Example #1
0
 /**
  * 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];
 }
Example #2
0
 /**
  * Uninstall components
  */
 public function uninstall()
 {
     // Check access
     $user = JFactory::getUser();
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=component', false));
     if (!$user->authorise('components.uninstall', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     require_once JDeveloperLIB . DS . 'install.php';
     $app = JFactory::getApplication();
     $ids = $app->input->get('cid', array(), 'array');
     foreach ($ids as $id) {
         $component = $this->getModel()->getItem($id);
         JDeveloperInstall::uninstall("component", "com_" . $component->name);
     }
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_COMPONENT_UNINSTALLED', count($ids)));
 }
Example #3
0
 /**
  * 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];
 }
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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");
     }
 }
Example #6
0
 /**
  * Import fields from xml file
  */
 public function fieldsFromForm()
 {
     JDeveloperLoader::import("install");
     $this->setRedirect(JRoute::_("index.php?option=com_jdeveloper&view=import&active=fields", false));
     $jform = $this->input->post->get("jform", array(), "array");
     if (empty($jform["table"])) {
         $this->setMessage(JText::_("COM_JDEVELOPER_IMPORT_ERROR_NO_TABLE_GIVEN"), "error");
         return;
     }
     // Get data
     $files = $this->input->files->get("jform", array(), "files");
     $manifest = JFile::upload($files["formfile"]["tmp_name"], JDeveloperINSTALL . "/import_fields.xml", false);
     $xml = new SimpleXMLElement(JDeveloperINSTALL . "/import_fields.xml", null, true);
     // Get fields from xml file
     $model = $this->getModel("ImportXml");
     if (false === ($fields = $model->getFields($xml, $jform["table"]))) {
         $this->setMessage(JText::_("COM_JDEVELOPER_IMPORT_MESSAGE_FIELDS_ERROR") . ": " . JText::_("COM_JDEVELOPER_IMPORT_ERROR_NO_FORM_FILE"), "error");
         JDeveloperInstall::cleanInstallDir();
         return;
     }
     // Save fields
     $model = $this->getModel("Field");
     foreach ($fields as $field) {
         if ($field["name"] == "id") {
             continue;
         }
         $model->save($field);
     }
     JDeveloperInstall::cleanInstallDir();
     $this->setMessage(JText::_("COM_JDEVELOPER_IMPORT_MESSAGE_FIELDS_SUCCESS"));
 }
Example #7
0
 /**
  * Uninstall modules
  */
 public function uninstall()
 {
     // Check access
     $user = JFactory::getUser();
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=module', false));
     if (!$user->authorise('modules.uninstall', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     // Initialize
     require_once JDeveloperLIB . DS . 'install.php';
     $app = JFactory::getApplication();
     $ids = $app->input->get('cid', array(), 'array');
     // Uninstall modules
     foreach ($ids as $id) {
         $module = $this->getModel()->getItem($id);
         JDeveloperInstall::uninstall("module", "mod_" . $module->name);
     }
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_MODULE_MESSAGE_UNINSTALLED', count($ids)));
 }
Example #8
0
 /**
  * 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)));
 }
Example #9
0
 /**
  * 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];
 }