[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/includes/runtime/ -> Theme.php (source)

   1  <?php
   2  /*+***********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   *************************************************************************************/
  10  
  11  class Vtiger_Theme extends Vtiger_Viewer {
  12  
  13      /**
  14       * Function to get the path of a given style sheet or default style sheet
  15       * @param <String> $fileName
  16       * @return <string / Boolean> - file path , false if not exists
  17       */
  18  	public static function getStylePath($fileName=''){
  19          // Default CSS for better performance, LESS format for development.
  20          if(empty($fileName)) {
  21              $fileName = 'style.css';
  22          }
  23          $filePath =  self::getThemePath() . '/' . $fileName;
  24          $fallbackPath = self::getBaseThemePath() . '/' . self::getDefaultThemeName() .'/' .'style.less' ;
  25  
  26          $completeFilePath = Vtiger_Loader::resolveNameToPath('~'.$filePath);
  27          $completeFallBackPath = Vtiger_Loader::resolveNameToPath('~'.$fallbackPath);
  28  
  29          if(file_exists($completeFilePath)){
  30              return $filePath;
  31          }
  32          else if(file_exists($completeFallBackPath)){
  33              return $fallbackPath;
  34          }
  35          // Exception should be thrown???
  36          return false;
  37      }
  38  
  39      /**
  40       * Function to get the image path
  41       * This checks image in selected theme if not in images folder if it doest nor exists either case will retutn false
  42       * @param <string> $imageFileName - file name with extension
  43       * @return <string/boolean> - returns file path if exists or false;
  44       */
  45  	public static function getImagePath($imageFileName){
  46          $imageFilePath = self::getThemePath() . '/' . 'images' . '/' . $imageFileName;
  47          $fallbackPath = self::getBaseThemePath() . '/' . 'images' . '/' . $imageFileName;
  48          $completeImageFilePath = Vtiger_Loader::resolveNameToPath('~'.$imageFilePath);
  49          $completeFallBackThemePath = Vtiger_Loader::resolveNameToPath('~'.$fallbackPath);
  50  
  51          if(file_exists($completeImageFilePath)){
  52              return $imageFilePath;
  53          }
  54          else if(file_exists($completeFallBackThemePath)){
  55              return $fallbackPath;
  56          }
  57          return false;
  58      }
  59  
  60      /**
  61       * Function to get the Base Theme Path, until theme folder not selected theme folder
  62       * @return <string> - theme folder
  63       */
  64  	public static function getBaseThemePath(){
  65          return 'layouts'. '/' . self::getLayoutName(). '/skins';
  66      }
  67  
  68      /**
  69       * Function to get the selected theme folder path
  70       * @return <string> -  selected theme path
  71       */
  72  	public static function getThemePath($theme=''){
  73          if(empty($theme)) {
  74              $theme = self::getDefaultThemeName();
  75          }
  76  
  77          $selectedThemePath = self::getBaseThemePath() . '/' . $theme;
  78          $fallBackThemePath = self::getBaseThemePath() . '/' . self::getDefaultThemeName();
  79  
  80          $completeSelectedThemePath = Vtiger_Loader::resolveNameToPath('~'.$selectedThemePath);
  81          $completeFallBackThemePath = Vtiger_Loader::resolveNameToPath('~'.$fallBackThemePath);
  82  
  83          if(file_exists($completeSelectedThemePath)){
  84              return $selectedThemePath;
  85          }
  86          else if(file_exists($completeFallBackThemePath)){
  87              return $fallBackThemePath;
  88          }
  89          return false;
  90      }
  91  
  92      /**
  93       * Function to get the default theme name
  94       * @return <String> - Default theme name
  95       */
  96  	public static function getDefaultThemeName(){
  97          $currentUserModel = Users_Record_Model::getCurrentUserModel();
  98          $theme = $currentUserModel->get('theme');
  99          return empty($theme)? self::DEFAULTTHEME : $theme;
 100      }
 101  
 102      /**
 103       * Function to returns all skins(themes)
 104       * @return <Array>
 105       */
 106      public static function getAllSkins(){
 107          return Vtiger_Util_Helper::getAllSkins();
 108      }
 109  
 110      /**
 111       * Function returns the current users skin(theme) path
 112        */
 113  	public static function getCurrentUserThemePath() {
 114          $themeName = self::getDefaultThemeName();
 115          $baseLayoutPath = self::getBaseThemePath();
 116          return $baseLayoutPath. '/' .$themeName;
 117      }
 118  }
 119  
 120  function vimage_path($imageName) {
 121      $args = func_get_args();
 122      return call_user_func_array(array('Vtiger_Theme', 'getImagePath'), $args);
 123  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1