本文整理汇总了PHP中Render::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Render::add方法的具体用法?PHP Render::add怎么用?PHP Render::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Render
的用法示例。
在下文中一共展示了Render::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($args)
{
$render = new Render();
$render->add('path', $args['path']);
$render->add('fullPath', $args['fullPath']);
$render->add('args', $args['args']);
switch (true) {
case count($args['args']) == 0:
case $args['args'][0] == 'pages':
case $args['args'][0] == 'page':
$render->view('index');
break;
default:
$render->view('404', true, true, "HTTP/1.0 404 Not Found");
break;
}
}
示例2: open
public function open($pagina)
{
if ($this->allowCrossDomain) {
header('Access-Control-Allow-Origin: *');
}
if ($this->onlyJson && $_SERVER["HTTP_ACCEPT"] && strpos($_SERVER["HTTP_ACCEPT"], "application/json") === false) {
return false;
}
if ($this->onlyLocal && strpos($_SERVER['HTTP_REFERER'], getenv('HTTP_HOST')) === false) {
return false;
}
$retorno = 200;
$pagina = substr($pagina, -1) == "/" ? substr($pagina, 0, -1) : $pagina;
$pedacos = explode("/", $pagina);
$arg = array();
$index = $pagina;
while (count($pedacos) >= 0) {
if (count($pedacos) == 0 || isset($this->controller[$index]) && in_array($this->controller[$index], $this->controller)) {
break;
} else {
$arg[] = array_pop($pedacos);
$index = join("/", $pedacos);
}
}
if (count($arg) == 0) {
}
$index = $index == "" ? 'index' : $index;
$args = array('fullPath' => $pagina, 'path' => $index, 'args' => count($arg) > 0 && $arg[0] !== "" ? array_reverse($arg) : array());
if (!is_null($this->controller[$index]) && $index !== "") {
if (file_exists($this->controller[$index]['caminho'])) {
include $this->controller[$index]['caminho'];
$className = $this->controller[$index]['controle'];
if (class_exists($className)) {
$objController = new $className();
// roda a funcao init da classe
$action = $this->controller[$index]['action'];
$retorno = $objController->run($action, $args);
// roda a funcao run
//return true;
} else {
$retorno = 404;
//echo "Erro ao ativar o controller: ".$className."<br>";
//return false;
}
} else {
$retorno = 404;
}
} else {
$retorno = 404;
}
if ($retorno) {
if (Render::templateExists($retorno)) {
if (is_numeric($retorno)) {
}
$render = new Render();
$render->add('args', $args);
$render->view($retorno);
return true;
} else {
http_response_code($retorno);
return false;
}
} else {
return true;
}
}