Beispiel #1
0
 function editTemplate()
 {
     jimport('joomla.filesystem.path');
     // Initialize some variables
     $db =& JFactory::getDBO();
     $cid = JRequest::getVar('cid', array(), 'method', 'array');
     $cid = array(JFilterInput::clean(@$cid[0], 'cmd'));
     $template = $cid[0];
     $option = JRequest::getCmd('option');
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     if (!$cid[0]) {
         return JError::raiseWarning(500, JText::_('Template not specified'));
     }
     $tBaseDir = JPath::clean($client->path . DS . 'templates');
     if (!is_dir($tBaseDir . DS . $template)) {
         return JError::raiseWarning(500, JText::_('Template not found'));
     }
     $lang =& JFactory::getLanguage();
     $lang->load('tpl_' . $template, JPATH_ADMINISTRATOR);
     $ini = $client->path . DS . 'templates' . DS . $template . DS . 'params.ini';
     $xml = $client->path . DS . 'templates' . DS . $template . DS . 'templateDetails.xml';
     $row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $template);
     jimport('joomla.filesystem.file');
     // Read the ini file
     if (JFile::exists($ini)) {
         $content = JFile::read($ini);
     } else {
         $content = null;
     }
     $params = new JParameter($content, $xml, 'template');
     $assigned = TemplatesHelper::isTemplateAssigned($row->directory);
     $default = TemplatesHelper::isTemplateDefault($row->directory, $client->id);
     if ($client->id == '1') {
         $lists['selections'] = JText::_('Cannot assign an administrator template');
     } else {
         $lists['selections'] = TemplatesHelper::createMenuList($template);
     }
     if ($default) {
         $row->pages = 'all';
     } elseif (!$assigned) {
         $row->pages = 'none';
     } else {
         $row->pages = null;
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
     require_once JPATH_COMPONENT . DS . 'admin.templates.html.php';
     TemplatesView::editTemplate($row, $lists, $params, $option, $client, $ftp, $template);
 }