Fix the content pages in admin area.

(cherry picked from commit 8d59b44)
This commit is contained in:
Darko
2015-06-08 09:29:27 +02:00
parent 767a2cf6da
commit f8300a1ab1
5 changed files with 169 additions and 208 deletions
+9 -15
View File
@@ -36,7 +36,6 @@ class BasePage
public $smarty = '';
public $userdata = array();
public $serverurl = '';
public $site = '';
public $secure_connection = false;
@@ -58,19 +57,14 @@ class BasePage
$this->stripSlashes($_COOKIE);
}
// set site variable
$s = new Sites();
$this->site = $s->get();
$this->pdo = new Settings();
// Buffer settings/DB connection.
$this->settings = new newznab\db\Settings();
$this->settings = new Settings();
$this->smarty = new Smarty();
$this->captcha = new Captcha(['Settings' => $this->settings]);
$this->smarty->setTemplateDir(
array(
'user_frontend' => NN_WWW . 'templates/' . $this->pdo->getSetting('style') . '/views/frontend',
'user_frontend' => NN_WWW . 'templates/' . $this->settings->getSetting('style') . '/views/frontend',
'frontend' => NN_WWW . 'templates/default/views/frontend'
)
);
@@ -80,8 +74,8 @@ class BasePage
$this->smarty->error_reporting = ((NN_DEBUG ? E_ALL : E_ALL - E_NOTICE));
$this->secure_connection = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)) ;
if (file_exists(WWW_DIR.'templates/'.$this->pdo->getSetting('style').'/theme.php'))
require_once(WWW_DIR.'templates/'.$this->pdo->getSetting('style').'/theme.php');
if (file_exists(WWW_DIR.'templates/'.$this->settings->getSetting('style').'/theme.php'))
require_once(WWW_DIR.'templates/'.$this->settings->getSetting('style').'/theme.php');
$this->smarty->assign('themevars', (isset($themevars) ? $themevars : null));
$servername = null;
@@ -105,7 +99,7 @@ class BasePage
$this->userdata["categoryexclusions"] = $this->users->getCategoryExclusion($this->users->currentUserId());
// Change the theme to user's selected theme if they selected one, else use the admin one.
if ($this->pdo->getSetting('userselstyle') == 1) {
if ($this->settings->getSetting('userselstyle') == 1) {
if (isset($this->userdata['style']) && $this->userdata['style'] !== 'None') {
$this->smarty->setTemplateDir(
array(
@@ -145,9 +139,9 @@ class BasePage
if ($this->userdata["hideads"] == "1")
{
$this->pdo->setSetting(['adheader', '']);
$this->pdo->setSetting(['adbrowse', '']);
$this->pdo->setSetting(['addetail', '']);
$this->settings->setSetting(['adheader', '']);
$this->settings->setSetting(['adbrowse', '']);
$this->settings->setSetting(['addetail', '']);
}
$this->floodCheck($this->userdata["role"]);
@@ -162,7 +156,7 @@ class BasePage
}
$this->smarty->assign('site', $this->site);
$this->smarty->assign('site', $this->settings);
$this->smarty->assign('page', $this);
}
+41 -50
View File
@@ -1,68 +1,59 @@
<?php
require_once './config.php';
$page = new AdminPage();
$contents = new Contents();
$id = 0;
// set the current action
$page = new AdminPage();
$contents = new Contents(['Settings' => $page->settings]);
$id = 0;
// Set the current action.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
switch($action)
{
case 'add':
$page->title = "Content Add";
$content = array();
$content["showinmenu"] = "1";
$content["status"] = "1";
$content["contenttype"] = "2";
$page->smarty->assign('content',$content);
break;
switch ($action) {
case 'add':
$page->title = "Content Add";
$content = new Content();
$content->showinmenu = "1";
$content->status = "1";
$content->contenttype = "2";
$page->smarty->assign('content', $content);
break;
case 'submit':
//
// validate and add or update
//
$returnid = 0;
if (!isset($_POST["id"]) || $_POST["id"]=="")
{
$returnid = $contents->add($_POST);
}
else
{
$content = $contents->update($_POST);
$returnid = $_POST["id"];
}
header("Location:content-add.php?id=".$returnid);
case 'submit':
// Validate and add or update.
$returnid = 0;
if (!isset($_POST["id"]) || $_POST["id"] == "") {
$returnid = $contents->add($_POST);
} else {
$content = $contents->update($_POST);
$returnid = $content->id;
}
header("Location:content-add.php?id=" . $returnid);
break;
break;
case 'view':
default:
case 'view':
default:
if (isset($_GET["id"])) {
$page->title = "Content Edit";
$id = $_GET["id"];
if (isset($_GET["id"]))
{
$page->title = "Content Edit";
$id = $_GET["id"];
$content = $contents->getByID($id, Users::ROLE_ADMIN);
$page->smarty->assign('content', $content);
}
break;
$content = $contents->getByID($id, Users::ROLE_ADMIN);
$page->smarty->assign('content', $content);
}
break;
}
$page->smarty->assign('status_ids', array(1,0));
$page->smarty->assign('status_names', array( 'Enabled', 'Disabled'));
$page->smarty->assign('status_ids', [1, 0]);
$page->smarty->assign('status_names', ['Enabled', 'Disabled']);
$page->smarty->assign('yesno_ids', array(1,0));
$page->smarty->assign('yesno_names', array( 'Yes', 'No'));
$page->smarty->assign('yesno_ids', [1, 0]);
$page->smarty->assign('yesno_names', ['Yes', 'No']);
$contenttypelist = array("1" => "Useful Link", "2" => "Article", "3" => "Homepage");
$contenttypelist = ["1" => "Useful Link", "2" => "Article", "3" => "Homepage"];
$page->smarty->assign('contenttypelist', $contenttypelist);
$rolelist = array("0" => "Everyone", "1" => "Logged in Users", "2" => "Admins");
$rolelist = ["0" => "Everyone", "1" => "Logged in Users", "2" => "Admins"];
$page->smarty->assign('rolelist', $rolelist);
$page->content = $page->smarty->fetch('content-add.tpl');
$page->render();
$page->render();
+5 -7
View File
@@ -1,15 +1,13 @@
<?php
require_once("config.php");
require_once './config.php';
$page = new AdminPage();
$contents = new Contents();
$page = new AdminPage();
$contents = new Contents(['Settings' => $page->settings]);
$contentlist = $contents->getAll();
$page->smarty->assign('contentlist',$contentlist);
$page->smarty->assign('contentlist', $contentlist);
$page->title = "Content List";
$page->content = $page->smarty->fetch('content-list.tpl');
$page->render();
$page->render();
@@ -1,89 +1,74 @@
<h1>{$page->title}</h1>
<form action="{$SCRIPT_NAME}?action=submit" method="POST">
<table class="input">
<tr>
<td><label for="title">Title</label>:</td>
<td>
<input type="hidden" name="id" value="{$content.id}" />
<input id="title" class="long" name="title" type="text" value="{$content.title}" />
</td>
</tr>
<tr>
<td><label for="url">Url</label>:</td>
<td>
<input id="url" class="long" name="url" type="text" value="{$content.url}" />
</td>
</tr>
<tr>
<td><label for="body">Body</label>:</td>
<td>
<textarea class="autosize" id="body" name="body">{$content.body}</textarea>
</td>
</tr>
<tr>
<td><label for="metadescription">Meta Description</label>:</td>
<td>
<textarea class="autosize" id="metadescription" name="metadescription">{$content.metadescription}</textarea>
</td>
</tr>
<tr>
<td><label for="metakeywords">Meta Keywords</label>:</td>
<td>
<textarea class="autosize" id="metakeywords" name="metakeywords">{$content.metakeywords}</textarea>
</td>
</tr>
<tr>
<td><label for="contenttype">Content Type</label>:</td>
<td>
{html_options id="contenttype" name='contenttype' options=$contenttypelist selected=$content.contenttype}
</td>
</tr>
<tr>
<td><label for="role">Visible To</label>:</td>
<td>
{html_options id="role" name='role' options=$rolelist selected=$content.role}
<div class="hint">Only appropriate for articles and useful links</div>
</td>
</tr>
<tr>
<td><label for="showinmenu">Show In Menu</label>:</td>
<td>
{html_radios id="showinmenu" name='showinmenu' values=$yesno_ids output=$yesno_names selected=$content.showinmenu separator='<br />'}
</td>
</tr>
<tr>
<td><label for="status">Status</label>:</td>
<td>
{html_radios id="status" name='status' values=$status_ids output=$status_names selected=$content.status separator='<br />'}
</td>
</tr>
<tr>
<td><label for="ordinal">Ordinal</label>:</td>
<td>
<input id="ordinal" name="ordinal" type="text" value="{$content.ordinal}" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Save" />
</td>
</tr>
</table>
<table class="input">
<tr>
<td><label for="title">Title:</label></td>
<td>
<input type="hidden" name="id" value="{$content->id}" />
<input id="title" class="long" name="title" type="text" value="{$content->title}" />
</td>
</tr>
<tr>
<td><label for="url">Url:</label></td>
<td>
<input id="url" class="long" name="url" type="text" value="{$content->url}" />
</td>
</tr>
<tr>
<td><label for="body">Body:</label></td>
<td>
<textarea id="body" name="body">{$content->body}</textarea>
</td>
</tr>
<tr>
<td><label for="metadescription">Meta Description:</label></td>
<td>
<textarea id="metadescription" name="metadescription">{$content->metadescription}</textarea>
</td>
</tr>
<tr>
<td><label for="metakeywords">Meta Keywords:</label></td>
<td>
<textarea id="metakeywords" name="metakeywords">{$content->metakeywords}</textarea>
</td>
</tr>
<tr>
<td><label for="contenttype">Content Type:</label></td>
<td>
{html_options id="contenttype" name='contenttype' options=$contenttypelist selected=$content->contenttype}
</td>
</tr>
<tr>
<td><label for="role">Visible To:</label></td>
<td>
{html_options id="role" name='role' options=$rolelist selected=$content->role}
<div class="hint">Only appropriate for articles and useful links</div>
</td>
</tr>
<tr>
<td><label for="showinmenu">Show In Menu:</label></td>
<td>
{html_radios id="showinmenu" name='showinmenu' values=$yesno_ids output=$yesno_names selected=$content->showinmenu separator='<br />'}
</td>
</tr>
<tr>
<td><label for="status">Status:</label></td>
<td>
{html_radios id="status" name='status' values=$status_ids output=$status_names selected=$content->status separator='<br />'}
</td>
</tr>
<tr>
<td><label for="ordinal">Ordinal:</label></td>
<td>
<input id="ordinal" name="ordinal" type="text" value="{$content->ordinal}" />
<div class="hint">If you set the ordinal = 1, then a all ordinals greater than 0 will be renumbered. This allows new content to be at the top without having to renumber all previous content.<br />If you set ordinal = 0, it will be at the top, sorted by ID(order added)</div>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Save" />
</td>
</tr>
</table>
</form>
@@ -1,11 +1,8 @@
<h1>{$page->title}</h1>
<table class="data Sortable highlight">
<tr>
<th width="60">ordinal</th>
<th width="30">id</th>
<th style="width:60px;">ordinal</th>
<th style="width:30px;">id</th>
<th>title</th>
<th>url</th>
<th>type</th>
@@ -15,50 +12,46 @@
<th>body</th>
<th>options</th>
</tr>
{foreach from=$contentlist item=content}
<tr class="{cycle values=",alt"}">
<td>{$content.ordinal}</td>
<td>{$content.id}</td>
<td><a href="{$smarty.const.WWW_TOP}/content-add.php?id={$content.id}" title="Edit {$content.title}">{$content.title}</a></td>
<td><a title="Preview in new window" href="{$smarty.const.WWW_TOP}/../content/{$content.id}{$content.url}" target="null">/content/{$content.id}{$content.url}</a></td>
<td>
{if $content.contenttype == "1"}
Useful Link
{elseif $content.contenttype == "2"}
Article
{elseif $content.contenttype == "3"}
Homepage
{/if}
</td>
<td>
{if $content.status == "1"}
Enabled
{else}
Disabled
{/if}
</td>
<td>
{if $content.role == "0"}
Everyone
{elseif $content.role == "1"}
Users
{elseif $content.role == "2"}
Admins
{/if}
</td>
<td style="width:50px;">
{if $content.showinmenu == "1"}
Yes
{else}
No
{/if}
</td>
<td title="{$content.body|escape:'htmlall'}">{$content.body|truncate:100|escape:'htmlall'}</td>
<td>{if $content.contenttype != "3"}<a class="confirm_action" href="{$smarty.const.WWW_TOP}/content-delete.php?id={$content.id}">delete</a>{/if}</td>
</tr>
<tr class="{cycle values=",alt"}">
<td>{$content->ordinal}</td>
<td>{$content->id}</td>
<td><a href="{$smarty.const.WWW_TOP}/content-add.php?id={$content->id}" title="Edit {$content->title}">{$content->title}</a></td>
<td><a title="Preview in new window" href="{$smarty.const.WWW_TOP}/{$content->url}c{$content->id}" target="null">{$content->url}c{$content->id}</a></td>
<td>
{if $content->contenttype == "1"}
Useful Link
{elseif $content->contenttype == "2"}
Article
{elseif $content->contenttype == "3"}
Homepage
{/if}
</td>
<td>
{if $content->status == "1"}
Enabled
{else}
Disabled
{/if}
</td>
<td>
{if $content->role == "0"}
Everyone
{elseif $content->role == "1"}
Users
{elseif $content->role == "2"}
Admins
{/if}
</td>
<td style="width:50px;">
{if $content->showinmenu == "1"}
Yes
{else}
No
{/if}
</td>
<td title="{$content->body|escape:'htmlall'}">{$content->body|truncate:100|escape:'htmlall'}</td>
<td>{if $content->contenttype != "3"}<a class="confirm_action" href="{$smarty.const.WWW_TOP}/content-delete.php?id={$content->id}">delete</a>{/if}</td>
</tr>
{/foreach}
</table>
</table>