Example #1
0
 function RenameFile()
 {
     global $langmessage, $gp_index, $page;
     includeFile('tool/Page_Rename.php');
     $new_title = gp_rename::RenameFile($this->title);
     if ($new_title !== false && $new_title != $this->title) {
         msg(sprintf($langmessage['will_redirect'], common::Link_Page($new_title)));
         $page->head .= '<meta http-equiv="refresh" content="15;url=' . common::GetUrl($new_title) . '">';
         return true;
     }
     return false;
 }
Example #2
0
 function AdminProtect()
 {
     global $gp_menu;
     $this->PageProtect();
     echo '<h2>';
     echo common::Link('Admin_Protect', 'Protected Pages');
     echo '</h2>';
     $cmd = common::GetCommand();
     switch ($cmd) {
         case 'savecontent':
             $this->SaveContent();
         case 'editcontent':
             $this->EditContent();
             return;
     }
     echo '<p>';
     echo '<b>' . common::Link('Admin_Protect', 'Protected Content', 'cmd=editcontent') . '</b> ';
     echo 'Edit the content users will see if they navigate to a protected page and aren\'t logged in.';
     echo '</p>';
     if (!count($this->config['pages'])) {
         echo '<p>There aren\'t any protected pages.</p>';
         return;
     }
     echo '<table class="bordered">';
     echo '<tr><th>Pages</th><th>Child Pages</th></tr>';
     foreach ($this->config['pages'] as $page_index => $bool) {
         $title = common::IndexToTitle($page_index);
         //may be deleted
         if (!$title) {
             continue;
         }
         echo '<tr>';
         echo '<td>';
         echo common::Link_Page($title);
         echo '</td>';
         echo '<td>';
         $affected = common::Descendants($page_index, $gp_menu);
         $titles = array();
         foreach ($affected as $temp_index) {
             $title = common::IndexToTitle($temp_index);
             $titles[] = common::Link_Page($title);
         }
         echo implode(', ', $titles);
         echo '</td>';
         echo '</tr>';
     }
     echo '</table>';
 }
Example #3
0
 /**
  * View all pages of the requested language
  *
  */
 public function AllTitles()
 {
     global $langmessage;
     echo '<h2>' . $langmessage['Pages'] . '</h2>';
     $lang_lists = array();
     foreach ($this->lists as $list_index => $list) {
         foreach ($list as $lang => $index) {
             $lang_lists[$lang][] = $index;
         }
     }
     foreach ($lang_lists as $lang => $indexes) {
         echo '<div class="ml_stats"><div>';
         echo '<table class="bordered striped">';
         echo '<thead><tr><th>' . $this->avail_langs[$lang] . '</th><th>' . $langmessage['options'] . '</th></tr>';
         echo '<tbody>';
         foreach ($indexes as $index) {
             echo '<tr><td>';
             $title = common::IndexToTitle($index);
             echo common::Link_Page($title);
             echo '</td><td>';
             echo common::Link('Admin_MultiLang', $langmessage['options'], 'cmd=TitleSettings&index=' . $index, ' name="gpabox"');
             echo '</td></tr>';
         }
         echo '</tbody>';
         echo '</table>';
         echo '</div></div>';
     }
 }
Example #4
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;
 }
Example #5
0
 function AdminContentPanel()
 {
     global $page, $config, $langmessage, $gp_menu;
     //the login form does not need the panel
     if (!common::LoggedIn()) {
         return;
     }
     echo '<div id="admincontent_panel" class="toolbar">';
     echo '<div class="right">';
     echo '<span class="admin_arrow_out"></span>';
     echo '<a class="docklink" name="gp_docklink"></a>';
     echo '</div>';
     reset($gp_menu);
     $homepath = common::IndexToTitle(key($gp_menu));
     echo common::Link_Page($homepath);
     echo ' &#187; ';
     echo common::Link('Admin_Main', $langmessage['administration']);
     if (!empty($page->title) && !empty($page->label) && $page->title != 'Admin_Main') {
         echo ' &#187; ';
         echo common::Link($page->title, $page->label);
     }
     echo '</div>';
 }
Example #6
0
 /**
  * Language selection popup
  *
  */
 function TitleSettings($args = array())
 {
     global $gp_titles, $langmessage, $langmessage, $ml_languages, $gp_index;
     $args += array('to_lang' => '', 'to_slug' => '');
     $page_index = $_REQUEST['index'];
     if (!isset($gp_titles[$page_index])) {
         echo $langmessage['OOPS'] . ' (Invalid Title - 3)';
         return;
     }
     $list = $this->GetList($page_index);
     echo '<div>';
     echo '<form method="post" action="' . common::GetUrl('Admin_MultiLang') . '">';
     echo '<input type="hidden" name="cmd" value="title_settings_add" />';
     echo '<input type="hidden" name="index" value="' . $page_index . '" />';
     echo '<h3>Page Settings</h3>';
     echo '<table class="bordered"><tr><th>Language</th><th>Title</th><th>Options</th></tr>';
     //not set yet
     if (!$list) {
         $in_menu = $this->InMenu($page_index);
         echo '<tr><td>';
         if ($in_menu) {
             echo $this->language;
         } else {
             $this->LanguageSelect('from_lang');
         }
         echo '</td><td>';
         $title = common::IndexToTitle($page_index);
         echo common::Link_Page($title);
         echo '</td><td>';
         echo '</td></tr>';
     }
     //current settings
     foreach ($ml_languages as $lang => $language) {
         if (!isset($list[$lang])) {
             continue;
         }
         $index = $list[$lang];
         echo '<tr><td>';
         echo $language . ' (' . $lang . ')';
         echo '</td><td>';
         $title = common::IndexToTitle($index);
         echo common::Link_Page($title);
         echo '</td><td>';
         echo common::Link('Admin_MultiLang', 'Remove', 'cmd=rmtitle&index=' . $page_index . '&rmindex=' . $index, 'name="gpabox" class="gpconfirm" title="Remove this entry?"');
         echo '</td></tr>';
     }
     //option to add another title
     echo '<tr><td>';
     $this->LanguageSelect('to_lang', $args['to_lang'], $this->lang);
     echo '</td><td>';
     $this->TitleSelect($args['to_slug'], $list);
     echo '</td><td>';
     echo '<input type="submit" value="' . $langmessage['save'] . '" class="gpabox gpbutton" /> ';
     echo '</td></tr>';
     echo '</table>';
     echo '</form>';
     $this->SmLinks();
     //add languages as json
     $data = array();
     foreach ($this->langs as $code => $label) {
         $data[] = array($label, $code);
     }
     echo "\n";
     echo '<span id="lang_data" data-json=\'' . htmlspecialchars(json_encode($data), ENT_QUOTES & ~ENT_COMPAT) . '\'></span>';
     //add titles as json
     $data = array();
     foreach ($gp_index as $slug => $index) {
         $label = common::GetLabelIndex($index);
         $data[] = array($slug, common::LabelSpecialChars($label));
     }
     echo "\n";
     echo '<span id="lang_titles" data-json=\'' . htmlspecialchars(json_encode($data), ENT_QUOTES & ~ENT_COMPAT, 'UTF-8', false) . '\'></span>';
     echo '</div>';
 }
Example #7
0
 /**
  * Give users the option of removing the settings for a page
  *
  */
 function ListSettings($page_index)
 {
     global $langmessage, $ml_languages;
     $list = $this->GetList($page_index);
     echo '<div>';
     echo '<form method="post" action="' . common::GetUrl('Admin_MultiLang') . '">';
     echo '<input type="hidden" name="cmd" value="title_settings_add" />';
     echo '<input type="hidden" name="index" value="' . $page_index . '" />';
     echo '<h3>Settings</h3>';
     echo '<p>This page has been associated with the following list of pages.</p>';
     echo '<table class="bordered"><tr><th>Language</th><th>Title</th><th>Options</th></tr>';
     //current settings
     foreach ($ml_languages as $lang => $language) {
         if (!isset($list[$lang])) {
             continue;
         }
         $index = $list[$lang];
         echo '<tr><td>';
         echo $language . ' (' . $lang . ')';
         echo '</td><td>';
         $title = common::IndexToTitle($index);
         echo common::Link_Page($title);
         echo '</td><td>';
         echo common::Link('Admin_MultiLang', 'Remove', 'cmd=rmtitle&index=' . $page_index . '&rmindex=' . $index, 'name="gpabox" class="gpconfirm" title="Remove this entry?"');
         echo '</td></tr>';
     }
     //option to add another title
     echo '<tr><td>';
     $this->LanguageSelect('ml_lang', false, $this->lang);
     echo '</td><td>';
     $this->TitleSelect(false, $list);
     echo '</td><td>';
     echo '<input type="submit" value="' . $langmessage['save'] . '" class="gpabox gpbutton" /> ';
     echo '</td></tr>';
     echo '</table>';
     echo '</form>';
     $this->SmLinks();
     echo '</div>';
 }
Example #8
0
 /**
  * Get a comma separated list of links to titles similar to the requested page
  * @return string
  *
  */
 function SimilarTitles()
 {
     $similar = $this->SimilarTitleArray($this->requested);
     $similar = array_slice($similar, 0, 7, true);
     $result = '';
     foreach ($similar as $title => $percent_similar) {
         $result .= common::Link_Page($title) . ', ';
     }
     return rtrim($result, ', ');
 }
Example #9
0
 /**
  * Message or redirect when file is saved
  *
  */
 public function HiddenSaved($new_index)
 {
     global $langmessage, $page;
     $this->search_page = 0;
     //take user back to first page where the new page will be displayed
     if (isset($_REQUEST['redir'])) {
         $title = common::IndexToTitle($new_index);
         $url = common::AbsoluteUrl($title, '', true, false);
         msg(sprintf($langmessage['will_redirect'], common::Link_Page($title)));
         $page->ajaxReplace[] = array('location', $url, 15000);
     } else {
         msg($langmessage['SAVED']);
     }
 }
Example #10
0
 /**
  * Rename a page
  *
  */
 public static function RenamePage($page)
 {
     global $langmessage, $gp_index;
     includeFile('tool/Page_Rename.php');
     $new_title = gp_rename::RenameFile($page->title);
     if ($new_title !== false && $new_title != $page->title) {
         msg(sprintf($langmessage['will_redirect'], common::Link_Page($new_title)));
         $page->head .= '<meta http-equiv="refresh" content="15;url=' . common::GetUrl($new_title) . '">';
         $page->ajaxReplace[] = array('location', common::GetUrl($new_title), 15000);
         return true;
     }
     return false;
 }