Ejemplo n.º 1
0
 /**
  * Get the content of the file in the trash so we can restore file information
  *  - resized images
  *  - \gp\special\Galleries::UpdateGalleryInfo($title,$content)
  *
  */
 public static function RestoreFile($title, $file, $title_info)
 {
     $file_sections = \gp\tool\Files::Get($file, 'file_sections');
     // Restore resized images
     if (count($file_sections)) {
         includeFile('image.php');
         \gp_resized::SetIndex();
         foreach ($file_sections as $section => $section_data) {
             if (!isset($section_data['resized_imgs'])) {
                 continue;
             }
             foreach ($section_data['resized_imgs'] as $image_index => $sizes) {
                 if (!isset(\gp_resized::$index[$image_index])) {
                     continue;
                 }
                 $img = \gp_resized::$index[$image_index];
                 foreach ($sizes as $size) {
                     list($width, $height) = explode('x', $size);
                     \gp\tool\Editing::CreateImage($img, $width, $height);
                 }
             }
             \gp\tool\Editing::ResizedImageUse(array(), $section_data['resized_imgs']);
         }
         \gp_resized::SaveIndex();
     }
     // Restore Galleries
     if (strpos($title_info['type'], 'gallery') !== false) {
         \gp\special\Galleries::UpdateGalleryInfo($title, $file_sections);
     }
 }
Ejemplo n.º 2
0
 /**
  * Save new/rearranged sections
  *
  */
 public function SaveSections()
 {
     global $langmessage;
     $this->ajaxReplace = array();
     $original_sections = $this->file_sections;
     $unused_sections = $this->file_sections;
     //keep track of sections that aren't used
     $new_sections = array();
     //make sure section_order isn't empty
     if (empty($_POST['section_order'])) {
         msg($langmessage['OOPS'] . ' (Invalid Request)');
         return false;
     }
     foreach ($_POST['section_order'] as $i => $arg) {
         $new_section = $this->SaveSection($i, $arg, $unused_sections);
         if ($new_section === false) {
             return false;
         }
         $new_sections[$i] = $new_section;
     }
     //make sure there's at least one section
     if (empty($new_sections)) {
         msg($langmessage['OOPS'] . ' (1 Section Minimum)');
         return false;
     }
     $this->file_sections = array_values($new_sections);
     // save a send message to user
     if (!$this->SaveThis()) {
         $this->file_sections = $original_sections;
         msg($langmessage['OOPS'] . '(4)');
         return;
     }
     $this->ajaxReplace[] = array('ck_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\tool\Editing::ResizedImageUse($section_data['resized_imgs'], array());
         }
     }
 }