添加到 trunk

+YUCHENG HU+

git-svn-id: https://svn.code.sf.net/p/hawebs/svn@319 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-06-13 23:14:07 +00:00
parent eaef67c913
commit ea84496d83
9 changed files with 1480 additions and 0 deletions
@@ -0,0 +1,101 @@
<?php
/**
* @version $Id: admin.templates.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Templates
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/*
* Make sure the user is authorized to view this page
*/
$user = & JFactory::getUser();
if (!$user->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;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,120 @@
<?php
/**
* @version $Id: template.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Templates
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
/**
* @package Joomla
* @subpackage Templates
*/
class TemplatesHelper
{
function isTemplateDefault($template, $clientId)
{
$db =& JFactory::getDBO();
// Get the current default template
$query = ' SELECT template '
.' FROM #__templates_menu '
.' WHERE client_id = ' . (int) $clientId
.' AND menuid = 0 ';
$db->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;
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<install type="component" version="1.0.0">
<name>Template Manager</name>
<author>Joomla! Project</author>
<creationDate>2006</creationDate>
<copyright>Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>1.5.0</version>
<description>Template Manager</description>
</install>
@@ -0,0 +1,77 @@
<?php
/**
* @version $Id: toolbar.templates.html.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Templates
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
/**
* @package Joomla
* @subpackage Templates
*/
class TOOLBAR_templates
{
function _DEFAULT(&$client)
{
JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' );
if ($client->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' ) . ': <small><small>[ '. JText::_( 'Edit' ) .' ]</small></small>', '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' );
}
}
@@ -0,0 +1,48 @@
<?php
/**
* @version $Id: toolbar.templates.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Templates
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
require_once( JApplicationHelper::getPath( 'toolbar_html' ) );
$client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
switch ($task)
{
case 'view' :
case 'preview':
TOOLBAR_templates::_VIEW($client);
break;
case 'edit_source':
TOOLBAR_templates::_EDIT_SOURCE($client);
break;
case 'edit':
TOOLBAR_templates::_EDIT($client);
break;
case 'choose_css':
TOOLBAR_templates::_CHOOSE_CSS($client);
break;
case 'edit_css':
TOOLBAR_templates::_EDIT_CSS($client);
break;
default:
TOOLBAR_templates::_DEFAULT($client);
break;
}