Beispiel #1
0
 function renderCell($key, $value, $item, $columnName)
 {
     $pageId = $this->application->getPageId();
     if ($this->user->acl($pageId, 'all') or $this->user->acl($pageId, 'edit')) {
         $output = org_glizy_Assets::makeLinkWithIcon('actionsMVC', 'icon-pencil btn-icon', array('title' => __T('GLZ_RECORD_EDIT'), 'id' => $key, 'action' => 'edit'));
     }
     if (!$item->language_isDefault) {
         $output .= org_glizy_Assets::makeLinkWithIcon('actionsMVC', 'icon-trash btn-icon', array('title' => __T('GLZ_RECORD_DELETE'), 'id' => $key, 'action' => 'delete'), __T('conferma cancellazione record'));
     }
     return $output;
 }
Beispiel #2
0
 function getIconFileName()
 {
     return org_glizy_Assets::get('ICON_MEDIA_OTHER');
 }
Beispiel #3
0
    function render()
    {
        if (!$this->iterator) {
            $this->addOutputCode('<p>' . $this->getAttribute('emptySearchLabel') . '</p>');
            return;
        }
        // legge le colonne da visualizzare dai figli
        // NOTA: le colonne sono gi� state lette sul process
        // ma vengono rilette perch� pu� essere variata la visibilit�
        $this->_columns = array();
        for ($i = 0; $i < count($this->childComponents); $i++) {
            $this->_columns[] = $this->childComponents[$i]->getProperties();
        }
        $addJsCode = false;
        $output = '';
        if ($this->_totalRecord > 0) {
            $class = $this->getAttribute('tableCssClass') != '' ? ' class="' . $this->getAttribute('tableCssClass') . '"' : '';
            $output .= '<table id="' . $this->getId() . '"' . $class . '>';
            if ($this->getAttribute('label') != '') {
                $output .= '<caption>' . $this->getAttribute('label') . '</caption>';
            }
            if ($this->getAttribute('drawHeader')) {
                // disegna le colonne
                $output .= '<thead>';
                $output .= '<tr>';
                //foreach ($this->_columns as $v)
                for ($i = 0; $i < count($this->_columns); $i++) {
                    $v = $this->_columns[$i];
                    if ($v['visible'] === true) {
                        $cssClass = !empty($v['cssClass']) ? ' class="' . $v['cssClass'] . '"' : '';
                        $id = !empty($v['id']) ? ' id="' . $v['id'] . '"' : '';
                        $width = !empty($v['width']) ? ' style="width: ' . $v['width'] . 'px;"' : '';
                        if (!empty($v['renderCell'])) {
                            $renderCell =& org_glizy_ObjectFactory::createObject($v['renderCell'], $this->_application);
                            if (method_exists($renderCell, 'getHeader')) {
                                $v['headerText'] = $renderCell->getHeader($v['headerText']);
                            }
                            unset($renderCell);
                        }
                        if (!empty($v['command'])) {
                            $output .= '<th' . $id . $cssClass . $width . '>';
                            if ($v['command'] == 'publish') {
                                $output .= '<input name="publishAll" value="" type="checkbox" class="js-selectall" />';
                            }
                            $output .= '</th>';
                        } else {
                            if (!$this->getAttribute('skipOrder') && $v['orderable']) {
                                $addJsCode = true;
                                $headerId = 'orderBy_' . $i;
                                $headerClass = 'DataGridHeader';
                                $headerImage = '';
                                if ($i == $this->_orderBy) {
                                    $headerId .= '_' . ($this->_orderDirection == 'ASC' ? 'DESC' : 'ASC');
                                    $headerImage = $this->_orderDirection == 'ASC' ? '<span class="ui-icon ui-icon-triangle-1-s"></span>' : '<span class="ui-icon ui-icon-triangle-1-n"></span>';
                                } else {
                                    $headerId .= '_' . $this->_orderDirection;
                                }
                                $output .= '<th' . $id . $cssClass . $width . '><a href="#" id="' . $headerId . '" class="' . $headerClass . '">' . $v['headerText'] . '</a>' . $headerImage . '</th>';
                            } else {
                                $output .= '<th' . $cssClass . $width . '>' . $v['headerText'] . '</th>';
                            }
                        }
                    }
                }
                $output .= '</tr>';
                $output .= '</thead>';
            }
            if (!$this->getAttribute('hideTotals')) {
                $output .= '<tfoot>';
                $output .= '<tr><td style="text-align: right;" colspan="' . count($this->_columns) . '">' . __T('GLZ_TOTAL_RECORDS') . ' ' . $this->_totalRecord . '</td></tr>';
                $output .= '</tfoot>';
            }
            $output .= '<tbody>';
            $key = 0;
            $tempCssClass = $this->_cssClass;
            $rowCellClass = $this->getAttribute('renderRow');
            if (!empty($rowCellClass)) {
                $rowCellClass =& org_glizy_ObjectFactory::createObject($rowCellClass, $this->_application);
            }
            foreach ($this->iterator as $ar) {
                $v = $ar->getValuesAsArray(true);
                $rowOutput = '';
                foreach ($this->_columns as $vv) {
                    if ($vv['key']) {
                        $key = $v[$vv['columnName']];
                    }
                    if ($vv['visible'] === false) {
                        continue;
                    }
                    $tempOutput = '';
                    $cssClass = '';
                    if (!empty($vv['renderCell'])) {
                        $renderCell =& org_glizy_ObjectFactory::createObject($vv['renderCell'], $this->_application);
                        if (is_object($renderCell)) {
                            $tempOutput .= $renderCell->renderCell($key, isset($v[$vv['columnName']]) ? $v[$vv['columnName']] : '', $ar, $vv['columnName']);
                            $cssClass = !empty($vv['cssClass']) ? $vv['cssClass'] : '';
                            if (method_exists($renderCell, 'getCssClass')) {
                                $cssClass = $renderCell->getCssClass($key, isset($v[$vv['columnName']]) ? $v[$vv['columnName']] : '', $v);
                            }
                        }
                    } else {
                        if (!empty($vv['command'])) {
                            $addJsCode = true;
                            if (strtolower($this->_application->getPageId()) == 'usergroups') {
                                if ($vv['command'] == 'delete' && $v['usergroup_backEndAccess']) {
                                    continue;
                                }
                            }
                            switch ($vv['command']) {
                                case 'edit':
                                    if ($this->_user->acl($vv['aclService'], $vv['command'])) {
                                        if (!is_null($this->_versionFieldName)) {
                                            if ($this->_user->acl($vv['aclService'], $vv['command'])) {
                                                $icon = org_glizy_Assets::get('ICON_EDIT');
                                                $ar =& $this->_dataProvider->getNewObject();
                                                $joinFields = $ar->getJoinFields();
                                                $result = $ar->find(array($joinFields['detailTable'] => $key, $this->_versionFieldName => 'PUBLISHED'));
                                                //$result = $ar->find(array($joinFields['detailTable'] => $key, $this->_versionFieldName => 'PUBLISHED', $this->_languageFieldName => $this->_application->getEditingLanguageId()));
                                            } else {
                                                $icon = org_glizy_Assets::get('ICON_EDITDRAFT');
                                                $result = true;
                                            }
                                            if ($result) {
                                                $tempOutput .= '<img title="' . org_glizy_locale_Locale::get('GLZ_RECORD_EDIT') . '" id="edit_' . $key . '" class="DataGridCommand" src="' . $icon . '" width="16" height="16" border="0" />';
                                            } else {
                                                $tempOutput .= '<img id="" class="DataGridCommand" src="' . org_glizy_Assets::get('ICON_EDIT_OFF') . '" width="16" height="16" border="0" />';
                                            }
                                        } else {
                                            $tempOutput .= '<img title="' . org_glizy_locale_Locale::get('GLZ_RECORD_EDIT') . '" id="edit_' . $key . '" class="DataGridCommand" src="' . org_glizy_Assets::get('ICON_EDIT') . '" width="16" height="16" border="0" />';
                                        }
                                    }
                                    break;
                                case 'editDraft':
                                    if (!is_null($this->_versionFieldName) && $this->_user->acl($vv['aclService'], $vv['command'])) {
                                        $ar =& $this->_dataProvider->getNewObject();
                                        $joinFields = $ar->getJoinFields();
                                        $result = $ar->find(array($joinFields['detailTable'] => $key, $this->_versionFieldName => 'DRAFT'));
                                        //$result = $ar->find(array($joinFields['detailTable'] => $key, $this->_versionFieldName => 'DRAFT', $this->_languageFieldName => $this->_application->getEditingLanguageId()));
                                        if ($result) {
                                            $tempOutput .= '<img title="' . org_glizy_locale_Locale::get('GLZ_RECORD_EDIT') . '" id="editDraft_' . $key . '" class="DataGridCommand" src="' . org_glizy_Assets::get('ICON_EDITDRAFT') . '" width="16" height="16" border="0" />';
                                        } else {
                                            $tempOutput .= '<img id="" class="DataGridCommand" src="' . org_glizy_Assets::get('ICON_EDITDRAFT_OFF') . '" width="16" height="16" border="0" />';
                                        }
                                    }
                                    break;
                                case 'preview':
                                    $tempOutput .= '<img title="' . org_glizy_locale_Locale::get('GLZ_RECORD_PREVIEW') . '" id="preview_' . $key . '" class="DataGridCommand" src="' . org_glizy_Assets::get('ICON_PREVIEW') . '" width="16" height="16" border="0" />';
                                    break;
                                case 'delete':
                                    if ($this->_user->acl($vv['aclService'], $vv['command'])) {
                                        $tempOutput .= '<img title="' . org_glizy_locale_Locale::get('GLZ_RECORD_DELETE') . '" id="delete_' . $key . '" class="DataGridCommand" src="' . org_glizy_Assets::get('ICON_DELETE') . '" width="16" height="16" border="0" />';
                                    }
                                    break;
                                case 'publish':
                                    if ($this->_user->acl($vv['aclService'], $vv['command'])) {
                                        $tempOutput .= '<input name="publish[]" value="' . $key . '" type="checkbox">';
                                    }
                                    break;
                            }
                        } else {
                            if (!is_null($this->_languageFieldName) && $v[$this->_languageFieldName] != $this->_application->getEditingLanguageId()) {
                                $tempOutput .= '<em>' . $v[$vv['columnName']] . '</em>';
                            } else {
                                $tempOutput .= $v[$vv['columnName']];
                            }
                        }
                    }
                    $cssClass = !empty($cssClass) ? ' class="' . $cssClass . '"' : '';
                    $rowOutput .= '<td style="text-align: ' . $vv['align'] . ';"' . $cssClass . '>' . $tempOutput . '</td>';
                }
                if (!count($tempCssClass)) {
                    $tempCssClass = $this->_cssClass;
                }
                $cssClass = array_shift($tempCssClass);
                if (!empty($rowCellClass)) {
                    $output .= $rowCellClass->renderRow($v, $cssClass);
                } else {
                    $output .= '<tr class="' . $cssClass . '" id="row_' . $key . '">';
                }
                $output .= $rowOutput . '</tr>';
            }
            $output .= '</tbody>';
            $output .= '</table>';
        } else {
            $emptyLabel = $this->getAttribute('emptyLabel');
            if (!empty($emptyLabel)) {
                $output .= '<p class="datagridEmpty">' . $emptyLabel . '</p>';
            }
        }
        $this->addOutputCode($output);
        if (!$addJsCode) {
            return;
        }
        $jsId = $this->getId();
        $jsMessage = org_glizy_locale_Locale::get('GLZ_RECORD_MSG_DELETE');
        // TODO
        // controllare che il valore di controller sia settato
        $controllerClass =& $this->getAttribute('controller');
        if (is_object($controllerClass)) {
            $jsStateUrl = $controllerClass->changeStateUrl();
            $jsStateUrl = str_replace(__Link::makeUrl('link', array('pageId' => $this->_application->getPageId())) . '?', '', $jsStateUrl);
            $jsStateUrl = __Link::removeParams(array($controllerClass->getId() . '_recordId'), $jsStateUrl);
            $jsCurrentStateUrl = $controllerClass->changeStateUrl($controllerClass->getState());
            $controllerId = $controllerClass->getid();
        } else {
            $jsStateUrl = __Link::removeParams(array($jsId . '_orderBy', $jsId . '_orderDirection'));
            $jsCurrentStateUrl = $jsStateUrl;
            $controllerId = '';
        }
        $output = '';
        $output = <<<EOD
<script language="JavaScript" type="text/JavaScript">
jQuery(document).ready(function() {
    jQuery('#{$jsId} input.js-selectall').change(function(){
        var checked = this.checked;
        \$(this).closest('table').find("input[name='publish[]']").each(function(i, el){
            el.checked = checked;
        })
    });

    jQuery(['#{$jsId} .DataGridCommand', '#{$jsId} .DataGridHeader']).each(function(index,element)
    {
        jQuery( element ).css( {cursor: 'pointer'} );
        jQuery( element ).click( function()
        {
            var command = this.id.split('_');
            var loc = "{$jsStateUrl}"+command[0]+"&{$controllerId}_recordId="+command[1];
            switch (command[0])
            {
                case 'delete':
                    this.parentNode.parentNode.oldClass2    = this.parentNode.parentNode.oldClass;
                    this.parentNode.parentNode.className2    = this.parentNode.parentNode.className;
                    this.parentNode.parentNode.className    = "ruled";
                    this.parentNode.parentNode.oldClass        = "ruled";

                    if (confirm("{$jsMessage}"))
                    {
                        location.href = loc;
                    }

                    this.parentNode.parentNode.oldClass    = this.parentNode.parentNode.oldClass2;
                    this.parentNode.parentNode.className = this.parentNode.parentNode.oldClass2;
                    break;
                case 'orderBy':
                    loc = "{$jsCurrentStateUrl}&{$jsId}_orderBy="+command[1]+"&{$jsId}_orderDirection="+command[2];
                    location.href = loc;

                default:
                    location.href = loc;
                    break;

            }
        });
    });
});
</script>
EOD;
        if (!empty($output)) {
            $this->addOutputCode($output);
        }
    }
Beispiel #4
0
 private function resizeImage_im($cacheFileName, $width, $height, $crop = false, $cropOffset = 1, $forceSize = false, $usePiramidalSizes = true, $resize = true)
 {
     if (file_exists($this->getFileName())) {
         $originalSizes = $this->getOriginalSizes();
         $finalSizes = $this->resizeImageGetFinalSizes($width, $height, $crop, $cropOffset, $forceSize);
         $filename = utf8_encode(realpath($this->getFileName()));
         $cacheFileName = str_replace(__Paths::get('CACHE'), org_glizy_Paths::getRealPath('CACHE'), $cacheFileName);
         $thumb = new Imagick();
         $thumb->readImage($this->getFileName());
         if ($resize) {
             $thumb->resizeImage($finalSizes['width'], $finalSizes['height'], Imagick::FILTER_LANCZOS, 1);
             if ($crop) {
                 $thumb->cropImage($width, $height, -$finalSizes['cropX'], -$finalSizes['cropY']);
             }
             $thumb->setImageCompressionQuality(org_glizy_Config::get('JPG_COMPRESSION'));
             $thumb->stripImage();
         }
         if ($this->watermark) {
             $this->insertWatermark($thumb, $crop ? $width : $finalSizes['width'], $crop ? $height : $finalSizes['height'], 'Imagick', false);
         }
         $thumb->writeImage($cacheFileName);
         $thumb->clear();
         $thumb->destroy();
         @touch($cacheFileName, filemtime($this->getFileName()));
         @chmod($cacheFileName, 0777);
         $retInfo = array('imageType' => IMG_JPG, 'fileName' => $cacheFileName, 'width' => $crop ? $width : $finalSizes['width'], 'height' => $crop ? $height : $finalSizes['height'], 'originalWidth' => $originalSizes['width'], 'originalHeight' => $originalSizes['height']);
     } else {
         $fileName = org_glizy_Assets::get('ICON_MEDIA_IMAGE');
         list($width, $height, $imagetypes) = getImageSize($fileName);
         $retInfo = array('imageType' => IMG_GIF, 'fileName' => $fileName, 'width' => $width, 'height' => $height, 'originalWidth' => $width, 'originalHeight' => $height);
     }
     return $retInfo;
 }
Beispiel #5
0
 /**
  * @param null $outputMode
  * @param bool $skipChilds
  */
 function render($outputMode = NULL, $skipChilds = false)
 {
     if ($this->_content['totalPages'] > 1) {
         $currentPage = $this->_content['currentPage'];
         $groupLength = $this->getAttribute("groupLength");
         $start = 1;
         $stop = $this->_content['totalPages'];
         $lastLink = array();
         $showDisabledLinks = $this->getAttribute('showDisabledLinks');
         if ($this->_content['totalPages'] > $groupLength) {
             $start = max(1, floor($currentPage / $groupLength) * $groupLength);
             $stop = min($this->_content['totalPages'], $start + ($groupLength - 1));
             if ($currentPage != 1 || $showDisabledLinks) {
                 $label = $this->getAttribute('arrowGroupPrev');
                 if ($label) {
                     $tempArray = array();
                     $tempArray['__cssClass__'] = 'noNumber';
                     $tempArray['__url__'] = $currentPage != 1 ? org_glizy_helpers_Link::addParams(array($this->getId() . '_' . $this->pageUrl => 1)) : '';
                     $tempArray['value'] = $label;
                     $this->_content['pagesLinks'][] = $tempArray;
                 }
                 $label = $this->getAttribute('arrowPrev');
                 if ($label) {
                     $tempArray = array();
                     $tempArray['__cssClass__'] = 'noNumber';
                     $tempArray['__url__'] = $currentPage != 1 ? org_glizy_helpers_Link::addParams(array($this->getId() . '_' . $this->pageUrl => max(1, $currentPage - 1))) : '';
                     $tempArray['value'] = $label;
                     $this->_content['pagesLinks'][] = $tempArray;
                 }
             }
             if ($currentPage != $this->_content['totalPages'] || $showDisabledLinks) {
                 $label = $this->getAttribute('arrowNext');
                 if ($label) {
                     $tempArray = array();
                     $tempArray['__cssClass__'] = 'noNumber';
                     $tempArray['__url__'] = $currentPage != $this->_content['totalPages'] ? org_glizy_helpers_Link::addParams(array($this->getId() . '_' . $this->pageUrl => min($this->_content['totalPages'], $currentPage + 1))) : '';
                     $tempArray['value'] = $label;
                     $lastLink[] = $tempArray;
                 }
                 $label = $this->getAttribute('arrowGroupNext');
                 if ($label) {
                     $tempArray = array();
                     $tempArray['__cssClass__'] = 'noNumber';
                     $tempArray['__url__'] = $currentPage != $this->_content['totalPages'] ? org_glizy_helpers_Link::addParams(array($this->getId() . '_' . $this->pageUrl => $this->_content['totalPages'])) : '';
                     $tempArray['value'] = $label;
                     $lastLink[] = $tempArray;
                 }
             }
         }
         for ($i = $start; $i <= $stop; $i++) {
             $tempArray = array();
             $tempArray['__cssClass__'] = $currentPage == $i ? 'current' : 'number';
             $tempArray['__cssClass__'] .= $i == $start ? ($tempArray['__cssClass__'] != '' ? ' ' : '') . 'first' : '';
             $tempArray['__cssClass__'] .= $i == $stop ? ($tempArray['__cssClass__'] != '' ? ' ' : '') . 'last' : '';
             $tempArray['__url__'] = '';
             $tempArray['value'] = $i;
             if ($currentPage != $i) {
                 $tempArray['__url__'] = org_glizy_helpers_Link::addParams(array($this->getId() . '_' . $this->pageUrl => $i));
             }
             $this->_content['pagesLinks'][] = $tempArray;
         }
         if (count($lastLink)) {
             $this->_content['pagesLinks'] = array_merge($this->_content['pagesLinks'], $lastLink);
         }
     }
     $this->_content['goTo'] = '';
     if ($this->getAttribute('showGoTo')) {
         $form = '<form action="' . org_glizy_helpers_Link::addParams(array()) . '" method="post">';
         $form .= '<input class="page" type="text" onfocus="this.value=\'\';" value="#" name="' . $this->getId() . '_' . $this->pageUrl . '"/>';
         $form .= '<input class="go" type="image" src="' . org_glizy_Assets::get('ICON_GO') . '"/>';
         $form .= '</form>';
         $this->_content['goTo'] = $form;
     }
     if ($this->getAttribute('showTotal')) {
         $this->_content['totalRecords'] = $this->_content['recordsCount'];
     }
     parent::render($outputMode, $skipChilds);
 }
Beispiel #6
0
 /**
  * @param bool $init
  * @return mixed
  */
 public static function &_getPathsArray($init = false)
 {
     // Array associativo (PATH_CODE=>PATH)
     static $_pathsArray = array();
     if (!count($_pathsArray) && !$init) {
         org_glizy_Assets::init();
     }
     return $_pathsArray;
 }