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; }
public function render($name, $params = array(), $content = null) { // Initialise variables. $buffer = null; $lists = null; // Get the message queue $messages = MFactory::getApplication()->getMessageQueue(); // Build the sorted message list if (is_array($messages) && !empty($messages)) { foreach ($messages as $msg) { if (isset($msg['type']) && isset($msg['message'])) { $lists[$msg['type']][] = $msg['message']; } } } // If messages exist render them if (is_array($lists)) { foreach ($lists as $type => $msgs) { $class = 'updated'; if ($type == 'error' or $type == 'warning') { $class = 'error'; } if (count($msgs)) { foreach ($msgs as $msg) { $buffer .= "\n" . '<div id="message" class="' . $class . '">'; $buffer .= "\n\t\t" . '<p>' . $msg . '</p>'; $buffer .= "</div>"; } } } } return $buffer; }
public static function isWinOS() { // Deprecation warning. MLog::add('MUtility::isWinOS() is deprecated.', MLog::WARNING, 'deprecated'); $application = MFactory::getApplication(); return $application->isWinOS(); }
function display($tpl = null) { $mainframe = MFactory::getApplication(); $option = MRequest::getCmd('option'); $document = MFactory::getDocument(); $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css'); MToolBarHelper::title(MText::_('MiwoSQL') . ' - ' . MText::_('COM_MIWOSQL_SAVED_QUERIES'), 'miwosql'); MToolBarHelper::editList(); MToolBarHelper::deleteList(); // ACL if (version_compare(MVERSION, '1.6.0', 'ge') && MFactory::getUser()->authorise('core.admin', 'com_miwosql')) { MToolBarHelper::divider(); MToolBarHelper::preferences('com_miwosql', '550'); } $this->mainframe = MFactory::getApplication(); $this->option = MRequest::getWord('option'); $filter_order = $mainframe->getUserStateFromRequest($option . '.queries.filter_order', 'filter_order', 'title', 'string'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . '.queries.filter_order_Dir', 'filter_order_Dir', '', 'word'); $search = $mainframe->getUserStateFromRequest($option . '.queries.search', 'search', '', 'string'); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // search filter $lists['search'] = $search; $this->lists = $lists; $this->items = $this->get('Data'); $this->pagination = $this->get('Pagination'); parent::display($tpl); }
public function __construct($context) { $this->context = $context; $this->constants(); $miwi = MPATH_WP_CNT . '/miwi/initialise.php'; if (!file_exists($miwi)) { return false; } require_once $miwi; $this->app = MFactory::getApplication(); $this->app->initialise(); mimport('framework.filesystem.file'); }
function __construct() { parent::__construct(); $this->mainframe = MFactory::getApplication(); $this->option = MRequest::getWord('option'); // Get the pagination request variables $limit = $this->mainframe->getUserStateFromRequest($this->option . '.queries.limit', 'limit', $this->mainframe->getCfg('list_limit'), 'int'); $limitstart = $this->mainframe->getUserStateFromRequest($this->option . '.queries.limitstart', 'limitstart', 0, 'int'); // In case limit has been changed, adjust limitstart accordingly $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0; $this->setState($this->option . '.queries.limit', $limit); $this->setState($this->option . '.queries.limitstart', $limitstart); $this->_buildViewQuery(); }
public static function administrator($file, $folder = '/images/', $altFile = null, $altFolder = '/images/', $alt = null, $attribs = null, $asTag = true) { // Deprecation warning. MLog::add('MImage::administrator is deprecated.', MLog::WARNING, 'deprecated'); $app = MFactory::getApplication(); if (is_array($attribs)) { $attribs = MArrayHelper::toString($attribs); } $cur_template = $app->getTemplate(); // Strip HTML. $alt = html_entity_decode($alt, ENT_COMPAT, 'UTF-8'); if ($altFile) { $image = $altFolder . $altFile; } elseif ($altFile == -1) { $image = ''; } else { if (file_exists(MPATH_ADMINISTRATOR . '/templates/' . $cur_template . '/images/' . $file)) { $image = 'templates/' . $cur_template . '/images/' . $file; } else { // Compatibility with previous versions. if (substr($folder, 0, 14) == "/administrator") { $image = substr($folder, 15) . $file; } else { $image = $folder . $file; } } } if (substr($image, 0, 1) == "/") { $image = substr_replace($image, '', 0, 1); } // Prepend the base path. $image = MURI::base(true) . '/' . $image; // Outputs actual HTML <img> tag. if ($asTag) { $image = '<img src="' . $image . '" alt="' . $alt . '" ' . $attribs . ' />'; } return $image; }
public function addEntry(MLogEntry $entry) { switch ($entry->priority) { case MLog::EMERGENCY: case MLog::ALERT: case MLog::CRITICAL: case MLog::ERROR: MFactory::getApplication()->enqueueMessage($entry->message, 'error'); break; case MLog::WARNING: MFactory::getApplication()->enqueueMessage($entry->message, 'warning'); break; case MLog::NOTICE: MFactory::getApplication()->enqueueMessage($entry->message, 'notice'); break; case MLog::INFO: MFactory::getApplication()->enqueueMessage($entry->message, 'message'); break; default: // Ignore other priorities. break; } }
public static function renderComponent($option, $params = array()) { $app = MFactory::getApplication(); $lang = MFactory::getLanguage(); if (empty($option)) { throw new Exception(MText::_('MLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404); } // Record the scope $scope = $app->scope; // Set scope to component name $app->scope = $option; // Build the component path. $option = preg_replace('/[^A-Z0-9_\\.-]/i', '', $option); $file = substr($option, 4); // Define component path. define('MPATH_COMPONENT_SITE', MPATH_WP_PLG . '/' . $file . '/site'); define('MPATH_COMPONENT_ADMINISTRATOR', MPATH_WP_PLG . '/' . $file . '/admin'); if (MFactory::getApplication()->isAdmin()) { define('MPATH_COMPONENT', MPATH_COMPONENT_ADMINISTRATOR); } else { define('MPATH_COMPONENT', MPATH_COMPONENT_SITE); } $path = MPATH_COMPONENT . '/' . $file . '.php'; // If component is disabled throw error if (!self::isEnabled($option) || !file_exists($path)) { throw new Exception(MText::_('MLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404); } // Load common and local language files. $lang->load($option, MPATH_COMPONENT, null, false, true); // Handle template preview outlining. $contents = null; // Execute the component. $contents = self::executeComponent($path); // Revert the scope $app->scope = $scope; return $contents; }
public static function getLanguages($key = 'default') { static $languages; if (empty($languages)) { // Installation uses available languages if (MFactory::getApplication()->getClientId() == 2) { $languages[$key] = array(); $knownLangs = MLanguage::getKnownLanguages(MPATH_BASE); foreach ($knownLangs as $metadata) { // Take off 3 letters iso code languages as they can't match browsers' languages and default them to en $languages[$key][] = new MObject(array('lang_code' => $metadata['tag'])); } } else { $cache = MFactory::getCache('com_languages', ''); if (!($languages = $cache->get('languages'))) { $langs = get_available_languages(); $i = 0; $lngs = array(); foreach ($langs as $lang) { $lngs[$i] = new stdClass(); $lngs[$i]->title = $lang; $i++; } $languages['default'] = $lngs; $languages['lang_code'] = array(); if (isset($languages['default'][0])) { foreach ($languages['default'] as $lang) { $languages['lang_code'][$lang->title] = $lang; } } $cache->store($languages, 'languages'); } } } return $languages[$key]; }
public function initialise() { $miwi = MPATH_WP_CNT . '/miwi/initialise.php'; if (!file_exists($miwi)) { return false; } require_once $miwi; $this->app = MFactory::getApplication(); $this->app->initialise(); # auto upgrade mimport('joomla.application.component.helper'); $config = MComponentHelper::getParams('com_' . $this->context); if (!empty($config) and file_exists(MPATH_WP_CNT . '/miwi/autoupdate.php')) { $pid = $config->get('pid'); if (!empty($pid)) { $path = 'http://miwisoft.com/index.php?option=com_mijoextensions&view=download&pack=upgrade&model=' . $this->context . '&pid=' . $pid; require_once MPATH_WP_CNT . '/miwi/autoupdate.php'; new MiwisoftAutoUpdate($path, $this->context); } } }
public static function getRouter($name = null, array $options = array()) { if (!isset($name)) { $app = MFactory::getApplication(); $name = $app->getName(); } $config = MFactory::getConfig(); $options['mode'] = $config->get('sef'); mimport('framework.application.router'); $router = MRouter::getInstance($name, $options); if ($router instanceof Exception) { return null; } return $router; }
public static function checkToken($method = 'post') { if ($method == 'default') { trigger_error("MSession::checkToken() doesn't support 'default' for the method parameter.", E_USER_ERROR); return false; } $token = self::getFormToken(); $app = MFactory::getApplication(); if (!MRequest::getVar($token, '', $method, 'alnum')) { $session = MFactory::getSession(); if ($session->isNew()) { // Redirect to login screen. $app->redirect(MRoute::_('index.php'), MText::_('MLIB_ENVIRONMENT_SESSION_EXPIRED')); $app->close(); } else { return false; } } else { return true; } }
protected function getLayoutsFromViews($plugin, $view) { $options = array(); $layouts = array(); $layoutNames = array(); $app = MFactory::getApplication(); $path = ''; // Get the views for this component. if (is_dir(MPATH_WP_PLG . '/' . $plugin . '/site')) { $folders = MFolder::folders(MPATH_WP_PLG . '/' . $plugin . '/site', '^view[s]?$', false, true); } if (!empty($folders[0])) { $path = $folders[0] . '/' . $view . '/tmpl'; } if (is_dir($path)) { $layouts = array_merge($layouts, MFolder::files($path, '.xml$', false, true)); } else { return $options; } // Build list of standard layout names foreach ($layouts as $layout) { // Ignore private layouts. if (strpos(basename($layout), '_') === false) { // Get the layout name. $layoutNames[] = basename($layout, '.xml'); } } // Get the template layouts $tmpl = $app->getTemplate(); // Array to hold association between template file names and templates $templateName = array(); //@TODO : Do not forget that delete "com_" string if (is_dir(MPATH_THEMES . '/' . $tmpl . '/html/com_' . $plugin . '/' . $view)) { $templateLayouts = MFolder::files(MPATH_THEMES . '/' . $tmpl . '/html/com_' . $plugin . '/' . $view, '.xml$', false, true); foreach ($templateLayouts as $templateLayout) { // Get the layout name. $templateLayoutName = basename($templateLayout, '.xml'); // add to the list only if it is not a standard layout if (array_search($templateLayoutName, $layoutNames) === false) { $layouts[] = $templateLayout; // Set template name array so we can get the right template for the layout $templateName[$templateLayout] = $tmpl; } } } // Process the found layouts. foreach ($layouts as $layout) { $file = $layout; $array = array(); // Ignore private layouts. if (strpos(basename($layout), '_') === false) { $form = new MForm(basename($layout)); $form->loadFile($layout, true, '/metadata'); if (is_file($file)) { // Attempt to load the xml file. if ($xml = simplexml_load_file($file)) { // Look for the first view node off of the root node. if ($menu = $xml->xpath('layout[1]')) { $menu = $menu[0]; // If the view is hidden from the menu, discard it and move on to the next view. if (!empty($menu['hidden']) && $menu['hidden'] == 'true') { unset($xml); unset($o); continue; } // Populate the title and description if they exist. if (!empty($menu['title'])) { $array['title'] = trim((string) $menu['title']); } } } } // Add the layout to the options array. $array['form'] = $form; $options[$view . '_' . basename($layout, '.xml')] = $array; } } return $options; }
protected function _item_inactive(&$item) { $app = MFactory::getApplication(); if ($app->isAdmin()) { return "<span class=\"pagination_link\">" . $item->text . "</span>"; } else { return "<span class=\"pagenav\">" . $item->text . "</span>"; } }
protected function populateState() { $table = $this->getTable(); $key = $table->getKeyName(); // Get the pk of the record from the request. $pk = MFactory::getApplication()->input->getInt($key); $this->setState($this->getName() . '.id', $pk); // Load the parameters. $value = MComponentHelper::getParams($this->option); $this->setState('params', $value); }
public static function makeId() { $app = MFactory::getApplication(); if (!empty($app->registeredurlparams)) { $registeredurlparams = $app->registeredurlparams; } else { return md5(serialize(MRequest::getURI())); } $registeredurlparams->format = 'WORD'; $registeredurlparams->option = 'WORD'; $registeredurlparams->view = 'WORD'; $registeredurlparams->layout = 'WORD'; $registeredurlparams->tpl = 'CMD'; $registeredurlparams->id = 'INT'; $safeuriaddon = new stdClass(); foreach ($registeredurlparams as $key => $value) { $safeuriaddon->{$key} = MRequest::getVar($key, null, 'default', $value); } return md5(serialize($safeuriaddon)); }
public static function getLayoutPath($module, $layout = 'default') { $template = MFactory::getApplication()->getTemplate(); $defaultLayout = $layout; if (strpos($layout, ':') !== false) { // Get the template and file name from the string $temp = explode(':', $layout); $template = $temp[0] == '_' ? $template : $temp[0]; $layout = $temp[1]; $defaultLayout = $temp[1] ? $temp[1] : 'default'; } // Build the template and base path for the layout $tPath = MPATH_THEMES . '/' . $template . '/html/' . $module . '/' . $layout . '.php'; $bPath = MPATH_MODULES . '/' . $module . '/tmpl/' . $defaultLayout . '.php'; $dPath = MPATH_MODULES . '/' . $module . '/tmpl/default.php'; // If the template has a layout override use it if (file_exists($tPath)) { return $tPath; } elseif (file_exists($bPath)) { return $bPath; } else { return $dPath; } }
public static function noframes() { // Only load once if (isset(self::$loaded[__METHOD__])) { return; } // Include MooTools framework self::framework(); // Include jQuery MHtml::_('jquery.framework'); $js = "jQuery(function () {if (top == self) {document.documentElement.style.display = 'block'; }" . " else {top.location = self.location; }});"; $document = MFactory::getDocument(); $document->addStyleDeclaration('html { display:none }'); $document->addScriptDeclaration($js); MFactory::getApplication()->setHeader('X-Frames-Options', 'SAMEORIGIN'); self::$loaded[__METHOD__] = true; }
public static function customErrorPage(&$error) { // Deprecation warning. MLog::add('MError::customErrorPage() is deprecated.', MLog::WARNING, 'deprecated'); // Initialise variables. $app = MFactory::getApplication(); $document = MDocument::getInstance('error'); if ($document) { $config = MFactory::getConfig(); // Get the current template from the application $template = $app->getTemplate(); // Push the error object into the document $document->setError($error); // If site is offline and it's a 404 error, just go to index (to see offline message, instead of 404) if ($error->getCode() == '404' && MFactory::getConfig()->get('offline') == 1) { MFactory::getApplication()->redirect('index.php'); } @ob_end_clean(); $document->setTitle(MText::_('Error') . ': ' . $error->get('code')); $data = $document->render(false, array('template' => $template, 'directory' => MPATH_THEMES, 'debug' => $config->get('debug'))); // Failsafe to get the error displayed. if (empty($data)) { self::handleEcho($error, array()); } else { // Do not allow cache MResponse::allowCache(false); MResponse::setBody($data); echo MResponse::toString(); } } else { // Must echo the error since there is no document // This is a common use case for Command Line Interface applications. self::handleEcho($error, array()); } $app->close(0); }
protected function releaseEditId($context, $id) { $app = MFactory::getApplication(); $values = (array) $app->getUserState($context . '.id'); // Do a strict search of the edit list values. $index = array_search((int) $id, $values, true); if (is_int($index)) { unset($values[$index]); $app->setUserState($context . '.id', $values); if (defined('MDEBUG') && MDEBUG) { MLog::add(sprintf('Releasing edit ID %s.%s %s', $context, $id, str_replace("\n", ' ', print_r($values, 1))), MLog::INFO, 'controller'); } } }
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; }
public static function checkToken($method = 'post') { $token = MSession::getFormToken(); if (!self::getVar($token, '', $method, 'alnum')) { $session = MFactory::getSession(); if ($session->isNew()) { // Redirect to login screen. $app = MFactory::getApplication(); $return = MRoute::_('index.php'); $app->redirect($return, MText::_('MLIB_ENVIRONMENT_SESSION_EXPIRED')); $app->close(); } else { return false; } } else { return true; } }
protected function _noChange() { $app = MFactory::getApplication(); header('HTTP/1.x 304 Not Modified', true); $app->close(); }
protected function cleanCache($group = null, $client_id = 0) { $conf = MFactory::getConfig(); $dispatcher = MEventDispatcher::getInstance(); $options = array('defaultgroup' => $group ? $group : (isset($this->option) ? $this->option : MFactory::getApplication()->input->get('option')), 'cachebase' => $client_id ? MPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', MPATH_SITE . '/cache')); $cache = MCache::getInstance('callback', $options); $cache->clean(); // Trigger the onContentCleanCache event. $dispatcher->trigger($this->event_clean_cache, $options); }
public function _replacePrefix($query) { $mainframe = MFactory::getApplication(); $msg = ''; $config_file = MPATH_CONFIGURATION . '/configuration.php'; list($prefix, $new_prefix) = sscanf(str_replace(array('`', '"', "'"), '', strtolower(trim($query))), "replace prefix %s to %s"); if (!is_writable($config_file)) { echo '<h2 style="color: red;">' . sprintf(MText::_('COM_MIWOSQL_CONFIG_NOT_WRITABLE'), $config_fname) . '</h2>'; return $msg; } $this->_db->setQuery("SHOW TABLES LIKE '" . $prefix . "%'"); $tables = $this->_db->loadResultArray(); foreach ($tables as $tbl) { $new_tbl = str_replace($prefix, $new_prefix, $tbl); $this->_db->setQuery('ALTER TABLE `' . $tbl . '` RENAME `' . $new_tbl . '`'); $this->_db->query(); if (!empty($this->_db->_errorMsg)) { echo '<small style="color:red;">' . $this->_db->_errorMsg . '</small><br/>'; } } $config = MFactory::getConfig(); if (version_compare(MVERSION, '1.6.0', 'ge')) { $config->set('dbprefix', $new_prefix); } else { $config->setValue('config.dbprefix', $new_prefix); } /*jimport('joomla.filesystem.path'); if (!$ftp['enabled'] && MPath::isOwner($config_fname) && !MPath::setPermissions($config_fname, '0644')) { MError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php writable'); }*/ mimport('framwork.filesystem.file'); if (version_compare(MVERSION, '1.6.0', 'ge')) { if (!MFile::write($config_file, $config->toString('PHP', array('class' => 'MConfig', 'closingtag' => false)))) { $msg = MText::_('COM_MIWOSQL_DONE'); } else { $msg = MText::_('ERRORCONFIGFILE'); } } else { if (MFile::write($config_file, $config->toString('PHP', 'config', array('class' => 'MConfig')))) { $msg = MText::_('COM_MIWOSQL_DONE'); } else { $msg = MText::_('ERRORCONFIGFILE'); } } return $msg; }
public function fetchHead(&$document) { // Trigger the onBeforeCompileHead event (skip for installation, since it causes an error) $app = MFactory::getApplication(); $app->triggerEvent('onBeforeCompileHead'); // Get line endings $lnEnd = $document->_getLineEnd(); $tab = $document->_getTab(); $tagEnd = ' />'; $buffer = ''; // Generate base tag (need to happen first) $base = $document->getBase(); if (!empty($base)) { $buffer .= $tab . '<base href="' . $document->getBase() . '" />' . $lnEnd; } // Generate META tags (needs to happen as early as possible in the head) foreach ($document->_metaTags as $type => $tag) { foreach ($tag as $name => $content) { if ($type == 'http-equiv') { $content .= '; charset=' . $document->getCharset(); $buffer .= $tab . '<meta http-equiv="' . $name . '" content="' . htmlspecialchars($content) . '" />' . $lnEnd; } elseif ($type == 'standard' && !empty($content)) { $buffer .= $tab . '<meta name="' . $name . '" content="' . htmlspecialchars($content) . '" />' . $lnEnd; } } } // Don't add empty descriptions $documentDescription = $document->getDescription(); if ($documentDescription) { $buffer .= $tab . '<meta name="description" content="' . htmlspecialchars($documentDescription) . '" />' . $lnEnd; } // Don't add empty generators $generator = $document->getGenerator(); if ($generator) { $buffer .= $tab . '<meta name="generator" content="' . htmlspecialchars($generator) . '" />' . $lnEnd; } $buffer .= $tab . '<title>' . htmlspecialchars($document->getTitle(), ENT_COMPAT, 'UTF-8') . '</title>' . $lnEnd; // Generate link declarations foreach ($document->_links as $link => $linkAtrr) { $buffer .= $tab . '<link href="' . $link . '" ' . $linkAtrr['relType'] . '="' . $linkAtrr['relation'] . '"'; if ($temp = MArrayHelper::toString($linkAtrr['attribs'])) { $buffer .= ' ' . $temp; } $buffer .= ' />' . $lnEnd; } // Generate stylesheet links foreach ($document->_styleSheets as $strSrc => $strAttr) { $buffer .= $tab . '<link rel="stylesheet" href="' . $strSrc . '" type="' . $strAttr['mime'] . '"'; if (!is_null($strAttr['media'])) { $buffer .= ' media="' . $strAttr['media'] . '" '; } if ($temp = MArrayHelper::toString($strAttr['attribs'])) { $buffer .= ' ' . $temp; } $buffer .= $tagEnd . $lnEnd; } // Generate stylesheet declarations foreach ($document->_style as $type => $content) { $buffer .= $tab . '<style type="' . $type . '">' . $lnEnd; // This is for full XHTML support. if ($document->_mime != 'text/html') { $buffer .= $tab . $tab . '<![CDATA[' . $lnEnd; } $buffer .= $content . $lnEnd; // See above note if ($document->_mime != 'text/html') { $buffer .= $tab . $tab . ']]>' . $lnEnd; } $buffer .= $tab . '</style>' . $lnEnd; } // Generate script file links foreach ($document->_scripts as $strSrc => $strAttr) { $buffer .= $tab . '<script src="' . $strSrc . '"'; if (!is_null($strAttr['mime'])) { $buffer .= ' type="' . $strAttr['mime'] . '"'; } if ($strAttr['defer']) { $buffer .= ' defer="defer"'; } if ($strAttr['async']) { $buffer .= ' async="async"'; } $buffer .= '></script>' . $lnEnd; } // Generate script declarations foreach ($document->_script as $type => $content) { $buffer .= $tab . '<script type="' . $type . '">' . $lnEnd; // This is for full XHTML support. if ($document->_mime != 'text/html') { $buffer .= $tab . $tab . '<![CDATA[' . $lnEnd; } $buffer .= $content . $lnEnd; // See above note if ($document->_mime != 'text/html') { $buffer .= $tab . $tab . ']]>' . $lnEnd; } $buffer .= $tab . '</script>' . $lnEnd; } // Generate script language declarations. if (count(MText::script())) { $buffer .= $tab . '<script type="text/javascript">' . $lnEnd; $buffer .= $tab . $tab . '(function() {' . $lnEnd; $buffer .= $tab . $tab . $tab . 'var strings = ' . json_encode(MText::script()) . ';' . $lnEnd; $buffer .= $tab . $tab . $tab . 'if (typeof Miwi == \'undefined\') {' . $lnEnd; $buffer .= $tab . $tab . $tab . $tab . 'Miwi = {};' . $lnEnd; $buffer .= $tab . $tab . $tab . $tab . 'Miwi.MText = strings;' . $lnEnd; $buffer .= $tab . $tab . $tab . '}' . $lnEnd; $buffer .= $tab . $tab . $tab . 'else {' . $lnEnd; $buffer .= $tab . $tab . $tab . $tab . 'Miwi.MText.load(strings);' . $lnEnd; $buffer .= $tab . $tab . $tab . '}' . $lnEnd; $buffer .= $tab . $tab . '})();' . $lnEnd; $buffer .= $tab . '</script>' . $lnEnd; } foreach ($document->_custom as $custom) { $buffer .= $tab . $custom . $lnEnd; } return $buffer; }
public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true) { $app = MFactory::getApplication(); $input = $app->input; $old_state = $app->getUserState($key); $cur_state = !is_null($old_state) ? $old_state : $default; $new_state = $input->get($request, null, $type); if ($cur_state != $new_state && $resetPage) { $input->set('limitstart', 0); } // Save the new value only if it is set in this request. if ($new_state !== null) { $app->setUserState($key, $new_state); } else { $new_state = $cur_state; } return $new_state; }
protected function _setPath($type, $path) { $component = MApplicationHelper::getComponentName(); $app = MFactory::getApplication(); // Clear out the prior search dirs $this->_path[$type] = array(); // Actually add the user-specified directories $this->_addPath($type, $path); // Always add the fallback directories as last resort switch (strtolower($type)) { case 'template': // Set the alternative template search dir if (isset($app)) { $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component); $fallback = MPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName(); $this->_addPath('template', $fallback); } break; } }
public static function getLanguagePath($basePath = null, $language = null) { if (is_null($basePath)) { $basePath = MPATH_SITE; if (MFactory::getApplication()->isAdmin()) { $side = 'admin'; } else { $side = 'site'; } } else { if (strpos($basePath, 'admin') === false) { $side = 'site'; } else { $side = 'admin'; } } $basePath = str_replace('/admin', '', $basePath); $dir = "{$basePath}/languages/{$side}"; if (!empty($language)) { $dir .= "/{$language}"; } return $dir; }