Ejemplo n.º 1
0
 /**
  * @param $path
  * @param $type
  * @param $szField
  */
 public function show($path, $type, $szField)
 {
     $design = CMSDesign::getInstance();
     //
     $path = stripslashes($path);
     $type = stripslashes($type);
     $szField = stripslashes($szField);
     $modelName = \Extasy\Model\Model::isModel($type);
     $fields = call_user_func($modelName, 'getFieldsInfo');
     $aInfo = @getimagesize(\Extasy\CMS::getFilesPath() . ${$fields}[$szField]['base_dir'] . $path);
     $szFilename = \Extasy\CMS::getFilesHttpRoot() . $fields[$szField]['base_dir'] . $path;
     $x = '?' . rand(0, 1000000);
     if (isset($aInfo[2])) {
         $aParse['szFilename'] = $szFilename;
     }
     $design->popupBegin();
     $design->popupHeader('Просмотр изображения');
     $design->formBegin();
     $design->br();
     if (!empty($szFilename)) {
         print '<img src="' . $szFilename . $x . '">';
     }
     $design->popupEnd();
     $this->output();
 }
Ejemplo n.º 2
0
 /**
  * (non-PHPdoc)
  * @see \Extasy\Columns\BaseColumn::getAdminFormValue()
  */
 public function getAdminFormValue($onlyResizes = false)
 {
     static $librariesLoaded = false;
     $nId = $this->document->id->getValue();
     if (!empty($nId)) {
         $baseUrl = \Extasy\CMS::getFilesHttpRoot() . $this->getSrc();
         $filePath = \Extasy\CMS::getFilesPath() . $this->getSrc();
         $aPlaceholder = array();
         $aParse = array();
         if ($this->imageExists()) {
             $aSize = getimagesize($filePath);
             $aParse[] = array('url' => $baseUrl, 'size_x' => $aSize[0], 'size_y' => $aSize[1], 'basename' => 'default');
             // Если передан массив images
             $bIsArray = isset($this->fieldInfo['images']) && is_array($this->fieldInfo['images']);
             if ($bIsArray) {
                 foreach ($this->fieldInfo['images'] as $key => $value) {
                     $value = explode('x', $value);
                     if (sizeof($value) == 1) {
                         $w = $h = $value[0];
                     } else {
                         list($w, $h) = $value;
                     }
                     $imageUrl = imageHelper::getTimthumbUrl($baseUrl, $w, $h) . '&rand=' . rand();
                     $aParse[] = array('size_x' => $w, 'size_y' => $h, 'url' => $imageUrl, 'basename' => $key);
                 }
             }
             // setup thumbnail
             $aPlaceholder['thumbnailSrc'] = imageHelper::getTimthumbUrl($baseUrl, self::thumbWidth, self::thumbHeight) . '&rand=' . rand();
         } else {
             $aSize = null;
         }
         $aPlaceholder['aList'] = $aParse;
     }
     $aPlaceholder['name'] = $this->szFieldName;
     $aPlaceholder['value'] = $this->aValue;
     $aPlaceholder['librariesLoaded'] = $librariesLoaded;
     $aPlaceholder['required'] = !empty($this->fieldInfo['required']);
     $aPlaceholder['title'] = !empty($this->fieldInfo['title']) ? $this->fieldInfo['title'] : '';
     if ($onlyResizes) {
         $template = __DIR__ . DIRECTORY_SEPARATOR . 'image/resizes.tpl';
     } else {
         $template = __DIR__ . DIRECTORY_SEPARATOR . 'image/formAdmin.tpl';
     }
     $szResult = UParser::parsePHPFile($template, $aPlaceholder);
     $librariesLoaded = true;
     return $szResult;
 }