Exemple #1
0
 public static 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');
     $default = TemplatesHelper::isTemplateDefault($row->directory, $client->id);
     if (TemplatesHelper::isTemplateDefault($row->directory, $client->id)) {
         $row->default = 1;
     } else {
         $row->default = 0;
     }
     // 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, array(), $params, $option, $client, $ftp, $template);
 }
Exemple #2
0
 function editTemplateCSS()
 {
     global $mainframe;
     // Initialize some variables
     $option = JRequest::getCmd('option');
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     $template = JRequest::getVar('id', '', 'method', 'cmd');
     $filename = JRequest::getVar('filename', '', 'method', 'cmd');
     jimport('joomla.filesystem.file');
     if (JFile::getExt($filename) !== 'css') {
         $msg = JText::_('Wrong file type given, only CSS files can be edited.');
         $mainframe->redirect('index.php?option=' . $option . '&client=' . $client->id . '&task=choose_css&id=' . $template, $msg, 'error');
     }
     $content = JFile::read($client->path . DS . 'templates' . DS . $template . DS . 'css' . DS . $filename);
     if ($content !== false) {
         // Set FTP credentials, if given
         jimport('joomla.client.helper');
         $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
         $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');
         require_once JPATH_COMPONENT . DS . 'admin.templates.html.php';
         TemplatesView::editCSSSource($template, $filename, $content, $option, $client, $ftp);
     } else {
         $msg = JText::sprintf('Operation Failed Could not open', $client->path . $filename);
         $mainframe->redirect('index.php?option=' . $option . '&client=' . $client->id, $msg);
     }
 }