Skip to content

Commit

Permalink
Adding smarty implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Sep 19, 2011
1 parent 2e40a5f commit 41d4969
Show file tree
Hide file tree
Showing 57 changed files with 520 additions and 437 deletions.
94 changes: 37 additions & 57 deletions admin/index.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
/* For licensing terms, see /license.txt */

define("PAGE", "Admin Area");
require_once '../includes/compiler.php';

define("PAGE", "Admin Area");


/**
*
Expand Down Expand Up @@ -44,7 +45,6 @@
//Main ACP Function - Creates the ACP basically
function acp() {
global $main, $db, $style, $type, $email, $user;
ob_start(); # Stop the output buffer

if (!isset($main->getvar['page'])) {
$main->getvar['page'] = 'home';
Expand All @@ -69,6 +69,7 @@ function acp() {

// Left menu
$array['LINKS'] = '';

foreach ($admin_navigation as $row) {
if ($main->checkPerms($row['link'])) {
$array_item['IMGURL'] = $row['icon'];
Expand All @@ -81,16 +82,16 @@ function acp() {
$array_item['ACTIVE'] = ' ';
}*/

$array['LINKS'] .= $style->replaceVar("tpl/menu/leftmenu_link.tpl", $array_item);
$array['LINKS'] .= $style->replaceVar("menu/leftmenu_link.tpl", $array_item);
}
}
//Adding the logout link
$array_item['IMGURL'] = "logout.png";
$array_item['LINK'] = "?page=logout";
$array_item['VISUAL'] = "Logout";
$array['LINKS'] .= $style->replaceVar("tpl/menu/leftmenu_link.tpl", $array_item);
$array['LINKS'] .= $style->replaceVar("menu/leftmenu_link.tpl", $array_item);

$sidebar = $style->replaceVar("tpl/menu/leftmenu_main.tpl", $array);
$sidebar = $style->replaceVar("menu/leftmenu_main.tpl", $array);

$user_permission = true;
if (!file_exists($link)) {
Expand All @@ -107,15 +108,9 @@ function acp() {

//Page Sidebar

$sidebar_link_link = "tpl/menu/leftmenu_link.tpl";
$sidebar_link = "tpl/menu/leftmenu_main.tpl";

//if (isset($main->getvar['sub'])) {

//}



$sidebar_link_link = "menu/leftmenu_link.tpl";
$sidebar_link = "menu/leftmenu_main.tpl";

if (isset($main->getvar['sub']) && $main->getvar['sub'] && $admin_nave_item['link'] != "type") {
if (is_array($content->navlist)) {
foreach($content->navlist as $key => $value) {
Expand Down Expand Up @@ -158,26 +153,21 @@ function acp() {
}
} else {
$html = '';
ob_start();

/**
* Experimental changes only applied to the billing cycle objects otherwise work as usual
* */
if (isset($content->pagename)) {
$method_list = array('add', 'edit', 'delete', 'show', 'listing');
$sub = $main->get_variable('sub');
$sub = $main->get_variable('sub');
if (in_array($sub, $method_list)) {
$content->$sub();
} else {
$content->listing();
}
} else {
$content->content();
}
//$description = $content->description();

$html = ob_get_contents(); # Retrieve the HTML

ob_clean(); # Flush the HTML
} else {
$content->content();
}
}
} else {
$html = "You trying to hack me? You've been warned. An email has been sent.. May I say, Owned?";
Expand All @@ -187,23 +177,18 @@ function acp() {

$staffuser = $db->staff($main->getCurrentStaffId());

define("INFO", '<b>Welcome back, '. strip_tags($staffuser['name']) .'</b><br />');

$data['LEFT_COLUMN'] = $sidebar;
$data['RIGHT_COLUMN'] = '';
$data['SUBMENU'] = $content->get_submenu();
define("INFO", '<b>Welcome back, '. strip_tags($staffuser['name']) .'</b><br />');
$style->assign('sidebar', $sidebar);
$style->assign('sub_menu', $content->get_submenu());

if (!empty($content->content)) {
$style->assign('content', $content->content);
}

if (isset($header)) {
$data['HEADER'] = $header;
$data['RIGHT_COLUMN'] .= $html;
} else {
$data['RIGHT_COLUMN'] .= $html;
}
return $data; # Return the HTML
}

//If user is NOT log in
if (!isset($_SESSION['logged'])) {
if (!isset($_SESSION['logged'])) {
if (isset($main->getvar['page']) && $main->getvar['page'] == "forgotpass") {
define("SUB", "Reset Password");
define("INFO", SUB);
Expand Down Expand Up @@ -231,15 +216,14 @@ function acp() {
}
}
$content['CONTENT'] = '<div align="center">'.$main->table("Admin Area - Reset Password", $style->replaceVar("tpl/login/reset.tpl", $array), "300px").'</div>';
echo $style->get("tpl/layout/one-col/header.tpl");
echo $style->replaceVar("tpl/layout/one-col/content.tpl", $content);
echo $style->get("tpl/layout/one-col/footer.tpl");

} else {
define("SUB", "Login");
define("INFO", " ");
echo $style->replaceVar("layout/one-col/index.tpl", $content);


if ($_POST) { # If user submitts form
} else {
define("SUB", "Login");
define("INFO", " ");
if ($_POST) {
if ($main->checkToken()) {
if($main->staffLogin($main->postvar['user'], $main->postvar['pass'])) {
$main->redirect("?page=home");
Expand All @@ -248,13 +232,10 @@ function acp() {
$main->generateToken();
}
}
}

$content['CONTENT'] = $style->replaceVar("tpl/login/alogin.tpl", array());

echo $style->get("tpl/layout/one-col/header.tpl");
echo $style->replaceVar("tpl/layout/one-col/content.tpl", $content);

}
$login = $style->fetch("login/alogin.tpl");
$style->assign('content', $login);
echo $style->display("layout/one-col/index.tpl");
}
} elseif(isset($_SESSION['logged'])) {
//Ok user is already in
Expand All @@ -263,14 +244,13 @@ function acp() {
} elseif($main->getvar['page'] == "logout") {
$main->logout('admin');
$main->redirect("?page=home");
}

$content = acp();
echo $style->get("tpl/layout/two-col/header.tpl");
echo $style->replaceVar("tpl/layout/two-col/content.tpl", $content);
}

$content = acp();
echo $style->display("layout/two-col/index.tpl");
}

echo $style->get("tpl/layout/two-col/footer.tpl");

//End the script
require_once LINK ."output.php";
require_once INCLUDES."output.php";
7 changes: 3 additions & 4 deletions admin/pages/addons.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public function description() {
}

public function content() {
require_once LINK.'validator.class.php';


# Displays the page
global $main, $style, $db, $billing, $addon;

Expand Down Expand Up @@ -93,7 +92,7 @@ public function content() {
$array['MANDATORY'] = $main->createCheckbox('', 'mandatory');

//----- Finish billing cycle
echo $style->replaceVar("tpl/addons/add.tpl", $array);
echo $style->replaceVar("addons/add.tpl", $array);
break;
case 'view':
case 'edit':
Expand Down Expand Up @@ -181,7 +180,7 @@ public function content() {

//----- Finish billing cycle

echo $style->replaceVar('tpl/addons/edit.tpl', $array);
echo $style->replaceVar('addons/edit.tpl', $array);
}
} else {
$query = $db->query("SELECT * FROM <PRE>addons");
Expand Down
4 changes: 2 additions & 2 deletions admin/pages/billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function add() {
}
$array['NUMBER_MONTHS'] = $main->dropDown("number_months", $values, '');
$array['STATUS'] = $main->createCheckbox('', 'status');
echo $style->replaceVar("tpl/billing/add.tpl", $array);
echo $style->replaceVar("billing/add.tpl", $array);
}

public function edit() {
Expand Down Expand Up @@ -156,7 +156,7 @@ public function show() {
$array['number_months'] = $result->number_months;
$array['name'] = $result->name;
$array['status'] = ($result->status)? 'Active': 'Inactive';
echo $style->replaceVar("tpl/billing/show.tpl", $array);
echo $style->replaceVar("billing/show.tpl", $array);
}
}

Expand Down
2 changes: 1 addition & 1 deletion admin/pages/credits.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public function content() { # Displays the page
global $db;
global $main;

echo $style->replaceVar("tpl/credits.tpl");
echo $style->replaceVar("credits.tpl");
}
}
4 changes: 2 additions & 2 deletions admin/pages/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public function content() { # Displays the page
$array['TEMPLATES'] = $main->dropDown("LOL", $values, $selected_id, 0, 1);
$array['TEMPLATE_ID'] = $selected_id;

echo $style->replaceVar("tpl/email/emailtemplates.tpl", $array);
echo $style->replaceVar("email/emailtemplates.tpl", $array);
break;

case "mass": #mass emailer
echo $style->replaceVar("tpl/email/massemail.tpl");
echo $style->replaceVar("email/massemail.tpl");
break;
}
}
Expand Down
35 changes: 15 additions & 20 deletions admin/pages/home.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */

class page extends Controller {
/*public function curl_get_content($url="http://thehostingtool.com/updates/version.txt"){
$ch = curl_init();
Expand All @@ -19,15 +20,14 @@ class page extends Controller {
} */

public function content() {
global $db, $main, $style, $page, $server, $package;


global $db, $main, $style, $page, $server, $package;

//$current_version = rtrim($this->curl_get_content('http://thehostingtool.com/updates/version.txt')); #Clears the end whitespace. ARGHHH
$current_version = '1.3';

$running_version = $main->cleanwip($db->config('version'));
$install_check = $main->checkDir(LINK ."../install/");
$conf_check = $main->checkFilePermission(LINK ."conf.inc.php");
$install_check = $main->checkDir(INCLUDES ."../install/");
$conf_check = $main->checkFilePermission(INCLUDES ."conf.inc.php");

if ($current_version == $running_version){
$updatemsg = "<span style='color:green'>Up-To-Date</span>";
Expand Down Expand Up @@ -57,13 +57,11 @@ public function content() {
$stats['MULTI'] = $main->cleaninteger($db->config('multiple'));
$stats['UPDATE'] = $updatemsg;
$stats['UPG_BOX'] = $upgrademsg;
$stats_box = $style->replaceVar('tpl/dashboard/stats.tpl', $stats);
$stats_box = $style->replaceVar('dashboard/stats.tpl', $stats);

$cron = '<a href="'.$db->config('url').'includes/cron.php" target="_blank">Run cron here</a>';

$content = '<h2>Welcome to your Admin Dashboard!</h2>Welcome to the dashboard of your Admin Control Panel. In this area you can do the tasks that you need to complete such as manage servers, create packages, manage users.<br />
Here, you can also change the look and feel of your BNPanel Installation. If you require any help, be sure to ask at the <a href="http://www.beeznest.com" title="BNPanel Community is the official stop for BNPanel Support, Modules, Developer Center and more! Visit our growing community now!" class="tooltip">BNPanel Community</a>' .
'<br />'.$stats_box.$cron.'<br />';
$content = '<br />'.$stats_box.$cron.'<br />';

if ($_POST) {
foreach($main->postvar as $key => $value) {
Expand All @@ -81,7 +79,7 @@ public function content() {
}
}
$array['NOTEPAD'] = $db->resources('admin_notes');
$content_notepad = $style->replaceVar('tpl/notepad.tpl', $array);
$content_notepad = $style->replaceVar('notepad.tpl', $array);

$subdomain_list = $main->getSubDomains();

Expand Down Expand Up @@ -114,16 +112,13 @@ public function content() {
$todo_content .= $style->returnMessage(_('Your Server is in Test Mode, you can manually change <a href="?page=settings&sub=paths">here</a>'), 'warning');
}

// Todo/warning content
if (!empty($todo_content)) {
echo $main->table('Admin TODO List', $todo_content, 'auto', 'auto');
}
$style->assign('todo', $todo_content);
$style->assign('notepad', $content_notepad);


// Welcome message
echo $main->table('Welcome', $content, 'auto', 'auto');
$content = $style->fetch('admin/home.tpl');
$style->assign('content', $content);

//Notepad?
echo $main->table('Admin Notepad', $content_notepad, 'auto', 'auto');

//Lates commit?
Expand All @@ -141,12 +136,12 @@ public function content() {
} else {
$html= 'You can check the latest version here: https://bnpanel.googlecode.com/hg/';
}
echo $main->table('Test Server ', $style->returnMessage($html), 'auto', 'auto');
echo $style->returnMessage($html);
}

//RSS
/*
require_once(LINK.'rss/rss_fetch.inc');
require_once(INCLUDES.'rss/rss_fetch.inc');
$url = "http://thehostingtool.com/forum/syndication.php?fid=2&limit=3";
$rss = fetch_rss($url);
$news = $main->sub("<strong>Add the THT RSS Feed!</strong>", '<a href="http://thehostingtool.com/forum/syndication.php?fid=2" target="_blank" class="tooltip" title="Add the THT RSS Feed!"><img src="<URL>themes/icons/feed.png" /></a>');
Expand Down
4 changes: 2 additions & 2 deletions admin/pages/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public function content() { # Displays the page
global $db;
global $main;
global $type;
$files = $main->folderFiles(LINK ."import/");
$files = $main->folderFiles(INCLUDES ."import/");
foreach($files as $value) {
$link = LINK. "import/". $value;
$link = INCLUDES. "import/". $value;
$data = explode(".", $value);
if(file_exists($link)) {
include($link);
Expand Down
Loading

0 comments on commit 41d4969

Please sign in to comment.