示例#1
0
 /**
  * Class constructor
  *
  * @param   JApplicationCms  $app   JApplicationCms Object
  * @param   JMenu            $menu  JMenu object
  *
  * @since   3.4
  */
 public function __construct(JApplicationCms $app = null, JMenu $menu = null)
 {
     $this->app = $app ? $app : JApplicationCms::getInstance('site');
     $this->menu = $menu ? $menu : $this->app->getMenu();
     // Add core rules
     if ($this->app->get('force_ssl') == 2) {
         $this->attachParseRule(array($this, 'parseCheckSSL'), self::PROCESS_BEFORE);
     }
     $this->attachParseRule(array($this, 'parseInit'), self::PROCESS_BEFORE);
     $this->attachBuildRule(array($this, 'buildInit'), self::PROCESS_BEFORE);
     $this->attachBuildRule(array($this, 'buildComponentPreprocess'), self::PROCESS_BEFORE);
     if ($this->app->get('sef')) {
         if ($this->app->get('sef_suffix')) {
             $this->attachParseRule(array($this, 'parseFormat'), self::PROCESS_BEFORE);
             $this->attachBuildRule(array($this, 'buildFormat'), self::PROCESS_AFTER);
         }
         $this->attachParseRule(array($this, 'parseSefRoute'), self::PROCESS_DURING);
         $this->attachBuildRule(array($this, 'buildSefRoute'), self::PROCESS_DURING);
         $this->attachParseRule(array($this, 'parsePaginationData'), self::PROCESS_AFTER);
         $this->attachBuildRule(array($this, 'buildPaginationData'), self::PROCESS_AFTER);
         if ($this->app->get('sef_rewrite')) {
             $this->attachBuildRule(array($this, 'buildRewrite'), self::PROCESS_AFTER);
         }
     }
     $this->attachParseRule(array($this, 'parseRawRoute'), self::PROCESS_DURING);
     $this->attachBuildRule(array($this, 'buildBase'), self::PROCESS_AFTER);
 }
示例#2
0
文件: script.php 项目: grlf/eyedock
 /**
  * method to run after an install/update/uninstall method
  *
  * @return void
  */
 function postflight($type, $parent)
 {
     // $parent is the class calling this method
     // $type is the type of change (install, update or discover_install)
     $siteApp = JApplicationCms::getInstance('site');
     $menu = $siteApp->getMenu()->getItems('link', 'index.php?option=com_alfcontact&view=alfcontact');
     $firstmenu = array_shift($menu);
     if ($type == 'update' && !$firstmenu->params->exists('header')) {
         //upgrade v3.1.1: moved parameters from component to menu-item
         echo 'The Title, Header and Footer parameters have now been moved to the menu-item settings!';
         //check for component parameters
         $c_params = JComponentHelper::getParams('com_alfcontact');
         // get the 'old' values from the component settings
         $temp_title = $c_params->get('title');
         $temp_header = $c_params->get('header');
         $temp_footer = $c_params->get('footer');
         //clear the 'old' settings in the component settings
         $c_params->set('title', '');
         $c_params->set('header', '');
         $c_params->set('footer', '');
         //Copy the parameteres to the menu-item settings
         $db = JFactory::getDBO();
         $name = 'com_alfcontact';
         $query = "UPDATE #__extensions SET params =" . $db->quote((string) $c_params) . "WHERE name =" . $db->quote((string) $name);
         $db->setQuery($query);
         foreach ($menu as $val) {
             $val->params->set('title', $temp_title);
             $val->params->set('header', $temp_header);
             $val->params->set('footer', $temp_footer);
             $query = "UPDATE #__menu SET params = " . $db->quote((string) $val->params) . " WHERE id = " . $db->quote((string) $val->id);
             $db->setQuery($query);
         }
     }
     echo '<p>' . JText::_('COM_ALFCONTACT_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
 }
示例#3
0
文件: Menu.php 项目: nmsde/gantry5
 public function __construct()
 {
     $this->app = \JApplicationCms::getInstance('site');
     $lang = \JFactory::getLanguage();
     $tag = \JLanguageMultilang::isEnabled() ? $lang->getTag() : '*';
     $this->menu = $this->app->getMenu();
     $this->default = $this->menu->getDefault($tag);
     $this->active = $this->menu->getActive();
 }
示例#4
0
 /**
  * Class constructor.
  *
  * @param   array  $options  The class options.
  *
  * @since   1.5
  */
 public function __construct($options = array())
 {
     $this->_pathway = array();
     $app = JApplicationCms::getInstance('site');
     $menu = $app->getMenu();
     if ($item = $menu->getActive()) {
         $menus = $menu->getMenu();
         $home = $menu->getDefault();
         if (is_object($home) && $item->id != $home->id) {
             foreach ($item->tree as $menupath) {
                 $url = '';
                 $link = $menu->getItem($menupath);
                 switch ($link->type) {
                     case 'separator':
                     case 'heading':
                         $url = null;
                         break;
                     case 'url':
                         if (strpos($link->link, 'index.php?') === 0 && strpos($link->link, 'Itemid=') === false) {
                             // If this is an internal Joomla link, ensure the Itemid is set.
                             $url = $link->link . '&Itemid=' . $link->id;
                         } else {
                             $url = $link->link;
                         }
                         break;
                     case 'alias':
                         // If this is an alias use the item id stored in the parameters to make the link.
                         $url = 'index.php?Itemid=' . $link->params->get('aliasoptions');
                         break;
                     default:
                         $router = $app::getRouter();
                         if ($router->getMode() == JROUTER_MODE_SEF) {
                             $url = 'index.php?Itemid=' . $link->id;
                         } else {
                             $url .= $link->link . '&Itemid=' . $link->id;
                         }
                         break;
                 }
                 $this->addItem($menus[$menupath]->title, $url);
             }
         }
     }
 }
示例#5
0
 /**
  * Class constructor.
  *
  * @param   array  $options  The class options.
  *
  * @since   1.5
  */
 public function __construct($options = array())
 {
     $this->_pathway = array();
     $app = JApplicationCms::getInstance('site');
     $menu = $app->getMenu();
     $lang = JFactory::getLanguage();
     if ($item = $menu->getActive()) {
         $menus = $menu->getMenu();
         // Look for the home menu
         if (JLanguageMultilang::isEnabled()) {
             $home = $menu->getDefault($lang->getTag());
         } else {
             $home = $menu->getDefault();
         }
         if (is_object($home) && $item->id != $home->id) {
             foreach ($item->tree as $menupath) {
                 $link = $menu->getItem($menupath);
                 switch ($link->type) {
                     case 'separator':
                     case 'heading':
                         $url = null;
                         break;
                     case 'url':
                         if (strpos($link->link, 'index.php?') === 0 && strpos($link->link, 'Itemid=') === false) {
                             // If this is an internal Joomla link, ensure the Itemid is set.
                             $url = $link->link . '&Itemid=' . $link->id;
                         } else {
                             $url = $link->link;
                         }
                         break;
                     case 'alias':
                         // If this is an alias use the item id stored in the parameters to make the link.
                         $url = 'index.php?Itemid=' . $link->params->get('aliasoptions');
                         break;
                     default:
                         $url = $link->link . '&Itemid=' . $link->id;
                         break;
                 }
                 $this->addItem($menus[$menupath]->title, $url);
             }
         }
     }
 }
示例#6
0
 /**
  * Class constructor
  *
  * @param   array            $options  Array of options
  * @param   JApplicationCms  $app      JApplicationCms Object
  * @param   JMenu            $menu     JMenu object
  *
  * @since   3.4
  */
 public function __construct($options = array(), JApplicationCms $app = null, JMenu $menu = null)
 {
     parent::__construct($options);
     $this->app = $app ? $app : JApplicationCms::getInstance('site');
     $this->menu = $menu ? $menu : $this->app->getMenu();
 }
 protected function sendMail($project, $emailId)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get website
     $uri = JUri::getInstance();
     $website = $uri->toString(array("scheme", "host"));
     $emailMode = $this->params->get("email_mode", "plain");
     // Route project URI
     $appSite = JApplicationCms::getInstance('site');
     $router = $appSite->getRouter('site');
     $routedUri = $router->build(CrowdfundingHelperRoute::getDetailsRoute($project->slug, $project->catslug));
     if ($routedUri instanceof JUri) {
         $routedUri = $routedUri->toString();
     }
     if (0 === strpos($routedUri, "/administrator")) {
         $routedUri = str_replace("/administrator", "", $routedUri);
     }
     // Prepare data for parsing
     $data = array("site_name" => $app->get("sitename"), "site_url" => JUri::root(), "item_title" => $project->title, "item_url" => $website . $routedUri);
     // Send mail to the administrator
     if (!$emailId) {
         return false;
     }
     $email = new EmailTemplates\Email();
     $email->setDb(JFactory::getDbo());
     $email->load($emailId);
     if (!$email->getSenderName()) {
         $email->setSenderName($app->get("fromname"));
     }
     if (!$email->getSenderEmail()) {
         $email->setSenderEmail($app->get("mailfrom"));
     }
     $recipientName = $project->name;
     $recipientMail = $project->email;
     // Prepare data for parsing
     $data["sender_name"] = $email->getSenderName();
     $data["sender_email"] = $email->getSenderEmail();
     $data["recipient_name"] = $recipientName;
     $data["recipient_email"] = $recipientMail;
     $email->parse($data);
     $subject = $email->getSubject();
     $body = $email->getBody($emailMode);
     $mailer = JFactory::getMailer();
     if (strcmp("html", $emailMode) == 0) {
         // Send as HTML message
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
     } else {
         // Send as plain text.
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
     }
     // Log the error.
     if ($result !== true) {
         $this->log->add(JText::sprintf("PLG_CONTENT_CROWDFUNDINGUSERMAIL_ERROR_SEND_MAIL", $this->name), "PLG_CONTENT_USERE_MAIL_ERROR", JText::sprintf("PLG_CONTENT_CROWDFUNDINGUSERMAIL_ERROR_SEND_MAIL_NOTE", $mailer->ErrorInfo));
         return false;
     }
     return true;
 }
 /**
  * @param stdClass $project
  * @param int $emailId
  *
  * @return bool
  */
 protected function sendMail($project, $emailId)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get website
     $uri = JUri::getInstance();
     $website = $uri->toString(array('scheme', 'host'));
     $emailMode = $this->params->get('email_mode', 'plain');
     // Route project URI
     $appSite = JApplicationCms::getInstance('site');
     $router = $appSite->getRouter('site');
     $routedUri = $router->build(CrowdfundingHelperRoute::getDetailsRoute($project->slug, $project->catslug));
     if ($routedUri instanceof JUri) {
         $routedUri = $routedUri->toString();
     }
     if (0 === strpos($routedUri, '/administrator')) {
         $routedUri = str_replace('/administrator', '', $routedUri);
     }
     // Prepare data for parsing
     $data = array('site_name' => $app->get('sitename'), 'site_url' => JUri::root(), 'item_title' => $project->title, 'item_url' => $website . $routedUri);
     $email = new Emailtemplates\Email();
     $email->setDb(JFactory::getDbo());
     $email->load($emailId);
     if (!$email->getSenderName()) {
         $email->setSenderName($app->get('fromname'));
     }
     if (!$email->getSenderEmail()) {
         $email->setSenderEmail($app->get('mailfrom'));
     }
     $recipientName = $project->name;
     $recipientMail = $project->email;
     // Prepare data for parsing
     $data['sender_name'] = $email->getSenderName();
     $data['sender_email'] = $email->getSenderEmail();
     $data['recipient_name'] = $recipientName;
     $data['recipient_email'] = $recipientMail;
     $email->parse($data);
     $subject = $email->getSubject();
     $body = $email->getBody($emailMode);
     $mailer = JFactory::getMailer();
     if (strcmp('html', $emailMode) === 0) {
         // Send as HTML message
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
     } else {
         // Send as plain text.
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
     }
     // Log the error.
     if ($result !== true) {
         JLog::add($this->errorPrefix . $mailer->ErrorInfo, JLog::WARNING, 'com_crowdfunding');
         return false;
     }
     return true;
 }
示例#9
0
 /**
  * Route URI to front-end.
  *
  * @param string  $url
  *
  * @return string
  */
 public static function siteRoute($url)
 {
     $appSite = JApplicationCms::getInstance('site');
     $routerSite = $appSite->getRouter('site');
     $routedUri = $routerSite->build($url);
     if ($routedUri instanceof JUri) {
         $routedUri = $routedUri->toString();
     }
     if (false !== strpos($routedUri, '/administrator')) {
         $routedUri = str_replace('/administrator', '', $routedUri);
     }
     return JUri::root() . $routedUri;
 }
示例#10
0
 /**
  * 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 = JApplicationCms::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);
     }
 }
示例#11
0
 /**
  * Get menu item by id
  *
  * @param   string  $language  The language code.
  *
  * @return  mixed  The item object or null when not found for given language
  *
  * @since   1.6
  */
 public function getDefault($language = '*')
 {
     if (array_key_exists($language, $this->_default) && JApplicationCms::getInstance('site')->getLanguageFilter()) {
         return $this->_items[$this->_default[$language]];
     } elseif (array_key_exists('*', $this->_default)) {
         return $this->_items[$this->_default['*']];
     } else {
         return null;
     }
 }
示例#12
0
 /**
  * Get an application object.
  *
  * Returns the global {@link JApplicationCms} object, only creating it if it doesn't already exist.
  *
  * @param   mixed      $id         A client identifier or name.
  * @param   array      $config     An optional associative array of configuration settings.
  * @param   string     $prefix     Application prefix
  * @param   Container  $container  An optional dependency injection container to inject into the application.
  *
  * @return  JApplicationCms object
  *
  * @see     JApplication
  * @since   11.1
  * @throws  Exception
  */
 public static function getApplication($id = null, array $config = array(), $prefix = 'JApplication', Container $container = null)
 {
     if (!self::$application) {
         if (!$id) {
             throw new Exception('Application Instantiation Error', 500);
         }
         $container = $container ?: self::getContainer();
         self::$application = JApplicationCms::getInstance($id, $prefix, $container);
     }
     return self::$application;
 }
示例#13
0
 /**
  * Get a application object.
  *
  * Returns the global {@link JApplicationCms} object, only creating it if it doesn't already exist.
  *
  * @param   mixed   $id      A client identifier or name.
  * @param   array   $config  An optional associative array of configuration settings.
  * @param   string  $prefix  Application prefix
  *
  * @return  JApplicationCms object
  *
  * @see     JApplication
  * @since   11.1
  * @throws  Exception
  */
 public static function getApplication($id = null, array $config = array(), $prefix = 'J')
 {
     if (!self::$application) {
         if (!$id) {
             throw new Exception('Application Instantiation Error', 500);
         }
         self::$application = JApplicationCms::getInstance($id);
     }
     return self::$application;
 }
示例#14
0
 /**
  * Main get data method
  *
  * @access public
  * @return Object[]
  */
 public function getData()
 {
     // Load data from XML file, parse it to load records
     $cachedSitemapFilePath = JPATH_COMPONENT_ADMINISTRATOR . '/cache/analyzer/';
     // Has sitemap some vars such as lang or Itemid?
     $sitemapLang = $this->getState('sitemaplang', '');
     $sitemapLinksLang = $sitemapLang ? $sitemapLang . '/' : '';
     $sitemapLang = $sitemapLang ? '_' . $sitemapLang : '';
     $sitemapDataset = $this->getState('sitemapdataset', '');
     $sitemapDataset = $sitemapDataset ? '_dataset' . (int) $sitemapDataset : '';
     $sitemapItemid = $this->getState('sitemapitemid', '');
     $sitemapItemid = $sitemapItemid ? '_menuid' . (int) $sitemapItemid : '';
     // Final name
     $cachedSitemapFilename = 'sitemap_xml' . $sitemapLang . $sitemapDataset . $sitemapItemid . '.xml';
     // Start processing
     try {
         // Now check if the file correctly exists
         if (JFile::exists($cachedSitemapFilePath . $cachedSitemapFilename)) {
             $loadedSitemapXML = simplexml_load_file($cachedSitemapFilePath . $cachedSitemapFilename);
         } else {
             throw new JMapException(JText::sprintf('COM_JMAP_ANALYZER_NOCACHED_FILE_EXISTS', $this->_db->getErrorMsg()), 'error');
         }
         // Execute HTTP request and associate HTTP response code with each record links
         $httpClient = new JMapHttp();
         if ($loadedSitemapXML->url->count()) {
             // Manage splice pagination here for the XML records
             $convertedIteratorToArray = iterator_to_array($loadedSitemapXML->url, false);
             // Store number of records for pagination
             $this->recordsNumber = count($convertedIteratorToArray);
             // Execute pagination splicing if any limit is set
             $limit = $this->getState('limit');
             if ($limit) {
                 $loadedSitemapXML = array_splice($convertedIteratorToArray, $this->getState('limitstart'), $this->getState('limit'));
             } else {
                 $loadedSitemapXML = $convertedIteratorToArray;
             }
             // Now start the Analyzer
             $siteRouter = JRouterSite::getInstance('site', array('mode' => JROUTER_MODE_SEF));
             if (version_compare(JVERSION, '3.4', '>=')) {
                 JApplicationCms::getInstance('site')->loadLanguage();
             }
             $headers = array('Accept' => 'text/html', 'User-Agent' => 'Googlebot-Image/1.0');
             foreach ($loadedSitemapXML as $url) {
                 $httpResponse = $httpClient->get($url->loc, $headers);
                 $url->httpstatus = $httpResponse->code;
                 // Find informations about the link, component and menu itemid if any, need a workaround to parse correctly from backend
                 $baseAdmin = JURI::base();
                 $baseSite = str_replace('/administrator', '', $baseAdmin);
                 $fakedUrl = str_replace($baseSite, $baseAdmin, $url->loc);
                 $fakedUrl = str_replace($sitemapLinksLang, '', $fakedUrl);
                 // Now instantiate and parse the faked url from backend, replacing the uri base it will be = site
                 $uriObject = JURI::getInstance((string) $fakedUrl);
                 $parseUri = $siteRouter->parse($uriObject);
                 // Now augment the object to show informations
                 $url->component = isset($parseUri['option']) ? $parseUri['option'] : JText::_('COM_JMAP_ANALYZER_NOINFO');
                 $url->menuId = isset($parseUri['Itemid']) ? $parseUri['Itemid'] : JText::_('COM_JMAP_ANALYZER_NOINFO');
                 $url->menuTitle = JText::_('COM_JMAP_ANALYZER_NOINFO');
                 // Translate human menu
                 if (isset($parseUri['Itemid'])) {
                     $query = "SELECT" . $this->_db->quoteName('title') . "\n FROM #__menu" . "\n WHERE " . $this->_db->quoteName('id') . " = " . (int) $parseUri['Itemid'];
                     $menuTitle = $this->_db->setQuery($query)->loadResult();
                     $url->menuTitle = $menuTitle;
                 }
             }
             // Perform array sorting if any
             $order = $this->getState('order', null);
             $jmapAnalyzerOrderDir = $this->getState('order_dir', 'asc');
             if ($order == 'httpstatus') {
                 function cmpAsc($a, $b)
                 {
                     return (int) $a->httpstatus < (int) $b->httpstatus ? -1 : 1;
                 }
                 function cmpDesc($a, $b)
                 {
                     return (int) $a->httpstatus > (int) $b->httpstatus ? -1 : 1;
                 }
                 $callbackName = $jmapAnalyzerOrderDir == 'asc' ? 'cmpAsc' : 'cmpDesc';
                 usort($loadedSitemapXML, $callbackName);
             }
             if ($order == 'link') {
                 function cmpAsc($a, $b)
                 {
                     return strcmp($a->loc, $b->loc);
                 }
                 function cmpDesc($a, $b)
                 {
                     return strcmp($b->loc, $a->loc);
                 }
                 $callbackName = $jmapAnalyzerOrderDir == 'asc' ? 'cmpAsc' : 'cmpDesc';
                 usort($loadedSitemapXML, $callbackName);
             }
         } else {
             throw new JMapException(JText::sprintf('COM_JMAP_ANALYZER_EMPTY_SITEMAP', $this->_db->getErrorMsg()), 'notice');
         }
     } catch (JMapException $e) {
         $this->app->enqueueMessage($e->getMessage(), $e->getErrorLevel());
         $loadedSitemapXML = array();
     } catch (Exception $e) {
         $jmapException = new JMapException($e->getMessage(), 'error');
         $this->app->enqueueMessage($jmapException->getMessage(), $jmapException->getErrorLevel());
         $loadedSitemapXML = array();
     }
     return $loadedSitemapXML;
 }
示例#15
0
 /**
  * Create a uri based on a full or partial url string
  *
  * @param   string  $url  The URI
  *
  * @return  JUri
  *
  * @since   3.2
  */
 protected function createURI($url)
 {
     // Create the URI
     $uri = parent::createURI($url);
     // Set URI defaults
     $app = JApplicationCms::getInstance('site');
     $menu = $app->getMenu();
     // Get the itemid form the URI
     $itemid = $uri->getVar('Itemid');
     if (is_null($itemid)) {
         if ($option = $uri->getVar('option')) {
             $item = $menu->getItem($this->getVar('Itemid'));
             if (isset($item) && $item->component == $option) {
                 $uri->setVar('Itemid', $item->id);
             }
         } else {
             if ($option = $this->getVar('option')) {
                 $uri->setVar('option', $option);
             }
             if ($itemid = $this->getVar('Itemid')) {
                 $uri->setVar('Itemid', $itemid);
             }
         }
     } else {
         if (!$uri->getVar('option')) {
             if ($item = $menu->getItem($itemid)) {
                 $uri->setVar('option', $item->component);
             }
         }
     }
     return $uri;
 }
示例#16
0
 /**
  * Tests the JApplicationCms::getInstance method.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testGetInstance()
 {
     TestReflection::setValue('JApplicationCms', 'instances', array('CmsInspector' => $this->class));
     $this->assertInstanceOf('JApplicationCmsInspector', JApplicationCms::getInstance('CmsInspector'), 'Tests that getInstance will instantiate a valid child class of JApplicationCms.');
     TestReflection::setValue('JApplicationCms', 'instances', array('CmsInspector' => 'foo'));
     $this->assertThat(JApplicationCms::getInstance('CmsInspector'), $this->equalTo('foo'), 'Tests that singleton value is returned.');
 }
示例#17
0
 function getData($number)
 {
     nextendimport('nextend.database.database');
     $db = NextendDatabase::getInstance();
     $data = array();
     $query = 'SELECT ';
     $query .= 'con.id ';
     $query .= 'FROM #__content AS con ';
     $query .= 'LEFT JOIN #__flexicontent_cats_item_relations AS fcat ON fcat.itemid = con.id ';
     $query .= 'LEFT JOIN #__categories AS cat ON fcat.catid = cat.id ';
     $where = array();
     $category = array_map('intval', explode('||', $this->_data->get('sourcecategory', '')));
     if (!in_array('0', $category) && !in_array('1', $category)) {
         $where[] = 'fcat.catid IN (' . implode(',', $category) . ') ';
     }
     if ($this->_data->get('sourcepublished', 1)) {
         $where[] = 'con.state = 1 ';
     }
     if ($this->_data->get('sourcefeatured', 0)) {
         $where[] = 'con.featured = 1 ';
     }
     $language = $this->_data->get('sourcelanguage', '*');
     if ($language) {
         $where[] = 'con.language = ' . $db->quote($language) . ' ';
     }
     if (count($where)) {
         $query .= ' WHERE ' . implode(' AND ', $where);
     }
     $query .= 'GROUP BY con.id ';
     $order = NextendParse::parse($this->_data->get('order1', 'con.title|*|asc'));
     if ($order[0]) {
         $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
         $order = NextendParse::parse($this->_data->get('order2', 'con.title|*|asc'));
         if ($order[0]) {
             $query .= ', ' . $order[0] . ' ' . $order[1] . ' ';
         }
     }
     $query .= 'LIMIT 0, ' . $number . ' ';
     $db->setQuery($query);
     $result = $db->loadAssocList();
     $lng = JFactory::getLanguage();
     $adminapp = JFactory::$application;
     $siteapp = JApplicationCms::getInstance('site');
     $siteapp->loadLanguage($lng);
     require_once JPATH_ADMINISTRATOR . DS . 'components/com_flexicontent/defineconstants.php';
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'tables');
     require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php';
     require_once JPATH_SITE . DS . "components/com_flexicontent/classes/flexicontent.fields.php";
     require_once JPATH_SITE . DS . "components/com_flexicontent/classes/flexicontent.helper.php";
     require_once JPATH_SITE . '/components/com_flexicontent/models/item.php';
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $aid = FLEXI_J16GE ? $user->getAuthorisedViewLevels() : (int) $user->get('aid');
     $itemmodel = FLEXI_J16GE ? new FlexicontentModelItem() : new FlexicontentModelItems();
     for ($i = 0; $i < count($result); $i++) {
         $data[$i] = array();
         JFactory::$application = $siteapp;
         $item = $itemmodel->getItem($result[$i]['id'], $check_view_access = false);
         list($item) = FlexicontentFields::getFields($item, '', $item->parameters, $aid);
         JFactory::$application = $adminapp;
         $data[$i]['link'] = FlexicontentHelperRoute::getItemRoute($item->id, $item->catid);
         foreach ($item->fields as $k => $field) {
             $data[$i][$k] = FlexicontentFields::getFieldDisplay($item, $k, $values = null, $method = 'display');
         }
     }
     JFactory::$application = $adminapp;
     return $data;
 }
示例#18
0
 /**
  * Returns the global JApplicationCms object, only creating it if it
  * doesn't already exist.
  *
  * @param   mixed   $client  A client identifier or name.
  * @param   array   $config  An optional associative array of configuration settings.
  * @param   string  $prefix  A prefix for class names
  *
  * @return  JApplicationCms  A JApplicationCms object.
  *
  * @since   11.1
  * @deprecated  4.0  Use JApplicationCms::getInstance() instead
  * @note    As of 3.2, this proxies to JApplicationCms::getInstance()
  */
 public static function getInstance($client, $config = array(), $prefix = 'J')
 {
     return JApplicationCms::getInstance($client);
 }
示例#19
0
 /**
  * Tests the JApplicationCms::getInstance method.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testGetInstance()
 {
     TestReflection::setValue('JApplicationCms', 'instances', array('CmsInspector' => $this->class));
     $this->assertInstanceOf('JApplicationCmsInspector', JApplicationCms::getInstance('CmsInspector'));
     TestReflection::setValue('JApplicationCms', 'instances', array('CmsInspector' => 'foo'));
     $this->assertEquals('foo', JApplicationCms::getInstance('CmsInspector'));
 }
示例#20
0
<?php

/**
 * @package      Crowdfunding
 * @subpackage   Components
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2016 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      GNU General Public License version 3 or later; see LICENSE.txt
 */
// no direct access
defined('_JEXEC') or die;
$appSite = JApplicationCms::getInstance('site');
$routerSite = $appSite->getRouter('site');
$uri = JUri::getInstance();
$website = $uri->toString(array('scheme', 'host'));
foreach ($this->items as $i => $item) {
    $ordering = $this->listOrder === 'a.ordering';
    $disableClassName = '';
    $disabledLabel = '';
    if (!$this->saveOrder) {
        $disabledLabel = JText::_('JORDERINGDISABLED');
        $disableClassName = 'inactive tip-top';
    }
    $numberOfRewards = isset($this->rewards[$item->id]) ? $this->rewards[$item->id]['number'] : 0;
    ?>
    <tr class="row<?php 
    echo $i % 2;
    ?>
" sortable-group-id="<?php 
    echo $item->catid;
    ?>
示例#21
0
 /**
  * Initialise the application.
  *
  * Loads the necessary Joomla libraries to make sure
  * the Joomla application can run and sets up the JFactory properties.
  *
  * @param   array  $options  An optional associative array of configuration settings.
  * @return  void
  */
 protected function _initialize()
 {
     // Load dependencies
     jimport('joomla.application.component.helper');
     jimport('joomla.application.menu');
     jimport('joomla.environment.uri');
     jimport('joomla.event.dispatcher');
     jimport('joomla.utilities.utility');
     jimport('joomla.utilities.arrayhelper');
     jimport('joomla.application.module.helper');
     // Tell JFactory where to find the current application object
     JFactory::$application = $this;
     // Start a new session and tell JFactory where to find it if we're on Joomla 3
     if (version_compare(JVERSION, '3.0.0', '>=')) {
         JFactory::$session = $this->_startSession();
     }
     // Load plugins
     JPluginHelper::importPlugin('system');
     // Load required languages
     $lang = JFactory::getLanguage();
     $lang->load('lib_joomla', JPATH_ADMINISTRATOR, null, true);
     $lang->load('com_installer', JPATH_ADMINISTRATOR, null, true);
     // Instiantiate the Joomla application object if we
     // need either admin or site
     $name = $this->getName();
     if (in_array($name, array('administrator', 'site'))) {
         $this->_application = \JApplicationCms::getInstance($name);
     }
 }