示例#1
0
 /**
  * @see	JDeveloperCreate
  */
 protected function getLanguage($name = "")
 {
     $_name = "tpl_" . $this->item->name;
     $config = array("prefix" => "TPL_" . strtoupper($this->item->name));
     if (!empty($name)) {
         $_name .= "_" . $name;
     }
     return JDeveloperLanguage::getInstance($_name, $config);
 }
示例#2
0
 /**
  * @see	JDeveloperCreate
  */
 protected function getLanguage()
 {
     return JDeveloperLanguage::getStaticInstance("com_" . $this->component->name);
 }
示例#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)));
 }