actions = array('site_map' => 'doSiteMap') + $this->actions; unset($this->actions['list']); $this->Doc_Middle($Page, $DBObj, $options); } function doSiteMap() { $site_map = $this->DBObj->getSiteMap(); $this->Doc->addContent( array( 'tpl' => SiteMap::getPath('CMS/tpl/site_map_light.tpl'), 'siteMap' => $site_map, 'cnt_total' => $this->DBObj->total_pages, ) ); return true; } function _bindFormFields($form) { $form->setAttribute('class', 'cms_form'); require_once 'class/DB/Lang/DLang.php'; $DLang = new DLang(); $langList = $DLang->getList(); $form->addElement('hidden', 'id_parent', $this->DBObj->id_parent); $alias = $form->createElement('text', 'alias', 'Alias'); $alias->setValue($this->DBObj->getData('alias')); $form->addElement($alias); $form->addFormRule(array(&$this, 'validAlias')); $form->addRule('alias', 'Alias is requied', 'required'); $form->addRule('alias', 'Alias is requied', 'required', null, 'client'); $form->addRule('alias', 'Invalid Alias', 'alias'); $form->addRule('alias', 'Invalid Alias', 'alias', null, 'client'); if (count($langList) > 1) { $form->addElement('header', 'title_header', 'Page Title'); } foreach ($langList as $lang) { $name = "title[{$lang['name']}]"; if (count($langList) == 1) { $title_error = 'Page Title is required'; $title = '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('rows' => '3', 'style' => 'width:100%;')); $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('rows' => '3', 'style' => 'width:100%;')); $textarea->setValue($this->DBObj->getData($name)); $form->addElement($textarea); } } $system =& Form::createElement('advcheckbox', 'system', ' ', 'Don\'t show in sitemap', null, array('n', 'y')); $system->setValue($this->DBObj->getData('system')); $form->addElement($system); $handler =& $form->createElement('select', 'handler', 'Page Type', $this->DBObj->getTypes()); $handler->setValue($this->DBObj->getData('handler')); $form->addElement($handler); $form->addElement('extended_text', 'redirect_url', 'URL', array('style'=>'width:500px', 'value'=>$this->DBObj->getData('redirect_url')), null, '
Example: http://google.com
'); $regex = '/^((http|https|ftp):\/\/)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i'; $form->addRule('redirect_url', 'URL is in wrong format', 'regex', $regex); $form->addRule('redirect_url', 'URL is in wrong format', 'regex', $regex, 'client'); if (count($langList) > 1) { $form->addElement('header', 'header_header', 'Page Header'); } foreach ($langList as $lang) { $name = "header[{$lang['name']}]"; if (count($langList) == 1) { $title_error = 'Page Header is required'; $title = 'Page Header'; } else { $title_error = $lang['title'] . ' page header 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 (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"); } } $form->addFormRule(array($this, 'validForm')); $this->Doc->addItemProp('JSs', 'js/cms.js'); return $form; } function renderForm($form) { $params = array('id_form'=>$form->getAttribute('id'), 'action' => $this->action); $this->Doc->addItemProp('initFuncsEx', array('name'=>'cms_initForm', 'params' => array(json_encode($params)))); $form->exec(); } function validForm($data) { $err = array(); //$regex = '/^((http|https|ftp):\/\/)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i'; if ($data['handler'] == 'RedirectDoc') { if (empty($data['redirect_url'])) { $err['redirect_url'] = 'URL is required'; }/* else if (!preg_match($regex, $data['redirect_url'])) { $err['redirect_url'] = 'URL is in wron format'; }*/ } return (empty($err))?true:$err; } function _getEditForm() { $form = $this->_getBaseForm(); $form->addElement('static', 'seo_header', null, ''); $form = $this->_bindFormFields($form); $this->setFormTitle($form, 'Edit '.$this->DBObj->itemName); $form->action = CURR_PAGE.'?action=update'; $form->addElement('hidden', 'action', 'update') ; $form->addElement('hidden', 'id', $this->DBObj->getData('id')) ; return $form; } function doUpdate() { $form = $this->_getEditForm(); if ($form->validate()) { $this->DBObj->initFromForm($form); $this->DBObj->update(); Session::setData(CURR_PAGE, 'msg', $this->DBObj->itemName.' updated'); $this->doBack(); } else { $showRows = false; foreach (array('alias', 'title', 'head', 'system') as $name) { if (isset($form->_errors[$name])) { $showRows = true; break; } } if ($showRows) { $form->getElement('seo_header')->setValue('Click here to show / hide the page title, meta tags.'); } $form->exec(); } return true; } }