Example #1
0
function _modifyResponsiveTemplate()
{
    // Get the current HTML body.
    $body = trim(JResponse::getBody());
    // Correct doctype declaration.
    $doctype = '<!doctype html>';
    // Modified flag.
    $modified = false;
    // Found doctype declaration.
    if (preg_match('#<\\!doctype(.*?)>#is', $body, $match)) {
        // Make sure it's the correct type.
        if (strtolower($match[0]) != $doctype) {
            $body = str_replace($match[0], $doctype, $body);
            $modified = true;
        }
    } else {
        // No doctype declaration, just add it.
        $body = $doctype . "\n" . $body;
        $modified = true;
    }
    // Set the new body only if we've modified it.
    if ($modified) {
        JResponse::setBody($body);
    }
}
Example #2
0
 public function display()
 {
     // Get model data.
     $state = $this->get('State');
     $item = $this->get('Item');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $doc = JFactory::getDocument();
     $doc->setMetaData('Content-Type', 'text/directory', true);
     // Initialise variables.
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $user = JFactory::getUser();
     $dispatcher = JEventDispatcher::getInstance();
     // Compute lastname, firstname and middlename
     $item->name = trim($item->name);
     // "Lastname, Firstname Midlename" format support
     // e.g. "de Gaulle, Charles"
     $namearray = explode(',', $item->name);
     if (count($namearray) > 1) {
         $lastname = $namearray[0];
         $card_name = $lastname;
         $name_and_midname = trim($namearray[1]);
         $firstname = '';
         if (!empty($name_and_midname)) {
             $namearray = explode(' ', $name_and_midname);
             $firstname = $namearray[0];
             $middlename = count($namearray) > 1 ? $namearray[1] : '';
             $card_name = $firstname . ' ' . ($middlename ? $middlename . ' ' : '') . $card_name;
         }
     } else {
         $namearray = explode(' ', $item->name);
         $middlename = count($namearray) > 2 ? $namearray[1] : '';
         $firstname = array_shift($namearray);
         $lastname = count($namearray) ? end($namearray) : '';
         $card_name = $firstname . ($middlename ? ' ' . $middlename : '') . ($lastname ? ' ' . $lastname : '');
     }
     $rev = date('c', strtotime($item->modified));
     JResponse::setHeader('Content-disposition', 'attachment; filename="' . $card_name . '.vcf"', true);
     $vcard = array();
     $vcard[] .= 'BEGIN:VCARD';
     $vcard[] .= 'VERSION:3.0';
     $vcard[] = 'N:' . $lastname . ';' . $firstname . ';' . $middlename;
     $vcard[] = 'FN:' . $item->name;
     $vcard[] = 'TITLE:' . $item->con_position;
     $vcard[] = 'TEL;TYPE=WORK,VOICE:' . $item->telephone;
     $vcard[] = 'TEL;TYPE=WORK,FAX:' . $item->fax;
     $vcard[] = 'TEL;TYPE=WORK,MOBILE:' . $item->mobile;
     $vcard[] = 'ADR;TYPE=WORK:;;' . $item->address . ';' . $item->suburb . ';' . $item->state . ';' . $item->postcode . ';' . $item->country;
     $vcard[] = 'LABEL;TYPE=WORK:' . $item->address . "\n" . $item->suburb . "\n" . $item->state . "\n" . $item->postcode . "\n" . $item->country;
     $vcard[] = 'EMAIL;TYPE=PREF,INTERNET:' . $item->email_to;
     $vcard[] = 'URL:' . $item->webpage;
     $vcard[] = 'REV:' . $rev . 'Z';
     $vcard[] = 'END:VCARD';
     echo implode("\n", $vcard);
     return true;
 }
Example #3
0
 public function onAfterRender()
 {
     // only in html and feeds
     if (JFactory::getDocument()->getType() !== 'html' && JFactory::getDocument()->getType() !== 'feed') {
         return;
     }
     $html = JResponse::getBody();
     if ($html == '') {
         return;
     }
     if (JFactory::getDocument()->getType() != 'html') {
         $this->helpers->get('replace')->replaceTags($html, 'body');
         $this->helpers->get('clean')->cleanLeftoverJunk($html);
         JResponse::setBody($html);
         return;
     }
     // only do stuff in body
     list($pre, $body, $post) = nnText::getBody($html);
     $this->helpers->get('replace')->replaceTags($body, 'body');
     $html = $pre . $body . $post;
     $this->helpers->get('clean')->cleanLeftoverJunk($html);
     // replace head with newly generated head
     // this is necessary because the plugins might have added scripts/styles to the head
     $this->helpers->get('head')->updateHead($html);
     JResponse::setBody($html);
 }
 function display($tpl = null)
 {
     // Do not allow cache
     JResponse::allowCache(false);
     $app = JFactory::getApplication();
     $style = $app->getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word');
     $lang = JFactory::getLanguage();
     JHtml::_('behavior.framework', true);
     $document = JFactory::getDocument();
     $document->addStyleSheet('../media/media/css/medialist-' . $style . '.css');
     if ($lang->isRTL()) {
         $document->addStyleSheet('../media/media/css/medialist-' . $style . '_rtl.css');
     }
     $document->addScriptDeclaration("\n\t\twindow.addEvent('domready', function() {\n\t\t\twindow.parent.document.updateUploader();\n\t\t\t\$\$('a.img-preview').each(function(el) {\n\t\t\t\tel.addEvent('click', function(e) {\n\t\t\t\t\tnew Event(e).stop();\n\t\t\t\t\twindow.top.document.preview.fromElement(el);\n\t\t\t\t});\n\t\t\t});\n\t\t});");
     $images = $this->get('images');
     $documents = $this->get('documents');
     $folders = $this->get('folders');
     $state = $this->get('state');
     $this->baseURL = JURI::root();
     $this->assignRef('images', $images);
     $this->assignRef('documents', $documents);
     $this->assignRef('folders', $folders);
     $this->assignRef('state', $state);
     parent::display($tpl);
 }
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $_PROFILER;
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($app->isAdmin() || JDEBUG) {
         return;
     }
     if (count($app->getMessageQueue())) {
         return;
     }
     if ($user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $app->close();
     }
 }
Example #6
0
 /**
  * Render the document.
  *
  * @param   boolean  $cache   If true, cache the output
  * @param   array    $params  Associative array of attributes
  *
  * @return  The rendered data
  *
  * @since  11.1
  */
 public function render($cache = false, $params = array())
 {
     JResponse::allowCache(false);
     JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true);
     parent::render();
     return $this->getBuffer();
 }
Example #7
0
 function onAfterRender()
 {
     $buffer = JResponse::getBody();
     $buffer = preg_replace('#<head>([\\s\\S]+?)<\\/head>#', '<head>$1' . $this->loadStyles() . '</head>', $buffer);
     JResponse::setBody($buffer);
     return true;
 }
 public function display($tpl = null)
 {
     JResponse::allowCache(true);
     $app = JFactory::getApplication();
     if ($app->input->get('callback', '', 'cmd')) {
         $document = JFactory::getDocument();
         $document->setMimeEncoding('application/javascript');
     }
     $this->categories = $this->get('Categories');
     $this->extensions = $this->get('Extensions');
     $this->breadcrumbs = $this->get('Breadcrumbs');
     $this->orderby = $this->get('OrderBy');
     $this->params = new JRegistry();
     // Temporary params @DELETE
     $this->params->set('extensions_perrow', 4);
     $response = array();
     $response['body'] = array('html' => iconv("UTF-8", "UTF-8//IGNORE", $this->loadTemplate($tpl)), 'pluginuptodate' => $this->get('PluginUpToDate'));
     $response['error'] = false;
     $response['message'] = '';
     $json = new JResponseJson($response['body'], $response['message'], $response['error']);
     if ($app->input->get('callback', '', 'cmd')) {
         echo str_replace(array('\\n', '\\t'), '', $app->input->get('callback') . '(' . $json . ')');
     } else {
         echo str_replace(array('\\n', '\\t'), '', $json);
     }
 }
Example #9
0
 /**
  * Converting the site URL to fit to the HTTP request
  */
 function onAfterRender()
 {
     $app =& JFactory::getApplication();
     if ($app->getName() != 'site') {
         return true;
     }
     //Replace src links
     $base = JURI::base(true) . '/';
     $buffer = JResponse::getBody();
     $regex = '#href="index.php\\?([^"]*)#m';
     $buffer = preg_replace_callback($regex, array('plgSystemSEF', 'route'), $buffer);
     $protocols = '[a-zA-Z0-9]+:';
     //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
     $regex = '#(src|href)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
     $buffer = preg_replace($regex, "\$1=\"{$base}\$2\"", $buffer);
     $regex = '#(onclick="window.open\\(\')(?!/|' . $protocols . '|\\#)([^/]+[^\']*?\')#m';
     $buffer = preg_replace($regex, '$1' . $base . '$2', $buffer);
     // ONMOUSEOVER / ONMOUSEOUT
     $regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|' . $protocols . '|\\#|\')([^"]+)"#m';
     $buffer = preg_replace($regex, '$1="this.src=$2' . $base . '$3$4"', $buffer);
     // Background image
     $regex = '#style\\s*=\\s*[\'\\"](.*):\\s*url\\s*\\([\'\\"]?(?!/|' . $protocols . '|\\#)([^\\)\'\\"]+)[\'\\"]?\\)#m';
     $buffer = preg_replace($regex, 'style="$1: url(\'' . $base . '$2$3\')', $buffer);
     // OBJECT <param name="xx", value="yy"> -- fix it only inside the <param> tag
     $regex = '#(<param\\s+)name\\s*=\\s*"(movie|src|url)"[^>]\\s*value\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
     $buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer);
     // OBJECT <param value="xx", name="yy"> -- fix it only inside the <param> tag
     $regex = '#(<param\\s+[^>]*)value\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"\\s*name\\s*=\\s*"(movie|src|url)"#m';
     $buffer = preg_replace($regex, '<param value="' . $base . '$2" name="$3"', $buffer);
     // OBJECT data="xx" attribute -- fix it only in the object tag
     $regex = '#(<object\\s+[^>]*)data\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
     $buffer = preg_replace($regex, '$1data="' . $base . '$2"$3', $buffer);
     JResponse::setBody($buffer);
     return true;
 }
Example #10
0
 function onAfterRender()
 {
     $fbml = '<html xmlns:fb="http://www.facebook.com/2008/fbml"';
     $html = JResponse::getBody();
     $html = JString::str_ireplace('<html', $fbml, $html);
     JResponse::setBody($html);
 }
Example #11
0
 function onAfterRender()
 {
     if ((defined('JCOMMENTS_CSS') || defined('JCOMMENTS_JS')) && !defined('JCOMMENTS_SHOW')) {
         $app =& JFactory::getApplication();
         if ($app->getName() != 'site') {
             return true;
         }
         $buffer = JResponse::getBody();
         $regexpJS = '#(\\<script(\\stype=\\"text\\/javascript\\")? src="[^\\"]*\\/com_jcomments\\/[^\\>]*\\>\\<\\/script\\>[\\s\\r\\n]*?)#ismU';
         $regexpCSS = '#(\\<link rel="stylesheet" href="[^\\"]*\\/com_jcomments\\/[^>]*>[\\s\\r\\n]*?)#ismU';
         $jcommentsTestJS = '#(JCommentsEditor|new JComments)#ismU';
         $jcommentsTestCSS = '#(comment-link|jcomments-links)#ismU';
         $jsFound = preg_match($jcommentsTestJS, $buffer);
         $cssFound = preg_match($jcommentsTestCSS, $buffer);
         if (!$jsFound) {
             // remove JavaScript if JComments isn't loaded
             $buffer = preg_replace($regexpJS, '', $buffer);
         }
         if (!$cssFound && !$jsFound) {
             // remove CSS if JComments isn't loaded
             $buffer = preg_replace($regexpCSS, '', $buffer);
         }
         if ($buffer != '') {
             JResponse::setBody($buffer);
         }
     }
     return true;
 }
Example #12
0
 function init()
 {
     $mainframe =& JFactory::getApplication();
     $file = JRequest::getVar('file');
     $folder = JRequest::getVar('folder');
     jimport('joomla.filesystem.file');
     // only allow files that have .inc.php in the file name
     if (!$file || strpos($file, '.inc.php') === false) {
         echo JText::_('Access Denied');
         exit;
     }
     if (!$mainframe->isAdmin() && !JRequest::getCmd('usetemplate')) {
         $mainframe->setTemplate('system');
     }
     $_REQUEST['tmpl'] = 'component';
     $mainframe->_messageQueue = array();
     $html = '';
     $path = JPATH_SITE;
     if ($folder) {
         $path .= DS . implode(DS, explode('.', $folder));
     }
     $file = $path . DS . $file;
     if (JFile::exists($file)) {
         ob_start();
         include $file;
         $html = ob_get_contents();
         ob_end_clean();
     }
     $document =& JFactory::getDocument();
     $document->setBuffer($html, 'component');
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/nonumberelements/css/default.css');
     $mainframe->render();
     echo JResponse::toString($mainframe->getCfg('gzip'));
     exit;
 }
Example #13
0
 /**
  * Registers a handler to filter the final output
  *
  * @param  callable  $handler  A function( $body ) { return $bodyChanged; }
  * @return self                To allow chaining.
  */
 public function registerOnAfterRenderBodyFilter($handler)
 {
     $this->registerEvent('onAfterRender', function () use($handler) {
         \JResponse::setBody($handler(\JResponse::getBody()));
     });
     return $this;
 }
Example #14
0
 /**
  * Render the error page based on an exception.
  *
  * @param   Exception  $error  The exception for which to render the error page.
  *
  * @return  void
  *
  * @since   3.0
  */
 public static function render(Exception $error)
 {
     try {
         $app = JFactory::getApplication();
         $document = JDocument::getInstance('error');
         if (!$document) {
             // We're probably in an CLI environment
             exit($error->getMessage());
             $app->close(0);
         }
         $config = JFactory::getConfig();
         // Get the current template from the application
         $template = $app->getTemplate();
         // Push the error object into the document
         $document->setError($error);
         if (ob_get_contents()) {
             ob_end_clean();
         }
         $document->setTitle(JText::_('Error') . ': ' . $error->getCode());
         $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug')));
         // Failsafe to get the error displayed.
         if (empty($data)) {
             exit($error->getMessage());
         } else {
             // Do not allow cache
             JResponse::allowCache(false);
             JResponse::setBody($data);
             echo JResponse::toString();
         }
     } catch (Exception $e) {
         exit('Error displaying the error page: ' . $e->getMessage());
     }
 }
 /**
  * Display the application.
  */
 public function render()
 {
     $user = JFactory::getUser();
     $conf = JFactory::getConfig();
     if ($user->guest || !JFactory::getUser()->authorise('core.admin', 'com_cache')) {
         //TODO change this to the the proper access acl
         echo JText::_('Unauthorized');
         exit;
     }
     $logfile = $this->input->getPath('logfile', null);
     if (is_null($logfile)) {
         echo JText::_('Log not found.');
         exit;
     }
     $logfile_path = JPATH_ROOT . '/logs/' . $logfile;
     if (!is_file($logfile_path)) {
         echo JText::_('Log not found.');
         exit;
     }
     JResponse::clearHeaders();
     header('Content-type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . pathinfo($logfile, PATHINFO_FILENAME) . '.log');
     header('Content-Length: ' . filesize($logfile_path) . ';');
     header('Content-Transfer-Encoding: binary');
     readfile($logfile_path);
     exit;
 }
 function onAfterRender()
 {
     $type = $this->params->get('type', '');
     $trackerCode = $this->params->get('code', '');
     $domain = $this->params->get('domain', 'auto');
     $verify = $this->params->get('verify', '');
     $javascript = '';
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return;
     }
     $buffer = JResponse::getBody();
     if ($verify) {
         $javascript .= "\n\n<meta name=\"google-site-verification\" content=\"" . $verify . "\" />\n\n";
     }
     if ($type == 'asynchronous') {
         $javascript .= "<script type=\"text/javascript\">\n            " . $enhancedOutput . "\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', '" . $trackerCode . "']);\n";
         $javascript .= "_gaq.push(['_trackPageview']);\n (function() {\n  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n</script>\n<!-- Asynchonous Google Analytics Plugin by PB Web Development -->";
     }
     if ($type == 'universal') {
         $javascript .= "\n<script>\n  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n  ga('create', '" . $trackerCode . "', '" . $domain . "');\n  ga('send', 'pageview');\n\n</script>\n<!-- Universal Google Analytics Plugin by PB Web Development -->\n";
     }
     $buffer = preg_replace("/<\\/head>/", "\n\n" . $javascript . "\n\n</head>", $buffer);
     JResponse::setBody($buffer);
     return true;
 }
 public function onAfterRender()
 {
     if ($this->app->isAdmin()) {
         return;
     }
     $app = JFactory::getApplication();
     $option = $app->input->get('option');
     $view = $app->input->get('view');
     $tmpl = $app->input->get('tmpl');
     $body = JResponse::GetBody();
     if ($app->isSite() && $tmpl != 'component') {
         $_cls = explode(',', $this->_params->get('item_class'));
         if (empty($_cls)) {
             return;
         }
         $cls = array();
         for ($i = 0; $i < count($_cls); $i++) {
             $cls[] = trim($_cls[$i]);
         }
         $cls_str = implode(', ', $cls);
         $body = str_replace('</body>', $this->_addScriptQV($cls_str) . '</body>', $body);
         JResponse::setBody($body);
         return true;
     }
     $is_ajax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
     $is_ajax_qv = (int) JRequest::getVar('isajax_qv', 0);
     if ($is_ajax && $is_ajax_qv) {
         $body = JResponse::GetBody();
         preg_match("~<body.*?>(.*?)<\\/body>~is", $body, $match);
         echo '<div id="sj_quickview">' . $match[1] . '</div>';
         die;
         //die(json_encode('<div id="sj_quickview">'.$match[1].'</div>'));
     }
 }
Example #18
0
 /**
  * Display the view
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     $basename = $this->get('BaseName');
     $filetype = $this->get('FileType');
     $mimetype = $this->get('MimeType');
     $content = $this->get('Content');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $document = JFactory::getDocument();
     $document->setMimeEncoding($mimetype);
     // Joomla 3
     if (version_compare(JVERSION, '3.0', 'ge')) {
         JFactory::getApplication()->setHeader('Content-disposition', 'attachment; filename="' . $basename . '.' . $filetype . '"; creation-date="' . JFactory::getDate()->toRFC822() . '"', true);
     } else {
         JResponse::setHeader('Content-disposition', 'attachment; filename="' . $basename . '.' . $filetype . '"; creation-date="' . JFactory::getDate()->toRFC822() . '"', true);
     }
     // Open file pointer to standard output
     //		$fp = fopen('php://output', 'w');
     // Add BOM to fix UTF-8 in Excel
     //		fputs($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
     //		fclose($fp);
     echo $content;
 }
Example #19
0
 public function cron($cachable = false)
 {
     // Makes sure SiteGround's SuperCache doesn't cache the CRON view
     JResponse::setHeader('X-Cache-Control', 'False', true);
     require_once F0FTemplateUtils::parsePath('admin://components/com_akeebasubs/helpers/cparams.php', true);
     $configuredSecret = AkeebasubsHelperCparams::getParam('secret', '');
     if (empty($configuredSecret)) {
         header('HTTP/1.1 503 Service unavailable due to configuration');
         JFactory::getApplication()->close();
     }
     $secret = $this->input->get('secret', null, 'raw');
     if ($secret != $configuredSecret) {
         header('HTTP/1.1 403 Forbidden');
         JFactory::getApplication()->close();
     }
     $command = $this->input->get('command', null, 'raw');
     $command = trim(strtolower($command));
     if (empty($command)) {
         header('HTTP/1.1 501 Not implemented');
         JFactory::getApplication()->close();
     }
     F0FPlatform::getInstance()->importPlugin('system');
     F0FPlatform::getInstance()->runPlugins('onAkeebasubsCronTask', array($command, array('time_limit' => 10)));
     echo "{$command} OK";
     JFactory::getApplication()->close();
 }
	/**
	 * Test...
	 *
	 * @todo Implement testRender().
	 *
	 * @return void
	 */
	public function testRender()
	{
		$this->object = new JDocumentRaw;
		JResponse::clearHeaders();

		$this->object->setBuffer('Unit Test Buffer');

		$this->assertThat(
			$this->object->render(),
			$this->equalTo('Unit Test Buffer')
		);

		$headers = JResponse::getHeaders();

		foreach ($headers as $head)
		{
			if ($head['name'] == 'Expires')
			{
				$this->assertThat(
					$head['value'],
					$this->stringContains('GMT')
				);
			}
		}
	}
Example #21
0
 /**
  * Converting the site URL to fit to the HTTP request
  *
  */
 function onAfterInitialise()
 {
     global $_PROFILER;
     $app =& JFactory::getApplication();
     $user =& JFactory::getUser();
     if ($app->isAdmin() || JDEBUG) {
         return;
     }
     if (!$user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         // the following code searches for a token in the cached page and replaces it with the
         // proper token.
         $token = JUtility::getToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         $data = preg_replace($search, $replacement, $data);
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $app->close();
     }
 }
Example #22
0
 function onAfterRender()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return;
     }
     // Initialise variables
     $id = $this->params->get('id', '');
     $webvisor = $this->params->get('webvisor', '');
     $clickMap = $this->params->get('clickMap', '');
     $linksOut = $this->params->get('linksOut', '');
     $accurateTrackBounce = $this->params->get('accurateTrackBounce', '');
     $noIndex = $this->params->get('noIndex', '');
     $noIndexWrapper = $this->params->get('noindexWrapper', '1');
     //getting body code and storing as buffer
     $buffer = JResponse::getBody();
     //embed Yandex Metrika code
     $webvisor = $webvisor ? 'true' : 'false';
     $clickMap = $clickMap ? 'true' : 'false';
     $linksOut = $linksOut ? 'true' : 'false';
     $accurateTrackBounce = $accurateTrackBounce ? 'true' : 'false';
     $noIndex = $noIndex ? 'ut:"noindex",' : '';
     $javascript = '<!-- Yandex.Metrika counter --><script type="text/javascript">(function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter' . $id . ' = new Ya.Metrika({id:' . $id . ', clickmap:' . $clickMap . ', trackLinks:' . $linksOut . ', accurateTrackBounce:' . $accurateTrackBounce . ',' . $noIndex . ' webvisor:' . $webvisor . '}); } catch(e) {} }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script><noscript><div><img src="//mc.yandex.ru/watch/' . $id . '" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter -->';
     if ($noIndexWrapper) {
         $javascript = '<!--noindex-->' . $javascript . '<!--/noindex-->';
     }
     $buffer = preg_replace("/<\\/body>/", $javascript . "\n\n</body>", $buffer);
     //output the buffer
     JResponse::setBody($buffer);
     return true;
 }
 function _displayModal($tpl)
 {
     $mainframe = JFactory::getApplication();
     // Do not allow cache
     JResponse::allowCache(false);
     $document = JFactory::getDocument();
     $prjid = array();
     $prjid = JRequest::getVar('prjid', array(0), 'post', 'array');
     $proj_id = (int) $prjid[0];
     //build the html select list for projects
     $projects[] = JHTML::_('select.option', '0', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_PROJECT'), 'id', 'name');
     if ($res = JoomleagueHelper::getProjects()) {
         $projects = array_merge($projects, $res);
     }
     $lists['projects'] = JHTMLSelect::genericlist($projects, 'prjid[]', 'class="inputbox" onChange="this.form.submit();" style="width:170px"', 'id', 'name', $proj_id);
     unset($projects);
     $projectteams[] = JHTMLSelect::option('0', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_TEAM'), 'value', 'text');
     // if a project is active we show the teams select list
     if ($proj_id > 0) {
         if ($res = JoomleagueHelper::getProjectteams($proj_id)) {
             $projectteams = array_merge($projectteams, $res);
         }
         $lists['projectteams'] = JHTMLSelect::genericlist($projectteams, 'xtid[]', 'class="inputbox" style="width:170px"', 'value', 'text');
         unset($projectteams);
     }
     $this->assignRef('lists', $lists);
     $this->assignRef('project_id', $proj_id);
     parent::display($tpl);
 }
Example #24
0
 private function _renderStatus()
 {
     $date = JFactory::getDate();
     $jparam = new JConfig();
     if (!JFile::exists(JPATH_ROOT . '/administrator/components/com_community/community.xml')) {
         return false;
     }
     if (JFile::exists(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini')) {
         $lastcheckdate = JFile::read(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini');
     } else {
         $lastcheckdate = $date->format('Y-m-d H:i:s');
     }
     JFile::write(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini', $lastcheckdate);
     $dayInterval = 1;
     // days
     $currentdate = $date->format('Y-m-d H:i:s');
     $checkVersion = strtotime($currentdate) > strtotime($lastcheckdate) + $dayInterval * 60 * 60 * 24;
     // Load language
     $lang = JFactory::getLanguage();
     $lang->load('com_community', JPATH_ROOT . '/administrator');
     $button = $this->_getButton($checkVersion);
     $html = JResponse::getBody();
     $html = str_replace('<div id="module-status">', '<div id="module-status">' . $button, $html);
     // Load AJAX library for the back end.
     $jaxScript = '';
     $noHTML = JRequest::getInt('no_html', 0);
     $format = JRequest::getWord('format', 'html');
     if (!$noHTML && $format == 'html') {
         require_once AZRUL_SYSTEM_PATH . '/pc_includes/ajax.php';
         $jax = new JAX(AZRUL_SYSTEM_LIVE . '/pc_includes');
         $jax->setReqURI(rtrim(JURI::root(), '/') . '/administrator/index.php');
         $jaxScript = $jax->getScript();
     }
     JResponse::setBody($html . $jaxScript);
 }
Example #25
0
 /**
  * Render the document
  *
  * @param   boolean  $cache   If true, cache the output
  * @param   array    $params  Associative array of attributes
  *
  * @return  string   The rendered data
  *
  * @since   11.1
  */
 public function render($cache = false, $params = array())
 {
     // If no error object is set return null
     if (!isset($this->_error)) {
         return;
     }
     //Set the status header
     JResponse::setHeader('status', $this->_error->getCode() . ' ' . str_replace("\n", ' ', $this->_error->getMessage()));
     $file = 'error.php';
     // check template
     $directory = isset($params['directory']) ? $params['directory'] : 'templates';
     $template = isset($params['template']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system';
     if (!file_exists($directory . '/' . $template . '/' . $file)) {
         $template = 'system';
     }
     //set variables
     $this->baseurl = JURI::base(true);
     $this->template = $template;
     $this->debug = isset($params['debug']) ? $params['debug'] : false;
     $this->error = $this->_error;
     // load
     $data = $this->_loadTemplate($directory . '/' . $template, $file);
     parent::render();
     return $data;
 }
Example #26
0
 /**
  * Method for to append new track into database
  *
  */
 function append()
 {
     $dispatcher = JDispatcher::getInstance();
     // Send the appropriate error code response.
     JResponse::clearHeaders();
     JResponse::setHeader('Content-Type', 'application/json; charset=utf-8');
     JResponse::sendHeaders();
     $total = $_GET['total'];
     $one_procent = 1 / ($total / 100);
     $curr_index = number_format($_GET['total'] * $_GET['status'] / 100, 0, '', '');
     $path_from_cache = explode('*|*', JFactory::getApplication()->getUserState('com_playjoom.path.array'));
     $php_array['status'] = $_GET['status'] + $one_procent;
     //$dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__.":".__LINE__, 'message' => 'Add track no '.$curr_index.' in path: '.base64_decode(($path_from_cache[$curr_index] - 1)), 'priority' => JLog::INFO, 'section' => 'admin')));
     if (isset($path_from_cache[$curr_index])) {
         $model = $this->getModel('savetracks');
         $model->AddTrackItem(base64_decode($path_from_cache[$curr_index]), 'audio');
     }
     // Bei 100% ist Schluss ;)
     if ($php_array['status'] > 100) {
         $php_array['status'] = 100;
     }
     if ($php_array['status'] != 100 && isset($path_from_cache[$curr_index])) {
         $php_array['message'] = JText::_('COM_PLAYJOOM_SAVETRACKS_CURRENT_STATUS') . ' ' . ($curr_index + 1) . ' / ' . $total . ' - ' . round($php_array['status'], 1) . '%';
         $php_array['message_path'] = JText::_('COM_PLAYJOOM_SAVETRACKS_PATH_STATUS') . ' ' . base64_decode($path_from_cache[$curr_index]);
     } else {
         //Clear UserStates in session
         JFactory::getApplication()->setUserState('com_playjoom.savetracks', null);
         JFactory::getApplication()->setUserState('com_playjoom.path.array', null);
         JFactory::getApplication()->setUserState('com_playjoom.path.data', null);
         $php_array['message'] = 'done';
     }
     // Output as PHP arrays as JSON Objekt
     echo json_encode($php_array);
 }
Example #27
0
function setStyle()
{
    $app = JFactory::getApplication();
    $doc = JFactory::getDocument();
    if ($doc->getType() != 'html') {
        return;
    }
    //include_once AK_LIB_PATH.DS.'dom'.DS.'simple_html_dom.php';
    $body = JResponse::getBody();
    $body = explode('</head>', $body);
    $base = JURI::root();
    $style = "\n";
    if ($app->isSite()) {
        if (JVERSION < 3.0) {
            $style .= '<link rel="stylesheet" href="' . AK_ADMIN_CSS_URL . '/system.css" type="text/css" />' . "\n";
        }
        $style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom-typo.css" type="text/css" />' . "\n";
        $style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom.css" type="text/css" />' . "\n";
    } else {
        if (JVERSION < 3.0) {
            $style .= '<link rel="stylesheet" href="' . AK_ADMIN_CSS_URL . '/system.css" type="text/css" />' . "\n";
        }
        $style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom-admin.css" type="text/css" />' . "\n";
    }
    $body[0] .= $style;
    //Fold content
    $replace['{fold}'] = '<div class="ak-fold-warp"><div class="ak-fold-outter"><div class="ak-fold-inner">';
    $replace['{/fold}'] = '</div></div><div class="ak-fold-button"></div></div><div class="clearfix"></div>';
    if ($app->isSite()) {
        $body[1] = strtr($body[1], $replace);
    }
    $body = implode('</head>', $body);
    JResponse::setBody($body);
}
Example #28
0
 /**
  * Return statistics CSV file
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  void
  */
 function display($tpl = null)
 {
     $this->item = $this->get('Item');
     // Get parameters
     $jinput = JFactory::getApplication()->input;
     $type = $jinput->get('type', null, 'string');
     $begin = $jinput->get('begin', null, 'string');
     $end = $jinput->get('end', null, 'string');
     // Convert date strings to JDate objects
     $beginDate = new JDate($begin);
     $endDate = new JDate($end . ' 23:59:59');
     // Get statistic model
     $statisticModel = JModelLegacy::getInstance('statistic', 'IssnregistryModel');
     // Get statistics
     $csv = $statisticModel->getStats($type, $beginDate, $endDate);
     // Set document properties
     $document = JFactory::getDocument();
     $document->setMimeEncoding('text/csv; charset="UTF-8"');
     JResponse::setHeader('Content-disposition', 'attachment; filename="statistics.csv"', true);
     // Write to output
     $out = fopen('php://output', 'w');
     // Loop through CSV data and write each row to output
     foreach ($csv as $row) {
         // Columns are tab separated
         fputcsv($out, $row, "\t");
     }
     // Close output
     fclose($out);
 }
Example #29
0
	/**
	 * Render the document.
	 *
	 * @param   boolean  $cache   If true, cache the output
	 * @param   array    $params  Associative array of attributes
	 *
	 * @return  The rendered data
	 *
	 * @since  11.1
	 */
	public function render($cache = false, $params = array())
	{
		parent::render();
		JResponse::setHeader('Content-disposition', 'inline; filename="' . $this->getName() . '.xml"', true);

		return $this->getBuffer();
	}
Example #30
0
 /**
  * Display the template
  *
  * @param   sting  $tpl  template
  *
  * @return void
  */
 public function display($tpl = null)
 {
     if (parent::display($tpl) !== false) {
         $app = JFactory::getApplication();
         if (!$app->isAdmin()) {
             $this->state = $this->get('State');
             $this->params = $this->state->get('params');
             $this->document = JFactory::getDocument();
             if ($this->params->get('menu-meta_description')) {
                 $this->document->setDescription($this->params->get('menu-meta_description'));
             }
             if ($this->params->get('menu-meta_keywords')) {
                 $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
             }
             if ($this->params->get('robots')) {
                 $this->document->setMetadata('robots', $this->params->get('robots'));
             }
         }
         // Set the response to indicate a file download
         JResponse::setHeader('Content-Type', 'application/vnd.ms-word');
         $name = $this->getModel()->getTable()->label;
         $name = JStringNormalise::toDashSeparated($name);
         JResponse::setHeader('Content-Disposition', "attachment;filename=\"" . $name . ".doc\"");
         $this->document->setMimeEncoding('text/html; charset=Windows-1252', false);
         $this->output();
     }
 }