/** * 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 $app->allowCache(false); $app->setBody($data); echo $app->toString(); } } catch (Exception $e) { exit('Error displaying the error page: ' . $e->getMessage() . ': ' . $error->getMessage()); } }
/** * Resets the document type to format=raw * * @return void * @since 0.1 * @todo Figure out if there is a better way to do this */ private function resetDocumentType() { $document =& JFactory::getDocument(); $raw =& JDocument::getInstance('raw'); $document = $raw; JResponse::clearHeaders(); }
/** * Tests JHtml::calendar() method with and without 'readonly' attribute. */ public function testCalendar() { // Create a world for the test jimport('joomla.session.session'); jimport('joomla.application.application'); jimport('joomla.document.document'); $cfg = new JObject(); JFactory::$session = $this->getMock('JSession', array('_start')); JFactory::$application = $this->getMock('ApplicationMock'); JFactory::$config = $cfg; JFactory::$application->expects($this->any())->method('getTemplate')->will($this->returnValue('atomic')); $cfg->live_site = 'http://example.com'; $cfg->offset = 'Europe/Kiev'; $_SERVER['HTTP_USER_AGENT'] = 'Test Browser'; // two sets of test data $test_data = array('date' => '2010-05-28 00:00:00', 'friendly_date' => 'Friday, 28 May 2010', 'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d', 'attribs' => array()); $test_data_ro = array_merge($test_data, array('attribs' => array('readonly' => 'readonly'))); foreach (array($test_data, $test_data_ro) as $data) { // Reset the document JFactory::$document = JDocument::getInstance('html', array('unique_key' => serialize($data))); $input = JHtml::calendar($data['date'], $data['name'], $data['id'], $data['format'], $data['attribs']); $this->assertEquals((string) $xml->input['title'], $data['friendly_date'], 'Line:' . __LINE__ . ' The calendar input should have `title == "' . $data['friendly_date'] . '"`'); $this->assertEquals((string) $xml->input['name'], $data['name'], 'Line:' . __LINE__ . ' The calendar input should have `name == "' . $data['name'] . '"`'); $this->assertEquals((string) $xml->input['id'], $data['id'], 'Line:' . __LINE__ . ' The calendar input should have `id == "' . $data['id'] . '"`'); $head_data = JFactory::getDocument()->getHeadData(); if (!isset($data['attribs']['readonly']) || !$data['attribs']['readonly'] === 'readonly') { $this->assertArrayHasKey('/media/system/js/calendar.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar.js" should be loaded'); $this->assertArrayHasKey('/media/system/js/calendar-setup.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar-setup.js" should be loaded'); } } }
/** * Register the API server. * * @throws \Exception * @return boolean */ public function register() { $uri = \JURI::getInstance(); if (!$this->isApi()) { return false; } $app = \JFactory::getApplication(); $input = $app->input; // Restore Joomla handler and using our Json handler. JsonResponse::registerErrorHandler(); // Authentication if (!$this->isUserOperation($uri) && $this->option['authorise']) { if (!Authentication::authenticate($input->get('session_key'))) { throw new \Exception(\JText::_('JERROR_ALERTNOAUTHOR'), 403); } } // Set Format to JSON $input->set('format', 'json'); // Store JDocumentJson to Factory \JFactory::$document = \JDocument::getInstance('json'); $router = $app::getRouter(); // Attach a hook to Router $router->attachParseRule(array($this, 'parseRule')); return true; }
/** * 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 jexit($error->getMessage()); } // 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' => JDEBUG)); // Do not allow cache $app->allowCache(false); // If nothing was rendered, just use the message from the Exception if (empty($data)) { $data = $error->getMessage(); } $app->setBody($data); echo $app->toString(); } catch (Exception $e) { // Try to set a 500 header if they haven't already been sent if (!headers_sent()) { header('HTTP/1.1 500 Internal Server Error'); } jexit('Error displaying the error page: ' . $e->getMessage() . ': ' . $error->getMessage()); } }
function display() { $doDisplay = true; // Set a default view if none exists if (!JRequest::getCmd('view')) { JRequest::setVar('view', 'tickets'); } // Handle displaying an attachment if (JRequest::getCmd('view') == 'attachment') { $model = $this->getModel('attachment'); $result = $model->download(JRequest::getVar('ArticleID', '', '', 'integer'), JRequest::getVar('AtmID', '', '', 'integer')); if (array_key_exists('data', $result)) { $document =& JFactory::getDocument(); $doc =& JDocument::getInstance('raw'); $document = $doc; JResponse::clearHeaders(); $document->setMimeEncoding($result['data']->ContentType); JResponse::setHeader('Content-length', $result['data']->FilesizeRaw, true); $fn = preg_replace('/"/', '\\"', $result['data']->Filename); JResponse::setHeader('Content-disposition', sprintf('attachment;filename="%s"', $fn), true); $document->render(); echo $result['data']->Content; $doDisplay = false; } } if ($doDisplay) { parent::display(); } }
/** * Submits a bug report to Dioscouri. * Thanks so much! They really help improve the product! */ function sendBug() { $mainframe = JFactory::getApplication(); $body = JRequest::getVar('body'); $name = JRequest::getVar('title'); $body .= "\n\n Project: tienda"; $body .= "\n Tracker: Bug"; $body .= "\n Affected Version: " . Tienda::getVersion(); $doc = JDocument::getInstance('raw'); ob_start(); $option = JRequest::getCmd('option'); $db = JFactory::getDBO(); $path = JPATH_ADMINISTRATOR . '/components/com_admin/'; require_once $path . 'admin.admin.html.php'; $path .= 'tmpl/'; require_once $path . 'sysinfo_system.php'; require_once $path . 'sysinfo_directory.php'; require_once $path . 'sysinfo_phpinfo.php'; require_once $path . 'sysinfo_phpsettings.php'; require_once $path . 'sysinfo_config.php'; jimport('joomla.filesystem.file'); $contents = ob_get_contents(); ob_end_clean(); $doc->setBuffer($contents); $contents = $doc->render(); $sitename = $config->get('sitename', $mainframe->getCfg('sitename')); // write file with info $config = JFactory::getConfig(); $filename = 'system_info_' . $sitename . '.html'; $file = JPATH_SITE . '/tmp/' . $filename; JFile::write($file, $contents); $mailer = JFactory::getMailer(); $success = false; // For now, bug submission goes to info@dioscouri.com, // but in the future, it will go to projects@dioscouri.com // (once we get the Redmine auto-create working properly // and format the subject/body of the email properly) $mailer->addRecipient('*****@*****.**'); $mailer->setSubject($name); $mailfrom = $config->get('emails_defaultemail', $mainframe->getCfg('mailfrom')); $fromname = $config->get('emails_defaultname', $mainframe->getCfg('fromname')); // check user mail format type, default html $mailer->setBody($body); $mailer->addAttachment($file); $sender = array($mailfrom, $fromname); $mailer->setSender($sender); $sent = $mailer->send(); if ($sent == '1') { $success = true; } JFile::delete($file); if ($success) { $msg = JText::_('COM_TIENDA_BUG_SUBMIT_OK'); $msgtype = 'message'; } else { $msg = JText::_('COM_TIENDA_BUG_SUBMIT_FAIL'); $msgtype = 'notice'; } $mainframe->redirect(JRoute::_('index.php?option=com_tienda&view=dashboard'), $msg, $msgtype); }
/** * @todo Implement testGetInstance(). */ public function testGetInstance() { $this->object = JDocument::getInstance(); $this->assertThat($this->object, $this->isInstanceOf('JDocumentHtml')); $this->object = JDocument::getInstance('custom'); $this->assertThat($this->object, $this->isInstanceOf('JDocumentRaw')); $this->assertThat($this->object->getType(), $this->equalTo('custom')); }
/** * Render the error page based on an exception. * * @param Exception|Throwable $error An Exception or Throwable (PHP 7+) object for which to render the error page. * * @return void * * @since 3.0 */ public static function render($error) { $expectedClass = PHP_MAJOR_VERSION >= 7 ? 'Throwable' : 'Exception'; $isException = $error instanceof $expectedClass; // In PHP 5, the $error object should be an instance of Exception; PHP 7 should be a Throwable implementation if ($isException) { try { // 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' && JFactory::getConfig()->get('offline') == 1) { JFactory::getApplication()->redirect('index.php'); } $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); if (!$document) { // We're probably in an CLI environment jexit($error->getMessage()); } // 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' => JDEBUG)); // Do not allow cache $app->allowCache(false); // If nothing was rendered, just use the message from the Exception if (empty($data)) { $data = $error->getMessage(); } $app->setBody($data); echo $app->toString(); $app->close(0); // This return is needed to ensure the test suite does not trigger the non-Exception handling below return; } catch (Throwable $e) { // Pass the error down } catch (Exception $e) { // Pass the error down } } // This isn't an Exception, we can't handle it. if (!headers_sent()) { header('HTTP/1.1 500 Internal Server Error'); } $message = 'Error displaying the error page'; if ($isException) { $message .= ': '; if (isset($e)) { $message .= $e->getMessage() . ': '; } $message .= $error->getMessage(); } echo $message; jexit(1); }
/** * Render the error page based on an exception. * * @param object $error An Exception or Throwable (PHP 7+) object for which to render the error page. * * @return void * * @since 3.0 */ public static function render($error) { $expectedClass = PHP_MAJOR_VERSION >= 7 ? 'Throwable' : 'Exception'; $isException = $error instanceof $expectedClass; // In PHP 5, the $error object should be an instance of Exception; PHP 7 should be a Throwable implementation if ($isException) { try { $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); $code = $error->getCode(); if (!isset(JHttpResponse::$status_messages[$code])) { $code = '500'; } if (ini_get('display_errors')) { $message = $error->getMessage(); } else { $message = JHttpResponse::$status_messages[$code]; } if (!$document || PHP_SAPI == 'cli') { // We're probably in an CLI environment jexit($message); } // 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') . ': ' . $code); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => JFactory::getConfig()->get('debug'))); // Do not allow cache $app->allowCache(false); // If nothing was rendered, just use the message from the Exception if (empty($data)) { $data = $message; } $app->setBody($data); echo $app->toString(); return; } catch (Exception $e) { // Pass the error down } } // This isn't an Exception, we can't handle it. if (!headers_sent()) { header('HTTP/1.1 500 Internal Server Error'); } $message = 'Error displaying the error page'; if ($isException) { $message .= ': ' . $e->getMessage() . ': ' . $message; } echo $message; jexit(1); }
function ezStream() { $options = array('margin-header' => 5, 'margin-footer' => 10, 'margin-top' => 20, 'margin-bottom' => 20, 'margin-left' => 15, 'margin-right' => 15); $pdfDoc =& JDocument::getInstance('pdf', $options); $pdfDoc->setTitle($this->_title); $pdfDoc->setHeader($this->_header); $pdfDoc->setBuffer($this->_text); header('Content-Type: application/pdf'); header('Content-disposition: inline; filename="file.pdf"', true); echo $pdfDoc->render(); }
function display($tpl = null) { jimport('joomla.utilities.date'); $option = 'com_jobboard'; $document =& JFactory::getDocument(); $doc =& JDocument::getInstance('json'); // Set the MIME type for JSON output. if (version_compare(JVERSION, '2.5.0', 'ge')) { } else { $doc->setMimeEncoding('application/json'); // Change the suggested filename. JResponse::setHeader('Content-Disposition', 'attachment; filename="results.json"'); } // Output the JSON data. echo json_encode($this->data); }
/** * Tests JHtml::calendar() method with and without 'readonly' attribute. */ public function testCalendar() { // Create a world for the test jimport('joomla.session.session'); jimport('joomla.application.application'); jimport('joomla.document.document'); $cfg = new JObject(); JFactory::$session = $this->getMock('JSession', array('_start')); JFactory::$application = $this->getMock('ApplicationMock'); JFactory::$config = $cfg; JFactory::$application->expects($this->any())->method('getTemplate')->will($this->returnValue('atomic')); $cfg->live_site = 'http://example.com'; $cfg->offset = 'Europe/Kiev'; $_SERVER['HTTP_USER_AGENT'] = 'Test Browser'; // two sets of test data $test_data = array('date' => '2010-05-28', 'friendly_date' => 'Friday, 28 May 2010', 'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d', 'attribs' => array()); $test_data_ro = array_merge($test_data, array('attribs' => array('readonly' => 'readonly'))); foreach (array($test_data, $test_data_ro) as $data) { // Reset the document JFactory::$document = JDocument::getInstance('html', array('unique_key' => serialize($data))); $input = JHtml::calendar($data['date'], $data['name'], $data['id'], $data['format'], $data['attribs']); $this->assertThat(strlen($input), $this->greaterThan(0), 'Line:' . __LINE__ . ' The calendar method should return something without error.'); $xml = new simpleXMLElement('<calendar>' . $input . '</calendar>'); $this->assertEquals((string) $xml->input['type'], 'text', 'Line:' . __LINE__ . ' The calendar input should have `type == "text"`'); $this->assertEquals((string) $xml->input['title'], $data['friendly_date'], 'Line:' . __LINE__ . ' The calendar input should have `title == "' . $data['friendly_date'] . '"`'); $this->assertEquals((string) $xml->input['name'], $data['name'], 'Line:' . __LINE__ . ' The calendar input should have `name == "' . $data['name'] . '"`'); $this->assertEquals((string) $xml->input['id'], $data['id'], 'Line:' . __LINE__ . ' The calendar input should have `id == "' . $data['id'] . '"`'); $this->assertEquals((string) $xml->input['value'], $data['date'], 'Line:' . __LINE__ . ' The calendar input should have `value == "' . $data['date'] . '"`'); $head_data = JFactory::getDocument()->getHeadData(); if (isset($data['attribs']['readonly']) && $data['attribs']['readonly'] === 'readonly') { $this->assertEquals((string) $xml->input['readonly'], $data['attribs']['readonly'], 'Line:' . __LINE__ . ' The readonly calendar input should have `readonly == "' . $data['attribs']['readonly'] . '"`'); $this->assertFalse(isset($xml->img), 'Line:' . __LINE__ . ' The readonly calendar input shouldn\'t have a calendar image'); $this->assertArrayNotHasKey('/media/system/js/calendar.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar.js" shouldn\'t be loaded'); $this->assertArrayNotHasKey('/media/system/js/calendar-setup.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar-setup.js" shouldn\'t be loaded'); $this->assertArrayNotHasKey('text/javascript', $head_data['script'], 'Line:' . __LINE__ . ' Inline JS for the calendar shouldn\'t be loaded'); } else { $this->assertFalse(isset($xml->input['readonly']), 'Line:' . __LINE__ . ' The calendar input shouldn\'t have readonly attribute'); $this->assertTrue(isset($xml->img), 'Line:' . __LINE__ . ' The calendar input should have a calendar image'); $this->assertEquals((string) $xml->img['id'], $data['id'] . '_img', 'Line:' . __LINE__ . ' The calendar image should have `id == "' . $data['id'] . '_img' . '"`'); $this->assertEquals((string) $xml->img['class'], 'calendar', 'Line:' . __LINE__ . ' The calendar image should have `class == "calendar"`'); $this->assertFileExists(JPATH_ROOT . $xml->img['src'], 'Line:' . __LINE__ . ' The calendar image source should point to an existent file'); $this->assertArrayHasKey('/media/system/js/calendar.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar.js" should be loaded'); $this->assertArrayHasKey('/media/system/js/calendar-setup.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar-setup.js" should be loaded'); $this->assertContains('DHTML Date/Time Selector', $head_data['script']['text/javascript'], 'Line:' . __LINE__ . ' Inline JS for the calendar should be loaded'); } } }
/** * The exception handler. * * @param \Exception $exception The exception object. * * @return void */ public static function exception(\Exception $exception) { try { $response = static::response($exception); } catch (\Exception $e) { $msg = "Infinity loop in exception handler. \n\nException:\n" . $e; exit($msg); } $response->code = $exception->getCode(); if (JDEBUG) { $response->backtrace = $exception->getTrace(); } $app = \JFactory::getApplication(); $doc = \JDocument::getInstance('json'); $app->setBody($doc->setBuffer($response)->render()); $app->setHeader('Content-Type', $doc->getMimeEncoding() . '; charset=' . $doc->getCharset()); echo $app->toString(); die; }
function replaceImage(&$row, $align, $autoresize, $maxchars, $showimage, $width = 0, $height = 0, $hiddenClasses = '') { global $database, $_MAMBOTS, $current_charset; $regex = '#<\\s*img [^\\>]*src\\s*=\\s*(["\'])(.*?)\\1#im'; preg_match($regex, $row->introtext, $matches); if (!count($matches)) { preg_match($regex, $row->fulltext, $matches); } $images = count($matches) ? $matches : array(); $image = ''; if (count($images)) { $image = trim($images[2]); } $align = $align ? "align=\"{$align}\"" : ""; if ($image && $showimage) { if ($autoresize && function_exists('imagecreatetruecolor') && ($image1 = modJANewsHelper::processImage($image, $width, $height))) { $image = "<img src=\"" . $image1 . "\" alt=\"{$row->title}\" {$align} />"; } else { $width = $width ? "width=\"{$width}\"" : ""; $height = $height ? "height=\"{$height}\"" : ""; $image = "<img src=\"" . $image . "\" alt=\"{$row->title}\" {$width} {$height} {$align} />"; } } else { $image = ''; } $regex1 = "/\\<img[^\\>]*>/"; $row->introtext = preg_replace($regex1, '', $row->introtext); $regex1 = "/<div class=\"mosimage\".*<\\/div>/"; $row->introtext = preg_replace($regex1, '', $row->introtext); $row->introtext = trim($row->introtext); $row->introtext1 = $row->introtext; if ($maxchars && strlen($row->introtext) > $maxchars) { $doc = JDocument::getInstance(); if (function_exists('mb_substr')) { $row->introtext1 = SmartTrim::mb_trim($row->introtext, 0, $maxchars, $doc->_charset); } else { $row->introtext1 = SmartTrim::trim($row->introtext, 0, $maxchars); } } // clean up globals return $image; }
/** * 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'); $code = $error->getCode(); if (!isset(JHttpResponse::$status_messages[$code])) { $code = '500'; } if (ini_get('display_errors')) { $message = $error->getMessage(); } else { $message = JHttpResponse::$status_messages[$code]; } // Exit immediatly if we are in a CLI environment if (!$document || PHP_SAPI == 'cli') { exit($message); $app->close(0); } $config = JFactory::getConfig(); // Get the current template from the application $template = $app->getTemplate(); $document->setError($error); if (ob_get_contents()) { ob_end_clean(); } $document->setTitle(JText::_('Error') . ': ' . $code); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug'))); // Failsafe to get the error displayed. if (!empty($data)) { // Do not allow cache $app->allowCache(false); $app->setBody($data); echo $app->toString(); } else { exit($message); } } catch (Exception $e) { exit('Error displaying the error page: ' . $e->getMessage() . ': ' . $message); } }
function renderRaw($data) { $document =& JFactory::getDocument(); $doc =& JDocument::getInstance('raw'); $document = $doc; $view =& $this->getView('user', 'html'); $view->setLayout('user'); $view->assign('context', 'profile'); $view->assignRef('data', $data); $view->display(); }
/** * Create a document object * * @return JDocument object * * @see JDocument * @since 11.1 */ protected static function createDocument() { $lang = self::getLanguage(); $input = self::getApplication()->input; $type = $input->get('format', 'html', 'word'); $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => ' ', 'language' => $lang->getTag(), 'direction' => $lang->isRTL() ? 'rtl' : 'ltr'); return JDocument::getInstance($type, $attributes); }
/** * * Get Articles of K2 * @param array $catids categories of K2 * @param object $helper * @param object $params * @return object */ function getArticles($catids, &$helper, $params) { jimport('joomla.filesystem.file'); $limit = (int) $params->get('introitems', $helper->get('introitems')) + (int) $params->get('linkitems', $helper->get('linkitems')); if (!$limit) { $limit = 4; } $ordering = $helper->get('ordering', ''); //get params of K2 component $componentParams = JComponentHelper::getParams('com_k2'); $limitstart = 0; $user = JFactory::getUser(); $aid = $user->get('aid') ? $user->get('aid') : 1; $db = JFactory::getDBO(); $jnow = JFactory::getDate(); //$now = $jnow->toMySQL(); if (version_compare(JVERSION, '3.0', 'ge')) { $now = $jnow->toSql(); } else { if (version_compare(JVERSION, '2.5', 'ge')) { $now = $jnow->toMySQL(); } else { $now = $jnow->toMySQL(); } } $nullDate = $db->getNullDate(); $query = "SELECT i.*, c.name AS categoryname,c.id AS categoryid, c.alias AS categoryalias, c.name as cattitle, c.params AS categoryparams"; $query .= "\n FROM #__k2_items as i LEFT JOIN #__k2_categories c ON c.id = i.catid"; $query .= "\n WHERE i.published = 1 AND i.access <= {$aid} AND i.trash = 0 AND c.published = 1 AND c.access <= {$aid} AND c.trash = 0"; $query .= "\n AND i.catid IN ({$catids})"; $query .= "\n AND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " )"; $query .= "\n AND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )"; if ($helper->get('featured') == 'hide') { $query .= "\n AND i.featured = 0"; } if ($helper->get('featured') == 'only') { $query .= "\n AND i.featured = 1"; } if ($helper->get('timerange') > 0) { $datenow = JFactory::getDate(); //$date = $datenow->toMySQL(); if (version_compare(JVERSION, '3.0', 'ge')) { $date = $datenow->toSql(); } else { if (version_compare(JVERSION, '2.5', 'ge')) { $date = $datenow->toMySQL(); } else { $date = $datenow->toMySQL(); } } $query .= " AND i.created > DATE_SUB('{$date}',INTERVAL " . $helper->get('timerange') . " DAY) "; } $sort_order = $helper->get('sort_order', 'DESC'); switch ($ordering) { case 'ordering': $ordering = 'ordering ' . $sort_order; break; case 'rand': $ordering = 'RAND()'; break; case 'hits': $ordering = 'hits ' . $sort_order; break; case 'created': $ordering = 'created ' . $sort_order; break; case 'modified': $ordering = 'modified ' . $sort_order; break; case 'title': $ordering = 'title ' . $sort_order; break; } if ($ordering == 'RAND()') { $query .= "\n ORDER BY " . $ordering; } else { $query .= "\n ORDER BY i." . $ordering; } $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $autoresize = intval(trim($helper->get('autoresize', 0))); $width_img = (int) $helper->get('width', 100) < 0 ? 100 : $helper->get('width', 100); $height_img = (int) $helper->get('height', 100) < 0 ? 100 : $helper->get('height', 100); $img_w = intval(trim($width_img)); $img_h = intval(trim($height_img)); //$img_w = intval(trim($helper->get('width', 100))); //$img_h = intval(trim($helper->get('height', 100))); $img_align = $helper->get('align', 'left'); $showimage = $params->get('showimage', $helper->get('showimage', 0)); $maxchars = intval(trim($helper->get('maxchars', 200))); $hiddenClasses = trim($helper->get('hiddenClasses', '')); $showdate = $helper->get('showdate', 0); $enabletimestamp = $helper->get('timestamp', 0); if (count($rows)) { foreach ($rows as $j => $row) { $row->introtext1 = ""; $row->cat_link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($row->categoryid . ':' . urlencode($row->categoryalias)))); //Clean title $row->title = JFilterOutput::ampReplace($row->title); //Images $image = ''; if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XL.jpg')) { $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_XL.jpg'; } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XS.jpg')) { $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_XS.jpg'; } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_L.jpg')) { $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_L.jpg'; } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_S.jpg')) { $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_S.jpg'; } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_M.jpg')) { $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_M.jpg'; } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_Generic.jpg')) { $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_Generic.jpg'; } if ($image != '') { $thumbnailMode = $helper->get('thumbnail_mode', 'crop'); $aspect = $helper->get('use_ratio', '1'); $crop = $thumbnailMode == 'crop' ? true : false; $align = $img_align ? "align=\"{$img_align}\"" : ""; $jaimage = JAImage::getInstance(); if ($thumbnailMode != 'none' && $jaimage->sourceExited($image)) { $imageURL = $jaimage->resize($image, $img_w, $img_h, $crop, $aspect); $imageURL = str_replace(JURI::base(), '', $imageURL); $imageURL = JURI::base() . $imageURL; $row->image = $imageURL ? "<img class=\"{$img_align}\" src=\"" . $imageURL . "\" alt=\"{$row->title}\" {$align} />" : ""; } else { $width = $img_w ? "width=\"{$img_w}\"" : ""; $height = $img_h ? "height=\"{$img_h}\"" : ""; $imageURL = str_replace(JURI::base(), '', $imageURL); $imageURL = JURI::base() . $imageURL; $row->image = "<img class=\"{$img_align}\" src=\"" . $image . "\" alt=\"{$row->title}\" {$img_w} {$img_h} {$align} />"; } if ($maxchars && strlen($row->introtext) > $maxchars) { $doc = JDocument::getInstance(); if (function_exists('mb_substr')) { $row->introtext1 = SmartTrim::mb_trim($row->introtext, 0, $maxchars, $doc->_charset); } else { $row->introtext1 = SmartTrim::trim($row->introtext, 0, $maxchars); } } elseif ($maxchars == 0) { $row->introtext1 = ''; } $helper->replaceImage($row, $img_align, $autoresize, $maxchars, $showimage, $img_w, $img_h, $hiddenClasses); } else { $row->image = $helper->replaceImage($row, $img_align, $autoresize, $maxchars, $showimage, $img_w, $img_h, $hiddenClasses); if ($maxchars == 0) { $row->introtext1 = ''; } } // Introtext $row->text = $row->introtext; //Read more link $row->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($row->id . ':' . urlencode($row->alias), $row->catid . ':' . urlencode($row->categoryalias)))); $helper->_params->set('parsedInModule', 1); $dispatcher = JDispatcher::getInstance(); if ($helper->get('JPlugins', 1)) { //Plugins $results = $dispatcher->trigger('onBeforeDisplay', array(&$row, &$helper->_params, $limitstart)); $row->event->BeforeDisplay = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplay', array(&$row, &$helper->_params, $limitstart)); $row->event->AfterDisplay = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$row, &$helper->_params, $limitstart)); $row->event->AfterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$row, &$helper->_params, $limitstart)); $row->event->BeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayContent', array(&$row, &$helper->_params, $limitstart)); $row->event->AfterDisplayContent = trim(implode("\n", $results)); $dispatcher->trigger('onPrepareContent', array(&$row, &$helper->_params, $limitstart)); $row->introtext = $row->text; } //Init K2 plugin events $row->event->K2BeforeDisplay = ''; $row->event->K2AfterDisplay = ''; $row->event->K2AfterDisplayTitle = ''; $row->event->K2BeforeDisplayContent = ''; $row->event->K2AfterDisplayContent = ''; $row->event->K2CommentsCounter = ''; //K2 plugins if ($helper->get('K2Plugins', 1)) { JPluginHelper::importPlugin('k2'); $results = $dispatcher->trigger('onK2BeforeDisplay', array(&$row, &$helper->_params, $limitstart)); $row->event->K2BeforeDisplay = trim(implode("\n", $results)); $results = $dispatcher->trigger('onK2AfterDisplay', array(&$row, &$helper->_params, $limitstart)); $row->event->K2AfterDisplay = trim(implode("\n", $results)); $results = $dispatcher->trigger('onK2AfterDisplayTitle', array(&$row, &$helper->_params, $limitstart)); $row->event->K2AfterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onK2BeforeDisplayContent', array(&$row, &$helper->_params, $limitstart)); $row->event->K2BeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onK2AfterDisplayContent', array(&$row, &$helper->_params, $limitstart)); $row->event->K2AfterDisplayContent = trim(implode("\n", $results)); $dispatcher->trigger('onK2PrepareContent', array(&$row, &$helper->_params, $limitstart)); $row->introtext = $row->text; } //Clean the plugin tags $row->introtext = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $row->introtext); $row->introtext = '<p>' . $row->introtext . '</p>'; //Author if ($helper->get('showcreator')) { if (!empty($row->created_by_alias)) { $row->author = $row->created_by_alias; $row->authorGender = NULL; } else { $author = JFactory::getUser($row->created_by); $row->author = $author->name; $query = "SELECT `gender` FROM #__k2_users WHERE userID=" . (int) $author->id; $db->setQuery($query, 0, 1); $row->authorGender = $db->loadResult(); //Author Link $row->authorLink = JRoute::_(K2HelperRoute::getUserRoute($row->created_by)); } } $row->created = $row->modified != '' && $row->modified != '0000-00-00 00:00:00' ? $row->modified : $row->created; if ($enabletimestamp) { $row->created = $helper->generatTimeStamp($row->created); } else { $row->created = JHTML::_('date', $row->created); } $rows[$j] = $row; } } return $rows; }
/** * Display a custom error page and exit gracefully * * @param object &$error Exception object * * @return void * * @deprecated 12.1 * @since 11.1 */ public static function customErrorPage(&$error) { // Deprecation warning. JLog::add('JError::customErrorPage() is deprecated.', JLog::WARNING, 'deprecated'); // Initialise variables. $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); if ($document) { $config = JFactory::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' && JFactory::getConfig()->get('offline') == 1) { JFactory::getApplication()->redirect('index.php'); } @ob_end_clean(); $document->setTitle(JText::_('Error') . ': ' . $error->get('code')); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug'))); // Failsafe to get the error displayed. if (empty($data)) { self::handleEcho($error, array()); } else { // Do not allow cache JResponse::allowCache(false); JResponse::setBody($data); echo JResponse::toString(); } } else { // Just 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); }
/** * Tests JHtml::calendar() method with and without 'readonly' attribute. * * @return void * * @since 3.1 */ public function testCalendar() { // @TODO - Test currently failing, fix this later $this->markTestSkipped('Skipping failing test'); $cfg = new JObject(); JFactory::$session = $this->getMockSession(); JFactory::$config = $cfg; JFactory::$application->expects($this->any())->method('getTemplate')->will($this->returnValue('atomic')); $cfg->live_site = 'http://example.com'; $cfg->offset = 'Europe/Kiev'; // Two sets of test data $test_data = array('date' => '2010-05-28 00:00:00', 'friendly_date' => 'Friday, 28 May 2010', 'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d', 'attribs' => array()); $test_data_ro = array_merge($test_data, array('attribs' => array('readonly' => 'readonly'))); foreach (array($test_data, $test_data_ro) as $data) { // Reset the document JFactory::$document = JDocument::getInstance('html', array('unique_key' => serialize($data))); $input = JHtml::calendar($data['date'], $data['name'], $data['id'], $data['format'], $data['attribs']); $this->assertGreaterThan(strlen($input), 0, 'Line:' . __LINE__ . ' The calendar method should return something without error.'); $xml = new SimpleXMLElement('<calendar>' . $input . '</calendar>'); $this->assertEquals('text', (string) $xml->input['type'], 'Line:' . __LINE__ . ' The calendar input should have `type == "text"`'); // @todo We can't test this yet due to dependency on language strings $this->assertEquals($data['friendly_date'], (string) $xml->input['title'], 'Line:' . __LINE__ . ' The calendar input should have `title == "' . $data['friendly_date'] . '"`'); $this->assertEquals($data['name'], (string) $xml->input['name'], 'Line:' . __LINE__ . ' The calendar input should have `name == "' . $data['name'] . '"`'); $this->assertEquals($data['id'], (string) $xml->input['id'], 'Line:' . __LINE__ . ' The calendar input should have `id == "' . $data['id'] . '"`'); $this->assertEquals($data['date'], (string) $xml->input['value'], 'Line:' . __LINE__ . ' The calendar input should have `value == "' . $data['date'] . '"`'); $head_data = JFactory::getDocument()->getHeadData(); if (isset($data['attribs']['readonly']) && $data['attribs']['readonly'] === 'readonly') { $this->assertEquals($data['attribs']['readonly'], (string) $xml->input['readonly'], 'Line:' . __LINE__ . ' The readonly calendar input should have `readonly == "' . $data['attribs']['readonly'] . '"`'); $this->assertFalse(isset($xml->img), 'Line:' . __LINE__ . ' The readonly calendar input shouldn\'t have a calendar image'); $this->assertArrayNotHasKey('/media/system/js/calendar.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar.js" shouldn\'t be loaded'); $this->assertArrayNotHasKey('/media/system/js/calendar-setup.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar-setup.js" shouldn\'t be loaded'); $this->assertArrayNotHasKey('text/javascript', $head_data['script'], 'Line:' . __LINE__ . ' Inline JS for the calendar shouldn\'t be loaded'); } else { $this->assertFalse(isset($xml->input['readonly']), 'Line:' . __LINE__ . ' The calendar input shouldn\'t have readonly attribute'); $this->assertTrue(isset($xml->img), 'Line:' . __LINE__ . ' The calendar input should have a calendar image'); $this->assertEquals($data['id'] . '_img', (string) $xml->img['id'], 'Line:' . __LINE__ . ' The calendar image should have `id == "' . $data['id'] . '_img' . '"`'); $this->assertEquals('calendar', (string) $xml->img['class'], 'Line:' . __LINE__ . ' The calendar image should have `class == "calendar"`'); $this->assertFileExists(JPATH_ROOT . $xml->img['src'], 'Line:' . __LINE__ . ' The calendar image source should point to an existent file'); $this->assertArrayHasKey('/media/system/js/calendar.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar.js" should be loaded'); $this->assertArrayHasKey('/media/system/js/calendar-setup.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar-setup.js" should be loaded'); $this->assertContains('DHTML Date\\/Time Selector', $head_data['script']['text/javascript'], 'Line:' . __LINE__ . ' Inline JS for the calendar should be loaded'); } } }
public static function setFormat($format = 'html') { // Default to raw output $doc = JFactory::getDocument(); $document = JDocument::getInstance($format); $doc = $document; }
/** * Create a document object * * @return JDocument object * * @see JDocument * @since 11.1 */ protected static function createDocument() { $lang = self::getLanguage(); $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => ' ', 'language' => $lang->getTag(), 'direction' => $lang->isRTL() ? 'rtl' : 'ltr'); return JDocument::getInstance('html', $attributes); }
/** * Method to run the next batch of content through the indexer. * * @return void * * @since 2.5 */ public function batch() { static $log; $params = JComponentHelper::getParams('com_finder'); if ($params->get('enable_logging', '0')) { if ($log == null) { $options['format'] = '{DATE}\\t{TIME}\\t{LEVEL}\\t{CODE}\\t{MESSAGE}'; $options['text_file'] = 'indexer.php'; $log = JLog::addLogger($options); } } // Log the start JLog::add('Starting the indexer batch process', JLog::INFO); // We don't want this form to be cached. header('Pragma: no-cache'); header('Cache-Control: no-cache'); header('Expires: -1'); // Check for a valid token. If invalid, send a 403 with the error message. JSession::checkToken('request') or $this->sendResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Put in a buffer to silence noise. ob_start(); // Remove the script time limit. @set_time_limit(0); // Get the indexer state. $state = FinderIndexer::getState(); // Reset the batch offset. $state->batchOffset = 0; // Update the indexer state. FinderIndexer::setState($state); // Import the finder plugins. JPluginHelper::importPlugin('finder'); /* * We are going to swap out the raw document object with an HTML document * in order to work around some plugins that don't do proper environment * checks before trying to use HTML document functions. */ $raw = clone JFactory::getDocument(); $lang = JFactory::getLanguage(); // Get the document properties. $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => ' ', 'language' => $lang->getTag(), 'direction' => $lang->isRtl() ? 'rtl' : 'ltr'); // Get the HTML document. $html = JDocument::getInstance('html', $attributes); $doc = JFactory::getDocument(); // Swap the documents. $doc = $html; // Get the admin application. $admin = clone JFactory::getApplication(); // Get the site app. $site = JApplication::getInstance('site'); // Swap the app. $app = JFactory::getApplication(); $app = $site; // Start the indexer. try { // Trigger the onBeforeIndex event. JEventDispatcher::getInstance()->trigger('onBeforeIndex'); // Trigger the onBuildIndex event. JEventDispatcher::getInstance()->trigger('onBuildIndex'); // Get the indexer state. $state = FinderIndexer::getState(); $state->start = 0; $state->complete = 0; // Swap the documents back. $doc = $raw; // Swap the applications back. $app = $admin; // Send the response. $this->sendResponse($state); } catch (Exception $e) { // Swap the documents back. $doc = $raw; // Send the response. $this->sendResponse($e); } }
/** * trim string with max specify * * @param string $title * @param integer $max. */ function trimString($title, $maxchars = 60, $includeTags = NULL) { if (!empty($includeTags)) { $title = $this->trimIncludeTags($title, $this->buildStrTags($includeTags)); } if (function_exists('mb_substr')) { $doc = JDocument::getInstance(); return SmartTrim::mb_trim($title, 0, $maxchars, $doc->_charset); } else { return SmartTrim::trim($title, 0, $maxchars); } }
/** * Display a custom error page and exit gracefully * * @param object $error Exception object * * @return void * * @deprecated * @since 11.1 */ public static function customErrorPage(&$error) { // Initialise variables. jimport('joomla.document.document'); $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); $config = JFactory::getConfig(); // Get the current template from the application $template = $app->getTemplate(); // Push the error object into the document $document->setError($error); @ob_end_clean(); $document->setTitle(JText::_('Error') . ': ' . $error->get('code')); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug'))); // Do not allow cache JResponse::allowCache(false); JResponse::setBody($data); echo JResponse::toString(); $app->close(0); }
/** * Allows the application to load a custom or default document. * * The logic and options for creating this object are adequately generic for default cases * but for many applications it will make sense to override this method and create a document, * if required, based on more specific needs. * * @param JDocument $document An optional document object. If omitted, the factory document is created. * * @return InstallationApplicationWeb This method is chainable. * * @since 3.2 */ public function loadDocument(JDocument $document = null) { if ($document === null) { $lang = JFactory::getLanguage(); $type = $this->input->get('format', 'html', 'word'); $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => ' ', 'language' => $lang->getTag(), 'direction' => $lang->isRtl() ? 'rtl' : 'ltr'); $document = JDocument::getInstance($type, $attributes); // Register the instance to JFactory. JFactory::$document = $document; } $this->document = $document; return $this; }
function writeContactForm($_this) { ?> <?php if (!$_this->returnAjaxForm) { // header of the adminForm // don't remove this line echo $_this->getTmplHeader(); ?> <div id="displayAiContactSafeForm_<?php echo $_this->profile->id; ?> "> <?php } ?> <?php if ($_this->returnAjaxForm) { $doc = JDocument::getInstance(); $renderer = $doc->loadRenderer('message'); echo '<div class="error">'; echo $renderer->render('message'); echo '</div>'; if ($_this->_app->_session->get('isOK:' . $_this->_sTask)) { $message = $_this->_app->_session->get('confirmationMessage:' . $_this->_sTask . '_' . $_this->r_id); if (strlen($message) > 0) { echo '<input type="hidden" id="ajax_message_sent" name="ajax_message_sent" value="1" />'; } } } ?> <div class="aiContactSafe" id="aiContactSafe_contact_form"> <?php if ($_this->requested_fields) { ?> <div class="aiContactSafe" id="aiContactSafe_info"><?php echo $_this->contactinformations['required_field_notification']; ?> </div> <?php } ?> <?php foreach ($_this->fields as $field) { if (is_null($field->html_label)) { ?> <div class="aiContactSafe_row_hidden" id="aiContactSafe_row_<?php echo $field->name; ?> "><div class="aiContactSafe_contact_form_field_right"><?php echo $field->html_tag; ?> </div></div> <?php } else { if ($_this->profile->bottom_row_space > 0) { $row_space = '<div class="row_space" style="clear:both; height:' . $_this->profile->bottom_row_space . 'px; line-height:' . $_this->profile->bottom_row_space . 'px;"> </div>'; } else { $row_space = ''; } if ($field->label_after_field) { ?> <div class="aiContactSafe_row<?php echo $field->has_errors ? ' with_errors' : ''; ?> " id="aiContactSafe_row_<?php echo $field->name; ?> "><div class="aiContactSafe_contact_form_field_left"><?php echo $field->html_tag; ?> </div><div class="aiContactSafe_contact_form_field_label_right"><?php echo $field->html_label; ?> <?php echo $field->field_required ? '<label class="required_field">' . $_this->profile->required_field_mark . '</label>' : ''; ?> </div> <?php if ($field->has_errors) { echo '<div class="aiContactSafe_error_msg"><ul>'; foreach ($field->error_msg as $msg) { echo '<li>' . $msg . '</li>'; } echo '</ul></div>'; } ?> <?php echo $row_space; ?> </div> <?php } else { ?> <div class="aiContactSafe_row<?php echo $field->has_errors ? ' with_errors' : ''; ?> " id="aiContactSafe_row_<?php echo $field->name; ?> "><div class="aiContactSafe_contact_form_field_label_left"><?php echo $field->html_label; ?> <?php echo $field->field_required ? '<label class="required_field">' . $_this->profile->required_field_mark . '</label>' : ''; ?> </div><div class="aiContactSafe_contact_form_field_right"><?php echo $field->html_tag; ?> </div> <?php if ($field->has_errors) { echo '<div class="aiContactSafe_error_msg"><ul>'; foreach ($field->error_msg as $msg) { echo '<li>' . $msg . '</li>'; } echo '</ul></div>'; } ?> <?php echo $row_space; ?> </div> <?php } } } ?> </div> <?php if ($_this->returnAjaxForm) { ?> <br style="clear:all;" /> <?php } else { ?> </div> <br style="clear:all;" /> <?php $_this->writeCaptcha(); ?> <br style="clear:all;" /> <div id="aiContactSafeBtns"><?php echo $_this->buttons; ?> </div> <br style="clear:all;" /> <?php // footer of the adminForm // don't remove this line echo $_this->getTmplFooter(); } ?> <?php }
/** * Create a document object * * @access private * @return object JDocument * @since 1.5 */ private static function &_createDocument() { jimport('joomla.document.document'); $lang =& JFactory::getLanguage(); //Keep backwards compatibility with Joomla! 1.0 $raw = JRequest::getBool('no_html'); $type = JRequest::getWord('format', $raw ? 'raw' : 'html'); $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => ' ', 'language' => $lang->getTag(), 'direction' => $lang->isRTL() ? 'rtl' : 'ltr'); $doc =& JDocument::getInstance($type, $attributes); return $doc; }
case "cartCheckout": $mainframe->redirect('index.php?&option=com_docmanpaypal&task=order&mode=cart'); break; case "pdfPreview": $id = JRequest::getInt('id'); $database->setQuery("select * from #__docman_documents where docman_document_id = $id limit 1"); $row = $database->loadObject(); if (pathinfo($row->storage_path,PATHINFO_EXTENSION) != 'pdf') { die('This is not a pdf file.'); } @ini_set('memory_limit','512M'); $database = &JFactory::getDBO(); $document = &JFactory::getDocument(); $doc = &JDocument::getInstance('raw'); $document = $doc; require_once(JPATH_ADMINISTRATOR . DS .'components' . DS. 'com_docmanpaypal' . DS . 'fpdi' . DS . 'FPDI_Protection.php'); $pdf = new FPDI_Protection(); if ($dm->cfg['pdfOrientation'] == 'portrait') { $pdf->FPDF('P', 'in', array('8.267','11.692')); } else { $pdf->FPDF('P', 'in', array('11.692','8.267')); } $sourceFile = $dm->docman_path . DS . $row->storage_path; $pdfPreviewPath = dirname($sourceFile) . DS . basename($sourceFile,'.pdf') . "_preview.pdf"; //die($pdfPreviewPath);