public function render(Zend_View_Interface $view = null) { if (!count($this->getMultiOptions())) { $this->addMultiOption(0, $this->getView()->translate('message.noResult.short')); } return parent::render($view); }
public function render(Zend_View_Interface $view = null) { if (count($this->getMultiOptions()) == 0) { $this->setMultiOptions(); } return parent::render($view); }
function getlibellesbyidcategorieAction() { $oMapper = new Application_Model_Mapper_RefItems(); $oSelect = new Zend_Form_Element_Select(Form_AjoutProduit::LIBELLE); $oSelect->setMultiOptions($oMapper->getLibelleByIdCategorie($this->_getParam('idCategorie')))->setDecorators(array('ViewHelper')); $this->view->element = $oSelect->render(); }
public function render(Zend_View $view = null) { if ($view) { $view->addHelperPath(Dfi_View_Helper_FormSelectChained::getPath(), 'Dfi_View_Helper'); } else { $this->getView()->addHelperPath(Dfi_View_Helper_FormSelectChained::getPath(), 'Dfi_View_Helper'); } return parent::render($view); }
public function render(Zend_View_Interface $view = null) { $this->getView()->setEncoding('cp1251'); return parent::render($view); }
public function testMultiOptionsPassedToViewHelperAreTranslated() { require_once 'Zend/Form/Element/Select.php'; require_once 'Zend/Translate.php'; $element = new Zend_Form_Element_Select('foo'); $options = array('foo' => 'This Foo Will Not Be Displayed', 'bar' => 'This Bar Will Not Be Displayed', 'baz' => 'This Baz Will Not Be Displayed'); $element->setMultiOptions($options); $translations = array('This Foo Will Not Be Displayed' => 'This is the Foo Value', 'This Bar Will Not Be Displayed' => 'This is the Bar Value', 'This Baz Will Not Be Displayed' => 'This is the Baz Value'); $translate = new Zend_Translate('array', $translations, 'en'); $translate->setLocale('en'); $element->setTranslator($translate); $test = $element->render($this->getView()); foreach ($options as $key => $value) { $this->assertNotContains($value, $test); $this->assertContains($translations[$value], $test); } }
/** * @todo : description * @return mixed * @throws Centurion_Exception */ public function generateList() { $select = $this->getSelectFiltred(); //TODO: move all of this in a view helper (except pagination, ) $headCol = array(); foreach ($this->_displays as $key => $col) { if (is_string($col)) { $label = $col; } else { if (is_array($col) && isset($col['label'])) { $label = $col['label']; } else { throw new Centurion_Exception(sprintf('Col %s have no label', $key)); } } $params = array('page' => 0, 'sort' => $key, 'order' => $this->_sort !== $key || $this->_order === Zend_Db_Select::SQL_DESC ? Zend_Db_Select::SQL_ASC : Zend_Db_Select::SQL_DESC); $params += $this->getFilter()->getValuesForUrl(); if (!isset($col['sortable']) || $col['sortable'] !== false) { $link = $this->view->url($params); } else { $link = null; } $headCol[$key] = array('label' => $label, 'link' => $link); } $this->_headCol = $headCol; $this->_preGenerateList(); $paginator = $this->getPaginator($select); $this->_postGenerateList($paginator); $result = array(); foreach ($paginator as $row) { $temp = array(); if ($this->_showCheckbox) { //TODO : id en dur, utiliser la pk du model $temp['checkbox'] = '<input type="checkbox" value="' . $row->id . '" name="rowId[]">'; } foreach ($this->_displays as $key => $options) { if (is_string($options) || !isset($options['type'])) { $value = $row->{$key}; } else { if ($options['type'] === self::COLS_ROW_COL) { if (isset($options['col'])) { $col = $options['col']; } else { $col = $key; } $value = $row->{$col}; } else { if ($options['type'] === self::COLS_ROW_FUNCTION) { if (isset($options['function'])) { $function = $options['function']; } else { $function = $key; } $value = $row->{$function}(); } else { if ($options['type'] === self::COLS_CALLBACK) { if (!isset($options['callback'])) { $options['callback'] = array($this, $key); } $params = array_merge(array($row), isset($options['callbackParams']) ? (array) $options['callbackParams'] : array()); $value = call_user_func_array($options['callback'], $params); } else { if ($options['type'] === self::COLS_TYPE_PREVIEW) { $value = '<a href="' . $this->view->url(array('object' => $row), $options['param']['route']) . '">' . $this->view->translate('Preview') . '</a>'; } else { if ($options['type'] === self::COL_TYPE_FIRSTCOL) { $value = $this->view->renderToString('centurion/_first_col.phtml', array('extraParam' => $this->_extraParam, 'row' => $row, 'first' => $options['param'], 'controller' => $this->_request->getControllerName(), 'module' => $this->_request->getModuleName())); } else { if ($options['type'] === self::COL_TYPE_ONOFF) { if (isset($options['onoffLabel']) && count($options['onoffLabel']) === 2) { $onLabel = $options['onoffLabel'][0]; $offLabel = $options['onoffLabel'][1]; } else { $onLabel = $this->view->translate('On'); $offLabel = $this->view->translate('Off'); } if (isset($options['column'])) { $column = $options['column']; } else { $column = $key; } //TODO : id en dur, utiliser la pk du model $element = new Zend_Form_Element_Select(array('disableTranslator' => true, 'name' => $key . '_' . $row->id, 'class' => 'field-switcher')); $element->addMultiOption('1', $onLabel); $element->addMultiOption('0', $offLabel); $element->removeDecorator('Label'); $element->setValue($row->{$column}); $value = $element->render(); } else { //TODO: more explicit (add type, ...) throw new Centurion_Exception(sprintf('I don\'t now what to do with the col %s', $key)); } } } } } } } if (is_array($options) && isset($options['filters'])) { $options['filters'] = (array) $options['filters']; //TODO: allow to use real filter (instance of Zend_Filter_Interface) foreach ($options['filters'] as $filter) { if ($filter === self::COL_DISPLAY_DATE) { if ($value == '0000-00-00 00:00:00' || $value == null) { $value = ''; } else { $date = new Zend_Date($value, Centurion_Date::MYSQL_DATETIME); $value = $date->toString(Zend_Date::DATE_MEDIUM); } } } } $temp[$key] = $value; } $temp['row'] = $row; //TODO : id en dur, utiliser la pk du model $result[$row->id] = $temp; } $this->_result = $result; return $this->_result; }
public function listAction() { $listcount = new LookupType(); $listcount->setName("LIST_ITEM_COUNT_OPTIONS"); $values = $listcount->getOptionValues(); asort($values, SORT_NUMERIC); $session = SessionWrapper::getInstance(); $dropdown = new Zend_Form_Element_Select('itemcountperpage', array('multiOptions' => $values, 'view' => new Zend_View(), 'decorators' => array('ViewHelper'), 'class' => array('form-control', 'width75', 'inline', 'input-sm', 'perpageswitcher'))); if (isEmptyString($this->_getParam('itemcountperpage'))) { if (!isEmptyString($session->getVar('itemcountperpage'))) { $dropdown->setValue($session->getVar('itemcountperpage')); if ($session->getVar('itemcountperpage') == 'ALL') { $session->setVar('itemcountperpage', ''); $dropdown->setValue('50'); } } else { $dropdown->setValue('50'); } } else { $session->setVar('itemcountperpage', $this->_getParam('itemcountperpage')); $dropdown->setValue($session->getVar('itemcountperpage')); } $this->view->listcountdropdown = '<span>Per page: ' . $dropdown->render() . '</span>'; }
/** * @return String */ public function getListCountDropDown() { $listcount = new LookupType(); $listcount->setName("LIST_ITEM_COUNT_OPTIONS"); $values = $listcount->getOptionValues(); asort($values, SORT_NUMERIC); $session = SessionWrapper::getInstance(); $dropdown = new Zend_Form_Element_Select('itemcountperpage', array('multiOptions' => $values, 'view' => new Zend_View(), 'decorators' => array('ViewHelper'), 'class' => array('form-control', 'width75', 'inline', 'input-sm'))); if (isEmptyString($this->getItemCountPerPage())) { $dropdown->setValue($session->getVar('itemcountperpage')); } else { $session->setVar('itemcountperpage', $this->getItemCountPerPage()); $dropdown->setValue($this->getItemCountPerPage()); } $selectobj = '<span>Per page: ' . $dropdown->render() . '</span>'; return $selectobj; }