From ea84496d83544e2e58ecdcdacec8a65bc6cc187a Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Sun, 13 Jun 2010 23:14:07 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=B0=20trunk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit +YUCHENG HU+ git-svn-id: https://svn.code.sf.net/p/hawebs/svn@319 a2543c7e-f6e9-4f8a-8bff-1ffc34733512 --- .../com_templates/admin.templates.html.php | 620 ++++++++++++++++++ .../com_templates/admin.templates.php | 101 +++ .../components/com_templates/controller.php | 500 ++++++++++++++ .../com_templates/helpers/index.html | 1 + .../com_templates/helpers/template.php | 120 ++++ .../components/com_templates/index.html | 1 + .../components/com_templates/templates.xml | 12 + .../com_templates/toolbar.templates.html.php | 77 +++ .../com_templates/toolbar.templates.php | 48 ++ 9 files changed, 1480 insertions(+) create mode 100644 oss/joomla/trunk/administrator/components/com_templates/admin.templates.html.php create mode 100644 oss/joomla/trunk/administrator/components/com_templates/admin.templates.php create mode 100644 oss/joomla/trunk/administrator/components/com_templates/controller.php create mode 100644 oss/joomla/trunk/administrator/components/com_templates/helpers/index.html create mode 100644 oss/joomla/trunk/administrator/components/com_templates/helpers/template.php create mode 100644 oss/joomla/trunk/administrator/components/com_templates/index.html create mode 100644 oss/joomla/trunk/administrator/components/com_templates/templates.xml create mode 100644 oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php create mode 100644 oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php diff --git a/oss/joomla/trunk/administrator/components/com_templates/admin.templates.html.php b/oss/joomla/trunk/administrator/components/com_templates/admin.templates.html.php new file mode 100644 index 00000000..650e0d2e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_templates/admin.templates.html.php @@ -0,0 +1,620 @@ +authorUrl) && $row->authorUrl != '') { + $row->authorUrl = str_replace('http://', '', $row->authorUrl); + } + + JHTML::_('behavior.tooltip'); +?> +
+ + + + + + + id == 1) { +?> + + + + + + + + + + + + + + + + + authorEmail . '
' . @ $row->authorUrl; +?> + + + + + id == 1) { +?> + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + get ('id'), $row->checked_out )) { +?> +   + + + + id == 1 ? JURI::root().'administrator' : $mainframe->getSiteURL() ).'/templates/'.$row->directory.'/template_thumbnail.png'; ?> + + name;?> + + published == 1) { +?> + <?php echo JText::_( 'Published' ); ?> + +   + + + published == 1) { +?> + <?php echo JText::_( 'Default' ); ?> + +   + + + assigned == 1) { +?> + <?php echo JText::_( 'Assigned' ); ?> + +   + + + version; ?> + + creationdate; ?> + + + author != '' ? $row->author : ' '; ?> + +
+ + + + + + +
+ id ? JURI::base() : $mainframe->getSiteURL(); +?> + + + + + + + + + + +
+ + + '_blank')); ?> +
+ 'previewFrame')) ?> +
+ +
+ + +
+ + + + + +

message); ?>

+ + + + + + + + + + + + + +
+ + + +
+ + + +
+
+ + +
+
+ + + + + + + + + + + +
+ : + + + name); ?> + +
+ : + + description); ?> +
+
+ +
+ + + + + + + + pages != 'all' && $client->id != 1) : ?> + + + + + +
+ : + + id == 1) { + echo JText::_('Cannot assign administrator template'); + } elseif ($row->pages == 'all') { + echo JText::_('Cannot assign default template'); + echo ''; + } elseif ($row->pages == 'none') { ?> + + + + + + +
+ : + + + pages == 'none') { ?> + + +
+
+
+ +
+
+ + path.$templatefile) ? JText::sprintf('PARAMSWRITABLE', $templatefile):JText::sprintf('PARAMSUNWRITABLE', $templatefile); ?> + + + + +
+ render(); + } else { + echo '' . JText :: _('No Parameters') . ''; + } +?> +
+
+
+
+ + + + + + +
+ path .DS. 'templates' .DS. $template .DS. 'index.php'; +?> +
+ + +
+ + + + + +

message); ?>

+ + + + + + + + + + + + + +
+ + + +
+ + + +
+
+ + + + + + + + + +
+ +
+ +
+ +
+ + + + + + + +
+ +
+ + + + + +
+   +
+ + + + + + + + + + + + + +
+ + + + + / +
+ + + + + '. JText::_( 'Writable' ) .'' : ' '. JText::_( 'Unwritable' ) .'' ?> +
+ + + + + + +
+ path.DS.'templates'.DS.$template.DS.'css'.DS.$filename; + +?> +
+ + +
+ + + + + +

message); ?>

+ + + + + + + + + + + + + +
+ + + +
+ + + +
+
+ + + + + + + + + +
+ +
+ +
+ + + + + + + + +
+ authorize('com_templates', 'manage')) { + $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); +} + +// Set the table directory +JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_templates'.DS.'tables'); + +// Import file dependencies +require_once (JPATH_COMPONENT.DS.'helpers'.DS.'template.php'); +require_once (JPATH_COMPONENT.DS.'controller.php'); + +$task = JRequest::getCmd('task'); + +$client = JRequest::getVar('client', 0, '', 'int'); + +if ($client == 1) { + JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0'); + JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1', true); +} elseif ($client == 0 && !$task) { + JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0', true); + JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1'); +} else { + JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0'); + JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1'); +} + +switch ($task) +{ + case 'edit' : + TemplatesController::editTemplate(); + break; + + case 'save' : + case 'apply' : + TemplatesController::saveTemplate(); + break; + + case 'edit_source' : + TemplatesController::editTemplateSource(); + break; + + case 'save_source' : + case 'apply_source' : + TemplatesController::saveTemplateSource(); + break; + + case 'choose_css' : + TemplatesController::chooseTemplateCSS(); + break; + + case 'edit_css' : + TemplatesController::editTemplateCSS(); + break; + + case 'save_css' : + case 'apply_css' : + TemplatesController::saveTemplateCSS(); + break; + + case 'publish' : + case 'default' : + TemplatesController::publishTemplate(); + break; + + case 'cancel' : + TemplatesController::cancelTemplate(); + break; + + case 'save_positions' : + TemplatesController::savePositions(); + break; + + case 'preview' : + TemplatesController::previewTemplate(); + break; + + default : + TemplatesController::viewTemplates(); + break; +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_templates/controller.php b/oss/joomla/trunk/administrator/components/com_templates/controller.php new file mode 100644 index 00000000..c5fa8fb9 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_templates/controller.php @@ -0,0 +1,500 @@ +getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest($option.'.'.$client->id.'.limitstart', 'limitstart', 0, 'int'); + + $select[] = JHTML::_('select.option', '0', JText::_('Site')); + $select[] = JHTML::_('select.option', '1', JText::_('Administrator')); + $lists['client'] = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $client->id); + + $tBaseDir = $client->path.DS.'templates'; + + //get template xml file info + $rows = array(); + $rows = TemplatesHelper::parseXMLTemplateFiles($tBaseDir); + + // set dynamic template information + for($i = 0; $i < count($rows); $i++) { + $rows[$i]->assigned = TemplatesHelper::isTemplateAssigned($rows[$i]->directory); + $rows[$i]->published = TemplatesHelper::isTemplateDefault($rows[$i]->directory, $client->id); + } + + jimport('joomla.html.pagination'); + $page = new JPagination(count($rows), $limitstart, $limit); + + $rows = array_slice($rows, $page->limitstart, $page->limit); + + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::showTemplates($rows, $lists, $page, $option, $client); + } + + /** + * Show the template with module position in an iframe + */ + function previewTemplate() + { + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + if (!$template) + { + return JError::raiseWarning( 500, JText::_('Template not specified') ); + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::previewTemplate($template, true, $client, $option); + } + + /** + * Publish, or make current, the selected template + */ + function publishTemplate() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db = & JFactory::getDBO(); + $cid = JRequest::getVar('cid', array(), 'method', 'array'); + $cid = array(JFilterInput::clean(@$cid[0], 'cmd')); + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + if ($cid[0]) + { + $query = 'DELETE FROM #__templates_menu' . + ' WHERE client_id = '.(int) $client->id . + ' AND (menuid = 0 OR template = '.$db->Quote($cid[0]).')'; + $db->setQuery($query); + $db->query(); + + $query = 'INSERT INTO #__templates_menu' . + ' SET client_id = '.(int) $client->id .', template = '.$db->Quote($cid[0]).', menuid = 0'; + $db->setQuery($query); + $db->query(); + } + + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); + } + + 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); + } + + function saveTemplate() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db = & JFactory::getDBO(); + + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $option = JRequest::getVar('option', '', '', 'cmd'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $menus = JRequest::getVar('selections', array(), 'post', 'array'); + $params = JRequest::getVar('params', array(), 'post', 'array'); + $default = JRequest::getBool('default'); + JArrayHelper::toInteger($menus); + + if (!$template) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + $ftp = JClientHelper::getCredentials('ftp'); + + $file = $client->path.DS.'templates'.DS.$template.DS.'params.ini'; + + jimport('joomla.filesystem.file'); + if (JFile::exists($file) && count($params)) + { + $registry = new JRegistry(); + $registry->loadArray($params); + $txt = $registry->toString(); + + // Try to make the params file writeable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file writable')); + } + + $return = JFile::write($file, $txt); + + // Try to make the params file unwriteable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file unwritable')); + } + + if (!$return) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); + } + } + + // Reset all existing assignments + $query = 'DELETE FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND template = '.$db->Quote( $template ); + $db->setQuery($query); + $db->query(); + + if ($default) { + $menus = array( 0 ); + } + + foreach ($menus as $menuid) + { + // If 'None' is not in array + if ((int) $menuid >= 0) + { + // check if there is already a template assigned to this menu item + $query = 'DELETE FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND menuid = '.(int) $menuid; + $db->setQuery($query); + $db->query(); + + $query = 'INSERT INTO #__templates_menu' . + ' SET client_id = 0, template = '. $db->Quote( $template ) .', menuid = '.(int) $menuid; + $db->setQuery($query); + $db->query(); + } + } + + $task = JRequest::getCmd('task'); + if($task == 'apply') { + $mainframe->redirect('index.php?option='.$option.'&task=edit&cid[]='.$template.'&client='.$client->id); + } else { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); + } + } + + function cancelTemplate() + { + global $mainframe; + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); + } + + function editTemplateSource() + { + global $mainframe; + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $file = $client->path.DS.'templates'.DS.$template.DS.'index.php'; + + // Read the source file + jimport('joomla.filesystem.file'); + $content = JFile::read($file); + + 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::editTemplateSource($template, $content, $option, $client, $ftp); + } else { + $msg = JText::sprintf('Operation Failed Could not open', $file); + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg); + } + } + + function saveTemplateSource() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW); + + if (!$template) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); + } + + if (!$filecontent) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.')); + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + $ftp = JClientHelper::getCredentials('ftp'); + + $file = $client->path.DS.'templates'.DS.$template.DS.'index.php'; + + // Try to make the template file writeable + if (!$ftp['enabled'] && !JPath::setPermissions($file, '0755')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file writable')); + } + + jimport('joomla.filesystem.file'); + $return = JFile::write($file, $filecontent); + + // Try to make the template file unwriteable + if (!$ftp['enabled'] && !JPath::setPermissions($file, '0555')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file unwritable')); + } + + if ($return) + { + $task = JRequest::getCmd('task'); + switch($task) + { + case 'apply_source': + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_source&id='.$template, JText::_('Template source saved')); + break; + + case 'save_source': + default: + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('Template source saved')); + break; + } + } + else { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); + } + } + + function chooseTemplateCSS() + { + global $mainframe; + + // Initialize some variables + $option = JRequest::getCmd('option'); + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + // Determine template CSS directory + $dir = $client->path.DS.'templates'.DS.$template.DS.'css'; + + // List template .css files + jimport('joomla.filesystem.folder'); + $files = JFolder::files($dir, '\.css$', false, false); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::chooseCSSFiles($template, $dir, $files, $option, $client); + } + + 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); + } + } + + function saveTemplateCSS() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $template = JRequest::getVar('id', '', 'post', 'cmd'); + $filename = JRequest::getVar('filename', '', 'post', 'cmd'); + $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW); + + if (!$template) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); + } + + if (!$filecontent) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.')); + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + $ftp = JClientHelper::getCredentials('ftp'); + + $file = $client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename; + + // Try to make the css file writeable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file writable')); + } + + jimport('joomla.filesystem.file'); + $return = JFile::write($file, $filecontent); + + // Try to make the css file unwriteable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file unwritable')); + } + + if ($return) + { + $task = JRequest::getCmd('task'); + switch($task) + { + case 'apply_css': + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_css&id='.$template.'&filename='.$filename, JText::_('File Saved')); + break; + + case 'save_css': + default: + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('File Saved')); + break; + } + } + else { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&id='.$template.'&task=choose_css', JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_templates/helpers/index.html b/oss/joomla/trunk/administrator/components/com_templates/helpers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_templates/helpers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php b/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php new file mode 100644 index 00000000..99ae4328 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php @@ -0,0 +1,120 @@ +setQuery($query); + $defaultemplate = $db->loadResult(); + + return $defaultemplate == $template ? 1 : 0; + } + + function isTemplateAssigned($template) + { + $db =& JFactory::getDBO(); + + // check if template is assigned + $query = 'SELECT COUNT(*)' . + ' FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND template = '.$db->Quote($template) . + ' AND menuid <> 0'; + $db->setQuery($query); + return $db->loadResult() ? 1 : 0; + } + + function parseXMLTemplateFiles($templateBaseDir) + { + // Read the template folder to find templates + jimport('joomla.filesystem.folder'); + $templateDirs = JFolder::folders($templateBaseDir); + + $rows = array(); + + // Check that the directory contains an xml file + foreach ($templateDirs as $templateDir) + { + if(!$data = TemplatesHelper::parseXMLTemplateFile($templateBaseDir, $templateDir)){ + continue; + } else { + $rows[] = $data; + } + } + + return $rows; + } + + function parseXMLTemplateFile($templateBaseDir, $templateDir) + { + // Check of the xml file exists + if(!is_file($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml')) { + return false; + } + + $xml = JApplicationHelper::parseXMLInstallFile($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml'); + + if ($xml['type'] != 'template') { + return false; + } + + $data = new StdClass(); + $data->directory = $templateDir; + + foreach($xml as $key => $value) { + $data->$key = $value; + } + + $data->checked_out = 0; + $data->mosname = JString::strtolower(str_replace(' ', '_', $data->name)); + + return $data; + } + + function createMenuList($template) + { + $db =& JFactory::getDBO(); + + // get selected pages for $menulist + $query = 'SELECT menuid AS value' . + ' FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND template = '.$db->Quote($template); + $db->setQuery($query); + $lookup = $db->loadObjectList(); + if (empty( $lookup )) { + $lookup = array( JHTML::_('select.option', '-1' ) ); + } + + // build the html select list + $options = JHTML::_('menu.linkoptions'); + $result = JHTML::_('select.genericlist', $options, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' ); + return $result; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_templates/index.html b/oss/joomla/trunk/administrator/components/com_templates/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_templates/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_templates/templates.xml b/oss/joomla/trunk/administrator/components/com_templates/templates.xml new file mode 100644 index 00000000..bdb42ed4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_templates/templates.xml @@ -0,0 +1,12 @@ + + + Template Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Template Manager + diff --git a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php new file mode 100644 index 00000000..04b9ee68 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php @@ -0,0 +1,77 @@ +id == '1') { + JToolBarHelper::makeDefault('publish'); + } else { + JToolBarHelper::makeDefault(); + } + JToolBarHelper::editListX( 'edit', 'Edit' ); + //JToolBarHelper::addNew(); + JToolBarHelper::help( 'screen.templates' ); + } + function _VIEW(&$client){ + + JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' ); + JToolBarHelper::back(); + } + + function _EDIT_SOURCE(&$client){ + + JToolBarHelper::title( JText::_( 'Template HTML Editor' ), 'thememanager' ); + JToolBarHelper::save( 'save_source' ); + JToolBarHelper::apply( 'apply_source' ); + JToolBarHelper::cancel('edit'); + JToolBarHelper::help( 'screen.templates' ); + } + + function _EDIT(&$client){ + JToolBarHelper::title( JText::_( 'Template' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'thememanager' ); + JToolBarHelper::custom('preview', 'preview.png', 'preview_f2.png', 'Preview', false, false); + JToolBarHelper::custom( 'edit_source', 'html.png', 'html_f2.png', 'Edit HTML', false, false ); + JToolBarHelper::custom( 'choose_css', 'css.png', 'css_f2.png', 'Edit CSS', false, false ); + JToolBarHelper::save( 'save' ); + JToolBarHelper::apply(); + JToolBarHelper::cancel( 'cancel', 'Close' ); + JToolBarHelper::help( 'screen.templates' ); + } + + function _CHOOSE_CSS(&$client){ + JToolBarHelper::title( JText::_( 'Template CSS Editor' ), 'thememanager' ); + JToolBarHelper::custom( 'edit_css', 'edit.png', 'edit_f2.png', 'Edit', true ); + JToolBarHelper::cancel('edit'); + JToolBarHelper::help( 'screen.templates' ); + } + + function _EDIT_CSS(&$client){ + JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' ); + JToolBarHelper::save( 'save_css' ); + JToolBarHelper::apply( 'apply_css'); + JToolBarHelper::cancel('choose_css'); + JToolBarHelper::help( 'screen.templates' ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php new file mode 100644 index 00000000..b6ce0ba3 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php @@ -0,0 +1,48 @@ +