示例#1
0
 /**
  * Handle renaming a page based on POSTed data
  *
  */
 public static function RenameFile($title)
 {
     global $langmessage, $page, $gp_index, $gp_titles;
     $page->ajaxReplace = array();
     //change the title
     $title = self::RenameFileWorker($title);
     if ($title === false) {
         return false;
     }
     if (!isset($gp_index[$title])) {
         msg($langmessage['OOPS']);
         return false;
     }
     $id = $gp_index[$title];
     $title_info =& $gp_titles[$id];
     //change the label
     $title_info['label'] = \gp\admin\Tools::PostedLabel($_POST['new_label']);
     if (isset($title_info['lang_index'])) {
         unset($title_info['lang_index']);
     }
     //browser_title, keywords, description
     self::SetInfo($title_info, 'browser_title');
     self::SetInfo($title_info, 'keywords');
     self::SetInfo($title_info, 'description');
     self::SetRobots($title_info);
     //same as auto-generated?
     $auto_browser_title = strip_tags($title_info['label']);
     if (isset($title_info['browser_title']) && $title_info['browser_title'] == $auto_browser_title) {
         unset($title_info['browser_title']);
     }
     if (!\gp\admin\Tools::SavePagesPHP(true, true)) {
         return false;
     }
     return $title;
 }
示例#2
0
 /**
  * Check the values of a post with external link values
  *
  */
 public function ExternalPost()
 {
     $array = array();
     if (empty($_POST['url']) || $_POST['url'] == 'http://') {
         return false;
     }
     $array['url'] = htmlspecialchars($_POST['url']);
     if (!empty($_POST['label'])) {
         $array['label'] = \gp\admin\Tools::PostedLabel($_POST['label']);
     }
     if (!empty($_POST['title_attr'])) {
         $array['title_attr'] = htmlspecialchars($_POST['title_attr']);
     }
     if (isset($_POST['new_win']) && $_POST['new_win'] == 'new_win') {
         $array['new_win'] = true;
     }
     return $array;
 }
示例#3
0
 /**
  * Create a new page from a user post
  *
  */
 public static function CreateNew()
 {
     global $gp_index, $gp_titles, $langmessage, $gpAdmin;
     //check title
     $title = $_POST['title'];
     $title = \gp\admin\Tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         msg($message);
         return false;
     }
     //multiple section types
     $type = $_POST['content_type'];
     if (strpos($type, '{') === 0) {
         $types = json_decode($type, true);
         if ($types) {
             $types += array('wrapper_class' => 'gpRow');
             $content = array();
             //wrapper section
             $section = \gp\tool\Editing::DefaultContent('wrapper_section');
             $section['contains_sections'] = count($types['types']);
             $section['attributes']['class'] = $types['wrapper_class'];
             $content[] = $section;
             //nested sections
             foreach ($types['types'] as $type) {
                 if (strpos($type, '.')) {
                     list($type, $class) = explode('.', $type, 2);
                 } else {
                     $class = '';
                 }
                 $section = \gp\tool\Editing::DefaultContent($type);
                 $section['attributes']['class'] .= ' ' . $class;
                 $content[] = $section;
             }
         }
         //single section type
     } else {
         $content = \gp\tool\Editing::DefaultContent($type, $_POST['title']);
         if ($content['content'] === false) {
             return false;
         }
     }
     //add to $gp_index first!
     $index = \gp\tool::NewFileIndex();
     $gp_index[$title] = $index;
     if (!\gp\tool\Files::NewTitle($title, $content, $type)) {
         msg($langmessage['OOPS'] . ' (cn1)');
         unset($gp_index[$title]);
         return false;
     }
     //add to gp_titles
     $new_titles = array();
     $new_titles[$index]['label'] = \gp\admin\Tools::PostedLabel($_POST['title']);
     $new_titles[$index]['type'] = $type;
     $gp_titles += $new_titles;
     //add to users editing
     if ($gpAdmin['editing'] != 'all') {
         $gpAdmin['editing'] = rtrim($gpAdmin['editing'], ',') . ',' . $index . ',';
         $users = \gp\tool\Files::Get('_site/users');
         $users[$gpAdmin['username']]['editing'] = $gpAdmin['editing'];
         \gp\tool\Files::SaveData('_site/users', 'users', $users);
     }
     return $index;
 }