$route = '/model/' . $model->class; \runner::redirect_route($route, \runner::config("scaffold"), true, $_model_context, $root_router, $root_model); if (isset($router->runner->backend_context["model"]["fields"])) { $fields = $router->runner->backend_context["model"]["fields"]; } if (isset($root_router->runner->backend_context["model"]["fields"])) { $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; }
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; } } if ($orderBy === \Routerunner\Routerunner::BY_INDEX) { // get order_no sibling $order_no_reference = self::resolve_model_reference('order_no', $where, true); if ($order_no_reference !== false) { $where_reference['model_traverse.order_no IN (' . implode(',', $order_no_reference) . ')'] = null; $strict = true; $skip_state = true; $by_index = true; } } if ($where_reference) { $SQL = 'SELECT models.reference, model_traverse.parent_ref' . PHP_EOL; if ($orderBy === \Routerunner\Routerunner::BY_TREE || $orderBy === \Routerunner\Routerunner::BY_TREE_DESC || $by_tree) { $SQL .= ', prev_ref AS prev' . PHP_EOL; } elseif ($orderBy === \Routerunner\Routerunner::BY_INDEX || $orderBy === \Routerunner\Routerunner::BY_INDEX_DESC || $by_index) { $SQL .= ', order_no AS prev' . PHP_EOL; } $SQL .= 'FROM {PREFIX}models AS models ' . PHP_EOL; if ($orderBy === \Routerunner\Routerunner::BY_TREE || $orderBy === \Routerunner\Routerunner::BY_TREE_DESC || $by_tree) { $SQL .= 'LEFT JOIN {PREFIX}model_trees AS model_traverse ON model_traverse.reference = models.reference ' . PHP_EOL; } elseif ($orderBy === \Routerunner\Routerunner::BY_INDEX || $orderBy === \Routerunner\Routerunner::BY_INDEX_DESC || $by_index) { $SQL .= 'LEFT JOIN {PREFIX}model_orders AS model_traverse ON model_traverse.reference = models.reference ' . PHP_EOL; } $SQL .= 'WHERE ' . implode(' AND ', array_keys($where_reference)) . PHP_EOL; if ($orderBy === \Routerunner\Routerunner::BY_INDEX || $by_index) { $SQL .= 'ORDER BY model_traverse.parent_ref, model_traverse.order_no, models.reference'; } } } if ($strict && !empty($SQL) && ($result = \db::query($SQL, $params))) { // modify SQL params if (!$leftJoin) { $leftJoin = array(); } if (strpos($from, '{PREFIX}models') !== false || $from == 'models') { $from = '`{PREFIX}models` AS models'; $model_class = 'models'; $primary_key = 'reference'; } else { array_unshift($leftJoin, '`' . $from . '` ON `' . $from . '`.`' . $primary_key . '` = models.table_id AND models.table_from = \'' . $from . '\''); $model_class = trim($from, '`'); $primary_key = trim($primary_key, '`'); $from = '{PREFIX}models AS models'; } if ($orderBy === \Routerunner\Routerunner::BY_INDEX || $orderBy === \Routerunner\Routerunner::BY_INDEX_DESC || $by_index) { foreach ($result as $reference_row) { $tree[] = $reference_row['reference']; $parents[$reference_row["reference"]] = $reference_row["parent_ref"]; $prevs[$reference_row["reference"]] = $reference_row["prev"]; } $orderBy = '`models`.`order_no`'; } elseif ($orderBy === \Routerunner\Routerunner::BY_TREE || $orderBy === \Routerunner\Routerunner::BY_TREE_DESC || $by_tree) { $orderByTree = $orderBy === \Routerunner\Routerunner::BY_TREE || $orderBy === \Routerunner\Routerunner::BY_TREE_DESC ? true : false; if ($orderByTree) { $orderBy = 'CASE `models`.`reference`'; } $reorder_tree = array(); foreach ($result as $reference_row) { $reorder_tree[$reference_row['prev']] = $reference_row; $parents[$reference_row["reference"]] = $reference_row["parent_ref"]; $prevs[$reference_row["reference"]] = $reference_row["prev"]; } if (count($reorder_tree) === 1) { $prev = key($reorder_tree); $index = 0; } else { $prev = 0; $index = 0; } while (isset($reorder_tree[$prev])) { $current = $reorder_tree[$prev]['reference']; $tree[] = $current; $prev = $current; if ($orderByTree) { $orderBy .= ' WHEN ' . $current . ' THEN ' . $index; } $index++; } if ($orderByTree) { $orderBy .= ' END'; } } elseif (isset($where["direct"])) { foreach ($result as $reference_row) { $tree[] = $reference_row['reference']; } } if ($ordering === \Routerunner\Routerunner::BY_INDEX_DESC || $ordering === \Routerunner\Routerunner::BY_TREE_DESC) { $orderBy .= ' DESC'; } if (!$where) { $where = array(); } $where['models.reference IN (' . implode(',', $tree) . ')'] = null; $where['`' . $model_class . '`.`' . $primary_key . '` IS NOT NULL'] = null; } elseif ($strict) { $where['1 = 0'] = null; } if ($config_reference = \runner::config('reference')) { $where['models.reference IN (' . $config_reference . ')'] = null; } } else { // join models table and filter to reference } \runner::stack("parents", $parents); \runner::stack("prevs", $prevs); $SQL = ''; unset($where["direct"]); $visible_references = array(); $params = array(); if (\runner::config("mode") != "backend" && \runner::config("mode") != "sitemap" && !\runner::now("skip_state_check") && !$skip_state) { $_from = $from; if (strpos($_from, "AS") !== false) { $_from = substr($_from, 0, strpos($_from, "AS")); } $SQL = "SELECT models.reference FROM " . $_from; if (strpos($_from, "models") !== false) { $SQL .= " AS models"; } $SQL .= PHP_EOL; if ($leftJoin) { foreach ($leftJoin as $join) { $SQL .= 'LEFT JOIN ' . $join . PHP_EOL; } } if (strpos($_from, "models") === false) { $SQL .= "LEFT JOIN {PREFIX}models AS models ON models.table_from = '" . $_from . "' AND models.table_id = " . $_from . "." . $primary_key . PHP_EOL; } $_where = array(); if (isset($where) && is_array($where)) { $_where = $where; } $time = time(); $_where["models.reference NOT IN (SELECT model FROM {PREFIX}model_states AS states WHERE states.active = 0 OR " . $time . " NOT BETWEEN COALESCE(begin, " . $time . ") AND COALESCE(end, " . $time . "))"] = null; if (is_array($_where) && count($_where)) { $SQL .= 'WHERE '; $i = 0; foreach ($_where as $filter => $param) { if (!is_numeric($filter)) { $SQL .= $filter; } if (preg_match('/(:[a-z0-9]+)/i', $filter, $match)) { $params[$match[0]] = $param; } elseif (strpos($filter, '?') !== false) { $params[] = $param; } $i++; if (!is_numeric($filter) && $i < count($_where)) { $SQL .= ' AND '; } $SQL .= PHP_EOL; } } elseif ($_where) { $SQL .= 'WHERE ' . $_where . PHP_EOL; } if ($state_results = \db::query($SQL, $params)) { foreach ($state_results as $state_result) { if (!empty($state_result["reference"])) { $visible_references[] = $state_result["reference"]; } } } $SQL = ''; $params = array(); } if ($orderBy !== \Routerunner\Routerunner::BY_INDEX && $orderBy !== \Routerunner\Routerunner::BY_INDEX_DESC && $orderBy !== \Routerunner\Routerunner::BY_TREE && $orderBy !== \Routerunner\Routerunner::BY_TREE_DESC || $where) { $SQL = 'SELECT '; array_walk($select, function (&$value, $key) { if (is_null($value)) { $value = 'NULL AS `' . trim($key, '`') . '`'; } else { $value = $value . ' AS `' . trim($key, '`') . '`'; } }); $SQL .= implode(', ', $select); $SQL .= PHP_EOL; $SQL .= 'FROM ' . $from . PHP_EOL; if ($leftJoin) { foreach ($leftJoin as $join) { $SQL .= 'LEFT JOIN ' . $join . PHP_EOL; } } if ($visible_references) { /* $SQL .= "LEFT JOIN {PREFIX}models AS models ON models.table_from = '" . $from . "' AND models.table_id = " . $from . "." . $primary_key . PHP_EOL; */ if (!isset($where) || !is_array($where)) { $where = array(); } $where["`" . $from . "`.`" . $primary_key . "` IN (SELECT models.table_id FROM {PREFIX}models AS models\nWHERE models.reference IN (" . implode(",", $visible_references) . "))"] = null; } if (is_array($where) && count($where)) { $SQL .= 'WHERE '; $i = 0; foreach ($where as $filter => $param) { if (!is_numeric($filter)) { $SQL .= $filter; } if (preg_match('/(:[a-z0-9]+)/i', $filter, $match)) { $params[$match[0]] = $param; } elseif (strpos($filter, '?') !== false) { $params[] = $param; } $i++; if (!is_numeric($filter) && $i < count($where)) { $SQL .= ' AND '; } $SQL .= PHP_EOL; } } elseif ($where) { $SQL .= 'WHERE ' . $where . PHP_EOL; } if ($groupBy) { $SQL .= 'GROUP BY ' . $groupBy . PHP_EOL; } if ($orderBy != "BY_TREE" && $orderBy != "BY_TREE_DESC" && $orderBy != "BY_INDEX" && $orderBy != "BY_INDEX_DESC") { if ($orderBy) { $SQL .= 'ORDER BY ' . $orderBy . PHP_EOL; } elseif ($orderBy !== false) { $SQL .= 'ORDER BY ' . $primary_key . PHP_EOL; } } if ($limit !== false) { $SQL .= 'LIMIT ' . $limit . PHP_EOL; if ($offset !== false) { $SQL .= 'OFFSET ' . $offset . PHP_EOL; } } elseif ($limit === false && $offset !== false) { $SQL .= 'LIMIT 18446744073709551615' . PHP_EOL; $SQL .= 'OFFSET ' . $offset . PHP_EOL; } } return $SQL; }
private function backend_wrapper($html = '', $type = 'model', $context = false) { if ($context) { $backend_type_context = $context; } elseif (is_callable($this->backend_context[$type])) { $backend_type_context = $this->backend_context[$type]($this); } else { $backend_type_context = $this->backend_context[$type]; } if (!($tree = \runner::config("tree"))) { $scaffold = $this->scaffold_root; $tree = @(include $scaffold . '/model/tree.php'); } if ($type == 'container') { // get parent model $parent = 0; if (isset($backend_type_context['parent'])) { $parent = $backend_type_context['parent']; } if (!$parent && $this->model && $this->model->reference && ($parents = \Routerunner\Bootstrap::parent($this->model->reference))) { $array_pop = array_pop($parents); $parent = $array_pop['reference']; } if (!$parent && isset($backend_type_context['traverse']) && is_array($traverse = $backend_type_context['traverse'])) { if (count($traverse) && ($lvl = array_pop($traverse)) && ($parent_table_id = \bootstrap::get($lvl))) { if (is_array($parent_table_id)) { $tmp_parent_table_id = false; foreach ($parent_table_id["parents"] as $tmp_parent) { if ($tmp_parent["model_class"] == $lvl) { $tmp_parent_table_id = $tmp_parent["reference"]; } } if ($tmp_parent_table_id) { $parent_table_id = $tmp_parent_table_id; } } $SQL = 'SELECT reference FROM {PREFIX}models WHERE model_class = :class AND table_id = :table_id'; if ($result = \db::query($SQL, array(':class' => $lvl, ':table_id' => $parent_table_id))) { $parent = $result[0]['reference']; } } } // get acceptable models $accept = array(); if (isset($backend_type_context['accept'])) { $accept = $backend_type_context['accept']; } elseif (isset($backend_type_context['traverse']) && ($branch = \Routerunner\Helper::tree_route($tree, $backend_type_context['traverse'], $this->model))) { foreach ($branch['children'] as $child_class => $child_params) { if (isset($child_params['blank'])) { $blank[] = $child_class; $accept[$child_class] = $child_params['blank']; } } } $backend_type_context['parent'] = $parent; $backend_type_context['blank'] = $accept; if (!isset($backend_type_context['wrapper'])) { $backend_type_context['wrapper'] = array('class' => ''); } elseif (!isset($backend_type_context['wrapper']['class'])) { $backend_type_context['wrapper']['class'] = ''; } $classes = explode(' ', $backend_type_context['wrapper']['class']); $classes = array_merge($classes, array_keys($accept)); $backend_type_context['wrapper']['class'] .= implode(' ', $classes); } $dom = false; if ($html) { if (isset($backend_type_context['template']['opening'])) { $dom = \phpQuery::newDocument($backend_type_context['template']['opening'] . $html . $backend_type_context['template']['closing']); if (!$dom) { $dom = \phpQuery::newDocumentHTML($html); } } elseif (isset($backend_type_context['wrapper']['element'])) { $dom = \phpQuery::newDocumentHTML($html, $charset = 'utf-8'); $dom = $this->dom_wrapper($dom, $backend_type_context['wrapper']['element'], null); } else { $dom = \phpQuery::newDocumentHTML($html); } } elseif (isset($backend_type_context['wrapper']['element'])) { $html = '<' . $backend_type_context['wrapper']['element'] . '></' . $backend_type_context['wrapper']['element'] . '>'; $dom = \phpQuery::newDocumentHTML($html); } elseif (isset($backend_type_context['template']['opening'])) { $html = $backend_type_context['template']['opening'] . $backend_type_context['template']['closing']; $dom = \phpQuery::newDocumentHTML($html); } $root_nodes = array(); if ($dom && isset($backend_type_context['selector'])) { $root_nodes = pq($backend_type_context['selector'] . ":not(.routerunner-" . $type . ")"); } elseif ($dom) { $root_nodes = $dom->children(":not(.routerunner-" . $type . ")"); } $model = false; if ($type == 'model' && isset($this->model)) { $model = $this->model; } elseif ($type == 'container' && isset($backend_type_context['blank'])) { $model = new \stdClass(); $model->reference = 0; foreach ($backend_type_context['blank'] as $blank_field => $blank_value) { $model->{$blank_field} = $blank_value; } } foreach ($root_nodes as $index => $node) { if (!in_array(strtolower($node->tagName), array("html", "head", "body", "script", "style"))) { if (!$this->unique) { $this->unique = uniqid(); } $backend_class = 'routerunner-backend routerunner-inline routerunner-' . $type . ' routerunner-' . $type . '-wrapper '; if (isset($backend_type_context['wrapper']['class'])) { $backend_class .= $backend_type_context['wrapper']['class'] . ' '; } $pqnode = pq($node); $backend_context = $backend_type_context; unset($backend_context['wrapper']['element'], $backend_context['wrapper']['class'], $backend_context['wrapper']['attr'], $backend_context['template']['opening'], $backend_context['template']['closing']); $pqnode->removeAttr('data-routerunner-id'); $pqnode->removeAttr('data-route'); $pqnode->removeAttr('data-table_id'); if ($model) { foreach ($model as $data => $value) { $pqnode->removeAttr('data-' . $data); } } if (isset($backend_type_context['wrapper']['attr']) && is_array($backend_type_context['wrapper']['attr'])) { foreach (array_keys($backend_type_context['wrapper']['attr']) as $attr) { $pqnode->removeAttr($attr); } } if (isset($backend_context) && is_array($backend_context)) { foreach (array_keys($backend_context) as $data) { $pqnode->removeAttr('data-' . $data); } } // modify model tag if ($type == 'model' && $model) { $this->backend_id[$index] = 'ref' . $model->reference . '_' . $this->unique; $model->backend_ref = $this->backend_id[$index]; $pqnode->attr('data-routerunner-id', $this->backend_id[$index]); $pqnode->attr('data-route', $this->router->runner->path . $this->router->runner->route); $pqnode->attr('data-url', $model->url()); if ($model) { foreach ($model as $data => $value) { if (is_array($value)) { $value = json_encode($value, JSON_HEX_APOS); } else { $value = htmlentities(addslashes(preg_replace('/\\n|\\r/m', '', $value))); } $pqnode->attr('data-' . $data, $value); } } } elseif ($type == 'container') { $this->backend_id[$index] = 'route_' . trim(str_replace('/', '_', $this->path . $this->route), '_') . '_' . $this->unique; $pqnode->attr('data-routerunner-id', $this->backend_id[$index]); $pqnode->attr('data-route', $this->router->runner->path . $this->router->runner->route); if ($model) { foreach ($model as $attr => $value) { $traverse_child = isset($backend_type_context['traverse']) ? $backend_type_context['traverse'] : array(); $traverse_child[] = $attr; if ($branch = \Routerunner\Helper::tree_route($tree, $traverse_child)) { foreach ($branch as $branch_attr => $branch_value) { if (substr($branch_attr, 0, 4) == 'btn-' || $branch_attr == 'icon') { $value[$branch_attr] = $branch_value; } } } if (is_array($value)) { $value = json_encode($value, JSON_HEX_APOS); } else { $value = htmlentities(addslashes(preg_replace('/\\n|\\r/m', '', $value))); } $pqnode->attr('data-' . str_replace("/", "-", $attr), $value); } } } if (isset($backend_type_context['wrapper']['attr']) && is_array($backend_type_context['wrapper']['attr'])) { foreach ($backend_type_context['wrapper']['attr'] as $attr => $value) { $pqnode->attr($attr, $value); } } $backend_classes = explode(' ', $backend_class); foreach ($backend_classes as $class) { if (!$pqnode->hasClass($class)) { $pqnode->addClass($class); } } if (isset($backend_context) && is_array($backend_context)) { foreach ($backend_context as $data => $value) { if (is_array($value)) { $value = json_encode($value, JSON_HEX_APOS); } else { $value = htmlentities(addslashes(preg_replace('/\\n|\\r/m', '', $value))); } $pqnode->attr('data-' . $data, $value); } } } } $return = ""; if ($dom) { $return = $dom->htmlOuter(); } return $return; }
<?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);
\runner::stack("model_create", array("route" => $route)); \runner::route($route, array("direct" => 0), $router, true, $model); $return["html"] = $router->runner->html_render; $return["html_before"] = $router->runner->html_before; $return["html_after"] = $router->runner->html_after; if (isset($router->runner->backend_context["model"])) { $return["backend_context"] = $router->runner->backend_context["model"]; } \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) {
* Created by PhpStorm. * User: csibi * Date: 2014.10.30. * Time: 20:47 */ session_start(); require $_SESSION["runner_config"]['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $_SESSION["runner_config"]["SITEROOT"] . $_SESSION["runner_config"]["BACKEND_ROOT"] . 'Routerunner/Routerunner.php'; use Routerunner\Routerunner as runner; $post = array_merge($_GET, $_POST); new runner(array('mode' => 'backend', 'params' => $post, 'silent' => true, 'method' => 'any', 'resource' => '/', 'bootstrap' => false), function () use($post) { $lang = \runner::config("language"); $treeroot = false; $route = array(''); if (isset($post["current"]) && is_numeric($post["current"])) { $lang = \Routerunner\Bootstrap::lang($post["current"]); $parents = \Routerunner\Bootstrap::parent($post["current"], $treeroot); if (!$treeroot && !empty($post['current'])) { if ($current_model = \model::load(array('direct' => $post['current']))) { if ($current_model->class == 'tree') { $treeroot = array("lvl" => 1, "reference" => $current_model->reference, "model_class" => $current_model->class, "table_id" => $current_model->table_id); } } } if ($treeroot) { $route[] = $treeroot["model_class"] . '/' . $treeroot["table_id"]; } if (isset($post['route']) && is_array($post['route'])) { $treeroot_index = false; foreach ($post['route'] as $post_route_index => $post_route) { if ($post_route && ($post_route == $treeroot["model_class"] || strpos($post_route, $treeroot["model_class"] . '/') !== false)) { $treeroot_index = $post_route_index;