Ejemplo n.º 1
0
 /**
  * Get active profile name
  *
  * @return string
  */
 public static function get_active_profile()
 {
     // @todo improve way to select profile
     static $profile = null;
     if ($profile) {
         return $profile;
     }
     $lang = JFactory::getLanguage();
     $lang = strtolower($lang->getTag());
     $params = T3Common::get_template_based_params();
     $pages_profile = strtolower($params->get('pages_profile'));
     $profile = '';
     //Get active profile by pages
     //$menu = JSite::getMenu();
     $menu = JFactory::getApplication()->getMenu();
     $menuid = T3Common::getItemid();
     while ($menuid && !$profile) {
         // Check there is assignment with current language and menu
         $regex = '/(^|,|\\>|\\n)\\s*' . $lang . '#' . $menuid . '(,[^=]*)?=([^\\<\\n]*)/';
         if (preg_match($regex, $pages_profile, $matches)) {
             $profile = $matches[3];
             if (T3Common::profile_exists($profile)) {
                 return $profile;
             }
         }
         // Check there is assignment with default language and menu
         $regex = '/(^|,|\\>|\\n)\\s*' . $menuid . '(,[^=]*)?=([^\\<\\n]*)/';
         if (preg_match($regex, $pages_profile, $matches)) {
             $profile = $matches[3];
             if (T3Common::profile_exists($profile)) {
                 return $profile;
             }
         }
         $menuitem = $menu->getItem($menuid);
         $menuid = $menuitem && isset($menuitem->parent) ? $menuitem->parent : 0;
     }
     //Get profile by component name(such as com_content)
     $comname = JRequest::getCmd('option');
     if ($comname) {
         // Check there is assignment with current language and component
         $regex = '/(^|,|\\>|\\n)\\s*' . $lang . '#' . $comname . '\\s*(,[^=]*)?=([^\\<\\n]*)/';
         if (preg_match($regex, $pages_profile, $matches)) {
             $profile = $matches[3];
             if (T3Common::profile_exists($profile)) {
                 return $profile;
             }
         }
         // Check there is assingment with default language and component
         $regex = '/(^|,|\\>|\\n)\\s*' . $comname . '\\s*(,[^=]*)?=([^\\<\\n]*)/';
         if (preg_match($regex, $pages_profile, $matches)) {
             $profile = $matches[3];
             if (T3Common::profile_exists($profile)) {
                 return $profile;
             }
         }
     }
     //Get profile by page name (such as home)
     if (JRequest::getCmd('view') == 'frontpage') {
         $regex = '/(^|,|\\>|\\n)\\s*home(,[^=]*)?=([^\\<\\n]*)/';
         if (preg_match($regex, $pages_profile, $matches)) {
             $profile = $matches[3];
             if (T3Common::profile_exists($profile)) {
                 return $profile;
             }
         }
     }
     // Check there is assingmnet for current language
     $regex = '/(^|,|\\>|\\n)\\s*' . $lang . '(,[^=]*)?=([^\\<\\n]*)/';
     if (preg_match($regex, $pages_profile, $matches)) {
         $profile = $matches[3];
         if (T3Common::profile_exists($profile)) {
             return $profile;
         }
     }
     //Get active profile from user setting
     $profile = T3Common::get_default_profile();
     return $profile;
 }
Ejemplo n.º 2
0
 /**
  * Constructor
  *
  * @param array &$params  Parameters
  *
  * @return void
  */
 function __construct(&$params)
 {
     $this->_params = $params;
     $this->Itemid = T3Common::getItemid();
     //$this->loadMenu();
 }
Ejemplo n.º 3
0
 /**
  * Get menu type
  *
  * @param $menutype string
  *            Menu type name
  *
  * @return string Menu type
  */
 function getMenuType($menutype = null)
 {
     global $option;
     if ($menutype && is_file(T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$menutype}.class.php")) {
         return $menutype;
     }
     /*
      * Not detect handheld if desktop mainnav is used //auto detect if
      * (($mobile=T3Common::mobile_device_detect ())) { if
      * (is_file(T3Path::path(T3_CORE).DS.'menu'.DS."$mobile.class.php"))
      * $menutype = $mobile; else $menutype = 'handheld'; return $menutype; }
      */
     $page_menus = $this->getParam('page_menus');
     $page_menus = str_replace("<br />", "\n", $page_menus);
     //$pmenus = new JParameter($page_menus);
     // Strict standards: Declaration of JParameter::loadSetupFile() should be compatible with that of JRegistry::loadSetupFile()
     $pmenus = $page_menus;
     if (!$page_menus instanceof JRegistry) {
         $pmenus = new JRegistry($page_menus);
     }
     // specify menu type for page
     $menutype = $pmenus->get(T3Common::getItemid());
     if (is_file(T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$menutype}.class.php")) {
         return $menutype;
     }
     // specify menu type for component
     $menutype = $pmenus->get($option);
     if (is_file(T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$menutype}.class.php")) {
         return $menutype;
     }
     // default menu type for site
     $menutype = $this->getParam(T3_TOOL_MENU, 'css');
     if (is_file(T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$menutype}.class.php")) {
         return $menutype;
     }
     return 'css';
 }
Ejemplo n.º 4
0
 function get_active_profile()
 {
     static $profile = null;
     if ($profile) {
         return $profile;
     }
     $params = T3Common::get_template_based_params();
     $pages_profile = strtolower($params->get('pages_profile'));
     $profile = '';
     //Get profile by component name(such as com_content)
     $comname = JRequest::getCmd('option');
     if ($comname) {
         $regex = '/(^|,|\\>|\\n)\\s*' . $comname . '\\s*(,[^=]*)?=([^\\<\\n]*)/';
         if (preg_match($regex, $pages_profile, $matches)) {
             $profile = $matches[3];
             if (T3Common::profile_exists($profile)) {
                 return $profile;
             }
         }
     }
     //Get active profile by pages
     $menu =& JSite::getMenu();
     $menuid = T3Common::getItemid();
     while ($menuid && !$profile) {
         $regex = '/(^|,|\\>|\\n)\\s*' . $menuid . '(,[^=]*)?=([^\\<\\n]*)/';
         if (preg_match($regex, $pages_profile, $matches)) {
             $profile = $matches[3];
             if (T3Common::profile_exists($profile)) {
                 return $profile;
             }
         }
         $menuitem = $menu->getItem($menuid);
         $menuid = $menuitem && isset($menuitem->parent) ? $menuitem->parent : 0;
     }
     //Get profile by page name (such as home)
     if (JRequest::getCmd('view') == 'frontpage') {
         $regex = '/(^|,|\\>|\\n)\\s*home(,[^=]*)?=([^\\<\\n]*)/';
         if (preg_match($regex, $pages_profile, $matches)) {
             $profile = $matches[3];
             if (T3Common::profile_exists($profile)) {
                 return $profile;
             }
         }
     }
     //Get active profile from user setting
     $profile = T3Common::get_default_profile();
     return $profile;
 }
Ejemplo n.º 5
0
 function getMenuType($menutype = null)
 {
     global $option;
     if ($menutype && is_file(T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$menutype}.class.php")) {
         return $menutype;
     }
     /* Not detect handheld if desktop mainnav is used
     		//auto detect 
     		if (($mobile=T3Common::mobile_device_detect ())) {
     			if (is_file(T3Path::path(T3_CORE).DS.'menu'.DS."$mobile.class.php")) $menutype = $mobile;
     			else $menutype = 'handheld';
     			return $menutype;
     		}
     		*/
     $page_menus = $this->getParam('page_menus');
     $page_menus = str_replace("<br />", "\n", $page_menus);
     $pmenus = new JParameter($page_menus);
     //specify menu type for page
     $menutype = $pmenus->get(T3Common::getItemid());
     if (is_file(T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$menutype}.class.php")) {
         return $menutype;
     }
     //specify menu type for component
     $menutype = $pmenus->get($option);
     if (is_file(T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$menutype}.class.php")) {
         return $menutype;
     }
     //default menu type for site
     $menutype = $this->getParam(T3_TOOL_MENU, 'css');
     if (is_file(T3Path::path(T3_CORE) . DS . 'menu' . DS . "{$menutype}.class.php")) {
         return $menutype;
     }
     return 'css';
 }