_addLinkPrefix = $addLinkPrefix; } public function getAddLinkPrefix() { return $this->_addLinkPrefix; } /** * @param null|string $itemName */ public function setItemName($itemName) { $this->_itemName = $itemName; } /** * @return null|string */ public function getItemName() { return $this->_itemName; } public function clearColumns() { $this->_columns = array(); return $this; } public function setColumns(array $columns) { $this->clearColumns(); $this->addColumns($columns); return $this; } public function addColumns(array $columns) { foreach ($columns as $name => $options) { $this->addColumn($name, $options); } return $this; } public function addColumn($name, array $options) { if (!isset($options['type'])) { throw new Qs_Form_Element_Exception('Type is undefined for column "' . $name . '"'); } if (!in_array($options['type'], $this->_columnTypes)) { throw new Qs_Form_Element_Exception('Type "' . $options['type'] . '" is not registered'); } $this->_columns[$name] = $options; return $this; } public function getColumns() { return $this->_columns; } public function setSortable($flag = true) { $this->_sortable = (bool) $flag; return $this; } public function isSortable() { return $this->_sortable; } public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('Grid', array('itemName' => $this->_itemName, 'addLinkPrefix' => $this->_addLinkPrefix)) ->addDecorator('Errors') ->addDecorator('Description', array('tag' => 'p', 'class' => 'description')) ->addDecorator('HtmlTag', array('tag' => 'dd', 'id' => $this->getName() . '-element')) ->addDecorator('Label', array('tag' => 'dt')); } } public function getSourceElements() { return $this->_sourceElements; } public function getSourceElement($name) { if (isset($this->_sourceElements[$name])) { return $this->_sourceElements[$name]; } return null; } public function addColumnSourceElement($columnName, $elementType, $helperArguments) { if (!isset($this->_columns[$columnName])) { throw new Qs_Form_Element_Exception('Column "' . $columnName . '" not found'); } $elementName = current($helperArguments); $this->_columns[$columnName]['valueFrom'] = $elementName; $helperArguments[0] = str_replace('[]', '[' . $elementName . ']', $this->getFullyQualifiedName()); $this->_sourceElements[$elementName] = array('type' => $elementType, 'arguments' => $helperArguments); return $this; } protected function _getErrorMessages() { $translator = $this->getTranslator(); $messages = $this->getErrorMessages(); $value = $this->getValue(); foreach ($messages as $key => &$message) { if (null !== $translator) { $message = $translator->translate($message); } } return $messages; } public function setScriptOptions(array $options = array()) { $this->_scriptOptions = $options; } public function getScriptOptions() { return $this->_scriptOptions; } }