本文整理汇总了PHP中Controller::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::instance方法的具体用法?PHP Controller::instance怎么用?PHP Controller::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Perform initial checks and load requested view
*
* @param string $url
* URL path of requested view
*/
public function load($url = null)
{
// Check for login
Controller::instance()->isLoggedIn();
if (!Controller::instance()->isLoggedIn()) {
$this->parseURL('/login');
} else {
try {
if (is_null($url)) {
// Get user's default section
$section_handle = Controller::instance()->User->default_section;
// If the section exists, load publish view
try {
$section = Section::loadFromHandle($section_handle);
$this->parseURL('/publish/' . $section_handle);
} catch (Exception $e) {
$this->parseURL('/blueprints/sections/');
}
} else {
$this->parseURL($url);
}
// TODO: Fix this
if (!$this instanceof AdministrationView) {
throw new Exception('View not found');
}
} catch (Exception $e) {
throw $e;
//catch the exception
print 'Sorry could not load ' . $url;
}
}
}
示例2: __construct
public function __construct()
{
$this->view = Controller::instance()->View;
$this->document = $this->view->document;
$this->url = Controller::instance()->url;
$this->setTitle();
}
示例3: postConstruct
/**
* This part has had to be outsourced from the Constructor,
* because the called Classes access the core and by
* that the Core::instance() method. Thus an endless recursion
* occured. because the instance is not already instantiated
*/
private function postConstruct()
{
$this->db = Grootdb::instance();
I18N::instance()->addFolder('i18n');
UserHandler::instance();
$this->controller = Controller::instance();
}
示例4: getInstance
function getInstance()
{
if (Controller::$instance === null) {
Controller::$instance = new Controller();
}
return Controller::$instance;
}
示例5: getInstance
/**
* Fetch instance of this class
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new Controller();
}
return self::$instance;
}
示例6: processRequests
public function processRequests()
{
if (isset($_POST['action'])) {
$actionParts = array_keys($_POST['action']);
$action = end($actionParts);
##Login Attempted
if ($action == 'login') {
if (!isset($_POST['username']) || strlen(trim($_POST['username'])) == 0) {
$this->invalid_credentials = true;
$this->missing_username = true;
}
if (!isset($_POST['password']) || strlen(trim($_POST['password'])) == 0) {
$this->invalid_credentials = true;
$this->missing_password = true;
} elseif (!Controller::instance()->login($_POST['username'], $_POST['password'])) {
$this->invalid_credentials = true;
} else {
if (isset($_POST['redirect'])) {
redirect(URL . str_replace(parse_url(URL, PHP_URL_PATH), NULL, $_POST['redirect']));
}
redirect(ADMIN_URL . '/');
}
}
}
}
示例7: getInstance
public static function getInstance()
{
if (self::$instance === false) {
self::$instance = new Controller();
}
return self::$instance;
}
示例8: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
$class = __CLASS__;
self::$instance = new $class();
}
return self::$instance;
}
示例9: __construct
public function __construct()
{
$this->view = Controller::instance()->View;
$this->document = $this->view->document;
$this->url = Controller::instance()->url;
// Probably a neater way to store and fetch the section handle
$this->section = Section::loadFromHandle($this->view->params[0]);
$this->setTitle();
}
示例10: process
public function process($config)
{
$controller = Controller::instance();
$view_key = $controller->getViewKey();
static::pushPath($controller->getViewUrl('home'), i('view_label_home'));
if ($view_key != 'home') {
static::pushPath($controller->getViewUrl(), i('view_label_' . $view_key));
}
}
示例11: instance
public function instance()
{
if (self::$instance != null) {
return self::$instance;
}
self::$instance = new Controller();
self::$instance->postConstruct();
return self::$instance;
}
示例12: _getShowCase
private function _getShowCase($genre, $page = 0, $size = 4)
{
$books = $this->_getBooksByGenre($genre, $page, $size);
$num_books = Core::instance()->getDb()->countBookyByGenre($genre);
if (count($books) == 0) {
return null;
}
$args = array('books' => $books, 'style' => 'showcase', 'text_details' => i('To the details'), 'navigation' => true, 'prev_hidden' => $num_books <= $size, 'next_hidden' => count($books) < $size, 'config' => urlencode(json_encode(array('page' => $page, 'size' => $size, 'request' => Controller::instance()->getViewUrl() . '&ajax=1&ajax_fn=nextShowcasePage&page={%page%}&size={%size%}&genre=' . $genre))));
return TemplateRenderer::instance()->extendedRender('theme/templates/snippets/showcase.html', $args);
}
示例13: __construct
public function __construct()
{
self::$instance = $this;
foreach (loaded() as $name => $class) {
$this->{$name} = load($class);
}
$this->view = load('View');
$this->load = load('Loader', 'system/core', NULL, 1);
$this->view->load = $this->load;
if (USE_AUTOLOAD) {
$this->autoload = load('Autoload', 'system/core', NULL, 0);
}
if (USE_LANG) {
$this->lang = load('Language');
$this->view->lang = $this->lang;
}
}
示例14: displayCart
public function displayCart()
{
$TID = 0;
if (sizeof($this->items) == 0) {
return i("Your shopping cart is empty.");
}
$table = "";
//Erstellen des HTML Contents, der von der displayCart() Funktion dann zurückgegeben wird
$table = "<p>" . i('Your shoppingcart contains') . ": " . sizeof($this->items) . " " . i('product(s)') . "</p>" . "<table id='shoppingTable'>" . "<tr id='tableTopics'>\n\t\t<td>" . i('isbn') . "</td>\n\t\t<td>" . i('Amount') . "</td>\n\t\t<td>" . i('Title') . "</td>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td>" . i('Price') . "</td>\n\t\t<td></td>";
/* Die Tabelle zur Anzeige der in den Korb gelegten Items wird aufbereitet. Der Remove Button wird hinter jeden Zeileneintrag mit der entsprechenden Post Variable
* gesetzt und die + und - Buttons werden angehängt
* Update 30.12: Anstatt meiner Lösung unten hätte ich besser die +/- Buttons auch schon bei der Generierung mit den Actions belegen sollen.
*/
foreach ($this->items as $index) {
$ID2del = $index->ID;
$list = BookModel::findList(array('isbn' => array($index->ID)), null);
$title = $list[0]['title'];
$price = $list[0]['price'];
$totPrice = $price * $index->amount;
$table = $table . "<tr id={$TID} onclick=''><td>{$index->ID}</td>\n\t\t\t<td>{$title}</td>\n\t\t\t<td name='amount'>{$index->amount}</td>\n\t \t \t<td>\n\t \t \t<input type='button' id='plusButton' value='+'></input></td>\n\t \t \t<td><input type='button' id='minusButton' value='-'></input></td>\n\t \t \t<td>{$totPrice}</td>\n\t \t \t<td><form action='" . Controller::instance()->getViewUrl('shoppingcart') . "&remove={$ID2del}' method='post'><input type='submit' value='" . i('Remove') . "'></input></form></td>\n\t \t \t</tr>";
$TID++;
$this->subTotal += $totPrice;
}
/*
* Totaler Wert des Warenkorbs
*/
$table = $table . "\n\t\t\t\t<tr>\n\t\t<td></td><td></td><td></td><td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td></td><td></td><td></td><td></td>\n\t\t<td>Sub Total:</td>\n\t\t<td>{$this->subTotal}</td>\n\t\t<td></td>\n\t\t</tr>";
/*
*
*/
$table = $table . "</table>\n\t \t\t\t<div class='action-wrapper'><form action='index.php?view=shoppingcart' method='post' class='clear-form'>\n\t \t\t\t<input type='submit' value='" . i('Empty cart') . "' class='button button-primary'></input>\n\t \t\t\t<input type='hidden' name='clearCart'></input></form>";
//Add Button go to payment
$table = $table . "\n\t\t\t\t<a href='index.php?view=payment' class='next'>\n <input class='button button-primary' type='button' value='" . i('Go to payment') . "'></input>\n </a></div>\n\t\t\t";
// Hier den JavascriptCode rein: Erhöhen liest Anzahl aus, zählt eins dazu und reloaded the page mit dem GET Paramter: &update=ID&Amount=NEUER AMOUNT
$table = $table . "\n\t \t\t\t<script type='text/javascript'>\n\n\t \t\t\tvar theTbl = document.getElementById('shoppingTable');\n\t \t\t\tvar rows = theTbl.rows;\n\n\t\t\t\tconsole.log(rows.length);\n\n\t\t\t\tfor(var i=0;i<rows.length;i++) {\n\n \t\t\t\t \t\t\tfor(var j=0;j<rows[i].cells.length;j++)\t{\n\t \t\t\t\t\t\tconsole.log('set');\n \t\t\t \t\t\t\trows[i].cells[j].onclick = alertInnerHTML;\n\t \t\t\t\t\t\t}\n\t\t\t\t}\n\n\t \t\t\trowIndex = 0;\n\n\t \t\t\tfunction myFunction(x) {\n\t \t\t\trowIndex = x.rowIndex\n\t \t\t\twindow.alert(rowIndex)\n\t\t\t\t}\n\n\n\n\t \t\t\tfunction alertInnerHTML(e) {\n \t\t\t\t\t e = e || window.event;//IE\n\t \t\t\t\trownumber = this.parentNode.id;\n\t \t\t\t\tcellNumber = this.cellIndex;\n\n\t \t\t\t\tconsole.log('Zeilennummer: '+rownumber + ' Spalte:' +cellNumber);\n\n\t \t\t\t\tif(cellNumber==3) {\n\t \t\t\t\tconsole.log('increase');\n\t \t\t\t\tincrease(rownumber);\n\t \t\t\t\t}\n\n\t \t\t\t\tif(cellNumber==4) {\n\t \t\t\t\tdecrease(rownumber);\n\t \t\t\t\t}\n\n\t \t\t\t\t}\n\n\t \t\t \tfunction increase(rownumber) {\n\t\t\t\trownumber++;\n\t \t\t\tvar table = document.getElementById('shoppingTable');\n\t\t\t\tproductID = table.rows[rownumber].cells[0].innerHTML;\n\t \t\t\twindow.open('index.php?view=shoppingcart&action=mod&id2Change='+productID+'&change=up','_self')\n\n\t \t\t\t}\n\n\t \t\t\tfunction decrease(rownumber) {\n\t\t\t\trownumber++;\n\t \t\t\tvar table = document.getElementById('shoppingTable');\n\t\t\t\tproductID = table.rows[rownumber].cells[0].innerHTML;\n\n\t\t\t\twindow.open('index.php?view=shoppingcart&action=mod&id2Change='+productID+'&change=down','_self')\n\t \t\t\treturn false;\n\t \t\t\t}\n\n\n\n\t \t</script>";
return $table;
}
示例15: makeMenu
public function makeMenu()
{
#label of selectbox
$selectName = "cat";
$divId = "logo";
$classIcon = "stdanimation1_4";
$grootLogoChar = "G";
//Build html
$html = "";
$selectBox = GenreModel::getTranslatedGenres();
array_unshift($selectBox, array('value' => '', 'label' => i('All')));
$cat = isset($_REQUEST['cat']) ? htmlspecialchars($_REQUEST['cat']) : null;
//build the select html element
$selectBoxHtml = Utilities::buildSelectbox($selectBox, $selectName, $cat);
//Logo
$html .= '
<a href="index.php?view=home">
<div id="' . $divId . '">
<span class="' . $classIcon . '">' . $grootLogoChar . '</span>
</div>
</a>
';
$query_val = isset($_REQUEST['query']) ? htmlspecialchars($_REQUEST['query']) : '';
//Searchbar
$html .= '<form id="search" method="GET">
' . $selectBoxHtml . '
<input type="hidden" name="view" value="search" />
<input type="text" name="query" id="query" value="' . $query_val . '" autocomplete="off"/>
<button type="submit" name="search" value="search">' . i("Search") . '</button>
</form>';
//Build up all the navigation points from an array
$naviElement = "";
$current_view_url = Controller::instance()->getViewUrl();
foreach (I18n::availableLanguages() as $lang) {
$naviArray[] = array("link" => $current_view_url . '&lang=' . $lang, "icon" => "", "cls" => $lang == I18n::lang() ? 'active' : '', "label" => strtoupper($lang));
}
//create HTML elements for each navi point
foreach ($naviArray as $navi) {
$navi['label'] = i($navi['label']);
$naviElement .= '<li class="' . $navi['cls'] . '"><a class="stdanimation1_2" href="' . $navi["link"] . '">' . $navi["label"] . '</a></li>';
}
$html .= '<ul class="menu menu-main">
' . $naviElement . '
</ul>';
//Deside, if user is logged in or not and change appearance
if (UserHandler::instance()->loggedin()) {
$mask_cls = 'loggedin';
$buttons = '<input type="submit" class="button" name="Logout" value="Logout">';
//getting the values from the protected data array via class.basemodel
if (UserHandler::instance()->user()) {
$firstName = UserHandler::instance()->user()->getValue('first_name');
$lastName = UserHandler::instance()->user()->getValue('last_name');
} else {
$firstName = "";
$lastName = "";
}
$greeting = i('Hello');
$loginMask = $greeting . ' ' . $firstName . ' ' . $lastName;
} else {
$mask_cls = 'loggedout';
$buttons = '<input type="submit" class="button" name="Login" value="Login"/>';
$loginMask = '<div><label for="Loginname">' . i("User") . ':</label><input class="" name="Loginname" /> </div>
<div><label for="Password">' . i("Password") . ':</label><input class="" type="password" name="Password" /> </div>';
}
$html .= '<div class="login-mask ' . $mask_cls . '">
<form action="" method="POST">
<div class="mask">' . $loginMask . '</div>
<div class="buttons">' . $buttons . '</div>
</form>
</div>';
return $html;
}