function render_html() { $name = $this->getAttribute('name'); if ($this->_content === true) { $this->_content = 'true'; } if ($this->_content === false) { $this->_content = 'false'; } $output = org_glizy_helpers_Html::hidden(empty($name) ? $this->getOriginalId() : $name, !is_object($this->_content) && !is_array($this->_content) ? $this->_content : json_encode($this->_content), array('class' => $this->getAttribute('cssClass')), $this->getAttribute('data')); $this->addOutputCode($this->applyItemTemplate('', $output, true)); }
function render() { // TODO: controllo acl $name = $this->getId(); if (!$this->_user->acl($this->_application->getPageId(), 'new') || $this->getAttribute('hide')) { $output = org_glizy_helpers_Html::hidden($name, $this->_content, array('class' => $this->getAttribute('cssClass'))); $this->addOutputCode($output); } else { $attributes = array(); $attributes['id'] = $this->getId(); $attributes['name'] = $this->getOriginalId(); $attributes['disabled'] = $this->getAttribute('disabled') ? 'disabled' : ''; $attributes['data-type'] = $this->getAttribute('data-type') ? $this->getAttribute('data-type') : 'selectpagetype'; $attributes['data-linked'] = $this->getAttribute('linked') ? $this->getAttribute('linked') : ''; $attributes['data-onlywithparent'] = $this->getAttribute('onlyWithParent') ? $this->getAttribute('onlyWithParent') : ''; $attributes['class'] = $this->getAttribute('required') ? 'required' : ''; $attributes['class'] .= $this->getAttribute('cssClass') != '' ? ($attributes['class'] != '' ? ' ' : '') . $this->getAttribute('cssClass') : ''; $attributes['class'] .= ' hidden'; $output = '<input ' . $this->_renderAttributes($attributes) . '/>'; $output .= '<ul class="pageTypeSelect">'; foreach ($this->items as $v) { $output .= '<li>'; $output .= '<a class="' . $v['cssClass'] . '" data-type="' . $v['type'] . '" data-acceptparent="' . @$v['acceptParent'] . '">' . $v['label'] . '</a>'; $output .= '</li>'; } $output .= '</ul>'; $cssClassLabel = $this->getAttribute('cssClassLabel'); $cssClassLabel .= ($cssClassLabel ? ' ' : '') . ($this->getAttribute('required') ? 'required' : ''); if ($this->getAttribute('wrapLabel')) { $label = org_glizy_helpers_Html::label($this->getAttributeString('label'), $this->getId(), true, $output, array('class' => $cssClassLabel), false); $output = ''; } else { $label = org_glizy_helpers_Html::label($this->getAttributeString('label'), $this->getId(), false, '', array('class' => $cssClassLabel), false); } $this->addOutputCode($this->applyItemTemplate($label, $output)); } }
function _render() { if ($this->getAttribute('outputOnlyValue')) { return $this->_content; } else { $output = ''; $attributes = array(); $attributes['id'] = $this->getId(); $attributes['name'] = $this->getOriginalId(); $attributes['disabled'] = $this->getAttribute('disabled') ? 'disabled' : ''; $attributes['class'] = $this->getAttribute('required') ? 'required' : ''; $attributes['class'] .= $this->getAttribute('cssClass') != '' ? ($attributes['class'] != '' ? ' ' : '') . $this->getAttribute('cssClass') : ''; $attributes['title'] = $this->getAttributeString('title'); $attributes['onchange'] = $this->getAttribute('onChange'); if ($this->getAttribute('readOnly')) { $output .= org_glizy_helpers_Html::hidden($attributes['name'], $this->_content); $attributes['name'] .= '_orig'; $attributes['id'] .= '_orig'; $attributes['disabled'] = true; } if ($this->getAttribute('rows') > 1) { $attributes['size'] = $this->getAttribute('rows'); $attributes['multiple'] = $this->getAttribute('multiSelect') ? 'multiple' : ''; } $output .= '<select ' . $this->_renderAttributes($attributes) . '>'; foreach ($this->_items as $item) { if ($this->_content == '' || is_null($this->_content)) { $selected = isset($item['selected']) && $item['selected'] ? ' selected="selected"' : ''; } else { if (is_array($this->_content)) { $selected = in_array(strtoupper($item['key']), $this->_content) ? ' selected="selected"' : ''; } else { $selected = strtoupper($item['key']) == strtoupper($this->_content) ? ' selected="selected"' : ''; } } $disabled = isset($item['disabled']) ? ' ' . $item['disabled'] : ''; $options = isset($item['options']) ? ' data-options="' . $item['options'] . '"' : ''; $output .= '<option value="' . glz_encodeOutput($item['key']) . '"' . $selected . $disabled . $options . '>' . glz_encodeOutput($item['value']) . '</option>'; } $output .= '</select>'; $label = $this->getAttributeString('label') ?: ''; if ($label) { $cssClassLabel = $this->getAttribute('cssClassLabel'); $cssClassLabel .= ($cssClassLabel ? ' ' : '') . ($this->getAttribute('required') ? 'required' : ''); if ($this->getAttribute('wrapLabel')) { $label = org_glizy_helpers_Html::label($this->getAttributeString('label'), $this->getId(), true, $output, array('class' => $cssClassLabel), false); $output = ''; } else { $label = org_glizy_helpers_Html::label($this->getAttributeString('label'), $this->getId(), false, '', array('class' => $cssClassLabel), false); } } return $this->applyItemTemplate($label, $output); } }
function render() { // TODO: controllo acl $name = $this->getId(); if (!$this->_user->acl($this->_application->getPageId(), 'new')) { $output = org_glizy_helpers_Html::hidden($name, $this->_content, array('class' => $this->getAttribute('cssClass'))); } else { $pageTypes = array(); if ($dh = @opendir(org_glizy_Paths::get('APPLICATION_TO_ADMIN_PAGETYPE'))) { // scan the pageType folder while ($fileName = readdir($dh)) { // check if the item is a folder if ($fileName != "." && $fileName != ".." && strpos($fileName, '.xml') !== false) { if ($fileName == 'Common.xml') { continue; } $pageTypes[] = preg_replace('/\\.xml/i', '', $fileName); } } closedir($dh); glz_loadLocale(org_glizy_Paths::get('APPLICATION_TO_ADMIN_PAGETYPE')); } else { // can't open pageTypes folder // show the error new org_glizy_Exception(array('[%s] %s: %s', $this->getClassName(), GLZ_ERR_NO_PAGETYPE_FOLDER, org_glizy_Paths::get('APPLICATION_TO_ADMIN') . '/pageTypes/')); } $modules = org_glizy_Modules::getModules(); foreach ($modules as $moduleVO) { if ($moduleVO->pageType) { $pageTypes[] = $moduleVO->pageType; } } $output = '<option value=""></option>'; $values = array(array($this->getAttribute('emptyValue'), '', 1, array(), 0)); $modifyMode = $this->getAttribute('modify'); foreach ($pageTypes as $item) { $moduleVO = null; foreach ($modules as $m) { if ($m->pageType == $item) { $moduleVO = $m; break; } } if ($moduleVO) { if (!$moduleVO->show) { continue; } if ($moduleVO->unique && (!$modifyMode || $modifyMode && $item != $this->_content)) { $ar =& org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Menu'); $result = $ar->find(array('menu_pageType' => $item)); unset($ar); if ($result) { continue; } } } $pageName = __T($item); $output .= '<option value="' . $item . '"' . ($item == $this->_content ? ' selected' : '') . '>' . __T($item) . '</option>'; } $attributes = array(); $attributes['id'] = $this->getId(); $attributes['name'] = $this->getOriginalId(); $attributes['disabled'] = $this->getAttribute('disabled') ? 'disabled' : ''; $attributes['class'] = $this->getAttribute('required') ? 'required' : ''; $attributes['class'] .= $this->getAttribute('cssClass') != '' ? ($attributes['class'] != '' ? ' ' : '') . $this->getAttribute('cssClass') : ''; $output = '<select ' . $this->_renderAttributes($attributes) . '>' . $output . '</select>'; $cssClassLabel = $this->getAttribute('cssClassLabel'); $cssClassLabel .= ($cssClassLabel ? ' ' : '') . ($this->getAttribute('required') ? 'required' : ''); if ($this->getAttribute('wrapLabel')) { $label = org_glizy_helpers_Html::label($this->getAttributeString('label'), $this->getId(), true, $output, array('class' => $cssClassLabel), false); $output = ''; } else { $label = org_glizy_helpers_Html::label($this->getAttributeString('label'), $this->getId(), false, '', array('class' => $cssClassLabel), false); } $this->addOutputCode($this->applyItemTemplate($label, $output)); } }