コード例 #1
0
ファイル: IsotopeGallery.php プロジェクト: rikaix/core-1
 /**
  * Set a value
  * @param string
  * @param mixed
  */
 public function __set($strKey, $varValue)
 {
     switch ($strKey) {
         case 'files':
             $this->arrFiles = array();
             $varValue = deserialize($varValue);
             if (is_array($varValue) && count($varValue)) {
                 foreach ($varValue as $k => $file) {
                     $strFile = 'isotope/' . strtolower(substr($file['src'], 0, 1)) . '/' . $file['src'];
                     if (is_file(TL_ROOT . '/' . $strFile)) {
                         $objFile = new File($strFile);
                         if ($objFile->isGdImage) {
                             foreach ((array) $this->Isotope->Config->imageSizes as $size) {
                                 $strImage = $this->getImage($strFile, $size['width'], $size['height'], $size['mode']);
                                 if ($size['watermark'] != '') {
                                     $strImage = IsotopeFrontend::watermarkImage($strImage, $size['watermark'], $size['position']);
                                 }
                                 $arrSize = @getimagesize(TL_ROOT . '/' . $strImage);
                                 if (is_array($arrSize) && strlen($arrSize[3])) {
                                     $file[$size['name'] . '_size'] = $arrSize[3];
                                 }
                                 $file['alt'] = specialchars($file['alt']);
                                 $file['desc'] = specialchars($file['desc']);
                                 $file[$size['name']] = $strImage;
                             }
                             $this->arrFiles[] = $file;
                         }
                     }
                 }
             }
             // No image available, add default image
             if (!count($this->arrFiles) && is_file(TL_ROOT . '/' . $this->Isotope->Config->missing_image_placeholder)) {
                 foreach ((array) $this->Isotope->Config->imageSizes as $size) {
                     $strImage = $this->getImage($this->Isotope->Config->missing_image_placeholder, $size['width'], $size['height'], $size['mode']);
                     $arrSize = @getimagesize(TL_ROOT . '/' . $strImage);
                     if (is_array($arrSize) && strlen($arrSize[3])) {
                         $file[$size['name'] . '_size'] = $arrSize[3];
                     }
                     $file[$size['name']] = $strImage;
                 }
                 $this->arrFiles[] = $file;
             }
             break;
         default:
             $this->arrData[$strKey] = $varValue;
             break;
     }
 }