* @param string $field * @return boolean */ private function arrayFilter($value, $field) { foreach ($this->_where as $expression) { if ($expression['field'] == $field) { switch ($expression['op']) { case '=': return ($value == $expression['value']); case '==': return ($value === $expression['value']); case '>': return ($value > $expression['value']); case '>=': return ($value >= $expression['value']); case '<': return ($value < $expression['value']); case '<=':
private function arrayFilter($value, $field) { foreach ($this->_where as $expression) { if ($expression['field'] == $field) { switch ($expression['op']) { case '=': return ($value == $expression['value']); case '==': return ($value === $expression['value']); case '>': return ($value > $expression['value']); case '>=': return ($value >= $expression['value']);
if (empty($whereExpression)) { $data = $containerData; } else { $data = array_filter($containerData, function ($item) { foreach ($item as $field => $value) { if (!$this->arrayFilter($value, $field)) { return false; } } return true; });
$containerData = $this->getDataProvider(); $whereExpression = $this->_where; if (empty($whereExpression)) { $data = $containerData; } else { $data = array_filter($containerData, function ($item) { foreach ($item as $field => $value) { if (!$this->arrayFilter($value, $field)) { return false; } }
* If there are several items, it just takes the first one and does not throw an exception. * * @return \luya\admin\image\Item|\luya\admin\file\Item|\luya\admin\folder\Item */ public function one() { $data = $this->filter(); return (count($data) !== 0) ? $this->createItem(array_values($data)[0]) : false; } /** * FindOne with the specific ID.
* * @param array $args An array with conditions to match e.g. `['is_hidden' => 1, 'is_deleted' => 0]`. * @return \luya\admin\image\Item The file item object. */ public function findImage(array $args = []) { return (new \luya\admin\image\Query())->where($args)->one(); } /** * Get a single image based on the ID. * * If not found false is returned.
<?php $items = Yii::$app->menu->getCurrent()->getChildren(); ?> <?php // if (!empty()) foreach ($items as $child): /* @var $child \luya\cms\menu\Item */ $image = Yii::$app->storage->findImage(['id' => $child->getProperty('image')])->source; $original = Yii::getAlias('@webroot').$image; $watermark = Yii::getAlias('@webroot').'/images/watermark.png'; $sizes = getimagesize($original); $sizes2 = getimagesize($watermark); $width = $sizes[0]; $height = $sizes[1];
{ $_obInitialLevel_ = ob_get_level(); ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); try { require $_file_; return ob_get_clean(); } catch (\Exception $e) { while (ob_get_level() > $_obInitialLevel_) { if (!@ob_end_clean()) { ob_clean(); }
$this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); } array_pop($this->_viewFiles); $this->context = $oldContext;
* @since 2.0.1 */ public function renderContent($content) { $layoutFile = $this->findLayoutFile($this->getView()); if ($layoutFile !== false) { return $this->getView()->renderFile($layoutFile, ['content' => $content], $this); } return $content; } /**
// Default format is FORMAT_HTML, if RAW is used we render the content without layout. // @see https://github.com/luyadev/luya-module-cms/issues/35 if (Yii::$app->response->format == Response::FORMAT_RAW) { return $content; } return $this->renderContent($content); } protected function findInternalRedirect() { $path = Yii::$app->request->pathInfo; $compositePath = Yii::$app->composition->prependTo($path);
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
// apply strict, hsts and x-* headers Yii::$app->response->headers->set('Strict-Transport-Security', 'max-age=31536000'); Yii::$app->response->headers->set('X-XSS-Protection', "1; mode=block"); Yii::$app->response->headers->set('X-Frame-Options', "SAMEORIGIN"); } return parent::handleRequest($request); } /** * @inheritdoc */ public function coreComponents()
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
$config = $this->getConfigArray(); $this->includeYii(); $mergedConfig = ArrayHelper::merge($config, ['bootstrap' => ['luya\web\Bootstrap']]); $this->app = new WebApplication($mergedConfig); if (!$this->mockOnly) { return $this->app->run(); } } /** * Returns the path to luya core files *
public function run() { if ($this->getIsCli()) { return $this->applicationConsole(); } return $this->applicationWeb(); } /** * Run Cli-Application based on the provided config file. */ public function applicationConsole()
// composer autoload include require(__DIR__ . '/../vendor/autoload.php'); // use the luya boot wrapping class $boot = new \luya\Boot(); $boot->setBaseYiiFile(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); $boot->run();
$_GET = [ 'path' => 'blog', ];