getTemplatePath() . 'editStaticPageForm.tpl'); $this->journalId = $journalId; $this->plugin =& $plugin; $this->staticPageId = isset($staticPageId)? (int) $staticPageId: null; $this->addCheck(new FormValidatorCustom($this, 'pagePath', 'required', 'plugins.generic.staticPages.duplicatePath', array(&$this, 'checkForDuplicatePath'), array($journalId, $staticPageId))); $this->addCheck(new FormValidatorPost($this)); } /** * Custom Form Validator for PATH to ensure no duplicate PATHs are created * @param $pagePath String the PATH being checked * @param $journalId int * @param $staticPageId int */ function checkForDuplicatePath($pagePath, $journalId, $staticPageId) { $staticPageDao =& DAORegistry::getDAO('StaticPagesDAO'); return !$staticPageDao->duplicatePathExists($pagePath, $journalId, $staticPageId); } /** * Initialize form data from current group group. */ function initData() { $journalId = $this->journalId; $plugin =& $this->plugin; // add the tiny MCE script $this->addTinyMCE(); if (isset($this->staticPageId)) { $staticPageDao =& DAORegistry::getDAO('StaticPagesDAO'); $staticPage =& $staticPageDao->getStaticPage($this->staticPageId); if ($staticPage != null) { $this->_data = array( 'staticPageId' => $staticPage->getId(), 'pagePath' => $staticPage->getPath(), 'title' => $staticPage->getTitle(null), 'content' => $staticPage->getContent(null) ); } else { $this->staticPageId = null; } } } function addTinyMCE() { $journalId = $this->journalId; $plugin =& $this->plugin; $templateMgr =& TemplateManager::getManager(); // Enable TinyMCE with specific params $additionalHeadData = $templateMgr->get_template_vars('additionalHeadData'); import('classes.file.JournalFileManager'); $publicFileManager = new PublicFileManager(); $tinyMCE_script = ' '; $templateMgr->assign('additionalHeadData', $additionalHeadData."\n".$tinyMCE_script); } /** * Assign form data to user-submitted data. */ function readInputData() { $this->readUserVars(array('staticPageId', 'pagePath', 'title', 'content')); } /** * Get the names of localized fields * @return array */ function getLocaleFieldNames() { return array('title', 'content'); } /** * Save page into DB */ function save() { $plugin =& $this->plugin; $journalId = $this->journalId; $plugin->import('StaticPage'); $staticPagesDao =& DAORegistry::getDAO('StaticPagesDAO'); if (isset($this->staticPageId)) { $staticPage =& $staticPagesDao->getStaticPage($this->staticPageId); } if (!isset($staticPage)) { $staticPage = new StaticPage(); } $staticPage->setJournalId($journalId); $staticPage->setPath($this->getData('pagePath')); $staticPage->setTitle($this->getData('title'), null); // Localized $staticPage->setContent($this->getData('content'), null); // Localized if (isset($this->staticPageId)) { $staticPagesDao->updateStaticPage($staticPage); } else { $staticPagesDao->insertStaticPage($staticPage); } } function display() { $templateMgr =& TemplateManager::getManager(); parent::display(); } } ?>