예제 #1
0
 public function test_anonymous_controller__conditionnal_controller()
 {
     \Staq::App()->addController('/*', function () {
         if (\Staq::App()->getCurrentUri() == '/coco') {
             return NULL;
         }
     })->run();
     $this->expectOutputHtmlContent('error 404');
 }
예제 #2
0
 protected function initialize()
 {
     if (\Staq::App() && \Staq::App()->isInitialized()) {
         static::$cacheFile = reset($this->extensions) . '/cache/autoload.php';
         if (\is_file(static::$cacheFile)) {
             require_once static::$cacheFile;
         }
         static::$initialized = TRUE;
     }
     return $this;
 }
예제 #3
0
파일: Error.php 프로젝트: pixel418/staq
 public function actionView($code)
 {
     parent::actionView($code);
     $message = '';
     $exception = \Staq::App()->getLastException();
     if ($exception && \Staq::App()->settings->getAsBoolean('error.display_errors')) {
         $message = $exception->getMessage() . HTML_EOL . $exception->getTraceAsString();
     }
     $page = new \Stack\View\Error();
     $page['code'] = $code;
     $page['message'] = $message;
     return $page;
 }
예제 #4
0
파일: Router.php 프로젝트: pixel418/staq
 protected function callController($controller, $action, $route)
 {
     $controllers = $this->setting->getAsArray('auth.controller');
     $exclude = $this->setting['auth.mode'] == 'exclude';
     $level = $this->setting->get('auth.level', 0);
     $inner = in_array($controller, $controllers);
     if ($exclude xor $inner) {
         if (!\Staq::Ctrl('Auth')->isLogged()) {
             throw new \Stack\Exception\MustBeLogged();
         }
         $user = \Staq::Ctrl('Auth')->currentUser();
         if ($user->hasAttribute('right')) {
             if ($user->getAttribute('right')->getSeed() < $level) {
                 throw new \Stack\Exception\NotAllowed();
             }
         }
     }
     $result = parent::callController($controller, $action, $route);
     return $result;
 }
예제 #5
0
파일: View.php 프로젝트: pixel418/staq
 protected function getTwigEnvironmentParameters()
 {
     $params = [];
     $settings = (new \Stack\Setting())->parse('Application.ini');
     if ($settings->getAsBoolean('cache.twig')) {
         if ($cachePath = \Staq::App()->getPath('cache/twig/', TRUE)) {
             $params['cache'] = $cachePath;
         }
     }
     if ($settings->getAsBoolean('error.display_errors')) {
         $this->debug = TRUE;
         $params['debug'] = TRUE;
     }
     return $params;
 }
예제 #6
0
파일: Entity.php 프로젝트: pixel418/staq
 protected function globDataFile($pattern, $asId = false)
 {
     $path = $this->folder;
     $folders = \Staq::App()->getExtensions();
     array_walk($folders, function (&$a) use($path) {
         $a = realpath($a . $path);
     });
     $folders = array_filter($folders, function ($a) {
         return !empty($a);
     });
     $files = [];
     foreach ($folders as $folder) {
         $fullFolder = $folder . DIRECTORY_SEPARATOR . $pattern;
         foreach (glob($fullFolder . '\\.*') as $filename) {
             if ($asId) {
                 $id = \UString::notStartWith($filename, $folder . '/');
                 \UString::doSubstrBeforeLast($id, '.');
                 $files[$id] = $id;
             } else {
                 $files[] = $filename;
             }
         }
     }
     if ($asId) {
         array_values($files);
     }
     return array_reverse($files);
 }
예제 #7
0
 protected function tearDown()
 {
     (new \Stack\Storage\Database\Request())->loadMysqlFile(\Staq::App()->getPath('dataset/reset.sql'));
 }
예제 #8
0
파일: Model.php 프로젝트: pixel418/staq
 protected function redirectList($type)
 {
     $params = [];
     $params['type'] = $type;
     \Staq\Util::httpRedirectUri(\Staq::App()->getUri($this, 'list', $params));
 }
예제 #9
0
 protected function getPublicPath()
 {
     return \Staq::App()->getCurrentUri();
 }
예제 #10
0
파일: Auth.php 프로젝트: pixel418/staq
 protected function getRedirectUri()
 {
     if (isset($_POST['redirect'])) {
         return $_POST['redirect'];
     }
     if (isset($_GET['redirect'])) {
         return $_GET['redirect'];
     }
     return \Staq::App()->getCurrentUri();
 }
예제 #11
0
파일: View.php 프로젝트: pixel418/staq
 protected function addVariables()
 {
     parent::addVariables();
     $this['currentUser'] = \Staq::Ctrl('Auth')->currentUser();
 }
예제 #12
0
파일: Setting.php 프로젝트: pixel418/staq
 protected function getFilePaths($fullSettingFileName)
 {
     $fileNames = $this->getFileNames($fullSettingFileName);
     $platformName = \Staq::App()->getPlatform();
     $filePaths = [];
     foreach (\Staq::App()->getExtensions() as $extension) {
         foreach ($fileNames as $fileName) {
             if ($platformName) {
                 $fileName .= '.' . $platformName;
             }
             while ($fileName) {
                 $path = realpath($extension . '/setting/' . $fileName . '.ini');
                 if ($path) {
                     $filePaths[] = $path;
                 }
                 $fileName = \UString::substrBeforeLast($fileName, '.');
             }
         }
     }
     return array_reverse($filePaths);
 }
예제 #13
0
파일: Util.php 프로젝트: pixel418/staq
 public static function getModelControllerUrl($model, $action = 'view', $parameters = [], $absoluteURL = false)
 {
     $controllerName = \Staq\Util::getStackQuery($model);
     $controller = \Staq::Ctrl($controllerName);
     if ($controller) {
         $parameters = $controller->getRouteAttributes($model);
     }
     $uri = \Staq::App()->getUri($controller, $action, $parameters);
     return \Staq\Util::getPublicUrl($uri, $absoluteURL);
 }