/** * Install components */ public function install() { // Check access $user = JFactory::getUser(); $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=component', false)); // Check if action is allowed if (!$user->authorise('components.install', 'com_jdeveloper')) { $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning'); return; } jimport('joomla.filesystem.folder'); require_once JDeveloperLIB . DS . 'install.php'; $app = JFactory::getApplication(); $ids = $app->input->get('cid', array(), 'array'); // Install components foreach ($ids as $id) { $component = $this->getModel()->getItem($id); $path = $component->createDir . '.zip'; $this->create(array($id)); if (JDeveloperInstall::isInstalled('component', 'com_' . $component->name)) { JDeveloperInstall::install($path, true); } else { JDeveloperInstall::install($path); } } $this->setMessage(JText::sprintf('COM_JDEVELOPER_COMPONENT_INSTALLED', count($ids))); }
/** * Method to get an array of data items. * * @return array An array of data items * * @since 12.2 */ public function getItems() { JDeveloperLoader::import("archive"); $extension = JTable::getInstance("Extension", "JTable"); // Get a storage key. $store = $this->getStoreId('getItems'); // Load the list items. $items = parent::getItems(); // Add information foreach ($items as $item) { // Is Component already installed? $item->createDir = JDeveloperArchive::getArchiveDir() . "/" . JDeveloperArchive::getArchiveName("mod_", $item->name, $item->version); $item->installed = JDeveloperInstall::isInstalled("module", "mod_" . $item->name); if ($item->installed) { $extension->load(array("name" => "mod_" . $item->name, "type" => "module")); $item->enabled = (bool) $extension->enabled; } else { $item->enabled = false; } } // If emtpy or an error, just return. if (empty($items)) { return array(); } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }
/** * Method to get an array of data items. * * @return array An array of data items * * @since 12.2 */ public function getItems() { require_once JDeveloperLIB . DS . 'archive.php'; // Get a storage key. $store = $this->getStoreId('getItems'); // Load the list items. $items = parent::getItems(); // Add information foreach ($items as $item) { // Is Component already installed? $item->installed = JDeveloperInstall::isInstalled("template", $item->name); $item->createDir = JDeveloperArchive::getArchiveDir() . "/" . JDeveloperArchive::getArchiveName("tpl_", $item->name, $item->version); } // If emtpy or an error, just return. if (empty($items)) { return array(); } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }
/** * Method to get a single record. * * @param integer $pk The id of the primary key. * * @return mixed Object on success, false on failure. * * @since 12.2 */ public function getItem($pk = null) { $app = JFactory::getApplication(); $itemId = $this->getState("data.id", 0); $layout = $app->input->get("layout", "default", "string"); if (empty($pk) && $layout == "default" && !empty($itemId)) { $pk = $itemId; } if (false === ($item = parent::getItem($pk))) { return false; } // Get related config form id $table = JTable::getInstance("Form", "JDeveloperTable"); if ($table->load(array("tag" => "config", "relation" => "module." . $item->id . ".config"), true)) { $item->form_id = $table->id; } else { $item->form_id = 0; } $item->installed = JDeveloperInstall::isInstalled("module", "mod_" . $item->name); $item->createDir = JDeveloperArchive::getArchiveDir() . "/" . JDeveloperArchive::getArchiveName("mod_", $item->name, $item->version); $params = JComponentHelper::getParams("com_jdeveloper"); if (empty($item->params['author'])) { $item->params['author'] = $params->get("author", ""); } if (empty($item->params['author_email'])) { $item->params['author_email'] = $params->get("author_email", ""); } if (empty($item->params['author_url'])) { $item->params['author_url'] = $params->get("author_url", ""); } if (empty($item->params['copyright'])) { $item->params['copyright'] = $params->get("copyright", ""); } if (empty($item->params['license'])) { $item->params['license'] = $params->get("license", ""); } return $item; }
/** * Install table */ public function install() { $user = JFactory::getUser(); // Check if action is allowed if (!$user->authorise('components.install', 'com_jdeveloper')) { $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning'); return; } // Get table data $app = JFactory::getApplication(); $id = $app->input->get('id', 0, 'int'); $model = JModelLegacy::getInstance("Table", "JDeveloperModel"); $item = $model->getItem($id); $component = JModelLegacy::getInstance("Component", "JDeveloperModel")->getItem($item->component); $this->setRedirect(JRoute::_("index.php?option=com_jdeveloper&view=component&id=" . $component->id, false)); // If component is installed, install table if (JDeveloperInstall::isInstalled('component', 'com_' . $component->name)) { // If table is already installed, the procedure is finished here if ($model->isInstalled($item->id)) { return; } // Get SQL code of table and send SQL install query to database $sql = JDeveloperCreate::getInstance("table.admin.sql", array("item_id" => $item->id))->getBuffer(); $db = JFactory::getDbo(); $db->setQuery($sql)->execute(); $this->setMessage("COM_JDEVELOPER_TABLE_MESSAGE_TABLE_INSTALLED", "error"); } else { $this->setMessage("COM_JDEVELOPER_TABLE_MESSAGE_COMPONENT_NOT_INSTALLED", "error"); } }
/** * Install templates */ public function install() { // Check access $user = JFactory::getUser(); $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=template', false)); if (!$user->authorise('templates.install', 'com_jdeveloper')) { $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning'); return; } // Initialize jimport('joomla.filesystem.folder'); require_once JDeveloperLIB . '/install.php'; $app = JFactory::getApplication(); $ids = $app->input->get('cid', array(), 'array'); // Install templates foreach ($ids as $id) { $template = $this->getModel()->getItem($id); $path = $template->createDir . ".zip"; $this->create(array($id)); if (JDeveloperInstall::isInstalled('template', $template->name)) { JDeveloperInstall::install($path, true); } else { JDeveloperInstall::install($path); } } $this->setMessage(JText::sprintf('COM_JDEVELOPER_TEMPLATE_MESSAGE_INSTALLED', count($ids))); }
/** * Install packages */ public function install() { require_once JDeveloperLIB . DS . 'install.php'; $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=packages', false)); $app = JFactory::getApplication(); $user = JFactory::getUser(); if (!$user->authorise('packages.install', 'com_jdeveloper')) { $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning'); return; } $files = $app->input->get('cid', array(), 'array'); foreach ($files as $file) { preg_match("/pkg_[A-Za-z_]*/", $file, $matches); $path = JDeveloperARCHIVE . "/" . $file; JDeveloperInstall::install($path, JDeveloperInstall::isInstalled('package', $matches[0])); } $this->setMessage(JText::sprintf('COM_JDEVELOPER_PACKAGE_INSTALLATION_SUCCESS', count($files))); }
/** * Method to get an array of data items. * * @return array An array of data items * * @since 12.2 */ public function getItems() { require_once JDeveloperLIB . DS . 'archive.php'; // Get a storage key. $store = $this->getStoreId('getItems'); // Load the list items. $items = parent::getItems(); // If emtpy or an error, just return. if (empty($items)) { return array(); } // Get the ids and names of the components $db = JFactory::getDbo(); // Add information foreach ($items as $item) { $query = $db->getQuery(true)->select('COUNT(*)')->from('#__jdeveloper_tables AS t')->where('t.component = "' . $db->escape($item->id) . '"'); $db->setQuery($query); $item->numberOfTables = $db->loadResult(); // Get the main table $query2 = $db->getQuery(true)->select('name')->from('#__jdeveloper_tables As t')->where('t.component = ' . $db->quote($item->id))->order('t.ordering', 'asc'); $db->setQuery($query2); $result = $db->loadAssoc(); $item->maintable = $result['name']; // Is Component already installed? $item->installed = JDeveloperInstall::isInstalled("component", "com_" . $item->name); } // Get the params as an array foreach ($items as $item) { $item->createDir = JDeveloperArchive::getArchiveDir() . "/" . JDeveloperArchive::getArchiveName("com_", $item->name, $item->version); $registry = new JRegistry(); $registry->loadString($item->params); $item->params = $registry->toArray(); } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }