Exemplo n.º 1
0
 /**
  * Create a new page from a user post
  *
  */
 function CreateNew()
 {
     global $gp_index, $gp_titles, $langmessage;
     includeFile('tool/editing_page.php');
     $title = $_POST['title'];
     $title = admin_tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         message($message);
         return false;
     }
     $type = $_POST['content_type'];
     $content = editing_page::GetDefaultContent($type);
     if ($content === false) {
         return false;
     }
     $label = admin_tools::PostedLabel($_POST['title']);
     if ($type == 'text') {
         $content = '<h2>' . strip_tags($_POST['title']) . '</h2>' . $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'] = $label;
     $new_titles[$index]['type'] = $type;
     $gp_titles += $new_titles;
     return $index;
 }
Exemplo n.º 2
0
 /**
  * Display a form for adding a new section to the page
  *
  */
 function NewSectionPrompt()
 {
     global $langmessage;
     ob_start();
     echo '<div class="inline_box">';
     echo '<form method="post" action="' . common::GetUrl($this->title) . '">';
     echo '<h2>' . $langmessage['new_section_about'] . '</h2>';
     echo '<table class="bordered full_width">';
     echo '<tr><th colspan="2">' . $langmessage['New Section'] . '</th></tr>';
     echo '<tr><td>';
     echo $langmessage['Content Type'];
     echo '</td><td>';
     editing_page::SectionTypes();
     echo '</td></tr>';
     echo '<tr><td>';
     echo $langmessage['Insert Location'];
     echo '</td><td>';
     echo '<label><input type="radio" name="insert" value="before" /> ';
     echo $langmessage['insert_before'];
     echo '</label>';
     echo '<label><input type="radio" name="insert" value="after" checked="checked" /> ';
     echo $langmessage['insert_after'];
     echo '</label>';
     echo '</td></tr>';
     echo '</table>';
     echo '<p>';
     echo '<input type="hidden" name="last_mod" value="' . $this->fileModTime . '" />';
     echo '<input type="hidden" name="section" value="' . $_GET['section'] . '" />';
     echo '<input type="hidden" name="cmd" value="add_section" />';
     echo '<input type="submit" name="" value="' . $langmessage['save'] . '" class="gpsubmit"/>';
     echo ' <input type="button" name="" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" />';
     echo '</p>';
     echo '</form>';
     echo '</div>';
     $this->contentBuffer = ob_get_clean();
 }
Exemplo n.º 3
0
 /**
  * Display the dialog for inserting pages into a menu
  *
  */
 function InsertDialog($cmd)
 {
     global $langmessage, $page;
     includeFile('admin/admin_trash.php');
     echo '<div class="inline_box">';
     echo '<div class="layout_links">';
     echo ' <a href="#gp_Insert_New" data-cmd="tabs" class="selected">' . $langmessage['new_file'] . '</a>';
     echo ' <a href="#gp_Insert_Hidden" data-cmd="tabs">' . $langmessage['Available Pages'] . '</a>';
     echo ' <a href="#gp_Insert_Deleted" data-cmd="tabs">' . $langmessage['restore_from_trash'] . '</a>';
     echo ' <a href="#gp_Insert_External" data-cmd="tabs">' . $langmessage['External Link'] . '</a>';
     echo '</div>';
     // Insert New
     echo '<div id="gp_Insert_New">';
     echo '<form action="' . $this->GetUrl('Admin_Menu') . '" method="post">';
     echo '<table class="bordered full_width">';
     echo '<tr><th>&nbsp;</th><th>&nbsp;</th></tr>';
     echo '<tr>';
     echo '<td>' . $langmessage['label'] . '</td>';
     echo '<td><input type="text" name="title" maxlength="100" value="" size="50" class="gpinput" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '<td>' . $langmessage['Content Type'] . '</td>';
     echo '<td>';
     includeFile('tool/editing_page.php');
     editing_page::SectionTypes();
     echo '</td>';
     echo '</tr>';
     echo '</table>';
     echo '<p>';
     echo '<input type="hidden" name="insert_how" value="' . htmlspecialchars($cmd) . '" />';
     echo '<input type="hidden" name="insert_where" value="' . htmlspecialchars($_GET['insert_where']) . '" />';
     echo '<input type="hidden" name="cmd" value="new_file" />';
     echo '<input type="submit" name="aaa" value="' . $langmessage['create_new_file'] . '" class="menupost gpsubmit"/> ';
     echo '<input type="submit" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" /> ';
     echo '</p>';
     echo '</form>';
     echo '</div>';
     // Insert Hidden
     echo '<div id="gp_Insert_Hidden" class="nodisplay">';
     if ($this->is_main_menu) {
         $avail = $this->GetAvailable();
     } else {
         $avail = $this->GetAvail_Current();
     }
     if (count($avail) == 0) {
         echo '<p>';
         echo $langmessage['Empty'];
         echo '</p>';
     } else {
         echo '<form action="' . common::GetUrl('Admin_Menu') . '" method="post">';
         echo '<table class="bordered full_width">';
         echo '<thead><tr><th>';
         echo $langmessage['title'];
         echo ' &nbsp; <input type="text" name="search" value="" class="gpinput gpsearch" />';
         echo '</th><th class="gp_right">';
         echo $langmessage['insert_into_menu'];
         echo '</th></tr></thead>';
         echo '</table>';
         echo '<ul class="gpui-scrolllist ui-menu ui-widget ui-widget-content ui-corner-all">';
         //sort by label
         $sort_avail = array();
         foreach ($avail as $index => $title) {
             $sort_avail[$index] = common::GetLabel($title);
         }
         natcasesort($sort_avail);
         foreach ($sort_avail as $index => $label) {
             echo '<li class="ui-menu-item">';
             echo '<label class="ui-corner-all">';
             echo '<input type="checkbox" name="keys[]" value="' . htmlspecialchars($index) . '" />';
             echo common::LabelSpecialChars($label);
             echo '<span class="slug">';
             echo '/' . $avail[$index];
             echo '</span>';
             echo '</label>';
             echo '</li>';
         }
         echo '</ul>';
         echo '<p>';
         echo '<input type="hidden" name="insert_how" value="' . htmlspecialchars($cmd) . '" />';
         echo '<input type="hidden" name="insert_where" value="' . htmlspecialchars($_GET['insert_where']) . '" />';
         echo '<input type="hidden" name="cmd" value="insert_from_hidden"  />';
         echo '<input type="submit" name="" value="' . $langmessage['insert_into_menu'] . '" class="menupost gpsubmit" />';
         echo ' <input type="submit" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" /> ';
         echo '</p>';
         echo '</form>';
     }
     echo '</div>';
     // Insert Deleted / Restore from trash
     echo '<div id="gp_Insert_Deleted" class="nodisplay">';
     $trashtitles = admin_trash::TrashFiles();
     if (count($trashtitles) == 0) {
         echo '<p>' . $langmessage['TRASH_IS_EMPTY'] . '</p>';
     } else {
         echo '<form action="' . common::GetUrl('Admin_Menu') . '" method="post">';
         echo '<table class="bordered full_width"><thead>';
         echo '<tr><th>' . $langmessage['title'];
         echo ' &nbsp; <input type="text" name="search" value="" class="gpinput gpsearch" />';
         echo '</th><th class="gp_right">';
         echo $langmessage['restore'];
         echo '</th></tr>';
         echo '</thead></table>';
         echo '<ul class="gpui-scrolllist ui-menu ui-widget ui-widget-content ui-corner-all">';
         foreach ($trashtitles as $title => $info) {
             echo '<li class="ui-menu-item">';
             echo '<label class="ui-corner-all">';
             echo '<input type="checkbox" name="titles[]" value="' . htmlspecialchars($title) . '" />';
             echo $info['label'];
             echo '<span class="slug">';
             echo '/' . $title;
             echo '</span>';
             echo '</label></li>';
         }
         echo '</ul>';
         echo '<p>';
         echo '<input type="hidden" name="insert_how" value="' . htmlspecialchars($cmd) . '" />';
         echo '<input type="hidden" name="insert_where" value="' . htmlspecialchars($_GET['insert_where']) . '" />';
         echo '<input type="hidden" name="cmd" value="restore"  />';
         echo '<input type="submit" name="" value="' . $langmessage['restore'] . '" class="menupost gpsubmit" />';
         echo ' <input type="submit" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" /> ';
         echo '</p>';
         echo '</form>';
     }
     echo '</div>';
     //Insert External
     echo '<div id="gp_Insert_External" class="nodisplay">';
     $args['insert_how'] = $cmd;
     $args['insert_where'] = $_GET['insert_where'];
     $this->ExternalForm('new_external', $langmessage['insert_into_menu'], $args);
     echo '</div>';
     echo '</div>';
 }
Exemplo n.º 4
0
 /**
  * Display the dialog for inserting pages into a menu
  *
  */
 public function InsertDialog($cmd)
 {
     global $langmessage, $page, $gp_index;
     includeFile('admin/admin_trash.php');
     //create format of each tab
     ob_start();
     echo '<div id="%s" class="%s">';
     echo '<form action="' . common::GetUrl('Admin_Menu') . '" method="post">';
     echo '<input type="hidden" name="insert_where" value="' . htmlspecialchars($_GET['insert_where']) . '" />';
     echo '<input type="hidden" name="insert_how" value="' . htmlspecialchars($cmd) . '" />';
     echo '<table class="bordered full_width">';
     echo '<thead><tr><th>&nbsp;</th></tr></thead>';
     echo '</table>';
     $format_top = ob_get_clean();
     ob_start();
     echo '<p>';
     echo '<button type="submit" name="cmd" value="%s" class="gpsubmit" data-cmd="gppost">%s</button>';
     echo '<button class="admin_box_close gpcancel">' . $langmessage['cancel'] . '</button>';
     echo '</p>';
     echo '</form>';
     echo '</div>';
     $format_bottom = ob_get_clean();
     echo '<div class="inline_box">';
     //tabs
     echo '<div class="layout_links">';
     echo ' <a href="#gp_Insert_Copy" data-cmd="tabs" class="selected">' . $langmessage['Copy'] . '</a>';
     echo ' <a href="#gp_Insert_New" data-cmd="tabs">' . $langmessage['new_file'] . '</a>';
     echo ' <a href="#gp_Insert_Hidden" data-cmd="tabs">' . $langmessage['Available'] . '</a>';
     echo ' <a href="#gp_Insert_External" data-cmd="tabs">' . $langmessage['External Link'] . '</a>';
     echo ' <a href="#gp_Insert_Deleted" data-cmd="tabs">' . $langmessage['trash'] . '</a>';
     echo '</div>';
     // Copy
     echo sprintf($format_top, 'gp_Insert_Copy', '');
     echo '<table class="bordered full_width">';
     echo '<tr><td>';
     echo $langmessage['label'];
     echo '</td><td>';
     echo '<input type="text" name="title" maxlength="100" size="50" value="" class="gpinput full_width" required/>';
     echo '</td></tr>';
     echo '<tr><td>';
     echo $langmessage['Copy'];
     echo '</td><td>';
     $this->ScrollList($gp_index);
     echo '</td></tr>';
     echo '</table>';
     echo sprintf($format_bottom, 'CopyPage', $langmessage['Copy']);
     // Insert New
     echo sprintf($format_top, 'gp_Insert_New', 'nodisplay');
     echo '<table class="bordered full_width">';
     echo '<tr><td>';
     echo $langmessage['label'];
     echo '</td><td>';
     echo '<input type="text" name="title" maxlength="100" value="" size="50" class="gpinput full_width" required />';
     echo '</td></tr>';
     echo '<tr><td>';
     echo $langmessage['Content Type'];
     echo '</td><td>';
     includeFile('tool/editing_page.php');
     echo '<div id="new_section_links">';
     editing_page::NewSections(true);
     echo '</div>';
     echo '</td></tr>';
     echo '</table>';
     echo sprintf($format_bottom, 'new_file', $langmessage['create_new_file']);
     // Insert Hidden
     $avail = $this->GetAvail_Current();
     if ($avail) {
         echo sprintf($format_top, 'gp_Insert_Hidden', 'nodisplay');
         $avail = array_flip($avail);
         $this->ScrollList($avail, 'keys[]', 'checkbox', true);
         echo sprintf($format_bottom, 'insert_from_hidden', $langmessage['insert_into_menu']);
     }
     // Insert Deleted / Restore from trash
     $trashtitles = admin_trash::TrashFiles();
     if ($trashtitles) {
         echo sprintf($format_top, 'gp_Insert_Deleted', 'nodisplay');
         echo '<div class="gpui-scrolllist">';
         echo '<input type="text" name="search" value="" class="gpsearch" placeholder="' . $langmessage['Search'] . '" autocomplete="off" />';
         foreach ($trashtitles as $title => $info) {
             echo '<label>';
             echo '<input type="checkbox" name="titles[]" value="' . htmlspecialchars($title) . '" />';
             echo '<span>';
             echo $info['label'];
             echo '<span class="slug">';
             if (isset($info['title'])) {
                 echo '/' . $info['title'];
             } else {
                 echo '/' . $title;
             }
             echo '</span>';
             echo '</span>';
             echo '</label>';
         }
         echo '</div>';
         echo sprintf($format_bottom, 'restore', $langmessage['restore_from_trash']);
     }
     //Insert External
     echo '<div id="gp_Insert_External" class="nodisplay">';
     $args['insert_how'] = $cmd;
     $args['insert_where'] = $_GET['insert_where'];
     $this->ExternalForm('new_external', $langmessage['insert_into_menu'], $args);
     echo '</div>';
     echo '</div>';
 }