Skip to content

Commit

Permalink
Issue #000 feat: Initial commit com_cluster (#1)
Browse files Browse the repository at this point in the history
* Issue #000 feat: Initial commit com_cluster

* Issue #000 feat: Initial commit com_cluster
  • Loading branch information
praneettekdi authored and manojLondhe committed May 24, 2019
1 parent 8b1dee8 commit cd02980
Show file tree
Hide file tree
Showing 72 changed files with 3,332 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/com_cluster/administrator/access.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<access component="com_cluster">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
</section>
</access>
27 changes: 27 additions & 0 deletions src/components/com_cluster/administrator/cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* @package Cluster
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController;

\JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR);

$document = Factory::getDocument();
$script = 'const root_url = "' . Juri::root() . '";';
$document->addScriptDeclaration($script, 'text/javascript');

\JLoader::registerPrefix('Cluster', JPATH_ADMINISTRATOR);
\JLoader::register('ClusterController', JPATH_ADMINISTRATOR . '/controller.php');

// Execute the task.
$controller = BaseController::getInstance('Cluster');
$controller->execute(Factory::getApplication()->input->get('task'));
$controller->redirect();
6 changes: 6 additions & 0 deletions src/components/com_cluster/administrator/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset name="permissions" description="JCONFIG_PERMISSIONS_DESC" label="JCONFIG_PERMISSIONS_LABEL">
<field name="rules" type="rules" component="com_cluster" class="inputbox" filter="rules" validate="rules" label="JCONFIG_PERMISSIONS_LABEL" section="component" />
</fieldset>
</config>
43 changes: 43 additions & 0 deletions src/components/com_cluster/administrator/controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* @package Cluster
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController;

\JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR);
\JLoader::register('ClusterHelper', __DIR__ . '/helpers/cluster.php');

/**
* Class ClusterController
*
* @since 1.0.0
*/
class ClusterController extends BaseController
{
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param mixed $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @since 1.0.0
*/
public function display($cachable = false, $urlparams = false)
{
$app = Factory::getApplication();
$view = $app->input->getCmd('view', 'clusters');
$app->input->set('view', $view);

return parent::display($cachable, $urlparams);
}
}
21 changes: 21 additions & 0 deletions src/components/com_cluster/administrator/controllers/cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @package Cluster
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\FormController;

/**
* The cluster controller
*
* @since 1.0.0
*/
class ClusterControllerCluster extends FormController
{
}
35 changes: 35 additions & 0 deletions src/components/com_cluster/administrator/controllers/clusters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @package Cluster
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\MVC\Controller\AdminController;

/**
* Clusters list controller class.
*
* @since 1.0.0
*/
class ClusterControllerClusters extends AdminController
{
/**
* Proxy for getModel.
*
* @param STRING $name model name
* @param STRING $prefix model prefix
*
* @return Joomla\CMS\MVC\Model\BaseDatabaseModel
*
* @since 1.0.0
*/
public function getModel($name = 'Cluster', $prefix = 'ClusterModel')
{
return parent::getModel($name, $prefix, array('ignore_request' => true));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @package Cluster
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\FormController;

/**
* The Cluster user controller
*
* @since 1.0.0
*/
class ClusterControllerClusterUser extends FormController
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @package Cluster
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\AdminController;

/**
* Cluster Users controller class.
*
* @since 1.0.0
*/
class ClusterControllerClusterUsers extends AdminController
{
/**
* Proxy for getModel.
*
* @param STRING $name model name
* @param STRING $prefix model prefix
*
* @return Joomla\CMS\MVC\Model\BaseDatabaseModel |boolean Model object on success; otherwise false on failure.
*
* @since 1.0.0
*/
public function getModel($name = 'ClusterUser', $prefix = 'ClusterModel')
{
return parent::getModel($name, $prefix, array('ignore_request' => true));
}
}
Empty file.
85 changes: 85 additions & 0 deletions src/components/com_cluster/administrator/helpers/cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* @package Cluster
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;

/**
* Cluster helper.
*
* @since 1.0.0
*/
class ClusterHelper
{
/**
* Configure the Linkbar.
*
* @param string $vName view name string
*
* @return void
*/
public static function addSubmenu($vName = '')
{
$app = Factory::getApplication();
$layout = $app->input->get('layout', '', 'STRING');

if ($layout != "default")
{
JHtmlSidebar::addEntry(
JText::_('COM_CLUSTERS_VIEW_CLUSTERS'),
'index.php?option=com_cluster&view=clusters',
$vName == 'clusters'
);

JHtmlSidebar::addEntry(
JText::_('COM_CLUSTERS_VIEW_CLUSTER_USERS'),
'index.php?option=com_cluster&view=clusterusers',
$vName == 'clusterusers'
);
}
else
{
$client = $app->input->get('client', '', 'STRING');

// Set ordering.
$fullClient = explode('.', $client);

// Eg com_jgive
$component = $fullClient[0];
$eName = str_replace('com_', '', $component);
$file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');

if (file_exists($file))
{
require_once $file;

$prefix = ucfirst(str_replace('com_', '', $component));
$cName = $prefix . 'Helper';

if (class_exists($cName))
{
if (is_callable(array($cName, 'addSubmenu')))
{
$lang = Factory::getLanguage();

// Loading language file from the administrator/language directory then
// Loading language file from the administrator/components/*extension*/language directory
$lang->load($component, JPATH_BASE, null, false, false)
|| $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), null, false, false)
|| $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false)
|| $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), $lang->getDefault(), false, false);

call_user_func(array($cName, 'addSubmenu'), $vName);
}
}
}
}
}
}
62 changes: 62 additions & 0 deletions src/components/com_cluster/administrator/includes/cluster.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* @package Cluster
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die();

use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Table\Table;

JLoader::discover("Cluster", JPATH_ADMINISTRATOR . '/components/com_cluster/libraries');

/**
* Cluster factory class.
*
* This class perform the helpful operation for truck app
*
* @since 1.0.0
*/
class ClusterFactory
{
/**
* Retrieves a table from the table folder
*
* @param string $name The table file name
*
* @return Table object
*
* @since 1.0.0
**/
public static function table($name)
{
// @TODO Improve file loading with specific table file.

Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_cluster/tables');

// @TODO Add support for cache
return Table::getInstance($name, 'ClusterTable');
}

/**
* Retrieves a model from the model folder
*
* @param string $name The model name to instantiate
* @param array $config Configuration array for model. Optional.
*
* @return BaseDatabaseModel object
*
* @since 1.0.0
**/
public static function model($name, $config = array())
{
BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_cluster/models');

// @TODO Add support for cache
return BaseDatabaseModel::getInstance($name, 'ClusterModel', $config);
}
}
Empty file.
Loading

0 comments on commit cd02980

Please sign in to comment.