コード例 #1
0
ファイル: route.php プロジェクト: vanie3/appland
 public static function _($url, $xhtml = true, $ssl = null)
 {
     $app = MFactory::getApplication();
     $router = $app->getRouter();
     if (!$router) {
         return null;
     }
     if (strpos($url, '&') !== 0 && strpos($url, 'index.php') !== 0) {
         return $url;
     }
     $uri = $router->build($url);
     $url = $uri->toString(array('path', 'query', 'fragment'));
     $url = preg_replace('/\\s/u', '%20', $url);
     if ((int) $ssl) {
         $uri = MUri::getInstance();
         static $prefix;
         if (!$prefix) {
             $prefix = $uri->toString(array('host', 'port'));
         }
         $scheme = (int) $ssl === 1 ? 'https' : 'http';
         if (!preg_match('#^/#', $url)) {
             $url = '/' . $url;
         }
         $url = $scheme . '://' . $prefix . $url;
     }
     if ($xhtml) {
         $url = htmlspecialchars($url);
     }
     return $url;
 }
コード例 #2
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');
     }
 }
コード例 #3
0
ファイル: factory.php プロジェクト: vanie3/appland
 public static function getUri($uri = 'SERVER')
 {
     mimport('framework.environment.uri');
     return MUri::getInstance($uri);
 }
コード例 #4
0
ファイル: application.php プロジェクト: vanie3/appland
 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();
 }
コード例 #5
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;
 }
コード例 #6
0
ファイル: uri.php プロジェクト: vanie3/appland
 public static function reset()
 {
     self::$instances = array();
     self::$base = array();
     self::$root = array();
     self::$current = '';
 }
コード例 #7
0
ファイル: router.php プロジェクト: vanie3/appland
 protected function _createURI($url)
 {
     // Create full URL if we are only appending variables to it
     if (substr($url, 0, 1) == '&') {
         $vars = array();
         if (strpos($url, '&amp;') !== false) {
             $url = str_replace('&amp;', '&', $url);
         }
         parse_str($url, $vars);
         $vars = array_merge($this->getVars(), $vars);
         foreach ($vars as $key => $var) {
             if ($var == "") {
                 unset($vars[$key]);
             }
         }
         $url = 'index.php?' . MUri::buildQuery($vars);
     }
     // Decompose link into url component parts
     return new MUri($url);
 }