Esempio n. 1
0
 protected function defaultFilters()
 {
     return ['size' => ['class' => \rock\template\filters\StringFilter::className()], 'trimPattern' => ['class' => \rock\template\filters\StringFilter::className()], 'contains' => ['class' => \rock\template\filters\StringFilter::className()], 'truncate' => ['class' => \rock\template\filters\StringFilter::className()], 'truncateWords' => ['class' => \rock\template\filters\StringFilter::className()], 'upper' => ['class' => \rock\template\filters\StringFilter::className()], 'lower' => ['class' => \rock\template\filters\StringFilter::className()], 'upperFirst' => ['class' => \rock\template\filters\StringFilter::className()], 'encode' => ['class' => \rock\template\filters\StringFilter::className()], 'decode' => ['class' => \rock\template\filters\StringFilter::className()], 'markdown' => ['class' => \rock\template\filters\StringFilter::className()], 'paragraph' => ['class' => \rock\template\filters\StringFilter::className()], 'isParity' => ['class' => \rock\template\filters\NumericFilter::className()], 'positive' => ['class' => \rock\template\filters\NumericFilter::className()], 'formula' => ['class' => \rock\template\filters\NumericFilter::className()], 'unserialize' => ['class' => \rock\template\filters\BaseFilter::className()], 'replaceTpl' => ['class' => \rock\template\filters\BaseFilter::className()], 'modifyDate' => ['class' => \rock\template\filters\BaseFilter::className()], 'date' => ['class' => \rock\template\filters\BaseFilter::className()], 'modifyUrl' => ['class' => \rock\template\filters\BaseFilter::className()], 'url' => ['method' => 'modifyUrl', 'class' => \rock\template\filters\BaseFilter::className()], 'arrayToJson' => ['class' => \rock\template\filters\BaseFilter::className()], 'toJson' => ['method' => 'arrayToJson', 'class' => \rock\template\filters\BaseFilter::className()], 'jsonToArray' => ['method' => 'unserialize', 'class' => \rock\template\filters\BaseFilter::className()], 'toArray' => ['method' => 'unserialize', 'class' => \rock\template\filters\BaseFilter::className()], 'notEmpty' => ['class' => \rock\template\filters\ConditionFilter::className()], 'empty' => ['method' => '_empty', 'class' => \rock\template\filters\ConditionFilter::className()], 'inotEmpty' => ['class' => \rock\template\filters\ConditionFilter::className()], 'iempty' => ['class' => \rock\template\filters\ConditionFilter::className()], 'notIsset' => ['class' => \rock\template\filters\ConditionFilter::className()], 'isset' => ['method' => '_isset', 'class' => \rock\template\filters\ConditionFilter::className()], 'if' => ['method' => '_if', 'class' => \rock\template\filters\ConditionFilter::className()], 'thumb' => ['class' => \rock\template\filters\BaseFilter::className()]];
 }
Esempio n. 2
0
<?php

use rock\base\Alias;
use rock\db\BatchQueryResult;
use rock\rbac\Permission;
use rock\rbac\Role;
use rock\Rock;
use rock\security\Security;
use rock\template\Template;
return array_merge(['route' => ['class' => \rock\route\Route::className()], 'access' => ['class' => \rock\access\Access::className()], 'behavior' => ['class' => \rock\components\Behavior::className()], 'db' => ['class' => \rock\db\Connection::className(), 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'dsn' => 'mysql:host=localhost;dbname=rockdemo;charset=utf8', 'tablePrefix' => 'spt_', 'aliasSeparator' => '__'], 'BatchQueryResult' => ['class' => BatchQueryResult::className()], 'template' => ['class' => Template::className(), 'locale' => [\rock\LocaleProperties::className(), 'locale'], 'autoEscape' => Template::ESCAPE | Template::TO_TYPE, 'handlerLink' => function ($link, Template $template, array $params = []) {
    if (!($link = Alias::getAlias("@{$link}", [], false))) {
        return '#';
    }
    return $template->autoEscape(\rock\template\filters\BaseFilter::modifyUrl($link, $params));
}, 'extensions' => ['cfg' => function (array $keys) {
    return \rock\helpers\ArrayHelper::getValue(Rock::$config, $keys);
}, 'user' => function (array $keys) {
    if (current($keys) === 'isGuest') {
        return Rock::$app->user->isGuest();
    } elseif (in_array(current($keys), ['isLogged', 'isAuthenticated'], true)) {
        return !Rock::$app->user->isGuest();
    }
    return \rock\helpers\ArrayHelper::getValue(Rock::$app->user->getAll(), $keys);
}, 'call' => function (array $call, array $params = [], Template $template) {
    if (!isset($call[1])) {
        $call[1] = null;
    }
    list($class, $method) = $call;
    if ($class === 'context') {
        $object = $template->context;
        $function = [$object, $method];