Esempio n. 1
0
 /**
  * Perform a page copy
  *
  */
 function CopyPage()
 {
     global $gp_index, $gp_titles, $page, $langmessage;
     //existing page info
     $from_title = $_POST['from_title'];
     if (!isset($gp_index[$from_title])) {
         message($langmessage['OOPS_TITLE']);
         return false;
     }
     $from_index = $gp_index[$from_title];
     $info = $gp_titles[$from_index];
     //check the new title
     $title = $_POST['title'];
     $title = admin_tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         message($message);
         return false;
     }
     //get the existing content
     $from_file = gpFiles::PageFile($from_title);
     $contents = file_get_contents($from_file);
     //add to $gp_index first!
     $index = common::NewFileIndex();
     $gp_index[$title] = $index;
     $file = gpFiles::PageFile($title);
     if (!gpFiles::Save($file, $contents)) {
         message($langmessage['OOPS'] . ' (File not saved)');
         return false;
     }
     //add to gp_titles
     $new_titles = array();
     $new_titles[$index]['label'] = admin_tools::PostedLabel($_POST['title']);
     $new_titles[$index]['type'] = $info['type'];
     $gp_titles += $new_titles;
     if (!admin_tools::SavePagesPHP()) {
         message($langmessage['OOPS'] . ' (CP2)');
         return false;
     }
     message($langmessage['SAVED']);
     if (isset($_REQUEST['redir'])) {
         $url = common::AbsoluteUrl($title, '', true, false);
         $page->ajaxReplace[] = array('eval', '', 'window.setTimeout(function(){window.location="' . $url . '"},15000);');
         message(sprintf($langmessage['will_redirect'], common::Link_Page($title)));
     }
     return $index;
 }
Esempio n. 2
0
 /**
  * Perform a page copy
  *
  */
 function CopyPage()
 {
     global $gp_index, $gp_titles, $page, $langmessage;
     $this->CacheSettings();
     //existing page info
     $from_title = $_POST['from_title'];
     if (!isset($gp_index[$from_title])) {
         msg($langmessage['OOPS_TITLE']);
         return false;
     }
     $from_index = $gp_index[$from_title];
     $info = $gp_titles[$from_index];
     //check the new title
     $title = $_POST['title'];
     $title = admin_tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         msg($message);
         return false;
     }
     //get the existing content
     $from_file = gpFiles::PageFile($from_title);
     $contents = file_get_contents($from_file);
     //add to $gp_index first!
     $index = common::NewFileIndex();
     $gp_index[$title] = $index;
     $file = gpFiles::PageFile($title);
     if (!gpFiles::Save($file, $contents)) {
         msg($langmessage['OOPS'] . ' (File not saved)');
         return false;
     }
     //add to gp_titles
     $new_titles = array();
     $new_titles[$index]['label'] = admin_tools::PostedLabel($_POST['title']);
     $new_titles[$index]['type'] = $info['type'];
     $gp_titles += $new_titles;
     //add to menu
     $insert = array();
     $insert[$index] = array();
     if (!$this->SaveNew($insert)) {
         $this->RestoreSettings();
         return false;
     }
     $this->HiddenSaved($index);
     return true;
 }
Esempio n. 3
0
 /**
  * Restore $titles and return array with menu information
  * @param array $titles An array of titles to be restored. After completion, it will contain only the titles that were prepared successfully
  * @return array A list of restored titles that can be used for menu insertion
  *
  */
 function RestoreTitles(&$titles)
 {
     global $dataDir, $gp_index, $gp_titles;
     $new_menu = array();
     $new_titles = array();
     foreach ($titles as $title => $empty) {
         $new_title = admin_tools::CheckPostedNewPage($title, $message);
         if (!$new_title) {
             //message($message);
             continue;
         }
         //add to $gp_index first for PageFile()
         $index = common::NewFileIndex();
         $gp_index[$new_title] = $index;
         //get trash info about file
         $title_info = admin_trash::GetInfo($title);
         if ($title_info === false) {
             unset($gp_index[$new_title]);
             continue;
         }
         //make sure the trash file exists
         $trash_file = $dataDir . '/data/_trash/' . $title_info['file'];
         if (!file_exists($trash_file)) {
             unset($gp_index[$new_title]);
             continue;
         }
         //copy the trash file to the /_pages directory
         $new_file = gpFiles::PageFile($new_title);
         if (!copy($trash_file, $new_file)) {
             unset($gp_index[$new_title]);
             continue;
         }
         //add to $gp_titles
         $gp_titles[$index] = array();
         $gp_titles[$index]['label'] = $title_info['label'];
         $gp_titles[$index]['type'] = $title_info['type'];
         $new_menu[$index] = array();
         $new_titles[$new_title] = true;
         admin_trash::RestoreFile($new_title, $trash_file, $title_info);
     }
     $titles = $new_titles;
     return $new_menu;
 }
Esempio n. 4
0
 function TrashRow($trash_index, $info, $show_orphaned = false)
 {
     global $langmessage;
     $class = '';
     if (isset($info['orphaned'])) {
         $class = 'orphaned';
     }
     //title
     echo '<tr class="' . $class . '"><td>';
     echo '<label style="display:block;">';
     echo '<input type="checkbox" name="titles[]" value="' . htmlspecialchars($trash_index) . '" />';
     echo ' &nbsp; ';
     if (isset($info['orphaned'])) {
         echo '(Orphaned) &nbsp; ';
     }
     echo common::Link('Admin_Trash/' . $trash_index, str_replace('_', ' ', $info['title']));
     echo '</label>';
     //time
     echo '</td><td>';
     if (!empty($info['time'])) {
         $elapsed = admin_tools::Elapsed(time() - $info['time']);
         echo sprintf($langmessage['_ago'], $elapsed);
     }
     echo '</td><td>';
     if (isset($info['type'])) {
         $this->TitleTypes($info['type']);
     }
     echo '</td><td>';
     if (admin_tools::CheckPostedNewPage($info['title'], $msg)) {
         echo common::Link('Admin_Trash', $langmessage['restore'], 'cmd=RestoreDeleted&titles[]=' . rawurlencode($trash_index), array('data-cmd' => 'postlink'));
     } else {
         echo '<span>' . $langmessage['restore'] . '</span>';
     }
     echo ' &nbsp; ';
     echo common::Link('Admin_Trash', $langmessage['delete'], 'cmd=DeleteFromTrash&titles[]=' . rawurlencode($trash_index), array('data-cmd' => 'postlink'));
     echo '</td></tr>';
 }