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("'", "'", $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("'", "'", $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("'", "'", $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(); }
function modChrome_outline($module, &$params, &$attribs) { static $css = false; if (!$css) { $css = true; mimport('framework.environment.browser'); $doc = MFactory::getDocument(); $browser = MBrowser::getInstance(); $doc->addStyleDeclaration(".mod-preview-info { padding: 2px 4px 2px 4px; border: 1px solid black; position: absolute; background-color: white; color: red;}"); $doc->addStyleDeclaration(".mod-preview-wrapper { background-color:#eee; border: 1px dotted black; color:#700;}"); if ($browser->getBrowser() == 'msie') { if ($browser->getMajor() <= 7) { $doc->addStyleDeclaration(".mod-preview-info {filter: alpha(opacity=80);}"); $doc->addStyleDeclaration(".mod-preview-wrapper {filter: alpha(opacity=50);}"); } else { $doc->addStyleDeclaration(".mod-preview-info {-ms-filter: alpha(opacity=80);}"); $doc->addStyleDeclaration(".mod-preview-wrapper {-ms-filter: alpha(opacity=50);}"); } } else { $doc->addStyleDeclaration(".mod-preview-info {opacity: 0.8;}"); $doc->addStyleDeclaration(".mod-preview-wrapper {opacity: 0.5;}"); } } ?> <div class="mod-preview"> <div class="mod-preview-info"><?php echo $module->position . "[" . $module->style . "]"; ?> </div> <div class="mod-preview-wrapper"> <?php echo $module->content; ?> </div> </div> <?php }
protected static function includeRelativeFiles($folder, $file, $relative, $detect_browser, $detect_debug) { // If http is present in filename if (strpos($file, 'http') === 0) { $includes = array($file); } else { // Extract extension and strip the file $strip = MFile::stripExt($file); $ext = MFile::getExt($file); // Detect browser and compute potential files if ($detect_browser) { $navigator = MBrowser::getInstance(); $browser = $navigator->getBrowser(); $major = $navigator->getMajor(); $minor = $navigator->getMinor(); // Try to include files named filename.ext, filename_browser.ext, filename_browser_major.ext, filename_browser_major_minor.ext // where major and minor are the browser version names $potential = array($strip, $strip . '_' . $browser, $strip . '_' . $browser . '_' . $major, $strip . '_' . $browser . '_' . $major . '_' . $minor); } else { $potential = array($strip); } // If relative search in template directory or media directory if ($relative) { // Get the template $app = MFactory::getApplication(); $template = $app->getTemplate(); // Prepare array of files $includes = array(); // For each potential files foreach ($potential as $strip) { $files = array(); // Detect debug mode if ($detect_debug && MFactory::getConfig()->get('debug')) { $files[] = $strip . '-uncompressed.' . $ext; } $files[] = $strip . '.' . $ext; // Loop on 1 or 2 files and break on first found foreach ($files as $file) { // If the file is in the template folder if (file_exists(MPATH_THEMES . "/{$template}/{$folder}/{$file}")) { $includes[] = MURI::base(true) . "/templates/{$template}/{$folder}/{$file}"; break; } else { // If the file contains any /: it can be in an media extension subfolder if (strpos($file, '/')) { // Divide the file extracting the extension as the first part before / list($extension, $file) = explode('/', $file, 2); // If the file yet contains any /: it can be a plugin if (strpos($file, '/')) { // Divide the file extracting the element as the first part before / list($element, $file) = explode('/', $file, 2); // Try to deal with plugins group in the media folder if (file_exists(MPATH_ROOT . "/media/{$extension}/{$element}/{$folder}/{$file}")) { $includes[] = MURL_WP_CNT . "/miwi/media/{$extension}/{$element}/{$folder}/{$file}"; break; } elseif (file_exists(MPATH_ROOT . "/media/{$extension}/{$folder}/{$element}/{$file}")) { $includes[] = MURL_WP_CNT . "/miwi/media/{$extension}/{$folder}/{$element}/{$file}"; break; } elseif (file_exists(MPATH_THEMES . "/{$template}/{$folder}/system/{$element}/{$file}")) { $includes[] = MURL_WP_CNT . "/miwi/templates/{$template}/{$folder}/system/{$element}/{$file}"; break; } elseif (file_exists(MPATH_ROOT . "/media/system/{$folder}/{$element}/{$file}")) { $includes[] = MURL_WP_CNT . "/miwi/media/system/{$folder}/{$element}/{$file}"; break; } } elseif (file_exists(MPATH_ROOT . "/media/{$extension}/{$folder}/{$file}")) { $includes[] = MURL_WP_CNT . "/miwi/media/{$extension}/{$folder}/{$file}"; break; } elseif (file_exists(MPATH_THEMES . "/{$template}/{$folder}/system/{$file}")) { $includes[] = MURL_WP_CNT . "/miwi/templates/{$template}/{$folder}/system/{$file}"; break; } elseif (file_exists(MPATH_ROOT . "/media/system/{$folder}/{$file}")) { $includes[] = MURL_WP_CNT . "/miwi/media/system/{$folder}/{$file}"; break; } } elseif (file_exists(MPATH_ROOT . "/media/system/{$folder}/{$file}")) { $includes[] = MURL_WP_CNT . "/miwi/media/system/{$folder}/{$file}"; break; } } } } } else { $includes = array(); foreach ($potential as $strip) { // Detect debug mode if ($detect_debug && MFactory::getConfig()->get('debug') && file_exists(MPATH_ROOT . "/{$strip}-uncompressed.{$ext}")) { $includes[] = MURI::root(false) . "/{$strip}-uncompressed.{$ext}"; } elseif (file_exists(MPATH_ROOT . "/{$strip}.{$ext}")) { $includes[] = MURI::root(false) . "/{$strip}.{$ext}"; } } } } return $includes; }