public static function __callStatic($name, $args) { if (count($args) == 1 && is_string($args[0]) || count($args) == 2 && is_string($args[0]) && is_array($args[1])) { foreach (CONFIG::get("sql") as $value) { if (CONFIG::has_attribute($value, "database_alias", true) && CONFIG::has_attribute($value, "model", true)) { $alias = $value["@attributes"]["database_alias"]; $model = $value["@attributes"]["model"]; $modelname = $args[0]; $params = []; if (isset($args[1])) { $params = $args[1]; } if ($name == $alias && $modelname == $model) { foreach ($value as $subkey => $subvalue) { if (self::startswith(strtolower($subkey), "select:")) { $handler = new self($alias, CONFIG::content($subvalue), $params); return $handler; } } } } } } return null; }
public static function translate($template, $value) { $tags = ["title", "description", "keywords", "icon", "meta", "stylesheet", "scriptfile", "script"]; $vars = []; foreach ($template as $subkey => $subvalue) { if (self::startswith(strtolower($subkey), "var:") && \Nise\CONFIG::has_attribute($subvalue, ["name", "value"], true)) { $on = true; if (isset($subvalue["@attributes"]['when'])) { $on = \Nise\NISE::get($subvalue["@attributes"]['when']); } if (is_bool($on) && $on == true) { $vars[$subvalue["@attributes"]['name']] = $subvalue["@attributes"]['value']; } } } foreach ($template as $subkey => $subvalue) { foreach ($tags as $tag) { if (self::startswith(strtolower($subkey), $tag . ":")) { $targets = self::get_target($subvalue); if (!empty($subvalue["@attributes"])) { foreach ($targets as $target) { self::set_tag($tag, $subvalue["@attributes"], $target); } } } } if (self::startswith(strtolower($subkey), "fragment:") && \Nise\CONFIG::has_attribute($subvalue, "name", true)) { if (\Nise\CONFIG::has_attribute($subvalue, "loop", true)) { $loop = \Nise\NISE::get($subvalue["@attributes"]['loop']); if (is_array($loop)) { $fragments = []; foreach ($loop as $item) { $item = is_array($item) ? $item : []; $fragment = self::nise_html_decode(\Nise\CONFIG::content($subvalue), array_merge($vars, $item)); $fragments[] = $fragment->render(); } $fragment = implode("\n", $fragments); } } else { $fragment = self::nise_html_decode(\Nise\CONFIG::content($subvalue), $vars); $fragment = $fragment->render(); } if ($fragment != null) { $targets = self::get_target($subvalue); foreach ($targets as $target) { self::add($fragment, $subvalue["@attributes"]["name"], $target); } } } if (self::startswith(strtolower($subkey), "fragmentorder:")) { /// name ? $targets = self::get_target($subvalue); $attributes = array_flip($subvalue["@attributes"]); ksort($attributes); foreach ($targets as $target) { $HTMLORDER = $target . "ORDER"; self::${$HTMLORDER} = $attributes; } } } }