Example #1
0
 public static function GetSize($intImageTypeId)
 {
     list($intDefWidth, $intDefHeight) = ImagesType::$SizeArray[$intImageTypeId];
     $strCfg = ImagesType::GetConfigKey($intImageTypeId);
     $strCfgWidth = $strCfg . '_WIDTH';
     $strCfgHeight = $strCfg . '_HEIGHT';
     $intWidth = Yii::app()->theme->info->{$strCfgWidth};
     $intHeight = Yii::app()->theme->info->{$strCfgHeight};
     //If our theme doesn't have the config there, see if we have a 3.0 style config.xml
     if (empty($intWidth) || empty($intHeight)) {
         $fnOptions = YiiBase::getPathOfAlias('webroot') . "/themes/" . Yii::app()->theme->name . "/config.xml";
         if (file_exists($fnOptions)) {
             $strXml = file_get_contents($fnOptions);
             // Parse xml for response values
             $oXML = new SimpleXMLElement($strXml);
             if (isset($oXML->defaults->configuration)) {
                 foreach ($oXML->defaults->configuration as $item) {
                     if ((string) $item->key_name == $strCfgWidth) {
                         $intWidth = (string) $item->key_value;
                     }
                     if ((string) $item->key_name == $strCfgHeight) {
                         $intHeight = (string) $item->key_value;
                     }
                 }
             }
         }
     }
     //if all else STILL fails, go old school and get them from the config (And even more so, use defaults)
     if (empty($intWidth) || empty($intHeight)) {
         $intWidth = _xls_get_conf($strCfgWidth, $intDefWidth);
         $intHeight = _xls_get_conf($strCfgHeight, $intDefHeight);
     }
     return array($intWidth, $intHeight);
 }