return $handle; } /* * @param string $dir */ private static function clearDir($dir) { if (!is_dir($dir)) { throw new InvalidArgumentException("The dir argument must be a directory: $dir"); } return rtrim($dir, DIRECTORY_SEPARATOR); } /** * Checks if the given file path satisfies the filtering options. * @param string $path the path of the file or directory to be checked * @param array $options the filtering options. See [[findFiles()]] for explanations of * the supported options.
* - `recursive`: boolean, whether the files under the subdirectories should also be looked for. Defaults to `true`. * @return array files found under the directory, in no particular order. Ordering depends on the files system used. * @throws InvalidArgumentException if the dir is invalid. */ public static function findFiles($dir, $options = []) { $dir = self::clearDir($dir); $options = self::setBasePath($dir, $options); $list = []; $handle = self::openDir($dir); while (($file = readdir($handle)) !== false) { if ($file === '.' || $file === '..') { continue;
*/ public function getUrl($scheme = false){ return \werewolf8904\cmscore\helpers\Url::getObjectUrl($this, $scheme); } public static function getFilesWithFolder($path){ return FileHelper::findFiles($path,['only'=>['*.jpg','*.jpeg','*.png','*.bmp', '*.tiff', '*.gif', '*.JPG'], 'recursive'=>FALSE]); } }
*/ public function actionView($id): string { $model = Gallery::find()->andWhere([Gallery::tableName() . '.id' => $id])->one(); $storage = env('STORAGE_HOST_INFO') . '/source'; $model->path = str_replace($storage,'', $model->path); $img = Gallery::getFilesWithFolder(Yii::getAlias('@storage/web/source/' . $model->path)); $clear_path = realpath($_SERVER['DOCUMENT_ROOT'].'/../../') . '/storage/web/source'; foreach ($img as $key=>$image){ $images[$key]= str_replace('\\', '/', str_replace($clear_path,'', $image)); } if (!$model) { throw new NotFoundHttpException;
$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) {
{ 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();
new yii\web\Application(require \hiqdev\composer\config\Builder::path('frontend')); $emails = Yii::$app->keyStorage->get('common.admin_emails', false); if ($emails) { Yii::$app->params['adminEmail'] = \yii\helpers\ArrayHelper::map($emails, 'email', 'name'); } Yii::$app->run(); })(); /*/ // Composer require(__DIR__ . '/../../vendor/autoload.php');
$emails = Yii::$app->keyStorage->get('common.admin_emails', false); if ($emails) { Yii::$app->params['adminEmail'] = \yii\helpers\ArrayHelper::map($emails, 'email', 'name'); } Yii::$app->run(); })(); /*/ // Composer require(__DIR__ . '/../../vendor/autoload.php'); // Environment
$_GET = [ 'id' => '12', ];