Exemplo n.º 1
0
 /**
  * Create a new page from a user post
  *
  */
 function CreateNew()
 {
     global $gp_index, $gp_titles, $langmessage;
     includeFile('tool/editing_page.php');
     $title = $_POST['title'];
     $title = admin_tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         message($message);
         return false;
     }
     $type = $_POST['content_type'];
     $content = editing_page::GetDefaultContent($type);
     if ($content === false) {
         return false;
     }
     $label = admin_tools::PostedLabel($_POST['title']);
     if ($type == 'text') {
         $content = '<h2>' . strip_tags($_POST['title']) . '</h2>' . $content;
     }
     //add to $gp_index first!
     $index = common::NewFileIndex();
     $gp_index[$title] = $index;
     if (!gpFiles::NewTitle($title, $content, $type)) {
         message($langmessage['OOPS'] . ' (cn1)');
         unset($gp_index[$title]);
         return false;
     }
     //add to gp_titles
     $new_titles = array();
     $new_titles[$index]['label'] = $label;
     $new_titles[$index]['type'] = $type;
     $gp_titles += $new_titles;
     return $index;
 }
Exemplo n.º 2
0
 /**
  * Add a new section to the page
  *
  */
 function AddNewSection()
 {
     global $langmessage;
     if ($_POST['last_mod'] != $this->fileModTime) {
         message($langmessage['OOPS']);
         return false;
     }
     if (!isset($_POST['section'])) {
         message($langmessage['OOPS'] . '(1)');
         return;
     }
     $section = $_POST['section'];
     if (!isset($this->file_sections[$section])) {
         message($langmessage['OOPS'] . '(2)');
         return;
     }
     if (isset($_POST['copy'])) {
         $start_content = $this->file_sections[$section];
     } else {
         $start_content['type'] = $_POST['content_type'];
         $start_content['content'] = editing_page::GetDefaultContent($start_content['type']);
         if ($start_content['content'] === false) {
             message($langmessage['OOPS'] . '(3)');
             return;
         }
     }
     if (isset($_POST['insert']) && $_POST['insert'] == 'before') {
         array_splice($this->file_sections, $section, 0, 'temporary');
         $new_section = $section;
     } else {
         array_splice($this->file_sections, $section + 1, 0, 'temporary');
         $new_section = $section + 1;
     }
     if ($this->file_sections[$new_section] != 'temporary') {
         message($langmessage['OOPS'] . '(4)');
         return;
     }
     $this->file_sections[$new_section] = $start_content;
     $this->ResetFileTypes();
     if (!$this->SaveThis()) {
         message($langmessage['OOPS'] . '(4)');
         return;
     }
     message($langmessage['SAVED']);
 }