Exemple #1
0
 private function onTranslate(GWF_Page $page)
 {
     $form = $this->formTranslate($page);
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     $options = 0;
     $options |= GWF_Page::ENABLED;
     $options |= GWF_Page::TRANSLATION;
     $options |= $page->isLoginRequired() ? GWF_Page::LOGIN_REQUIRED : 0;
     $options |= $this->locked_mode ? GWF_Page::LOCKED : 0;
     $options |= $page->getMode();
     $options |= $page->getShowFlags();
     $gstring = $page->getVar('page_groups');
     $tags = ',' . trim(trim($form->getVar('tags')), ',') . ',';
     $author = GWF_User::getStaticOrGuest();
     $time = time();
     $date = GWF_Time::getDate(GWF_Time::LEN_SECOND, $time);
     $newpage = new GWF_Page(array('page_id' => '0', 'page_otherid' => $page->getID(), 'page_lang' => $form->getVar('lang'), 'page_author' => $author->getID(), 'page_author_name' => $author->getVar('user_name'), 'page_groups' => $gstring, 'page_create_date' => $date, 'page_date' => $date, 'page_time' => $time, 'page_url' => $form->getVar('url'), 'page_title' => $form->getVar('title'), 'page_cat' => '0', 'page_meta_tags' => $tags, 'page_meta_desc' => $form->getVar('descr'), 'page_content' => $form->getVar('content'), 'page_views' => '0', 'page_options' => $options, 'page_inline_css' => $page->getVar('page_inline_css')));
     if (false === $newpage->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     // 		if (false === GWF_PageGID::updateGIDs($newpage, $gstring))
     // 		{
     // 			return GWF_HTML::err('ERR_DATABASE', array(__FILE__,__LINE__));
     // 		}
     if (false === GWF_PageTags::updateTags($newpage, $tags, $form->getVar('lang'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $this->module->writeHTA()) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if ($this->locked_mode) {
         $this->module->sendModMails();
         return $this->module->message('msg_added_locked');
     }
     if (false === GWF_PageHistory::push($newpage)) {
         GWF_Error::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_trans');
 }
Exemple #2
0
 private function onEdit()
 {
     $form = $this->formEdit();
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     $page = $this->page;
     $gstring = $this->buildGroupString();
     $tags = ',' . trim(trim($form->getVar('tags')), ',') . ',';
     $data = array();
     if ($page->getVar('page_url') !== ($url = $form->getVar('url'))) {
         $data['page_url'] = $url;
     }
     if ($page->getVar('page_title') !== ($title = $form->getVar('title'))) {
         $data['page_title'] = $title;
     }
     if ($page->getVar('page_meta_tags') !== $tags) {
         $data['page_meta_tags'] = $tags;
     }
     if ($page->getVar('page_meta_desc') !== ($descr = $form->getVar('descr'))) {
         $data['page_meta_desc'] = $descr;
     }
     if ($page->getVar('page_content') !== ($content = $form->getVar('content'))) {
         $data['page_content'] = $content;
     }
     if ($this->is_author) {
         if ($page->getVar('page_inline_css') !== ($css = $form->getVar('inline_css'))) {
             $data['page_inline_css'] = $css;
         }
     }
     $content_changed = count($data) > 0;
     if ($content_changed) {
         $time = time();
         $data['page_time'] = $time;
         $data['page_date'] = GWF_Time::getDate(GWF_Time::LEN_SECOND, $time);
         if (false === $page->saveVars($data)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     if (isset($_POST['home_page']) && $this->is_author) {
         $this->module->setHomePage($page->getOtherID());
     }
     if ($this->is_author) {
         if (false === $this->setAuthorOptions($page)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     if ($this->is_oowner) {
         if (false === $this->setRootOptions($page, $gstring)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         if ($gstring !== $page->getVar('page_groups')) {
             if (false === GWF_PageGID::updateGIDs($page, $gstring)) {
                 return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
             }
         }
     }
     if ($this->is_owner) {
         if (false === $this->setOwnerOptions($page)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     if (false === GWF_PageTags::updateTags($page, $tags, $page->getVar('page_lang'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $this->module->writeHTA()) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     # No content change
     if (!$content_changed) {
         return $this->module->message('msg_edited', array(GWF_WEB_ROOT . $page->display('page_url'), $page->display('page_title')));
     }
     # Content changed!
     echo GWF_Error::message('PageBuilder', 'Content changed!');
     # If author mode we directly push
     if ($this->is_author) {
         if (false === GWF_PageHistory::push($page)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         return $this->module->message('msg_edited', array(GWF_WEB_ROOT . $page->getVar('page_url'), $page->getVar('page_title')));
     }
     # Else we gonna send moderation mails
     if (false === $page->saveOption(GWF_Page::LOCKED, true)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $this->module->sendModMails($page);
     return $this->module->message('msg_edit_locked');
 }
Exemple #3
0
 private function onAdd()
 {
     $form = $this->formAdd();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateAdd();
     }
     $page = $this->getPageObject($form);
     $gstring = $page->getVar('page_groups');
     $tags = $page->getVar('page_meta_tags');
     if (false === $page->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $page->saveVars(array('page_otherid' => $page->getID()))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === GWF_PageGID::updateGIDs($page, Common::getPostArray('groups', array()))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === GWF_PageTags::updateTags($page, $tags, $form->getVar('lang'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (isset($_POST['home_page']) && $this->is_author) {
         $this->module->setHomePage($page->getID());
     }
     if (false === $this->module->writeHTA()) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if ($this->locked_mode) {
         $this->module->sendModMails($page);
     } else {
         GWF_PageHistory::push($page);
     }
     return $this->locked_mode ? $this->module->message('msg_added_locked') : $this->module->message('msg_added', array(GWF_WEB_ROOT . $page->getVar('page_url'), $page->getVar('page_title')));
 }
Exemple #4
0
 private function onDeleteCleanup()
 {
     return GWF_PageTags::cleanupTags();
 }