Exemplo n.º 1
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];
 }
Exemplo n.º 2
0
 public function displayType()
 {
     $extension = strtolower(pathinfo($this->pointer, PATHINFO_EXTENSION));
     if ($this->getType() == 'embed') {
         $extension = 'mpg';
     }
     return "<img class='icon' src='" . Ajde_Resource_FileIcon::_($extension) . "'' />";
 }