当前位置: 首页>>代码示例>>PHP>>正文


PHP JVersion::getHelpVersion方法代码示例

本文整理汇总了PHP中JVersion::getHelpVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP JVersion::getHelpVersion方法的具体用法?PHP JVersion::getHelpVersion怎么用?PHP JVersion::getHelpVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JVersion的用法示例。


在下文中一共展示了JVersion::getHelpVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetHelpVersion

 /**
  * This checks for the correct Help Version.
  *
  * @param	string	$release	Joomla release number
  * @param	string	$expect		Expected help Version
  * @param	string	$message	Test failure message
  *
  * @return void
  * @dataProvider casesHelp
  */
 public function testGetHelpVersion($release, $expect, $message)
 {
     if (is_null($release)) {
         $output = $this->object->getHelpVersion();
     } else {
         $this->object->RELEASE = '1.0';
         $output = $this->object->getHelpVersion();
     }
     $this->assertEquals($expect, $output, $message);
 }
开发者ID:Joomla-on-NoSQL,项目名称:LaMojo,代码行数:20,代码来源:JVersionTest.php

示例2: createURL

 /**
  * Create an URL for a giving help file reference
  *
  * @param string The name of the popup file (excluding the file extension for an xml file)
  * @param boolean Use the help file in the component directory
  */
 static function createURL($ref, $useComponent = false)
 {
     $component = JApplicationHelper::getComponentName();
     $app =& JFactory::getApplication();
     $user =& JFactory::getUser();
     $userHelpUrl = $user->getParam('helpsite');
     $globalHelpUrl = $app->getCfg('helpurl');
     $lang =& JFactory::getLanguage();
     if ($useComponent) {
         if (!preg_match('#\\.html$#i', $ref)) {
             $ref = $ref . '.html';
         }
         $url = 'components/' . $component . '/help';
         $tag = $lang->getTag();
         // Check if the file exists within a different language!
         if ($lang->getTag() != 'en-GB') {
             $localeURL = JPATH_BASE . DS . $url . DS . $tag . DS . $ref;
             jimport('joomla.filesystem.file');
             if (!JFile::exists($localeURL)) {
                 $tag = 'en-GB';
             }
         }
         return $url . '/' . $tag . '/' . $ref;
     }
     if ($userHelpUrl) {
         // Online help site as defined in GC
         $version = new JVersion();
         $ref .= $version->getHelpVersion();
         $url = $userHelpUrl . '/index2.php?option=com_content&task=findkey&tmpl=component&keyref=' . urlencode($ref);
     } else {
         if ($globalHelpUrl) {
             // Online help site as defined in GC
             $version = new JVersion();
             $ref .= $version->getHelpVersion();
             $url = $globalHelpUrl . '/index2.php?option=com_content&task=findkey&tmpl=component;1&keyref=' . urlencode($ref);
         } else {
             // Included html help files
             $helpURL = 'help/' . $lang->getTag() . '/';
             if (!eregi('\\.html$', $ref)) {
                 $ref = $ref . '.html';
             }
             // Check if the file exists within a different language!
             if ($lang->getTag() != 'en-GB') {
                 $localeURL = JPATH_BASE . $helpURL . $ref;
                 jimport('joomla.filesystem.file');
                 if (!JFile::exists($localeURL)) {
                     $helpURL = 'help/en-GB/';
                 }
             }
             $url = $helpURL . $ref;
         }
     }
     return $url;
 }
开发者ID:joebushi,项目名称:joomla,代码行数:60,代码来源:help.php

示例3: __construct

 public function __construct()
 {
     parent::__construct();
     // Only process this if task != azrul_ajax
     $task = JRequest::getCmd('task', '');
     $document = JFactory::getDocument();
     if ($document instanceof JDocumentHTML) {
         $app = JFactory::getApplication();
         $template = $app->getTemplate();
         // Add some javascript that may be needed
         // Add some javascript that may be needed
         if ($task != 'azrul_ajax') {
             $version = new JVersion();
             if ($version->getHelpVersion() <= '0.25') {
                 // load jquery if joomla 2.5.x
                 $document->addScript(COMMUNITY_ASSETS_URL . '/js/jquery.min.js');
                 $document->addScript(COMMUNITY_ASSETS_URL . '/js/bootstrap.min.js');
                 $document->addScript(COMMUNITY_ASSETS_URL . '/js/joomla25.min.js');
                 // load css if joomla 2.5.x
                 $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/joomla25.css');
             }
             //$document->addScript( COMMUNITY_ASSETS_URL . '/js/jquery.min.js' );
             //$document->addScript( COMMUNITY_ASSETS_URL . '/js/bootstrap.min.js' );
             //$document->addScript( COMMUNITY_ASSETS_URL . '/js/ace-elements.min.js' );
             //$document->addScript( COMMUNITY_ASSETS_URL . '/js/ace.min.js' );
             //dont load in installer
             if (JRequest::getCmd('view', 'community') !== 'installer') {
                 require_once JPATH_COMPONENT . '/helpers/community.php';
             }
         }
         $document->addScript(COMMUNITY_ASSETS_URL . '/admin.js');
         $document->addScript(JURI::root() . 'components/com_community/assets/window-1.0.js');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/bootstrap.min.css');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/font-awesome.min.css');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/ace-fonts.css');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/ace.min.css');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/fullcalendar.css');
     }
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:39,代码来源:controller.php

示例4: getTemplateSuffixes

 /**
  * Get application-specific suffixes to use with template paths. This allows
  * you to look for view template overrides based on the application version.
  *
  * @return  array  A plain array of suffixes to try in template names
  */
 public function getTemplateSuffixes()
 {
     $jversion = new \JVersion();
     $versionParts = explode('.', $jversion->RELEASE);
     $majorVersion = array_shift($versionParts);
     $suffixes = array('.j' . str_replace('.', '', $jversion->getHelpVersion()), '.j' . $majorVersion);
     return $suffixes;
 }
开发者ID:Joal01,项目名称:fof,代码行数:14,代码来源:Platform.php

示例5: __construct

    public function __construct()
    {
        parent::__construct();
        if (defined('ZE_USERINFO_JUST_ADDED')) {
            return;
        }
        define('ZE_USERINFO_JUST_ADDED', true);
        $doc = JFactory::getDocument();
        $doc->addStyleSheet(JURI::root() . 'plugins/user/zygo_profile/fields/userinfo.css');
        $doc->addScript(JURI::root() . 'plugins/user/zygo_profile/fields/drag.js');
        //$doc->addStyleSheet(JURI::root().'plugins/user/zygo_profile/fields/drag.css');
        $version = new JVersion();
        $Jversion = (int) substr($version->getHelpVersion(), 1);
        $Jversion = $Jversion >= 30 ? 30 : ($Jversion >= 16 ? 16 : 15);
        $disabled_options = $this->disabled_options();
        $disabledJS = array();
        foreach ($disabled_options as $name => $value) {
            if (is_string($value)) {
                $disabledJS[] = $name . ': "' . $value . '"';
            } else {
                $disabledJSC = $name . ': {';
                foreach ($value as $k => $val) {
                    if ($k) {
                        $disabledJSC .= ', ';
                    }
                    $disabledJSC .= $val . ': true';
                }
                $disabledJSC .= '}';
                $disabledJS[] = $disabledJSC;
            }
        }
        $disabledJSString = 'var ZEdisabledJS = {' . implode(', ', $disabledJS) . '}; ';
        $addSelectCorrection = '';
        if ($Jversion == 30) {
            $addSelectCorrection = '

				newTab.getElements("select").setStyles({"display":"block"});
				newTab.getElements(".chzn-container").destroy();

				jQuery("select", newTab).removeClass("chzn-done").chosen({
						disable_search_threshold : 10,
						allow_single_deselect : true
					});';
        }
        $doc->addScriptDeclaration($disabledJSString . '
			window.addEvent("domready", function() {
				prop={};

				var wrapperLis=$$(".userinfo_wrapper")[0].getParent().getParent().getChildren("li");

				wrapperLis.each(function(el, i){
					if(!el.getChildren(".userinfo_wrapper")[0]){
						oddEven=(i%2)? "odd" : "even";
						el.addClass("zeLiWrap "+oddEven);
						var zdiv=document.createElement("div");
						zdiv.className="zeClear";
						el.appendChild(zdiv);
					}
				});


		      list2 = document.getElementById("userinfo_tab_ul_userinfo");
		      if(list2){
			      ZDragDrop.makeListContainer( list2 );
			      list2.onZDragOver = function() { this.style["border"] = "1px dashed #8E0B8C"; this.style["background"] = "#FFF"; };
			      list2.onZDragOut = function() {this.style["border"] = "1px solid transparent"; this.style["background"] = "none";};
		      }

			});
			function zeOpenClose(e, self){
				var target = e.srcElement || e.target;
				target = $(target);
				self = $(self);
				if(!target.hasClass("zeOpenCloseSpan") && !target.hasClass("userinfo_tab_head")) return;

				if(self.hasClass("zeOpened")){
					self.removeClass("zeOpened");
				}else{
					self.addClass("zeOpened");
				}
			}
			function zeFieldCheck(self, checkedEl){
				fieldname=self.getAttribute("rel");

				$$(".zeFieldCheck_"+fieldname).removeClass("checked");
				if(self.hasClass("checked")){
					self.removeClass("checked");
				}else{
					self.addClass("checked");
				}
				$("jform_params_"+fieldname+"activeTab").value=checkedEl;
			}
			function zeRemove(self){
				self.parentNode.parentNode.destroy();
			}

			var ZE_NUM_ALL=[];
			function zeAddNew(fieldname){
				ZE_NUM=ZE_NUM_ALL[fieldname];

//.........这里部分代码省略.........
开发者ID:psytronica,项目名称:zygoprofile,代码行数:101,代码来源:userinfo.php

示例6: enablePlugin

 public function enablePlugin($plugin)
 {
     $db = JFactory::getDBO();
     $version = new JVersion();
     $joomla_ver = $version->getHelpVersion();
     $query = 'UPDATE ' . $db->quoteName('#__extensions') . ' SET ' . $db->quoteName('enabled') . ' = ' . $db->quote(1) . ' WHERE ' . $db->quoteName('element') . ' = ' . $db->quote($plugin);
     $db->setQuery($query);
     if (!$db->query()) {
         return $db->getErrorNum() . ':' . $db->getErrorMsg();
     } else {
         return null;
     }
 }
开发者ID:Jougito,项目名称:DynWeb,代码行数:13,代码来源:installer.helper.php

示例7: enablePlugin

 function enablePlugin($plugin)
 {
     $db =& JFactory::getDBO();
     $version = new JVersion();
     $joomla_ver = $version->getHelpVersion();
     //Joomla version 1.5 above
     if ($joomla_ver <= '0.15') {
         $query = 'UPDATE ' . $db->nameQuote('#__plugins') . ' SET ' . $db->nameQuote('published') . ' = ' . $db->quote(1) . ' WHERE ' . $db->nameQuote('element') . ' = ' . $db->quote($plugin);
     } elseif ($joomla_ver >= '0.16') {
         //Joomla version 1.6 and later
         $query = 'UPDATE ' . $db->nameQuote('#__extensions') . ' SET ' . $db->nameQuote('enabled') . ' = ' . $db->quote(1) . ' WHERE ' . $db->nameQuote('element') . ' = ' . $db->quote($plugin);
     }
     $db->setQuery($query);
     if (!$db->query()) {
         return $db->getErrorNum() . ':' . $db->getErrorMsg();
     } else {
         return null;
     }
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:19,代码来源:installer.helper.php

示例8: getRssFeed

 public function getRssFeed($url, $id)
 {
     $response = new JAXResponse();
     $version = new JVersion();
     $joomla_ver = $version->getHelpVersion();
     $rss = array();
     if ($joomla_ver <= '0.30') {
         $rssData = $this->getRSS($url, $id);
         foreach ($rssData->items as $item) {
             $data = new stdClass();
             preg_match_all('#(<[/]?img.*>)#U', $item->get_content(), $matches);
             $imgSrc = '';
             if (isset($matches[0][0])) {
                 $imgSrc = explode('src="', $matches[0][0]);
                 $imgSrc = explode('" ', $imgSrc[1]);
                 $imgSrc = $imgSrc[0];
             }
             $data->title = $item->get_title();
             $data->url = $item->get_link();
             $data->img = $imgSrc;
             $data->published = strtolower($item->get_date('l , d F Y'));
             $data->content = strip_tags(JFilterOutput::stripImages($item->get_description()));
             $rss[] = $data;
         }
     } else {
         try {
             $feed = new JFeedFactory();
             $rssDoc = $feed->getFeed($url);
         } catch (InvalidArgumentException $e) {
             return JText::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
         } catch (RunTimeException $e) {
             return JText::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
         } catch (LogicException $e) {
             return JText::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
         }
         if (empty($rssDoc)) {
             return JText::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
         }
         if ($rssDoc) {
             for ($i = 0; $i < 5; $i++) {
                 $date = $rssDoc[$i]->publishedDate;
                 $data = new stdClass();
                 preg_match_all('#(<[/]?img.*>)#U', $rssDoc[$i]->content, $matches);
                 $imgSrc = '';
                 if (isset($matches[0][0])) {
                     $imgSrc = explode('src="', $matches[0][0]);
                     $imgSrc = explode('" ', $imgSrc[1]);
                     $imgSrc = $imgSrc[0];
                 }
                 $data->title = $rssDoc[$i]->title;
                 $data->url = $rssDoc[$i]->uri;
                 $data->img = $imgSrc;
                 $data->published = strtolower($date->format('l , d F Y'));
                 $data->content = strip_tags(JFilterOutput::stripImages($rssDoc[$i]->content));
                 $rss[] = $data;
             }
         }
     }
     $html = '';
     foreach ($rss as $data) {
         //var_dump($data->img);
         $html .= '<div class="media clearfix">';
         $html .= '<div class="media-body">';
         $html .= '<h4 class="media-heading reset-gap"><a href="' . $data->url . '" target="_blank">' . $data->title . '</a></h4>';
         $html .= '<p class="orange">' . $data->published . '</p>';
         if ($data->img) {
             $html .= '<a class="pull-left thumbnail" href="' . $data->url . '" target="_blank">';
             $html .= '<img class="media-object" src="' . $data->img . '" width="100px"  />';
             $html .= '</a>';
         }
         $html .= JHTML::_('string.truncate', $data->content, 200);
         $html .= '</div>';
         $html .= '</div>';
     }
     $response->addScriptCall('joms.jQuery("#' . $id . '").html', $html);
     return $response->sendResponse();
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:77,代码来源:community.php

示例9: testGetHelpVersion

 /**
  * Tests the getHelpVersion method
  *
  * @return  void
  *
  * @since   3.0
  */
 public function testGetHelpVersion()
 {
     $this->assertInternalType('string', $this->object->getHelpVersion());
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:11,代码来源:JVersionTest.php

示例10: die

<?php

/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <webmaster@ijoomla.com>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/
// Disallow direct access to this file
defined('_JEXEC') or die('Restricted access');
define('COMMUNITY_ASSETS_PATH', JPATH_COMPONENT . '/assets');
define('COMMUNITY_ASSETS_URL', JURI::base() . 'components/com_community/assets');
define('COMMUNITY_BASE_PATH', dirname(JPATH_BASE) . '/components/com_community');
define('COMMUNITY_BASE_ASSETS_PATH', JPATH_BASE . '/components/com_community/assets');
define('COMMUNITY_BASE_ASSETS_URL', JURI::root() . 'components/com_community/assets');
define('COMMUNITY_CONTROLLERS', JPATH_COMPONENT . '/controllers');
// @TODO to be removed.
jimport('joomla.version');
$version = new JVersion();
$joomla_ver = $version->getHelpVersion();
// @ENDTODO
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:23,代码来源:defines.php

示例11: testGetHelpVersion

 /**
  * Tests the getHelpVersion method
  *
  * @return  void
  *
  * @since   3.0
  *
  * @covers  JVersion::getHelpVersion
  */
 public function testGetHelpVersion()
 {
     $this->assertThat($this->object->getHelpVersion(), $this->isType('string'), 'getHelpVersion should return a string with the version.');
 }
开发者ID:rasiodesign,项目名称:joomla-cms,代码行数:13,代码来源:JVersionTest.php

示例12: save


//.........这里部分代码省略.........
     }
     //Joomla 1.6 patch to keep the group ID of user intact when saving
     if (property_exists($user, 'groups')) {
         foreach ($user->groups as $groupid => $groupname) {
             $user->groups[$groupid] = $groupid;
         }
     }
     if (!$user->save()) {
         $message = JText::_('COM_COMMUNITY_USERS_SAVE_USER_INFORMATION_ERROR') . ' : ' . $user->getError();
         $mainframe->redirect($url, $message);
         exit;
     }
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $userRow = array();
     $userRow[] = $user;
     $appsLib->triggerEvent('onUserDetailsUpdate', $userRow);
     // @rule: Send out email if it is a new user.
     if ($isNew) {
         $adminEmail = $my->get('email');
         $adminName = $my->get('name');
         $subject = JText::_('COM_COMMUNITY_USERS_NEW_USER_MESSAGE_SUBJECT');
         $message = sprintf(JText::_('COM_COMMUNITY_USERS_NEW_USER_MESSAGE'), $user->get('name'), $siteName, JURI::root(), $user->get('username'), $user->password_clear);
         if (!empty($mailfrom) && !empty($fromName)) {
             $adminName = $fromName;
             $adminEmail = $mailFrom;
         }
         JUtility::sendMail($adminEmail, $adminName, $user->get('email'), $subject, $message);
     }
     // If updating self, load the new user object into the session
     if ($user->get('id') == $my->get('id')) {
         jimport('joomla.version');
         $version = new JVersion();
         $joomla_ver = $version->getHelpVersion();
         // Get the user group from the ACL
         if ($joomla_ver <= '0.15') {
             $grp = $acl->getAroGroup($user->get('id'));
             // Mark the user as logged in
             $user->set('guest', 0);
             $user->set('aid', 1);
             // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
             if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
                 $user->set('aid', 2);
             }
             // Set the usertype based on the ACL group name
             $user->set('usertype', $grp->name);
         } elseif ($joomla_ver >= '0.16') {
             $grp_name = $cacl->getGroupUser($user->get('id'));
             // Mark the user as logged in
             $user->set('guest', 0);
             $user->set('aid', 1);
             // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
             if ($cacl->is_group_child_of($grp_name, 'Registered') || $cacl->is_group_child_of($grp_name, 'Public Backend')) {
                 $user->set('aid', 2);
             }
             // Set the usertype based on the ACL group name
             $user->set('usertype', $grp_name);
         }
         $session =& JFactory::getSession();
         $session->set('user', $user);
     }
     // Process and save custom fields
     $user = CFactory::getUser($userId);
     $model =& $this->getModel('users');
     $userModel = CFactory::getModel('profile');
     $values = array();
开发者ID:Simarpreet05,项目名称:joomla,代码行数:67,代码来源:users.php

示例13: jQuery

</div>
    <div id="progress-status" style="padding-top: 5px;"></div>
</fieldset>
</div>
</form>

<script>
    jQuery("#toolbar-save").prependTo(".send-message-wrapper");
    var click = jQuery("#toolbar-save button").attr('onclick');
    click +=';return false;';
    jQuery("#toolbar-save button").attr('onclick',click);
</script>

<?php 
$version = new JVersion();
if ($version->getHelpVersion() <= '0.25') {
    ?>

    <script>
        jQuery("#toolbar-save").prependTo(".send-message-wrapper");
        jQuery("#toolbar-save").replaceWith(function() {
            return jQuery("<div />", {html: jQuery(this).html()});
        });
        jQuery(".send-message-wrapper span").addClass('icon-save');
        jQuery(".send-message-wrapper a").addClass('btn btn-success btn-small');
    </script>

    <?php 
} else {
    ?>
开发者ID:Jougito,项目名称:DynWeb,代码行数:30,代码来源:default.php

示例14: findFormFilename

 /**
  * Guesses the best candidate for the path to use for a particular form.
  *
  * @param   string  $source  The name of the form file to load, without the .xml extension
  *
  * @return  string  The path and filename of the form to load
  *
  * @since   2.0
  */
 public function findFormFilename($source)
 {
     // Get some useful variables
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     $option = $this->input->getCmd('option', 'com_foobar');
     $view = $this->input->getCmd('view', 'cpanels');
     if (!$isCli) {
         $template = JFactory::getApplication()->getTemplate();
     } else {
         $template = 'cli';
     }
     $file_root = $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $file_root .= '/components/' . $option;
     $alt_file_root = $isAdmin ? JPATH_SITE : JPATH_ADMINISTRATOR;
     $alt_file_root .= '/components/' . $option;
     $template_root = $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $template_root .= '/templates/' . $template . '/html/' . $option;
     // Set up the paths to look into
     $paths = array($template_root . '/' . $view, $template_root . '/' . FOFInflector::singularize($view), $template_root . '/' . FOFInflector::pluralize($view), $file_root . '/views/' . $view . '/tmpl', $file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $alt_file_root . '/views/' . $view . '/tmpl', $alt_file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $alt_file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $file_root . '/models/forms', $alt_file_root . '/models/forms');
     // Set up the suffixes to look into
     $jversion = new JVersion();
     $versionParts = explode('.', $jversion->RELEASE);
     $majorVersion = array_shift($versionParts);
     $suffixes = array('.j' . str_replace('.', '', $jversion->getHelpVersion()) . '.xml', '.j' . $majorVersion . '.xml', '.xml');
     unset($jversion, $versionParts, $majorVersion);
     // Look for all suffixes in all paths
     JLoader::import('joomla.filesystem.file');
     $result = false;
     foreach ($paths as $path) {
         foreach ($suffixes as $suffix) {
             $filename = $path . '/' . $source . $suffix;
             if (JFile::exists($filename)) {
                 $result = $filename;
                 break;
             }
         }
         if ($result) {
             break;
         }
     }
     return $result;
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:51,代码来源:model.php

示例15: loadAnyTemplate

 /**
  * Loads a template given any path. The path is in the format:
  * [admin|site]:com_foobar/viewname/templatename
  * e.g. admin:com_foobar/myview/default
  *
  * This function searches for Joomla! version override templates. For example,
  * if you have run this under Joomla! 3.0 and you try to load
  * admin:com_foobar/myview/default it will automatically search for the
  * template files default.j30.php, default.j3.php and default.php, in this
  * order.
  *
  * @param string $path
  * @param array $forceParams A hash array of variables to be extracted in the local scope of the template file
  */
 public function loadAnyTemplate($path = '', $forceParams = array())
 {
     // Automatically check for a Joomla! version specific override
     $throwErrorIfNotFound = true;
     $jversion = new JVersion();
     $versionParts = explode('.', $jversion->RELEASE);
     $majorVersion = array_shift($versionParts);
     $suffixes = array('.j' . str_replace('.', '', $jversion->getHelpVersion()), '.j' . $majorVersion);
     unset($jversion, $versionParts, $majorVersion);
     foreach ($suffixes as $suffix) {
         if (substr($path, -strlen($suffix)) == $suffix) {
             $throwErrorIfNotFound = false;
             break;
         }
     }
     if ($throwErrorIfNotFound) {
         foreach ($suffixes as $suffix) {
             $result = $this->loadAnyTemplate($path . $suffix, $forceParams);
             if ($result !== false) {
                 return $result;
             }
         }
     }
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     if (!$isCli) {
         $template = JFactory::getApplication()->getTemplate();
     } else {
         $template = 'cli';
     }
     $layoutTemplate = $this->getLayoutTemplate();
     // Parse the path
     $templateParts = $this->_parseTemplatePath($path);
     // Get the default paths
     $paths = array();
     $paths[] = ($templateParts['admin'] ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/' . $template . '/html/' . $templateParts['component'] . '/' . $templateParts['view'];
     $paths[] = ($templateParts['admin'] ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/components/' . $templateParts['component'] . '/views/' . $templateParts['view'] . '/tmpl';
     if (isset($this->_path) || property_exists($this, '_path')) {
         $paths = array_merge($paths, $this->_path['template']);
     } elseif (isset($this->path) || property_exists($this, 'path')) {
         $paths = array_merge($paths, $this->path['template']);
     }
     // Look for a template override
     if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) {
         $apath = array_shift($paths);
         array_unshift($paths, str_replace($template, $layoutTemplate, $apath));
     }
     $filetofind = $templateParts['template'] . '.php';
     JLoader::import('joomla.filesystem.path');
     $this->_tempFilePath = JPath::find($paths, $filetofind);
     if ($this->_tempFilePath) {
         // Unset from local scope
         unset($template);
         unset($layoutTemplate);
         unset($paths);
         unset($path);
         unset($filetofind);
         // Never allow a 'this' property
         if (isset($this->this)) {
             unset($this->this);
         }
         // Force parameters into scope
         if (!empty($forceParams)) {
             extract($forceParams);
         }
         // Start capturing output into a buffer
         ob_start();
         // Include the requested template filename in the local scope
         // (this will execute the view logic).
         include $this->_tempFilePath;
         // Done with the requested template; get the buffer and
         // clear it.
         $this->_output = ob_get_contents();
         ob_end_clean();
         return $this->_output;
     } else {
         if ($throwErrorIfNotFound) {
             return new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $path), 500);
         }
         return false;
     }
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:95,代码来源:view.php


注:本文中的JVersion::getHelpVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。