plugins/admin/PageManager.php
changeset 1227 bdac73ed481e
parent 1124 1e956881d362
child 1325 1e20add419c8
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
    13 
    13 
    14 // Page management smart form
    14 // Page management smart form
    15 
    15 
    16 function page_Admin_PageManager()
    16 function page_Admin_PageManager()
    17 {
    17 {
    18   global $db, $session, $paths, $template, $plugins; // Common objects
    18 	global $db, $session, $paths, $template, $plugins; // Common objects
    19   global $lang;
    19 	global $lang;
    20   global $cache;
    20 	global $cache;
    21   
    21 	
    22   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
    22 	if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
    23   {
    23 	{
    24     $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
    24 		$login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
    25     echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
    25 		echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
    26     echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
    26 		echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
    27     return;
    27 		return;
    28   }
    28 	}
    29   
    29 	
    30   require_once(ENANO_ROOT . '/includes/pageutils.php');
    30 	require_once(ENANO_ROOT . '/includes/pageutils.php');
    31   
    31 	
    32   echo '<h3>' . $lang->get('acppm_heading_main') . '</h3>';
    32 	echo '<h3>' . $lang->get('acppm_heading_main') . '</h3>';
    33   $show_select = true;
    33 	$show_select = true;
    34   
    34 	
    35   if ( isset($_REQUEST['action']) || isset($_REQUEST['source']) )
    35 	if ( isset($_REQUEST['action']) || isset($_REQUEST['source']) )
    36   {
    36 	{
    37     if ( isset($_REQUEST['action']) )
    37 		if ( isset($_REQUEST['action']) )
    38     {
    38 		{
    39       $act =& $_REQUEST['action'];
    39 			$act =& $_REQUEST['action'];
    40       $act = strtolower($act);
    40 			$act = strtolower($act);
    41     }
    41 		}
    42     else if ( isset($_REQUEST['source']) && $_REQUEST['source'] == 'ajax' )
    42 		else if ( isset($_REQUEST['source']) && $_REQUEST['source'] == 'ajax' )
    43     {
    43 		{
    44       $act = 'select';
    44 			$act = 'select';
    45     }
    45 		}
    46     switch ( $act )
    46 		switch ( $act )
    47     {
    47 		{
    48       case 'save':
    48 			case 'save':
    49       case 'select':
    49 			case 'select':
    50         // First step is to determine the page ID and namespace
    50 				// First step is to determine the page ID and namespace
    51         
    51 				
    52         if ( isset($_REQUEST['pid_search']) )
    52 				if ( isset($_REQUEST['pid_search']) )
    53         {
    53 				{
    54           list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
    54 					list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
    55           $name = $db->escape(dirtify_page_id($page_id));
    55 					$name = $db->escape(dirtify_page_id($page_id));
    56           $page_id = $db->escape(sanitize_page_id($page_id));
    56 					$page_id = $db->escape(sanitize_page_id($page_id));
    57           $namespace = $db->escape($namespace);
    57 					$namespace = $db->escape($namespace);
    58           $name = strtolower($name);
    58 					$name = strtolower($name);
    59           $page_id = strtolower($page_id);
    59 					$page_id = strtolower($page_id);
    60           $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;";
    60 					$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;";
    61         }
    61 				}
    62         else
    62 				else
    63         {
    63 				{
    64           // pid_search was not set, assume absolute page ID
    64 					// pid_search was not set, assume absolute page ID
    65           list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
    65 					list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
    66           $page_id = $db->escape(sanitize_page_id($page_id));
    66 					$page_id = $db->escape(sanitize_page_id($page_id));
    67           $namespace = $db->escape($namespace);
    67 					$namespace = $db->escape($namespace);
    68           
    68 					
    69           $sql = "SELECT * FROM " . table_prefix . "pages WHERE urlname = '$page_id' AND namespace = '$namespace';";
    69 					$sql = "SELECT * FROM " . table_prefix . "pages WHERE urlname = '$page_id' AND namespace = '$namespace';";
    70         }
    70 				}
    71         
    71 				
    72         if ( !($q = $db->sql_query($sql)) )
    72 				if ( !($q = $db->sql_query($sql)) )
    73         {
    73 				{
    74           $db->_die('PageManager selecting dataset for page');
    74 					$db->_die('PageManager selecting dataset for page');
    75         }
    75 				}
    76         
    76 				
    77         if ( $db->numrows() < 1 )
    77 				if ( $db->numrows() < 1 )
    78         {
    78 				{
    79           echo '<div class="error-box">
    79 					echo '<div class="error-box">
    80                   ' . $lang->get('acppm_err_page_not_found') . '
    80 									' . $lang->get('acppm_err_page_not_found') . '
    81                 </div>';
    81 								</div>';
    82           break;
    82 					break;
    83         }
    83 				}
    84         
    84 				
    85         if ( $db->numrows() > 1 )
    85 				if ( $db->numrows() > 1 )
    86         {
    86 				{
    87           // Ambiguous results
    87 					// Ambiguous results
    88           if ( isset($_REQUEST['pid_search']) )
    88 					if ( isset($_REQUEST['pid_search']) )
    89           {
    89 					{
    90             echo '<h3>' . $lang->get('acppm_msg_results_ambiguous_title') . '</h3>';
    90 						echo '<h3>' . $lang->get('acppm_msg_results_ambiguous_title') . '</h3>';
    91             echo '<p>' . $lang->get('acppm_msg_results_ambiguous_body') . '</p>';
    91 						echo '<p>' . $lang->get('acppm_msg_results_ambiguous_body') . '</p>';
    92             echo '<ul>';
    92 						echo '<ul>';
    93             while ( $row = $db->fetchrow($q) )
    93 						while ( $row = $db->fetchrow($q) )
    94             {
    94 						{
    95               echo '<li>';
    95 							echo '<li>';
    96               $pathskey = $paths->nslist[$row['namespace']] . $row['urlname'];
    96 							$pathskey = $paths->nslist[$row['namespace']] . $row['urlname'];
    97               $edit_url = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager&action=select&page_id=$pathskey", true);
    97 							$edit_url = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager&action=select&page_id=$pathskey", true);
    98               $view_url = makeUrlNS($row['namespace'], $row['urlname']);
    98 							$view_url = makeUrlNS($row['namespace'], $row['urlname']);
    99               $page_name = htmlspecialchars(get_page_title_ns( $row['urlname'], $row['namespace'] ));
    99 							$page_name = htmlspecialchars(get_page_title_ns( $row['urlname'], $row['namespace'] ));
   100               $view_link = $lang->get('acppm_ambig_btn_viewpage');
   100 							$view_link = $lang->get('acppm_ambig_btn_viewpage');
   101               echo "<a href=\"$edit_url\">$page_name</a> (<a onclick=\"window.open(this.href); return false;\" href=\"$view_url\">$view_link</a>)";
   101 							echo "<a href=\"$edit_url\">$page_name</a> (<a onclick=\"window.open(this.href); return false;\" href=\"$view_url\">$view_link</a>)";
   102               echo '</li>';
   102 							echo '</li>';
   103             }
   103 						}
   104             echo '</ul>';
   104 						echo '</ul>';
   105             $show_select = false;
   105 						$show_select = false;
   106             break;
   106 						break;
   107           }
   107 					}
   108           else
   108 					else
   109           {
   109 					{
   110             echo '<p>' . $lang->get('acppm_err_ambig_absolute') . '</p>';
   110 						echo '<p>' . $lang->get('acppm_err_ambig_absolute') . '</p>';
   111             break;
   111 						break;
   112           }
   112 					}
   113         }
   113 				}
   114         
   114 				
   115         // From this point on we can assume that exactly one matching page was found.
   115 				// From this point on we can assume that exactly one matching page was found.
   116         $dataset = $db->fetchrow();
   116 				$dataset = $db->fetchrow();
   117         $page_id = $dataset['urlname'];
   117 				$page_id = $dataset['urlname'];
   118         $namespace = $dataset['namespace'];
   118 				$namespace = $dataset['namespace'];
   119         
   119 				
   120         // This is used to re-determine the page ID after submit.
   120 				// This is used to re-determine the page ID after submit.
   121         $pathskey = $paths->nslist[$namespace] . sanitize_page_id($page_id);
   121 				$pathskey = $paths->nslist[$namespace] . sanitize_page_id($page_id);
   122         
   122 				
   123         // The extra switch allows us to break out of the save routine if needed
   123 				// The extra switch allows us to break out of the save routine if needed
   124         switch ( $act )
   124 				switch ( $act )
   125         {
   125 				{
   126           case 'save':
   126 					case 'save':
   127             
   127 						
   128             $errors = array();
   128 						$errors = array();
   129             $page_id_changed = false;
   129 						$page_id_changed = false;
   130             $namespace_changed = false;
   130 						$namespace_changed = false;
   131             
   131 						
   132             // Backup the dataset to avoid redundantly updating values
   132 						// Backup the dataset to avoid redundantly updating values
   133             $dataset_backup = $dataset;
   133 						$dataset_backup = $dataset;
   134             
   134 						
   135             // We've elected to save the page. The angle of attack here is to validate each form field,
   135 						// We've elected to save the page. The angle of attack here is to validate each form field,
   136             // and if the field validates successfully, change the value in $dataset accordingly.
   136 						// and if the field validates successfully, change the value in $dataset accordingly.
   137             
   137 						
   138             // Field: page name
   138 						// Field: page name
   139             $page_name = $_POST['page_name'];
   139 						$page_name = $_POST['page_name'];
   140             $page_name = trim($page_name);
   140 						$page_name = trim($page_name);
   141             if ( empty($page_name) )
   141 						if ( empty($page_name) )
   142             {
   142 						{
   143               $errors[] = $lang->get('acppm_err_invalid_page_name');
   143 							$errors[] = $lang->get('acppm_err_invalid_page_name');
   144             }
   144 						}
   145             else
   145 						else
   146             {
   146 						{
   147               $dataset['name'] = $page_name;
   147 							$dataset['name'] = $page_name;
   148             }
   148 						}
   149             
   149 						
   150             // Field: page URL string
   150 						// Field: page URL string
   151             $page_urlname = $_POST['page_urlname'];
   151 						$page_urlname = $_POST['page_urlname'];
   152             $page_urlname = trim($_POST['page_urlname']);
   152 						$page_urlname = trim($_POST['page_urlname']);
   153             if ( empty($page_urlname) && !have_blank_urlname_page() )
   153 						if ( empty($page_urlname) && !have_blank_urlname_page() )
   154             {
   154 						{
   155               $errors[] = $lang->get('acppm_err_invalid_url_string');
   155 							$errors[] = $lang->get('acppm_err_invalid_url_string');
   156             }
   156 						}
   157             else
   157 						else
   158             {
   158 						{
   159               $page_id_changed = ( $_POST['page_urlname'] !== $dataset['urlname'] );
   159 							$page_id_changed = ( $_POST['page_urlname'] !== $dataset['urlname'] );
   160               $dataset['urlname'] = sanitize_page_id($page_urlname);
   160 							$dataset['urlname'] = sanitize_page_id($page_urlname);
   161             }
   161 						}
   162             
   162 						
   163             // Field: namespace
   163 						// Field: namespace
   164             $namespace_new = $_POST['page_namespace'];
   164 						$namespace_new = $_POST['page_namespace'];
   165             if ( !isset($paths->nslist[ $namespace ]) )
   165 						if ( !isset($paths->nslist[ $namespace ]) )
   166             {
   166 						{
   167               $errors[] = $lang->get('acppm_err_invalid_namespace');
   167 							$errors[] = $lang->get('acppm_err_invalid_namespace');
   168             }
   168 						}
   169             else
   169 						else
   170             {
   170 						{
   171               $namespace_changed = ( $_POST['page_namespace'] !== $dataset['namespace'] );
   171 							$namespace_changed = ( $_POST['page_namespace'] !== $dataset['namespace'] );
   172               $dataset['namespace'] = $namespace_new;
   172 							$dataset['namespace'] = $namespace_new;
   173             }
   173 						}
   174             
   174 						
   175             // Field: comments enabled
   175 						// Field: comments enabled
   176             $dataset['comments_on'] = ( isset($_POST['comments_on']) ) ? 1 : 0;
   176 						$dataset['comments_on'] = ( isset($_POST['comments_on']) ) ? 1 : 0;
   177             
   177 						
   178             // Field: page visible
   178 						// Field: page visible
   179             $dataset['visible'] = ( isset($_POST['visible']) ) ? 1 : 0;
   179 						$dataset['visible'] = ( isset($_POST['visible']) ) ? 1 : 0;
   180             
   180 						
   181             // Field: standalone page
   181 						// Field: standalone page
   182             $dataset['special'] = ( isset($_POST['special']) ) ? 1 : 0;
   182 						$dataset['special'] = ( isset($_POST['special']) ) ? 1 : 0;
   183             
   183 						
   184             // Field: page protection
   184 						// Field: page protection
   185             $protect_level = $_POST['protected'];
   185 						$protect_level = $_POST['protected'];
   186             if ( !in_array($protect_level, array('0', '1', '2')) )
   186 						if ( !in_array($protect_level, array('0', '1', '2')) )
   187             {
   187 						{
   188               $errors[] = $lang->get('acppm_err_invalid_protection');
   188 							$errors[] = $lang->get('acppm_err_invalid_protection');
   189             }
   189 						}
   190             else
   190 						else
   191             {
   191 						{
   192               $dataset['protected'] = intval($protect_level);
   192 							$dataset['protected'] = intval($protect_level);
   193             }
   193 						}
   194             
   194 						
   195             // Field: wiki mode
   195 						// Field: wiki mode
   196             $wiki_mode = $_POST['wikimode'];
   196 						$wiki_mode = $_POST['wikimode'];
   197             if ( !in_array($wiki_mode, array('0', '1', '2')) )
   197 						if ( !in_array($wiki_mode, array('0', '1', '2')) )
   198             {
   198 						{
   199               $errors[] = $lang->get('acppm_err_invalid_wiki_mode');
   199 							$errors[] = $lang->get('acppm_err_invalid_wiki_mode');
   200             }
   200 						}
   201             else
   201 						else
   202             {
   202 						{
   203               $dataset['wiki_mode'] = intval($wiki_mode);
   203 							$dataset['wiki_mode'] = intval($wiki_mode);
   204             }
   204 						}
   205             
   205 						
   206             if ( count($errors) < 1 )
   206 						if ( count($errors) < 1 )
   207             {
   207 						{
   208               // We're free of errors. Build a SQL query to update the page table.
   208 							// We're free of errors. Build a SQL query to update the page table.
   209               $particles = array();
   209 							$particles = array();
   210               
   210 							
   211               foreach ( $dataset as $key => $value )
   211 							foreach ( $dataset as $key => $value )
   212               {
   212 							{
   213                 if ( $value === $dataset_backup[$key] || ( is_int($value) && $value === intval($dataset_backup[$key]) ) )
   213 								if ( $value === $dataset_backup[$key] || ( is_int($value) && $value === intval($dataset_backup[$key]) ) )
   214                   continue;
   214 									continue;
   215                 if ( is_int($value) )
   215 								if ( is_int($value) )
   216                 {
   216 								{
   217                   $particle = "$key = $value";
   217 									$particle = "$key = $value";
   218                 }
   218 								}
   219                 else
   219 								else
   220                 {
   220 								{
   221                   $value = $db->escape($value);
   221 									$value = $db->escape($value);
   222                   $particle = "$key = '$value'";
   222 									$particle = "$key = '$value'";
   223                 }
   223 								}
   224                 $particles[] = $particle;
   224 								$particles[] = $particle;
   225                 unset($particle);
   225 								unset($particle);
   226               }
   226 							}
   227               
   227 							
   228               $page_id_new = $db->escape($dataset['urlname']);
   228 							$page_id_new = $db->escape($dataset['urlname']);
   229               $namespace_new = $db->escape($dataset['namespace']);
   229 							$namespace_new = $db->escape($dataset['namespace']);
   230               
   230 							
   231               // Only run the update query if at least one field was changed.
   231 							// Only run the update query if at least one field was changed.
   232               if ( count($particles) > 0 )
   232 							if ( count($particles) > 0 )
   233               {
   233 							{
   234                 $particles = implode(', ', $particles);
   234 								$particles = implode(', ', $particles);
   235                 $page_id_db = $db->escape($page_id);
   235 								$page_id_db = $db->escape($page_id);
   236                 $namespace_db = $db->escape($namespace);
   236 								$namespace_db = $db->escape($namespace);
   237                 $sql = 'UPDATE ' . table_prefix . "pages SET $particles WHERE urlname = '$page_id_db' AND namespace = '$namespace_db';";
   237 								$sql = 'UPDATE ' . table_prefix . "pages SET $particles WHERE urlname = '$page_id_db' AND namespace = '$namespace_db';";
   238                 
   238 								
   239                 if ( !$db->sql_query($sql) )
   239 								if ( !$db->sql_query($sql) )
   240                   $db->_die('PageManager running primary update query');
   240 									$db->_die('PageManager running primary update query');
   241                 
   241 								
   242                 // Did we change the page ID or namespace? If so we need to also change logs, comments, tags, etc.
   242 								// Did we change the page ID or namespace? If so we need to also change logs, comments, tags, etc.
   243                 if ( $page_id_changed || $namespace_changed )
   243 								if ( $page_id_changed || $namespace_changed )
   244                 {
   244 								{
   245                   $sql = array(
   245 									$sql = array(
   246                       'UPDATE ' . table_prefix . "logs SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';",
   246 											'UPDATE ' . table_prefix . "logs SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';",
   247                       'UPDATE ' . table_prefix . "tags SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';",
   247 											'UPDATE ' . table_prefix . "tags SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';",
   248                       'UPDATE ' . table_prefix . "comments SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';",
   248 											'UPDATE ' . table_prefix . "comments SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';",
   249                       'UPDATE ' . table_prefix . "page_text SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';",
   249 											'UPDATE ' . table_prefix . "page_text SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';",
   250                       'UPDATE ' . table_prefix . "categories SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';"
   250 											'UPDATE ' . table_prefix . "categories SET page_id = '$page_id_new', namespace = '$namespace_new' WHERE page_id = '$page_id_db' AND namespace = '$namespace_db';"
   251                     );
   251 										);
   252                   foreach ( $sql as $q )
   252 									foreach ( $sql as $q )
   253                   {
   253 									{
   254                     if ( !$db->sql_query($q) )
   254 										if ( !$db->sql_query($q) )
   255                       $db->_die('PageManager running slave update query after page ID/namespace change');
   255 											$db->_die('PageManager running slave update query after page ID/namespace change');
   256                   }
   256 									}
   257                   
   257 									
   258                   // If we're going File -> other, remove files
   258 									// If we're going File -> other, remove files
   259                   if ( $namespace_db === 'File' )
   259 									if ( $namespace_db === 'File' )
   260                   {
   260 									{
   261                     PageUtils::delete_page_files($page_id);
   261 										PageUtils::delete_page_files($page_id);
   262                   }
   262 									}
   263                 }
   263 								}
   264                 
   264 								
   265                 // Did we change the name of the page? If so, make PageProcessor log it
   265 								// Did we change the name of the page? If so, make PageProcessor log it
   266                 if ( $dataset_backup['name'] != $dataset['name'] )
   266 								if ( $dataset_backup['name'] != $dataset['name'] )
   267                 {
   267 								{
   268                   $page = new PageProcessor($page_id_new, $namespace_new);
   268 									$page = new PageProcessor($page_id_new, $namespace_new);
   269                   $page->rename_page($dataset['name']);
   269 									$page->rename_page($dataset['name']);
   270                 }
   270 								}
   271                 
   271 								
   272                 // Finally, clear the metadata cache
   272 								// Finally, clear the metadata cache
   273                 $cache->purge('page_meta');
   273 								$cache->purge('page_meta');
   274               }
   274 							}
   275               
   275 							
   276               // Did the user ask to delete the page?
   276 							// Did the user ask to delete the page?
   277               // I know it's a bit pointless to delete the page only after validating and processing the whole form, but what the heck :)
   277 							// I know it's a bit pointless to delete the page only after validating and processing the whole form, but what the heck :)
   278               if ( isset($_POST['delete']) )
   278 							if ( isset($_POST['delete']) )
   279               {
   279 							{
   280                 PageUtils::deletepage($page_id_new, $namespace_new, $lang->get('acppm_delete_reason'));
   280 								PageUtils::deletepage($page_id_new, $namespace_new, $lang->get('acppm_delete_reason'));
   281               }
   281 							}
   282               
   282 							
   283               echo '<div class="info-box">' . $lang->get('acppm_msg_save_success', array( 'viewpage_url' => makeUrlNS($dataset['namespace'], $dataset['urlname']) )) . '</div>';
   283 							echo '<div class="info-box">' . $lang->get('acppm_msg_save_success', array( 'viewpage_url' => makeUrlNS($dataset['namespace'], $dataset['urlname']) )) . '</div>';
   284               break 2;
   284 							break 2;
   285             }
   285 						}
   286             
   286 						
   287             break;
   287 						break;
   288         }
   288 				}
   289         $tpl_code = <<<TPLCODE
   289 				$tpl_code = <<<TPLCODE
   290         <div class="tblholder">
   290 				<div class="tblholder">
   291           <table border="0" cellspacing="1" cellpadding="4">
   291 					<table border="0" cellspacing="1" cellpadding="4">
   292             <tr>
   292 						<tr>
   293               <th colspan="2">
   293 							<th colspan="2">
   294                 {lang:acppm_heading_editing} "{PAGE_NAME}"
   294 								{lang:acppm_heading_editing} "{PAGE_NAME}"
   295               </th>
   295 							</th>
   296             </tr>
   296 						</tr>
   297             
   297 						
   298             <tr>
   298 						<tr>
   299               <td class="row2">
   299 							<td class="row2">
   300                 {lang:acppm_lbl_page_name}
   300 								{lang:acppm_lbl_page_name}
   301               </td>
   301 							</td>
   302               <td class="row1">
   302 							<td class="row1">
   303                 <input type="text" name="page_name" value="{PAGE_NAME}" size="40" />
   303 								<input type="text" name="page_name" value="{PAGE_NAME}" size="40" />
   304               </td>
   304 							</td>
   305             </tr>
   305 						</tr>
   306             
   306 						
   307             <tr>
   307 						<tr>
   308               <td class="row2">
   308 							<td class="row2">
   309                 {lang:acppm_lbl_page_urlname}<br />
   309 								{lang:acppm_lbl_page_urlname}<br />
   310                 <small>{lang:acppm_lbl_page_urlname_hint}</small>
   310 								<small>{lang:acppm_lbl_page_urlname_hint}</small>
   311               </td>
   311 							</td>
   312               <td class="row1">
   312 							<td class="row1">
   313                 <input type="text" name="page_urlname" value="{PAGE_URLNAME}" size="40" />
   313 								<input type="text" name="page_urlname" value="{PAGE_URLNAME}" size="40" />
   314               </td>
   314 							</td>
   315             </tr>
   315 						</tr>
   316             
   316 						
   317             <tr>
   317 						<tr>
   318               <td class="row2">
   318 							<td class="row2">
   319                 {lang:acppm_lbl_namespace}
   319 								{lang:acppm_lbl_namespace}
   320               </td>
   320 							</td>
   321               <td class="row1">
   321 							<td class="row1">
   322                 <select name="page_namespace">
   322 								<select name="page_namespace">
   323                 {NAMESPACE_LIST}</select>
   323 								{NAMESPACE_LIST}</select>
   324                 <!-- BEGIN is_file -->
   324 								<!-- BEGIN is_file -->
   325                 <br />
   325 								<br />
   326                 {lang:acppm_msg_file_ns_warning}
   326 								{lang:acppm_msg_file_ns_warning}
   327                 <!-- END is_file -->
   327 								<!-- END is_file -->
   328               </td>
   328 							</td>
   329             </tr>
   329 						</tr>
   330             
   330 						
   331             <tr>
   331 						<tr>
   332               <th colspan="2" class="subhead">
   332 							<th colspan="2" class="subhead">
   333                 {lang:acppm_heading_advanced}
   333 								{lang:acppm_heading_advanced}
   334               </th>
   334 							</th>
   335             </tr>
   335 						</tr>
   336             
   336 						
   337             <tr>
   337 						<tr>
   338               <td class="row2">
   338 							<td class="row2">
   339                 {lang:acppm_lbl_enable_comments_title}
   339 								{lang:acppm_lbl_enable_comments_title}
   340               </td>
   340 							</td>
   341               <td class="row1">
   341 							<td class="row1">
   342                 <label>
   342 								<label>
   343                   <input type="checkbox" name="comments_on" <!-- BEGIN comments_enabled -->checked="checked" <!-- END comments_enabled -->/>
   343 									<input type="checkbox" name="comments_on" <!-- BEGIN comments_enabled -->checked="checked" <!-- END comments_enabled -->/>
   344                   {lang:acppm_lbl_enable_comments}
   344 									{lang:acppm_lbl_enable_comments}
   345                 </label>
   345 								</label>
   346                 <br />
   346 								<br />
   347                 <small>{lang:acppm_lbl_enable_comments_hint}</small>
   347 								<small>{lang:acppm_lbl_enable_comments_hint}</small>
   348               </td>
   348 							</td>
   349             </tr>
   349 						</tr>
   350             
   350 						
   351             <tr>
   351 						<tr>
   352               <td class="row2">
   352 							<td class="row2">
   353                 {lang:acppm_lbl_special_title}
   353 								{lang:acppm_lbl_special_title}
   354               </td>
   354 							</td>
   355               <td class="row1">
   355 							<td class="row1">
   356                 <label>
   356 								<label>
   357                   <input type="checkbox" name="special" <!-- BEGIN special -->checked="checked" <!-- END special -->/>
   357 									<input type="checkbox" name="special" <!-- BEGIN special -->checked="checked" <!-- END special -->/>
   358                   {lang:acppm_lbl_special}
   358 									{lang:acppm_lbl_special}
   359                 </label>
   359 								</label>
   360                 <br />
   360 								<br />
   361                 <small>{lang:acppm_lbl_special_hint}</small>
   361 								<small>{lang:acppm_lbl_special_hint}</small>
   362               </td>
   362 							</td>
   363             </tr>
   363 						</tr>
   364             
   364 						
   365             <tr>
   365 						<tr>
   366               <td class="row2">
   366 							<td class="row2">
   367                 {lang:acppm_lbl_visible_title}
   367 								{lang:acppm_lbl_visible_title}
   368               </td>
   368 							</td>
   369               <td class="row1">
   369 							<td class="row1">
   370                 <label>
   370 								<label>
   371                   <input type="checkbox" name="visible" <!-- BEGIN visible -->checked="checked" <!-- END visible -->/>
   371 									<input type="checkbox" name="visible" <!-- BEGIN visible -->checked="checked" <!-- END visible -->/>
   372                   {lang:acppm_lbl_visible}
   372 									{lang:acppm_lbl_visible}
   373                 </label>
   373 								</label>
   374                 <br />
   374 								<br />
   375                 <small>{lang:acppm_lbl_visible_hint}</small>
   375 								<small>{lang:acppm_lbl_visible_hint}</small>
   376               </td>
   376 							</td>
   377             </tr>
   377 						</tr>
   378             
   378 						
   379             <tr>
   379 						<tr>
   380               <td class="row2">
   380 							<td class="row2">
   381                 {lang:acppm_lbl_protected_title}
   381 								{lang:acppm_lbl_protected_title}
   382               </td>
   382 							</td>
   383               <td class="row1">
   383 							<td class="row1">
   384                 <label>
   384 								<label>
   385                   <input type="radio" name="protected" value="0" <!-- BEGIN protected_off -->checked="checked" <!-- END protected_off -->/>
   385 									<input type="radio" name="protected" value="0" <!-- BEGIN protected_off -->checked="checked" <!-- END protected_off -->/>
   386                   {lang:acppm_lbl_protected_off}
   386 									{lang:acppm_lbl_protected_off}
   387                 </label>
   387 								</label>
   388                 <br />
   388 								<br />
   389                 <label>
   389 								<label>
   390                   <input type="radio" name="protected" value="1" <!-- BEGIN protected_on -->checked="checked" <!-- END protected_on -->/>
   390 									<input type="radio" name="protected" value="1" <!-- BEGIN protected_on -->checked="checked" <!-- END protected_on -->/>
   391                   {lang:acppm_lbl_protected_on}
   391 									{lang:acppm_lbl_protected_on}
   392                 </label>
   392 								</label>
   393                 <br />
   393 								<br />
   394                 <label>
   394 								<label>
   395                   <input type="radio" name="protected" value="2" <!-- BEGIN protected_semi -->checked="checked" <!-- END protected_semi -->/>
   395 									<input type="radio" name="protected" value="2" <!-- BEGIN protected_semi -->checked="checked" <!-- END protected_semi -->/>
   396                   {lang:acppm_lbl_protected_semi}
   396 									{lang:acppm_lbl_protected_semi}
   397                 </label>
   397 								</label>
   398                 <br />
   398 								<br />
   399                 <small>{lang:acppm_lbl_protected_hint}</small>
   399 								<small>{lang:acppm_lbl_protected_hint}</small>
   400               </td>
   400 							</td>
   401             </tr>
   401 						</tr>
   402             
   402 						
   403             <tr>
   403 						<tr>
   404               <td class="row2">
   404 							<td class="row2">
   405                 {lang:acppm_lbl_wikimode_title}
   405 								{lang:acppm_lbl_wikimode_title}
   406               </td>
   406 							</td>
   407               <td class="row1">
   407 							<td class="row1">
   408                 <label>
   408 								<label>
   409                   <input type="radio" name="wikimode" value="0" <!-- BEGIN wikimode_off -->checked="checked" <!-- END wikimode_off -->/>
   409 									<input type="radio" name="wikimode" value="0" <!-- BEGIN wikimode_off -->checked="checked" <!-- END wikimode_off -->/>
   410                   {lang:acppm_lbl_wikimode_off}
   410 									{lang:acppm_lbl_wikimode_off}
   411                 </label>
   411 								</label>
   412                 <br />
   412 								<br />
   413                 <label>
   413 								<label>
   414                   <input type="radio" name="wikimode" value="1" <!-- BEGIN wikimode_on -->checked="checked" <!-- END wikimode_on -->/>
   414 									<input type="radio" name="wikimode" value="1" <!-- BEGIN wikimode_on -->checked="checked" <!-- END wikimode_on -->/>
   415                   {lang:acppm_lbl_wikimode_on}
   415 									{lang:acppm_lbl_wikimode_on}
   416                 </label>
   416 								</label>
   417                 <br />
   417 								<br />
   418                 <label>
   418 								<label>
   419                   <input type="radio" name="wikimode" value="2" <!-- BEGIN wikimode_global -->checked="checked" <!-- END wikimode_global -->/>
   419 									<input type="radio" name="wikimode" value="2" <!-- BEGIN wikimode_global -->checked="checked" <!-- END wikimode_global -->/>
   420                   {lang:acppm_lbl_wikimode_global}
   420 									{lang:acppm_lbl_wikimode_global}
   421                 </label>
   421 								</label>
   422                 <br />
   422 								<br />
   423                 <small>{lang:acppm_lbl_wikimode_hint}</small>
   423 								<small>{lang:acppm_lbl_wikimode_hint}</small>
   424               </td>
   424 							</td>
   425             </tr>
   425 						</tr>
   426             
   426 						
   427             <tr>
   427 						<tr>
   428               <td class="row2">
   428 							<td class="row2">
   429                 {lang:acppm_lbl_delete_title}
   429 								{lang:acppm_lbl_delete_title}
   430               </td>
   430 							</td>
   431               <td class="row1">
   431 							<td class="row1">
   432                 <label>
   432 								<label>
   433                   <input type="checkbox" name="delete" />
   433 									<input type="checkbox" name="delete" />
   434                   {lang:acppm_lbl_delete}
   434 									{lang:acppm_lbl_delete}
   435                 </label>
   435 								</label>
   436                 <br />
   436 								<br />
   437                 <small>{lang:acppm_lbl_delete_hint}</small>
   437 								<small>{lang:acppm_lbl_delete_hint}</small>
   438               </td>
   438 							</td>
   439             </tr>
   439 						</tr>
   440             
   440 						
   441             <tr>
   441 						<tr>
   442               <th colspan="2" class="subhead">
   442 							<th colspan="2" class="subhead">
   443                 <button name="action" value="save">
   443 								<button name="action" value="save">
   444                   <b>{lang:etc_save_changes}</b>
   444 									<b>{lang:etc_save_changes}</b>
   445                 </button>
   445 								</button>
   446                 <button name="action" value="nil">
   446 								<button name="action" value="nil">
   447                   <b>{lang:etc_cancel}</b>
   447 									<b>{lang:etc_cancel}</b>
   448                 </button>
   448 								</button>
   449               </th>
   449 							</th>
   450             </tr>
   450 						</tr>
   451             
   451 						
   452           </table>
   452 					</table>
   453         </div>
   453 				</div>
   454         
   454 				
   455         <input type="hidden" name="page_id" value="{PATHS_KEY}" />
   455 				<input type="hidden" name="page_id" value="{PATHS_KEY}" />
   456 TPLCODE;
   456 TPLCODE;
   457         $parser = $template->makeParserText($tpl_code);
   457 				$parser = $template->makeParserText($tpl_code);
   458         
   458 				
   459         $ns_list = '';
   459 				$ns_list = '';
   460         foreach ( $paths->nslist as $ns => $prefix ) 
   460 				foreach ( $paths->nslist as $ns => $prefix ) 
   461         {
   461 				{
   462           // FIXME: Plugins need to specify whether they want Enano's regular PageProcessor
   462 					// FIXME: Plugins need to specify whether they want Enano's regular PageProcessor
   463           // to handle these pages, and whether such pages from namespaces created by plugins
   463 					// to handle these pages, and whether such pages from namespaces created by plugins
   464           // can be stored in the database or not.
   464 					// can be stored in the database or not.
   465           if ( $ns == 'Special' || $ns == 'Admin' || $ns == 'Anonymous' )
   465 					if ( $ns == 'Special' || $ns == 'Admin' || $ns == 'Anonymous' )
   466             continue;
   466 						continue;
   467           $ns = htmlspecialchars($ns);
   467 					$ns = htmlspecialchars($ns);
   468           $prefix = htmlspecialchars($prefix);
   468 					$prefix = htmlspecialchars($prefix);
   469           if ( empty($prefix) )
   469 					if ( empty($prefix) )
   470             $prefix = $lang->get('acppm_ns_article');
   470 						$prefix = $lang->get('acppm_ns_article');
   471           $sel = ( $dataset['namespace'] == $ns ) ? ' selected="selected"' : '';
   471 					$sel = ( $dataset['namespace'] == $ns ) ? ' selected="selected"' : '';
   472           $ns_list .= "  <option value=\"$ns\"$sel>$prefix</option>\n                ";
   472 					$ns_list .= "  <option value=\"$ns\"$sel>$prefix</option>\n                ";
   473         }
   473 				}
   474         
   474 				
   475         $parser->assign_vars(array(
   475 				$parser->assign_vars(array(
   476             'PAGE_NAME' => htmlspecialchars($dataset['name']),
   476 						'PAGE_NAME' => htmlspecialchars($dataset['name']),
   477             'PAGE_URLNAME' => htmlspecialchars($dataset['urlname']),
   477 						'PAGE_URLNAME' => htmlspecialchars($dataset['urlname']),
   478             'NAMESPACE_LIST' => $ns_list,
   478 						'NAMESPACE_LIST' => $ns_list,
   479             'PATHS_KEY' => $pathskey
   479 						'PATHS_KEY' => $pathskey
   480           ));
   480 					));
   481         
   481 				
   482         $parser->assign_bool(array(
   482 				$parser->assign_bool(array(
   483             'comments_enabled' => ( $dataset['comments_on'] == 1 ),
   483 						'comments_enabled' => ( $dataset['comments_on'] == 1 ),
   484             'special' => ( $dataset['special'] == 1 ),
   484 						'special' => ( $dataset['special'] == 1 ),
   485             'visible' => ( $dataset['visible'] == 1 ),
   485 						'visible' => ( $dataset['visible'] == 1 ),
   486             'protected_off'   => ( $dataset['protected'] == 0 ),
   486 						'protected_off'   => ( $dataset['protected'] == 0 ),
   487             'protected_on'    => ( $dataset['protected'] == 1 ),
   487 						'protected_on'    => ( $dataset['protected'] == 1 ),
   488             'protected_semi'  => ( $dataset['protected'] == 2 ),
   488 						'protected_semi'  => ( $dataset['protected'] == 2 ),
   489             'wikimode_off'    => ( $dataset['wiki_mode'] == 0 ),
   489 						'wikimode_off'    => ( $dataset['wiki_mode'] == 0 ),
   490             'wikimode_on'     => ( $dataset['wiki_mode'] == 1 ),
   490 						'wikimode_on'     => ( $dataset['wiki_mode'] == 1 ),
   491             'wikimode_global' => ( $dataset['wiki_mode'] == 2 ),
   491 						'wikimode_global' => ( $dataset['wiki_mode'] == 2 ),
   492             'is_file'         => ( $dataset['namespace'] == 'File' )
   492 						'is_file'         => ( $dataset['namespace'] == 'File' )
   493           ));
   493 					));
   494         
   494 				
   495         if ( isset($errors) )
   495 				if ( isset($errors) )
   496         {
   496 				{
   497           echo '<div class="error-box">';
   497 					echo '<div class="error-box">';
   498           echo $lang->get('acppm_err_header');
   498 					echo $lang->get('acppm_err_header');
   499           echo '<ul>';
   499 					echo '<ul>';
   500           echo '<li>' . implode('</li><li>', $errors) . '</li>';
   500 					echo '<li>' . implode('</li><li>', $errors) . '</li>';
   501           echo '</ul>';
   501 					echo '</ul>';
   502           echo '</div>';
   502 					echo '</div>';
   503         }
   503 				}
   504         
   504 				
   505         $form_action = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager", true);
   505 				$form_action = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager", true);
   506         
   506 				
   507         echo "<form action=\"$form_action\" method=\"post\">";
   507 				echo "<form action=\"$form_action\" method=\"post\">";
   508         echo $parser->run();
   508 				echo $parser->run();
   509         echo "</form>";
   509 				echo "</form>";
   510         
   510 				
   511         $show_select = false;
   511 				$show_select = false;
   512         break;
   512 				break;
   513     }
   513 		}
   514   }
   514 	}
   515   
   515 	
   516   if ( $show_select )
   516 	if ( $show_select )
   517   {
   517 	{
   518     echo '<p>' . $lang->get('acppm_hint') . '</p>';
   518 		echo '<p>' . $lang->get('acppm_hint') . '</p>';
   519     
   519 		
   520     // Show the search form
   520 		// Show the search form
   521     
   521 		
   522     $form_action = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager", true);
   522 		$form_action = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager", true);
   523     echo "<form action=\"$form_action\" method=\"post\">";
   523 		echo "<form action=\"$form_action\" method=\"post\">";
   524     echo $lang->get('acppm_lbl_field_search') . ' ';
   524 		echo $lang->get('acppm_lbl_field_search') . ' ';
   525     echo $template->pagename_field('page_id') . ' ';
   525 		echo $template->pagename_field('page_id') . ' ';
   526     echo '<input type="hidden" name="action" value="select" />';
   526 		echo '<input type="hidden" name="action" value="select" />';
   527     echo '<input type="submit" name="pid_search" value="' . $lang->get('search_btn_search') . '" />';
   527 		echo '<input type="submit" name="pid_search" value="' . $lang->get('search_btn_search') . '" />';
   528     echo "</form>";
   528 		echo "</form>";
   529     
   529 		
   530     // Grab all pages from the database and show a list of pages on the site
   530 		// Grab all pages from the database and show a list of pages on the site
   531     
   531 		
   532     echo '<h3>' . $lang->get('acppm_heading_select_page_from_list') . '</h3>';
   532 		echo '<h3>' . $lang->get('acppm_heading_select_page_from_list') . '</h3>';
   533     echo '<p>' . $lang->get('acppm_hint_select_page_from_list') . '</p>';
   533 		echo '<p>' . $lang->get('acppm_hint_select_page_from_list') . '</p>';
   534     
   534 		
   535     $q = $db->sql_query('SELECT COUNT(name) AS num_pages FROM ' . table_prefix . 'pages;');
   535 		$q = $db->sql_query('SELECT COUNT(name) AS num_pages FROM ' . table_prefix . 'pages;');
   536     if ( !$q )
   536 		if ( !$q )
   537       $db->_die('PageManager doing initial page count');
   537 			$db->_die('PageManager doing initial page count');
   538     list($num_pages) = $db->fetchrow_num();
   538 		list($num_pages) = $db->fetchrow_num();
   539     $db->free_result();
   539 		$db->free_result();
   540     
   540 		
   541     $pg_start = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
   541 		$pg_start = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
   542     
   542 		
   543     $q = $db->sql_query('SELECT urlname, name, namespace, ' . $num_pages . ' AS num_pages, ' . $pg_start . ' AS offset FROM ' . table_prefix . 'pages ORDER BY name ASC;');
   543 		$q = $db->sql_query('SELECT urlname, name, namespace, ' . $num_pages . ' AS num_pages, ' . $pg_start . ' AS offset FROM ' . table_prefix . 'pages ORDER BY name ASC;');
   544     if ( !$q )
   544 		if ( !$q )
   545       $db->_die('PageManager doing main select query for page list');
   545 			$db->_die('PageManager doing main select query for page list');
   546     
   546 		
   547     // Paginate results
   547 		// Paginate results
   548     $html = paginate(
   548 		$html = paginate(
   549         $q,
   549 				$q,
   550         '{urlname}',
   550 				'{urlname}',
   551         $num_pages,
   551 				$num_pages,
   552         makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager&offset=%s", false),
   552 				makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager&offset=%s", false),
   553         $pg_start,
   553 				$pg_start,
   554         99,
   554 				99,
   555         array('urlname' => 'admin_pagemanager_format_listing'),
   555 				array('urlname' => 'admin_pagemanager_format_listing'),
   556         '<div class="tblholder" style="height: 300px; clip: rect(0px, auto, auto, 0px); overflow: auto;">
   556 				'<div class="tblholder" style="height: 300px; clip: rect(0px, auto, auto, 0px); overflow: auto;">
   557         <table border="0" cellspacing="1" cellpadding="4">',
   557 				<table border="0" cellspacing="1" cellpadding="4">',
   558         '  </table>
   558 				'  </table>
   559          </div>'
   559  				</div>'
   560       );
   560 			);
   561     echo $html;
   561 		echo $html;
   562   }
   562 	}
   563   
   563 	
   564 }
   564 }
   565 
   565 
   566 function admin_pagemanager_format_listing($_, $row)
   566 function admin_pagemanager_format_listing($_, $row)
   567 {
   567 {
   568   global $db, $session, $paths, $template, $plugins; // Common objects
   568 	global $db, $session, $paths, $template, $plugins; // Common objects
   569   
   569 	
   570   static $cell_count = 0;
   570 	static $cell_count = 0;
   571   static $td_class = 'row1';
   571 	static $td_class = 'row1';
   572   static $run_count = 0;
   572 	static $run_count = 0;
   573   static $num_pages_floor = false;
   573 	static $num_pages_floor = false;
   574   if ( !$num_pages_floor )
   574 	if ( !$num_pages_floor )
   575   {
   575 	{
   576     $num_pages_floor = $row['num_pages'];
   576 		$num_pages_floor = $row['num_pages'];
   577     while ( $num_pages_floor % 99 > 0 )
   577 		while ( $num_pages_floor % 99 > 0 )
   578       $num_pages_floor--;
   578 			$num_pages_floor--;
   579   }
   579 	}
   580   $return = '';
   580 	$return = '';
   581   $run_count++;
   581 	$run_count++;
   582   
   582 	
   583   $last_page = ( $row['offset'] == $num_pages_floor );
   583 	$last_page = ( $row['offset'] == $num_pages_floor );
   584   $last_run = ( ( $last_page && $run_count == $row['num_pages'] % 99 ) || $run_count == 99 );
   584 	$last_run = ( ( $last_page && $run_count == $row['num_pages'] % 99 ) || $run_count == 99 );
   585   if ( $cell_count == 0 )
   585 	if ( $cell_count == 0 )
   586   {
   586 	{
   587     $return .= "<tr>\n";
   587 		$return .= "<tr>\n";
   588   }
   588 	}
   589   $title = get_page_title_ns($row['urlname'], $row['namespace']);
   589 	$title = get_page_title_ns($row['urlname'], $row['namespace']);
   590   $pathskey = $paths->nslist[$row['namespace']] . $row['urlname'];
   590 	$pathskey = $paths->nslist[$row['namespace']] . $row['urlname'];
   591   if ( isset($row['mode']) && $row['mode'] == 'edit' )
   591 	if ( isset($row['mode']) && $row['mode'] == 'edit' )
   592   {
   592 	{
   593     $url = makeUrlNS($row['namespace'], $row['urlname'], false, true) . '#do:edit';
   593 		$url = makeUrlNS($row['namespace'], $row['urlname'], false, true) . '#do:edit';
   594   }
   594 	}
   595   else
   595 	else
   596   {
   596 	{
   597     $url = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager&action=select&page_id=$pathskey", true);
   597 		$url = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageManager&action=select&page_id=$pathskey", true);
   598   }
   598 	}
   599   $url = '<a href="' . $url . '">' . htmlspecialchars($title) . '</a>';
   599 	$url = '<a href="' . $url . '">' . htmlspecialchars($title) . '</a>';
   600   $return .= '  <td class="' . $td_class . '" style="width: 33%;">' . $url . '</td>' . "\n";
   600 	$return .= '  <td class="' . $td_class . '" style="width: 33%;">' . $url . '</td>' . "\n";
   601   $cell_count++;
   601 	$cell_count++;
   602   if ( $cell_count == 3 && !$last_run )
   602 	if ( $cell_count == 3 && !$last_run )
   603   {
   603 	{
   604     $cell_count = 0;
   604 		$cell_count = 0;
   605     $td_class = ( $td_class == 'row2' ) ? 'row1' : 'row2';
   605 		$td_class = ( $td_class == 'row2' ) ? 'row1' : 'row2';
   606     $return .= "</tr>\n";
   606 		$return .= "</tr>\n";
   607   }
   607 	}
   608   else if ( $last_run )
   608 	else if ( $last_run )
   609   {
   609 	{
   610     while ( $cell_count < 3 )
   610 		while ( $cell_count < 3 )
   611     {
   611 		{
   612       $return .= "  <td class=\"{$td_class}\"></td>\n";
   612 			$return .= "  <td class=\"{$td_class}\"></td>\n";
   613       $cell_count++;
   613 			$cell_count++;
   614     }
   614 		}
   615     $return .= "</tr>\n";
   615 		$return .= "</tr>\n";
   616   }
   616 	}
   617   return $return;
   617 	return $return;
   618 }
   618 }
   619 
   619 
   620 ?>
   620 ?>