plugins/admin/PageEditor.php
author Dan
Thu, 26 Feb 2009 01:27:56 -0500
changeset 845 a4460ba8ada2
parent 801 eb8b23f11744
child 1013 8626bb38410f
permissions -rw-r--r--
Set password in userinfo to allow auth plugins to see it (some really do need it)
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
801
eb8b23f11744 Two big commits in one day I know, but redid password storage to use HMAC-SHA1. Consolidated much AES processing to three core methods in session that should handle everything automagically. Installation works; upgrades should. Rebranded as 1.1.6.
Dan
parents: 685
diff changeset
     5
 * Version 1.1.6 (Caoineag beta 1)
536
218a627eb53e Rebrand as 1.1.4 (Caoineag alpha 4)
Dan
parents: 504
diff changeset
     6
 * Copyright (C) 2006-2008 Dan Fuhry
346
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     7
 *
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
     8
 * 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
     9
 * 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
    10
 *
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    11
 * 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
    12
 * 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
    13
 */
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    14
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    15
// Page editing portal
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    16
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    17
function page_Admin_PageEditor()
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    18
{
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    19
  global $db, $session, $paths, $template, $plugins; // Common objects
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    20
  global $lang;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    21
  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
    22
  {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    23
    $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
    24
    echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    25
    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
    26
    return;
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
  
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    29
  echo '<h3>' . $lang->get('acped_heading_main') . '</h3>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    30
  $show_select = true;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    31
  
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    32
  if ( isset($_REQUEST['action']) || isset($_REQUEST['source']) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    33
  {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    34
    if ( isset($_REQUEST['action']) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    35
    {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    36
      $act =& $_REQUEST['action'];
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    37
      $act = strtolower($act);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    38
    }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    39
    else if ( isset($_REQUEST['source']) && $_REQUEST['source'] == 'ajax' )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    40
    {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    41
      $act = 'select';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    42
    }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    43
    switch ( $act )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    44
    {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    45
      case 'save':
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    46
      case 'select':
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    47
        // First step is to determine the page ID and namespace
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    48
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    49
        if ( isset($_REQUEST['pid_search']) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    50
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    51
          list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    52
          $name = $db->escape(dirtify_page_id($page_id));
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    53
          $page_id = $db->escape(sanitize_page_id($page_id));
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    54
          $namespace = $db->escape($namespace);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    55
          $name = strtolower($name);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    56
          $page_id = strtolower($page_id);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    57
          $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
    58
        }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    59
        else
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    60
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    61
          // pid_search was not set, assume absolute page ID
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    62
          list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    63
          $page_id = $db->escape(sanitize_page_id($page_id));
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    64
          $namespace = $db->escape($namespace);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    65
          
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    66
          $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
    67
        }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    68
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    69
        if ( !($q = $db->sql_query($sql)) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    70
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    71
          $db->_die('PageManager selecting dataset for page');
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
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    74
        if ( $db->numrows() < 1 )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    75
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    76
          echo '<div class="error-box">
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    77
                  ' . $lang->get('acped_err_page_not_found') . '
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    78
                </div>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    79
          break;
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
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    82
        if ( $db->numrows() > 1 )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    83
        {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    84
          // Ambiguous results
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    85
          if ( isset($_REQUEST['pid_search']) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    86
          {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    87
            echo '<h3>' . $lang->get('acped_msg_results_ambiguous_title') . '</h3>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    88
            echo '<p>' . $lang->get('acped_msg_results_ambiguous_body') . '</p>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    89
            echo '<ul>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    90
            while ( $row = $db->fetchrow($q) )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    91
            {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    92
              echo '<li>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    93
              $pathskey = $paths->nslist[$row['namespace']] . $row['urlname'];
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    94
              $edit_url = makeUrlNS($row['namespace'], $row['urlname']) . '#do:edit';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    95
              $view_url = makeUrlNS($row['namespace'], $row['urlname']);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    96
              $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
    97
              $view_link = $lang->get('acped_ambig_btn_viewpage');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
    98
              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
    99
              echo '</li>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   100
            }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   101
            echo '</ul>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   102
            $show_select = false;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   103
            break;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   104
          }
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   105
          else
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   106
          {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   107
            echo '<p>' . $lang->get('acped_err_ambig_absolute') . '</p>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   108
            break;
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
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   112
        // 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
   113
        $dataset = $db->fetchrow();
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   114
        $page_id = $dataset['urlname'];
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   115
        $namespace = $dataset['namespace'];
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   116
        $url = makeUrlNS($namespace, $page_id, false, true) . '#do:edit';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   117
        $url = addslashes($url);
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   118
        echo '<script type="text/javascript">
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   119
                window.location = \'' . $url . '\';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   120
              </script>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   121
        
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   122
        $show_select = false;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   123
        break;
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
  
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   127
  if ( $show_select )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   128
  {
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   129
    echo '<p>' . $lang->get('acped_hint') . '</p>';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   130
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   131
    // Show the search form
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   132
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   133
    $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
   134
    echo "<form action=\"$form_action\" method=\"post\">";
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   135
    echo $lang->get('acped_lbl_field_search') . ' ';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   136
    echo $template->pagename_field('page_id') . ' ';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   137
    echo '<input type="hidden" name="action" value="select" />';
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   138
    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
   139
    echo "</form>";
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   140
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   141
    // 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
   142
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   143
    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
   144
    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
   145
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   146
    $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
   147
    if ( !$q )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   148
      $db->_die('PageManager doing initial page count');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   149
    list($num_pages) = $db->fetchrow_num();
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   150
    $db->free_result();
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   151
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   152
    $pg_start = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   153
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   154
    $q = $db->sql_unbuffered_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;');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   155
    if ( !$q )
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   156
      $db->_die('PageManager doing main select query for page list');
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   157
    
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   158
    // Paginate results
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   159
    $html = paginate(
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   160
        $q,
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   161
        '{urlname}',
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   162
        $num_pages,
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   163
        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
   164
        $pg_start,
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   165
        99,
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   166
        array('urlname' => 'admin_pagemanager_format_listing'),
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   167
        '<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
   168
        <table border="0" cellspacing="1" cellpadding="4">',
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   169
        '  </table>
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   170
         </div>'
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   171
      );
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   172
    echo $html;
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
cdf24ba5f114 Oops, forgot to add in the rewritten Admin:PageEditor
Dan
parents:
diff changeset
   177
?>