Ejemplo n.º 1
0
 static function &geTtoolbarParams($editor, $args = array())
 {
     if (count($args) > 1) {
         $row = $args[1];
     }
     if (is_a($args[0], 'JParameter')) {
         $params = $args[0];
     } else {
         if ($row) {
             $params = new JParameter($row->params);
         } else {
             $row =& JCKHelper::getTable('toolbar');
             // load the row from the db table
             $row->load($args[0]);
             //get toolbar parameter
             $params = new JParameter($row->params);
         }
     }
     $editor_params = new JParameter($editor->params);
     $toolbar = $params->get('toolbar', $row->name);
     $skins = $params->get('skin', $editor_params->def('skin', 'office2003'));
     $width = $params->get('wwidth', $editor_params->def('wwidth', '100%'));
     $editor_params->set('toolbar', $toolbar);
     $editor_params->set('skin', $skins);
     $editor_params->set('wwidth', $width);
     $editor_params->Set('hheight', 300);
     return $editor_params;
 }
Ejemplo n.º 2
0
 /**
  * Test the JParameter::def method
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testDef()
 {
     $p = new JParameter('');
     $p->set('foo1', 'bar1');
     $this->assertThat($p->def('foo1', 'bar2'), $this->equalTo('bar1'));
     $this->assertThat($p->def('foo2', 'bar2'), $this->equalTo('bar2'));
 }
Ejemplo n.º 3
0
 public function getParameters()
 {
     $active = $this->getObject('application.pages')->getActive();
     $parameters = new JParameter($active->params);
     $parameters->def('description_login_text', 'LOGIN_DESCRIPTION');
     $parameters->def('registration', $this->getObject('application.extensions')->users->params->get('allowUserRegistration'));
     return $parameters;
 }
Ejemplo n.º 4
0
 /**
  * Tags 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)
 {
     $searchText = $text;
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchTagsAreas()))) {
             return array();
         }
     }
     // load plugin params info
     $plugin = JPluginHelper::getPlugin('search', 'cedtags');
     $pluginParams = new JParameter($plugin->params);
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $rows = $this->searchForText($text, $limit);
     $count = count($rows);
     for ($i = 0; $i < $count; $i++) {
         $link = 'index.php?option=com_cedtag&task=tag&tag=' . CedTagsHelper::urlTagname($rows[$i]->name);
         $rows[$i]->href = JRoute::_($link);
         $rows[$i]->section = JText::_('TAG');
     }
     $return = array();
     foreach ($rows as $key => $tag) {
         if (searchHelper::checkNoHTML($tag, $searchText, array('name', 'title', 'text'))) {
             $return[] = $tag;
         }
     }
     return $return;
 }
Ejemplo n.º 5
0
function plgSearchEvents($text, $phrase = '', $ordering = '', $areas = null)
{
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchEventsAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'events');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $events = KService::get('com://admin/calendar.model.events')->sort('tbl.start_date')->direction('ASC')->limit($limit)->search($text)->getList();
    $return = array();
    foreach ($events as $event) {
        if (searchHelper::checkNoHTML($event, $text, array('title', 'description'))) {
            $event->text = $event->description;
            $event->origin = 'events';
            $event->href = 'index.php?option=com_calendar&view=event&id=' . $event->id . '&slug=' . $event->slug;
            $event->section = JText::_('Events');
            $return[] = $event->getData();
        }
    }
    return $return;
}
Ejemplo n.º 6
0
 function onPrepareContent(&$article, &$params, $limitstart)
 {
     global $mainframe;
     // 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 JParameter($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);
     }
 }
Ejemplo n.º 7
0
function plgSearchArticles($text, $phrase = '', $ordering = '', $areas = null)
{
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchArticlesAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'articles');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $articles = KService::get('com://admin/news.model.articles')->sort('tbl.created_on')->direction('DESC')->limit($limit)->search($text)->getList();
    $return = array();
    foreach ($articles as $article) {
        if (searchHelper::checkNoHTML($article, $text, array('title', 'text'))) {
            $article->origin = 'articles';
            $article->href = 'index.php?option=com_news&view=article&id=' . $article->id . '&slug=' . $article->slug;
            $article->section = $article->category_title;
            $return[] = $article->getData();
        }
    }
    return $return;
}
Ejemplo n.º 8
0
/**
* Plugin that loads module positions within content
*/
function plgContentLoadModule(&$row, &$params, $page = 0)
{
    $db =& JFactory::getDBO();
    // simple performance check to determine whether bot should process further
    if (JString::strpos($row->text, 'loadposition') === false) {
        return true;
    }
    // Get plugin info
    $plugin =& JPluginHelper::getPlugin('content', 'loadmodule');
    // expression to search for
    $regex = '/{loadposition\\s*.*?}/i';
    $pluginParams = new JParameter($plugin->params);
    // check whether plugin has been unpublished
    if (!$pluginParams->get('enabled', 1)) {
        $row->text = preg_replace($regex, '', $row->text);
        return true;
    }
    // find all instances of plugin and put in $matches
    preg_match_all($regex, $row->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);
        plgContentProcessPositions($row, $matches, $count, $regex, $style);
    }
}
Ejemplo n.º 9
0
/**
* Contacts 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
*/
function plgSearchJFContacts($text, $phrase = '', $ordering = '', $areas = null)
{
    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    $registry =& JFactory::getConfig();
    $lang = $registry->getValue("config.jflang");
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchContactAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'jfcontacts');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $activeLang = $pluginParams->def('active_language_only', 0);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $section = JText::_('Contact');
    switch ($ordering) {
        case 'alpha':
            $order = 'a.name ASC';
            break;
        case 'category':
            $order = 'b.title ASC, a.name ASC';
            break;
        case 'popular':
        case 'newest':
        case 'oldest':
        default:
            $order = 'a.name DESC';
    }
    $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
    $query = 'SELECT a.id as contid, b.id as catid,  a.name AS title, "" AS created,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(\':\', b.id, b.alias) ELSE b.id END AS catslug, ' . ' a.name, a.con_position, a.misc,' . ' "2" AS browsernav,' . ' jfl.code as jflang, jfl.name as jflname' . ' FROM #__contact_details AS a' . ' INNER JOIN #__categories AS b ON b.id = a.catid' . "\n LEFT JOIN #__jf_content as jfc ON reference_id = a.id" . "\n LEFT JOIN #__languages as jfl ON jfc.language_id = jfl.id" . ' WHERE jfc.value LIKE ' . $text . ' AND a.published = 1' . ' AND b.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND b.access <= ' . (int) $user->get('aid') . "\n AND jfc.reference_table = 'contact_details'" . ($activeLang ? "\n AND jfl.code = '{$lang}'" : '') . ' GROUP BY a.id' . ' ORDER BY ' . $order;
    $db->setQuery($query, 0, $limit);
    $rows = $db->loadObjectList();
    foreach ($rows as $key => $row) {
        $rows[$key]->text = $row->name . "/" . $row->con_position . "/" . $row->misc;
        $rows[$key]->section = $section . "/" . $row->title . " - " . $row->jflname;
        $rows[$key]->href = 'index.php?option=com_contact&view=contact&id=' . $row->slug . '&catid=' . $row->catslug;
    }
    return $rows;
}
Ejemplo n.º 10
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 plgSearchJFCategories($text, $phrase = '', $ordering = '', $areas = null)
{
    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    $registry =& JFactory::getConfig();
    $lang = $registry->getValue("config.jflang");
    require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchCategoryAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'jfcategories');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $activeLang = $pluginParams->def('active_language_only', 0);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    switch ($ordering) {
        case 'alpha':
            $order = 'a.name ASC';
            break;
        case 'category':
        case 'popular':
        case 'newest':
        case 'oldest':
        default:
            $order = 'a.name DESC';
    }
    $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
    $query = 'SELECT a.title, a.description AS text, "" AS created,' . ' "2" AS browsernav,' . ' s.id AS secid, a.id AS catid,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' jfl.code as jflang, jfl.name as jflname' . ' FROM #__categories AS a' . ' INNER JOIN #__sections AS s ON s.id = a.section' . "\n LEFT JOIN #__jf_content as jfc ON reference_id = a.id" . "\n LEFT JOIN #__languages as jfl ON jfc.language_id = jfl.id" . ' WHERE  jfc.value LIKE ' . $text . ' AND a.published = 1' . ' AND s.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND s.access <= ' . (int) $user->get('aid') . "\n AND jfc.reference_table = 'categories'" . ($activeLang ? "\n AND jfl.code = '{$lang}'" : '') . ' GROUP BY a.id' . ' ORDER BY ' . $order;
    $db->setQuery($query, 0, $limit);
    $rows = $db->loadObjectList();
    $count = count($rows);
    for ($i = 0; $i < $count; $i++) {
        $rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug, $rows[$i]->secid);
        $rows[$i]->section = JText::_('Category') . " - " . $rows[$i]->jflname;
    }
    return $rows;
}
Ejemplo n.º 11
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 JParameter($link->attribs);
    $params->def('show_review', $mtconf->get('show_review'));
    $params->def('show_rating', $mtconf->get('show_rating'));
    return $link;
}
Ejemplo n.º 12
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 onSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db =& JFactory::getDbo();
     $user =& JFactory::getUser();
     $groups = implode(',', $user->authorisedLevels());
     $searchText = $text;
     require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchCategoryAreas()))) {
             return array();
         }
     }
     // load plugin params info
     $plugin =& JPluginHelper::getPlugin('search', 'categories');
     $pluginParams = new JParameter($plugin->params);
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     switch ($ordering) {
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'category':
         case 'popular':
         case 'newest':
         case 'oldest':
         default:
             $order = 'a.title DESC';
     }
     $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
     $query = 'SELECT a.title, a.description AS text, "" AS created, "2" AS browsernav, a.id AS catid,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug' . ' FROM #__categories AS a' . ' WHERE (a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ')' . ' AND a.published = 1' . ' AND a.access IN (' . $groups . ')' . ' GROUP BY a.id' . ' ORDER BY ' . $order;
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     $count = count($rows);
     for ($i = 0; $i < $count; $i++) {
         $rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug);
         $rows[$i]->section = JText::_('Category');
     }
     $return = array();
     foreach ($rows as $key => $category) {
         if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) {
             $return[] = $category;
         }
     }
     return $return;
 }
Ejemplo n.º 13
0
/**
* Sections 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 plgSearchSections($text, $phrase = '', $ordering = '', $areas = null)
{
    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    $searchText = $text;
    require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchSectionAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'sections');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    switch ($ordering) {
        case 'alpha':
            $order = 'a.name ASC';
            break;
        case 'category':
        case 'popular':
        case 'newest':
        case 'oldest':
        default:
            $order = 'a.name DESC';
    }
    $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
    $query = 'SELECT a.title AS title, a.description AS text, a.name, ' . ' "" AS created,' . ' "2" AS browsernav,' . ' a.id AS secid' . ' FROM #__sections AS a' . ' WHERE ( a.name LIKE ' . $text . ' OR a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ' )' . ' AND a.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' GROUP BY a.id' . ' ORDER BY ' . $order;
    $db->setQuery($query, 0, $limit);
    $rows = $db->loadObjectList();
    $count = count($rows);
    for ($i = 0; $i < $count; $i++) {
        $rows[$i]->href = ContentHelperRoute::getSectionRoute($rows[$i]->secid);
        $rows[$i]->section = JText::_('Section');
    }
    $return = array();
    foreach ($rows as $key => $section) {
        if (searchHelper::checkNoHTML($section, $searchText, array('name', 'title', 'text'))) {
            $return[] = $section;
        }
    }
    return $return;
}
Ejemplo n.º 14
0
/**
* Ninjaboard 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
*/
function plgSearchNinjaboard($text, $phrase = '', $ordering = '', $areas = null)
{
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchNinjaboardAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $pluginParams = new JParameter(JPluginHelper::getPlugin('search', 'ninjaboard')->params);
    $limit = $pluginParams->def('search_limit', 50);
    if (($text = trim($text)) == '') {
        return array();
    }
    $order = 'created_time';
    $direction = 'desc';
    switch ($ordering) {
        case 'alpha':
            $order = 'subject';
            $direction = 'asc';
            break;
        case 'category':
            $order = array('forum', 'topic');
            $direction = 'desc';
            break;
        case 'popular':
            $order = array('hits', 'created_time');
            $direction = 'asc';
            break;
        case 'newest':
            $order = 'created_time';
            $direction = 'desc';
            break;
        case 'oldest':
            $order = 'created_time';
            $direction = 'asc';
    }
    $posts = KFactory::tmp('admin::com.ninjaboard.model.posts')->search($text)->limit($limit)->sort($order)->direction($direction)->getList();
    // Bit hackish. Don't blame me, com_search is a piece of M**bo crap
    $results = array();
    foreach ($posts as $post) {
        $results[] = (object) array('href' => 'index.php?option=com_ninjaboard&view=topic&id=' . $post->topic . '&post=' . $post->id . '#p' . $post->id . '', 'title' => $post->subject, 'created' => $post->created_on, 'section' => $post->forum, 'text' => KFactory::get('admin::com.ninja.helper.bbcode')->parse(array('text' => $post->text)), 'browsernav' => 0);
    }
    return $results;
}
Ejemplo n.º 15
0
 function GantryMenu($params)
 {
     if (empty($params)) {
         $params = new JParameter('');
     }
     $params->def('menutype', 'mainmenu');
     $params->def('class_sfx', '');
     $params->def('menu_images', 0);
     // Added in 1.5
     $params->def('startLevel', 0);
     $params->def('endLevel', 0);
     $params->def('showAllChildren', 0);
     $this->_menudata = GantryMenu::_getMenuData($params);
 }
Ejemplo n.º 16
0
 /**
  * Contacts 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
  */
 function onSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db =& JFactory::getDbo();
     $user =& JFactory::getUser();
     $groups = implode(',', $user->authorisedLevels());
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchContactAreas()))) {
             return array();
         }
     }
     // load plugin params info
     $plugin =& JPluginHelper::getPlugin('search', 'contacts');
     $pluginParams = new JParameter($plugin->params);
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $section = JText::_('Contact');
     switch ($ordering) {
         case 'alpha':
             $order = 'a.name ASC';
             break;
         case 'category':
             $order = 'b.title ASC, a.name ASC';
             break;
         case 'popular':
         case 'newest':
         case 'oldest':
         default:
             $order = 'a.name DESC';
     }
     $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
     $query = 'SELECT a.name AS title, "" AS created,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(\':\', b.id, b.alias) ELSE b.id END AS catslug, ' . ' CONCAT_WS(", ", a.name, a.con_position, a.misc) AS text,' . ' CONCAT_WS(" / ", ' . $db->Quote($section) . ', b.title) AS section,' . ' "2" AS browsernav' . ' FROM #__contact_details AS a' . ' INNER JOIN #__categories AS b ON b.id = a.catid' . ' WHERE (a.name LIKE ' . $text . ' OR a.misc LIKE ' . $text . ' OR a.con_position LIKE ' . $text . ' OR a.address LIKE ' . $text . ' OR a.suburb LIKE ' . $text . ' OR a.state LIKE ' . $text . ' OR a.country LIKE ' . $text . ' OR a.postcode LIKE ' . $text . ' OR a.telephone LIKE ' . $text . ' OR a.fax LIKE ' . $text . ')' . ' AND a.published = 1' . ' AND b.published = 1' . ' AND a.access IN (' . $groups . ')' . ' AND b.access IN (' . $groups . ')' . ' GROUP BY a.id' . ' ORDER BY ' . $order;
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     foreach ($rows as $key => $row) {
         $rows[$key]->href = 'index.php?option=com_contact&view=contact&id=' . $row->slug . '&catid=' . $row->catslug;
     }
     return $rows;
 }
Ejemplo n.º 17
0
function showform2(&$matches)
{
    global $mainframe;
    $posted = JRequest::get('post', JREQUEST_ALLOWRAW);
    $database =& JFactory::getDBO();
    $matches[0] = preg_replace('/{chronocontact}/i', '', $matches[0]);
    $matches[0] = preg_replace('/{\\/chronocontact}/i', '', $matches[0]);
    $formname = $matches[0];
    $plugin =& JPluginHelper::getPlugin('content', 'chronocontact');
    $botParams = new JParameter($plugin->params);
    $type = $botParams->def('type', 1);
    $MyForm =& CFChronoForm::getInstance($formname);
    $MyForm->pagetype = 'plugin';
    $session =& JFactory::getSession();
    $MyForm->formerrors = $session->get('chrono_form_errors_' . $formname, '', md5('chrono'));
    if ($session->get('chrono_form_data_' . $formname, array(), md5('chrono'))) {
        $posted = $session->get('chrono_form_data_' . $formname, array(), md5('chrono'));
        //print_r($posted);
    }
    ob_start();
    $MyForm->showForm($formname, $posted);
    return $result = ob_get_clean();
    ob_end_clean();
}
Ejemplo n.º 18
0
/**
 * Cloak all emails in text from spambots via Javascript.
 *
 * @param string The string to be cloaked.
 * @param array Additional parameters. Parameter "mode" (integer, default 1)
 * replaces addresses with "mailto:" links if nonzero.
 * @return boolean True on success.
 */
function plgEmailCloak(&$text, &$params)
{
    /*
     * Check for presence of {emailcloak=off} which is explicits disables this
     * bot for the item.
     */
    if (JString::strpos($text, '{emailcloak=off}') !== false) {
        $text = JString::str_ireplace('{emailcloak=off}', '', $text);
        return true;
    }
    // Simple performance check to determine whether bot should process further.
    if (JString::strpos($text, '@') === false) {
        return true;
    }
    $plugin =& JPluginHelper::getPlugin('content', 'emailcloak');
    // Load plugin params info
    $pluginParams = new JParameter($plugin->params);
    $mode = $pluginParams->def('mode', 1);
    // split the string into parts to exclude strcipt tags from being handled
    $text = explode('<script', $text);
    foreach ($text as $i => $str) {
        if ($i == 0) {
            plgEmailCloakString($text[$i], $mode);
        } else {
            $str_split = explode('</script>', $str);
            foreach ($str_split as $j => $str_split_part) {
                if ($j % 2 == 1) {
                    plgEmailCloakString($str_split[$i], $mode);
                }
            }
            $text[$i] = implode('</script>', $str_split);
        }
    }
    $text = implode('<script', $text);
    return true;
}
Ejemplo n.º 19
0
/**
 * Content 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 the search it to be restricted to areas, null if search all
 */
function plgSearchContent($text, $phrase = '', $ordering = '', $areas = null)
{
    global $mainframe;
    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
    require_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_search' . DS . 'helpers' . DS . 'search.php';
    $searchText = $text;
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchContentAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin =& JPluginHelper::getPlugin('search', 'content');
    $pluginParams = new JParameter($plugin->params);
    $sContent = $pluginParams->get('search_content', 1);
    $sUncategorised = $pluginParams->get('search_uncategorised', 1);
    $sArchived = $pluginParams->get('search_archived', 1);
    $limit = $pluginParams->def('search_limit', 50);
    $nullDate = $db->getNullDate();
    $date =& JFactory::getDate();
    $now = $date->toMySQL();
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $wheres = array();
    switch ($phrase) {
        case 'exact':
            $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
            $wheres2 = array();
            $wheres2[] = 'a.title LIKE ' . $text;
            $wheres2[] = 'a.introtext LIKE ' . $text;
            $wheres2[] = 'a.`fulltext` LIKE ' . $text;
            $wheres2[] = 'a.metakey LIKE ' . $text;
            $wheres2[] = 'a.metadesc LIKE ' . $text;
            $where = '(' . implode(') OR (', $wheres2) . ')';
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
                $wheres2 = array();
                $wheres2[] = 'a.title LIKE ' . $word;
                $wheres2[] = 'a.introtext LIKE ' . $word;
                $wheres2[] = 'a.`fulltext` LIKE ' . $word;
                $wheres2[] = 'a.metakey LIKE ' . $word;
                $wheres2[] = 'a.metadesc LIKE ' . $word;
                $wheres[] = implode(' OR ', $wheres2);
            }
            $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
            break;
    }
    $morder = '';
    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;
    }
    $rows = array();
    // search articles
    if ($sContent && $limit > 0) {
        $query = 'SELECT a.title AS title, a.metadesc, a.metakey,' . ' a.created AS created,' . ' CONCAT(a.introtext, a.`fulltext`) AS text,' . ' CONCAT_WS( "/", u.title, b.title ) AS section,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug,' . ' u.id AS sectionid,' . ' "2" AS browsernav' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS b ON b.id=a.catid' . ' INNER JOIN #__sections AS u ON u.id = a.sectionid' . ' WHERE ( ' . $where . ' )' . ' AND a.state = 1' . ' AND u.published = 1' . ' AND b.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND b.access <= ' . (int) $user->get('aid') . ' AND u.access <= ' . (int) $user->get('aid') . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . ' GROUP BY a.id' . ' ORDER BY ' . $order;
        $db->setQuery($query, 0, $limit);
        $list = $db->loadObjectList();
        $limit -= count($list);
        if (isset($list)) {
            foreach ($list as $key => $item) {
                $list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid);
            }
        }
        $rows[] = $list;
    }
    // search uncategorised content
    if ($sUncategorised && $limit > 0) {
        $query = 'SELECT id, a.title AS title, a.created AS created, a.metadesc, a.metakey, ' . ' a.introtext AS text,' . ' "2" as browsernav, "' . $db->Quote(JText::_('Uncategorised Content')) . '" AS section' . ' FROM #__content AS a' . ' WHERE (' . $where . ')' . ' AND a.state = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND a.sectionid = 0' . ' AND a.catid = 0' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . ' ORDER BY ' . ($morder ? $morder : $order);
        $db->setQuery($query, 0, $limit);
        $list2 = $db->loadObjectList();
        $limit -= count($list2);
        if (isset($list2)) {
            foreach ($list2 as $key => $item) {
                $list2[$key]->href = ContentHelperRoute::getArticleRoute($item->id);
            }
        }
        $rows[] = $list2;
    }
    // search archived content
    if ($sArchived && $limit > 0) {
        $searchArchived = JText::_('Archived');
        $query = 'SELECT a.title AS title, a.metadesc, a.metakey,' . ' a.created AS created,' . ' a.introtext AS text,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug,' . ' u.id AS sectionid,' . ' "2" AS browsernav' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS b ON b.id=a.catid AND b.access <= ' . $user->get('gid') . ' INNER JOIN #__sections AS u ON u.id = a.sectionid' . ' WHERE ( ' . $where . ' )' . ' AND a.state = -1' . ' AND u.published = 1' . ' AND b.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND b.access <= ' . (int) $user->get('aid') . ' AND u.access <= ' . (int) $user->get('aid') . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . ' ORDER BY ' . $order;
        $db->setQuery($query, 0, $limit);
        $list3 = $db->loadObjectList();
        if (isset($list3)) {
            foreach ($list3 as $key => $item) {
                $list3[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid);
            }
        }
        $rows[] = $list3;
    }
    $results = array();
    if (count($rows)) {
        foreach ($rows as $row) {
            $new_row = array();
            foreach ($row as $key => $article) {
                if (searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey'))) {
                    $new_row[] = $article;
                }
            }
            $results = array_merge($results, (array) $new_row);
        }
    }
    return $results;
}
Ejemplo n.º 20
0
/**
* Utility function for writing a menu link
*/
function mosGetMenuLink($mitem, $level = 0, &$params, $open = null)
{
    global $Itemid;
    $txt = '';
    // Menu Link is a special type that is a link to another item
    if ($mitem->type == 'menulink') {
        $menu =& JSite::getMenu();
        if ($tmp = $menu->getItem($mitem->query['Itemid'])) {
            $name = $mitem->name;
            $mid = $mitem->id;
            $parent = $mitem->parent;
            $mitem = clone $tmp;
            $mitem->name = $name;
            $mitem->mid = $mid;
            $mitem->parent = $parent;
        } else {
            return;
        }
    }
    switch ($mitem->type) {
        case 'separator':
            break;
        case 'url':
            if (eregi('index.php\\?', $mitem->link)) {
                if (!eregi('Itemid=', $mitem->link)) {
                    $mitem->link .= '&amp;Itemid=' . $mitem->id;
                }
            }
            break;
        default:
            $mitem->link = 'index.php?Itemid=' . $mitem->id;
            break;
    }
    // Active Menu highlighting
    $current_itemid = intval($Itemid);
    if (!$current_itemid) {
        $id = '';
    } else {
        if ($current_itemid == $mitem->id) {
            $id = 'id="active_menu' . $params->get('class_sfx') . '"';
        } else {
            if ($params->get('activate_parent') && isset($open) && in_array($mitem->id, $open)) {
                $id = 'id="active_menu' . $params->get('class_sfx') . '"';
            } else {
                if ($mitem->type == 'url' && ItemidContained($mitem->link, $current_itemid)) {
                    $id = 'id="active_menu' . $params->get('class_sfx') . '"';
                } else {
                    $id = '';
                }
            }
        }
    }
    if ($params->get('full_active_id')) {
        // support for `active_menu` of 'Link - Url' if link is relative
        if ($id == '' && $mitem->type == 'url' && strpos('http', $mitem->link) === false) {
            $url = array();
            parse_str($mitem->link, $url);
            if (isset($url['Itemid'])) {
                if ($url['Itemid'] == $current_itemid) {
                    $id = 'id="active_menu' . $params->get('class_sfx') . '"';
                }
            }
        }
    }
    // replace & with amp; for xhtml compliance
    $menu_params = new stdClass();
    $menu_params = new JParameter($mitem->params);
    $menu_secure = $menu_params->def('secure', 0);
    if (strcasecmp(substr($mitem->link, 0, 4), 'http')) {
        $mitem->url = JRoute::_($mitem->link, true, $menu_secure);
    } else {
        $mitem->url = $mitem->link;
    }
    $menuclass = 'mainlevel' . $params->get('class_sfx');
    if ($level > 0) {
        $menuclass = 'sublevel' . $params->get('class_sfx');
    }
    // replace & with amp; for xhtml compliance
    // remove slashes from excaped characters
    $mitem->name = stripslashes(htmlspecialchars($mitem->name));
    switch ($mitem->browserNav) {
        // cases are slightly different
        case 1:
            // open in a new window
            $txt = '<a href="' . $mitem->url . '" target="_blank" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
            break;
        case 2:
            // open in a popup window
            $txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $mitem->url . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"{$menuclass}\" " . $id . ">" . $mitem->name . "</a>\n";
            break;
        case 3:
            // don't link it
            $txt = '<span class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</span>';
            break;
        default:
            // formerly case 2
            // open in parent window
            $txt = '<a href="' . $mitem->url . '" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
            break;
    }
    if ($params->get('menu_images')) {
        $menu_params = new stdClass();
        $menu_params = new JParameter($mitem->params);
        $menu_image = $menu_params->def('menu_image', -1);
        if ($menu_image != '-1' && $menu_image) {
            $image = '<img src="' . JURI::base(true) . '/images/stories/' . $menu_image . '" border="0" alt="' . $mitem->name . '"/>';
            if ($params->get('menu_images_align')) {
                $txt = $txt . ' ' . $image;
            } else {
                $txt = $image . ' ' . $txt;
            }
        }
    }
    return $txt;
}
Ejemplo n.º 21
0
 function onPrepareContent(&$article, &$params, $limitstart)
 {
     global $mainframe;
     $document =& JFactory::getDocument();
     $view = JRequest::getCmd('view');
     if ($view != 'article') {
         return;
     }
     // Get plugin info
     $plugin =& JPluginHelper::getPlugin('content', 'multishare');
     $pluginParams = new JParameter($plugin->params);
     $excludeSectionID = $pluginParams->get('excludeSectionID', '');
     $excludeCategoryID = $pluginParams->get('excludeCategoryID', '');
     $excludeID = $pluginParams->get('excludeID', '');
     $listexcludeSection = @explode(",", $excludeSectionID);
     $listexcludeCategory = @explode(",", $excludeCategoryID);
     $listexclude = @explode(",", $excludeID);
     if ($params->get('intro_only') || in_array($article->id, $listexclude) || in_array($article->sectionid, $listexcludeSection) || in_array($article->catid, $listexcludeCategory)) {
         return;
     }
     $shareservice = $pluginParams->def('shareservice', '');
     $addthis_pub = $pluginParams->def('addthis_pub', '');
     $LogoURL = $pluginParams->def('LogoURL', '');
     $Language = $pluginParams->def('Language', 'en');
     $AddThisBrand = $pluginParams->def('addthis_brand', '');
     $AddThisLogoBackground = $pluginParams->def('addthis_logo_background_color', '');
     $AddThisLogoColor = $pluginParams->def('addthis_logo_color', '');
     $AddThisServicesOrder = $pluginParams->get('addthis_services_order', '');
     $AddThisBrandColor = $pluginParams->def('addthis_brand_color', '');
     $AddThisBrandBackgroundColor = $pluginParams->get('addthis_brand_background_color', '');
     $URI = $pluginParams->get('URI', '');
     $Buttonimage = $pluginParams->get('Buttonimage', 'http://s7.addthis.com/static/btn/lg-share-' . $Language . '.gif');
     $SharethisCode = $pluginParams->get('SharethisCode', '');
     $TellafriendCode = $pluginParams->get('TellafriendCode', '');
     $CustomCode = $pluginParams->get('CustomCode', '');
     $show = $pluginParams->get('Show', '');
     $css = $pluginParams->get('DivCSS', '');
     $html = "";
     $code = "";
     if ($shareservice == '1') {
         $code = "<div style=\"{$css}\">";
         $code .= "<!-- ADDTHIS BUTTON BEGIN -->\n<script type=\"text/javascript\">\naddthis_pub             = '{$addthis_pub}'; \naddthis_language        = '{$Language}';\naddthis_logo            = '{$LogoURL}';\naddthis_logo_background = '{$AddThisLogoBackground}';\naddthis_logo_color      = '{$AddThisLogoColor}';\naddthis_brand           = '{$AddThisBrand}';\naddthis_options         = '{$AddThisServicesOrder}';\naddthis_header_color = '#{$AddThisBrandColor}';\naddthis_header_background = '#{$AddThisBrandBackgroundColor}';\n</script>\n<a href=\"{$URI}\" onmouseover=\"return addthis_open(this, '', '[URL]', '[TITLE]')\" onmouseout=\"addthis_close()\" onclick=\"return addthis_sendto()\"><img src=\"{$Buttonimage}\" alt=\"Addthis\" border=\"0\"/></span></a><script type=\"text/javascript\" src=\"http://s7.addthis.com/js/200/addthis_widget.js\"></script>\n<!-- ADDTHIS BUTTON END -->\n";
         $code .= "</div>";
     }
     if ($shareservice == '2') {
         $code = "<div style=\"{$css}\">";
         $code .= "{$SharethisCode}\n";
         $code .= "</div>";
     }
     if ($shareservice == '3') {
         $code = "<div style=\"{$css}\">";
         $code .= "{$TellafriendCode}\n";
         $code .= "</div>";
     }
     if ($shareservice == '4') {
         $code = "<div style=\"{$css}\">";
         $code .= "{$CustomCode}\n";
         $code .= "</div>";
     }
     if ($show == '1') {
         $html = $article->text;
         $html .= $code;
         $article->text = $html;
     }
     if ($show == '2') {
         $html = $code;
         $html .= $article->text;
         $article->text = $html;
     }
     if ($show == '3') {
         $html = $code;
         $html .= $article->text;
         $html .= $code;
         $article->text = $html;
     }
 }
Ejemplo n.º 22
0
function mosGetLink($mitem, $level, $class_sfx = '')
{
    global $Itemid;
    $txt = '';
    $menuclass = '';
    $main = 'top';
    $router = JSite::getRouter();
    $mitem->url2 = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $mitem->id : $mitem->link . '&Itemid=' . $mitem->id;
    JRoute::_('$mitem->link');
    $menui = 'true';
    if ($menui == 'true') {
        $menu_params = new stdClass();
        $menu_params = new JParameter($mitem->params);
        $menu_image = $menu_params->def('menu_image', -1);
    }
    if ($mitem->url2[10] == "I") {
        if ($mitem->type != "url" && $mitem->type != "separator") {
            $sef_suf =& JFactory::getApplication();
            $sef_value = $sef_suf->getCfg('sef_suffix');
            $mitem->link = JRoute::_($mitem->alias);
            if ($sef_value == "1") {
                $mitem->link = "{$mitem->link}.html";
                $router = JSite::getRouter();
                $mitem->link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $mitem->id : $mitem->link . '&Itemid=' . $mitem->id;
            } else {
                if ($sef_value == "0") {
                    $router = JSite::getRouter();
                    $mitem->link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $mitem->id : $mitem->link . '&Itemid=' . $mitem->id;
                } else {
                    $mitem->link = $mitem->link;
                }
            }
        }
    }
    if ($mitem->id == 1) {
        $mitem->link = "";
    }
    switch ($mitem->browserNav) {
        case 1:
            if ($mitem->cnt > 0) {
                if ($level == 0) {
                    $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a class=\"main\" target=\"_window\"  href=\"{$mitem->link}\">{$mitem->name}</a></span></span>";
                    $main = "main";
                } else {
                    $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a class=\"sub\" target=\"_window\"  href=\"{$mitem->link}\">{$mitem->name}</a></span></span>";
                }
            } else {
                $txt = "<span><span><a href=\"{$mitem->link}\" class=\"sub\" target=\"_window\" >{$mitem->name}</a></span></span>\n";
            }
            break;
        case 2:
            if ($mitem->cnt > 0) {
                if ($level == 0) {
                    $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a href=\"#\" class=\"main\" onClick=\"javascript: window.open('{$mitem->link}', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"{$menuclass}\">{$mitem->name}</a></span></span>\n";
                    $main = "main";
                } else {
                    $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a href=\"#\" class=\"sub\" onClick=\"javascript: window.open('{$mitem->link}', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"{$menuclass}\">{$mitem->name}</a></span></span>\n";
                }
            } else {
                $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a href=\"#\" onClick=\"javascript: window.open('{$mitem->link}', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"{$menuclass}\">{$mitem->name}</a></span></span>\n";
            }
            break;
        case 3:
            if ($mitem->cnt > 0) {
                if ($level == 0) {
                    $txt = "<span><span><a class=\"main\">{$mitem->name}</a></span></span>";
                    $main = "main";
                } else {
                    $txt = "<span><span><a class=\"sub\">{$mitem->name}</a></span></span>";
                }
            } else {
                $txt = "<span><span><a>{$mitem->name}</a></span></span>\n";
            }
            break;
        default:
            if (isset($mitem->cnt) && $mitem->cnt > 0) {
                $random = rand() % 30000000000000;
                if ($level == 0) {
                    $LiveSite = JURI::base();
                    $txt = "<span class=\"s5_outer_active\"><span><a class=\"active\" href=\"{$mitem->link}\">{$mitem->name}<span class=\"s5_bottom_text\"></span></a><span class=\"s5_outerr\"></span></span></span>";
                    $main = "main";
                } else {
                    $txt = "<span class=\"parent\"><a class=\"parent\" href=\"{$mitem->link}\"> {$mitem->name}</a></span>";
                }
            } else {
                if ($level == 0) {
                    $LiveSite = JURI::base();
                    $txt = "<span class=\"s5_outer_active\"><span><a class=\"active\" href=\"{$mitem->link}\">{$mitem->name}<span class=\"s5_bottom_text\"></span></a><span class=\"s5_outerr\"></span></span></span>";
                } else {
                    if ($level > 0) {
                        $LiveSite = JURI::base();
                        $txt = "<span><span class=\"span_nonactive\"><a class=\"sub\" href=\"{$mitem->link}\">{$mitem->name}</a></span></span>";
                    }
                }
            }
            break;
    }
    return $txt;
}
Ejemplo n.º 23
0
 function getMenu($params)
 {
     $items = array();
     if ($params->get('menu')) {
         $menu =& JSite::getMenu();
         $items = $menu->getItems('menutype', $params->get('menu'));
     }
     foreach ($items as $item) {
         if (K2_JVERSION == '16') {
             $item->name = $item->title;
             $item->parent = $item->parent_id;
         }
         $index = $item->parent;
         $list = @$children[$index] ? $children[$index] : array();
         array_push($list, $item);
         $children[$index] = $list;
     }
     if (K2_JVERSION == '16') {
         $items = JHTML::_('menu.treerecurse', 1, '', array(), $children, 9999, 0, 0);
     } else {
         $items = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     }
     $links = array();
     foreach ($items as $item) {
         if (K2_JVERSION == '15') {
             $item->level = $item->sublevel;
             switch ($item->type) {
                 case 'separator':
                     continue;
                     break;
                 case 'url':
                     if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) {
                         $item->url = $item->link . '&amp;Itemid=' . $item->id;
                     } else {
                         $item->url = $item->link;
                     }
                     break;
                 default:
                     $router = JSite::getRouter();
                     $item->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $item->id : $item->link . '&Itemid=' . $item->id;
                     break;
             }
             $iParams = new JParameter($item->params);
             $iSecure = $iParams->def('secure', 0);
             if ($item->home == 1) {
                 $item->url = JURI::base();
             } elseif (strcasecmp(substr($item->url, 0, 4), 'http') && strpos($item->link, 'index.php?') !== false) {
                 $item->url = JRoute::_($item->url, true, $iSecure);
             } else {
                 $item->url = str_replace('&', '&amp;', $item->url);
             }
             $item->route = $item->url;
         } else {
             $item->flink = $item->link;
             switch ($item->type) {
                 case 'separator':
                     continue;
                 case 'url':
                     if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) {
                         $item->flink = $item->link . '&Itemid=' . $item->id;
                     }
                     break;
                 case 'alias':
                     $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions');
                     break;
                 default:
                     $router = JSite::getRouter();
                     if ($router->getMode() == JROUTER_MODE_SEF) {
                         $item->flink = 'index.php?Itemid=' . $item->id;
                     } else {
                         $item->flink .= '&Itemid=' . $item->id;
                     }
                     break;
             }
             if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) {
                 $item->flink = JRoute::_($item->flink, true, $item->params->get('secure'));
             } else {
                 $item->flink = JRoute::_($item->flink);
             }
             $item->route = $item->flink;
         }
         $links[] = $item;
     }
     return $links;
 }
Ejemplo n.º 24
0
 function _getItemData(&$params, $item)
 {
     $data = null;
     // 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->name . ']]></span>';
             $tmp->mid = $item->id;
             $tmp->parent = $item->parent;
         } else {
             return false;
         }
     } else {
         $tmp = clone $item;
         $tmp->name = '<span><![CDATA[' . $item->name . ']]></span>';
     }
     $iParams = new JParameter($tmp->params);
     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;
         }
         $image = '<img src="' . JURI::base(true) . '/images/stories/' . $iParams->get('menu_image') . '" ' . $imgalign . ' alt="' . $item->alias . '" />';
         if ($tmp->ionly) {
             $tmp->name = null;
         }
     } else {
         $image = null;
     }
     switch ($tmp->type) {
         case 'separator':
             return '<span class="separator">' . $image . $tmp->name . '</span>';
             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;
         default:
             $router = JSite::getRouter();
             $tmp->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $tmp->id : $tmp->link . '&Itemid=' . $tmp->id;
             break;
     }
     // Print a link if it exists
     if ($tmp->url != null) {
         // 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 . '">' . $image . $tmp->name . '</a>';
                 break;
             case 1:
                 // _blank
                 $data = '<a href="' . $tmp->url . '" target="_blank">' . $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;">' . $image . $tmp->name . '</a>';
                 break;
         }
     } else {
         $data = '<a>' . $image . $tmp->name . '</a>';
     }
     return $data;
 }
Ejemplo n.º 25
0
 function _getItemData(&$params, $item)
 {
     //Create the new Node
     $node = new RokNavMenuNode();
     $tmp = null;
     // 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 = $item->name;
             $tmp->mid = $item->id;
             $tmp->parent = $item->parent;
             $tmp->url = null;
             $tmp->nav = 'current';
         }
     }
     if ($item->type != 'menulink' || $item->type == 'menulink' && $tmp == null) {
         $tmp = clone $item;
         $tmp->name = $item->name;
         $tmp->mid = $tmp->id;
         $tmp->url = null;
         $tmp->nav = 'current';
     }
     $iParams = new JParameter($tmp->params);
     if ($params->get('menu_images') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
         $image = JURI::base(true) . '/images/stories/' . $iParams->get('menu_image');
         if ($tmp->ionly) {
             $tmp->name = null;
         }
     } else {
         $image = null;
     }
     switch ($tmp->type) {
         case 'separator':
             $tmp->outtype = 'separator';
             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;
             }
             $tmp->outtype = 'menuitem';
             break;
         default:
             $router = JSite::getRouter();
             $tmp->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $tmp->id : $tmp->link . '&Itemid=' . $tmp->id;
             $tmp->outtype = 'menuitem';
             break;
     }
     if ($tmp->url != null) {
         // set the target based on menu item options
         switch ($tmp->browserNav) {
             default:
             case 1:
                 $tmp->nav = 'new';
                 break;
             case 2:
                 $tmp->url = str_replace('index.php', 'index2.php', $tmp->url);
                 $tmp->nav = 'newnotool';
                 break;
             case 0:
             default:
                 $tmp->nav = 'current';
                 break;
         }
         // Get the final URL
         if ($tmp->home == 1) {
             // Set Home Links to the Base
             $tmp->url = JURI::base();
         } else {
             if ($tmp->type != 'separator' && $tmp->type != 'url') {
                 $iSecure = $iParams->def('secure', 0);
                 // Set Content links that can be put through JRoute through it
                 if (strcasecmp(substr($tmp->url, 0, 4), 'http') && strpos($tmp->url, 'index.php?') !== false) {
                     $prefix = '';
                     if ($this->_params->get('url_type', 'relative') == 'full') {
                         $uri =& JURI::getInstance();
                         $prefix = $uri->toString(array('scheme', 'host', 'port'));
                     }
                     $tmp->url = $prefix . JRoute::_($tmp->url, true, $iSecure);
                 } else {
                     if (strcasecmp(substr($tmp->url, 0, 4), 'http') && strpos($tmp->url, 'index.php2?') !== false) {
                     }
                 }
             } else {
                 if ($tmp->type == 'url') {
                     $tmp->url = str_replace('&', '&amp;', $tmp->url);
                 } else {
                 }
             }
         }
     }
     $node->id = $tmp->mid;
     $node->parent = $tmp->parent;
     $node->title = $tmp->name;
     $node->access = $tmp->access;
     $node->link = $tmp->url;
     $node->level = $item->sublevel;
     $node->image = $image;
     $node->alias = $tmp->alias;
     $node->nav = $tmp->nav;
     $node->setParameters($tmp->params);
     $node->type = $tmp->outtype;
     $node->order = $item->ordering;
     $node->addListItemClass("item" . $node->id);
     $node->addSpanClass($tmp->outtype);
     return $node;
 }
Ejemplo n.º 26
0
/**
* Contacts 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 the search it to be restricted to areas, null if search all
*/
function plgSearchJFNewsfeedslinks($text, $phrase = '', $ordering = '', $areas = null)
{
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    $registry = JFactory::getConfig();
    $lang = $registry->getValue("config.jflang");
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchNewsfeedAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin = JPluginHelper::getPlugin('search', 'jfnewsfeeds');
    $pluginParams = new JParameter($plugin->params);
    $limit = $pluginParams->def('search_limit', 50);
    $activeLang = $pluginParams->def('active_language_only', 0);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $wheres = array();
    switch ($phrase) {
        case 'exact':
            $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
            $where = "LOWER(jfc.value) LIKE " . $text;
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
                $wheres[] = "LOWER(jfc.value) LIKE " . $word;
            }
            $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
            break;
    }
    switch ($ordering) {
        case 'alpha':
            $order = 'a.name ASC';
            break;
        case 'category':
            $order = 'b.title ASC, a.name ASC';
            break;
        case 'oldest':
        case 'popular':
        case 'newest':
        default:
            $order = 'a.name ASC';
    }
    $searchNewsfeeds = JText::_('Newsfeeds');
    $query = 'SELECT a.id as contid, b.id as catid,  a.name AS title, "" AS created, a.link AS text,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(\':\', b.id, b.alias) ELSE b.id END as catslug, ' . ' b.title as btitle, ' . ' "1" AS browsernav,' . ' jfl.code as jflang, jfl.name as jflname' . ' FROM #__newsfeeds AS a' . ' INNER JOIN #__categories AS b ON b.id = a.catid' . "\n LEFT JOIN #__jf_content as jfc ON reference_id = a.id" . "\n LEFT JOIN #__languages as jfl ON jfc.language_id = jfl.id" . ' WHERE ( ' . $where . ' )' . ' AND a.published = 1' . ' AND b.published = 1' . ' AND b.access <= ' . (int) $user->get('aid') . "\n AND jfc.reference_table = 'newsfeeds'" . ($activeLang ? "\n AND jfl.code = '{$lang}'" : '') . ' GROUP BY a.id' . ' ORDER BY ' . $order;
    $db->setQuery($query, 0, $limit);
    $rows = $db->loadObjectList();
    foreach ($rows as $key => $row) {
        $rows[$key]->section = $db->Quote($searchNewsfeeds) . "/" . $row->btitle . " - " . $row->jflname;
        $rows[$key]->href = 'index.php?option=com_newsfeeds&view=newsfeed&catid=' . $row->catslug . '&id=' . $row->slug;
    }
    return $rows;
}
Ejemplo n.º 27
0
 /**
  * Constructor
  *
  * @access		public
  * @return		void
  */
 function __construct()
 {
     parent::__construct();
     global $mainframe, $cp_config;
     $session = JFactory::getSession();
     // configuration file
     require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_customproperties' . DS . 'cp_config.php';
     if (empty($cp_config)) {
         JError::raiseError(500, JText::_("CP_NON_CONFIG"));
     }
     $params = new JParameter('');
     $params->def('pageclass_sfx', $cp_config['pageclass_sfx']);
     $params->def('show_page_title', $cp_config['show_page_title']);
     //$params->def( 'header',				 	$cp_config['header'] != '' ? 			$cp_config['page_title'] 		: JText::_('Search') );
     $params->def('page_title', @$cp_config['page_title'] != '' ? $cp_config['page_title'] : JText::_('Search'));
     $params->def('use_joomfish', $cp_config['use_joomfish'] != "" ? $cp_config['use_joomfish'] : '0');
     $params->def('script_position', $cp_config['script_position'] != "" ? $cp_config['script_position'] : 'auto');
     $params->def('search_unauthorized', $cp_config['search_unauthorized'] != "" ? $cp_config['search_unauthorized'] : '1');
     $params->def('search_archived', $cp_config['search_archived'] != "" ? $cp_config['search_archived'] : '1');
     $params->def('use_itemid', $cp_config['use_itemid'] != "" ? $cp_config['use_itemid'] : '1');
     $params->def('result_acl', $cp_config['result_acl']);
     $params->def('frontend_tagging', $cp_config['frontend_tagging'] != '' ? $cp_config['frontend_tagging'] : '0');
     $params->def('editing_level', $cp_config['editing_level'] != '' ? $cp_config['editing_level'] : '1');
     $params->def('limit', $cp_config['limit'] != '' ? $cp_config['limit'] : $mainframe->getCfg('list_limit'));
     $params->def('search_sections', preg_replace('/[^0-9\\,]/', '', $cp_config['search_sections']));
     $params->def('default_ordering', $cp_config['default_ordering']);
     $params->def('ordering_field', $cp_config['ordering_field'] != "" ? $cp_config['ordering_field'] : '0');
     $params->def('use_cp_css', $cp_config['use_cp_css'] != "" ? $cp_config['use_cp_css'] : '1');
     $params->def('show_content_element_label', $cp_config['show_content_element_label'] != "" ? $cp_config['show_content_element_label'] : '0');
     $params->def('view', $cp_config['view'] != "" ? $cp_config['view'] : '2');
     $params->def('allowed_tags', $cp_config['allowed_tags'] != "" ? $cp_config['allowed_tags'] : "<h3><h4><h5><a><p>");
     $params->def('text_length', $cp_config['text_length'] != '' ? $cp_config['text_length'] : '200');
     $params->def('show_result_summary', $cp_config['show_result_summary'] != '' ? $cp_config['show_result_summary'] : '0');
     $params->def('show_content_element', $cp_config['show_content_element'] != "" ? $cp_config['show_content_element'] : '1');
     $params->def('show_create_date', $cp_config['show_create_date'] != "" ? $cp_config['show_create_date'] : '0');
     $params->def('show_section', $cp_config['show_section'] != "" ? $cp_config['show_section'] : '0');
     $params->def('linked_result_summary', $cp_config['linked_result_summary'] != '' ? $cp_config['linked_result_summary'] : '1');
     $params->def('search_header_tl', $cp_config['search_header_tl'] != "" ? $cp_config['search_header_tl'] : "1");
     $params->def('search_header_tr', $cp_config['search_header_tr'] != "" ? $cp_config['search_header_tr'] : "2");
     $params->def('search_header_bl', $cp_config['search_header_bl'] != "" ? $cp_config['search_header_bl'] : "3");
     $params->def('search_header_br', $cp_config['search_header_br'] != "" ? $cp_config['search_header_br'] : "4");
     $params->def('image_thumbnail', $cp_config['image_thumbnail'] != "" ? $cp_config['image_thumbnail'] : "1");
     $params->def('thumb_width', $cp_config['thumb_width'] != "" ? $cp_config['thumb_width'] : "100");
     $params->def('thumb_height', $cp_config['thumb_height'] != "" ? $cp_config['thumb_height'] : "100");
     $params->def('keep_aspect', $cp_config['keep_aspect'] != "" ? $cp_config['keep_aspect'] : "1");
     $params->def('image_quality', $cp_config['image_quality'] != "" ? $cp_config['image_quality'] : "75");
     $params->def('debug', $cp_config['debug'] != "" ? $cp_config['debug'] : "0");
     $params->def('show_tags', $cp_config['show_tags'] != "" ? $cp_config['show_tags'] : '0');
     $params->def('linked_tags', $cp_config['linked_tags'] != '' ? $cp_config['linked_tags'] : '1');
     $params->def('show_tag_name', $cp_config['show_tag_name'] != "" ? $cp_config['show_tag_name'] : '0');
     $params->def('url_format', $cp_config['url_format'] != "" ? $cp_config['url_format'] : '0');
     $this->_params =& $params;
     //USING session to store default co ordering
     if ($ordering = JRequest::getVar('ordering')) {
         $this->_ordering = $ordering;
         $session->set('cp_ordering', "{$ordering}");
     } elseif ($ordering = $session->get('cp_ordering')) {
         $this->_ordering = $ordering;
     } else {
         $this->_ordering = $cp_config['default_ordering'];
     }
 }
Ejemplo n.º 28
0
 function plgSearchFSSAnnounce($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys(plgSearchFSSAnnounceAreas()))) {
             return array();
         }
     }
     $plugin = JPluginHelper::getPlugin('search', 'fss_announce');
     if ($plugin) {
         $pluginParams = new JParameter($plugin->params);
     } else {
         $pluginParams = new JParameter(null);
     }
     $limit = $pluginParams->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $wheres = array();
     switch ($phrase) {
         case 'exact':
             $text = $db->Quote('%' . FSSJ3Helper::getEscaped($db, $text, true) . '%', false);
             $wheres2 = array();
             $wheres2[] = 'LOWER(a.title) LIKE ' . $text;
             $wheres2[] = 'LOWER(a.subtitle) LIKE ' . $text;
             $wheres2[] = 'LOWER(a.body) LIKE ' . $text;
             $where = '(' . implode(') OR (', $wheres2) . ')';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $wheres = array();
             foreach ($words as $word) {
                 $word = $db->Quote('%' . FSSJ3Helper::getEscaped($db, $word, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = 'LOWER(a.title) LIKE ' . $word;
                 $wheres2[] = 'LOWER(a.subtitle) LIKE ' . $word;
                 $wheres2[] = 'LOWER(a.body) LIKE ' . $word;
                 $wheres[] = implode(' OR ', $wheres2);
             }
             $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
             break;
     }
     switch ($ordering) {
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'oldest':
         case 'popular':
         case 'newest':
         default:
             $order = 'a.title ASC';
     }
     $searchFAQs = JText::_("ANNOUNCE");
     $query = 'SELECT a.title AS title,' . ' CONCAT(a.subtitle, " ", a.body) as text, ' . ' a.id, added as created, 2 as browsernav, "" as section' . ' FROM #__fss_announce AS a';
     $ow = "( " . $where . ")";
     $where = array();
     $where[] = $ow;
     $where[] = "a.published = 1";
     $where[] = 'language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')';
     $user = JFactory::getUser();
     $where[] = 'access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')';
     if (count($where) > 0) {
         $query .= " WHERE " . implode(" AND ", $where);
     }
     $query .= ' ORDER BY ' . $order;
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     foreach ($rows as $key => $row) {
         $rows[$key]->href = 'index.php?option=com_fss&view=announce&announceid=' . $row->id;
     }
     return $rows;
 }
Ejemplo n.º 29
0
/**
* 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 integer The state to search for -1=archived, 0=unpublished, 1=published [default]
* @param string A prefix for the section label, eg, 'Archived '
*/
function plgSearchJFContent($text, $phrase = '', $ordering = '', $areas = null)
{
    global $mainframe;
    $registry = JFactory::getConfig();
    $lang = $registry->getValue("config.jflang");
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
    if (is_array($areas)) {
        // Use main content search area
        if (!array_intersect($areas, array_keys(plgSearchContentAreas()))) {
            return array();
        }
    }
    // load plugin params info
    $plugin = JPluginHelper::getPlugin('search', 'jfcontent');
    $pluginParams = new JParameter($plugin->params);
    $sContent = $pluginParams->get('search_content', 1);
    $sUncategorised = $pluginParams->get('search_uncategorised', 1);
    $sArchived = $pluginParams->get('search_archived', 1);
    $limit = $pluginParams->def('search_limit', 50);
    $activeLang = $pluginParams->def('active_language_only', 0);
    $nullDate = $db->getNullDate();
    $date = JFactory::getDate();
    $now = $date->toMySQL();
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $wheres = array();
    switch ($phrase) {
        case 'exact':
            $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
            $where = "LOWER(jfc.value) LIKE " . $text;
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
                $wheres[] = "LOWER(jfc.value) LIKE " . $word;
            }
            $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
            break;
    }
    $morder = '';
    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;
    }
    $rows = array();
    // search articles
    if ($sContent && $limit > 0) {
        // NB can't use concat since Joomfish won't translate sub-values
        $query = 'SELECT a.id as contid, b.id as catid,  u.id AS secid, a.title AS title, a.created AS created,' . ' a.introtext, a.fulltext, ' . ' u.title as sectitle, b.title as cattitle,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug,' . ' "2" AS browsernav, ' . ' jfl.code as jflang, jfl.title as jflname' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS b ON b.id=a.catid' . ' INNER JOIN #__sections AS u ON u.id = a.sectionid' . "\n LEFT JOIN #__jf_content as jfc ON reference_id = a.id" . "\n LEFT JOIN #__languages as jfl ON jfc.language_id = jfl.lang_id" . ' WHERE ( ' . $where . ' )' . ' AND a.state = 1' . ' AND u.published = 1' . ' AND b.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND b.access <= ' . (int) $user->get('aid') . ' AND u.access <= ' . (int) $user->get('aid') . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . "\n AND jfc.reference_table = 'content'" . ($activeLang ? "\n AND jfl.code = '{$lang}'" : '') . ' GROUP BY a.id' . ' ORDER BY ' . $order;
        $db->setQuery($query, 0, $limit);
        $list = $db->loadObjectList();
        $limit -= count($list);
        if (isset($list)) {
            foreach ($list as $key => $item) {
                $list[$key]->text = $item->introtext . $item->fulltext;
                $list[$key]->section = $item->sectitle . "/" . $item->cattitle . " - " . $item->jflname;
                $list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->secid);
            }
        }
        $rows[] = $list;
    }
    // search uncategorised content
    if ($sUncategorised && $limit > 0) {
        $query = 'SELECT a.id as contid, a.title AS title, a.created AS created,' . ' a.introtext AS text,' . ' "2" as browsernav, "' . $db->Quote(JText::_('Uncategorised Content')) . '" AS section,' . ' jfl.code as jflang, jfl.title as jflname' . ' FROM #__content AS a' . "\n LEFT JOIN #__jf_content as jfc ON reference_id = a.id" . "\n LEFT JOIN #__languages as jfl ON jfc.language_id = jfl.lang_id" . ' WHERE (' . $where . ')' . ' AND a.state = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND a.sectionid = 0' . ' AND a.catid = 0' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . "\n AND jfc.reference_table = 'content'" . ($activeLang ? "\n AND jfl.code = '{$lang}'" : '') . ' ORDER BY ' . ($morder ? $morder : $order);
        $db->setQuery($query, 0, $limit);
        $list2 = $db->loadObjectList();
        $limit -= count($list2);
        if (isset($list2)) {
            foreach ($list2 as $key => $item) {
                $list2[$key]->href = ContentHelperRoute::getArticleRoute($item->contid);
            }
        }
        $rows[] = $list2;
    }
    // search archived content
    if ($sArchived && $limit > 0) {
        $searchArchived = JText::_('Archived');
        $query = 'SELECT a.title AS title, a.id as conti, b.id as catid,  u.id AS secid,' . ' a.created AS created,' . ' a.introtext AS text,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug,' . ' u.title as sectitle, b.title as cattitle,' . ' u.id AS sectionid,' . ' "2" AS browsernav,' . ' jfl.code as jflang, jfl.title as jflname' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS b ON b.id=a.catid AND b.access <= ' . $user->get('gid') . ' INNER JOIN #__sections AS u ON u.id = a.sectionid' . "\n LEFT JOIN #__jf_content as jfc ON reference_id = a.id" . "\n LEFT JOIN #__languages as jfl ON jfc.language_id = jfl.lang_id" . ' WHERE ( ' . $where . ' )' . ' AND a.state = -1' . ' AND u.published = 1' . ' AND b.published = 1' . ' AND a.access <= ' . (int) $user->get('aid') . ' AND b.access <= ' . (int) $user->get('aid') . ' AND u.access <= ' . (int) $user->get('aid') . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )' . "\n AND jfc.reference_table = 'content'" . ($activeLang ? "\n AND jfl.code = '{$lang}'" : '') . ' ORDER BY ' . $order;
        $db->setQuery($query, 0, $limit);
        $list3 = $db->loadObjectList();
        if (isset($list3)) {
            foreach ($list3 as $key => $item) {
                $list3[$key]->section = $item->sectitle . "/" . $item->cattitle . " - " . $item->jflname;
                $list3[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid);
            }
        }
        $rows[] = $list3;
    }
    $results = array();
    if (count($rows)) {
        foreach ($rows as $row) {
            $results = array_merge($results, (array) $row);
        }
    }
    return $results;
}
Ejemplo n.º 30
0
/**
 * Cloak all emails in text from spambots via Javascript.
 *
 * @param string The string to be cloaked.
 * @param array Additional parameters. Parameter "mode" (integer, default 1)
 * replaces addresses with "mailto:" links if nonzero.
 * @return boolean True on success.
 */
function plgEmailCloak(&$text, &$params)
{
    /*
     * Check for presence of {emailcloak=off} which is explicits disables this
     * bot for the item.
     */
    if (JString::strpos($text, '{emailcloak=off}') !== false) {
        $text = JString::str_ireplace('{emailcloak=off}', '', $text);
        return true;
    }
    // Simple performance check to determine whether bot should process further.
    if (JString::strpos($text, '@') === false) {
        return true;
    }
    $plugin =& JPluginHelper::getPlugin('content', 'emailcloak');
    // Load plugin params info
    $pluginParams = new JParameter($plugin->params);
    $mode = $pluginParams->def('mode', 1);
    // any@email.address.com
    $searchEmail = '([\\w\\.\\-]+\\@(?:[a-z0-9\\.\\-]+\\.)+(?:[a-z0-9\\-]{2,4}))';
    // any@email.address.com?subject=anyText
    $searchEmailLink = $searchEmail . '([?&][\\x20-\\x7f][^"<>]+)';
    // anyText
    $searchText = '([\\x20-\\x7f][^<>]+)';
    /*
     * Search for derivatives of link code <a href="mailto:email@amail.com"
     * >email@amail.com</a>
     */
    $pattern = plgContentEmailCloak_searchPattern($searchEmail, $searchEmail);
    while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) {
        $mail = $regs[1][0];
        $mailText = $regs[2][0];
        // Check to see if mail text is different from mail addy
        $replacement = JHTML::_('email.cloak', $mail, $mode, $mailText);
        // Replace the found address with the js cloaked email
        $text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
    }
    /*
     * Search for derivatives of link code <a href="mailto:email@amail.com">
     * anytext</a>
     */
    $pattern = plgContentEmailCloak_searchPattern($searchEmail, $searchText);
    while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) {
        $mail = $regs[1][0];
        $mailText = $regs[2][0];
        $replacement = JHTML::_('email.cloak', $mail, $mode, $mailText, 0);
        // Replace the found address with the js cloaked email
        $text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
    }
    /*
     * Search for derivatives of link code <a href="mailto:email@amail.com?
     * subject=Text">email@amail.com</a>
     */
    $pattern = plgContentEmailCloak_searchPattern($searchEmailLink, $searchEmail);
    while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) {
        $mail = $regs[1][0] . $regs[2][0];
        $mailText = $regs[3][0];
        // Needed for handling of Body parameter
        $mail = str_replace('&amp;', '&', $mail);
        // Check to see if mail text is different from mail addy
        $replacement = JHTML::_('email.cloak', $mail, $mode, $mailText);
        // Replace the found address with the js cloaked email
        $text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
    }
    /*
     * Search for derivatives of link code <a href="mailto:email@amail.com?
     * subject=Text">anytext</a>
     */
    $pattern = plgContentEmailCloak_searchPattern($searchEmailLink, $searchText);
    while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) {
        $mail = $regs[1][0] . $regs[2][0];
        $mailText = $regs[3][0];
        // Needed for handling of Body parameter
        $mail = str_replace('&amp;', '&', $mail);
        $replacement = JHTML::_('email.cloak', $mail, $mode, $mailText, 0);
        // Replace the found address with the js cloaked email
        $text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
    }
    // Search for plain text email@amail.com
    $pattern = '~' . $searchEmail . '([^a-z0-9]|$)~i';
    while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) {
        $mail = $regs[1][0];
        $replacement = JHTML::_('email.cloak', $mail, $mode);
        // Replace the found address with the js cloaked email
        $text = substr_replace($text, $replacement, $regs[1][1], strlen($mail));
    }
    return true;
}