00001 <?php
00002
00016 import('form.Form');
00017
00018 class StaticPagesEditForm extends Form {
00020 var $conferenceId;
00021
00023 var $plugin;
00024
00026 var $staticPageId;
00027
00029 var $errors;
00030
00035 function StaticPagesEditForm(&$plugin, $conferenceId, $staticPageId = null) {
00036
00037 parent::Form($plugin->getTemplatePath() . 'editStaticPageForm.tpl');
00038
00039 $this->conferenceId = $conferenceId;
00040 $this->plugin =& $plugin;
00041 $this->staticPageId = isset($staticPageId)? (int) $staticPageId: null;
00042
00043 $this->addCheck(new FormValidatorCustom($this, 'pagePath', 'required', 'plugins.generic.staticPages.duplicatePath', array(&$this, 'checkForDuplicatePath'), array($conferenceId, $staticPageId)));
00044 $this->addCheck(new FormValidatorPost($this));
00045
00046 }
00047
00054 function checkForDuplicatePath($pagePath, $conferenceId, $staticPageId) {
00055 $staticPageDAO =& DAORegistry::getDAO('StaticPagesDAO');
00056
00057 return !$staticPageDAO->duplicatePathExists($pagePath, $conferenceId, $staticPageId);
00058 }
00059
00063 function initData() {
00064 $conferenceId = $this->conferenceId;
00065 $plugin =& $this->plugin;
00066
00067
00068 $this->addTinyMCE();
00069
00070 if (isset($this->staticPageId)) {
00071 $staticPageDAO =& DAORegistry::getDAO('StaticPagesDAO');
00072 $staticPage =& $staticPageDAO->getStaticPage($this->staticPageId);
00073
00074 if ($staticPage != null) {
00075 $this->_data = array(
00076 'staticPageId' => $staticPage->getId(),
00077 'pagePath' => $staticPage->getPath(),
00078 'title' => $staticPage->getTitle(null),
00079 'content' => $staticPage->getContent(null)
00080 );
00081 } else {
00082 $this->staticPageId = null;
00083 }
00084 }
00085 }
00086
00087 function addTinyMCE() {
00088 $conferenceId = $this->conferenceId;
00089 $plugin =& $this->plugin;
00090 $templateMgr =& TemplateManager::getManager();
00091
00092
00093 $additionalHeadData = $templateMgr->get_template_vars('additionalHeadData');
00094
00095 import('file.ConferenceFileManager');
00096 $publicFileManager = new PublicFileManager();
00097 $tinyMCE_script = '
00098 <script language="javascript" type="text/javascript" src="'.Request::getBaseUrl().'/'.TINYMCE_JS_PATH.'/tiny_mce.js"></script>
00099 <script language="javascript" type="text/javascript">
00100 tinyMCE.init({
00101 mode : "textareas",
00102 plugins : "safari,spellchecker,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,pagebreak,",
00103 theme_advanced_buttons1_add : "fontsizeselect",
00104 theme_advanced_buttons2_add : "separator,preview,separator,forecolor,backcolor",
00105 theme_advanced_buttons2_add_before: "search,replace,separator",
00106 theme_advanced_buttons3_add_before : "tablecontrols,separator",
00107 theme_advanced_buttons3_add : "media,separator",
00108 theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,separator,styleprops,|,spellchecker,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,print,separator",
00109 theme_advanced_toolbar_location : "top",
00110 theme_advanced_toolbar_align : "left",
00111 theme_advanced_statusbar_location : "bottom",
00112 relative_urls : false,
00113 document_base_url : "'. Request::getBaseUrl() .'/'.$publicFileManager->getConferenceFilesPath($conferenceId) .'/",
00114 theme : "advanced",
00115 theme_advanced_layout_manager : "SimpleLayout",
00116 extended_valid_elements : "span[*], div[*]",
00117 spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv"
00118 });
00119 </script>';
00120
00121 $templateMgr->assign('additionalHeadData', $additionalHeadData."\n".$tinyMCE_script);
00122
00123 }
00124
00128 function readInputData() {
00129 $this->readUserVars(array('staticPageId', 'pagePath', 'title', 'content'));
00130 }
00131
00135 function save() {
00136 $plugin =& $this->plugin;
00137 $conferenceId = $this->conferenceId;
00138
00139 $plugin->import('StaticPage');
00140 $staticPagesDAO =& DAORegistry::getDAO('StaticPagesDAO');
00141 if (isset($this->staticPageId)) {
00142 $staticPage =& $staticPagesDAO->getStaticPage($this->staticPageId);
00143 }
00144
00145 if (!isset($staticPage)) {
00146 $staticPage = new StaticPage();
00147 }
00148
00149 $staticPage->setConferenceId($conferenceId);
00150 $staticPage->setPath($this->getData('pagePath'));
00151
00152 $staticPage->setTitle($this->getData('title'), null);
00153 $staticPage->setContent($this->getData('content'), null);
00154
00155 if (isset($this->staticPageId)) {
00156 $staticPagesDAO->updateStaticPage($staticPage);
00157 } else {
00158 $staticPagesDAO->insertStaticPage($staticPage);
00159 }
00160 }
00161
00162 function display() {
00163 $templateMgr =& TemplateManager::getManager();
00164
00165 parent::display();
00166 }
00167 }
00168
00169 ?>