You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
*/
|
||||
class JHtmlTemplates
|
||||
{
|
||||
/**
|
||||
* Display the thumb for the template.
|
||||
*
|
||||
* @param string The name of the active view.
|
||||
*/
|
||||
public static function thumb($template, $clientId = 0)
|
||||
{
|
||||
$client = JApplicationHelper::getClientInfo($clientId);
|
||||
$basePath = $client->path . '/templates/' . $template;
|
||||
$baseUrl = ($clientId == 0) ? JUri::root(true) : JUri::root(true) . '/administrator';
|
||||
$thumb = $basePath . '/template_thumbnail.png';
|
||||
$preview = $basePath . '/template_preview.png';
|
||||
$html = '';
|
||||
|
||||
if (file_exists($thumb))
|
||||
{
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
JHtml::_('behavior.modal');
|
||||
|
||||
$clientPath = ($clientId == 0) ? '' : 'administrator/';
|
||||
$thumb = $clientPath . 'templates/' . $template . '/template_thumbnail.png';
|
||||
$html = JHtml::_('image', $thumb, JText::_('COM_TEMPLATES_PREVIEW'));
|
||||
if (file_exists($preview))
|
||||
{
|
||||
$preview = $baseUrl . '/templates/' . $template . '/template_preview.png';
|
||||
$html = '<a href="' . $preview . '" class="thumbnail pull-left modal hasTooltip" title="' . JHtml::tooltipText('COM_TEMPLATES_CLICK_TO_ENLARGE') . '">' . $html . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
169
administrator/components/com_templates/helpers/templates.php
Normal file
169
administrator/components/com_templates/helpers/templates.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Templates component helper.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_templates
|
||||
* @since 1.6
|
||||
*/
|
||||
class TemplatesHelper
|
||||
{
|
||||
/**
|
||||
* Configure the Linkbar.
|
||||
*
|
||||
* @param string The name of the active view.
|
||||
*/
|
||||
public static function addSubmenu($vName)
|
||||
{
|
||||
JHtmlSidebar::addEntry(
|
||||
JText::_('COM_TEMPLATES_SUBMENU_STYLES'),
|
||||
'index.php?option=com_templates&view=styles',
|
||||
$vName == 'styles'
|
||||
);
|
||||
JHtmlSidebar::addEntry(
|
||||
JText::_('COM_TEMPLATES_SUBMENU_TEMPLATES'),
|
||||
'index.php?option=com_templates&view=templates',
|
||||
$vName == 'templates'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the actions that can be performed.
|
||||
*
|
||||
* @return JObject
|
||||
*/
|
||||
public static function getActions()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$result = new JObject;
|
||||
|
||||
$actions = JAccess::getActions('com_templates');
|
||||
|
||||
foreach ($actions as $action)
|
||||
{
|
||||
$result->set($action->name, $user->authorise($action->name, 'com_templates'));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of filter options for the application clients.
|
||||
*
|
||||
* @return array An array of JHtmlOption elements.
|
||||
*/
|
||||
public static function getClientOptions()
|
||||
{
|
||||
// Build the filter options.
|
||||
$options = array();
|
||||
$options[] = JHtml::_('select.option', '0', JText::_('JSITE'));
|
||||
$options[] = JHtml::_('select.option', '1', JText::_('JADMINISTRATOR'));
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of filter options for the templates with styles.
|
||||
*
|
||||
* @return array An array of JHtmlOption elements.
|
||||
*/
|
||||
public static function getTemplateOptions($clientId = '*')
|
||||
{
|
||||
// Build the filter options.
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
if ($clientId != '*')
|
||||
{
|
||||
$query->where('client_id=' . (int) $clientId);
|
||||
}
|
||||
|
||||
$query->select('element as value, name as text, extension_id as e_id')
|
||||
->from('#__extensions')
|
||||
->where('type = ' . $db->quote('template'))
|
||||
->where('enabled = 1')
|
||||
->order('client_id')
|
||||
->order('name');
|
||||
$db->setQuery($query);
|
||||
$options = $db->loadObjectList();
|
||||
return $options;
|
||||
}
|
||||
|
||||
public static function parseXMLTemplateFile($templateBaseDir, $templateDir)
|
||||
{
|
||||
$data = new JObject;
|
||||
|
||||
// Check of the xml file exists
|
||||
$filePath = JPath::clean($templateBaseDir . '/templates/' . $templateDir . '/templateDetails.xml');
|
||||
if (is_file($filePath))
|
||||
{
|
||||
$xml = JInstaller::parseXMLInstallFile($filePath);
|
||||
|
||||
if ($xml['type'] != 'template')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($xml as $key => $value)
|
||||
{
|
||||
$data->set($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function getPositions($clientId, $templateDir)
|
||||
{
|
||||
$positions = array();
|
||||
|
||||
$templateBaseDir = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
|
||||
$filePath = JPath::clean($templateBaseDir . '/templates/' . $templateDir . '/templateDetails.xml');
|
||||
|
||||
if (is_file($filePath))
|
||||
{
|
||||
// Read the file to see if it's a valid component XML file
|
||||
$xml = simplexml_load_file($filePath);
|
||||
if (!$xml)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for a valid XML root tag.
|
||||
|
||||
// Extensions use 'extension' as the root tag. Languages use 'metafile' instead
|
||||
|
||||
if ($xml->getName() != 'extension' && $xml->getName() != 'metafile')
|
||||
{
|
||||
unset($xml);
|
||||
return false;
|
||||
}
|
||||
|
||||
$positions = (array) $xml->positions;
|
||||
|
||||
if (isset($positions['position']))
|
||||
{
|
||||
$positions = $positions['position'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$positions = array();
|
||||
}
|
||||
}
|
||||
|
||||
return $positions;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user