예제 #1
0
     * @see Atomik::url()
     * @param string $plugin Plugin's name (default is the currently running pluggable app)
     * @param string $filename
     * @param array $params
     * @return string
     */
    public static function pluginAsset($plugin, $filename, $params = array())
    {
        $template = self::get('atomik.plugin_assets_tpl', 'app/plugins/%s/assets');
        $dirname = rtrim(sprintf($template, ucfirst($plugin)), '/');
        $filename = '/' . ltrim($filename, '/');
        return self::url($dirname . $filename, $params, false, false);
    }
    /**
     * Triggers a 404 error
     *
     * @param string $message
     */
    public static function trigger404($message = 'Not found')
    {
        throw new AtomikHttpException($message, 404);
    }
}
/* -------------------------------------------------------------------------------------------
 *  APPLICATION CONFIGURATION
 * ------------------------------------------------------------------------------------------ */
Atomik::reset(array('app' => array('default_action' => 'index', 'layout' => false, 'disable_layout' => false, 'vars_to_layout' => true, 'routes' => array(), 'force_uri_extension' => false, 'router' => 'Atomik::route', 'executor' => 'Atomik::executeFile', 'views' => array('auto' => true, 'file_extension' => '.phtml', 'short_tags' => true, 'engine' => false, 'default_context' => 'html', 'context_param' => 'format', 'contexts' => array('html' => array('suffix' => '', 'layout' => true, 'content_type' => 'text/html'), 'ajax' => array('suffix' => '', 'layout' => false, 'content_type' => 'text/html'), 'xml' => array('suffix' => 'xml', 'layout' => false, 'content_type' => 'text/xml'), 'json' => array('suffix' => 'json', 'layout' => false, 'content_type' => 'application/json'), 'js' => array('suffix' => 'js', 'layout' => false, 'content_type' => 'text/javascript'), 'css' => array('suffix' => 'css', 'layout' => false, 'content_type' => 'text/css'))), 'http_method_param' => '_method', 'allowed_http_methods' => array('GET', 'POST', 'PUT', 'DELETE', 'TRACE', 'HEAD', 'OPTIONS', 'CONNECT'))));
/* -------------------------------------------------------------------------------------------
 *  CORE CONFIGURATION
 * ------------------------------------------------------------------------------------------ */
Atomik::set(array('plugins' => array(), 'atomik' => array('base_url' => null, 'url_rewriting' => false, 'auto_uri_wildcard' => false, 'debug' => false, 'trigger' => 'action', 'class_autoload' => true, 'plugin_assets_tpl' => 'app/plugins/%s/assets/', 'dirs' => array('public' => '.', 'plugins' => array('Atomik' => __DIR__ . '/plugins', 'app/plugins'), 'actions' => 'app/actions', 'views' => 'app/views', 'layouts' => array('app/views', 'app/layouts'), 'helpers' => array('Atomik\\Helpers' => __DIR__ . '/helpers', 'app/helpers'), 'includes' => array('Atomik' => __DIR__ . '/plugins', 'app/includes', 'app/libs'), 'overrides' => 'app/overrides'), 'files' => array('index' => 'index.php', 'config' => 'app/config', 'bootstrap' => 'app/bootstrap.php', 'pre_dispatch' => 'app/pre_dispatch.php', 'post_dispatch' => 'app/post_dispatch.php')), 'start_time' => time() + microtime()));
예제 #2
0
Atomik::reset(array(

    'app' => array(
    
        /* @var string */
        'default_action'        => 'index',

        /* The name of the layout
         * Add multiple layouts using an array (will be rendered in reverse order)
         * @var array|bool|string */
        'layout'                => false,
    
        /* @var bool */
        'disable_layout'        => false,
        
        /* An array where keys are route names and their value is an associative
         * array of default values
         * @see Atomik::route()
         * @var array */
        'routes'                => array(),
    
        /* @var bool */
        'force_uri_extension'   => false,
            
        /* List of escaping profiles where keys are profile names and their
         * value an array of callbacks
         * @see Atomik::escape()
         * @var array */
        'escaping' => array(
            'default'           => array('htmlspecialchars', 'nl2br')
        ),
    
        /* @see Atomik::filter()
         * @var array */
        'filters' => array(
        
            /* @var array */
            'rules'             => array(),
            
            /* @var array */
            'callbacks'         => array(),
            
            /* @var string */
            'default_message'   => 'The %s field failed to validate',
            
            /* @var string */
            'required_message'  => 'The %s field must be filled'
        ),
    
        /* @see Atomik::render()
         * @var array */
        'views' => array(
        
            /* @var string */
            'file_extension'     => '.phtml',
            
            /* Alternative rendering engine
             * @see Atomik::_render()
             * @var callback */
            'engine'             => false,
            
            /* @var string */
            'default_context'    => 'html',
            
            /* The GET parameter to retrieve the current context
             * @var string */
            'context_param'      => 'format',
            
            /* List of contexts where keys are the context name.
             * Contexts can specify:
             *  - prefix (string): the view filename's extension prefix
             *  - layout (bool): whether the layout should be rendered
             *  - content_type (string): the HTTP response content type
             * @var array */
            'contexts' => array(
                'html' => array(
                    'prefix'         => '',
                    'layout'         => true,
                    'content_type'   => 'text/html'
                ),
                'ajax' => array(
                    'prefix'         => '',
                    'layout'         => false,
                    'content_type'   => 'text/html'
                ),
                'xml' => array(
                    'prefix'         => 'xml',
                    'layout'         => false,
                    'content_type'   => 'text/xml'
                ),
                'json' => array(
                    'prefix'         => 'json',
                    'layout'         => false,
                    'content_type'   => 'application/json'
                )
            )
        ),
        
        /* A parameter in the route that will allow to specify the http method 
         * (override the request's method). False to disable
         * @var string */
        'http_method_param'       => '_method',
        
        /* @var array */
        'allowed_http_methods'    => array('GET', 'POST', 'PUT', 'DELETE', 'TRACE', 'HEAD', 'OPTIONS', 'CONNECT')
        
     )       
));