Location: PHPKode > scripts > Noostr > style/admin/pages.php
<?php defined('SYSPATH') OR die('No direct access to this file is allowed.');
show_header();

if (isset($ns->querystring['action']) && isset($ns->querystring['id']) && !isset($ns->querystring['step'])) {
	$page = null;
	if ($ns->querystring['id'] > 0) {
		$page = get_pages($ns->pages, $ns->querystring['id']);
	}
	if ($page != null || $ns->querystring['action'] == 'new') {
		switch ($ns->querystring['action']) {
			case 'edit':
			case 'new':
				$roles = get_all_roles();
				$rolelist = '';
				for ($i = 0, $c = count($roles); $i < $c; $i++) {
					$rolelist .= '<option value="'.$roles[$i]['uid'].'"';
					if ($roles[$i]['default'] && $ns->querystring['action'] == 'new') {
						$rolelist .= ' selected="selected"';
					} elseif ($page['roleid'] == $roles[$i]['uid'] && $ns->querystring['action'] == 'edit') {
						$rolelist .= ' selected="selected"';
					}
					$rolelist .= '>'.$roles[$i]['name'].'</option>';
				}
				$pages = get_pages($ns->pages);
				$templatelist = '<option value="-1">None</option>';
				for ($i = 0, $c = count($pages); $i < $c; $i++) {
					if ($pages[$i]['uid'] != $page['uid']) {
						$templatelist .= '<option value="'.$pages[$i]['uid'].'"';
						if ($page['tid'] == $pages[$i]['uid'] && $ns->querystring['action'] == 'edit') {
							$templatelist .= ' selected="selected"';
						}
						$templatelist .= '>'.$pages[$i]['title'].'</option>';
					}
				}
				$parentlist = '<option value="-1">None</option>';
				for ($i = 0, $c = count($pages); $i < $c; $i++) {
					if ($pages[$i]['uid'] != $page['uid']) {
						$parentlist .= '<option value="'.$pages[$i]['uid'].'"';
						if ($page['pid'] == $pages[$i]['uid'] && $ns->querystring['action'] == 'edit') {
							$parentlist .= ' selected="selected"';
						}
						$parentlist .= '>'.$pages[$i]['title'].'</option>';
					}
				}
				$checked = '';
				if ($page['showAlways'] || $ns->querystring['action'] == 'new') {
					$checked = ' checked="checked"';
				}
?>
<form name="<?php echo $ns->querystring['action']; ?>page" id="<?php echo $ns->querystring['action']; ?>page" action="<?php echo PATH; ?>" method="post">
	<dl>
		<dt><label for="title">Page title:</label></dt>
		<dd><input type="text" name="title" id="title" value="<?php echo $page['title']; ?>" /></dd>
		<dt><label for="url">URL:</label></dt>
		<dd><input type="text" name="url" id="url" value="<?php echo $page['url']; ?>" /></dd>
		<dt><label for="content">Content:</label></dt>
		<dd><textarea name="content" id="content"><?php echo $page['content']; ?></textarea></dd>
		<dt><label for="displayorder">Display order:</label></dt>
		<dd><input type="text" name="displayorder" id="displayorder" value="<?php echo $page['displayorder']; ?>" /></dd>
		<dt><label for="roleid">Minimum role to view:</label></dt>
		<select name="roleid" id="roleid"><?php echo $rolelist; ?></select>
		<dt><label for="template">Template:</label></dt>
		<select name="template" id="template"><?php echo $templatelist; ?></select>
		<dt><label for="parent">Parent page:</label></dt>
		<select name="parent" id="parent"><?php echo $parentlist; ?></select>
		<dt><label for="showAlways">Always show in menu?</label></dt>
		<dd><input type="checkbox" name="showAlways" id="showAlways" value="1"<?php echo $checked;?> /></dd>
	</dl>
	<input type="hidden" name="type" id="type" value="admin_<?php echo $ns->querystring['action']; ?>_page" />
	<input type="hidden" name="from" id="from" value="<?php echo PATH; ?>" />
	<input type="hidden" name="id" id="id" value="<?php echo $page['uid']; ?>" />
	<input type="submit" name="submit" id="submit" value="Continue!" />
</form>
<?php
				break;
			case 'delete':
				echo '<p>Clicking the link below will permanently delete the <strong>'.$page['title'].'</strong> page.</p>';
				echo '<form action="'.PATH.'" method="post"><input type="hidden" name="id" id="id" value="'.$page['uid'].'" /><input type="hidden" name="type" id="type" value="admin_'.$ns->querystring['action'].'_page" /><input type="hidden" name="from" id="from" value="'.PATH.'" /><input type="submit" name="submit" id="submit" value="DELETE!" /></form>';
				break;
		}
	}
} else {
	$pages = get_pages($ns->pages);
	if ($pages != null) {
		echo '<table>';
		for ($i = 0, $c = count($pages); $i < $c; $i++) {
			echo '<tr>';
			echo '<td width="80%" class="title">'.$pages[$i]['title'].'</td>';
			echo '<td nowrap="nowrap">'.$pages[$i]['url'].'</td>';
			echo '<td nowrap="nowrap">'.$pages[$i]['created'].'</td>';
			echo '</tr>';
			echo '<tr><td colspan="3" class="edit"><a href="?action=edit&id='.$pages[$i]['uid'].'">Edit</a> | <a href="?action=delete&id='.$pages[$i]['uid'].'">Delete</a> | <a href="'.$pages[$i]['url'].'">View</a></td></tr>';
		}
		echo '</table>';
		echo '<p><a href="?action=new&id=-1">ADD A PAGE</a></p>';
	}
}
show_footer();
Return current item: Noostr