Example #1
0
 public function runResolve(framework\Request $request)
 {
     $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName();
     if ($request->hasParameter('css')) {
         $this->getResponse()->setContentType('text/css');
         if (!$request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css');
         } else {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css');
         }
     } elseif ($request->hasParameter('js')) {
         $this->getResponse()->setContentType('text/javascript');
         if ($request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js');
         } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
             $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js');
         } else {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js');
         }
     } else {
         throw new \Exception('The expected theme Asset type is not supported.');
     }
     $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath)));
     $fileAsset->load();
     // Do not decorate the asset with the theme's header/footer
     $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE);
     return $this->renderText($fileAsset->dump());
 }
Example #2
0
    ?>
>
                <span class="badge csrf <?php 
    echo $csrf_enabled ? 'enabled' : '';
    ?>
">CSRF</span>
                <span class="badge routename"><?php 
    echo $route_name;
    ?>
</span>
                <span class="badge url"><?php 
    echo $route;
    ?>
</span>
                <span class="badge method">\thebuggenie\<?php 
    echo Context::isInternalModule($module) ? "core\\" : '';
    ?>
<span class="badge modulename"><?php 
    echo $module;
    ?>
</span>\Actions::<?php 
    echo $action;
    ?>
()</span>
                <?php 
    if ($overridden) {
        ?>
                    <span class="badge csrf <?php 
        echo $csrf_enabled ? 'enabled' : '';
        ?>
">Overridden</span>
Example #3
0
 protected function loadModuleAnnotationRoutes($classname, $module)
 {
     if (!class_exists($classname)) {
         return;
     }
     $internal = Context::isInternalModule($module);
     $reflection = new \ReflectionClass($classname);
     $docblock = $reflection->getDocComment();
     $annotationset = new AnnotationSet($docblock);
     $route_url_prefix = '';
     $route_name_prefix = '';
     $default_route_name_prefix = $internal ? '' : $module . '_';
     if ($annotationset->hasAnnotation('Routes')) {
         $routes = $annotationset->getAnnotation('Routes');
         if ($routes->hasProperty('url_prefix')) {
             $route_url_prefix = $routes->getProperty('url_prefix');
         }
         if ($routes->hasProperty('name_prefix')) {
             $route_name_prefix = $routes->getProperty('name_prefix', $default_route_name_prefix);
         }
     } else {
         $route_name_prefix = $default_route_name_prefix;
     }
     foreach ($reflection->getMethods() as $method) {
         $annotationset = new AnnotationSet($method->getDocComment());
         if ($annotationset->hasAnnotation('Route')) {
             if (substr($method->name, 0, 3) != 'run') {
                 throw new exceptions\InvalidRouteException('A @Route annotation can only be used on methods prefixed with "run"');
             }
             $options = array();
             $route_annotation = $annotationset->getAnnotation('Route');
             $action = substr($method->name, 3);
             $name = $route_name_prefix . ($route_annotation->hasProperty('name') ? $route_annotation->getProperty('name') : strtolower($action));
             $route = $route_url_prefix . $route_annotation->getProperty('url');
             $options['csrf_enabled'] = $annotationset->hasAnnotation('CsrfProtected');
             $options['anonymous_route'] = $annotationset->hasAnnotation('AnonymousRoute');
             $http_methods = $route_annotation->getProperty('methods', array());
             $params = $annotationset->hasAnnotation('Parameters') ? $annotationset->getAnnotation('Parameters')->getProperties() : array();
             if ($annotationset->hasAnnotation('Overrides')) {
                 $name = $annotationset->getAnnotation('Overrides')->getProperty('name');
                 $this->overrideRoute($name, $module, $action);
             } elseif ($this->hasRoute($name)) {
                 throw new exceptions\RoutingException('A route that overrides another route must have an @Override annotation');
             } else {
                 $this->addRoute($name, $route, $module, $action, $params, $options, $http_methods);
             }
         }
     }
 }
Example #4
0
 public function runResolve(framework\Request $request)
 {
     $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName();
     $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
     if ($request->hasParameter('css')) {
         $this->getResponse()->setContentType('text/css');
         if ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'css';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'css' . DS . $request->getParameter('css');
         } elseif (!$request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css');
         } else {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css');
         }
     } elseif ($request->hasParameter('js')) {
         $this->getResponse()->setContentType('text/javascript');
         if ($request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js');
         } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js');
         } else {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js');
         }
     } elseif ($request->hasParameter('image')) {
         $basepath = THEBUGGENIE_PATH . 'themes';
         $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'images';
         if (isset($request['module_name'])) {
             $asset .= DS . "modules" . DS . $request['module_name'];
         }
         if (isset($request['folder'])) {
             $asset .= DS . $request['folder'];
         }
         $asset .= DS . $request->getParameter('image');
         if (!file_exists($asset) && isset($request['module_name']) && framework\Context::isModuleLoaded($request['module_name'])) {
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'images';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'images';
             if (isset($request['folder'])) {
                 $asset .= DS . $request['folder'];
             }
             $asset .= DS . $request->getParameter('image');
         }
         $fileinfo = finfo_open(FILEINFO_MIME_TYPE);
         $mimetype = finfo_file($fileinfo, $asset);
         finfo_close($fileinfo);
         $this->getResponse()->setContentType($mimetype);
     } else {
         throw new \Exception('The expected theme Asset type is not supported.');
     }
     $last_modified = filemtime($asset);
     $this->getResponse()->addHeader('Cache-Control: max-age=3600, must-revalidate');
     $this->getResponse()->addHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s ', $last_modified) . 'GMT');
     $this->getResponse()->addHeader('ETag: ' . md5($last_modified));
     if (!$this->getResponse()->isModified($last_modified)) {
         return $this->return304();
     }
     $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath)));
     $fileAsset->load();
     // Do not decorate the asset with the theme's header/footer
     $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE);
     return $this->renderText($fileAsset->dump());
 }