本文整理汇总了PHP中runner::stack方法的典型用法代码示例。如果您正苦于以下问题:PHP runner::stack方法的具体用法?PHP runner::stack怎么用?PHP runner::stack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类runner
的用法示例。
在下文中一共展示了runner::stack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
/**
* Created by PhpStorm.
* User: csibi
* Date: 2014.10.23.
* Time: 16:23
*/
$context = $runner->context;
$tree = \runner::stack('tree');
$branch = \Routerunner\Helper::tree_route($tree, $context['route']);
$accept = array();
if ($branch = \Routerunner\Helper::tree_route($tree, $context['route'])) {
$accept = $branch;
}
$runner->context['accept'] = $accept;
if ($runner->model) {
$runner->model->accept = $accept;
}
$debug = 1;
示例2: SQL_creator
private static function SQL_creator($select, $from, $primary_key, $leftJoin = array(), $where = array(), &$params = array(), $orderBy = false, $groupBy = false, $limit = false, $offset = false)
{
$ordering = $orderBy;
$parents = \runner::stack("parents");
if (!$parents) {
$parents = array();
}
$prevs = \runner::stack("prevs");
if (!$prevs) {
$prevs = array();
}
$strict = false;
$skip_state = false;
$by_tree = false;
$by_index = false;
if ($orderBy === \Routerunner\Routerunner::BY_TREE || $orderBy === \Routerunner\Routerunner::BY_TREE_DESC || $orderBy === \Routerunner\Routerunner::BY_INDEX || $orderBy === \Routerunner\Routerunner::BY_INDEX_DESC || isset($where["direct"]) && $where["direct"] || isset($where["parent"]) && $where["parent"] || isset($where["self"]) && $where["self"] || isset($where["lang"]) && $where["lang"]) {
$tree = array();
$params = array();
if (isset($where["direct"]) && is_numeric($where["direct"])) {
$SQL = 'SELECT models.reference, NULL AS parent_ref, NULL AS prev, table_from, table_id ' . PHP_EOL;
$SQL .= 'FROM {PREFIX}models AS models ' . PHP_EOL;
$SQL .= 'WHERE models.reference = :reference';
$params = array(":reference" => $where["direct"]);
$strict = true;
$skip_state = true;
$by_tree = true;
} elseif (isset($where["direct"]) && is_array($where["direct"])) {
$SQL = 'SELECT models.reference, NULL AS parent_ref, NULL AS prev, table_from, table_id ' . PHP_EOL;
$SQL .= 'FROM {PREFIX}models AS models ' . PHP_EOL;
$SQL .= 'WHERE models.model_class = :class AND models.table_id = :id';
if (is_numeric(current($where["direct"]))) {
$params = array(":class" => key($where["direct"]), ":id" => current($where["direct"]));
} else {
$params = array(":class" => current($where["direct"]), ":id" => key($where["direct"]));
}
$strict = true;
$skip_state = true;
$by_tree = true;
} else {
$where_reference = array();
// get self reference
if ($self_reference = self::resolve_model_reference('self', $where, true)) {
$where_reference['model_traverse.reference IN (' . implode(',', $self_reference) . ')'] = null;
$strict = true;
$skip_state = true;
$by_tree = true;
}
// get parent reference
if ($parent_reference = self::resolve_model_reference('parent', $where, true)) {
$where_reference['model_traverse.parent_ref IN (' . implode(',', $parent_reference) . ')'] = null;
$strict = true;
$skip_state = true;
$by_tree = true;
}
// get lang condition
if ($lang = self::resolve_model_reference('lang', $where, true)) {
$where_reference['model_traverse.lang IN (' . implode(',', $lang) . ')'] = null;
$strict = true;
$skip_state = true;
}
if (!$where_reference && $where) {
$SQL_reference = "SELECT models.reference FROM `" . $from . "` AS model_table " . PHP_EOL . "LEFT JOIN `" . $from . "` ON `" . $from . "`.`" . $primary_key . "` = model_table.`" . $primary_key . "`" . PHP_EOL . "LEFT JOIN `{PREFIX}models` AS models ON models.table_from = '" . $from . "' AND models.table_id = model_table.`" . $primary_key . "`" . PHP_EOL . " WHERE ";
$conds_reference = array();
$params_reference = array();
foreach ($where as $cond_reference => $param_reference) {
$conds_reference[] = preg_replace("~(:[a-z0-9\\-_\\.]+)~i", "?", $cond_reference);
if (!is_null($param_reference)) {
$params_reference[] = $param_reference;
}
}
$SQL_reference .= implode(" AND ", $conds_reference);
if ($result_reference = \db::query($SQL_reference, $params_reference)) {
$row_reference = array_shift($result_reference);
$reference_for_parent = $row_reference["reference"];
if (($parent_obj = \Routerunner\Bootstrap::parent($reference_for_parent)) && count($parent_obj)) {
$parent_obj = array_pop($parent_obj);
$parent_reference = $parent_obj["reference"];
$where_reference['model_traverse.parent_ref IN (' . $parent_reference . ')'] = null;
}
$strict = true;
$skip_state = true;
}
}
if ($orderBy === \Routerunner\Routerunner::BY_TREE || $orderBy === \Routerunner\Routerunner::BY_TREE_DESC) {
// get previous sibling
$prev_reference = self::resolve_model_reference('prev', $where, true);
if ($prev_reference !== false) {
$where_reference['model_traverse.prev_ref IN (' . implode(',', $prev_reference) . ')'] = null;
$strict = true;
$skip_state = true;
}
// get next sibling
// todo: check --- is it ok?
$next_reference = self::resolve_model_reference('next', $where, true);
if ($next_reference !== false) {
$where_reference['model_traverse.prev_ref IN (SELECT reference FROM {PREFIX}model_trees WHERE prev_ref IN (' . implode(',', $next_reference) . '))'] = null;
$strict = true;
$skip_state = true;
}
}
//.........这里部分代码省略.........
示例3: set
private static function set($user = null, $logout = false)
{
if (is_null($user)) {
// logout user
self::$me = false;
self::$email = null;
self::$name = null;
self::$group = null;
self::$scope = null;
self::$auth = null;
self::$custom = array();
self::$alias = 0;
self::close_token(self::$token);
if ($logout) {
$flash_var = \runner::config('User.UserFlashVar') ? \runner::config('User.UserFlashVar') : 'UserFlashVar';
if (isset($_SESSION['routerunner-logout-' . $flash_var]) && $_SESSION['routerunner-logout-' . $flash_var] === true) {
$cookie = \runner::config('User.TokenCookie') ? \runner::config('User.TokenCookie') : 'TokenCookie';
\Routerunner\Routerunner::$slim->setCookie($cookie, null, -1, '/');
$flash_var = \runner::config('User.UserFlashVar') ? \runner::config('User.UserFlashVar') : 'UserFlashVar';
\runner::now($flash_var, false);
\runner::stack($flash_var, false);
\runner::flash($flash_var, false);
unset($_SESSION['slim.flash'][$flash_var]);
setcookie($cookie, null, -1, '/');
unset($_COOKIE[$cookie]);
unset($_SESSION['routerunner-logout-' . $flash_var]);
} else {
$_SESSION['routerunner-logout-' . $flash_var] = true;
}
}
} elseif (isset($user) && !is_null($user) && is_array($user)) {
self::set();
// clear user if exists
$flash_var = \runner::config('User.UserFlashVar') ? \runner::config('User.UserFlashVar') : 'UserFlashVar';
if (\runner::now($flash_var)) {
$flash = \runner::now($flash_var);
} elseif (\runner::stack($flash_var)) {
$flash = \runner::stack($flash_var);
} else {
$flash = \runner::flash($flash_var);
}
$array_to_translate = \runner::config('User.UserArrayToTranslate') ? \runner::config('User.UserArrayToTranslate') : array();
if ($flash === $user) {
foreach ($user as $key => $value) {
$var = isset($array_to_translate[$key]) ? $array_to_translate[$key] : $key;
if ($var === 'email' || $var === 'name' || $var === 'alias') {
self::${$var} = $value;
} else {
self::$custom[$var] = $value;
}
}
if (self::get_user()) {
self::open_token();
self::set_session_token();
}
}
}
}
示例4: prepareLoader
public static function prepareLoader($route, $class, $version = false, &$path = false, &$file = false, $scaffolded = false, $created = false, $router = false)
{
$route = substr($route, 0, 1) !== DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR . $route : $route;
if ($router && $router->scaffold_root && $router->scaffold_root != \Routerunner\Routerunner::$slim->config('templates.path')) {
\Routerunner\Routerunner::$slim->config('templates.path', str_replace(\runner::config("SITEROOT"), '', $router->scaffold_root));
}
$path = realpath($router->scaffold_root . $route) . DIRECTORY_SEPARATOR;
$model_class = substr($route, strrpos($route, DIRECTORY_SEPARATOR) + 1);
if ($file) {
if (substr($file, 0, strlen($model_class) + 1) != $model_class . ".") {
$file = $model_class . "." . $file;
}
} else {
if (strpos($class, DIRECTORY_SEPARATOR) !== false) {
$file = substr($class, strrpos($class, DIRECTORY_SEPARATOR) + 1) . (substr($class, -1) == '.' ? '' : '.') . 'php';
} elseif (substr($class, 0, strlen($model_class)) === $model_class) {
$file = $class . (substr($class, -1) == '.' ? '' : '.') . 'php';
} else {
$file = $model_class . '.' . $class . (substr($class, -1) == '.' ? '' : '.') . 'php';
}
}
$versionroute = '';
if ($version) {
if (!is_array($version)) {
$version = array($version);
}
while (($version_row = array_shift($version)) && !$versionroute) {
$directory = $path . $version_row;
if (file_exists($directory)) {
$versionroute = $version_row . DIRECTORY_SEPARATOR;
}
}
}
if (\runner::config("mode") == "backend" && file_exists($path . $versionroute . 'backend' . DIRECTORY_SEPARATOR)) {
$backendroute = 'backend' . DIRECTORY_SEPARATOR;
if (!$created && \runner::stack("model_create")) {
$created = \runner::stack("model_create");
}
if ($created && file_exists($path . $versionroute . $backendroute . "create" . DIRECTORY_SEPARATOR . $file)) {
$versionroute = $versionroute . $backendroute . "create" . DIRECTORY_SEPARATOR;
} elseif (file_exists($path . $versionroute . $backendroute . $file)) {
$versionroute = $versionroute . $backendroute;
}
}
$model_root = $router->scaffold_root . DIRECTORY_SEPARATOR . "model" . DIRECTORY_SEPARATOR . $model_class . DIRECTORY_SEPARATOR;
if (file_exists($path . $versionroute . $file)) {
if ($scaffolded) {
return str_replace($router->scaffold_root, '', $path) . $versionroute . $file;
} else {
return $path . $versionroute . $file;
}
} elseif (file_exists($model_root . $file)) {
if ($scaffolded) {
return str_replace($router->scaffold_root, '', $model_root) . $file;
} else {
return $model_root . $file;
}
} else {
return false;
}
}
示例5:
<?php
$class = \runner::stack("testimonial_index") === 0 ? " active" : "";
\runner::stack("testimonial_index", \runner::stack("testimonial_index") + 1);
?>
<div class="item testimonial-item<?php
echo $class;
?>
">
<p class="citation"><?php
echo \model::property("brief");
?>
</p>
<p class="author"><span class="name"><?php
echo \model::property("label");
?>
</span> / <span class="position"><?php
echo \model::property("position");
?>
</span> / <span class="company"><?php
echo \model::property("company");
?>
</span></p>
</div>
示例6:
<?php
/**
* Created by PhpStorm.
* User: csibi
* Date: 2014.10.23.
* Time: 16:23
*/
\runner::stack("session_id", false, true);
示例7: array_merge
$fields = array_merge($fields, $root_router->runner->backend_context["model"]["fields"]);
}
foreach ($fields as $field_name => $field_data) {
if (isset($field_data["crop"])) {
$crops[$field_name] = $field_data["crop"];
}
}
$field_data = $fields[$field];
}
$parents = \Routerunner\Bootstrap::parent($reference);
if (isset($parents[0]["model_class"]) && $parents[0]["model_class"] == "lang") {
$lang = array_shift($parents);
}
$path_route = '';
while ($parent = array_shift($parents)) {
$_model_context = array("direct" => $parent["reference"], "session" => \runner::stack("session_id"));
$router = false;
$route = '/model/' . $parent["model_class"];
\runner::redirect_route($route, \runner::config("scaffold"), true, $_model_context, $router, $parent_model);
if (is_array($parent_model) && count($parent_model) == 1) {
$parent_model = array_shift($parent_model);
}
if (isset($parent_model) && is_object($parent_model) && get_parent_class($parent_model) == "Routerunner\\BaseModel" && isset($parent_model->label)) {
$path_route .= \runner::toAscii($parent_model->label) . DIRECTORY_SEPARATOR;
}
$debug = 1;
}
if (isset($value["src"])) {
// crop image
$src = $_SESSION["runner_config"]['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $_SESSION["runner_config"]["SITEROOT"] . $value["src"];
$filename = substr($value["src"], strrpos($value["src"], DIRECTORY_SEPARATOR) + 1);
示例8: array_merge
* User: csibi
* Date: 2014.10.20.
* Time: 10:33
*/
require '../../../Routerunner/Routerunner.php';
use Routerunner\Routerunner as runner;
$post = array_merge($_GET, $_POST);
new runner(array('mode' => 'backend', 'params' => $post, 'method' => 'post', 'resource' => '/', 'bootstrap' => false), function () use($post) {
$response = array("success" => false, "apply" => false, "change_id" => false, "error" => array());
$SQL = "CALL {PREFIX}change_get(:change_id, :session, :draft, :applied)";
$params = array(":change_id" => is_numeric($post["change_id"]) ? $post["change_id"] : null, ":session" => \runner::stack("session_id") ? \runner::stack("session_id") : null, ":draft" => 1, ":applied" => 0);
if ($change_get = \db::query($SQL, $params)) {
foreach ($change_get as $change) {
$response["change_id"] = $change["change_id"];
$SQL_apply = "CALL `{PREFIX}change_apply`(:change_id, :session)";
$params_apply = array(":change_id" => $change["change_id"], ":session" => \runner::stack("session_id") ? \runner::stack("session_id") : 0);
if ($change["state"] == "routerunner-page-properties" && ($changes = json_decode($change["changes"], true)) && ($resource = json_decode($change["resource"], true))) {
foreach ($changes as $field => $value) {
switch ($field) {
case "url":
case "urls":
$condition = array();
$params = array();
if (isset($resource["reference"]) && $resource["reference"]) {
$condition['reference'] = '`reference` = :reference';
$params[":reference"] = $resource["reference"];
}
if (isset($resource["resource_uri"]) && $resource["resource_uri"]) {
$condition['resource_uri'] = '`resource_uri` = :resource_uri';
$params[":resource_uri"] = $resource["resource_uri"];
}
示例9:
<?php
\runner::stack("testimonial_index", 0);
?>
<h2 class="section-title" data-animate="fadeInDown">Testimonials</h2>
<div id="carousel-testimonials" class="carousel-testimonials carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner text-center testimonials">
示例10: array
}
\runner::stack("model_create", false);
$models_created = \runner::stack("models_created");
if (!$models_created) {
$models_created = array();
}
$parent = array();
if (isset($post["parent"])) {
$parents = \Routerunner\Bootstrap::parent($post["parent"]);
foreach ($parents as $cur_parent) {
$parent[] = $cur_parent["reference"];
}
$parent[] = $post["parent"];
}
$models_created[$model->reference] = array("class" => $model->class, "route" => $model->route, "table_from" => $model->table_from, "table_id" => $model->table_id, "backend_ref" => $model->backend_ref, "parent" => $parent, "permission" => $model->permission);
\runner::stack("models_created", $models_created, true);
$return['success'] = true;
if (isset($model->reference)) {
$return['reference'] = $model->reference;
$return['model'] = $model;
} elseif (is_array($model) && count($model) == 1) {
$return['reference'] = $model[0]->reference;
$return['model'] = $model[0];
} elseif (is_array($model) && count($model) > 1) {
$return['reference'] = array();
foreach ($model as $row) {
if (isset($row->reference)) {
$return['reference'][] = $row->reference;
}
}
$return['model'] = $model;
示例11: array
<?php
/**
* Created by PhpStorm.
* User: csibi
* Date: 2014.10.23.
* Time: 16:23
*/
$runner->backend_context['parents'] = \Routerunner\Bootstrap::parent($runner->context['reference']);
$current = $runner->context['reference'];
$runner->backend_context['siblings'] = \Routerunner\Bootstrap::siblings($runner->context['reference'], false, $current);
$runner->backend_context['current'] = $runner->backend_context['siblings'][$current];
$parents_ref = array();
foreach ($runner->backend_context['parents'] as $parent) {
$parents_ref[] = $parent['reference'];
}
$runner->backend_context['parents_ref'] = $parents_ref;
\runner::stack('traverse', $runner->backend_context);
示例12: elseif
$model->{$attr} = $value;
}
$new_model = true;
}
$tree = \runner::stack('tree');
$route = false;
if ($branch = \Routerunner\Helper::tree_route($tree, $context['route'])) {
if (isset($branch['children']['#' . $context['reference']])) {
$route = '#' . $context['reference'];
} elseif (isset($branch['children'][$context['model_class'] . '/' . $context['table_id']])) {
$route = $context['model_class'] . '/' . $context['table_id'];
} elseif (isset($branch['children'][$context['model_class']])) {
$route = $context['model_class'];
}
}
$traverse = \runner::stack('traverse');
if ($route) {
$context['route'][] = $route;
if ($node = \Routerunner\Helper::tree_route($tree, $context['route'])) {
$parsed = \Routerunner\Helper::parse_array($node, $model, array("children"));
$jstree = array('type' => $context['model_class']);
if ($new_model) {
$jstree['icon'] = 'fa fa-folder icon-state-warning';
} elseif (isset($parsed['icon'])) {
$jstree['icon'] = $parsed['icon'];
}
if (isset($traverse['current']['reference']) && $traverse['current']['reference'] == $context['reference']) {
$jstree['selected'] = true;
}
$classes = array();
// todo: or children in memory
示例13: header
<?php
/**
* Created by PhpStorm.
* User: csibi
* Date: 2014.10.20.
* Time: 10:33
*/
header('Content-Type: application/json');
require '../../../Routerunner/Routerunner.php';
use Routerunner\Routerunner as runner;
$post = array_merge($_GET, $_POST);
new runner(array('mode' => 'backend', 'params' => $post, 'method' => 'post', 'resource' => '/', 'bootstrap' => false), function () use($post) {
$response = array("success" => false, "change_id" => false);
$SQL = "CALL {PREFIX}change_log(:change_id, :session, :reference, :resource, :changes, :state)";
$params = array(":change_id" => is_numeric($post["change_id"]) ? $post["change_id"] : 0, ":session" => \runner::stack("session_id"), ":reference" => is_numeric($post["reference"]) ? $post["reference"] : 0, ":resource" => json_encode($post["resource"]), ":changes" => json_encode($post["changes"]), ":state" => $post["state"]);
if ($result = \db::query($SQL, $params)) {
$response["success"] = true;
$response["change_id"] = $result[0]["change_id"];
$response["date"] = $result[0]["date"];
$response["state"] = $result[0]["state"];
}
echo json_encode($response);
});
示例14:
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<?php
for ($i = 0; $i < \runner::stack("testimonial_index"); $i++) {
$class = $i == 0 ? ' class="active"' : '';
echo ' <li data-target="#carousel-testimonials" data-slide-to="' . $i . '"' . $class . '></li>' . PHP_EOL;
}
?>
</ol>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-testimonials" data-slide="prev">
<span></span>
</a>
<a class="right carousel-control" href="#carousel-testimonials" data-slide="next">
<span></span>
</a>
</div> <!-- carousel -->
示例15: isset
}
}
$element = isset($accept['panel']['element']) ? $accept['panel']['element'] : 'ul';
$html = '';
$parsed = \Routerunner\Helper::parse_array($accept, $model, array("children"));
if (isset($parsed['panel']['attr']) && is_array($parsed['panel']['attr'])) {
foreach ($parsed['panel']['attr'] as $attr => $value) {
$html .= ' ' . $attr . '="' . $value . '"';
}
} elseif (isset($parsed['panel']['attr']) && is_string($parsed['panel']['attr'])) {
$html .= ' ' . $parsed['panel']['attr'];
}
$open = false;
$select = false;
$traverse = \runner::stack('traverse');
$models_created = \runner::stack("models_created");
$open = isset($runner->context['open']) ? $runner->context['open'] : false;
$debug = 1;
?>
<<?php
echo $element . $html;
?>
>
<?php
$router = false;
if ($open) {
$removed = array();
$children = \Routerunner\Bootstrap::children($runner->context['reference']);
foreach ($children as $index => $child) {
$open = in_array($child['reference'], $traverse['parents_ref']) ? true : false;
if ($models_created) {