Exemplo n.º 1
0
 /**
  * Copy a layout
  *
  */
 function CopyLayout()
 {
     global $gpLayouts, $langmessage, $config, $page, $dataDir;
     $copy_id =& $_REQUEST['layout'];
     if (empty($copy_id) || !isset($gpLayouts[$copy_id])) {
         message($langmessage['OOPS'] . '(Invalid Request)');
         return;
     }
     if (empty($_POST['label'])) {
         message($langmessage['OOPS'] . '(Empty Label)');
         return;
     }
     $newLayout = $gpLayouts[$copy_id];
     $newLayout['color'] = self::GetRandColor();
     $newLayout['label'] = htmlspecialchars($_POST['label']);
     //get new unique layout id
     do {
         $layout_id = rand(1000, 9999);
     } while (isset($gpLayouts[$layout_id]));
     $gpLayoutsBefore = $gpLayouts;
     $gpLayouts[$layout_id] = $newLayout;
     if (!gpFiles::ArrayInsert($copy_id, $layout_id, $newLayout, $gpLayouts, 1)) {
         message($langmessage['OOPS'] . '(Not Inserted)');
         return;
     }
     //copy any css
     $css = $this->layoutCSS($copy_id);
     if (!empty($css)) {
         $path = $dataDir . '/data/_layouts/' . $layout_id . '/custom.css';
         if (!gpFiles::Save($path, $css)) {
             message($langmessage['OOPS'] . ' (CSS not saved)');
             return false;
         }
     }
     if (admin_tools::SavePagesPHP()) {
         message($langmessage['SAVED']);
     } else {
         $gpLayouts = $gpLayoutsBefore;
         message($langmessage['OOPS'] . '(Not Saved)');
     }
 }
Exemplo n.º 2
0
 /**
  * Handle the renaming of galleries for admin_menu_tools.php
  *
  * @static
  *
  */
 function RenamedGallery($old_title, $new_title)
 {
     $galleries = special_galleries::GetData();
     if (!isset($galleries[$old_title])) {
         return;
     }
     if (gpFiles::ArrayInsert($old_title, $new_title, $galleries[$old_title], $galleries, 0, 1)) {
         special_galleries::SaveIndex($galleries);
     }
 }
Exemplo n.º 3
0
 /**
  * Replace a key-value pair in an associative array
  * ArrayReplace() is a shortcut for using gpFiles::ArrayInsert() with $offset = 0 and $length = 1
  */
 public static function ArrayReplace($search_key, $new_key, $new_value, &$array)
 {
     return gpFiles::ArrayInsert($search_key, $new_key, $new_value, $array, 0, 1);
 }
Exemplo n.º 4
0
 function NewDrag()
 {
     global $page, $langmessage;
     $page->ajaxReplace = array();
     //get the title of the gallery that was moved
     $dragging = $_POST['title'];
     if (!isset($this->galleries[$dragging])) {
         message($langmessage['OOPS'] . ' (Title not in gallery list)');
         return false;
     }
     $info = $this->galleries[$dragging];
     unset($this->galleries[$dragging]);
     //set visibility
     if (isset($_POST['active'])) {
         $info['visibility'] = 'show';
     } else {
         $info['visibility'] = 'hide';
     }
     //place before the element represented by $_POST['next'] if it's set
     if (isset($_POST['next'])) {
         $next = $_POST['next'];
         if (!isset($this->galleries[$next])) {
             message($langmessage['OOPS'] . ' (Next not found)');
             return false;
         }
         if (!gpFiles::ArrayInsert($next, $dragging, $info, $this->galleries)) {
             message($langmessage['OOPS'] . ' (Insert Failed)');
             return false;
         }
         //place at the end
     } else {
         $this->galleries[$dragging] = $info;
     }
     //save it
     if (!special_galleries::SaveIndex($this->galleries)) {
         message($langmessage['OOPS'] . ' (Not Saved)');
         return false;
     }
 }