Ejemplo n.º 1
0
 /**
  * The constructor
  */
 public function __construct($config = array())
 {
     parent::__construct();
     $app = JFactory::getApplication();
     if (!isset($config['item_id']) || empty($config['item_id'])) {
         throw new Exception($this->_name . ": No library id given");
     }
     // Get plugin data
     $this->item = $this->getModel('library')->getItem($config['item_id']);
     $this->type = "lib_" . strtolower($this->item->name);
     // Create plugin directory
     $this->createDir = $this->item->createDir;
     // Set template base dirs
     $this->templateDirs[0] = JDeveloperXTD . "/templates/library";
     $this->templateDirs[1] = JDeveloperTEMPLATES . "/library";
     $this->template = $this->getTemplate();
     if ($this->template === false) {
         throw new JDeveloperException("No template found<br>" . $this->getErrors());
     }
     // Get the plugin header
     $params = JComponentHelper::getParams('com_jdeveloper');
     $header = new JDeveloperTemplate(JDeveloperTEMPLATES . DS . 'fileheader.txt');
     $header->addPlaceholders(array('Author' => $params->get('author'), 'Copyright' => $params->get('copyright'), 'Extension' => ucfirst($this->item->name), 'License' => $params->get('license'), 'Version' => $this->item->version));
     self::$templateHeader = $header->getBuffer();
 }
Ejemplo n.º 2
0
 /**
  * Create ZIP file of libraries
  *
  * @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=library', false));
     empty($ids) ? $ids = $app->input->get('cid', array(), 'array') : null;
     // Check access
     if (!$user->authorise('libraries.create', 'com_jdeveloper')) {
         $this->setMessage(JText::_('COM_JDEVELOPER_ACTION_NOT_ALLOWED'), 'warning');
         return;
     }
     // Load classes
     JDeveloperLoader::import('archive');
     JDeveloperLoader::import('template');
     JDeveloperLoader::import('library', JDeveloperCREATE);
     jimport('joomla.filesystem.folder');
     // Create library for each id
     foreach ($ids as $id) {
         $library = $this->getModel()->getItem($id);
         $path = $library->createDir;
         // Delete old archive if exists
         JFile::exists($path . '.zip') ? JFile::delete($path . '.zip') : null;
         // Create library
         try {
             JDeveloperCreateLibrary::execute(array("item_id" => $id));
         } catch (Exception $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_LIBRARY_MESSAGE_ZIP_CREATED', count($ids)));
 }
Ejemplo n.º 3
0
 protected function initialize()
 {
     $this->template->addPlaceHolders(array("author" => $this->item->get('author'), "author_email" => $this->item->get('author_email'), "author_url" => $this->item->get('author_url'), "copyright" => $this->item->get('copyright'), "creationdate" => date("M Y"), "licence" => $this->item->get('licence'), "languages" => $this->lang(), "version" => $this->item->get('version')));
     return parent::initialize();
 }