array( 'adminPart' => true, 'jsPart' => true, 'viewTpl' => true, 'listTpl' => true ), 'useNameSpace' => 'y' ); protected function _initElements() { $this->addElement( 'text', 'name', array( 'label' => 'Name', 'required' => true, 'validators' => array(new Zend_Validate_Alnum()), 'description' => 'Allowed characters: a-z, A-Z, 0-9' ) ); $this->addElement( 'text', 'tableAlias', array( 'label' => 'Table Alias', 'validators' => array(new Zend_Validate_Alnum()), 'description' => 'Allowed characters: a-z, A-Z, 0-9' ) ); $this->addElement( 'multiCheckbox', 'options', array( 'label' => 'Additional Parts', 'multiOptions' => array( 'adminPart' => 'Admin Part', 'jsPart' => 'JS Part', 'viewTpl' => 'View.tpl', 'listTpl' => 'List.tpl' ) ) ); $this->addElement('checkbox', 'useNameSpace', array('label' => 'Use Namespace', 'decoration' => 'simple')); $this->addElement( 'select', 'directory', array( 'label' => 'Directory', 'escapeLabel' => false, 'multiOptions' => array('' => 'App') + $this->_getModulesTree() ) ); $providerObj = new App_Admin_Tool_Project_Provider_Module(); $this->addFormRule(array($providerObj, 'validateForm')); return $this; } protected function _initButtons() { parent::_initButtons(); $this->btnSubmit->setLabel('Generate'); return $this; } protected function _getModulesTree() { $list = $this->_prepareModuleTree($this->_getDPageItemTypes()); return $list; } protected function _getDPageItemTypes() { $db = Qs_Db::getInstance(); $itemTables = new Qs_Db_Table(array('name' => Qs_Db::getTableName('DPageItemType'), 'db' => $db)); return $itemTables->fetchAll(null, 'type')->toArray(); } protected function _prepareModuleTree($list) { $result = array(); foreach ($list as $item) { $type = str_replace('\\', '_', $item['type']); $directoryArray = explode('_', $type); $value = ''; foreach ($directoryArray as $key => $directory) { if (!empty($directory)) { $value .= $directory . '/'; if (!isset($result[$value])) { $result[$value] = str_repeat(' ', 4 * ($key + 1)) . $directory; } } } } return $result; } }