Esempio n. 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);
 }
Esempio n. 2
0
 /**
  * Create all our thumbnail sizes are part of our upload process
  * @param $objImage
  */
 protected function createThumbnails($objImage)
 {
     foreach (ImagesType::$NameArray as $intType => $value) {
         if ($intType > 0) {
             list($intWidth, $intHeight) = ImagesType::GetSize($intType);
             $this->createThumb($objImage, $intWidth, $intHeight, $intType);
         }
     }
 }
Esempio n. 3
0
 public static function LoadByRowidSize($id, $intSize)
 {
     if ($intSize == ImagesType::normal) {
         return Images::model()->findByPk($id);
     }
     list($intWidth, $intHeight) = ImagesType::GetSize($intSize);
     return Images::LoadByWidthHeightParent($intWidth, $intHeight, $id);
 }
Esempio n. 4
0
 public function getProductPhotos($absolute = false)
 {
     $objImages = Images::model()->findAll(array('condition' => 'product_id=:id AND `parent`=`id` order by `index`', 'params' => array(':id' => $this->id)));
     // If this is a child product and it has no images, check to see if the master has images and use those
     if (count($objImages) == 0) {
         $objImages = Images::model()->findAll(array('condition' => 'product_id=:id AND `parent`=`id` order by `index`', 'params' => array(':id' => $this->parent)));
     }
     $arrImages = array();
     foreach ($objImages as $obj) {
         $a = array();
         $a['image'] = Images::GetLink($obj->id, ImagesType::pdetail, $absolute);
         $a['image_thumb'] = Images::GetLink($obj->id, ImagesType::preview, $absolute);
         $a['image_alt'] = $this->Title;
         $a['image_desc'] = '';
         $a['image_large'] = Images::GetLink($obj->id, ImagesType::normal, $absolute);
         if (CPropertyValue::ensureInteger(Yii::app()->params['LIGHTSPEED_CLOUD']) === 0) {
             list($wt, $ht) = ImagesType::GetSize(ImagesType::pdetail);
             if ($obj->width <= $wt && $obj->height <= $ht) {
                 $a['image_large'] = $a['image'];
             }
         }
         $arrImages[] = $a;
     }
     //This will force the no-product image
     if (count($objImages) == 0) {
         $a = array();
         $a['image'] = Images::GetImageFallbackPath($absolute);
         $a['image_large'] = Images::GetImageFallbackPath();
         $a['image_thumb'] = Images::GetImageFallbackPath();
         $a['image_alt'] = $this->Title;
         $a['image_desc'] = '';
         $arrImages[] = $a;
     }
     return $arrImages;
 }