Esempio n. 1
0
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'base64':
             $image = new Ajde_Resource_Image($this->attributes['filename']);
             $image->setWidth($this->attributes['width']);
             $image->setHeight($this->attributes['height']);
             $image->setCrop($this->attributes['crop']);
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:imageBase64'));
             $controller->setImage($image);
             $controller->setWidth(issetor($this->attributes['width'], null));
             $controller->setHeight(issetor($this->attributes['height'], null));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'html':
             $image = new Ajde_Resource_Image($this->attributes['filename']);
             $image->setWidth($this->attributes['width']);
             $image->setHeight($this->attributes['height']);
             $image->setCrop($this->attributes['crop']);
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:image'));
             $controller->setImage($image);
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'image':
             return false;
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception('Missing required attributes for component call');
 }
Esempio n. 2
0
 public function getFilename($width = null, $height = null, $crop = null)
 {
     $path = $this->uploadDirectory . $this->thumbnail;
     $image = new Ajde_Resource_Image($path);
     $image->setWidth($width);
     $image->setHeight($height);
     $image->setCrop($crop);
     return $image->getLinkUrl();
 }
Esempio n. 3
0
 public static function fromFingerprint($fingerprint)
 {
     $array = self::decodeFingerprint($fingerprint);
     extract($array);
     $image = new Ajde_Resource_Image($s);
     $image->setWidth($w);
     $image->setHeight($h);
     $image->setCrop($c);
     return $image;
 }
Esempio n. 4
0
 public static function getImageTag($filename, $width = null, $height = null, $crop = true, $class = '', $lazy = false, $absoluteUrl = false)
 {
     $image = new Ajde_Resource_Image($filename);
     $image->setWidth($width);
     $image->setHeight($height);
     $image->setCrop($crop);
     $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:image'));
     $controller->setImage($image);
     $controller->setExtraClass($class);
     $controller->setLazy($lazy);
     $controller->setAbsoluteUrl($absoluteUrl);
     return $controller->invoke();
 }
Esempio n. 5
0
 private function getMultipleRow($crudId)
 {
     $session = new Ajde_Session('AC.Crud');
     /* @var $crud Ajde_Crud */
     $crud = $session->getModel($crudId);
     /* @var $model Ajde_Model */
     $model = $crud->getModel();
     // Get field properties
     $id = Ajde::app()->getRequest()->getParam('id');
     $fieldName = Ajde::app()->getRequest()->getParam('field');
     $fieldProperties = $crud->getOption('fields.' . $fieldName);
     $modelName = $crud->getOption('fields.' . $fieldName . '.modelName', $fieldName);
     // Get child model
     $className = ucfirst($modelName) . 'Model';
     $child = new $className();
     /* @var $child Ajde_Model */
     $child->loadByPK($id);
     $ret = [];
     if (isset($fieldProperties['tableFields'])) {
         foreach ($fieldProperties['tableFields'] as $extraField) {
             $value = $child->has($extraField['name']) ? $child->get($extraField['name']) : false;
             $type = $extraField['type'];
             $html = false;
             if ($type == 'file' && $value) {
                 $extension = pathinfo($value, PATHINFO_EXTENSION);
                 if ($isImage = in_array(strtolower($extension), ['jpg', 'jpeg', 'png', 'gif'])) {
                     $thumbDim = isset($fieldProperties['thumbDim']) ? $fieldProperties['thumbDim'] : ['width' => 75, 'height' => 75];
                     $html = "<a class='imagePreview img' title='" . esc($value) . "' href='" . $extraField['saveDir'] . $value . "' target='_blank'>";
                     $image = new Ajde_Resource_Image($extraField['saveDir'] . $value);
                     $image->setWidth($thumbDim['width']);
                     $image->setHeight($thumbDim['height']);
                     $image->setCrop(true);
                     $html = $html . "<img src='" . $image->getLinkUrl() . "' width='" . $thumbDim['width'] . "' height='" . $thumbDim['height'] . "' />";
                     $html = $html . '</a>';
                 } else {
                     $html = "<img class='icon' src='" . Ajde_Resource_FileIcon::_($extension) . "' />";
                     $html = $html . " <a class='filePreview preview' href='" . $extraField['saveDir'] . $value . "' target='_blank'>" . $value . '</a>';
                 }
             } else {
                 if ($type == 'text') {
                     $html = $value;
                 }
             }
             if ($html) {
                 $ret[] = $html;
             }
         }
     }
     $success = true;
     return ['operation' => 'getMultipleRow', 'success' => $success, 'displayField' => $child->get($child->getDisplayField()), 'data' => $ret];
 }
 public function imageData()
 {
     $fingerprint = Ajde::app()->getRequest()->getRaw('id');
     $image = Ajde_Resource_Image::fromFingerprint($fingerprint);
     //$session = new Ajde_Session('AC.Image');
     //if (!$session->has($imageId)) {
     //Ajde::app()->getResponse()->redirectNotFound();
     //}
     /* @var $image Ajde_Resource_Image */
     //$image = $session->get($imageId);
     //$image = $session->getOnce($imageId);
     // TODO: add crop/resize option
     $image->crop($image->getHeight(), $image->getWidth());
     Ajde::app()->getDocument()->setContentType($image->getMimeType());
     $output = $image->getImage();
     return $output;
 }