Example #1
1
 /**
  * Method to get an array of data items.
  *
  * @return  array  An array of data items
  *
  * @since   12.2
  */
 public function getItems()
 {
     jimport('joomla.filesystem.folder');
     $items = array();
     $files = JFolder::files(JDeveloperArchive::getArchiveDir());
     $store = $this->getStoreId('getItems');
     foreach ($files as $file) {
         if (preg_match('/(^pkg_).*(.zip$)/', $file)) {
             $item = new JObject();
             $item->set('id', $file);
             $item->set('name', $file);
             $item->set('created', date("Y M d - H:i:s", filemtime(JDeveloperArchive::getArchiveDir() . DS . $file)));
             $item->createDir = JDeveloperArchive::getArchiveDir() . "/" . JDeveloperArchive::getArchiveName("pkg_", $item->name, $item->get("version", "1.0.0"));
             $content = array();
             if (!($zip = zip_open(JDeveloperArchive::getArchiveDir() . DS . $file))) {
                 throw new Exception("Failed to open {$file}");
             }
             while ($zip_entry = zip_read($zip)) {
                 if (preg_match('/.zip$/', zip_entry_name($zip_entry))) {
                     $content[] = zip_entry_name($zip_entry);
                 }
             }
             $item->set('content', implode('<br>', $content));
             $items[] = $item;
         }
     }
     // Add the items to the internal cache.
     $this->cache['packages'] = $items;
     return $this->cache['packages'];
 }
Example #2
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 #3
0
 public static function archives($prefix, $name)
 {
     $html = "";
     if (count(JDeveloperArchive::getVersions($prefix, $name))) {
         foreach (JDeveloperArchive::getVersions($prefix, $name) as $file) {
             $download = JDeveloperArchive::getArchiveDir(true) . "/{$file}";
             $html .= '<a href="' . $download . '" class="hasTooltip" title="' . JText::_('COM_JDEVELOPER_COMPONENT_DOWNLOAD') . '">' . $file . '</a> - <span style="color:#999999;">' . date("Y.m.d H:i", filemtime(JDeveloperArchive::getArchiveDir() . "/{$file}")) . '</span><br>';
         }
     } else {
         $html .= '<i class="icon-unpublish"></i>';
     }
     return $html;
 }
Example #4
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     jimport('joomla.filesystem.folder');
     $files = JFolder::files(JDeveloperArchive::getArchiveDir(), "\\.zip\$");
     $options = array();
     foreach ($files as $file) {
         // Create a new option object based on the <option /> element.
         $tmp = JHtml::_('select.option', $file, $file);
         // Add the option object to the result set.
         $options[] = $tmp;
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Example #5
0
 /**
  * Method to get an array of data items.
  *
  * @return  array  An array of data items
  *
  * @since   12.2
  */
 public function getItems()
 {
     jimport("joomla.filesystem.folder");
     require_once JDeveloperLIB . DS . 'archive.php';
     $store = $this->getStoreId('getItems');
     $items = array();
     $files = JFolder::files(JDeveloperArchive::getArchiveDir(), "^(com|mod|pkg|plg|tpl)_[A-Za-z0-9-_]*_v[0-9.]*\\.zip\$");
     // Get archives
     foreach ($files as $file) {
         $archive = new JObject();
         $archive->name = $file;
         $archive->link = JDeveloperArchive::getArchiveDir(true) . "/" . $file;
         $items[] = $archive;
     }
     // Add the items to the internal cache.
     $this->cache[$store] = $items;
     return $this->cache[$store];
 }
Example #6
0
 /**
  * Create a package
  */
 public function create()
 {
     jimport('joomla.filesystem.folder');
     require_once JDeveloperLIB . '/archive.php';
     require_once JDeveloperLIB . '/path.php';
     require_once JDeveloperLIB . '/template.php';
     $data = $this->input->post->get('jform', array(), 'array');
     $params = JComponentHelper::getParams($this->option);
     $files = array();
     $path = JDeveloperArchive::getArchiveDir() . "/" . 'pkg_' . $data['name'];
     while (JFile::exists($path . '.zip')) {
         $data['name'] = JString::increment($data['name']);
     }
     JFolder::create($path);
     foreach ($data['files'] as $file) {
         if (preg_match('/^pkg_/', $file)) {
             $files[] = "<file type=\"package\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         if (preg_match('/^com_/', $file)) {
             $files[] = "<file type=\"component\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         if (preg_match('/^mod_/', $file)) {
             $files[] = "<file type=\"module\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         if (preg_match('/^tpl_/', $file)) {
             $files[] = "<file type=\"template\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         if (preg_match('/^plg_/', $file)) {
             $files[] = "<file type=\"plugin\" id=\"" . str_replace('.zip', '', $file) . "\">{$file}</file>";
         }
         JFile::copy(JDeveloperArchive::getArchiveDir() . DS . $file, $path . DS . $file, null, true);
     }
     $template = new JDeveloperTemplate(JDeveloperTEMPLATES . "/pkg/manifest.xml");
     $template->addPlaceholders(array('author' => $params->get('author'), 'author_email' => $params->get('email'), 'author_url' => $params->get('website'), 'copyright' => $params->get('copyright'), 'date' => date("M Y"), 'description' => $data['description'], 'files' => implode("\n\t\t", $files), 'license' => $params->get('license'), 'name' => $data['name'], 'version' => $data['version']));
     $buffer = $template->getBuffer();
     JFile::write($path . '/pkg_' . $data['name'] . '.xml', $buffer);
     JDeveloperArchive::html($path);
     JDeveloperArchive::zip($path);
     JFolder::delete($path);
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_PACKAGE_CREATED', $data['name']));
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=packages', false));
 }
Example #7
0
 /**
  * Delete ZIP files of modules
  */
 public function deletezip()
 {
     require_once JDeveloperLIB . "/archive.php";
     // Check access
     $user = JFactory::getUser();
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=module', false));
     if (!$user->authorise('modules.deletezip', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     $app = JFactory::getApplication();
     $ids = $app->input->get('cid', array(), 'array');
     foreach ($ids as $id) {
         $module = $this->getModel()->getItem($id);
         $files = JDeveloperArchive::getVersions("mod_", $module->name);
         foreach ($files as $file) {
             JFile::delete($module->createDir . ".zip");
         }
     }
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_MODULE_MESSAGE_ZIP_DELETED', count($ids)));
 }
Example #8
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 #9
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 #10
0
 /**
  * Delete ZIP files of component
  */
 public function deletezip()
 {
     // Check access
     $user = JFactory::getUser();
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=component', false));
     if (!$user->authorise('components.deletezip', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     $app = JFactory::getApplication();
     $ids = $app->input->get('cid', array(), 'array');
     foreach ($ids as $id) {
         $component = $this->getModel()->getItem($id);
         $files = JDeveloperArchive::getVersions("com_", $component->name);
         foreach ($files as $file) {
             JFile::delete(JDeveloperArchive::getArchiveDir() . "/" . $file);
         }
     }
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_COMPONENT_ZIP_DELETED', count($ids)));
 }
Example #11
0
 private function plugin($id)
 {
     $extension = JModelLegacy::getInstance("Extension", "JDeveloperModel")->getItem($id);
     $extension_file = 'plg_' . $extension->folder . '_' . $extension->element;
     if (!JFolder::exists(JPATH_PLUGINS . DS . $extension->folder . DS . $extension->element)) {
         throw new Exception(JText::sprintf('COM_JDEVELOPER_LIVE_EXTENSION_NOT_FOUND', JText::_('COM_JDEVELOPER_LIVE_FIELD_TYPE_PLUGIN'), $extension->name));
     }
     $PATH_PLG = JPATH_PLUGINS . DS . $extension->folder . DS . $extension->element;
     if (!JFolder::copy($PATH_PLG, JDeveloperLIVE . DS . $extension_file, '', true, true)) {
         throw new Exception(JText::sprintf('COM_JDEVELOPER_LIVE_COPY_FAILED', JText::_('COM_JDEVELOPER_LIVE_FIELD_TYPE_PLUGIN'), $extension->name));
     }
     JDeveloperArchive::copyLanguageToArchive($extension_file, 'language', 'admin');
     JDeveloperArchive::html(JDeveloperLIVE . DS . $extension_file);
     JDeveloperArchive::zip(JDeveloperLIVE . DS . $extension_file);
     JFolder::delete(JDeveloperLIVE . DS . $extension_file);
 }
Example #12
0
 /**
  * Fill every folder of this component with HTML file
  *
  * @note	Only important for developer of this component
  */
 public function html()
 {
     require_once JDeveloperLIB . "/archive.php";
     JDeveloperArchive::html(JPATH_COMPONENT);
     echo "HTML files created";
 }
Example #13
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];
 }