示例#1
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));
 }
示例#2
0
 /**
  * Create ZIP file of plugins
  *
  * @param	array	$ids	The primary keys of the items
  */
 public function create($ids = array())
 {
     // Initialize
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=plugin', false));
     if (empty($ids)) {
         $ids = $app->input->get('cid', array(), 'array');
     }
     // Check access
     if (!$user->authorise('plugins.create', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     // Load classes
     JDeveloperLoader::import('archive');
     JDeveloperLoader::import('template');
     JDeveloperLoader::import('plugin', JDeveloperCREATE);
     jimport('joomla.filesystem.folder');
     // Create Plugin for each id
     foreach ($ids as $id) {
         $plugin = $this->getModel()->getItem($id);
         $path = $plugin->createDir;
         // Delete old archive if exists
         JFile::exists($path . '.zip') ? JFile::delete($path . '.zip') : null;
         // Create Plugin
         try {
             JDeveloperCreatePlugin::execute(array("item_id" => $id));
         } catch (JDeveloperException $e) {
             $this->setMessage($e->getMessage(), "error");
             return;
         }
         // Create HTML files for each folder, zip the folder and delete the folder
         JDeveloperArchive::html($path);
         // Create ZIP archive and delete folder
         JDeveloperArchive::zip($path);
         JFolder::delete($path);
     }
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_PLUGIN_MESSAGE_ZIP_CREATED', count($ids)));
 }
示例#3
0
 /**
  * Create component ids
  *
  * @param	array	$ids	The component 
  */
 public function create($ids = array())
 {
     // Initialize
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $this->setRedirect(JRoute::_('index.php?option=com_jdeveloper&view=component', false));
     if (empty($ids)) {
         $ids = $app->input->get('cid', array(), 'array');
     }
     // Check access
     if (!$user->authorise('components.create', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     // Load classes
     JDeveloperLoader::import('archive');
     JDeveloperLoader::import('template');
     JDeveloperLoader::import('component', JDeveloperCREATE);
     JDeveloperLoader::import('table', JDeveloperCREATE);
     jimport('joomla.filesystem.folder');
     // Create component for each id
     foreach ($ids as $id) {
         $component = $this->getModel()->getItem($id);
         $path = $component->createDir;
         // Delete old archive if exists
         JFile::exists($path . '.zip') ? JFile::delete($path . '.zip') : null;
         // Create component
         JDeveloperCreateComponent::execute("admin", array("item_id" => $id));
         JDeveloperCreateTable::execute("admin", array("item_id" => $id));
         // Create component for frontend
         if ($component->get('site', 0)) {
             JDeveloperCreateComponent::execute("site", array("item_id" => $id));
             JDeveloperCreateTable::execute("site", array("item_id" => $id));
         }
         // Get language files content
         $buffer = JDeveloperLanguage::getInstance("com_" . $component->name)->sort()->toINI();
         $buffer_sys = JDeveloperLanguage::getInstance("com_" . $component->name . "_sys")->sort()->toINI();
         // Write language files
         foreach ($component->params["languages"] as $lang) {
             JFile::write($component->createDir . "/admin/language/{$lang}.com_" . strtolower($component->name) . ".ini", $buffer);
             JFile::write($component->createDir . "/admin/language/{$lang}.com_" . strtolower($component->name) . ".sys.ini", $buffer_sys);
             $component->site ? JFile::write($component->createDir . "/site/language/{$lang}.com_" . strtolower($component->name) . ".ini", $buffer) : null;
         }
         // Create HTML files for each folder
         JDeveloperArchive::html($path . '/admin');
         (int) $component->get('site', 0) ? JDeveloperArchive::html($path . '/site') : null;
         // Create ZIP archive and delete folder
         JDeveloperArchive::zip($path);
         JFolder::delete($path);
     }
     $this->setMessage(JText::sprintf('COM_JDEVELOPER_COMPONENT_CREATED', count($ids)));
 }
示例#4
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);
 }