plugins/admin/PageEditor.php
author Dan
Fri, 21 Aug 2009 13:50:20 -0400
changeset 1090 6c84fb196026
parent 1081 745200a9cc2a
child 1227 bdac73ed481e
permissions -rw-r--r--
Autofill: fixed missing parameter to $db->fetchrow()
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
346
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     1
<?php
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     2
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     3
/*
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1081
745200a9cc2a Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents: 1013
diff changeset
     5
 * Copyright (C) 2006-2009 Dan Fuhry
346
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     6
 *
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     7
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     8
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     9
 *
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    11
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    12
 */
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    13
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    14
// Page editing portal
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    15
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    16
function page_Admin_PageEditor()
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    17
{
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    18
  global $db, $session, $paths, $template, $plugins; // Common objects
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    19
  global $lang;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    20
  if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    21
  {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    22
    $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    23
    echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    24
    echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    25
    return;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    26
  }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    27
  
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    28
  echo '<h3>' . $lang->get('acped_heading_main') . '</h3>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    29
  $show_select = true;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    30
  
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    31
  if ( isset($_REQUEST['action']) || isset($_REQUEST['source']) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    32
  {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    33
    if ( isset($_REQUEST['action']) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    34
    {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    35
      $act =& $_REQUEST['action'];
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    36
      $act = strtolower($act);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    37
    }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    38
    else if ( isset($_REQUEST['source']) && $_REQUEST['source'] == 'ajax' )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    39
    {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    40
      $act = 'select';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    41
    }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    42
    switch ( $act )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    43
    {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    44
      case 'save':
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    45
      case 'select':
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    46
        // First step is to determine the page ID and namespace
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    47
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    48
        if ( isset($_REQUEST['pid_search']) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    49
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    50
          list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    51
          $name = $db->escape(dirtify_page_id($page_id));
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    52
          $page_id = $db->escape(sanitize_page_id($page_id));
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    53
          $namespace = $db->escape($namespace);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    54
          $name = strtolower($name);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    55
          $page_id = strtolower($page_id);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    56
          $sql = "SELECT * FROM " . table_prefix . "pages WHERE ( " . ENANO_SQLFUNC_LOWERCASE . "(urlname) LIKE '%$page_id%' OR " . ENANO_SQLFUNC_LOWERCASE . "(name) LIKE '%$name%' ) ORDER BY name ASC;";
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    57
        }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    58
        else
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    59
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    60
          // pid_search was not set, assume absolute page ID
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    61
          list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    62
          $page_id = $db->escape(sanitize_page_id($page_id));
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    63
          $namespace = $db->escape($namespace);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    64
          
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    65
          $sql = "SELECT * FROM " . table_prefix . "pages WHERE urlname = '$page_id' AND namespace = '$namespace';";
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    66
        }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    67
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    68
        if ( !($q = $db->sql_query($sql)) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    69
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    70
          $db->_die('PageManager selecting dataset for page');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    71
        }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    72
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    73
        if ( $db->numrows() < 1 )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    74
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    75
          echo '<div class="error-box">
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    76
                  ' . $lang->get('acped_err_page_not_found') . '
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    77
                </div>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    78
          break;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    79
        }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    80
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    81
        if ( $db->numrows() > 1 )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    82
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    83
          // Ambiguous results
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    84
          if ( isset($_REQUEST['pid_search']) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    85
          {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    86
            echo '<h3>' . $lang->get('acped_msg_results_ambiguous_title') . '</h3>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    87
            echo '<p>' . $lang->get('acped_msg_results_ambiguous_body') . '</p>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    88
            echo '<ul>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    89
            while ( $row = $db->fetchrow($q) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    90
            {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    91
              echo '<li>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    92
              $pathskey = $paths->nslist[$row['namespace']] . $row['urlname'];
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    93
              $edit_url = makeUrlNS($row['namespace'], $row['urlname']) . '#do:edit';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    94
              $view_url = makeUrlNS($row['namespace'], $row['urlname']);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    95
              $page_name = htmlspecialchars(get_page_title_ns( $row['urlname'], $row['namespace'] ));
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    96
              $view_link = $lang->get('acped_ambig_btn_viewpage');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    97
              echo "<a href=\"$edit_url\">$page_name</a> (<a onclick=\"window.open(this.href); return false;\" href=\"$view_url\">$view_link</a>)";
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    98
              echo '</li>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    99
            }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   100
            echo '</ul>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   101
            $show_select = false;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   102
            break;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   103
          }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   104
          else
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   105
          {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   106
            echo '<p>' . $lang->get('acped_err_ambig_absolute') . '</p>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   107
            break;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   108
          }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   109
        }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   110
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   111
        // From this point on we can assume that exactly one matching page was found.
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   112
        $dataset = $db->fetchrow();
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   113
        $page_id = $dataset['urlname'];
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   114
        $namespace = $dataset['namespace'];
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   115
        $url = makeUrlNS($namespace, $page_id, false, true) . '#do:edit';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   116
        $url = addslashes($url);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   117
        echo '<script type="text/javascript">
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   118
                window.location = \'' . $url . '\';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   119
              </script>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   120
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   121
        $show_select = false;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   122
        break;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   123
    }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   124
  }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   125
  
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   126
  if ( $show_select )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   127
  {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   128
    echo '<p>' . $lang->get('acped_hint') . '</p>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   129
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   130
    // Show the search form
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   131
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   132
    $form_action = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageEditor", true);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   133
    echo "<form action=\"$form_action\" method=\"post\">";
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   134
    echo $lang->get('acped_lbl_field_search') . ' ';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   135
    echo $template->pagename_field('page_id') . ' ';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   136
    echo '<input type="hidden" name="action" value="select" />';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   137
    echo '<input type="submit" name="pid_search" value="' . $lang->get('search_btn_search') . '" />';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   138
    echo "</form>";
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   139
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   140
    // Grab all pages from the database and show a list of pages on the site
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   141
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   142
    echo '<h3>' . $lang->get('acped_heading_select_page_from_list') . '</h3>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   143
    echo '<p>' . $lang->get('acped_hint_select_page_from_list') . '</p>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   144
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   145
    $q = $db->sql_query('SELECT COUNT(name) AS num_pages FROM ' . table_prefix . 'pages;');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   146
    if ( !$q )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   147
      $db->_die('PageManager doing initial page count');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   148
    list($num_pages) = $db->fetchrow_num();
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   149
    $db->free_result();
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   150
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   151
    $pg_start = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   152
    
1013
8626bb38410f Set a few queries to buffered due to intermediate queries during fetching
Dan
parents: 801
diff changeset
   153
    $q = $db->sql_query('SELECT urlname, name, namespace, ' . $num_pages . ' AS num_pages, ' . $pg_start . ' AS offset, \'edit\' AS mode FROM ' . table_prefix . 'pages ORDER BY name ASC;');
346
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   154
    if ( !$q )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   155
      $db->_die('PageManager doing main select query for page list');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   156
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   157
    // Paginate results
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   158
    $html = paginate(
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   159
        $q,
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   160
        '{urlname}',
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   161
        $num_pages,
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   162
        makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageEditor&offset=%s", false),
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   163
        $pg_start,
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   164
        99,
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   165
        array('urlname' => 'admin_pagemanager_format_listing'),
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   166
        '<div class="tblholder" style="height: 300px; clip: rect(0px, auto, auto, 0px); overflow: auto;">
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   167
        <table border="0" cellspacing="1" cellpadding="4">',
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   168
        '  </table>
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   169
         </div>'
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   170
      );
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   171
    echo $html;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   172
  }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   173
  
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   174
}
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   175
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   176
?>