예제 #1
0
파일: view.php 프로젝트: vanie3/appland
 public function __construct($config = array())
 {
     // Set the view name
     if (empty($this->_name)) {
         if (array_key_exists('name', $config)) {
             $this->_name = $config['name'];
         } else {
             $this->_name = $this->getName();
         }
     }
     // Set the charset (used by the variable escaping functions)
     if (array_key_exists('charset', $config)) {
         $this->_charset = $config['charset'];
     }
     // User-defined escaping callback
     if (array_key_exists('escape', $config)) {
         $this->setEscape($config['escape']);
     }
     // Set a base path for use by the view
     if (array_key_exists('base_path', $config)) {
         $this->_basePath = $config['base_path'];
     } else {
         $this->_basePath = MPATH_COMPONENT;
     }
     // Set the default template search path
     if (array_key_exists('template_path', $config)) {
         // User-defined dirs
         $this->_setPath('template', $config['template_path']);
     } else {
         $this->_setPath('template', $this->_basePath . '/views/' . $this->getName() . '/tmpl');
     }
     // Set the default helper search path
     if (array_key_exists('helper_path', $config)) {
         // User-defined dirs
         $this->_setPath('helper', $config['helper_path']);
     } else {
         $this->_setPath('helper', $this->_basePath . '/helpers');
     }
     // Set the layout
     if (array_key_exists('layout', $config)) {
         $this->setLayout($config['layout']);
     } else {
         $this->setLayout('default');
     }
     $this->baseurl = MUri::base(true);
     MHtml::_('behavior.framework');
     if (MFactory::getApplication()->isAdmin()) {
         MHtml::_('behavior.modal');
     }
 }
예제 #2
0
 public function redirect($url, $msg = '', $msgType = 'message', $moved = false)
 {
     // Check for relative internal links.
     if (preg_match('#^index2?\\.php#', $url)) {
         $url = MUri::base() . $url;
     }
     // Strip out any line breaks.
     $url = preg_split("/[\r\n]/", $url);
     $url = $url[0];
     // If we don't start with a http we need to fix this before we proceed.
     // We could validly start with something else (e.g. ftp), though this would
     // be unlikely and isn't supported by this API.
     if (!preg_match('#^http#i', $url)) {
         $uri = MUri::getInstance();
         $prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         if ($url[0] == '/') {
             // We just need the prefix since we have a path relative to the root.
             $url = $prefix . $url;
         } else {
             // It's relative to where we are now, so lets add that.
             $parts = explode('/', $uri->toString(array('path')));
             array_pop($parts);
             $path = implode('/', $parts) . '/';
             $url = $prefix . $path . $url;
         }
     }
     // If the message exists, enqueue it.
     if (trim($msg)) {
         $this->enqueueMessage($msg, $msgType);
     }
     // Persist messages if they exist.
     if (count($this->_messageQueue)) {
         $session = MFactory::getSession();
         $session->set('application.queue', $this->_messageQueue);
     }
     // WP redirect
     if ($this->isAdmin()) {
         $option = str_replace('com_', '', MRequest::getCmd('option'));
         $url = str_replace('index.php?', 'admin.php?page=' . $option . '&', $url);
     }
     // If the headers have been sent, then we cannot send an additional location header
     // so we will output a javascript redirect statement.
     if (headers_sent()) {
         echo "<script>document.location.href='" . str_replace("'", "&apos;", $url) . "';</script>\n";
     } else {
         mimport('phputf8.utils.ascii');
         mimport('framework.environment.browser');
         $document = MFactory::getDocument();
         $navigator = MBrowser::getInstance();
         if ($navigator->isBrowser('msie') && !utf8_is_ascii($url)) {
             // MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method
             echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />' . '<script>document.location.href=\'' . str_replace("'", "&apos;", $url) . '\';</script></head></html>';
         } elseif (!$moved and $navigator->isBrowser('konqueror')) {
             // WebKit browser (identified as konqueror by Joomla!) - Do not use 303, as it causes subresources
             // reload (https://bugs.webkit.org/show_bug.cgi?id=38690)
             echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />' . '<meta http-equiv="refresh" content="0; url=' . str_replace("'", "&apos;", $url) . '" /></head></html>';
         } else {
             // All other browsers, use the more efficient HTTP header method
             header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other');
             header('Location: ' . $url);
             header('Content-Type: text/html; charset=' . $document->getCharset());
         }
     }
     $this->close();
 }
예제 #3
0
파일: uri.php 프로젝트: vanie3/appland
 public static function reset()
 {
     self::$instances = array();
     self::$base = array();
     self::$root = array();
     self::$current = '';
 }
예제 #4
0
파일: html.php 프로젝트: vanie3/appland
 protected function _fetchTemplate($params = array())
 {
     // Check
     $directory = isset($params['directory']) ? $params['directory'] : 'templates';
     $filter = MFilterInput::getInstance();
     $template = $filter->clean($params['template'], 'cmd');
     $file = $filter->clean($params['file'], 'cmd');
     if (!file_exists($directory . '/' . $template . '/' . $file)) {
         $template = 'system';
     }
     // Load the language file for the template
     $lang = MFactory::getLanguage();
     // 1.5 or core then 1.6
     $lang->load('tpl_' . $template, MPATH_BASE, null, false, false) || $lang->load('tpl_' . $template, $directory . '/' . $template, null, false, false) || $lang->load('tpl_' . $template, MPATH_BASE, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template, $directory . '/' . $template, $lang->getDefault(), false, false);
     // Assign the variables
     $this->template = $template;
     $this->baseurl = MUri::base(true);
     $this->params = isset($params['params']) ? $params['params'] : new MRegistry();
     // Load
     $this->_template = $this->_loadTemplate($directory . '/' . $template, $file);
     return $this;
 }
예제 #5
0
파일: router.php 프로젝트: vanie3/appland
 protected function _buildSefRoute(&$uri)
 {
     // Get the route
     $route = $uri->getPath();
     $route = str_replace('index.php', '', $route);
     // Get the query data
     $query = $uri->getQuery(true);
     if (!isset($query['option'])) {
         return;
     }
     /*
      * Build the component route
      */
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']);
     $tmp = '';
     // Use the component routing handler if it exists
     $path = MPATH_WP_PLG . '/' . str_replace('com_', '', $component) . '/site/router.php';
     // Use the custom routing handler if it exists
     if (file_exists($path) && !empty($query)) {
         require_once $path;
         $function = str_replace('com_', '', $component) . 'BuildRoute';
         $function = str_replace(array("-", "."), "", $function);
         $parts = $function($query);
         // encode the route segments
         $parts = $this->_encodeSegments($parts);
         $result = implode('/', $parts);
         $tmp = $result != "" ? $result : '';
     }
     /*
      * Build the application route
      */
     if ($tmp) {
         $route .= '/' . $tmp;
     } elseif ($route == 'index.php') {
         $route = '';
     }
     $option_get = str_replace('com_', '', MRequest::getWord('option', ''));
     if (str_replace('com_', '', $component) == $option_get) {
         $page_id = MRequest::getInt('page_id');
     } else {
         $page_id = null;
     }
     if (empty($page_id)) {
         $page_id = MFactory::getWOption(str_replace('com_', '', $query['option']) . '_page_id');
     }
     if (!empty($page_id)) {
         $post = MFactory::getWPost($page_id);
         if (is_object($post)) {
             $route = $post->post_name . '/' . ltrim($route, '/');
         }
         $route = MUri::base(true) . '/' . ltrim($route, '/');
     }
     // Unset unneeded query information
     unset($query['option']);
     //Set query again in the URI
     $uri->setQuery($query);
     $uri->setPath($route);
 }