/** * @param $path * * @return int */ public static function folderCountInPath($path) { $path = AppFile::useBackslash($path); $path = AppFile::removeTrailingBackSlash($path); return sizeof(explode('/', $path)); }
/** * @param $model */ private function makeCrud($model) { $generator = new \yii\gii\generators\crud\Generator(); $generator->enableI18N = TRUE; $generator->modelClass = AppFile::useForwardSlash($this->models_path . chr(92) . $model); $generator->searchModelClass = AppFile::useForwardSlash($this->models_search_path . chr(92) . $model); $generator->controllerClass = AppFile::useForwardSlash($this->controller_path . chr(92) . $model . 'Controller'); if ($this->crud_template != 'default') { $generator->templates[$this->crud_template] = Yii::getAlias($this->crud_template_path); $generator->template = $this->crud_template; } else { $generator->template = 'default'; } $files = $generator->generate(); foreach ($files as $file) { $file->path = AppFile::useBackslash($file->path); $dir = AppFile::removeFileInPath($file->path); AppFile::buildPath($dir); $content = $file->content; if (strpos($file->path, '/views/') != FALSE) { $dir_name = trim(preg_replace('/([A-Z])/', " \$1", $model)); $dir_name = strtolower(str_replace(' ', '-', $dir_name)); $path = AppFile::useBackslash(Yii::getAlias('@' . $this->controller_path)) . '/' . $dir_name; $file->path = AppFile::fileFromPath($file->path); $path = preg_replace('/\\/controllers\\//', '/views/', $path); AppFile::buildPath($path); $file->path = $path . '/' . $file->path; } AppFile::writeFile($file->path, $content); } }
public function actionView() { $path = Yii::getAlias('@backend') . '/views'; $array = AppFile::recursiveDirectory($path, ''); return $this->render('view', ['array' => $array]); }
?> <div><a href="/?r=<?php echo $item['folder']; ?> " target="_blank"><?php echo $item['folder']; ?> </a></div> <?php } ?> </div> <div class="boundary"> <div class="title">Frontend</div> <?php $array = AppFile::recursiveDirectory(Yii::getAlias('@frontend') . '/views', '', ''); ?> <?php foreach ($array as $item) { ?> <?php $item = $item['item']; ?> <?php if (!$item['is_dir']) { continue; } ?> <div><a href="/?r=<?php echo $item['folder']; ?>