Example #1
0
 /**
  * Prepares the document
  */
 protected function _prepareDocument()
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $title = NULL;
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     }
     $title = $this->params->get('page_title', '');
     if ($this->folder->getDisplayName()) {
         $title = $this->folder->getDisplayName();
     }
     // Check for empty title and add site name if param is set
     if (empty($title)) {
         $title = $app->getCfg('sitename');
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
     }
     if (empty($title)) {
         $title = $this->folder->getDisplayName();
     }
     $this->document->setTitle($title);
     if ($this->folder->getText()) {
         $this->document->setDescription($this->folder->getText());
     } elseif (!$this->folder->getText() && $this->params->get('menu-meta_description')) {
         $this->document->setDescription($this->params->get('menu-meta_description'));
     }
 }
Example #2
0
function loadLink( $link_id, &$savantConf, &$fields, &$params ) {
	global $_MAMBOTS, $mtconf;

	$database	=& JFactory::getDBO();
	$jdate		= JFactory::getDate();
	$now		= $jdate->toMySQL();
	$nullDate	= $database->getNullDate();

	# Get all link data
	$database->setQuery( "SELECT l.*, u.username AS username, u.name AS owner, u.email AS owner_email, cl.cat_id AS cat_id, c.cat_name AS cat_name, img.filename AS link_image, img.img_id FROM (#__mt_links AS l, #__mt_cl AS cl)"
		. "\n LEFT JOIN #__users AS u ON u.id = l.user_id"
		. "\n LEFT JOIN #__mt_cats AS c ON c.cat_id = cl.cat_id"
		. "\n LEFT JOIN #__mt_images AS img ON img.link_id = l.link_id AND img.ordering = 1"
		. "\n WHERE link_published='1' AND link_approved > 0 AND l.link_id='".$link_id."' " 
		. "\n AND ( publish_up = ".$database->Quote($nullDate)." OR publish_up <= '$now'  ) "
		. "\n AND ( publish_down = ".$database->Quote($nullDate)." OR publish_down >= '$now' ) "
		. "\n AND l.link_id = cl.link_id"
		. "\n LIMIT 1"
	);
	$link = $database->loadObject();
	
	if(count($link)==0) return false;
	
	# Use owner's email address is listing e-mail is not available
	if ( $mtconf->get('use_owner_email') && empty($link->email) && $link->user_id > 0 ) {
		$link->email = $link->owner_email;
	}

	# Load link's template
	if ( empty($link->link_template) ) {
		// Get link's template
		$database->setQuery( "SELECT cat_template FROM #__mt_cats WHERE cat_id='".$link->cat_id."' LIMIT 1" );
		$cat_template = $database->loadResult();

		if ( !empty($cat_template) ) {
			loadCustomTemplate(null,$savantConf,$cat_template);
		}
	} else {
		loadCustomTemplate(null,$savantConf,$link->link_template);
	}
	
	# Load fields
	$fields = loadFields( $link );
	
	# Load custom fields' value from #__mt_cfvalues to $link
	$database->setQuery( "SELECT CONCAT('cust_',cf_id) as varname, value FROM #__mt_cfvalues WHERE link_id = '".$link_id."'" );
	$cfvalues = $database->loadObjectList('varname');
	foreach( $cfvalues as $cfkey => $cfvalue )
	{
		$link->$cfkey = $cfvalue->value;
	}

	# Parameters
	$params = new JRegistry( $link->attribs );
	$params->def( 'show_review', $mtconf->get('show_review'));
	$params->def( 'show_rating', $mtconf->get('show_rating' ));

	return $link;

}
Example #3
0
 /**
  * Prepares the document
  */
 protected function _prepareDocument()
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $title = NULL;
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     }
     $title = $this->params->get('page_title', '');
     $title .= " - " . JText::_('COM_EVENTGALLERY_ORDERS_PATH');
     // Check for empty title and add site name if param is set
     if (empty($title)) {
         $title = $app->getCfg('sitename');
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
     }
     if ($this->document) {
         $this->document->setTitle($title);
     }
 }
Example #4
0
 public function display($tpl = null)
 {
     require_once JPATH_SITE . '/modules/mod_k2_tools/helper.php';
     $application = JFactory::getApplication();
     $params = new JRegistry();
     $params->def('calendarCategory', $application->input->get('category', 0, 'int'));
     $params->def('month', $application->input->get('month', 0, 'int'));
     $params->def('year', $application->input->get('year', 0, 'int'));
     echo ModK2ToolsHelper::getCalendar($params);
 }
Example #5
0
File: oauth.php Project: 01J/topm
 /**
  * Constructor.
  *
  * @param   JRegistry  $options  JOpenstreetmapOauth options object.
  * @param   JHttp      $client   The HTTP client object.
  * @param   JInput     $input    The input object
  *
  * @since   13.1
  */
 public function __construct(JRegistry $options = null, JHttp $client = null, JInput $input = null)
 {
     $this->options = isset($options) ? $options : new JRegistry();
     $this->options->def('accessTokenURL', 'http://www.openstreetmap.org/oauth/access_token');
     $this->options->def('authoriseURL', 'http://www.openstreetmap.org/oauth/authorize');
     $this->options->def('requestTokenURL', 'http://www.openstreetmap.org/oauth/request_token');
     /*
     $this->options->def('accessTokenURL', 'http://api06.dev.openstreetmap.org/oauth/access_token');
     $this->options->def('authoriseURL', 'http://api06.dev.openstreetmap.org/oauth/authorize');
     $this->options->def('requestTokenURL', 'http://api06.dev.openstreetmap.org/oauth/request_token');
     */
     // Call the JOauth1Client constructor to setup the object.
     parent::__construct($this->options, $client, $input, null, '1.0');
 }
Example #6
0
 function onContentPrepare($context, &$article, &$params, $page = 0)
 {
     // simple performance check to determine whether bot should process further
     if (strpos($article->text, 'rokbox') === false) {
         return true;
     }
     // Get plugin info
     $plugin =& JPluginHelper::getPlugin('content', 'rokbox');
     // define the regular expression for the bot
     $regex = "#{rokbox(.*?)}(.*?){/rokbox}#s";
     $pluginParams = new JRegistry($plugin->params);
     // check whether plugin has been unpublished
     if (!$pluginParams->get('enabled', 1)) {
         $article->text = preg_replace($regex, '', $row->text);
         return true;
     }
     // find all instances of plugin and put in $matches
     preg_match_all($regex, $article->text, $matches);
     // Number of plugins
     $count = count($matches[0]);
     // plugin only processes if there are any instances of the plugin in the text
     if ($count) {
         // Get plugin parameters
         $style = $pluginParams->def('style', -2);
         $this->plgContentProcessRokboxImages($article, $matches, $count, $regex, $pluginParams);
     }
 }
Example #7
0
File: helper.php Project: 01J/topm
 public static function getParams($module_id = 0)
 {
     $module_id = $module_id ? $module_id : self::$module_id;
     if (!isset(self::$params[$module_id])) {
         jimport('joomla.registry.registry');
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         $query->select('params')->from('#__modules')->where('id=' . (int) $module_id);
         $db->setQuery($query);
         try {
             $params_str = $db->loadResult();
         } catch (RuntimeException $e) {
             $params_str = null;
             if (defined('PWEBCONTACT_DEBUG') and PWEBCONTACT_DEBUG) {
                 self::setLog('Database query error: ' . $e->getMessage());
             }
         }
         $params = new JRegistry($params_str);
         $params->def('id', (int) $module_id);
         self::$params[$module_id] = $params;
         if (!self::$module_id and $module_id) {
             self::$module_id = $module_id;
         }
     }
     return self::$params[$module_id];
 }
 /**
  * Constructor.
  *
  * @param   JRegistry    $options  Google options object
  * @param   JGoogleAuth  $auth     Google data http client object
  *
  * @since   1234
  */
 public function __construct(JRegistry $options = null, JGoogleAuth $auth = null)
 {
     // Setup the default API url if not already set.
     $options->def('api.url', 'https://www.googleapis.com/plus/v1/');
     parent::__construct($options, $auth);
     if (isset($this->auth) && !$this->auth->getOption('scope')) {
         $this->auth->setOption('scope', 'https://www.googleapis.com/auth/plus.me');
     }
 }
Example #9
0
 /**
  * Constructor.
  *
  * @param   JOpenstreetmapOauth  $oauth    Openstreetmap oauth client
  * @param   JRegistry            $options  Openstreetmap options object
  * @param   JHttp                $client   The HTTP client object
  *
  * @since   13.1
  */
 public function __construct(JOpenstreetmapOauth $oauth = null, JRegistry $options = null, JHttp $client = null)
 {
     $this->oauth = $oauth;
     $this->options = isset($options) ? $options : new JRegistry();
     $this->client = isset($client) ? $client : new JHttp($this->options);
     // Setup the default API url if not already set.
     $this->options->def('api.url', 'http://api.openstreetmap.org/api/0.6/');
     // $this->options->def('api.url', 'http://api06.dev.openstreetmap.org/api/0.6/');
 }
Example #10
0
 public function __construct($config = array())
 {
     //Change the column_name1,2,3 to the column names you want sortable
     $config['filter_fields'] = array('column_name_1', 'column_name_2', 'column_name_3');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin("socialpromoter", "stilerospflickr", false);
     $className = 'plgSocialpromoter' . ucfirst('Stilerospflickr');
     $pluginClass = new $className($dispatcher, array());
     $plg = JPluginHelper::getPlugin('socialpromoter', 'stilerospflickr');
     $plg_params = new JRegistry();
     $plg_params->loadString($plg->params);
     $this->api_key = $plg_params->def('api_key');
     $this->api_secret = $plg_params->def('api_secret');
     $this->auth_token = $plg_params->def('auth_token');
     $this->Flickr = new StileroFlickr($this->api_key, $this->api_secret);
     $this->Flickr->setAccessToken($this->auth_token);
     $this->Flickr->init();
     parent::__construct($config);
 }
Example #11
0
 /**
  * Sets up the page title
  *
  * @param   \JRegistry  $params
  * @param   string      $default
  *
  * @return  string  The document title, for use e.g. in RSS feeds.
  */
 public static function setTitleAndMeta(&$params, $default = '')
 {
     $document = \JFactory::getDocument();
     /** @var \JApplicationSite $app */
     $app = \JFactory::getApplication();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $title = null;
     // Set the default value for page_heading
     if ($menu) {
         $params->def('page_heading', $params->get('page_title', $menu->title));
     } else {
         $params->def('page_heading', JText::_($default));
     }
     // Set the document title
     $title = $params->get('page_title', '');
     $sitename = $app->get('sitename');
     if ($title == $sitename) {
         $title = JText::_($default);
     }
     if (empty($title)) {
         $title = $sitename;
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
     }
     $document->setTitle($title);
     // Set meta
     if ($params->get('menu-meta_description')) {
         $document->setDescription($params->get('menu-meta_description'));
     }
     if ($params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $params->get('menu-meta_keywords'));
     }
     if ($params->get('robots')) {
         $document->setMetadata('robots', $params->get('robots'));
     }
     return $title;
 }
Example #12
0
 function setupAuthentication()
 {
     $options = new JRegistry();
     $options->def('accessTokenURL', 'https://api.login.yahoo.com/oauth/v2/get_token');
     $options->def('authenticateURL', 'https://api.login.yahoo.com/oauth/v2/request_auth');
     $options->def('authoriseURL', 'https://api.login.yahoo.com/oauth/v2/request_auth');
     $options->def('requestTokenURL', 'https://api.login.yahoo.com/oauth/v2/get_request_token');
     $options->set('consumer_key', $this->appId);
     $options->set('consumer_secret', $this->secretKey);
     $options->set('callback', JURI::base() . 'index.php?option=com_jfbconnect&task=authenticate.callback&provider=yahoo&state=' . JSession::getFormToken());
     $options->set('sendheaders', true);
     // Enabled for now. Should probably switch to force the redirect so we can just detect if user is logged in
     $headers = array();
     $headers['Content-Type'] = 'application/xml';
     $options->set('headers', $headers);
     $this->client = new JFBConnectProviderYahooOauth1($options);
     $token = JFactory::getApplication()->getUserState('com_jfbconnect.' . strtolower($this->name) . '.token', null);
     if ($token) {
         $token = (array) json_decode($token);
         $this->client->setToken($token);
     }
 }
Example #13
0
 /**
  * Prepares the document
  */
 protected function _prepareDocument()
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $title = null;
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     }
     $title = $this->params->get('page_title', '');
     // checks for empty title or sets the folder description if
     // the current menu item is not the event view. This avoids
     // having the title of them menu item on all sub events
     if (empty($title) || isset($menu->query['view']) && strcmp($menu->query['view'], 'event') != 0) {
         $title = $this->folder->getDisplayName();
     }
     // Check for empty title and add site name if param is set
     if (empty($title)) {
         $title = $app->getCfg('sitename');
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
     }
     if (empty($title)) {
         $title = $this->folder->getDisplayName();
     }
     $this->document->setTitle($title);
     $description = $this->params->get('menu-meta_description');
     if (empty($description)) {
         $description = $this->folder->getMetadata()->get('metadesc');
     }
     // set the text of the folder as description if the meta desc is not set
     // or the menu item does not link to a single event
     if (empty($description) || isset($menu->query['view']) && strcmp($menu->query['view'], 'event') != 0) {
         $description = strip_tags($this->folder->getText());
     }
     $this->document->setDescription($description);
     $keys = $this->folder->getMetadata()->get('metakey');
     if ($this->params->get('menu-meta_keywords')) {
         $keys = $this->params->get('menu-meta_keywords');
     }
     $this->document->setMetadata('keywords', $keys);
     if ($this->params->get('robots')) {
         $this->document->setMetadata('robots', $this->params->get('robots'));
     }
     $this->document->setMetadata('fragment', '!');
 }
Example #14
0
 /**
  * Prepares the document
  */
 protected function _prepareDocument()
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $title = null;
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     }
     $title = $this->params->get('page_title', '');
     if ($this->folder->getDisplayName()) {
         $title = $this->folder->getDisplayName();
     }
     $title .= " - " . $this->position . ' / ' . $this->folder->getFileCount();
     // Check for empty title and add site name if param is set
     if (empty($title)) {
         $title = $app->getCfg('sitename');
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
     }
     if (empty($title)) {
         $title = $this->folder->getDisplayName();
     }
     if ($this->document) {
         $description = $this->folder->getMetadata()->get('metadesc');
         if (!empty($description)) {
             $this->document->setDescription($description);
         } elseif ($this->folder->getText()) {
             $this->document->setDescription(strip_tags($this->folder->getText()));
         } elseif (!$this->folder->getText() && $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'));
         } else {
             $this->document->setMetadata('keywords', $this->folder->getMetadata()->get('metakey'));
         }
         if ($this->params->get('robots')) {
             $this->document->setMetadata('robots', $this->params->get('robots'));
         }
         $this->document->setTitle($title);
         $this->document->setMetadata('fragment', '!');
     }
 }
Example #15
0
	public function testDef()
	{
		$a = new JRegistry();

		$this->assertThat(
			$a->def('foo', 'bar'),
			$this->equalTo('bar'),
			'Line: '.__LINE__.'. def should return default value'
		);

		$this->assertThat(
			$a->get('foo'),
			$this->equalTo('bar'),
			'Line: '.__LINE__.'. default should now be the current value'
		);
	}
Example #16
0
 /**
  * Method to set a default parameter if it does not exist
  *
  * @param   string  $key    Parameter key
  * @param   mixed   $value  Parameter value
  *
  * @return  mixed  Set parameter value
  *
  * @since   11.1
  */
 public function defParam($key, $value)
 {
     return $this->_params->def($key, $value);
 }
    $document->addScriptDeclaration('
      dojo.addOnLoad(function() {
        if (window.Skinchanger) window.skin = new Skinchanger({theme: "' . $params->get('theme', 'default') . '",skins: ' . json_encode($sks) . '});
      });
    ');
    if (isset($_REQUEST['skin']) && $skins->{$_REQUEST['skin']}) {
        $skin = $skins->{$_REQUEST['skin']}[0];
        foreach ($skin as $s) {
            $name = $s->getName();
            $value = (string) $s;
            $params->set($name, $value);
        }
        $_SESSION[$module->module . "_params"] = $params->toString();
    }
}
$params->def('theme', 'elegant');
$theme = $params->get('theme', 'elegant');
if (is_object($theme)) {
    //For 1.6, 1.7, 2.5
    $params->merge(new JRegistry($params->get('theme')));
    $params->set('theme', $theme->theme);
    $theme = $params->get('theme');
}
$searchresultwidth = $params->get('resultareawidth', 250);
$dynamicresult = $params->get('dynamicresult', 0);
$productimageheight = $params->get('productimageheight', 40);
$productsperplugin = $params->get('itemsperplugin', 3);
$minchars = $params->get('minchars', 2);
$resultalign = $params->get('resultalign', 0);
// 0-left 1-right
$scrolling = $params->get('scrolling', 1);
Example #18
0
 /**
  * Loads the correct Ldap configuration based on the record ID specified. Then uses
  * this configuration to instantiate an SHLdap client.
  *
  * @param   integer|string  $id        Configuration record ID. If blank, then returns all configs.
  * @param   JRegistry       $registry  Platform configuration.
  * @param   string          $source    Parameter source such as CONFIG_AUTO, CONFIG_SQL, CONFIG_FILE or CONFIG_PLUGIN.
  *
  * @return  false|JRegistry  Registry of parameters for Ldap or False on error.
  *
  * @since   2.0
  * @throws  InvalidArgumentException
  * @throws  RuntimeException
  */
 public static function getConfig($id = null, JRegistry $registry = null, $source = self::CONFIG_AUTO)
 {
     // Get the platform registry config from the factory if required
     $registry = is_null($registry) ? SHFactory::getConfig() : $registry;
     // If automatic configuration is specified; get the pre-configured source form registry
     if ($source === self::CONFIG_AUTO) {
         // Get the Ldap configuration source (e.g. sql | plugin | file)
         $source = (int) $registry->get('ldap.config', self::CONFIG_SQL);
     }
     if ($source === self::CONFIG_SQL) {
         // Get the database table using sh_ldap_config as default
         $table = $registry->get('ldap.table', '#__sh_ldap_config');
         // Get the global JDatabase object
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         // Check if we should return an array of configs
         if (empty($id)) {
             // Get all the enabled Ldap configurations from SQL
             $query->select($db->quoteName('name'))->select($db->quoteName('params'))->select($db->quoteName('user_params'))->select($db->quoteName('group_params'))->from($db->quoteName($table))->where($db->quoteName('enabled') . ' >= ' . $db->quote('1'))->order($db->quoteName('ordering'));
             // Execute the query
             if ($rows = $db->setQuery($query)->loadAssocList()) {
                 $configs = array();
                 // Push each found set of params into a registry
                 foreach ($rows as $row) {
                     $newConfig = new JRegistry();
                     $newConfig->loadString($row['params'], 'JSON');
                     // Inject the domain ID into the config
                     $newConfig->set('domain', $row['name']);
                     // Inject the user_params and group_params
                     $newConfig->set('user_params', $row['user_params']);
                     $newConfig->set('group_params', $row['group_params']);
                     // Push the Ldap config onto the return array
                     $configs[] = $newConfig;
                 }
                 return $configs;
             } else {
                 // No results found
                 throw new InvalidArgumentException(JText::_('LIB_SHLDAPHELPER_ERR_10604'), 10604);
             }
         } elseif (is_numeric($id)) {
             // Get the enabled configuration of the specified ID
             $query->select($db->quoteName('name'))->select($db->quoteName('params'))->select($db->quoteName('user_params'))->select($db->quoteName('group_params'))->from($db->quoteName($table))->where($db->quoteName('enabled') . ' >= ' . $db->quote('1'))->where($db->quoteName('id') . ' = ' . $db->quote((int) $id));
             // Execute the query
             if ($row = $db->setQuery($query)->loadAssoc()) {
                 $config = new JRegistry();
                 $config->loadString($row['params'], 'JSON');
                 // Inject the domain ID into the config
                 $config->set('domain', $row['name']);
                 // Inject the user_params and group_params
                 $config->set('user_params', $row['user_params']);
                 $config->set('group_params', $row['group_params']);
                 // Return our configuration result
                 return $config;
             } else {
                 // No result found
                 throw new InvalidArgumentException(JText::sprintf('LIB_SHLDAPHELPER_ERR_10605', $id), 10605);
             }
         } else {
             // Get the enabled configuration of the specified name
             $query->select($db->quoteName('params'))->select($db->quoteName('user_params'))->select($db->quoteName('group_params'))->from($db->quoteName($table))->where($db->quoteName('enabled') . ' >= ' . $db->quote('1'))->where($db->quoteName('name') . ' = ' . $db->quote((string) $id));
             // Execute the query
             if ($row = $db->setQuery($query)->loadAssoc()) {
                 $config = new JRegistry();
                 $config->loadString($row['params'], 'JSON');
                 // Inject the domain ID into the config
                 $config->set('domain', (string) $id);
                 // Inject the user_params and group_params
                 $config->set('user_params', $row['user_params']);
                 $config->set('group_params', $row['group_params']);
                 // Return our configuration result
                 return $config;
             } else {
                 // No result found
                 throw new InvalidArgumentException(JText::sprintf('LIB_SHLDAPHELPER_ERR_10606', $id), 10606);
             }
         }
     } elseif ($source === self::CONFIG_PLUGIN) {
         // Grab the plug-in name from the registry
         $name = empty($id) ? $registry->get('ldap.plugin', 'ldap') : $id;
         if ($plugin = JPluginHelper::getPlugin('authentication', $name)) {
             // Get the authentication LDAP plug-in parameters
             $params = new JRegistry();
             $params->loadString($plugin->params);
             /*
              * We may have to convert the parameters from the plugin so they can be
              * accepted into the SHLdap library. This is normally if we are using the
              * JLDAP parameters.
              */
             $converted = self::convertConfig($params, 'SHLdap');
             // Reload the converted parameters into a registry before returning
             $config = new JRegistry();
             $config->loadArray($converted);
             return $config;
         } else {
             // Invalid plugin
             throw new InvalidArgumentException(JText::sprintf('LIB_SHLDAPHELPER_ERR_10603', $name), 10603);
         }
     } elseif ($source === self::CONFIG_FILE) {
         // Define some default variables
         $namespace = '';
         $position = 0;
         $fileInc = false;
         // Grab the LDAP configuration file path from the registry and include it
         if ($file = $registry->get('ldap.file', JPATH_CONFIGURATION . '/ldap.php')) {
             $fileInc = @(include_once $file);
         }
         // Lets find all classes in the LDAP configuration file
         $classes = array_values(preg_grep('/(' . self::CONFIG_PREFIX . '){1}\\w*/i', get_declared_classes()));
         if (empty($classes)) {
             $fileInc = $fileInc ? JText::_('LIB_SHLDAPHELPER_INFO_10624') : JText::_('LIB_SHLDAPHELPER_INFO_10625');
             // Either file not lopaded or file has no valid classes
             throw new RuntimeException(JText::sprintf('LIB_SHLDAPHELPER_ERR_10623', $id, $fileInc), 10623);
         }
         $namespaces = $classes;
         // Retrieve the namespaces from the classes
         foreach ($namespaces as &$namespace) {
             $namespace = strtolower(str_ireplace(self::CONFIG_PREFIX, '', $namespace));
         }
         if (is_null($id)) {
             if (count($namespaces) === 1) {
                 // We will use a single namespace here
                 $nsKeys = array(0);
             } elseif (count($namespaces) > 1) {
                 // We will return an array of configs
                 $nsKeys = array_keys($namespaces);
             }
         } else {
             if (is_numeric($id)) {
                 // Need to treat the ID as a position - check if it exists
                 if (isset($namespaces[$id])) {
                     $nsKeys = array($id);
                 } else {
                     // Unable to load the file namespace specified
                     throw new InvalidArgumentException(JText::sprintf('LIB_SHLDAPHELPER_ERR_10609', $id), 10609);
                 }
             } elseif (is_string($id)) {
                 $key = array_search(strtolower($id), $namespaces, false);
                 if ($key !== false) {
                     $nsKeys = array($key);
                 } else {
                     // Unable to load the file namespace specified
                     throw new InvalidArgumentException(JText::sprintf('LIB_SHLDAPHELPER_ERR_10609', $id), 10609);
                 }
             } else {
                 // Invalid id argument
                 throw new InvalidArgumentException(JText::_('LIB_SHLDAPHELPER_ERR_10610'), 10610);
             }
         }
         $configs = array();
         // We need to instantiate the config classes from the file and store them in the configs
         foreach ($nsKeys as $nsKey) {
             $class = $classes[$nsKey];
             $config = new JRegistry();
             // Create the JConfig object
             $params = new $class();
             // Load the configuration values into the registry
             $config->loadObject($params);
             // Inject the domain ID into the config
             $config->def('domain', empty($namespaces[$nsKey]) ? 'default' : $namespaces[$nsKey]);
             $hostParams = array();
             $userParams = array();
             $groupParams = array();
             foreach ($config->toArray() as $key => $value) {
                 if (substr($key, 0, 5) == 'user_') {
                     $userParams[$key] = $value;
                 } elseif (substr($key, 0, 6) == 'group_') {
                     $groupParams[$key] = $value;
                 } else {
                     $hostParams[$key] = $value;
                 }
             }
             $config = new JRegistry($hostParams);
             // Inject the user_params and group_params
             $config->set('user_params', json_encode($userParams));
             $config->set('group_params', json_encode($groupParams));
             if (isset($userParams['user_qry'])) {
                 // Backwards compatibility with 2.0
                 $config->set('user_qry', $userParams['user_qry']);
             }
             $configs[] = $config;
         }
         // We only return an array when the ID is null
         return !is_null($id) ? $configs[0] : $configs;
     } else {
         // Invalid source
         throw new InvalidArgumentException(JText::_('LIB_SHLDAPHELPER_ERR_10601'), 10601);
     }
     // Failed to find a valid config
     return false;
 }
Example #19
0
 /**
  * Method to load content article parameters
  *
  * @access	private
  * @return	void
  * @since	1.5
  */
 function _loadItemParams($force = false)
 {
     if (!$force && !empty($this->_item->parameters)) {
         return;
     }
     $app = JFactory::getApplication();
     $menu = $app->getMenu()->getActive();
     // Retrieve currently active menu item (NOTE: this applies when Itemid variable or menu item alias exists in the URL)
     $isnew = !$this->_id;
     // **********************************************************************
     // Retrieve RELATED parameters that will be merged into item's parameters
     // **********************************************************************
     // Retrieve COMPONENT parameters
     $compParams = JComponentHelper::getComponent('com_flexicontent')->params;
     // Retrieve parameters of current category (NOTE: this applies when cid variable exists in the URL)
     $catParams = "";
     if ($this->_cid) {
         $query = 'SELECT c.title, c.params FROM #__categories AS c WHERE c.id = ' . (int) $this->_cid;
         $this->_db->setQuery($query);
         $catData = $this->_db->loadObject();
         $catParams = $catData->params;
         $this->_item->category_title = $catData->title;
     }
     $catParams = new JRegistry($catParams);
     // Retrieve/Create item's Content Type parameters
     $typeParams = $this->getTypeparams();
     $typeParams = new JRegistry($typeParams);
     // Create item parameters
     if (!is_object($this->_item->attribs)) {
         $itemParams = new JRegistry($this->_item->attribs);
     } else {
         $itemParams = $this->_item->attribs;
     }
     // Retrieve Layout's parameters, also deciding the layout
     $this->decideLayout($compParams, $typeParams, $itemParams);
     $layoutParams = $this->getLayoutparams();
     $layoutParams = new JRegistry($layoutParams);
     //print_r($layoutParams);
     // ***************************************************************************************************
     // Merge parameters in order: component, menu, (item 's) current category, (item's) content type, item
     // ***************************************************************************************************
     // a. Start with empty registry, then merge COMPONENT parameters
     $params = new JRegistry();
     $params->merge($compParams);
     // b. Merge parameters from current category
     $catParams->set('show_title', '');
     // Prevent show_title from propagating ... to the item, it is meant for category view only
     $catParams->set('title_linkable', '');
     // Prevent title_linkable from propagating ... to the item, it is meant for category view only
     $catParams->set('show_editbutton', '');
     // Prevent title_linkable from propagating ... to the item, it is meant for category view only
     $params->merge($catParams);
     // c0. Merge Layout parameters into the page configuration
     $params->merge($layoutParams);
     // c1. Merge TYPE parameters into the page configuration
     $params->merge($typeParams);
     // d. Merge ITEM parameters into the page configuration
     $params->merge($itemParams);
     // e. Merge ACCESS permissions into the page configuration
     $accessperms = $this->getItemAccess();
     $params->merge($accessperms);
     // d. Merge the active menu parameters, verify menu item points to current FLEXIcontent object
     if ($menu && !empty($this->mergeMenuParams)) {
         if (!empty($this->isForm)) {
             $this->menu_matches = false;
             $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view'];
             $this->menu_matches = $view_ok;
         } else {
             $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view'];
             $cid_ok = JRequest::getInt('cid') == (int) @$menu->query['cid'];
             $id_ok = JRequest::getInt('id') == (int) @$menu->query['id'];
             $this->menu_matches = $view_ok && $id_ok;
         }
     } else {
         $this->menu_matches = false;
     }
     // MENU ITEM matched, merge parameters and use its page heading (but use menu title if the former is not set)
     if ($this->menu_matches) {
         $params->merge($menu->params);
         $default_heading = $menu->title;
         // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->def('page_heading', $params->get('page_title', $default_heading));
         $params->def('page_title', $params->get('page_heading', $default_heading));
         $params->def('show_page_heading', $params->get('show_page_title', 0));
         $params->def('show_page_title', $params->get('show_page_heading', 0));
     } else {
         // Clear some menu parameters
         //$params->set('pageclass_sfx',	'');  // CSS class SUFFIX is behavior, so do not clear it ?
         // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ...
         $default_heading = empty($this->isForm) ? $this->_item->title : (!$isnew ? JText::_('FLEXI_EDIT') : JText::_('FLEXI_NEW'));
         // Decide to show page heading (=J1.5 page title), there is no need for this in item view
         $show_default_heading = 0;
         // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template)
         $params->set('page_title', $default_heading);
         $params->set('page_heading', $default_heading);
         $params->set('show_page_heading', $show_default_heading);
         $params->set('show_page_title', $show_default_heading);
     }
     // Prevent showing the page heading if (a) IT IS same as item title and (b) item title is already configured to be shown
     if ($params->get('show_title', 1)) {
         if ($params->get('page_heading') == $this->_item->title) {
             $params->set('show_page_heading', 0);
         }
         if ($params->get('page_title') == $this->_item->title) {
             $params->set('show_page_title', 0);
         }
     }
     // Also convert metadata property string to parameters object
     if (!empty($this->_item->metadata)) {
         $this->_item->metadata = new JRegistry($this->_item->metadata);
     } else {
         $this->_item->metadata = new JRegistry();
     }
     // *********************************************
     // Finally set 'parameters' property of the item
     // *********************************************
     $this->_item->parameters = $params;
 }
Example #20
0
 /**
  *
  * @return \CParserMetas
  */
 protected function _parseHead($content)
 {
     preg_match('/<head[^>]*>.*<\\/head>/is', $content, $head);
     $head = count($head) > 0 ? $head[0] : '';
     // get title
     preg_match('/<title[^>]*>(.*)<\\/title>/is', $head, $title);
     if (count($title) > 1) {
         $this->_extracted->def('title', utf8_encode($title[1]));
     }
     // get metas
     preg_match_all('/<meta[^>]*>/is', $head, $metas);
     if (count($metas) > 0) {
         $metas = $metas[0];
         // parse metas
         for ($i = 0, $len = count($metas); $i < $len; $i++) {
             preg_match_all('/\\s([a-z-]+)\\s*=\\s*["\']([^"\']+)["\']/is', $metas[$i], $matches);
             if (count($matches[1]) > 0) {
                 $meta = array();
                 for ($j = 0, $mlen = count($matches[1]); $j < $mlen; $j++) {
                     $meta[strtolower($matches[1][$j])] = utf8_encode($matches[2][$j]);
                 }
                 $metas[$i] = $meta;
             } else {
                 unset($metas[$i]);
             }
         }
         // assign metas
         foreach ($metas as $meta) {
             if (isset($meta['property'])) {
                 if ($meta['property'] == 'og:image') {
                     $this->_addArray('image', $meta['content']);
                 } else {
                     if ($meta['property'] == 'og:title') {
                         $this->_add('title', $meta['content']);
                     } else {
                         if ($meta['property'] == 'og:description') {
                             $this->_add('description', $meta['content']);
                         } else {
                             $this->_add($meta['property'], $meta['content']);
                         }
                     }
                 }
             } else {
                 if (isset($meta['name'])) {
                     if (isset($meta['content'])) {
                         $this->_add($meta['name'], $meta['content']);
                     } else {
                         if (isset($meta['value'])) {
                             $this->_add($meta['name'], $meta['value']);
                         }
                     }
                 } else {
                     if (isset($meta['http-equiv'])) {
                         $this->_add($meta['http-equiv'], $meta['content']);
                     } else {
                         if (isset($meta['itemprop'])) {
                             if ($meta['itemprop'] == 'image') {
                                 $this->_addArray('image', $meta['content']);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $this;
 }
Example #21
0
	/**
	 * Categories Search method
	 *
	 * The sql must return the following fields that are
	 * used in a common display routine: href, title, section, created, text,
	 * browsernav
	 * @param string Target search string
	 * @param string mathcing option, exact|any|all
	 * @param string ordering option, newest|oldest|popular|alpha|category
	 * @param mixed An array if restricted to areas, null if search all
	 */
	function onContentSearch($text, $phrase='', $ordering='', $areas=null)
	{
		$db     = JFactory::getDBO();
		$app    = JFactory::getApplication();
		$user   = JFactory::getUser();
		$groups = implode(',', $user->getAuthorisedViewLevels());
		$tag    = JFactory::getLanguage()->getTag();

		require_once(JPATH_SITE.'/components/com_jem/helpers/route.php');

		if (is_array($areas)) {
			if (!array_intersect($areas, array_keys(self::$_areas))) {
				return array();
			}
		} else {
			$areas = array_keys(self::$_areas);
		}

		// load plugin params info
		$plugin = JPluginHelper::getPlugin('search', 'jem');
		$pluginParams = new JRegistry($plugin->params);

		$limit = $pluginParams->def('search_limit', 50);

		$text = trim($text);
		if ($text == '') {
			return array();
		}

		$searchJEM = $db->Quote(JText::_('PLG_JEM_SEARCH_JEM'));

		$rows  = array();
		$query = $db->getQuery(true);

		if (in_array('jemevents', $areas) && $limit > 0) {
			$areaName = JText::_(self::$_areas['jemevents']);

			switch ($phrase) {
				case 'exact':
					$text_q		= $db->Quote('%'.$db->escape($text, true).'%', false);
					$wheres2 	= array();
					$wheres2[] 	= 'LOWER(a.title) LIKE '.$text_q;
					$wheres2[]	= 'LOWER(a.introtext) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(a.fulltext) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(a.meta_keywords) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(a.meta_description) LIKE '.$text_q;
					$where 		= '(' . implode(') OR (', $wheres2) . ')';
					break;

				case 'all':
				case 'any':
				default:
					$words = explode(' ', $text);
					$wheres = array();
					foreach ($words as $word) {
						$word 		= $db->Quote('%'.$db->escape( $word, true ).'%', false);
						$wheres2 	= array();
						$wheres2[] 	= 'LOWER(a.title) LIKE '.$word;
						$wheres2[]	= 'LOWER(a.introtext) LIKE '.$word;
						$wheres2[] 	= 'LOWER(a.fulltext) LIKE '.$word;
						$wheres2[] 	= 'LOWER(a.meta_keywords) LIKE '.$word;
						$wheres2[] 	= 'LOWER(a.meta_description) LIKE '.$word;
						$wheres[] 	= implode(' OR ', $wheres2);
					}
					$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
					break;
			}

			switch ($ordering) {
				case 'oldest':
					$order = 'a.dates ASC, a.times ASC';
					break;

				case 'alpha':
					$order = 'a.title ASC';
					break;

				case 'category':
					$order = 'c.catname ASC, a.title ASC';
					break;

				case 'newest':
				default:
					$order = 'a.dates DESC, a.times DESC';
			}

			$query->clear();
			//sqlsrv changes
			$case_when = ' CASE WHEN ';
			$case_when .= $query->charLength('a.alias');
			$case_when .= ' THEN ';
			$a_id = $query->castAsChar('a.id');
			$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
			$case_when .= ' ELSE ';
			$case_when .= $a_id.' END as slug';

	 		$case_when1 = ' CASE WHEN ';
	 		$case_when1 .= $query->charLength('c.alias');
	 		$case_when1 .= ' THEN ';
	 		$c_id = $query->castAsChar('c.id');
	  		$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':');
	 		$case_when1 .= ' ELSE ';
			$case_when1 .= $c_id.' END as catslug';

			$query->select('a.title AS title, a.meta_description, a.meta_keywords, a.created AS created');
			$query->select($query->concatenate(array('a.introtext', 'a.fulltext')).' AS text');
			$query->select($query->concatenate(array($db->quote($areaName), 'c.catname'), ' / ').' AS section');
			$query->select($case_when.','.$case_when1.', '.'\'2\' AS browsernav');
			$query->select('rel.catid');

			$query->from('#__jem_events AS a');
			$query->join('LEFT', '#__jem_cats_event_relations AS rel ON rel.itemid = a.id');
			$query->join('LEFT', '#__jem_categories AS c ON c.id = rel.catid');
			$query->where('('. $where .')' . ' AND a.published=1 AND c.published = 1 AND a.access IN ('.$groups.') '
			             .'AND c.access IN ('.$groups.') '
			             );
			$query->group('a.id');
			$query->order($order);

			$db->setQuery($query, 0, $limit);
			$list = $db->loadObjectList();
			$limit -= count($list);

			if (isset($list))
			{
				foreach($list as $key => $row)
				{
					$list[$key]->href = JEMHelperRoute::getEventRoute($row->slug);

					// todo: list ALL accessable categories
					// todo: show date/time somewhere because this is very useful information
				}
			}

			$rows[] = $list;
		}

		if (in_array('jemvenues', $areas) && $limit > 0) {
			$areaName = JText::_(self::$_areas['jemvenues']);

			switch ($phrase) {
				case 'exact':
					$text_q		= $db->Quote('%'.$db->escape($text, true).'%', false);
					$wheres2 	= array();
					$wheres2[] 	= 'LOWER(venue) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(locdescription) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(city) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(meta_keywords) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(meta_description) LIKE '.$text_q;
					$where 		= '(' . implode(') OR (', $wheres2) . ')';
					break;

				case 'all':
				case 'any':
				default:
					$words = explode(' ', $text);
					$wheres = array();
					foreach ($words as $word) {
						$word 		= $db->Quote('%'.$db->escape( $word, true ).'%', false);
						$wheres2 	= array();
						$wheres2[] 	= 'LOWER(venue) LIKE '.$word;
						$wheres2[] 	= 'LOWER(locdescription) LIKE '.$word;
						$wheres2[] 	= 'LOWER(city) LIKE '.$word;
						$wheres2[] 	= 'LOWER(meta_keywords) LIKE '.$word;
						$wheres2[] 	= 'LOWER(meta_description) LIKE '.$word;
						$wheres[] 	= implode(' OR ', $wheres2);
					}
					$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
					break;
			}

			switch ($ordering) {
				case 'oldest':
					$order = 'created DESC';
					break;

				case 'alpha':
					$order = 'venue ASC';
					break;

				case 'newest':
					$order = 'created ASC';
					break;

				default:
					$order = 'venue ASC';
			}

			$query = 'SELECT venue AS title,'
			       . ' locdescription AS text,'
			       . ' created,'
			       . ' "2" AS browsernav,'
			       . ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug, '
			       . ' '.$db->quote($areaName).' AS section'
			       . ' FROM #__jem_venues'
			       . ' WHERE ( '.$where.')'
			       . ' AND published = 1'
			       . ' ORDER BY '. $order
			       ;
			$db->setQuery($query, 0, $limit);
			$list2 = $db->loadObjectList();

			foreach((array) $list2 as $key => $row) {
				$list2[$key]->href = JEMHelperRoute::getVenueRoute($row->slug);
			}

			$rows[] = $list2;
		}

		if (in_array('jemcategories', $areas) && $limit > 0) {
			$areaName = JText::_(self::$_areas['jemcategories']);

			switch ($phrase) {
				case 'exact':
					$text_q		= $db->Quote('%'.$db->escape($text, true).'%', false);
					$wheres2 	= array();
					$wheres2[] 	= 'LOWER(catname) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(description) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(meta_keywords) LIKE '.$text_q;
					$wheres2[] 	= 'LOWER(meta_description) LIKE '.$text_q;
					$where 		= '(' . implode(') OR (', $wheres2) . ')';
					break;

				case 'all':
				case 'any':
				default:
					$words = explode(' ', $text);
					$wheres = array();
					foreach ($words as $word) {
						$word 		= $db->Quote('%'.$db->escape($word, true).'%', false);
						$wheres2 	= array();
						$wheres2[] 	= 'LOWER(catname) LIKE '.$word;
						$wheres2[] 	= 'LOWER(description) LIKE '.$word;
						$wheres2[] 	= 'LOWER(meta_keywords) LIKE '.$word;
						$wheres2[] 	= 'LOWER(meta_description) LIKE '.$word;
						$wheres[] 	= implode(' OR ', $wheres2);
					}
					$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
					break;
			}

			$query = 'SELECT catname AS title,'
			       . ' description AS text,'
			       . ' "" AS created,'
			       . ' "2" AS browsernav,'
			       . ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug, '
			       . ' '.$db->quote($areaName).' AS section'
			       . ' FROM #__jem_categories'
			       . ' WHERE ( '.$where.' )'
			       . ' AND published = 1'
			       . ' AND access IN ('.$groups.') '
			       . ' ORDER BY catname'
			       ;
			$db->setQuery($query, 0, $limit);
			$list3 = $db->loadObjectList();

			foreach((array)$list3 as $key => $row) {
				$list3[$key]->href = JEMHelperRoute::getCategoryRoute($row->slug);
			}

			$rows[] = $list3;
		}

		$count = count($rows);
		if ($count > 1) {
			switch ($count) {
				case 2:
					$results = array_merge((array)$rows[0], (array)$rows[1]);
					break;

				case 3:
					$results = array_merge((array)$rows[0], (array)$rows[1], (array)$rows[2]);
					break;

				case 4:
				default:
					$results = array_merge((array)$rows[0], (array)$rows[1], (array)$rows[2], (array)$rows[3]);
					break;
			}
			return $results;
		} else if ($count == 1) {
			return $rows[0];
		}
	}
Example #22
0
function viewlink_cache( $link, $limitstart, $fields, $params, $my, $option ) {
	global $savantConf, $Itemid, $mtconf;

	$database	=& JFactory::getDBO();
	$jdate		= JFactory::getDate();
	$now		= $jdate->toMySQL();
	$link_id	= $link->link_id;
	
	if ( !isset($link->link_id) || $link->link_id <= 0 ) {
		echo JText::_( 'NOT_EXIST' );
	} else {

		# Increase 1 hit
		$cookiename = "mtlink_hit$link->link_id";
		$visited = JRequest::getVar( $cookiename, '0', 'COOKIE', 'INT');
		
		if (!$visited) {
			$database->setQuery( "UPDATE #__mt_links SET link_hits=link_hits+1 WHERE link_id='".$link_id."'" );
			$database->query();
		}

		setcookie( $cookiename, '1', time()+$mtconf->get('hit_lag') );
	
		# Get reviews
		$database->setQuery( "SELECT COUNT(*) FROM #__mt_reviews AS r WHERE link_id = '".$link_id."' AND r.rev_approved = 1" );
		$total_reviews = $database->loadResult();
		
		$sql = "SELECT r.*, u.username, log.value AS rating FROM #__mt_reviews AS r"
			.	"\n LEFT JOIN #__users AS u ON u.id = r.user_id"
			.	"\n LEFT JOIN #__mt_log AS log ON log.user_id = r.user_id AND log.link_id = r.link_id AND log_type = 'vote' AND log.rev_id = r.rev_id"
			.	"\n WHERE r.link_id = '".$link_id."' AND r.rev_approved = 1 ";
		if( $mtconf->get('first_review_order1') != '' )
		{
			$sql .= "\n ORDER BY " . $mtconf->get('first_review_order1') . ' ' . $mtconf->get('first_review_order2') ;
			if( $mtconf->get('second_review_order1') != '' )
			{
				$sql .= ', ' . $mtconf->get('second_review_order1') . ' ' . $mtconf->get('second_review_order2');
				if( $mtconf->get('third_review_order1') != '' )
				{
					$sql .= ', ' . $mtconf->get('third_review_order1') . ' ' . $mtconf->get('third_review_order2');
				}
			}
		}
		$sql .= "\n LIMIT $limitstart, " . $mtconf->get('fe_num_of_reviews');
		$database->setQuery( $sql );
		$reviews = $database->loadObjectList();

		# Add <br /> to all new lines & gather an array of review_ids
		for( $i=0; $i<count($reviews); $i++ ) {
			$reviews[$i]->rev_text = nl2br(htmlspecialchars(trim($reviews[$i]->rev_text)));
			$reviews[$i]->ownersreply_text = nl2br(htmlspecialchars(trim($reviews[$i]->ownersreply_text)));
		}
		
		# If the user is logged in, get all voted rev_ids
		if( $my->id > 0 ) {
			$database->setQuery( 'SELECT value, rev_id FROM #__mt_log WHERE log_type = \'votereview\' AND user_id = \''.$my->id.'\' AND link_id = \''.$link_id.'\' LIMIT '.$total_reviews );
			$voted_reviews = $database->loadObjectList( 'rev_id' );
		} else {
			$voted_reviews = array();
		}
		# Get image ids
		$database->setQuery("SELECT img_id AS id, filename FROM #__mt_images WHERE link_id = '" . $link_id . "' ORDER BY ordering ASC");
		$images = $database->loadObjectList();
		
		# Page Navigation
		jimport('joomla.html.pagination');
		$pageNav = new JPagination($total_reviews, $limitstart, $mtconf->get('fe_num_of_reviews'));

		# Pathway
		$pathWay = new mtPathWay( $link->cat_id );

		# Mambots
		global $_MAMBOTS;
		$page = 0;

		# Load Parameters
		$params = new JRegistry( $link->attribs );
		$mtconf->set('show_rating',$params->def( 'show_rating', $mtconf->get('show_rating') ));
		$mtconf->set('show_review',$params->def( 'show_review', $mtconf->get('show_review') ));
		
		$savant = new Savant2($savantConf);
		assignCommonViewlinkVar( $savant, $link, $fields, $pathWay, $params );
		
		$savant->assign('pageNav', $pageNav);
		$savant->assign('my', $my);
		$savant->assign('reviews', $reviews);
		$savant->assign('images', $images);
		$savant->assign('voted_reviews', $voted_reviews);
		$savant->assign('total_reviews', ((isset($total_reviews)) ? $total_reviews : 0 ));
		$savant->assign('user_report_review',$mtconf->get('user_report_review'));
		
		if( $my->id > 0 && $mtconf->get('user_vote_review') == 1 ) {
			$savant->assign('show_review_voting', 1);
		} else {
			$savant->assign('show_review_voting', 0);
		}
		$savant->assign('user_report_review',$mtconf->get('user_report_review'));
		$savant->display( 'page_listing.tpl.php' );

	}
}
Example #23
0
 function getParams($component = true)
 {
     // we have to take clear JRegistry object to avoid overriding static component params
     $params = new JRegistry();
     // global params first
     $cparams = JComponentHelper::getParams('com_djmediatools');
     $params->merge($cparams);
     // override global params with menu params only for component view
     if ($component) {
         $app = JFactory::getApplication();
         $mparams = $app->getParams('com_djmediatools');
         //$mparams = clone($mparams);
         $params->merge($mparams);
     }
     // override global/menu params with category params
     $id = $this->getState('category.id');
     $category = $this->getItem($id);
     if ($category && $category != 'root') {
         $cparams = $category->params;
         $params->merge($cparams);
     }
     // set default values
     $params->def('blank', $params->get('blank', JURI::root(true) . '/components/com_djmediatools/assets/images/blank.gif'));
     return $params;
 }
Example #24
0
 static function rent_history($option)
 {
     global $database, $my, $Itemid, $booklibrary_configuration, $mainframe, $mosConfig_list_limit;
     PHP_booklibrary::addTitleAndMetaTags();
     //     $menu = new mosMenu($database);
     //     $menu->load( $Itemid );
     //     $params = new mosParameters( $menu->params );
     if (version_compare(JVERSION, '3.0', 'lt')) {
         $menu = new JTableMenu($database);
         // for 1.6
         $menu->load($Itemid);
         $params = new mosParameters($menu->params);
     } else {
         $menu = new JTableMenu($database);
         $menu->load($Itemid);
         $params = new JRegistry();
         $params->loadString($menu->params);
     }
     $database->setQuery("SELECT id FROM #__menu WHERE link='index.php?option=com_booklibrary'");
     if ($database->loadResult() != $Itemid) {
         $params->def('wrongitemid', '1');
     }
     if ($my->email == null) {
         echo "\n             <script type=\"text/JavaScript\" language = \"JavaScript\">\n                alert('You cannot view My Books that were not authorizated!');\n                window.history.go(-1);\n            </script>";
         exit;
     }
     $limit = $booklibrary_configuration['page']['items'];
     $limitstart = mosGetParam($_REQUEST, 'limitstart', 0);
     $database->setQuery("SELECT count(*) FROM #__booklibrary_lend AS l" . "\nLEFT JOIN #__booklibrary AS a ON a.id = l.   fk_bookid" . "\nWHERE l.fk_userid = '{$my->id}'");
     $total = $database->loadResult();
     echo $database->getErrorMsg();
     $pageNav = new JPagination($total, $limitstart, $limit);
     // for J 1.6
     $query = "SELECT l.*,a.* FROM #__booklibrary_lend AS l" . "\nLEFT JOIN #__booklibrary AS a ON a.id = l.   fk_bookid " . "\nWHERE l.fk_userid = '" . $my->id . "' LIMIT {$pageNav->limitstart},{$pageNav->limit};";
     $database->setQuery($query);
     $books = $database->loadObjectList();
     HTML_booklibrary::showRentHistory($option, $books, $pageNav, $params);
 }
Example #25
0
 /**
  * Plugin that returns the object list for DJ-Mediatools album
  * 
  * Each object must contain following properties (mandatory): title, description, image
  * Optional properties: link, target (_blank or _self), alt (alt attribute for image)
  * 
  * @param	object	The album params
  */
 public function onAlbumPrepare(&$source, &$params)
 {
     // Lets check the requirements
     $check = $this->onCheckRequirements($source);
     if (is_null($check) || is_string($check)) {
         return null;
     }
     $app = JFactory::getApplication();
     require_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php';
     Sobi::Initialise($params->get('section'));
     require_once dirname(__FILE__) . '/lib/emod.php';
     $emod = new SPEntriesDJMTCtrl();
     $default_image = $params->get('plg_sobipro_image');
     // create parameters for K2 content module helper
     $mparams = new JRegistry();
     $mparams->def('entriesLimit', $params->get('max_images'));
     $mparams->def('section', $params->get('section'));
     $mparams->def('cid', $params->get('cid'));
     $mparams->def('sid', $params->get('sid'));
     $mparams->def('autoListing', $params->get('plg_sobipro_autoListing'));
     $mparams->def('spOrder', $params->get('spOrder'));
     $mparams->def('spOrderDir', $params->get('spOrderDir'));
     $mparams->def('spLimit', $params->get('spLimit'));
     $mparams->def('engine', 'static');
     $items = $emod->getSourceEntries($mparams);
     $slides = array();
     //$this->debug($items);
     foreach ($items as $item) {
         $slide = (object) array();
         $slide->title = $item['name']['_data'];
         $slide->description = $item['fields']['field_short_description']['_data']['data']['_data'];
         $slide->image = $item['fields']['field_company_logo']['_data']['data']['_attributes']['image'];
         if (!$slide->image) {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($slide->description);
         }
         if (!$slide->image) {
             $slide->image = $default_image;
         }
         // if no default image set then don't display this entry
         if (!$slide->image) {
             continue;
         }
         $slide->id = $item->id;
         $slide->canonical = $slide->link = $item['url'];
         if ($comments = $params->get('commnets', 0)) {
             $host = str_replace(JURI::root(true), '', JURI::root());
             $host = preg_replace('/\\/$/', '', $host);
             switch ($comments) {
                 case 1:
                     // jcomments
                     $slide->comments = array('id' => $item->id, 'group' => 'com_sobipro');
                     break;
                 case 2:
                     // disqus
                     $disqus_shortname = $params->get('disqus_shortname', '');
                     if (!empty($disqus_shortname)) {
                         $slide->comments = array();
                         $slide->comments['url'] = $host . $slide->link;
                         $slide->comments['identifier'] = substr(md5($disqus_shortname), 0, 10) . "_id" . $item->id;
                     }
                     break;
                 case 3:
                     // facebook
                     $slide->comments = $host . $slide->link;
                     break;
                 case 4:
                     //komento
                     // not implemented
                     break;
             }
         }
         $slides[] = $slide;
     }
     return $slides;
 }
Example #26
0
 function update()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_sef/classes/config.php';
     $db = JFactory::getDBO();
     $jversion = new JVersion();
     // 20.8.2013 dajo: adapters don't need installation anymore, they're registered using our system plugin,
     //                 so remove them from older versions
     $path = JPATH_LIBRARIES . '/joomla/installer/adapters/sef_ext.php';
     if (JFile::exists($path)) {
         JFile::delete($path);
     }
     // Handle Joomla 3
     if ($jversion->isCompatible('3.0.0')) {
         $path = JPATH_LIBRARIES . '/cms/installer/adapter/sef_ext.php';
         if (JFile::exists($path)) {
             JFile::delete($path);
         }
     }
     $path = JPATH_LIBRARIES . '/joomla/updater/adapters/sef_update.php';
     if (JFile::exists($path)) {
         JFile::delete($path);
     }
     // Install JoomSEF plugins
     $this->installPlugins();
     JTable::addIncludePath(JPATH_LIBRARIES . '/joomla/database/table');
     $ext_update_dir = dirname(__FILE__) . '/site/sef_ext/';
     // Migrate existing extensions from old table
     $db = JFactory::getDBO();
     $query = "SELECT * FROM #__sefexts";
     $db->setQuery($query);
     $exts = $db->loadObjectList();
     // Delete extensions from old table, so they don't cause problems later
     $db->setQuery("DELETE FROM #__sefexts");
     $db->query();
     for ($i = 0; $i < count($exts); $i++) {
         $xml_file = JPATH_SITE . '/components/com_sef/sef_ext/' . $exts[$i]->file;
         if (file_exists($ext_update_dir . $exts[$i]->file)) {
             $xml_file = $ext_update_dir . $exts[$i]->file;
         }
         if (!file_exists($xml_file)) {
             // Extension not available
             continue;
         }
         $xml = simplexml_load_file($xml_file);
         $element = $this->getElement($xml);
         $query = "SELECT COUNT(*) FROM #__extensions WHERE type=" . $db->quote('sef_ext') . " AND element=" . $db->quote($element);
         $db->setQuery($query);
         $cnt = $db->loadResult();
         if ($cnt > 0) {
             continue;
         }
         $ext_table = JTable::getInstance('extension');
         $ext_table->name = (string) $xml->name;
         $ext_table->type = 'sef_ext';
         $ext_table->element = $element;
         $ext_table->enabled = 1;
         $ext_table->protected = 0;
         $ext_table->access = 1;
         $ext_table->client_id = 0;
         $params = new JRegistry($exts[$i]->params);
         $download_id = $params->get('downloadId');
         if (strlen($exts[$i]->title)) {
             $params->def('custom_menu_title', $exts[$i]->title);
         }
         $ext_table->params = $params->toString();
         $ext_table->custom_data = $exts[$i]->filters;
         $ext_table->manifest_cache = json_encode(JApplicationHelper::parseXMLInstallFile($xml_file));
         $ext_table->store();
         $query = "INSERT INTO #__schemas SET extension_id=" . $ext_table->extension_id . ", version_id=" . $db->quote((string) $xml->version);
         $db->setQuery($query);
         $db->query();
         if (isset($xml->updateservers->server)) {
             $location = (string) $xml->updateservers->server;
             if (isset($download_id) && strlen($download_id)) {
                 $location = str_replace('.xml', '-' . $download_id . '.xml', $location);
             }
             $query = "SELECT COUNT(*) FROM #__update_sites \n";
             $query .= "WHERE type=" . $db->quote((string) $xml->updateservers->server['type']) . " AND name=" . $db->quote((string) $xml->updateservers->server['name']);
             $db->setQuery($query);
             $cnt = $db->loadResult();
             if ($cnt) {
                 $query = "UPDATE #__update_sites SET location=" . $db->quote($location) . ", enabled=1 \n";
                 $query .= "WHERE type=" . $db->quote((string) $xml->updateservers->server['type']) . " AND name=" . $db->quote((string) $xml->updateservers->server['name']);
             } else {
                 $query = "INSERT INTO #__update_sites SET name=" . $db->quote((string) $xml->updateservers->server['name']) . ", type=" . $db->quote((string) $xml->updateservers->server['type']) . ", \n";
                 $query .= "location=" . $db->quote($location) . ", enabled=1 \n";
             }
             $db->setQuery($query);
             $db->query();
             $id = $db->insertId();
             $query = "SELECT COUNT(*) FROM #__update_sites_extensions \n";
             $query .= "WHERE update_site_id=" . $id;
             $db->setQuery($query);
             $cnt = $db->loadResult();
             if ($cnt) {
                 $query = "UPDATE #__update_sites_extensions \n";
                 $query .= "SET extension_id=" . $ext_table->extension_id . " \n";
                 $query .= "WHERE update_site_id=" . $id;
             } else {
                 $query = "INSERT INTO #__update_sites_extensions SET update_site_id=" . $id . ", extension_id=" . $ext_table->extension_id . " \n";
             }
             $db->setQuery($query);
             $db->query();
         }
     }
     //Add existing extensions to Joomla extensions table
     $list = JFolder::files(JPATH_SITE . '/components/com_sef/sef_ext');
     foreach ($list as $sef) {
         if (substr($sef, -4) != '.xml') {
             continue;
         }
         $xml_file = JPATH_SITE . '/components/com_sef/sef_ext/' . $sef;
         if (file_exists($ext_update_dir . $sef)) {
             $xml_file = $ext_update_dir . $sef;
         }
         $xml = simplexml_load_file($xml_file);
         $element = $this->getElement($xml);
         $query = "SELECT COUNT(*) FROM #__extensions WHERE type=" . $db->quote('sef_ext') . " AND element=" . $db->quote($element);
         $db->setQuery($query);
         $cnt = $db->loadResult();
         if ($cnt > 0) {
             continue;
         }
         $ext_table = JTable::getInstance('extension');
         $ext_table->name = (string) $xml->name;
         $ext_table->type = 'sef_ext';
         $ext_table->element = $element;
         $ext_table->enabled = 1;
         $ext_table->protected = 0;
         $ext_table->access = 1;
         $ext_table->client_id = 0;
         if (isset($xml->install->defaultparams)) {
             $ext_table->params = SEFTools::getDefaultParams((string) $xml->install->defaultparams);
         }
         if (isset($xml->install->defaultfilters)) {
             $ext_table->custom_data = SEFTools::getDefaultFilters((string) $xml->install->defaultfilters);
         }
         $ext_table->manifest_cache = json_encode(JApplicationHelper::parseXMLInstallFile($xml_file));
         $ext_table->store();
         $query = "INSERT INTO #__schemas SET extension_id=" . $ext_table->extension_id . ", version_id=" . $db->quote((string) $xml->version);
         $db->setQuery($query);
         $db->query();
         if (isset($xml->updateservers->server)) {
             $query = "INSERT INTO #__update_sites SET name=" . $db->quote((string) $xml->updateservers->server['name']) . ", type=" . $db->quote((string) $xml->updateservers->server['type']) . ", \n";
             $query .= "location=" . $db->quote((string) $xml->updateservers->server) . ", enabled=1 \n";
             $db->setQuery($query);
             $db->query();
             $id = $db->insertId();
             $query = "INSERT INTO #__update_sites_extensions SET update_site_id=" . $id . ", extension_id=" . $ext_table->extension_id . " \n";
             $db->setQuery($query);
             $db->query();
         }
     }
     $fields = $db->getTableColumns('#__sefurls');
     $fields = array_keys($fields);
     if (!in_array('metaauthor', $fields)) {
         $query = "ALTER TABLE #__sefurls \n";
         $query .= "ADD (metaauthor varchar(30) default '') \n";
         $db->setQuery($query);
         $db->query();
     }
     // 30.11.2012 dajo: Move stored configuration from params to custom_data field
     $db->setQuery("UPDATE `#__extensions` SET `custom_data` = `params` WHERE `type` = 'component' AND `element` = 'com_sef' AND (`custom_data` IS NULL OR `custom_data` = '') LIMIT 1");
     $db->query();
     // 2.1.2013 dajo: Remove left-over file
     if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_sef/tables/extension.php')) {
         JFile::delete(JPATH_ADMINISTRATOR . '/components/com_sef/tables/extension.php');
     }
     ob_start();
     $tmp_path = JFactory::getApplication()->getCfg('tmp_path');
     if (JFile::exists($tmp_path . '/joomsef-configuration.php')) {
         require_once $tmp_path . '/joomsef-configuration.php';
     }
     if (isset($artioDownloadId) && strlen($artioDownloadId)) {
         $query = "SELECT location FROM #__update_sites \n";
         $query .= "WHERE name=" . $db->quote('com_joomsef');
         $db->setQuery($query);
         $location = $db->loadResult();
         if (!preg_match("/(-([A-Za-z0-9]*)).xml/", $location)) {
             ?>
             <p class="message">
             It was found, that you have an commercial version of Artio JoomSEF and you dont have migrated your download id. Please finish upgrade by clicking <a href="index.php?option=com_sef&task=finish_upgrade">here</a>
             </p>
             <?php 
         }
     }
     $output = ob_get_contents();
     ob_end_clean();
     echo $output;
     return true;
 }
Example #27
0
 /**
  * Plugin that returns the object list for DJ-Mediatools album
  * 
  * Each object must contain following properties (mandatory): title, description, image
  * Optional properties: link, target (_blank or _self), alt (alt attribute for image)
  * 
  * @param	object	The album params
  */
 public function onAlbumPrepare(&$source, &$params)
 {
     // Lets check the requirements
     $check = $this->onCheckRequirements($source);
     if (is_null($check) || is_string($check)) {
         return null;
     }
     $app = JFactory::getApplication();
     require_once JPATH_ADMINISTRATOR . '/components/com_hikashop/helpers/helper.php';
     require_once JPATH_BASE . '/components/com_hikashop/views/product/view.html.php';
     $view = new ProductViewProduct(array('base_path' => HIKASHOP_FRONT));
     $view->setLayout('listing');
     // create params for hikashop view
     $mparams = new JRegistry();
     $mparams->set('show_limit', 0);
     $mparams->set('from_module', 'djmediatools');
     $mparams->set('content_type', 'product');
     $mparams->set('add_to_wishlist', 0);
     $mparams->set('link_to_product_page', 0);
     $mparams->set('show_vote_product', 0);
     $mparams->set('display_custom_item_fields', 0);
     $mparams->set('display_filters', 0);
     $mparams->set('display_badges', 0);
     // get options from album
     $mparams->def('limit', $params->get('max_images'));
     $mparams->def('content_synchronize', (int) $params->get('plg_hikashop_content_synchronize'));
     $mparams->def('product_synchronize', $params->get('plg_hikashop_product_synchronize'));
     $mparams->def('recently_viewed', (int) $params->get('plg_hikashop_recently_viewed'));
     $mparams->def('selectparentlisting', $params->get('plg_hikashop_selectparentlisting'));
     $mparams->def('filter_type', $params->get('plg_hikashop_filter_type'));
     $mparams->def('product_order', $params->get('plg_hikashop_product_order'));
     $mparams->def('order_dir', $params->get('plg_hikashop_order_dir'));
     $mparams->def('itemid', $params->get('plg_hikashop_itemid'));
     $mparams->def('add_to_cart', $params->get('plg_hikashop_add_to_cart'));
     $mparams->def('show_quantity_field', $params->get('plg_hikashop_show_quantity_field'));
     $mparams->def('show_out_of_stock', $params->get('plg_hikashop_show_out_of_stock'));
     $mparams->def('show_price', $params->get('plg_hikashop_show_price'));
     $mparams->def('random', $mparams->get('product_order') == 'random' ? 1 : 0);
     $show_price = (bool) $mparams->get('show_price');
     $show_addtocart = (bool) $mparams->get('add_to_cart');
     $default_image = $params->get('plg_hikashop_image');
     /* hikashop authors force me to do it, because their component is not object oriented and there is no other way
      * to get listing of the products unless we will rewrite the whole component logic, what is nonsens :)
      */
     ob_start();
     $view->display(null, $mparams);
     $js = @$view->js;
     ob_get_clean();
     // we don't need this, just $view object after view rendering
     //$this->debug($view->row);
     $slides = array();
     foreach ($view->rows as $item) {
         $slide = (object) array();
         $slide->image = $item->file_path;
         $slide->alt = $item->file_name;
         if (empty($slide->image)) {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->product_description);
         }
         // if no image found in product description then take default image
         if (empty($slide->image)) {
             $slide->image = $default_image;
         } else {
             $slide->image = str_replace(JURI::root(true), '', $view->image->uploadFolder_url) . $slide->image;
         }
         // if no default image set then don't display this product
         if (empty($slide->image)) {
             continue;
         }
         $slide->title = $item->product_name;
         $slide->description = $item->product_description;
         $slide->canonical = $slide->link = hikashop_contentLink('product&task=show&cid=' . $item->product_id . '&name=' . $item->alias . $view->itemid . $view->category_pathway, $item);
         $slide->id = $item->product_id . ':' . $item->alias;
         if ($comments = $params->get('commnets', 0)) {
             $host = str_replace(JURI::root(true), '', JURI::root());
             $host = preg_replace('/\\/$/', '', $host);
             switch ($comments) {
                 case 1:
                     // jcomments
                     $slide->comments = array('id' => $item->product_id, 'group' => 'com_hikashop');
                     break;
                 case 2:
                     // disqus
                     $disqus_shortname = $params->get('disqus_shortname', '');
                     if (!empty($disqus_shortname)) {
                         $slide->comments = array();
                         $slide->comments['url'] = $host . $slide->link;
                         $slide->comments['identifier'] = $disqus_shortname . '-hikashop-' . $item->product_id;
                         // ??
                     }
                     break;
                 case 3:
                     // facebook
                     $slide->comments = $host . $slide->link;
                     break;
                 case 4:
                     //komento
                     // not implemented
                     break;
             }
         }
         $view->row =& $item;
         if ($show_price) {
             $view->setLayout('listing_price');
             $slide->extra = $view->loadTemplate();
         }
         if ($show_addtocart) {
             if (!isset($slide->extra)) {
                 $slide->extra = '';
             }
             $view->setLayout('add_to_cart_listing');
             $slide->extra .= $view->loadTemplate();
         }
         $slides[] = $slide;
     }
     return $slides;
 }
Example #28
0
 function _getItemData(&$params, $item)
 {
     $data = null;
     $active_class = "";
     if ($item->id == $this->_currentItemId) {
         $active_class = "icemega_active";
     }
     // Menu Link is a special type that is a link to another item
     if ($item->type == 'menulink') {
         $menu =& JSite::getMenu();
         if ($newItem = $menu->getItem($item->query['Itemid'])) {
             $tmp = clone $newItem;
             $tmp->name = '<span><![CDATA[' . $item->title . ']]></span>';
             $tmp->mid = $item->id;
             $tmp->parent = $item->parent_id;
         } else {
             return false;
         }
     } else {
         $tmp = clone $item;
         $iParams = new JRegistry();
         $iParams->loadString($tmp->params);
         $tmp->name = '<span class="icemega_title' . ($iParams->get("icemega_subtitle", "") == "" ? ' icemega_nosubtitle' : '') . '"><![CDATA[' . $item->title . ']]></span>';
     }
     $iParams = new JRegistry();
     $iParams->loadString($tmp->params);
     if ($iParams->get('menu-anchor_css', "")) {
         JHTML::stylesheet('', $iParams->get('menu-anchor_css', ""));
     }
     if ($params->get('menu_images') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
         switch ($params->get('menu_images_align', 0)) {
             case 0:
                 $imgalign = 'align="left"';
                 break;
             case 1:
                 $imgalign = 'align="right"';
                 break;
             default:
                 $imgalign = '';
                 break;
         }
         if ($iParams->get('menu_anchor_css')) {
             $document->addStyleSheet($iParams->get('menu_anchor_css'));
         }
         $image = "";
         if ($iParams->get('menu_image')) {
             $image = '<img src="' . JURI::base(true) . "/" . $iParams->get('menu_image') . '" ' . $imgalign . ' alt="' . $item->alias . '" />';
         }
     } else {
         $image = null;
     }
     if ($iParams->get("icemega_subtitle", "") != "") {
         $tmp->name .= '<span class="icemega_desc">' . $iParams->get("icemega_subtitle", "") . '</span>';
     }
     switch ($tmp->type) {
         case 'separator':
             //return '<span class="separator">'.$image.$tmp->name.'</span>';
             if ($iParams->get("icemega_subtype") == 'mod' || $iParams->get("icemega_subtype") == 'pos') {
                 //$text  = 'window.addEvent("load", function(){if($(\'item-'.$tmp->id.'\') != null)$(\'item-'.$tmp->id.'\').setStyle(\'display\', \'none\')});';
                 //$document = &JFactory::getDocument();
                 //$document->addScriptDeclaration($text);
             }
             $tmp->url = "";
             break;
         case 'url':
             if (strpos($tmp->link, 'index.php?') === 0 && strpos($tmp->link, 'Itemid=') === false) {
                 $tmp->url = $tmp->link . '&amp;Itemid=' . $tmp->id;
             } else {
                 $tmp->url = $tmp->link;
             }
             break;
         case 'alias':
             $tmp->url = 'index.php?Itemid=' . $tmp->params->get('aliasoptions');
             break;
         default:
             $router = JSite::getRouter();
             $tmp->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $tmp->id : $tmp->link . '&Itemid=' . $tmp->id;
             break;
     }
     $myClass = "iceMenuTitle";
     if ($item->level == 1) {
         $myClass = "iceMenuTitle";
     }
     // Print a link if it exists
     if ($tmp->url != null && $iParams->get("icemega_showlink", 1)) {
         // Handle SSL links
         $iSecure = $iParams->def('secure', 0);
         if ($tmp->home == 1) {
             $tmp->url = JURI::base();
         } elseif (strcasecmp(substr($tmp->url, 0, 4), 'http') && strpos($tmp->link, 'index.php?') !== false) {
             $tmp->url = JRoute::_($tmp->url, true, $iSecure);
         } else {
             $tmp->url = str_replace('&', '&amp;', $tmp->url);
         }
         switch ($tmp->browserNav) {
             default:
             case 0:
                 // _top
                 $data = '<a href="' . $tmp->url . '" class="' . $active_class . ' ' . $myClass . '">' . $image . $tmp->name . '</a>';
                 break;
             case 1:
                 // _blank
                 $data = '<a href="' . $tmp->url . '" target="_blank"  class="' . $active_class . ' ' . $myClass . '">' . $image . $tmp->name . '</a>';
                 break;
             case 2:
                 // window.open
                 $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $this->_params->get('window_open');
                 // hrm...this is a bit dickey
                 $link = str_replace('index.php', 'index2.php', $tmp->url);
                 $data = '<a href="' . $link . '" onclick="window.open(this.href,\'targetWindow\',\'' . $attribs . '\');return false;"  class="' . $active_class . ' ' . $myClass . '">' . $image . $tmp->name . '</a>';
                 break;
         }
     } else {
         $data = '<a  class="' . $active_class . ' ' . $myClass . '">' . $image . $tmp->name . '</a>';
     }
     return $data;
 }
Example #29
0
 protected function setup()
 {
     $app = JFactory::getApplication();
     $tplarray = $this->params->toArray();
     // Loading joomla core features
     //JHtml::_('behavior.modal');
     //JHtml::_('behavior.tooltip');
     JHtml::_('bootstrap.tooltip');
     JHtml::_('jquery.ui', array('core', 'sortable'));
     // Adding layout responsiveness script
     if ($this->params->get('responsiveLayout', '1')) {
         $this->addScript(JMF_FRAMEWORK_URL . '/includes/assets/template/js/layout.js');
     }
     // determine the direction
     if ($app->input->get('direction') == 'rtl') {
         setcookie("jmfdirection", "rtl");
         $direction = 'rtl';
     } else {
         if ($app->input->get('direction') == 'ltr') {
             setcookie("jmfdirection", "ltr");
             $direction = 'ltr';
         } else {
             if (isset($_COOKIE['jmfdirection'])) {
                 $direction = $_COOKIE['jmfdirection'];
             } else {
                 $direction = $app->input->get('jmfdirection', $this->document->direction);
             }
         }
     }
     $this->direction = $this->params->set('direction', $direction);
     // handle JM Option Groups
     foreach ($tplarray as $param => $value) {
         if (is_string($value) && strstr($value, ';')) {
             $parts = explode(';', $value);
             if (is_numeric($parts[0])) {
                 $this->params->set($param, $parts[0]);
             }
             // only numeric to avoid cutting the text options containg semicolons
         }
     }
     // Mobile_Detect class for addtional browser detection
     if (!class_exists('Mobile_Detect')) {
         require_once JMF_FRAMEWORK_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'Mobile_Detect' . DIRECTORY_SEPARATOR . 'Mobile_Detect.php';
     }
     $detect = new Mobile_Detect();
     $this->browser_type = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'desktop';
     $themer_mode = $this->params->get('themermode', false) == '1' ? true : false;
     $browser = JBrowser::getInstance();
     // Use ThemeCustomiser only when using desktop browser. Mobile devices and bots are excluded
     $themer_mode = $this->browser_type != 'desktop' || $browser->isRobot() || $browser->isMobile() ? '0' : $themer_mode;
     // Disable ThemeCustomiser unless user turn it on from the front-end
     if ($themer_mode) {
         $themer_switch = $app->getUserStateFromRequest('themer.switch', 'tc', '0');
         if ($themer_switch !== '1') {
             $this->params->def('themerswitch', '1');
             $this->attachTCSwitch();
             $themer_mode = '0';
         }
     }
     $this->params->set('themermode', $themer_mode);
     if ($this->params->get('devmode', false)) {
         $app->enqueueMessage(JText::_('PLG_SYSTEM_JMFRAMEWORK_WARNING_DEV_MODE_ENABLED'));
     }
     // Making sure that custom fonts' CSS files have been generated
     $font_path = JMF_TPL_PATH . DIRECTORY_SEPARATOR . 'fonts';
     if (is_dir($font_path)) {
         $font_folders = JFolder::folders($font_path);
         if (is_array($font_folders) && !empty($font_folders)) {
             foreach ($font_folders as $font) {
                 if ($this->generateFontCss($font, $font_path . DIRECTORY_SEPARATOR . $font) && $themer_mode) {
                     $this->addStyleSheet(JMF_TPL_URL . '/fonts/' . $font . '/font.css');
                 }
             }
         }
     }
     // Purge obsolete CSS files that doesn't belong to any template style
     // Since styles have already been deleted, we have to discover somehow which files are no longer needed
     $db = JFactory::getDbo();
     $db->setQuery('SELECT id FROM #__template_styles ORDER BY id');
     // list of all style IDs
     $style_ids = $db->loadColumn();
     if (count($style_ids)) {
         // All LESS files in the template
         $less_files = JFolder::files(JPath::clean(JMF_TPL_PATH . '/less'), '\\.less$');
         // All CSS files that contain numerical suffix, e.g. "template.69.css"
         $css_files = JFolder::files(JPath::clean(JMF_TPL_PATH . '/css'), '\\.[0-9]+\\.css$');
         foreach ($css_files as $css_file) {
             // strip the extenion
             $name = JFile::stripExt($css_file);
             // split name by . (dot)
             $css_parts = explode('.', $name);
             // if there is at least one dot
             if (count($css_parts) > 1) {
                 // discover name of the LESS file
                 $less_name = JFile::stripExt($name);
                 // and the suffix itself
                 $last_part = (int) end($css_parts);
                 // if there is corresponding LESS file
                 // and the suffix does not correspond to any template style
                 // and the suffix is actually a number
                 if ($less_name && in_array($less_name . '.less', $less_files) && !in_array($last_part, $style_ids) && $last_part > 0) {
                     // delete obsolete CSS file
                     if (JFile::exists(JPath::clean(JPATH_ROOT . '/templates/' . JMF_TPL . '/css/') . $css_file)) {
                         JFile::delete(JPath::clean(JPATH_ROOT . '/templates/' . JMF_TPL . '/css/') . $css_file);
                     }
                     $map_file = str_replace('.css', '.map', $css_file);
                     if (JFile::exists(JPath::clean(JPATH_ROOT . '/templates/' . JMF_TPL . '/css/') . $map_file)) {
                         JFile::delete(JPath::clean(JPATH_ROOT . '/templates/' . JMF_TPL . '/css/') . $map_file);
                     }
                 }
             }
         }
     }
     $this->defaults = new JRegistry();
     $default_settings_file = JPath::clean(JPATH_ROOT . '/templates/' . JMF_TPL . '/templateDefaults.json');
     if (JFile::exists($default_settings_file)) {
         $this->defaults->loadFile($default_settings_file, 'JSON');
     }
 }
Example #30
0
 /**
  * Fabrik Search method
  *
  * The sql must return the following fields that are
  * used in a common display routine: href, title, section, created, text,
  * browsernav
  *
  * @param   string     $text      Target search string
  * @param   JRegistry  $params    Search plugin params
  * @param   string     $phrase    Matching option, exact|any|all
  * @param   string     $ordering  Option, newest|oldest|popular|alpha|category
  *
  * @return  array
  */
 public static function onDoContentSearch($text, $params, $phrase = '', $ordering = '')
 {
     $app = JFactory::getApplication();
     $fbConfig = JComponentHelper::getParams('com_fabrik');
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     if (defined('COM_FABRIK_SEARCH_RUN')) {
         return;
     }
     $input = $app->input;
     define('COM_FABRIK_SEARCH_RUN', true);
     JModelLegacy::addIncludePath(COM_FABRIK_FRONTEND . '/models', 'FabrikFEModel');
     $user = JFactory::getUser();
     $db = FabrikWorker::getDbo(true);
     require_once JPATH_SITE . '/components/com_content/helpers/route.php';
     // Load plugin params info
     $limit = $params->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     switch ($ordering) {
         case 'oldest':
             $order = 'a.created ASC';
             break;
         case 'popular':
             $order = 'a.hits DESC';
             break;
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'category':
             $order = 'b.title ASC, a.title ASC';
             $morder = 'a.title ASC';
             break;
         case 'newest':
         default:
             $order = 'a.created DESC';
             break;
     }
     // Set heading prefix
     $headingPrefix = $params->get('include_list_title', true);
     // Get all tables with search on
     $query = $db->getQuery(true);
     $query->select('id')->from('#__{package}_lists')->where('published = 1');
     $db->setQuery($query);
     $list = array();
     $ids = $db->loadColumn();
     $section = $params->get('search_section_heading');
     $urls = array();
     // $$$ rob remove previous search results?
     $input->set('resetfilters', 1);
     // Ensure search doesn't go over memory limits
     $memory = ini_get('memory_limit');
     $memory = (int) FabrikString::rtrimword($memory, 'M') * 1000000;
     $usage = array();
     $memSafety = 0;
     $listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
     $app = JFactory::getApplication();
     foreach ($ids as $id) {
         // Re-ini the list model (was using reset() but that was flaky)
         $listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
         // $$$ geros - http://fabrikar.com/forums/showthread.php?t=21134&page=2
         $key = 'com_' . $package . '.list' . $id . '.filter.searchall';
         $app->setUserState($key, null);
         $used = memory_get_usage();
         $usage[] = memory_get_usage();
         if (count($usage) > 2) {
             $diff = $usage[count($usage) - 1] - $usage[count($usage) - 2];
             if ($diff + $usage[count($usage) - 1] > $memory - $memSafety) {
                 $app->enqueueMessage('Some records were not searched due to memory limitations');
                 break;
             }
         }
         // $$$rob set this to current table
         // Otherwise the fabrik_list_filter_all var is not used
         $input->set('listid', $id);
         $listModel->setId($id);
         $searchFields = $listModel->getSearchAllFields();
         if (empty($searchFields)) {
             continue;
         }
         $filterModel = $listModel->getFilterModel();
         $requestKey = $filterModel->getSearchAllRequestKey();
         // Set the request variable that fabrik uses to search all records
         $input->set($requestKey, $text, 'post');
         $table = $listModel->getTable();
         $fabrikDb = $listModel->getDb();
         $params = $listModel->getParams();
         // Test for swap too boolean mode
         $mode = $input->get('searchphrase', '') === 'all' ? 0 : 1;
         // $params->set('search-mode-advanced', true);
         $params->set('search-mode-advanced', $mode);
         // The table shouldn't be included in the search results or we have reached the max number of records to show.
         if (!$params->get('search_use') || $limit <= 0) {
             continue;
         }
         // Set the table search mode to OR - this will search ALL fields with the search term
         $params->set('search-mode', 'OR');
         $allrows = $listModel->getData();
         $elementModel = $listModel->getFormModel()->getElement($params->get('search_description', $table->label), true);
         $descname = is_object($elementModel) ? $elementModel->getFullName() : '';
         $elementModel = $listModel->getFormModel()->getElement($params->get('search_title', 0), true);
         $title = is_object($elementModel) ? $elementModel->getFullName() : '';
         /**
          * $$$ hugh - added date element ... always use raw, as anything that isn't in
          * standard MySQL format will cause a fatal error in J!'s search code when it does the JDate create
          */
         $elementModel = $listModel->getFormModel()->getElement($params->get('search_date', 0), true);
         $date_element = is_object($elementModel) ? $elementModel->getFullName() : '';
         if (!empty($date_element)) {
             $date_element .= '_raw';
         }
         $aAllowedList = array();
         $pk = $table->db_primary_key;
         foreach ($allrows as $group) {
             foreach ($group as $oData) {
                 $pkval = $oData->__pk_val;
                 if ($app->isAdmin() || $params->get('search_link_type') === 'form') {
                     $href = $oData->fabrik_edit_url;
                 } else {
                     $href = $oData->fabrik_view_url;
                 }
                 if (!in_array($href, $urls)) {
                     $limit--;
                     $urls[] = $href;
                     $o = new stdClass();
                     if (isset($oData->{$title})) {
                         $o->title = $headingPrefix ? $table->label . ' : ' . $oData->{$title} : $oData->{$title};
                     } else {
                         $o->title = $table->label;
                     }
                     $o->_pkey = $table->db_primary_key;
                     $o->section = $section;
                     $o->href = $href;
                     // Need to make sure it's a valid date in MySQL format, otherwise J!'s code will pitch a fatal error
                     if (isset($oData->{$date_element}) && FabrikString::isMySQLDate($oData->{$date_element})) {
                         $o->created = $oData->{$date_element};
                     } else {
                         $o->created = '';
                     }
                     $o->browsernav = 2;
                     if (isset($oData->{$descname})) {
                         $o->text = $oData->{$descname};
                     } else {
                         $o->text = '';
                     }
                     $o->title = strip_tags($o->title);
                     $aAllowedList[] = $o;
                 }
             }
             $list[] = $aAllowedList;
         }
     }
     $allList = array();
     foreach ($list as $li) {
         if (is_array($li) && !empty($li)) {
             $allList = array_merge($allList, $li);
         }
     }
     return $allList;
 }