/**
  * Return the name of the cleansed extra area name, create file if it doesn't already exist
  *
  */
 function NewExtraArea()
 {
     global $langmessage, $dataDir;
     $title = gp_edit::CleanTitle($_REQUEST['extra_area']);
     if (empty($title)) {
         message($langmessage['OOPS']);
         return false;
     }
     $data = gp_edit::DefaultContent($_POST['type']);
     $file = $dataDir . '/data/_extra/' . $title . '.php';
     if (gpFiles::Exists($file)) {
         return $title;
     }
     if (!gpFiles::SaveData($file, 'extra_content', $data)) {
         message($langmessage['OOPS']);
         return false;
     }
     return $title;
 }
 /**
  * Create a new page from a user post
  *
  */
 function CreateNew()
 {
     global $gp_index, $gp_titles, $langmessage, $gpAdmin;
     includeFile('tool/editing_page.php');
     includeFile('tool/editing.php');
     $title = $_POST['title'];
     $title = admin_tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         message($message);
         return false;
     }
     $type = $_POST['content_type'];
     $section = gp_edit::DefaultContent($type);
     if ($section['content'] === false) {
         return false;
     }
     $label = admin_tools::PostedLabel($_POST['title']);
     if ($type == 'text') {
         $section['content'] = '<h2>' . strip_tags($_POST['title']) . '</h2>' . $section['content'];
     }
     //add to $gp_index first!
     $index = common::NewFileIndex();
     $gp_index[$title] = $index;
     if (!gpFiles::NewTitle($title, $section, $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;
     //add to users editing
     if ($gpAdmin['editing'] != 'all') {
         $gpAdmin['editing'] = rtrim($gpAdmin['editing'], ',') . ',' . $index . ',';
         $users = gpFiles::Get('_site/users');
         $users[$gpAdmin['username']]['editing'] = $gpAdmin['editing'];
         gpFiles::SaveData('_site/users', 'users', $users);
     }
     return $index;
 }
Example #3
0
 /**
  * Save new/rearranged sections
  *
  */
 function SaveSections()
 {
     global $page, $langmessage;
     $page->ajaxReplace = array();
     $original_sections = $this->file_sections;
     $unused_sections = $this->file_sections;
     //keep track of sections that aren't used
     $new_sections = array();
     $section_types = section_content::GetTypes();
     foreach ($_POST['section_order'] as $i => $arg) {
         // moved / copied sections
         if (ctype_digit($arg)) {
             $arg = (int) $arg;
             if (!isset($this->file_sections[$arg])) {
                 message($langmessage['OOPS'] . ' (Invalid Section Number)');
                 return false;
             }
             unset($unused_sections[$arg]);
             $new_section = $this->file_sections[$arg];
             $new_section['attributes'] = array();
             // otherwise, new sections
         } else {
             if (!isset($section_types[$arg])) {
                 message($langmessage['OOPS'] . ' (Unknown Type: ' . $arg . ')');
                 return false;
             }
             $new_section = gp_edit::DefaultContent($arg);
         }
         // attributes
         if (isset($_POST['attributes'][$i]) && is_array($_POST['attributes'][$i])) {
             foreach ($_POST['attributes'][$i] as $attr_name => $attr_value) {
                 $attr_name = strtolower($attr_name);
                 $attr_name = trim($attr_name);
                 $attr_value = trim($attr_value);
                 if (empty($attr_name) || empty($attr_value) || $attr_name == 'id' || substr($attr_name, 0, 7) == 'data-gp') {
                     continue;
                 }
                 $new_section['attributes'][$attr_name] = $attr_value;
             }
         }
         // wrapper section 'contains_sections'
         if ($new_section['type'] == 'wrapper_section') {
             $new_section['contains_sections'] = isset($_POST['contains_sections']) ? $_POST['contains_sections'][$i] : '0';
         }
         $new_sections[$i] = $new_section;
     }
     //make sure there's at least one section
     if (!$new_sections) {
         message($langmessage['OOPS'] . ' (1 Section Minimum)');
         return false;
     }
     $this->file_sections = $new_sections;
     $this->ResetFileTypes(false);
     // save a send message to user
     if (!$this->SaveThis()) {
         $this->file_sections = $original_sections;
         message($langmessage['OOPS'] . '(4)');
         return;
     }
     $page->ajaxReplace[] = array('ck_saved', '', '');
     message($langmessage['SAVED']);
     //update gallery info
     $this->GalleryEdited();
     //update usage of resized images
     foreach ($unused_sections as $section_data) {
         if (isset($section_data['resized_imgs'])) {
             includeFile('image.php');
             gp_resized::SetIndex();
             gp_edit::ResizedImageUse($section_data['resized_imgs'], array());
         }
     }
 }
Example #4
0
 /**
  * Create a new extra content section
  *
  */
 function NewSection()
 {
     global $langmessage, $gpAdmin;
     $title = gp_edit::CleanTitle($_REQUEST['file']);
     if (empty($title)) {
         message($langmessage['OOPS']);
         return false;
     }
     $data = gp_edit::DefaultContent($_POST['type']);
     $file = $this->folder . '/' . $title . '.php';
     $data['created'] = time();
     $data['created_by'] = $gpAdmin['username'];
     if (!gpFiles::SaveData($file, 'extra_content', $data)) {
         message($langmessage['OOPS']);
         $this->EditExtra();
         return false;
     }
     message($langmessage['SAVED']);
     $this->Getdata();
 }
Example #5
0
 /**
  * Create a new page from a user post
  *
  */
 function CreateNew()
 {
     global $gp_index, $gp_titles, $langmessage, $gpAdmin;
     includeFile('tool/editing_page.php');
     includeFile('tool/editing.php');
     //check title
     $title = $_POST['title'];
     $title = admin_tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         message($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_edit::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_edit::DefaultContent($type);
                 $section['attributes']['class'] .= ' ' . $class;
                 $content[] = $section;
             }
         }
         //single section type
     } else {
         $content = gp_edit::DefaultContent($type);
         if ($content['content'] === false) {
             return false;
         }
         if ($type == 'text') {
             $content['content'] = '<h2>' . strip_tags($_POST['title']) . '</h2>' . $content['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'] = 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 = gpFiles::Get('_site/users');
         $users[$gpAdmin['username']]['editing'] = $gpAdmin['editing'];
         gpFiles::SaveData('_site/users', 'users', $users);
     }
     return $index;
 }