plugins/admin/PageGroups.php
changeset 345 4ccdfeee9a11
parent 334 c72b545f1304
child 387 92664d2efab8
equal deleted inserted replaced
344:be6c5fdd9203 345:4ccdfeee9a11
    13  */
    13  */
    14 
    14 
    15 function page_Admin_PageGroups()
    15 function page_Admin_PageGroups()
    16 {
    16 {
    17   global $db, $session, $paths, $template, $plugins; // Common objects
    17   global $db, $session, $paths, $template, $plugins; // Common objects
       
    18   global $lang;
    18   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
    19   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
    19   {
    20   {
    20     echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
    21     $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
       
    22     echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
       
    23     echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
    21     return;
    24     return;
    22   }
    25   }
    23   
    26   
    24   if ( isset($_POST['action']) )
    27   if ( isset($_POST['action']) )
    25   {
    28   {
    28       switch ( isset($_POST['action']['create_stage2']) )
    31       switch ( isset($_POST['action']['create_stage2']) )
    29       {
    32       {
    30         case true:
    33         case true:
    31           if ( empty($_POST['pg_name']) || empty($_POST['group_type']) )
    34           if ( empty($_POST['pg_name']) || empty($_POST['group_type']) )
    32           {
    35           {
    33             echo '<div class="error-box">Please enter a name for the page group.</div>';
    36             echo '<div class="error-box">' . $lang->get('acppg_err_need_name') . '</div>';
    34             return;
    37             return;
    35           }
    38           }
    36           if ( $_POST['group_type'] == PAGE_GRP_TAGGED && empty($_POST['member_tag']) )
    39           if ( $_POST['group_type'] == PAGE_GRP_TAGGED && empty($_POST['member_tag']) )
    37           {
    40           {
    38             echo '<div class="error-box">Please enter a page tag.</div>';
    41             echo '<div class="error-box">' . $lang->get('acppg_err_need_tag') . '</div>';
    39             return;
    42             return;
    40           }
    43           }
    41           if ( $_POST['group_type'] == PAGE_GRP_CATLINK && empty($_POST['member_cat']) )
    44           if ( $_POST['group_type'] == PAGE_GRP_CATLINK && empty($_POST['member_cat']) )
    42           {
    45           {
    43             echo '<div class="error-box">Please create a category page before linking a page group to a category.</div>';
    46             echo '<div class="error-box">' . $lang->get('acppg_err_need_cat') . '</div>';
    44             return;
    47             return;
    45           }
    48           }
    46           if ( $_POST['group_type'] == PAGE_GRP_NORMAL && empty($_POST['member_page_0']) )
    49           if ( $_POST['group_type'] == PAGE_GRP_NORMAL && empty($_POST['member_page_0']) )
    47           {
    50           {
    48             echo '<div class="error-box">Please specify at least one page to place in this group.</div>';
    51             echo '<div class="error-box">' . $lang->get('acppg_err_need_page') . '</div>';
    49             return;
    52             return;
    50           }
    53           }
    51           if ( $_POST['group_type'] == PAGE_GRP_REGEX && empty($_POST['regex']) )
    54           if ( $_POST['group_type'] == PAGE_GRP_REGEX && empty($_POST['regex']) )
    52           {
    55           {
    53             echo '<div class="error-box">Please specify a regular expression to match page IDs against.</div>';
    56             echo '<div class="error-box">' . $lang->get('acppg_err_need_regex') . '</div>';
    54             return;
    57             return;
    55           }
    58           }
    56           if ( $_POST['group_type'] != PAGE_GRP_TAGGED && $_POST['group_type'] != PAGE_GRP_CATLINK && $_POST['group_type'] != PAGE_GRP_NORMAL && $_POST['group_type'] != PAGE_GRP_REGEX )
    59           if ( $_POST['group_type'] != PAGE_GRP_TAGGED && $_POST['group_type'] != PAGE_GRP_CATLINK && $_POST['group_type'] != PAGE_GRP_NORMAL && $_POST['group_type'] != PAGE_GRP_REGEX )
    57           {
    60           {
    58             echo '<div class="error-box">Umm, you sent an invalid group type. I\'d put a real error message here but this will only be shown if you try to hack the system.</div>';
    61             echo '<div class="error-box">Umm, you sent an invalid group type. I\'d put a real error message here but this will only be shown if you try to hack the system.</div>';
   115               $q = $db->sql_query($sql);
   118               $q = $db->sql_query($sql);
   116               if ( !$q )
   119               if ( !$q )
   117                 $db->_die();
   120                 $db->_die();
   118               break;
   121               break;
   119           }
   122           }
   120           echo '<div class="info-box">The page group "' . htmlspecialchars($_POST['pg_name']) . '" has been created.</div>';
   123           echo '<div class="info-box">' . $lang->get('acppg_msg_create_success', array('group_name' => htmlspecialchars($_POST['pg_name']))) . '</div>';
   121           break;
   124           break;
   122       }
   125       }
   123       // A little Javascript magic
   126       // A little Javascript magic
   124       ?>
   127       ?>
   125       <script language="javascript" type="text/javascript">
   128       <script language="javascript" type="text/javascript">
   293       if ( !$q )
   296       if ( !$q )
   294         $db->_die();
   297         $db->_die();
   295       
   298       
   296       if ( $db->numrows() < 1 )
   299       if ( $db->numrows() < 1 )
   297       {
   300       {
   298         $catlist = 'There aren\'t any categories on this site.';
   301         $catlist = $lang->get('acppg_err_no_cats');
   299       }
   302       }
   300       else
   303       else
   301       {
   304       {
   302         $catlist = '<select name="member_cat">';
   305         $catlist = '<select name="member_cat">';
   303         while ( $row = $db->fetchrow() )
   306         while ( $row = $db->fetchrow() )
   314       echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized || !__pg_edit_submitAuthorized) return false;" enctype="multipart/form-data">';
   317       echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized || !__pg_edit_submitAuthorized) return false;" enctype="multipart/form-data">';
   315       
   318       
   316       echo '<div class="tblholder">
   319       echo '<div class="tblholder">
   317             <table border="0" cellspacing="1" cellpadding="4">
   320             <table border="0" cellspacing="1" cellpadding="4">
   318               <tr>
   321               <tr>
   319               <th colspan="2">Create page group</th>
   322               <th colspan="2">' . $lang->get('acppg_th_create') . '</th>
   320               </tr>';
   323               </tr>';
   321       
   324       
   322       // Name
   325       // Name
   323       echo '<tr>
   326       echo '<tr>
   324               <td class="row2">
   327               <td class="row2">
   325               Group name:<br />
   328               ' . $lang->get('acppg_field_group_name') . '<br />
   326               <small>This should be short, descriptive, and human-readable.</small>
   329               <small>' . $lang->get('acppg_field_group_name_hint') . '</small>
   327               </td>
   330               </td>
   328               <td class="row1">
   331               <td class="row1">
   329               <input type="text" name="pg_name" size="30" />
   332               <input type="text" name="pg_name" size="30" />
   330               </td>
   333               </td>
   331             </tr>';
   334             </tr>';
   332             
   335             
   333       // Group type
   336       // Group type
   334       echo '<tr>
   337       echo '<tr>
   335               <td class="row2">
   338               <td class="row2">
   336               Group type:
   339               ' . $lang->get('acppg_field_group_type') . '
   337               </td>
   340               </td>
   338               <td class="row1">
   341               <td class="row1">
   339               <select name="group_type" onchange="pg_create_typeset(this);">
   342               <select name="group_type" onchange="pg_create_typeset(this);">
   340                 <option value="' . PAGE_GRP_NORMAL  . '" selected="selected">Static group of pages</option>
   343                 <option value="' . PAGE_GRP_NORMAL  . '" selected="selected">' . $lang->get('acppg_gtype_static') . '</option>
   341                 <option value="' . PAGE_GRP_TAGGED  . '">Group of pages with one tag</option>
   344                 <option value="' . PAGE_GRP_TAGGED  . '">' . $lang->get('acppg_gtype_tagged') . '</option>
   342                 <option value="' . PAGE_GRP_CATLINK . '">Link to category</option>
   345                 <option value="' . PAGE_GRP_CATLINK . '">' . $lang->get('acppg_gtype_catlink') . '</option>
   343                 <option value="' . PAGE_GRP_REGEX   . '">Perl-compatible regular expression (advanced)</option>
   346                 <option value="' . PAGE_GRP_REGEX   . '">' . $lang->get('acppg_gtype_regex_long') . '</option>
   344               </select>
   347               </select>
   345               </td>
   348               </td>
   346             </tr>';
   349             </tr>';
   347             
   350             
   348       // Titles
   351       // Titles
   349       echo '<tr>
   352       echo '<tr>
   350               <th colspan="2">
   353               <th colspan="2">
   351                 <span id="pg_create_title_normal">
   354                 <span id="pg_create_title_normal">
   352                   Static group of pages
   355                   ' . $lang->get('acppg_gtype_static') . '
   353                 </span>
   356                 </span>
   354                 <span id="pg_create_title_tagged">
   357                 <span id="pg_create_title_tagged">
   355                   Group of commonly tagged pages
   358                   ' . $lang->get('acppg_gtype_tagged') . '
   356                 </span>
   359                 </span>
   357                 <span id="pg_create_title_catlink">
   360                 <span id="pg_create_title_catlink">
   358                   Mirror a category
   361                   ' . $lang->get('acppg_gtype_catlink') . '
   359                 </span>
   362                 </span>
   360                 <span id="pg_create_title_regex">
   363                 <span id="pg_create_title_regex">
   361                   Filter through a regular expression
   364                   ' . $lang->get('acppg_gtype_regex') . '
   362                 </span>
   365                 </span>
   363               </th>
   366               </th>
   364             </tr>';
   367             </tr>';
   365       
   368       
   366       echo '<tr>
   369       echo '<tr>
   367               <td class="row2">
   370               <td class="row2">
   368                 <div id="pg_create_normal_1">
   371                 <div id="pg_create_normal_1">
   369                   Member pages:<br />
   372                   ' . $lang->get('acppg_field_member_pages') . '<br />
   370                   <small>Click the "plus" button to add more fields.</small>
   373                   <small>' . $lang->get('acppg_field_member_pages_hint') . '</small>
   371                 </div>
   374                 </div>
   372                 <div id="pg_create_catlink_1">
   375                 <div id="pg_create_catlink_1">
   373                   Include pages in this category:<br />
   376                   ' . $lang->get('acppg_field_target_category') . '<br />
   374                   <small>Pages in subcategories are <u>not</u> included, however subcategory pages themselves are.</small>
   377                   <small>' . $lang->get('acppg_field_target_category_hint') . '</small>
   375                 </div>
   378                 </div>
   376                 <div id="pg_create_tagged_1">
   379                 <div id="pg_create_tagged_1">
   377                   Include pages with this tag:
   380                   ' . $lang->get('acppg_field_target_tag') . '
   378                 </div>
   381                 </div>
   379                 <div id="pg_create_regex_1">
   382                 <div id="pg_create_regex_1">
   380                   Regular expression:<br />
   383                   ' . $lang->get('acppg_field_target_regex') . '<br />
   381                   <small>Be sure to include the starting and ending delimiters and any flags you might need.<br />
   384                   <small>' . $lang->get('acppg_field_target_regex_hint') . '</small>
   382                          These pages might help: <a href="http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php">Pattern modifiers</a> &bull;
       
   383                          <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Pattern syntax</a><br />
       
   384                          Examples: <tt>/^(Special|Admin):/i</tt> &bull; <tt>/^Image:([0-9]+)$/</tt><br />
       
   385                          Developers, remember that this will be matched against the full page identifier string. This means that <tt>/^About_Enano$/</tt>
       
   386                          will NOT match the page Special:About_Enano.</small>
       
   387               </td>';
   385               </td>';
   388             
   386             
   389       echo '  <td class="row1">
   387       echo '  <td class="row1">
   390                 <div id="pg_create_normal_2" />
   388                 <div id="pg_create_normal_2" />
   391                   <input type="text" style="margin-top: 3px;" name="member_page_0" id="pg_create_member_0" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br />
   389                   <input type="text" style="margin-top: 3px;" name="member_page_0" id="pg_create_member_0" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br />
   407               </td>
   405               </td>
   408             </tr>';
   406             </tr>';
   409             
   407             
   410       // Submit button
   408       // Submit button
   411       echo '<tr>
   409       echo '<tr>
   412               <th class="subhead" colspan="2"><input type="submit" name="action[create_stage2]" value="Create page group" style="font-weight: bold;" /> <input type="submit" name="action[noop]" value="Cancel" style="font-weight: normal;" /></th>
   410               <th class="subhead" colspan="2"><input type="submit" name="action[create_stage2]" value="' . $lang->get('acppg_btn_create_finish') . '" style="font-weight: bold;" /> <input type="submit" name="action[noop]" value="' . $lang->get('etc_cancel') . '" style="font-weight: normal;" /></th>
   413             </tr>';
   411             </tr>';
   414             
   412             
   415       echo '</table>
   413       echo '</table>
   416             </div>';
   414             </div>';
   417       
   415       
   425       $delete_id = array_keys($_POST['action']['del']);
   423       $delete_id = array_keys($_POST['action']['del']);
   426       $delete_id = intval($delete_id[0]);
   424       $delete_id = intval($delete_id[0]);
   427       
   425       
   428       if ( !empty($delete_id) )
   426       if ( !empty($delete_id) )
   429       {
   427       {
   430         echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   428         echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">' . "\n";
   431         echo '<input type="hidden" name="delete_id" value="' . $delete_id . '" />';
   429         echo '<input type="hidden" name="delete_id" value="' . $delete_id . '" />' . "\n";
   432         echo '<div class="tblholder">';
   430         echo '<div class="tblholder">' . "\n";
   433         echo '  <table border="0" cellspacing="1" cellpadding="4">';
   431         echo '  <table border="0" cellspacing="1" cellpadding="4">' . "\n";
   434         echo '    <tr><th>Confirm deletion</th></tr>';
   432         echo '    <tr><th>' . $lang->get('acppg_th_delete_confirm') . '</th></tr>' . "\n";
   435         echo '    <tr><td class="row2" style="text-align: center; padding: 20px 0;">Are you sure you want to delete this page group?</td></tr>';
   433         echo '    <tr><td class="row2" style="text-align: center; padding: 20px 0;">' . $lang->get('acppg_msg_delete_confirm') . '</td></tr>' . "\n";
   436         echo '    <tr><td class="row1" style="text-align: center;">';
   434         echo '    <tr><td class="row1" style="text-align: center;">' . "\n";
   437         echo '        <input type="submit" name="action[del_confirm]" value="Yes, delete group" style="font-weight: bold;" />';
   435         echo '        <input type="submit" name="action[del_confirm]" value="' . $lang->get('acppg_btn_delete_confirm') . '" style="font-weight: bold;" />' . "\n";
   438         echo '        <input type="submit" name="action[noop]" value="Cancel" style="font-weight: normal;" />';
   436         echo '        <input type="submit" name="action[noop]" value="' . $lang->get('etc_cancel') . '" style="font-weight: normal;" />' . "\n";
   439         echo '        </td></tr>';
   437         echo '        </td></tr>' . "\n";
   440         echo '  </table>';
   438         echo '  </table>' . "\n";
   441         echo '</form>';
   439         echo '</form>' . "\n";
   442         
   440         
   443         return;
   441         return;
   444       }
   442       }
   445     }
   443     }
   446     else if ( isset($_POST['action']['del_confirm']) )
   444     else if ( isset($_POST['action']['del_confirm']) )
   469       if ( !$q )
   467       if ( !$q )
   470         $db->_die();
   468         $db->_die();
   471       $q = $db->sql_query('DELETE FROM '.table_prefix.'page_group_members WHERE pg_id=' . $delete_id . ';');
   469       $q = $db->sql_query('DELETE FROM '.table_prefix.'page_group_members WHERE pg_id=' . $delete_id . ';');
   472       if ( !$q )
   470       if ( !$q )
   473         $db->_die();
   471         $db->_die();
   474       echo "<div class='info-box'>The group ".'"'.htmlspecialchars("$pg_name").'"'." has been deleted.</div>";
   472       
       
   473       $del_msg = $lang->get('acppg_msg_delete_success', array('pg_name' => htmlspecialchars($pg_name)));
       
   474       echo "<div class=\"info-box\">$del_msg</div>";
   475     }
   475     }
   476     else if ( isset($_POST['action']['edit']) && !isset($_POST['action']['noop']) )
   476     else if ( isset($_POST['action']['edit']) && !isset($_POST['action']['noop']) )
   477     {
   477     {
   478       if ( isset($_POST['action']['edit_save']) )
   478       if ( isset($_POST['action']['edit_save']) )
   479       {
   479       {
   498         
   498         
   499         // Run some validation - check that page exists and that it's not already in the group
   499         // Run some validation - check that page exists and that it's not already in the group
   500         $page = $_POST['new_page'];
   500         $page = $_POST['new_page'];
   501         if ( empty($page) )
   501         if ( empty($page) )
   502         {
   502         {
   503           $return = array('mode' => 'error', 'text' => 'Please enter a page title.');
   503           $return = array('mode' => 'error', 'text' => $lang->get('acppg_err_ajaxadd_need_title'));
   504           echo enano_json_encode($return);
   504           echo enano_json_encode($return);
   505           return;
   505           return;
   506         }
   506         }
   507         
   507         
   508         /*
   508         /*
   532           echo enano_json_encode($return);
   532           echo enano_json_encode($return);
   533           return;
   533           return;
   534         }
   534         }
   535         if ( $db->numrows() > 0 )
   535         if ( $db->numrows() > 0 )
   536         {
   536         {
   537           $return = array('mode' => 'error', 'text' => 'The page you are trying to add is already in this group.');
   537           $return = array('mode' => 'error', 'text' => $lang->get('acppg_err_ajaxadd_already_in'));
   538           echo enano_json_encode($return);
   538           echo enano_json_encode($return);
   539           return;
   539           return;
   540         }
   540         }
   541         
   541         
   542         $q = $db->sql_query('INSERT INTO '.table_prefix.'page_group_members(pg_id, page_id, namespace) VALUES(' . $edit_id . ', \'' . $db->escape($page_id) . '\', \'' . $namespace . '\');');
   542         $q = $db->sql_query('INSERT INTO '.table_prefix.'page_group_members(pg_id, page_id, namespace) VALUES(' . $edit_id . ', \'' . $db->escape($page_id) . '\', \'' . $namespace . '\');');
   547           return;
   547           return;
   548         }
   548         }
   549         
   549         
   550         $title = "($namespace) " . get_page_title($paths->nslist[$namespace] . $page_id);
   550         $title = "($namespace) " . get_page_title($paths->nslist[$namespace] . $page_id);
   551         
   551         
   552         $return = array('mode' => 'info', 'text' => 'The page has been added to the specified group.', 'successful' => true, 'title' => $title, 'member_id' => $db->insert_id());
   552         $return = array('mode' => 'info', 'text' => $lang->get('acppg_ajaxadd_success'), 'successful' => true, 'title' => $title, 'member_id' => $db->insert_id());
   553         
   553         
   554         echo enano_json_encode($return);
   554         echo enano_json_encode($return);
   555         return;
   555         return;
   556       }
   556       }
   557       
   557       
   563         {
   563         {
   564           // Update group name
   564           // Update group name
   565           $new_name = $_POST['pg_name'];
   565           $new_name = $_POST['pg_name'];
   566           if ( empty($new_name) )
   566           if ( empty($new_name) )
   567           {
   567           {
   568             echo '<div class="error-box">Please enter a valid name for this group.</div>';
   568             echo '<div class="error-box">' . $lang->get('acppg_err_save_need_name') . '</div>';
   569           }
   569           }
   570           else
   570           else
   571           {
   571           {
   572             $q = $db->sql_query('SELECT pg_name FROM '.table_prefix.'page_groups WHERE pg_id=' . $edit_id . ';');
   572             $q = $db->sql_query('SELECT pg_name FROM '.table_prefix.'page_groups WHERE pg_id=' . $edit_id . ';');
   573             if ( !$q )
   573             if ( !$q )
   579               $new_name = $db->escape(trim($new_name));
   579               $new_name = $db->escape(trim($new_name));
   580               $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_name=\'' . $new_name . '\' WHERE pg_id=' . $edit_id . ';');
   580               $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_name=\'' . $new_name . '\' WHERE pg_id=' . $edit_id . ';');
   581               if ( !$q )
   581               if ( !$q )
   582                 $db->_die();
   582                 $db->_die();
   583               else
   583               else
   584                 echo '<div class="info-box">The group name was updated successfully.</div>';
   584                 echo '<div class="info-box">' . $lang->get('acppg_msg_save_name_updated') . '</div>';
   585             }
   585             }
   586             if ( $_POST['pg_type'] == PAGE_GRP_TAGGED )
   586             if ( $_POST['pg_type'] == PAGE_GRP_TAGGED )
   587             {
   587             {
   588               $target = $_POST['pg_target'];
   588               $target = $_POST['pg_target'];
   589               $target = sanitize_tag($target);
   589               $target = sanitize_tag($target);
   590               if ( empty($target) )
   590               if ( empty($target) )
   591               {
   591               {
   592                 echo '<div class="error-box">Please enter a valid tag.</div>';
   592                 echo '<div class="error-box">' . $lang->get('acppg_err_save_need_tag') . '</div>';
   593               }
   593               }
   594               else
   594               else
   595               {
   595               {
   596                 $target = $db->escape($target);
   596                 $target = $db->escape($target);
   597                 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
   597                 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
   598                 if ( !$q )
   598                 if ( !$q )
   599                   $db->_die();
   599                   $db->_die();
   600                 else
   600                 else
   601                   echo '<div class="info-box">The affecting tag was updated.</div>';
   601                   echo '<div class="info-box">' . $lang->get('acppg_msg_save_tag_updated') . '</div>';
   602               }
   602               }
   603             }
   603             }
   604             else if ( $_POST['pg_type'] == PAGE_GRP_REGEX )
   604             else if ( $_POST['pg_type'] == PAGE_GRP_REGEX )
   605             {
   605             {
   606               $target = $_POST['pg_target'];
   606               $target = $_POST['pg_target'];
   607               if ( empty($target) )
   607               if ( empty($target) )
   608               {
   608               {
   609                 echo '<div class="error-box">Please enter an expression to match against..</div>';
   609                 echo '<div class="error-box">' . $lang->get('acppg_err_save_need_regex') . '</div>';
   610               }
   610               }
   611               else
   611               else
   612               {
   612               {
   613                 $target = $db->escape($target);
   613                 $target = $db->escape($target);
   614                 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
   614                 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
   615                 if ( !$q )
   615                 if ( !$q )
   616                   $db->_die();
   616                   $db->_die();
   617                 else
   617                 else
   618                   echo '<div class="info-box">The expression to match against was updated.</div>';
   618                   echo '<div class="info-box">' . $lang->get('acppg_msg_save_regex_updated') . '</div>';
   619               }
   619               }
   620             }
   620             }
   621             else if ( $_POST['pg_type'] == PAGE_GRP_CATLINK )
   621             else if ( $_POST['pg_type'] == PAGE_GRP_CATLINK )
   622             {
   622             {
   623               $target = $_POST['pg_target'];
   623               $target = $_POST['pg_target'];
   624               if ( empty($target) )
   624               if ( empty($target) )
   625               {
   625               {
   626                 echo '<div class="error-box">No category ID specified on POST URI.</div>';
   626                 echo '<div class="error-box">' . $lang->get('acppg_err_save_bad_category') . '</div>';
   627               }
   627               }
   628               else
   628               else
   629               {
   629               {
   630                 $target = $db->escape($target);
   630                 $target = $db->escape($target);
   631                 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
   631                 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
   632                 if ( !$q )
   632                 if ( !$q )
   633                   $db->_die();
   633                   $db->_die();
   634                 else
   634                 else
   635                   echo '<div class="info-box">The affecting category was updated.</div>';
   635                   echo '<div class="info-box">' . $lang->get('acppg_msg_save_cat_updated') . '</div>';
   636               }
   636               }
   637             }
   637             }
   638           }
   638           }
   639         }
   639         }
   640       }
   640       }
   665             $good[] = $id;
   665             $good[] = $id;
   666         }
   666         }
   667         $subquery = ( count($good) > 0 ) ? 'pg_member_id=' . implode(' OR pg_member_id=', $good) : "'foo'='bar'";
   667         $subquery = ( count($good) > 0 ) ? 'pg_member_id=' . implode(' OR pg_member_id=', $good) : "'foo'='bar'";
   668         if ( $subquery == "'foo'='bar'" )
   668         if ( $subquery == "'foo'='bar'" )
   669         {
   669         {
   670           echo '<div class="warning-box">No pages were selected for deletion, and thus none were deleted.</div>';
   670           echo '<div class="warning-box">' . $lang->get('acppg_err_save_no_pages') . '</div>';
   671         }
   671         }
   672         else
   672         else
   673         {
   673         {
   674           $sql = 'DELETE FROM '.table_prefix."page_group_members WHERE ( $subquery ) AND pg_id=$edit_id;";
   674           $sql = 'DELETE FROM '.table_prefix."page_group_members WHERE ( $subquery ) AND pg_id=$edit_id;";
   675           if ( !$db->sql_query($sql) )
   675           if ( !$db->sql_query($sql) )
   676           {
   676           {
   677             $db->_die();
   677             $db->_die();
   678           }
   678           }
   679           echo '<div class="info-box">The requested page group members have been deleted.</div>';
   679           echo '<div class="info-box">' . $lang->get('acppg_msg_save_pages_deleted') . '</div>';
   680         }
   680         }
   681       }
   681       }
   682       
   682       
   683       // Fetch information about page group
   683       // Fetch information about page group
   684       $q = $db->sql_query('SELECT pg_name, pg_type, pg_target FROM '.table_prefix.'page_groups WHERE pg_id=' . $edit_id . ';');
   684       $q = $db->sql_query('SELECT pg_name, pg_type, pg_target FROM '.table_prefix.'page_groups WHERE pg_id=' . $edit_id . ';');
   698       echo '<input type="hidden" name="action[edit]" value="' . $edit_id . '" />';
   698       echo '<input type="hidden" name="action[edit]" value="' . $edit_id . '" />';
   699       echo '<input type="hidden" name="pg_type" value="' . $row['pg_type'] . '" />';
   699       echo '<input type="hidden" name="pg_type" value="' . $row['pg_type'] . '" />';
   700       echo '<div class="tblholder">
   700       echo '<div class="tblholder">
   701               <table border="0" cellspacing="1" cellpadding="4">
   701               <table border="0" cellspacing="1" cellpadding="4">
   702                 <tr>
   702                 <tr>
   703                   <th colspan="3">Editing page group: ' . htmlspecialchars($row['pg_name']) . '</th>
   703                   <th colspan="3">' . $lang->get('acppg_th_editing_group') . ' ' . htmlspecialchars($row['pg_name']) . '</th>
   704                 </tr>';
   704                 </tr>';
   705       // Group name
   705       // Group name
   706       
   706       
   707       echo '    <tr>
   707       echo '    <tr>
   708                   <td class="row2">Group name:</td>
   708                   <td class="row2">' . $lang->get('acppg_field_group_name') . '</td>
   709                   <td class="row1" colspan="2"><input type="text" name="pg_name" value="' . htmlspecialchars($row['pg_name']) . '" size="30" /></td>
   709                   <td class="row1" colspan="2"><input type="text" name="pg_name" value="' . htmlspecialchars($row['pg_name']) . '" size="30" /></td>
   710                 </tr>';
   710                 </tr>';
   711       
   711       
   712       $ajax_page_add = false;
   712       $ajax_page_add = false;
   713                 
   713                 
   723         case PAGE_GRP_NORMAL:
   723         case PAGE_GRP_NORMAL:
   724           
   724           
   725           // You have guessed correct.
   725           // You have guessed correct.
   726           // *Sits in chair for 10 minutes listening to the radio in an effort to put off writing the code you see below*
   726           // *Sits in chair for 10 minutes listening to the radio in an effort to put off writing the code you see below*
   727           
   727           
   728           echo '<tr><th colspan="3" class="subhead"><input type="submit" name="action[edit_save]" value="Save group name" /></th></tr>';
   728           echo '<tr><th colspan="3" class="subhead"><input type="submit" name="action[edit_save]" value="' . $lang->get('acppg_btn_save_name') . '" /></th></tr>';
   729           echo '</table></div>';
   729           echo '</table></div>';
   730           echo '</form>';
   730           echo '</form>';
   731           echo '<form name="pg_static_rm_frm" action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" enctype="multipart/form-data">';
   731           echo '<form name="pg_static_rm_frm" action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" enctype="multipart/form-data">';
   732           echo '<input type="hidden" name="action[edit]" value="' . $edit_id . '" />';
   732           echo '<input type="hidden" name="action[edit]" value="' . $edit_id . '" />';
   733           echo '<div class="tblholder">
   733           echo '<div class="tblholder">
   734                   <table border="0" cellspacing="1" cellpadding="4">
   734                   <table border="0" cellspacing="1" cellpadding="4">
   735                     <tr>
   735                     <tr>
   736                       <th colspan="3">Remove pages from this group</th>
   736                       <th colspan="3">' . $lang->get('acppg_th_remove_selected') . '</th>
   737                     </tr>';
   737                     </tr>';
   738           
   738           
   739           $q = $db->sql_query('SELECT m.pg_member_id,m.page_id,m.namespace FROM '.table_prefix.'page_group_members AS m
   739           $q = $db->sql_query('SELECT m.pg_member_id,m.page_id,m.namespace FROM '.table_prefix.'page_group_members AS m
   740                                  LEFT JOIN '.table_prefix.'pages AS p
   740                                  LEFT JOIN '.table_prefix.'pages AS p
   741                                    ON ( p.urlname = m.page_id AND p.namespace = m.namespace )
   741                                    ON ( p.urlname = m.page_id AND p.namespace = m.namespace )
   742                                  WHERE m.pg_id=' . $edit_id . ';');
   742                                  WHERE m.pg_id=' . $edit_id . ';');
   743           
   743           
   744           if ( !$q )
   744           if ( !$q )
   745             $db->_die();
   745             $db->_die();
   746           
   746           
   747           $delim = ceil( $db->numrows() / 2 );
   747           $delim = ceil( $db->numrows($q) / 2 );
   748           if ( $delim < 5 )
   748           if ( $delim < 5 )
   749           {
   749           {
   750             $delim = 0xFFFFFFFE;
   750             $delim = 0xFFFFFFFE;
   751             // stupid hack
   751             // stupid hack. I'm XSSing my own code.
   752             $colspan = '2" id="pg_edit_tackon2me';
   752             $colspan = '2" id="pg_edit_tackon2me';
   753           }
   753           }
   754           else
   754           else
   755           {
   755           {
   756             $colspan = "1";
   756             $colspan = "1";
   757           }
   757           }
   758           
   758           
   759           echo '<tr><td class="row2" rowspan="2"><b>Remove</b> pages:</td><td class="row1" colspan="' . $colspan . '">';
   759           echo '<tr><td class="row2" rowspan="2">' . $lang->get('acppg_field_remove') . '</td><td class="row1" colspan="' . $colspan . '">';
   760           $i = 0;
   760           $i = 0;
   761           
   761           
   762           while ( $row = $db->fetchrow() )
   762           while ( $row = $db->fetchrow($q) )
   763           {
   763           {
   764             $i++;
   764             $i++;
   765             if ( $i == $delim )
   765             if ( $i == $delim )
   766             {
   766             {
   767               echo '</td><td class="row1" id="pg_edit_tackon2me">';
   767               echo '</td><td class="row1" id="pg_edit_tackon2me">';
   769             $page_name = '(' . $row['namespace'] . ') ' . get_page_title($paths->nslist[$row['namespace']] . $row['page_id']);
   769             $page_name = '(' . $row['namespace'] . ') ' . get_page_title($paths->nslist[$row['namespace']] . $row['page_id']);
   770             echo '<label><input type="checkbox" name="action[edit_save][rm][' . $row['pg_member_id'] . ']" /> ' . htmlspecialchars($page_name) . '</label><br />';
   770             echo '<label><input type="checkbox" name="action[edit_save][rm][' . $row['pg_member_id'] . ']" /> ' . htmlspecialchars($page_name) . '</label><br />';
   771           }
   771           }
   772           
   772           
   773           echo '</td></tr>';
   773           echo '</td></tr>';
   774           echo '<tr><th colspan="2" class="subhead" style="width: 70%;"><input type="submit" name="action[edit_save][do_rm]" value="Remove selected" /></th></tr>';
   774           echo '<tr><th colspan="2" class="subhead" style="width: 70%;"><input type="submit" name="action[edit_save][do_rm]" value="' . $lang->get('acppg_btn_do_remove') . '" /></th></tr>';
   775           
   775           
   776           // More javascript magic!
   776           // More javascript magic!
   777           ?>
   777           ?>
   778           <script type="text/javascript">
   778           <script type="text/javascript">
   779             var __pg_edit_submitAuthorized = true;
   779             var __pg_edit_submitAuthorized = true;
   780             var __ol_pg_edit_setup = function()
   780             var __ol_pg_edit_setup = function()
   781             {
   781             {
   782               var input = document.getElementById('inptext_pg_add_member');
   782               var input = document.getElementById('inptext_pg_add_member');
   783               input.onkeyup = function(e) { ajaxPageNameComplete(this); };
   783               input.onkeyup = function(e) { ajaxPageNameComplete(this); };
   784               input.onkeypress = function(e) { if ( e.keyCode == 13 ) { setTimeout('__pg_edit_ajaxadd(document.getElementById(\'' + this.id + '\'));', 500); } };
   784               <?php
       
   785               // stupid jEdit hack
       
   786               echo "input.onkeypress = function(e) { if ( e.keyCode == 13 ) { setTimeout('__pg_edit_ajaxadd(document.getElementById(\'' + this.id + '\'));', 500); } };";
       
   787               ?>
   785             }
   788             }
   786             addOnloadHook(__ol_pg_edit_setup);
   789             addOnloadHook(__ol_pg_edit_setup);
   787             var __pg_edit_objcache = false;
   790             var __pg_edit_objcache = false;
   788             function __pg_edit_ajaxadd(obj)
   791             function __pg_edit_ajaxadd(obj)
   789             {
   792             {
   867           
   870           
   868           break;
   871           break;
   869         case PAGE_GRP_TAGGED:
   872         case PAGE_GRP_TAGGED:
   870           echo '<tr>
   873           echo '<tr>
   871                   <td class="row2">
   874                   <td class="row2">
   872                     Include pages with this tag:
   875                     ' . $lang->get('acppg_field_target_tag') . '
   873                   </td>
   876                   </td>
   874                   <td class="row1">
   877                   <td class="row1">
   875                     <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" />
   878                     <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" />
   876                   </td>
   879                   </td>
   877                 </tr>';
   880                 </tr>';
   878           break;
   881           break;
   879         case PAGE_GRP_REGEX:
   882         case PAGE_GRP_REGEX:
   880           echo '<tr>
   883           echo '<tr>
   881                   <td class="row2">
   884                   <td class="row2">
   882                     Regular expression to use:<br />
   885                     ' . $lang->get('acppg_field_target_regex') . '<br />
   883                     <small>Be sure to include the starting and ending delimiters and any flags you might need.<br />
   886                     <small>' . $lang->get('acppg_field_target_regex_hint') . '</small>
   884                            These pages might help: <a href="http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php">Pattern modifiers</a> &bull;
       
   885                            <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Pattern syntax</a><br />
       
   886                            Examples: <tt>/^(Special|Admin):/i</tt> &bull; <tt>/^Image:([0-9]+)$/</tt><br />
       
   887                            Developers, remember that this will be matched against the full page identifier string. This means that <tt>/^About_Enano$/</tt>
       
   888                            will NOT match the page Special:About_Enano.</small>
       
   889                   </td>
   887                   </td>
   890                   <td class="row1">
   888                   <td class="row1">
   891                     <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" />
   889                     <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" />
   892                   </td>
   890                   </td>
   893                 </tr>';
   891                 </tr>';
   914             $catlist .= '</select>';
   912             $catlist .= '</select>';
   915           }
   913           }
   916           
   914           
   917           echo '<tr>
   915           echo '<tr>
   918                   <td class="row2">
   916                   <td class="row2">
   919                     Include pages that are in this category:<br />
   917                     ' . $lang->get('acppg_field_target_category') . '<br />
   920                     <small><b>Reminder:</b> Enano does not automatically place any access controls on the category. If you
   918                     <small>' . $lang->get('acppg_field_target_category_hint2') . '</small>
   921                            don\'t want users to be able to freely add and remove pages from the category (assuming Wiki Mode is enabled
       
   922                            for the category) then you need to enable protection on the category using the button on the more options menu.
       
   923                            </small>
       
   924                   </td>
   919                   </td>
   925                   <td class="row1">
   920                   <td class="row1">
   926                     ' . $catlist . '
   921                     ' . $catlist . '
   927                   </td>
   922                   </td>
   928                 </tr>';
   923                 </tr>';
   930           break;
   925           break;
   931       }
   926       }
   932       
   927       
   933       if ( $ajax_page_add )
   928       if ( $ajax_page_add )
   934       {
   929       {
   935         echo '<tr><th colspan="3"><input type="submit" name="action[noop]" value="Cancel all changes" /></th></tr>';
   930         echo '<tr><th colspan="3"><input type="submit" name="action[noop]" value="' . $lang->get('acppg_btn_cancel_all') . '" /></th></tr>';
   936       }
   931       }
   937       else
   932       else
   938       {
   933       {
   939         echo '<tr><th colspan="3" class="subhead">
   934         echo '<tr><th colspan="3" class="subhead">
   940                 <input type="submit" name="action[edit_save]" value="Save and update" />
   935                 <input type="submit" name="action[edit_save]" value="' . $lang->get('acppg_btn_save_update') . '" />
   941                 <input type="submit" name="action[noop]" value="Cancel all changes" />
   936                 <input type="submit" name="action[noop]" value="' . $lang->get('acppg_btn_cancel_all') . '" />
   942               </th></tr>';
   937               </th></tr>';
   943       }
   938       }
   944       
   939       
   945       echo '  </table>
   940       echo '  </table>
   946             </div>';
   941             </div>';
   948       
   943       
   949       if ( $ajax_page_add )
   944       if ( $ajax_page_add )
   950       {
   945       {
   951         // This needs to be outside of the form.
   946         // This needs to be outside of the form.
   952         echo '<div class="tblholder"><table border="0" cellspacing="1" cellpadding="4"><tr>';
   947         echo '<div class="tblholder"><table border="0" cellspacing="1" cellpadding="4"><tr>';
   953         echo '<th colspan="2">On-the-fly tools</th></tr>';
   948         echo '<th colspan="2">' . $lang->get('acppg_th_onthefly') . '</th></tr>';
   954         echo '<tr>';
   949         echo '<tr>';
   955         // Add pages AJAX form
   950         // Add pages AJAX form
   956         echo '<td class="row2">Add page:<br /><small>You can add multiple pages by entering part of a page title, and it will be auto-completed. Press Enter to quickly add the page. This only works if you a really up-to-date browser.</small></td>';
   951         echo '<td class="row2">' . $lang->get('acppg_field_add_page') . '<br /><small>' . $lang->get('acppg_field_add_page_hint') . '</small></td>';
   957         echo '<td class="row1"><input type="text" size="30" name="pg_add_member" id="inptext_pg_add_member" /></td>';
   952         echo '<td class="row1"><input type="text" size="30" name="pg_add_member" id="inptext_pg_add_member" /></td>';
   958         echo '</tr></table></div>';
   953         echo '</tr></table></div>';
   959       }
   954       }
   960       
   955       
   961       return;
   956       return;
   969       echo '<div class="error-box">Invalid format of $_POST[action].</div>';
   964       echo '<div class="error-box">Invalid format of $_POST[action].</div>';
   970     }
   965     }
   971   }
   966   }
   972   // No action defined - show default menu
   967   // No action defined - show default menu
   973   
   968   
   974   echo '<h2>Manage page groups</h2>';
   969   echo '<h2>' . $lang->get('acppg_heading_main') . '</h2>';
   975   echo '<p>Enano\'s page grouping system allows you to build sets of pages that can be controlled by a single ACL rule. This makes managing features such as a members-only section of your site a lot easier. If you don\'t use the ACL system, you probably don\'t need to use page groups.</p>';
   970   echo '<p>' . $lang->get('acppg_hint_intro') . '</p>';
   976   
   971   
   977   $q = $db->sql_query('SELECT pg_id, pg_type, pg_name, pg_target FROM '.table_prefix.'page_groups;');
   972   $q = $db->sql_query('SELECT pg_id, pg_type, pg_name, pg_target FROM '.table_prefix.'page_groups;');
   978   if ( !$q )
   973   if ( !$q )
   979     $db->_die();
   974     $db->_die();
   980 
   975 
   981   echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   976   echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   982   
   977   
   983   echo '<div class="tblholder">
   978   echo '<div class="tblholder">
   984           <table border="0" cellspacing="1" cellpadding="4">
   979           <table border="0" cellspacing="1" cellpadding="4">
   985             <tr>
   980             <tr>
   986               <th>Group name</th>
   981               <th>' . $lang->get('acppg_col_group_name') . '</th>
   987               <th>Type</th>
   982               <th>' . $lang->get('acppg_col_type') . '</th>
   988               <th>Target</th>
   983               <th>' . $lang->get('acppg_col_target') . '</th>
   989               <th colspan="2">Actions</th>
   984               <th colspan="2">' . $lang->get('acppg_col_actions') . '</th>
   990             </tr>';
   985             </tr>';
   991   
   986   
   992   if ( $row = $db->fetchrow() )
   987   if ( $row = $db->fetchrow($q) )
   993   {
   988   {
   994     do
   989     do
   995     {
   990     {
   996       $name = htmlspecialchars($row['pg_name']);
   991       $name = htmlspecialchars($row['pg_name']);
   997       $type = 'Invalid';
   992       $type = 'Invalid';
   998       switch ( $row['pg_type'] )
   993       switch ( $row['pg_type'] )
   999       {
   994       {
  1000         case PAGE_GRP_CATLINK:
   995         case PAGE_GRP_CATLINK:
  1001           $type = 'Link to category';
   996           $type = $lang->get('acppg_gtype_catlink');
  1002           break;
   997           break;
  1003         case PAGE_GRP_TAGGED:
   998         case PAGE_GRP_TAGGED:
  1004           $type = 'Set of tagged pages';
   999           $type = $lang->get('acppg_gtype_tagged');
  1005           break;
  1000           break;
  1006         case PAGE_GRP_NORMAL:
  1001         case PAGE_GRP_NORMAL:
  1007           $type = 'Static set of pages';
  1002           $type = $lang->get('acppg_gtype_static');
  1008           break;
  1003           break;
  1009         case PAGE_GRP_REGEX:
  1004         case PAGE_GRP_REGEX:
  1010           $type = 'Regular expression match';
  1005           $type = $lang->get('acppg_gtype_regex');
  1011           break;
  1006           break;
  1012       }
  1007       }
  1013       $target = '';
  1008       $target = '';
  1014       if ( $row['pg_type'] == PAGE_GRP_TAGGED )
  1009       if ( $row['pg_type'] == PAGE_GRP_TAGGED )
  1015       {
  1010       {
  1016         $target = 'Tag: ' . htmlspecialchars($row['pg_target']);
  1011         $target = $lang->get('acppg_lbl_tag') . ' ' . htmlspecialchars($row['pg_target']);
  1017       }
  1012       }
  1018       else if ( $row['pg_type'] == PAGE_GRP_CATLINK )
  1013       else if ( $row['pg_type'] == PAGE_GRP_CATLINK )
  1019       {
  1014       {
  1020         $target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target'])));
  1015         $target = $lang->get('acppg_lbl_category') . ' ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target'])));
  1021       }
  1016       }
  1022       else if ( $row['pg_type'] == PAGE_GRP_REGEX )
  1017       else if ( $row['pg_type'] == PAGE_GRP_REGEX )
  1023       {
  1018       {
  1024         $target = 'Expression: <tt>' . htmlspecialchars($row['pg_target']) . '</tt>';
  1019         $target = $lang->get('acppg_lbl_regex') . ' <tt>' . htmlspecialchars($row['pg_target']) . '</tt>';
  1025       }
  1020       }
  1026       $btn_edit = '<input type="submit" name="action[edit][' . $row['pg_id'] . ']" value="Edit" />';
  1021       $btn_edit = '<input type="submit" name="action[edit][' . $row['pg_id'] . ']" value="' . $lang->get('acppg_btn_edit') . '" />';
  1027       $btn_del = '<input type="submit" name="action[del][' . $row['pg_id'] . ']" value="Delete" />';
  1022       $btn_del = '<input type="submit" name="action[del][' . $row['pg_id'] . ']" value="' . $lang->get('acppg_btn_delete') . '" />';
  1028       // stupid jEdit bug/hack
       
  1029       $quot = '"';
       
  1030       echo "<tr>
  1023       echo "<tr>
  1031               <td class={$quot}row1{$quot}>$name</td>
  1024               <td class=\"row1\">$name</td>
  1032               <td class={$quot}row2{$quot}>$type</td>
  1025               <td class=\"row2\">$type</td>
  1033               <td class={$quot}row1{$quot}>$target</td>
  1026               <td class=\"row1\">$target</td>
  1034               <td class={$quot}row3{$quot} style={$quot}text-align: center;{$quot}>$btn_edit</td>
  1027               <td class=\"row3\" style=\"text-align: center;\">$btn_edit</td>
  1035               <td class={$quot}row3{$quot} style={$quot}text-align: center;{$quot}>$btn_del</td>
  1028               <td class=\"row3\" style=\"text-align: center;\">$btn_del</td>
  1036             </tr>";
  1029             </tr>";
  1037     }
  1030     }
  1038     while ( $row = $db->fetchrow() );
  1031     while ( $row = $db->fetchrow($q) );
  1039   }
  1032   }
  1040   else
  1033   else
  1041   {
  1034   {
  1042     echo '  <tr><td class="row3" colspan="5" style="text-align: center;">No page groups defined.</td></tr>';
  1035     echo '  <tr><td class="row3" colspan="5" style="text-align: center;">' . $lang->get('acppg_msg_no_groups') . '</td></tr>';
  1043   }
  1036   }
  1044   
  1037   
  1045   echo '    <tr>
  1038   echo '    <tr>
  1046               <th class="subhead" colspan="5">
  1039               <th class="subhead" colspan="5">
  1047                 <input type="submit" name="action[create]" value="Create new group" />
  1040                 <input type="submit" name="action[create]" value="' . $lang->get('acppg_btn_create_new') . '" />
  1048               </th>
  1041               </th>
  1049             </tr>';
  1042             </tr>';
  1050   
  1043   
  1051   echo '  </table>
  1044   echo '  </table>
  1052         </div>';
  1045         </div>';