コード例 #1
0
 public function __construct($route = null, $context = array(), $override = null, $root = false)
 {
     $route = str_replace('/', DIRECTORY_SEPARATOR, $route);
     $this->rid = uniqid('', true);
     if (substr($route, 0, 1) == '~' || substr($route, 0, 2) == '/~') {
         $root = \runner::config("scaffold");
         $route = str_replace('~', '', $route);
         if (strpos($route, '@') !== false) {
             $redirect_to = substr($route, strpos($route, '@') + 1);
             if (strpos($redirect_to, '?')) {
                 $redirect_to = substr($redirect_to, 0, strpos($redirect_to, '?'));
             }
             \runner::now("redirected-subpage", $redirect_to);
             $route = DIRECTORY_SEPARATOR . trim(substr($route, 0, strpos($route, '@')), DIRECTORY_SEPARATOR);
         }
     }
     if (substr($route, 0, 1) == '@' || substr($route, 0, 2) == '/@') {
         $root = \runner::config("BACKEND_DIR") . DIRECTORY_SEPARATOR . 'scaffold';
         $route = str_replace('@', '', $route);
     }
     $this->parent = \Routerunner\Routerunner::getParentInstance(false);
     if ($root && file_exists(realpath(\runner::config('SITEROOT') . $root))) {
         $this->scaffold_root = realpath(\runner::config('SITEROOT') . $root);
     } elseif (strpos($route, \Routerunner\Helper::$scaffold_class) !== false) {
         $this->scaffold_suffix = DIRECTORY_SEPARATOR . substr($route, 0, strpos($route, \Routerunner\Helper::$scaffold_class) + strlen(\Routerunner\Helper::$scaffold_class));
         $route = substr($route, strpos($route, \Routerunner\Helper::$scaffold_class) + strlen(\Routerunner\Helper::$scaffold_class) + 1);
     } elseif (isset($this->parent->scaffold_root) && $this->parent->scaffold_root) {
         $this->scaffold_root = $this->parent->scaffold_root;
     } elseif (isset($this->parent->scaffold_suffix) && $this->parent->scaffold_suffix) {
         $this->scaffold_suffix = $this->parent->scaffold_suffix;
     }
     if ($this->scaffold_suffix) {
         $this->scaffold_root = realpath(\runner::config('SITEROOT') . \runner::config('scaffold') . $this->scaffold_suffix);
     }
     if (!$this->scaffold_root) {
         $this->scaffold_root = realpath(\runner::config('SITEROOT') . \runner::config('scaffold'));
     }
     if (substr($route, 0, 1) === DIRECTORY_SEPARATOR) {
         $this->route = $route;
     } elseif ($this->parent) {
         $this->route = $this->parent->runner->path . $this->parent->runner->route . DIRECTORY_SEPARATOR . $route;
     } else {
         $this->route = DIRECTORY_SEPARATOR . $route;
     }
     if (\Routerunner\Helper::includeRoute($this, 'runner', \runner::config("version"))) {
         // return valid Router with runner included
         if (!empty($this->runner->cache_key)) {
             $this->cache_route = str_replace(array('{$url}', '{$route}'), array(\Routerunner\Bootstrap::$baseUri, $this->runner->path . $this->runner->route), $this->runner->cache_key);
         } else {
             $this->cache_route = \Routerunner\Bootstrap::$baseUri . '|' . $this->runner->path . $this->runner->route;
         }
         if ($override) {
             $this->runner->override = $override;
         }
         if (is_array($context) && count($context)) {
             $this->runner->context = array_merge($this->runner->context, $context);
         }
         $this->runner->files = \Routerunner\Helper::getFiles($this->runner);
         $this->runner->route_parser();
         if (\runner::config('silent')) {
             $this->runner->html = str_replace(array("\t", PHP_EOL . PHP_EOL), "", $this->runner->html);
         }
         \Routerunner\Routerunner::getParentInstance();
         if ($this->runner->cache_exp >= 0) {
             $this->set_cache();
         }
     } else {
         // exception: route not found
     }
 }
コード例 #2
0
<?php

/**
 * Created by PhpStorm.
 * User: csibi
 * Date: 2014.10.18.
 * Time: 15:08
 */
require '../runner-config.php';
require '../Routerunner/Routerunner.php';
use Routerunner\Routerunner as runner;
$post = $_POST;
$scaffold = '../scaffold';
$tree = @(include $scaffold . '/model/tree.php');
$runner = runner::runnerParams("runner", array("params" => $post));
if (isset($_SESSION["runner"])) {
    $runner = json_decode(base64_decode($_SESSION["runner"]), true);
}
if (!is_array($runner)) {
    $runner = array();
}
$runner = array_merge(array('root' => 'desktop', 'SITE' => '', 'SITENAME' => '', 'BASE' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/', 'tree' => $tree, 'language' => 1, 'mode' => 'backend', 'params' => $post), $runner);
new runner($runner, function () use($post) {
    $router = false;
    $route = "/backend/panel/pageproperties";
    echo \runner::route($route, null, $router, true);
});
コード例 #3
0
<?php

$bootstrap = \bootstrap::get();
$main_url = "";
$temp_url = array_shift($bootstrap->urls);
if ($temp_url != $bootstrap->resource_url) {
    $main_url = $temp_url;
}
$meta = array_merge(array("social-title" => "", "social-image" => "", "social-description" => "", "social-type" => ""), $bootstrap->pageproperties["meta"]);
$og_types = array("article", "book", "profile", "video", "website", "music");
$debug = 1;
?>
<!-- BEGIN PAGE PANEL -->
<div class="page-panel height-header">
	<?php 
echo \Routerunner\Routerunner::form("frm", $runner, true);
?>

</div>
<!-- END PAGE PANEL -->
コード例 #4
0

		<!-- Post Content -->
		<div class="rr-product-lead lead">
			<?php 
echo html_entity_decode(\model::property("lead"));
?>
		</div>
		<div class="rr-product-content">
			<?php 
echo html_entity_decode(\model::property("content"));
?>
		</div>

		<?php 
echo \Routerunner\Routerunner::form("order", $runner, false);
?>

		<hr>

		<?php 
\runner::route("comments");
?>

	</div>

	<!-- Blog Sidebar Widgets Column -->
	<div class="col-md-3">

		<!-- Blog Search Well -->
		<div class="well">
コード例 #5
0
 public static function get($name)
 {
     return \Routerunner\Routerunner::get($name);
 }
コード例 #6
0
 public function route_parser()
 {
     foreach ($this->load as $load) {
         $this->section = array();
         $file = '';
         if (isset($this->model, $this->model->permission) && is_array($this->model->permission)) {
             $this->permission = $this->model->permission;
         }
         if (is_array($load)) {
             \Routerunner\Helper::loadParser($load[0], $this, $parsed_section);
             if (isset($this->files[$parsed_section])) {
                 if (!is_array($this->files[$parsed_section])) {
                     $files = array($this->files[$parsed_section]);
                 } else {
                     $files = $this->files[$parsed_section];
                 }
                 $regexp = str_replace('~', '', trim($this->route, DIRECTORY_SEPARATOR) . '\\.');
                 foreach ($load as $section) {
                     $parsed = \Routerunner\Helper::loadParser($section, $this, $parsed_value);
                     if ($parsed_value) {
                         $regexp .= $parsed;
                     }
                     $this->section[] = $parsed_value;
                     $files = preg_grep('/\\b' . $regexp . '/', $files);
                 }
                 $files = preg_grep('/^' . $regexp . '$/', $files);
                 if (count($files) == 1) {
                     $file = array_shift($files);
                 } elseif (count($files) > 1) {
                     $file = array_shift($files);
                     while ($file_row = array_shift($files)) {
                         if (strlen($file_row) > strlen($file)) {
                             $file = $file_row;
                         }
                     }
                 } else {
                     // exception: no file match
                 }
             }
         } elseif (isset($this->files[$load])) {
             $this->section[] = $load;
             $file = $this->route . '.' . $load;
         }
         if ($file) {
             if (!$this->readable()) {
                 $debug = 1;
             }
             if ($this->readable() && ($this->section[0] == 'view' || $this->section[0] == 'list')) {
                 if (\runner::config('mode') != 'backend' && $this->router->cache_route && ($html = $this->router->get_cache($_model))) {
                     if (\runner::config('silent')) {
                         $html = str_replace(array("\t", PHP_EOL . PHP_EOL), "", $html);
                     }
                     $this->html = $html;
                     if ($_model) {
                         $this->model = $_model;
                     }
                     return true;
                 }
                 \model::stack();
                 Routerunner::$context = $this->context;
                 \Routerunner\Helper::prepareLoader($this->route, $file, $this->version, $path, $class, false, false, $this->router);
                 $this->view = $class;
                 if (isset($this->model) && $this->model === false) {
                     // todo: check view permission
                     $this->render();
                 } elseif (isset($this->model) && count($this->model) == 1 && ($this->section[0] != 'list' || isset($this->model_context['force_view']) && $this->model_context['force_view'] === true)) {
                     if (is_array($this->model)) {
                         $this->model = array_shift($this->model);
                     }
                     if (!$this->model->readable()) {
                         $debug = 1;
                     }
                     if ($this->model->readable()) {
                         $explode = explode('\\', get_class($this->model));
                         if ($explode[0] != "backend") {
                             \model::object($this->model);
                         }
                         $this->render();
                     }
                 } elseif (isset($this->model)) {
                     $models = $this->model;
                     if (!is_array($models)) {
                         $models = array($models);
                     }
                     $this->render_list($models);
                     $this->model = $models;
                 } elseif (!isset($this->model) && isset($this->files['list']) && is_array($this->files['list']) && in_array(trim($this->route, '/\\') . '.list.null.', $this->files['list'])) {
                     $this->render_null();
                 } elseif (!isset($this->model) && (isset($this->model_context['force_view']) && $this->model_context['force_view'] === true) && isset($this->files['view']) && is_array($this->files['view']) && in_array(trim($this->route, '/\\') . '.view.null.', $this->files['view'])) {
                     $this->render_null();
                 } elseif (!isset($this->model) && (isset($this->model_context['force_view']) && $this->model_context['force_view'] === true)) {
                     $this->render();
                 }
                 \model::unstack();
             } elseif ($this->section[0] == 'event' && ($this->section[count($this->section) - 1] == 'before' || $this->section[count($this->section) - 1] == 'after' || $this->section[count($this->section) - 1] == 'load')) {
                 if ($this->section[count($this->section) - 1] == 'before') {
                     $this->event_before = $file;
                 } elseif ($this->section[count($this->section) - 1] == 'after') {
                     $this->event_after = $file;
                 } elseif ($this->section[count($this->section) - 1] == 'load') {
                     $this->event_load = $file;
                 }
             } elseif ($this->section[0] == 'backend' && \runner::config('mode') == 'backend') {
                 \Routerunner\Helper::loader($this, $file, $output);
                 /*
                 if ($this->section[1] == "model" && isset($this->backend_context["model"]["fields"])) {
                 	foreach ($this->backend_context["model"]["fields"] as $field_name => & $field_data) {
                 		if (!isset($field_data["default"])) {
                 			if (\runner::config("default." . $field_name)) {
                 				$field_data["default"] = \runner::config("default." . $field_name);
                 			} elseif (\runner::config("default.type." . $field_data["type"])) {
                 				$field_data["default"] = \runner::config("default.type." . $field_data["type"]);
                 			}
                 		}
                 	}
                 	$_model = false;
                 	if (isset($this->model) && $this->model && is_array($this->model) && isset($this->model[0]->route)) {
                 		$_model = $this->model[0];
                 	} elseif (isset($this->model) && $this->model && isset($this->model->route)) {
                 		$_model = $this->model;
                 	}
                 	if (($model_create = \runner::stack("model_create")) && $_model &&
                 		isset($model_create["route"]) && $model_create["route"] == $_model->route) {
                 		foreach ($this->backend_context["model"]["fields"] as $field_name => $field_data) {
                 			if (isset($field_data["default"])) {
                 				$_model->$field_name = $field_data["default"];
                 			}
                 		}
                 	}
                 }
                 */
             } elseif (\runner::config('mode') == 'backend' || $this->section[0] != 'backend') {
                 \Routerunner\Helper::loader($this, $file, $output);
             }
         }
     }
 }
コード例 #7
0
 public function form($formname = null)
 {
     $formname = is_null($formname) && count(array_keys($this->form)) ? array_shift(array_keys($this->form)) : $formname;
     $this->currentform = $formname;
     if (!is_null($formname)) {
         $html_path = $this->router->get_route() . '\\' . substr($this->form[$formname]->view, 0, strrpos($this->form[$formname]->view, '.'));
         $formhtml = '';
         if (!\runner::config('silent')) {
             $formhtml .= '<!--Routerunner::Route(' . $html_path . ')//-->' . PHP_EOL;
         }
         $formhtml .= \Routerunner\Routerunner::$slim->render($this->path . $this->route . $this->versionroute . DIRECTORY_SEPARATOR . $this->form[$formname]->view, array('runner' => $this));
         $formhtml .= $this->plugins("form.min.js");
         if ($this->i18n) {
             $formhtml = str_replace(array_keys($this->i18n), array_values($this->i18n), $formhtml);
         }
         return \Routerunner\Routerunner::process($this, $formhtml);
     }
 }
コード例 #8
0
<body class="login">
<!-- BEGIN LOGO -->
<div class="logo">
	<a href="index.php">
		<img src="<?php 
echo \runner::config("BACKEND_ROOT");
?>
backend/img/logo/routerunner-cms-invert.png" alt="Routerunner CMS" width="300"/>
	</a>
</div>
<!-- END LOGO -->
<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
<div class="menu-toggler sidebar-toggler">
</div>
<!-- END SIDEBAR TOGGLER BUTTON -->
<!-- BEGIN LOGIN -->
<div class="content">
	<?php 
echo \Routerunner\Routerunner::form("signin", $runner, true) . PHP_EOL;
echo \Routerunner\Routerunner::form("forgotten", $runner, true) . PHP_EOL;
?>
</div>
<!-- END LOGIN -->
<!-- BEGIN COPYRIGHT -->
<div class="copyright">
	2015 &copy; Retroscope Creative.
</div>
<!-- END COPYRIGHT -->
コード例 #9
0
 public static function instance()
 {
     return \Routerunner\Routerunner::getParentInstance(false)->runner;
 }
コード例 #10
0
 public function middleware($routerunner_object, $arguments = array())
 {
     self::cache_connect();
     \Routerunner\Routerunner::$slim->flashKeep();
     \Routerunner\User::initialize();
     if ($uid = \Routerunner\User::me($email, $name, $gid)) {
         /*
         $this->uid = $uid;
         $this->gid = $gid;
         */
     }
     if (isset($routerunner_object->container['settings']['log.writer'])) {
         $log_class = $routerunner_object->container['settings']['log.writer'];
         $app = \Routerunner\Routerunner::$slim;
         $app->log->setWriter(new $log_class());
         $app->error(function (\Exception $e) use($app, $log_class) {
             new $log_class($e);
         });
     }
     if (!isset($arguments["bootstrap"]) || $arguments["bootstrap"] !== false) {
         \Routerunner\Bootstrap::initialize($routerunner_object->settings);
         $history = \Routerunner\Routerunner::$slim->flash('history');
         if (!is_array($history)) {
             $history = array();
         }
         if (count($history) > 20) {
             $history = array_slice($history, -20, 20);
         }
         if (!count($history) || count($history) && $history[count($history) - 1] != \Routerunner\Bootstrap::$fullUri) {
             $history[] = \Routerunner\Bootstrap::$fullUri;
         }
         \Routerunner\Bootstrap::$history = $history;
         \Routerunner\Routerunner::$slim->flash('history', \Routerunner\Bootstrap::$history);
         if (count($history) > 1) {
             \Routerunner\Routerunner::$slim->now('history.back', $history[count($history) - 2]);
         }
     }
     if (!isset($arguments["skip_route"]) || !$arguments["skip_redirect"]) {
         \Routerunner\Routerunner::route();
     }
     if (\Routerunner\Routerunner::$slim->now('redirect_url') && (!isset($arguments["skip_redirect"]) || !$arguments["skip_redirect"])) {
         \Routerunner\Routerunner::$slim->redirect(\Routerunner\Routerunner::$slim->now('redirect_url'));
     }
 }