Macro's admin

This code represents the NP_Macro's administration page. You should copy and paste this code into a file called index.php. You should upload this file to your nucleus/plugins/macros folder on your servier. This directory needs to be created if this is your first install.

<?php
 
	// if your 'plugin' directory is not in the default location,
	// edit this variable to point to your site directory
	// (where config.php is)
 
	$CONF['Self'] = "index.php";
	$strRel = '../../../'; 
 
	include($strRel . 'config.php');
	if (!$member->isLoggedIn())
		doError('You\'re not logged in.');
 
	include($DIR_LIBS . 'PLUGINADMIN.php');
 
	// create the admin area page
	$oPluginAdmin = new PluginAdmin('Macros');
	$oPluginAdmin->start();
 
	// get list of comments to approve
 
	$whatToDo = requestVar(action);
	$aList    = $oPluginAdmin->plugin->_getMacros();
 
	echo '<h2>Macros</h2>';
 
	if ($whatToDo == 'edit') {
		$id=requestVar(id);
		$aMacro = $oPluginAdmin->plugin->_getMacro($id);
 
		echo '<table><tr>';
 
		echo '<form method="post" action="'. $CONF['ActionURL'] .'">';
 
		?>
		<input type="hidden" name="action" value="plugin" />
		<input type="hidden" name="name" value="Macros" />
		<input type="hidden" name="type" value="update" />
		<?
 
		echo '<input type="hidden" name="id" value="'.$id.'" />';
 
		?>
		<td><label>Pattern </label>: </td><td>
		<?
 
		echo '<input name="pattern_string" size="80" value="'.htmlspecialchars($aMacro['pattern_string']).'" maxlength="80" class="formfield"/></td>';
 
		?>
 
		</tr><tr>
		<td><label>Replace String</label>:</td><td>
		<?
 
		echo '<input name="replace_string" size="80" value="'.htmlspecialchars($aMacro['replace_string']).'" maxlength="80" class="formfield"/></td>';
 
		?>
 
		</tr><tr>
 
	        <?	
		if ($aMacro['pattern_type'] == 0 ) {
		?>
			<td><input name="pattern_type" type="radio" tabindex="30" value="0" checked="yes" id="ereg_yes" /><label for="ereg_yes"><a href="http://in2.php.net/manual/en/function.ereg-replace.php" target="_blank">Simple Regular Expression</a></label>
			</td>
			<td><input name="pattern_type" type="radio" tabindex="30" value="1"  id="preg_yes" /><label for="preg_yes"><a href="http://in2.php.net/manual/en/function.preg-replace.php" target="_blank">Perl Style Reg Expression</a></label>
			</td>
		<?
		}
		else {
		?>
 
			<td><input name="pattern_type" type="radio" tabindex="30" value="0" id="ereg_yes" /><label for="ereg_yes"><a href="http://in2.php.net/manual/en/function.ereg-replace.php" target="_blank">Simple Regular Expression</a></label>
			</td>
			<td><input name="pattern_type" type="radio" tabindex="30" checked="yes" value="1"  id="preg_yes" /><label for="preg_yes"><a href="http://in2.php.net/manual/en/function.preg-replace.php" target="_blank">Perl Style Reg Expression</a></label>
			</td>
		<?
			}
		?>
		</tr><tr>
		<td><input type="submit" value="Edit Macro" class="formbutton" /></td>
		</form>
		</tr></table>
		<?
	}
	else {
 
		if (count($aList) > 0)
		{
 
			echo '<table><tr>';
			echo '<th>Pattern String</th>';
			echo '<th>Replace String</th>';
			echo '<th>Pattern Type</th>';
			echo '<th>Actions</th>';
 
			foreach ($aList as $aMacro)
			{
 
				$urledit	= $CONF['ActionURL'] . '?action=plugin&name=Macros&type=edit&id=' . $aMacro['id'];
				$urldelete	= $CONF['ActionURL'] . '?action=plugin&name=Macros&type=delete&id=' . $aMacro['id'];
 
				echo '</tr><tr>';		
				echo '<td>';
					echo htmlspecialchars($aMacro['pattern_string']);
				echo '</td>';
				echo '<td>';
					echo htmlspecialchars($aMacro['replace_string']);
				echo '</td>';
				echo '<td>';
					if ($aMacro[pattern_type] == 0 ) 
						echo '<a href="http://in2.php.net/manual/en/function.ereg-replace.php" target="_blank">Simple Regular Expression</a>';						
					else
						echo '<a href="http://in2.php.net/manual/en/function.preg-replace.php" target="_blank">Perl Style Reg Expression</a>';
				echo '</td>';
				echo '<td>';
					echo '<a href="'.htmlspecialchars($urledit).'">edit</a>';
					echo '<br />';
					echo '<a href="'.htmlspecialchars($urldelete).'">delete</a>';
				echo '</td>';
			}
		}
		echo '</tr></table>';
		echo '<table><tr>';
 
		echo '<form method="post" action="'. $CONF['ActionURL'] .'">';
		?>		
		<input type="hidden" name="action" value="plugin" />
		<input type="hidden" name="name" value="Macros" />
		<input type="hidden" name="type" value="add" />
		<td><label>Pattern </label>: </td><td><input name="pattern_string" size="80" value="Pattern" maxlength="80" class="formfield"/></td>
		</tr><tr>
		<td><label>Replace String</label>:</td><td><input name="replace_string" size="80" value="Replace String" maxlength="80" class="formfield"/></td>
		</tr>
		<tr>
		<td><input name="pattern_type" type="radio" tabindex="30" value="0" checked="yes" id="ereg_yes" /><label for="ereg_yes"><a href="http://in2.php.net/manual/en/function.ereg-replace.php" target="_blank">Simple Regular Expression</a></label>
		</td>
		<td><input name="pattern_type" type="radio" tabindex="30" value="1"  id="preg_yes" /><label for="preg_yes"><a href="http://in2.php.net/manual/en/function.preg-replace.php" target="_blank">Perl Style Reg Expression</a></label>
		</td>
		<tr><td><input type="submit" value="Add Macro" class="formbutton" /></td>
		</form>
		<?
		echo '</tr></table>';
 
	}	
 
	$oPluginAdmin->end();
 
?>
macrosadmin.txt · Last modified: 2007/11/14 23:07 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki