本文整理汇总了PHP中Application::template方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::template方法的具体用法?PHP Application::template怎么用?PHP Application::template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application::template方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error
private function error($errors)
{
Application::$template = false;
header("Content-Type: application/json");
echo json_encode(array('error' => $errors));
die;
}
示例2: getContents
public function getContents()
{
User::log("Logged out");
$_SESSION = array();
Application::$template = "login.tpl";
Application::redirect("/");
}
示例3: getContents
public function getContents()
{
User::log("Logged out");
$_SESSION = array();
header("Location: " . Application::getLink("/"));
Application::$template = "login.tpl";
return "You have been logged out.";
}
示例4: get
public function get($params)
{
ntentan\logger\Logger::info("Reading Notifications " . print_r($_SESSION['notifications'], true));
Application::$template = false;
header('Content-Type: application/json');
$response = json_encode($_SESSION['notifications']);
$_SESSION['notifications'] = array();
return $response;
}
示例5: __construct
public function __construct()
{
if (substr($_REQUEST["q"], 0, 10) == "system/api") {
Application::$template = "";
}
$this->format = isset($_REQUEST["__api_format"]) ? $_REQUEST["__api_format"] : $this->format;
unset($_REQUEST["__api_format"]);
unset($_REQUEST["q"]);
if ($_SESSION["logged_in"] == false && $_GET["q"] != "system/api/login") {
print $this->format(array("success" => false, "status" => 101, "message" => "Not authenticated"));
die;
}
}
示例6: getContents
/**
* The default page which shows the login form.
* @see lib/controllers/Controller#getContents()
*/
public function getContents()
{
Application::addStylesheet("css/login.css");
Application::$template = "login.tpl";
Application::setTitle("Login");
if ($_SESSION["logged_in"]) {
Application::redirect(Application::getLink("/"));
}
$form = new Form();
$form->setRenderer("default");
$username = new TextField("Username", "username");
$form->add($username);
$password = new PasswordField("Password", "password");
$form->add($password);
$form->setSubmitValue("Login");
$form->setCallback("{$this->getClassName()}::callback", $this);
return $form->render();
}
示例7: __construct
public function __construct()
{
ini_set('html_errors', 'Off');
if (substr($_REQUEST["q"], 0, 10) == "system/api") {
Application::$template = "";
}
$this->format = isset($_REQUEST["__api_format"]) ? $_REQUEST["__api_format"] : $this->format;
unset($_REQUEST["__api_format"]);
unset($_REQUEST["q"]);
if (isset($_REQUEST['__api_key']) && isset($_REQUEST['__api_signature'])) {
foreach ($_POST as $key => $value) {
$aggregatedKey .= $key . substr($_POST[$key], 0, 15);
}
foreach ($_GET as $key => $value) {
if ($key == '__api_key' || $key == '__api_signature' || $key == '__api_format' || $key == '__api_session_id' || $key == 'q') {
continue;
}
$aggregatedKey .= $key . substr($_GET[$key], 0, 15);
}
try {
@($apiKey = reset(Model::load('system.api_keys')->setQueryResolve(false)->getWithField2('key', $_REQUEST['__api_key'])));
if ($apiKey['active'] == 't') {
$signature = sha1($aggregatedKey . $apiKey['secret']);
if ($signature == $_GET['__api_signature']) {
$_SESSION['logged_in'] = true;
$_SESSION['user_id'] = $apiKey['user_id'];
}
}
} catch (Exception $e) {
print $this->format(array("success" => false, "message" => $e->getMessage()));
die;
}
}
if ($_SESSION["logged_in"] == false && $_GET["q"] != "api/login") {
print $this->format(array("success" => false, "status" => 101, "message" => "Not authenticated"));
die;
}
}
示例8: getContents
public function getContents()
{
// if(Configuration::get('attempt_counter') == null || Configuration::get('attempt_counter') === '0')
// {
// Configuration::set('attempt_counter',0);
// }
Application::addStylesheet("css/login.css");
Application::$template = "login.tpl";
Application::setTitle("Login");
if ($_SESSION["logged_in"]) {
Application::redirect("/");
}
$form = new Form();
$form->setRenderer("default");
$username = new TextField("Username", "username");
$form->add($username);
$password = new PasswordField("Password", "password");
$password->setEncrypted(false);
$form->add($password);
$form->setSubmitValue("Login");
$form->setValidatorCallback("{$this->getClassName()}::callback");
$form->setShowClear(false);
return $form->render();
}
示例9: render
/**
* Outputs the application. This calls all the template files and outputs the
* final application in HTML.
*/
public static function render()
{
$t = Application::$templateEngine;
if ($_GET["q"] == "") {
$_GET["q"] = "dashboard";
}
$path = explode("/", $_GET["q"]);
Application::$template = "main.tpl";
require SOFTWARE_HOME . "app/bootstrap.php";
$t->assign('prefix', Application::$prefix);
Application::setTitle();
$module = Controller::load($path);
if (Application::$cli) {
ob_start();
}
if (Application::$template == "") {
print $module->content;
} else {
$t->assign('content', $module->content);
$t->assign('module_name', $module->label);
$t->assign('module_description', $module->description);
foreach (array_keys(Application::$menus) as $key) {
$t->assign($key, Menu::getContents($key));
}
$t->assign('stylesheets', Application::$stylesheets);
$t->assign('styles', $t->fetch('stylesheets.tpl'));
$t->assign('javascripts', Application::$javascripts);
$t->assign('scripts', $t->fetch('javascripts.tpl'));
$t->assign('title', Application::$title);
$t->display(Application::$template);
}
if (Application::$cli) {
if (Application::$cliOutput == "") {
print ob_get_clean();
} else {
file_put_contents(Application::$cliOutput, ob_get_clean());
}
}
}
示例10: render
/**
* Outputs the application. This method is the final stage in the application
* lifecyle which calls all the template files and outputs the
* final application in HTML.
*/
public static function render()
{
$t = Application::$templateEngine;
if ($_GET["q"] == "") {
$_GET["q"] = Application::$defaultRoute;
}
$path = explode("/", $_GET["q"]);
Application::$template = "main.tpl";
$t->assign('prefix', Application::$prefix);
Application::setTitle();
$module = Controller::load($path);
if (Application::$cli) {
ob_start();
}
if (Application::$template == "") {
print $module->content;
} else {
$t->assign('content', $module->content);
$t->assign('module_name', $module->label);
$t->assign('module_description', $module->description);
$t->assign('side_menu_hidden', self::$sideMenuHidden);
foreach (array_keys(Application::$menus) as $key) {
$t->assign($key, Menu::getContents($key));
}
$t->assign('stylesheets', Application::$stylesheets);
$t->assign('styles', $t->fetch('stylesheets.tpl'));
$t->assign('javascripts', Application::$javascripts);
$t->assign('scripts', $t->fetch('javascripts.tpl'));
$t->assign('title', Application::$title);
$t->assign('session', $_SESSION);
$t->assign('info', array_merge(is_array($_SESSION['notes']) ? $_SESSION['notes'] : array(), self::$notes));
$t->display(Application::$template);
}
if (Application::$cli) {
if (Application::$cliOutput == "") {
print ob_get_clean();
} else {
file_put_contents(Application::$cliOutput, ob_get_clean());
}
}
}
示例11: __construct
/**
* Constructor for the ModelController.
* @param $model An instance of the Model class which represents the model
* to be used.
*/
public function __construct($model = "")
{
global $redirectedPackage;
$this->modelName = $this->modelName == "" ? $model : $this->modelName;
$this->model = Model::load($this->modelName);
$this->name = $this->model->name;
$this->t = $t;
$this->path = $path;
$this->urlBase = $this->urlBase == '' ? ($redirectedPackage != '' ? "{$redirectedPackage}" : '') . $this->modelName : $this->urlBase;
$this->urlPath = Application::$prefix . "/" . str_replace(".", "/", $this->urlBase);
$this->permissionPrefix = $redirectedPackage . str_replace(".", "_", $this->modelName);
$this->localPath = "app/modules/" . str_replace(".", "/", $this->urlBase);
if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' || $_REQUEST["__api_mode"] == "yes") {
Application::$template = "";
$this->apiMode = true;
unset($_REQUEST["__api_mode"]);
unset($_REQUEST["q"]);
} else {
$this->label = $this->model->label;
$this->description = $this->model->description;
Application::setTitle($this->label);
$this->toolbar = new Toolbar();
$this->table = new MultiModelTable(Application::$prefix . "/" . str_replace(".", "/", $this->urlBase) . "/");
$this->table->useAjax = true;
}
$this->_showInMenu = $this->model->showInMenu == "false" ? false : true;
if (file_exists($this->localPath . "/app.xml")) {
$this->app = simplexml_load_file($this->localPath . "/app.xml");
}
}
示例12: makeSourceResponse
{
if (!in_array($field, $existFields) || !isset($query)) {
return [];
}
return makeSourceResponse($source::retrieveByField($field, "%" . urldecode($query) . "%", SimpleOrm::FETCH_MANY));
}
// главная страница
Macaw::get('/', function () {
Application::sendHTMLString(Application::template(dirname(__FILE__) . "/templates/index.html", ['user' => checkAuth()]));
});
Macaw::get('/sign', function () {
$user = getUser();
if ($user) {
redirect("/");
} else {
Application::sendHTMLString(Application::template(dirname(__FILE__) . "/templates/signin.html", []));
}
});
Macaw::post('/sign', function () {
$user = getUser();
if ($user) {
redirect("/");
} else {
$gump = new GUMP();
$data = $gump->sanitize($_POST);
$gump->validation_rules(array('password' => 'required', 'username' => 'required'));
$validated_data = $gump->run($data);
if ($validated_data && authUser($validated_data['username'], $validated_data['password'])) {
redirect("/");
} else {
redirectToLogin();
示例13: render
/**
* Outputs the application. This method is the final stage in the application
* lifecyle which calls all the template files and outputs the
* final application in HTML.
*/
public static function render()
{
$t = Application::$templateEngine;
if ($_GET["q"] == "") {
$_GET["q"] = Application::$defaultRoute;
}
$path = explode("/", $_GET["q"]);
Application::$template = "main.tpl";
$t->assign('prefix', Application::$prefix);
Application::setTitle();
$module = Controller::load($path);
if (Application::$cli) {
ob_start();
}
if (Application::$template == "" || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
header("x-controller-label: {$module->label}");
header("x-controller-description: {$module->description}");
echo $module->content;
} else {
$t->assign('content', $module->content);
$t->assign('module_name', $module->label);
$t->assign('module_description', $module->description);
$t->assign('side_menu_hidden', self::$sideMenuHidden);
foreach (array_keys(Application::$menus) as $key) {
$t->assign($key, Menu::getContents($key));
}
$t->assign('stylesheets', Application::$stylesheets);
$t->assign('styles', $t->fetch('stylesheets.tpl'));
$t->assign('javascripts', Application::$javascripts);
$t->assign('scripts', $t->fetch('javascripts.tpl'));
$t->assign('title', Application::$title);
$t->assign('session', $_SESSION);
$t->assign('info', array_merge(is_array($_SESSION['notes']) ? $_SESSION['notes'] : array(), self::$notes));
$t->display(Application::$template);
}
}