本文整理汇总了PHP中JApplication::getTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplication::getTemplate方法的具体用法?PHP JApplication::getTemplate怎么用?PHP JApplication::getTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplication
的用法示例。
在下文中一共展示了JApplication::getTemplate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParam
/**
* Get the template style params
*
* @param string $param The param name
* @return string The param value
*/
public function getParam($param)
{
if (!isset($this->templateParams)) {
if (self::$isJ15) {
$template = $this->template->name;
$cont = null;
$ini = JPATH_THEMES . '/' . $template . '/params.ini';
$xml = JPATH_THEMES . '/' . $template . '/templateDetails.xml';
jimport('joomla.filesystem.file');
if (JFile::exists($ini)) {
$cont = JFile::read($ini);
} else {
$cont = null;
}
$this->templateParams = new JParameter($cont, $xml, $template);
} else {
if ($this->app->isAdmin()) {
jimport('joomla.environment.request');
$id = JRequest::getInt('id');
// Load the site template params from the database
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('params');
$query->from('#__template_styles');
$query->where('id = ' . $id);
$db->setQuery($query);
$result = $db->loadObject();
$this->templateParams = new JRegistry($result->params);
} else {
$template = $this->app->getTemplate(true);
$this->templateParams = $template->params;
}
}
}
$value = $this->templateParams->get($param);
if ($value) {
return $value;
} else {
return false;
}
}
示例2: getPath
/**
* Get a path
*
* @param string $varname
* @param string $user_option
* @return string The requested path
* @since 1.0
*/
public static function getPath($varname, $user_option = null)
{
// check needed for handling of custom/new module xml file loading
$check = $varname == 'mod0_xml' || $varname == 'mod1_xml';
if (!$user_option && !$check) {
$user_option = JRequest::getCmd('option');
} else {
$user_option = JFilterInput::getInstance()->clean($user_option, 'path');
}
$result = null;
$name = substr($user_option, 4);
switch ($varname) {
case 'front':
$result = self::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.php', 0);
break;
case 'html':
case 'front_html':
if (!($result = self::_checkPath(DS . 'templates' . DS . JApplication::getTemplate() . DS . 'components' . DS . $name . '.html.php', 0))) {
$result = self::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.html.php', 0);
}
break;
case 'toolbar':
$result = self::_checkPath(DS . 'components' . DS . $user_option . DS . 'toolbar.' . $name . '.php', -1);
break;
case 'toolbar_html':
$result = self::_checkPath(DS . 'components' . DS . $user_option . DS . 'toolbar.' . $name . '.html.php', -1);
break;
case 'toolbar_default':
case 'toolbar_front':
$result = self::_checkPath(DS . 'includes' . DS . 'HTML_toolbar.php', 0);
break;
case 'admin':
$path = DS . 'components' . DS . $user_option . DS . 'admin.' . $name . '.php';
$result = self::_checkPath($path, -1);
if ($result == null) {
$path = DS . 'components' . DS . $user_option . DS . $name . '.php';
$result = self::_checkPath($path, -1);
}
break;
case 'admin_html':
$path = DS . 'components' . DS . $user_option . DS . 'admin.' . $name . '.html.php';
$result = self::_checkPath($path, -1);
break;
case 'admin_functions':
$path = DS . 'components' . DS . $user_option . DS . $name . '.functions.php';
$result = self::_checkPath($path, -1);
break;
case 'class':
if (!($result = self::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.class.php'))) {
$result = self::_checkPath(DS . 'includes' . DS . $name . '.php');
}
break;
case 'helper':
$path = DS . 'components' . DS . $user_option . DS . $name . '.helper.php';
$result = self::_checkPath($path);
break;
case 'com_xml':
$path = DS . 'components' . DS . $user_option . DS . $name . '.xml';
$result = self::_checkPath($path, 1);
break;
case 'mod0_xml':
$path = DS . 'modules' . DS . $user_option . DS . $user_option . '.xml';
$result = self::_checkPath($path);
break;
case 'mod1_xml':
// admin modules
$path = DS . 'modules' . DS . $user_option . DS . $user_option . '.xml';
$result = self::_checkPath($path, -1);
break;
case 'plg_xml':
// Site plugins
$j15path = DS . 'plugins' . DS . $user_option . '.xml';
$parts = explode(DS, $user_option);
$j16path = DS . 'plugins' . DS . $user_option . DS . $parts[1] . '.xml';
$j15 = self::_checkPath($j15path, 0);
$j16 = self::_checkPath($j16path, 0);
// return 1.6 if working otherwise default to whatever 1.5 gives us
$result = $j16 ? $j16 : $j15;
break;
case 'menu_xml':
$path = DS . 'components' . DS . 'com_menus' . DS . $user_option . DS . $user_option . '.xml';
$result = self::_checkPath($path, -1);
break;
}
return $result;
}
示例3: getPath
/**
* Get a path
*
* @param string $varname Identify location or type of xml
* @param string $user_option Option (e.g. com_something) used to find path.
*
* @return string The requested path
*
* @since 11.1
* @deprecated 12.1
*/
public static function getPath($varname, $user_option = null)
{
$app = JFactory::getApplication();
// Check needed for handling of custom/new module XML file loading
$check = $varname == 'mod0_xml' || $varname == 'mod1_xml';
if (!$user_option && !$check) {
$user_option = $app->input->get('option');
} else {
$user_option = JFilterInput::getInstance()->clean($user_option, 'path');
}
$result = null;
$name = substr($user_option, 4);
switch ($varname) {
case 'front':
$result = $this->_checkPath('/components/' . $user_option . '/' . $name . '.php', 0);
break;
case 'html':
case 'front_html':
if (!($result = $this->_checkPath('/templates/' . JApplication::getTemplate() . '/components/' . $name . '.html.php', 0))) {
$result = $this->_checkPath('/components/' . $user_option . '/' . $name . '.html.php', 0);
}
break;
case 'toolbar':
$result = $this->_checkPath('/components/' . $user_option . '/toolbar.' . $name . '.php', -1);
break;
case 'toolbar_html':
$result = $this->_checkPath('/components/' . $user_option . '/toolbar.' . $name . '.html.php', -1);
break;
case 'toolbar_default':
case 'toolbar_front':
$result = $this->_checkPath('/includes/HTML_toolbar.php', 0);
break;
case 'admin':
$path = '/components/' . $user_option . '/admin.' . $name . '.php';
$result = $this->_checkPath($path, -1);
if ($result == null) {
$path = '/components/' . $user_option . '/' . $name . '.php';
$result = $this->_checkPath($path, -1);
}
break;
case 'admin_html':
$path = '/components/' . $user_option . '/admin.' . $name . '.html.php';
$result = $this->_checkPath($path, -1);
break;
case 'admin_functions':
$path = '/components/' . $user_option . '/' . $name . '.functions.php';
$result = $this->_checkPath($path, -1);
break;
case 'class':
if (!($result = $this->_checkPath('/components/' . $user_option . '/' . $name . '.class.php'))) {
$result = $this->_checkPath('/includes/' . $name . '.php');
}
break;
case 'helper':
$path = '/components/' . $user_option . '/' . $name . '.helper.php';
$result = $this->_checkPath($path);
break;
case 'com_xml':
$path = '/components/' . $user_option . '/' . $name . '.xml';
$result = $this->_checkPath($path, 1);
break;
case 'mod0_xml':
$path = '/modules/' . $user_option . '/' . $user_option . '.xml';
$result = $this->_checkPath($path);
break;
case 'mod1_xml':
// Admin modules
$path = '/modules/' . $user_option . '/' . $user_option . '.xml';
$result = $this->_checkPath($path, -1);
break;
case 'plg_xml':
// Site plugins
$j15path = '/plugins/' . $user_option . '.xml';
$parts = explode(DIRECTORY_SEPARATOR, $user_option);
$j16path = '/plugins/' . $user_option . '/' . $parts[1] . '.xml';
$j15 = $this->_checkPath($j15path, 0);
$j16 = $this->_checkPath($j16path, 0);
// Return 1.6 if working otherwise default to whatever 1.5 gives us
$result = $j16 ? $j16 : $j15;
break;
case 'menu_xml':
$path = '/components/com_menus/' . $user_option . '/' . $user_option . '.xml';
$result = $this->_checkPath($path, -1);
break;
}
return $result;
}
示例4: bc_getCurrentTemplate
function bc_getCurrentTemplate()
{
return JApplication::getTemplate();
}
示例5: getPath
/**
* Get a path
*
* @access public
* @param string $varname
* @param string $user_option
* @return string The requested path
* @since 1.0
*/
public function getPath($varname, $user_option = null)
{
// check needed for handling of custom/new module xml file loading
$check = $varname == 'mod0_xml' || $varname == 'mod1_xml';
if (!$user_option && !$check) {
$user_option = JRequest::getCmd('option');
} else {
$user_option = JFilterInput::clean($user_option, 'path');
}
$result = null;
$name = substr($user_option, 4);
switch ($varname) {
case 'front':
$result = self::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.php', 0);
break;
case 'html':
case 'front_html':
if (!($result = self::_checkPath(DS . 'templates' . DS . JApplication::getTemplate() . DS . 'components' . DS . $name . '.html.php', 0))) {
$result = self::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.html.php', 0);
}
break;
case 'toolbar':
$result = self::_checkPath(DS . 'components' . DS . $user_option . DS . 'toolbar.' . $name . '.php', -1);
break;
case 'toolbar_html':
$result = self::_checkPath(DS . 'components' . DS . $user_option . DS . 'toolbar.' . $name . '.html.php', -1);
break;
case 'toolbar_default':
case 'toolbar_front':
$result = self::_checkPath(DS . 'includes' . DS . 'HTML_toolbar.php', 0);
break;
case 'admin':
$path = DS . 'components' . DS . $user_option . DS . 'admin.' . $name . '.php';
$result = self::_checkPath($path, -1);
if ($result == null) {
$path = DS . 'components' . DS . $user_option . DS . $name . '.php';
$result = self::_checkPath($path, -1);
}
break;
case 'admin_html':
$path = DS . 'components' . DS . $user_option . DS . 'admin.' . $name . '.html.php';
$result = self::_checkPath($path, -1);
break;
case 'admin_functions':
$path = DS . 'components' . DS . $user_option . DS . $name . '.functions.php';
$result = self::_checkPath($path, -1);
break;
case 'class':
if (!($result = self::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.class.php'))) {
$result = self::_checkPath(DS . 'includes' . DS . $name . '.php');
}
break;
case 'helper':
$path = DS . 'components' . DS . $user_option . DS . $name . '.helper.php';
$result = self::_checkPath($path);
break;
case 'com_xml':
$path = DS . 'components' . DS . $user_option . DS . $name . '.xml';
$manifests = JFolder::files(JPATH_ADMINISTRATOR . '/components/' . $user_option, '.xml$', 0, true);
if (!empty($manifests)) {
foreach ($manifests as $result) {
$xml = simplexml_load_file($result);
if (isset($xml['type'])) {
break;
}
}
}
break;
case 'mod0_xml':
$path = DS . 'modules' . DS . $user_option . DS . $user_option . '.xml';
$result = self::_checkPath($path);
break;
case 'mod1_xml':
// admin modules
$path = DS . 'modules' . DS . $user_option . DS . $user_option . '.xml';
$result = self::_checkPath($path, -1);
break;
case 'bot_xml':
// legacy value
// legacy value
case 'plg_xml':
// Site plugins
$path = DS . 'plugins' . DS . $user_option . '.xml';
$result = self::_checkPath($path, 0);
break;
case 'menu_xml':
$path = DS . 'components' . DS . 'com_menus' . DS . $user_option . DS . $user_option . '.xml';
$result = self::_checkPath($path, -1);
break;
}
return $result;
//.........这里部分代码省略.........
示例6: getPath
/**
* Get a path
*
* @access public
* @param string $varname
* @param string $user_option
* @return string The requested path
* @since 1.0
*/
public static function getPath($varname, $user_option = null)
{
// check needed for handling of custom/new module xml file loading
$check = $varname == 'mod0_xml' || $varname == 'mod1_xml';
if (!$user_option && !$check) {
$user_option = JRequest::getCmd('option');
} else {
$user_option = JFilterInput::clean($user_option, 'path');
}
$result = null;
$name = substr($user_option, 4);
switch ($varname) {
case 'front':
$result = JApplicationHelper::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.php', 0);
break;
case 'html':
case 'front_html':
if (!($result = JApplicationHelper::_checkPath(DS . 'templates' . DS . JApplication::getTemplate() . DS . 'components' . DS . $name . '.html.php', 0))) {
$result = JApplicationHelper::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.html.php', 0);
}
break;
case 'toolbar':
$result = JApplicationHelper::_checkPath(DS . 'components' . DS . $user_option . DS . 'toolbar.' . $name . '.php', -1);
break;
case 'toolbar_html':
$result = JApplicationHelper::_checkPath(DS . 'components' . DS . $user_option . DS . 'toolbar.' . $name . '.html.php', -1);
break;
case 'toolbar_default':
case 'toolbar_front':
$result = JApplicationHelper::_checkPath(DS . 'includes' . DS . 'HTML_toolbar.php', 0);
break;
case 'admin':
$path = DS . 'components' . DS . $user_option . DS . 'admin.' . $name . '.php';
$result = JApplicationHelper::_checkPath($path, -1);
if ($result == null) {
$path = DS . 'components' . DS . $user_option . DS . $name . '.php';
$result = JApplicationHelper::_checkPath($path, -1);
}
break;
case 'admin_html':
$path = DS . 'components' . DS . $user_option . DS . 'admin.' . $name . '.html.php';
$result = JApplicationHelper::_checkPath($path, -1);
break;
case 'admin_functions':
$path = DS . 'components' . DS . $user_option . DS . $name . '.functions.php';
$result = JApplicationHelper::_checkPath($path, -1);
break;
case 'class':
if (!($result = JApplicationHelper::_checkPath(DS . 'components' . DS . $user_option . DS . $name . '.class.php'))) {
$result = JApplicationHelper::_checkPath(DS . 'includes' . DS . $name . '.php');
}
break;
case 'helper':
$path = DS . 'components' . DS . $user_option . DS . $name . '.helper.php';
$result = JApplicationHelper::_checkPath($path);
break;
case 'com_xml':
$path = DS . 'components' . DS . $user_option . DS . $name . '.xml';
$result = JApplicationHelper::_checkPath($path, 1);
break;
case 'mod0_xml':
$path = DS . 'modules' . DS . $user_option . DS . $user_option . '.xml';
$result = JApplicationHelper::_checkPath($path);
break;
case 'mod1_xml':
// admin modules
$path = DS . 'modules' . DS . $user_option . DS . $user_option . '.xml';
$result = JApplicationHelper::_checkPath($path, -1);
break;
case 'bot_xml':
// legacy value
// legacy value
case 'plg_xml':
// Site plugins
$path = DS . 'plugins' . DS . $user_option . '.xml';
$result = JApplicationHelper::_checkPath($path, 0);
break;
case 'menu_xml':
$path = DS . 'components' . DS . 'com_menus' . DS . $user_option . DS . $user_option . '.xml';
$result = JApplicationHelper::_checkPath($path, -1);
break;
}
return $result;
}
示例7: onAfterRender
/**
* Do some output manipulation.
*
* Auto-inject <b>jsn-master tmpl-nameOfDefaultTemplate</b> into the class
* attribute of <b><body></b> tag if not already exists. This
* automation only affects backend page.
*
* @return void
*/
public static function onAfterRender()
{
// Make sure the remaining process is executed in last order
if (!defined('JSN_EXTFW_LAST_EXECUTION')) {
return;
}
// Get active component
$option = self::$_app->input->getCmd('option');
// Get the rendered HTML code
$html = JResponse::getBody();
if (self::$_app->input->getVar('poweradmin')) {
preg_match_all('#<a[^\\>]*href\\s*=\\s*[\'"]([^"]*[^"]+)[\'"]#i', $html, $ms, PREG_SET_ORDER);
if (count($ms)) {
foreach ($ms as $m) {
$html = str_replace($m[0], str_replace($m[1], 'javascript:void(0)', $m[0]), $html);
}
}
}
// Do some fixes if this is admin page
if (self::$_app->isAdmin()) {
// Fix asset links for Joomla 2.5
if (JSNVersion::isJoomlaCompatible('2.5') and !JSNVersion::isJoomlaCompatible('3.0') and strpos($html, JSN_URL_ASSETS) !== false) {
// Get asset link
if (preg_match_all('#<(link|script)([^\\>]*)(href|src)="([^"]*' . JSN_URL_ASSETS . '[^"]+)"#i', $html, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
// Do replace
$html = str_replace($match[0], '<' . $match[1] . $match[2] . $match[3] . '="' . dirname(dirname($match[4])) . '/' . str_replace('.', '-', basename(dirname($match[4]))) . '/' . basename($match[4]) . '"', $html);
}
}
}
// Remove our extensions from the Joomla 3.0's global config page
if ($option == 'com_config' and JSNVersion::isJoomlaCompatible('3.0')) {
$html = preg_replace('#[\\s\\t]*<li[^\\r\\n]*>[\\r\\n\\s\\t]*<a[^\\r\\n]+index.php\\?option=com_config&view=component&component=(' . implode('|', JSNVersion::$products) . ')[^\\r\\n]+</a>[\\r\\n\\s\\t]*</li>[\\r\\n]#', '', $html);
}
// Alter body tag
if (preg_match('/<body[^>]*>/i', $html, $match) and strpos($match[0], 'jsn-master tmpl-' . self::$_app->getTemplate()) === false) {
if (strpos($match[0], 'class=') === false) {
$match[1] = substr($match[0], 0, -1) . ' class=" jsn-master tmpl-' . self::$_app->getTemplate() . ' ">';
} else {
$match[1] = str_replace('class="', 'class=" jsn-master tmpl-' . self::$_app->getTemplate() . ' ', $match[0]);
}
$html = str_replace($match[0], $match[1], $html);
}
if (JSNVersion::isJoomlaCompatible('3.2')) {
// Clean-up HTML5 fall-back script if running on Joomla 3.2
if (in_array($option, JSNVersion::$products) and preg_match('#[\\r\\n][\\s\\t]+<script src="[^"]*/media/system/js/html5fallback(-uncompressed)?\\.js"[^>]+></script>#', $html, $match)) {
$html = str_replace($match[0], '', $html);
}
// Temporary fix jQuery version conflict on Joomla 3.2
$pos = strpos($html, JSN_URL_ASSETS . '/3rd-party/jquery/jquery.min.js');
if ($pos !== false and preg_match('#<script[^>]+src="' . JSN_URL_ASSETS . '/3rd-party/jquery/jquery.min.js"[^>]*></script>#', $html, $match)) {
$html = explode($match[0], $html);
// Do some tricks on multiple jQuery instances
$script = '<script type="text/javascript">' . "\n\t\t" . '(JoomlaShine = window.JoomlaShine || {});' . "\n\t\t" . '(!window.jQuery || (JoomlaShine.jQueryBackup = jQuery));' . "\n\t" . '</script>' . "\n\t" . $match[0];
// Update document header
$html[0] .= $script;
// Truncate content
$html[2] = substr($html[1], strpos($html[1], '</head>'));
$html[1] = substr($html[1], 0, strpos($html[1], '</head>'));
if (preg_match('#<script[^>]+src="[^"]*/media/jui/js/jquery(\\.min)?\\.js"[^>]*></script>#', $html[1], $match)) {
$script = '<script type="text/javascript">' . "\n\t\t" . '(JoomlaShine = window.JoomlaShine || {});' . "\n\t\t" . '(!window.jQuery || (JoomlaShine.jQuery = jQuery));' . "\n\t" . '</script>' . "\n\t" . $match[0];
// Update document header
$html[1] = str_replace($match[0], $script, $html[1]);
} elseif (preg_match('#<script[^>]+src="[^"]*/js/template\\.js[^"]*"[^>]*></script>#', $html[1], $match)) {
$script = '<script type="text/javascript">' . "\n\t\t" . '(JoomlaShine = window.JoomlaShine || {});' . "\n\t\t" . '(!window.jQuery || (JoomlaShine.jQuery = jQuery));' . "\n\t\t" . '(!JoomlaShine.jQueryBackup || (jQuery = JoomlaShine.jQueryBackup));' . "\n\t" . '</script>' . "\n\t" . $match[0];
// Update document header
$html[1] = str_replace($match[0], $script, $html[1]);
} elseif (preg_match('#<script type="text/javascript">#', $html[1], $match)) {
$script = '<script type="text/javascript">' . "\n\t\t" . '(JoomlaShine = window.JoomlaShine || {});' . "\n\t\t" . '(!window.jQuery || (JoomlaShine.jQuery = jQuery));' . "\n\t\t" . '(!JoomlaShine.jQueryBackup || (jQuery = JoomlaShine.jQueryBackup));';
// Update document header
$html[1] = str_replace($match[0], $script, $html[1]);
}
$html = implode($html);
// Fix for (function($) { ... })(jQuery);
$tmp = preg_split('/\\}[\\s\\t\\r\\n]*\\)*\\([^\\r\\n]*jQuery[^\\r\\n]*\\)\\s*;?/', $html);
$html = '';
$i = 0;
foreach ($tmp as $part) {
$i++;
if ($i == count($tmp)) {
$html .= $part;
} else {
$parts = preg_split('/\\(\\s*function\\s*\\(\\s*\\$\\s*\\)\\s*\\{/', $part, 2);
if (count($parts) < 2) {
$html .= $part;
} elseif (stripos($parts[1], 'jsn') !== false) {
$html .= "{$parts[0]}(function(\$) {{$parts[1]}})((window.JoomlaShine && JoomlaShine.jQuery) ? JoomlaShine.jQuery : jQuery);";
} else {
$html .= "{$parts[0]}(function(\$) {{$parts[1]}})(jQuery);";
}
}
//.........这里部分代码省略.........