Exemplo n.º 1
0
 /**
  * Create ZIP file of modules
  *
  * @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=module', false));
     empty($ids) ? $ids = $app->input->get('cid', array(), 'array') : null;
     // Check access
     if (!$user->authorise('modules.create', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     // Load classes
     JDeveloperLoader::import('archive');
     JDeveloperLoader::import('template');
     JDeveloperLoader::import('module', JDeveloperCREATE);
     jimport('joomla.filesystem.folder');
     // Create module for each id
     foreach ($ids as $id) {
         $module = $this->getModel()->getItem($id);
         $path = $module->createDir;
         // Delete old archive if exists
         JFile::exists($path . '.zip') ? JFile::delete($path . '.zip') : null;
         // Create module
         try {
             JDeveloperCreateModule::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_MODULE_MESSAGE_ZIP_CREATED', count($ids)));
 }
Exemplo n.º 2
0
 /**
  * The constructor
  */
 public function __construct($config = array())
 {
     parent::__construct();
     $app = JFactory::getApplication();
     if (!isset($config['item_id']) || empty($config['item_id'])) {
         throw new JDeveloperException($this->_name . ": No module id given");
     }
     // Get module data
     $this->item = $this->getModel('module')->getItem($config['item_id']);
     // Create module directory
     $this->createDir = $this->item->createDir;
     // Set template base dirs
     $this->templateDirs[0] = JDeveloperXTD . "/templates/module";
     $this->templateDirs[1] = JDeveloperTEMPLATES . "/module";
     $this->template = $this->getTemplate();
     if ($this->template === false) {
         throw new JDeveloperException($this->getErrors());
     }
     // Get the template header
     $params = JComponentHelper::getParams('com_jdeveloper');
     $header = new JDeveloperTemplate(JDeveloperTEMPLATES . '/fileheader.txt');
     $header->addPlaceholders(array('Author' => $params->get('author'), 'Copyright' => $params->get('copyright'), 'License' => $params->get('license'), 'Version' => $this->item->version, 'Extension' => ucfirst($this->item->display_name)));
     self::$templateHeader = $header->getBuffer();
 }
Exemplo n.º 3
0
 public function initialize()
 {
     $this->template->addPlaceHolders(array("configfields" => $this->getConfigFields(), "configform" => $this->getForm($this->item->form_id), "languages" => $this->lang()));
     return parent::initialize();
 }
Exemplo n.º 4
0
 public function initialize()
 {
     $this->template->addPlaceHolders(array('thead' => $this->thead(), 'tbody' => $this->tbody()));
     return parent::initialize();
 }