actions['reoder_form'] = 'doReoderForm'; $this->actions['reoder_save'] = 'doReoderSave'; $this->_options = $options; $this->DB_Grid($Page, $DBObj); } function _bindFormFields($form) { $form->addElement('hidden', 'id', $this->DBObj->getData('id')) ; //$id_parent =& Form::createElement('select', 'id_parent', 'Parent Page', $this->DBObj->getPagentPages4Sel()); //$id_parent->setValue($this->DBObj->id_parent); //$form->addElement($id_parent); $form->addElement('hidden', 'id_parent', $this->DBObj->id_parent); $form = parent::_bindFormFields($form); $form->removeElement('final'); $form->removeElement('system'); $system =& Form::createElement('advcheckbox', 'system', 'Don\'t show in sitemap', null, array('n', 'y')); $system->setValue($this->DBObj->getData('system')); $form->addElement($system); $form->addFormRule(array(&$this, 'validAlias') ); $form->removeElement('sorter'); $form->addRule('alias', 'Alias is requied', 'required', null, 'client'); $form->addRule('alias', 'Alias is requied', 'required'); $form->addRule('alias', 'Invalid Alias', 'alias', null, 'client'); $form->addRule('alias', 'Invalid Alias', 'alias'); $form->removeElement('handler'); $handlerList = $this->DBObj->getTypes(); if (1 == count($handlerList)){ $handlerIds = array_keys($handlerList); $handler = Form::createElement('hidden', 'handler', $handlerIds[0]); }else { $handler = Form::createElement('select', 'handler', 'Page Type', $handlerList); $handler->setValue( $this->DBObj->getData('handler') ); } $form->addElement($handler); require_once 'class/DB/Lang/DLang.php'; $DLang = new DLang(); $langList = $DLang->getList(); if (count($langList) > 1){ $form->addElement('header', 'title_header', 'Title'); } foreach ($langList as $lang){ $name = "title[{$lang['name']}]"; if (count($langList) == 1){ $title_error = 'Title is required'; $title = 'Title'; }else{ $title_error = $lang['title'] . ' title is required'; $title = $lang['title']; } $form->addElement('text', $name, $title, array('value' => $this->DBObj->getData($name)) ); $form->addRule($name, $title_error, 'required'); $form->addRule($name, $title_error, 'required', null, 'client'); } if (count($langList) > 1) { $form->addElement('header', 'menu_header', 'Menu Page Title'); } foreach ($langList as $lang) { $name = "menutitle[{$lang['name']}]"; if (count($langList) == 1) { $title_error = 'Menu Page Title is required'; $title = 'Menu Page Title'; } else { $title_error = $lang['title'] . ' title is required'; $title = $lang['title']; } $form->addElement('text', $name, $title, array('value' => $this->DBObj->getData($name))); $form->addRule($name, $title_error, 'required'); $form->addRule($name, $title_error, 'required', null, 'client'); } if ( 1 == $this->_options['showSEO_Fields']){ if (count($langList) > 1){ $form->addElement('header', 'keyword_header', 'Keywords'); } foreach ($langList as $lang){ $name = "keyword[{$lang['name']}]"; if (count($langList) == 1){ $title = 'Keywords'; }else{ $title = $lang['title']; } $textarea = Form::createElement('textarea', $name, $title,array('cols' => '35', 'rows' => '3')); $textarea->setValue($this->DBObj->getData($name)); $form->addElement($textarea); } if (count($langList) > 1){ $form->addElement('header', 'description_header', 'Description'); } foreach ($langList as $lang){ $name = "description[{$lang['name']}]"; if (count($langList) == 1){ $title = 'Description'; }else{ $title = $lang['title']; } $textarea = Form::createElement('textarea', $name, $title,array('cols' => '35', 'rows' => '3')); $textarea->setValue($this->DBObj->getData($name)); $form->addElement($textarea); } } if (empty($this->DBObj->id)){ $form = $this->_addContFld($form, $langList, 'content'); }else { foreach ($this->DBObj->getDocContIds($id) AS $id){ $form = $this->_addContFld($form, $langList, "content_$id"); } } return $form; } function _addContFld($form, $langList, $elName, $elTitle = 'Content', $elType = 'html_editor') { if (count($langList) > 1){ $form->addElement('header', 'content_header', $elTitle); } foreach ($langList as $lang){ $name = $elName."[{$lang['name']}]"; if (count($langList) == 1){ $title = $elTitle; }else{ $title = $lang['title']; } $form->addElement($elType, $name, $title, null, (string)$this->DBObj->getData($name) ); } return $form; } function addLink() { $addLink = array( 'tpl' => 'center_link.tpl', 'link_list' => array( array('link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=reoder_form&id_parent='.$this->DBObj->id_parent, 'title' => 'Reorder '.$this->DBObj->itemName.'s', ), array('link' => Constant::get('BASE_URL').'/'.CURR_PAGE.'?action=new&id_parent='.$this->DBObj->id_parent, 'title' => 'Add new '.$this->DBObj->itemName, ), ), ); $this->Doc->addContent($addLink); } function doList() { $this->_saveBackUrl(); $this->addLink(); require_once('class/DB/List/List.php'); $DB_List = new DB_List($this->Doc, $this->DBObj, $this->functionalFields); $DB_List->def_order_by = 'sorter'; $DB_List->insertColLast('title', array('title' => 'Title', 'width' => 150, 'order_by' => 'title', 'tpl' => DB_LIST_CELL_TEXT, 'params' => array('title'), )); $DB_List->insertColLast('alias', Array ( 'title' => 'Alias', 'order_by' => 'alias', 'width' => 150, 'tpl' => DB_LIST_CELL_TEXT, 'params' => Array('alias'), ) ); if (count($this->DBObj->getTypes()) > 1 ){ $DB_List->insertColLast('handler', Array ( 'title' => 'Handler', 'order_by' => 'DocHandler.title', 'width' => 150, 'tpl' => DB_LIST_CELL_TEXT, 'params' => Array('handler'), )); } $DB_List->insertColLast('sub_pages', array('title' => 'Sub pages', 'width' => 100, 'tpl' => DB_LIST_CELL_LINK, 'params' => array('id'), 'empty_title' => 'Sub pages', 'url' => CURR_PAGE.'?id_parent=' )); $DB_List->insertColLast('options', array('title' => 'Options', 'width' => 100, 'tpl' => DB_LIST_CELL_EDIT_DEL, 'params' => array('id'), 'edit_link' => CURR_PAGE.'?action=edit&id=', 'del_link' => CURR_PAGE.'?action=del&id=', ) ); $DB_List->urlVarNames[] = 'id_parent'; $DB_List->bind(); $DB_List->exec(); return true; } function _getReorderFrom() { $form = $this->_getBaseForm(); $list = array(); $list4Grid = $this->DBObj->getList4Grid(array('order_by' => 'sorter')); foreach ($list4Grid['list'] as $val) { $list[$val['id']] = $val['title']; } $orderList = Form::createElement('select_edit', 'order_list', false, $list); $orderList->delAction('add'); $orderList->delAction('del'); $orderList->delAction('edit'); $form->addElement($orderList) ; $form->addElement('hidden', 'id_parent', $this->DBObj->id_parent); return $form; } function doReoderForm() { $form = $this->_getReorderFrom(); $form->setTitle('Reorder '.$this->DBObj->itemName.'s'); $form->addElement('hidden', 'action', 'reoder_save') ; $form->exec(); } function doReoderSave() { $form = $this->_getReorderFrom(); $this->DBObj->reorder( $form->getElementValue('order_list') ); $this->doBack(); } function validAlias($fields) { if ($this->DBObj->isAliasUnique($fields['alias'])){ return true; }else { return array('alias' => 'This alias already used. Please select another alias.'); } } } ?>