/**
* 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 botSearchNewsfeedslinks($text, $phrase = '', $ordering = '')
{
    global $database, $my, $_MAMBOTS;
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_search_mambot_params['newsfeeds'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'newsfeeds.searchbot'" . "\n AND folder = 'search'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_search_mambot_params['newsfeeds'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_search_mambot_params['newsfeeds'];
    $botParams = new mosParameters($mambot->params);
    $limit = $botParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $wheres = array();
    switch ($phrase) {
        case 'exact':
            $wheres2 = array();
            $wheres2[] = "LOWER(a.name) LIKE '%{$text}%'";
            $wheres2[] = "LOWER(a.link) LIKE '%{$text}%'";
            $where = '(' . implode(') OR (', $wheres2) . ')';
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $wheres2 = array();
                $wheres2[] = "LOWER(a.name) LIKE '%{$word}%'";
                $wheres2[] = "LOWER(a.link) LIKE '%{$word}%'";
                $wheres[] = implode(' OR ', $wheres2);
            }
            $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';
    }
    $query = "SELECT a.name AS title," . "\n '' AS created," . "\n a.link AS text," . "\n CONCAT_WS( ' / '," . $database->Quote(_SEARCH_NEWSFEEDS) . ", b.title )AS section," . "\n CONCAT( 'index.php?option=com_newsfeeds&task=view&feedid=', a.id ) AS href," . "\n '1' AS browsernav" . "\n FROM #__newsfeeds AS a" . "\n INNER JOIN #__categories AS b ON b.id = a.catid" . "\n WHERE ( {$where} )" . "\n AND a.published = 1" . "\n AND b.published = 1" . "\n AND b.access <= " . (int) $my->gid . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $rows = $database->loadObjectList();
    return $rows;
}
Esempio n. 2
0
/**
*/
function botMosImage($published, &$row, &$params, $page = 0)
{
    global $database, $_MAMBOTS;
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, 'mosimage') === false) {
        return true;
    }
    // expression to search for
    $regex = '/{mosimage\\s*.*?}/i';
    // check whether mosimage has been disabled for page
    // check whether mambot has been unpublished
    if (!$published || !$params->get('image')) {
        $row->text = preg_replace($regex, '', $row->text);
        return true;
    }
    //count how many {mosimage} are in introtext if it is set to hidden.
    $introCount = 0;
    if (!$params->get('introtext') & !$params->get('intro_only')) {
        preg_match_all($regex, $row->introtext, $matches);
        $introCount = count($matches[0]);
    }
    // find all instances of mambot and put in $matches
    preg_match_all($regex, $row->text, $matches);
    // Number of mambots
    $count = count($matches[0]);
    // mambot only processes if there are any instances of the mambot in the text
    if ($count) {
        // check if param query has previously been processed
        if (!isset($_MAMBOTS->_content_mambot_params['mosimage'])) {
            // load mambot params info
            $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mosimage'" . "\n AND folder = 'content'";
            $database->setQuery($query);
            $database->loadObject($mambot);
            // save query to class variable
            $_MAMBOTS->_content_mambot_params['mosimage'] = $mambot;
        }
        // pull query data from class variable
        $mambot = $_MAMBOTS->_content_mambot_params['mosimage'];
        $botParams = new mosParameters($mambot->params);
        $botParams->def('padding');
        $botParams->def('margin');
        $botParams->def('link', 0);
        $images = processImages($row, $botParams, $introCount);
        // store some vars in globals to access from the replacer
        $GLOBALS['botMosImageCount'] = 0;
        $GLOBALS['botMosImageParams'] =& $botParams;
        $GLOBALS['botMosImageArray'] =& $images;
        //$GLOBALS['botMosImageArray'] 	=& $combine;
        // perform the replacement
        $row->text = preg_replace_callback($regex, 'botMosImage_replacer', $row->text);
        // clean up globals
        unset($GLOBALS['botMosImageCount']);
        unset($GLOBALS['botMosImageMask']);
        unset($GLOBALS['botMosImageArray']);
        unset($GLOBALS['botJosIntroCount']);
        return true;
    }
}
Esempio n. 3
0
/**
* Saves the record from an edit form submit
* @param string The current GET/POST option
*/
function saveSyndicate($option)
{
    global $database;
    josSpoofCheck();
    $params = mosGetParam($_POST, 'params', '');
    if (is_array($params)) {
        $txt = array();
        foreach ($params as $k => $v) {
            $txt[] = "{$k}={$v}";
        }
        $_POST['params'] = mosParameters::textareaHandling($txt);
    }
    $id = intval(mosGetParam($_POST, 'id', '17'));
    $row = new mosComponent($database);
    $row->load($id);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $msg = 'Settings successfully Saved';
    mosRedirect('index2.php?option=' . $option, $msg);
}
/**
* 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
*/
function botSearchSections($text, $phrase = '', $ordering = '')
{
    global $database, $my, $_MAMBOTS;
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_search_mambot_params['sections'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'sections.searchbot'" . "\n AND folder = 'search'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_search_mambot_params['sections'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_search_mambot_params['sections'];
    $botParams = new mosParameters($mambot->params);
    $limit = $botParams->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';
    }
    $query = "SELECT a.name AS title," . "\n a.description AS text," . "\n '' AS created," . "\n '2' AS browsernav," . "\n a.id AS secid, m.id AS menuid, m.type AS menutype" . "\n FROM #__sections AS a" . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id" . "\n WHERE ( a.name LIKE '%{$text}%'" . "\n OR a.title LIKE '%{$text}%'" . "\n OR a.description LIKE '%{$text}%' )" . "\n AND a.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND ( m.type = 'content_section' OR m.type = 'content_blog_section' )" . "\n GROUP BY a.id" . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $rows = $database->loadObjectList();
    $count = count($rows);
    for ($i = 0; $i < $count; $i++) {
        if ($rows[$i]->menutype == 'content_section') {
            $rows[$i]->href = 'index.php?option=com_content&task=section&id=' . $rows[$i]->secid . '&Itemid=' . $rows[$i]->menuid;
            $rows[$i]->section = _SEARCH_SECLIST;
        }
        if ($rows[$i]->menutype == 'content_blog_section') {
            $rows[$i]->href = 'index.php?option=com_content&task=blogsection&id=' . $rows[$i]->secid . '&Itemid=' . $rows[$i]->menuid;
            $rows[$i]->section = _SEARCH_SECBLOG;
        }
    }
    return $rows;
}
 function getObjectTitle($id)
 {
     $title = 'JComments';
     $menu = jc_com_jcomments::getMenuItem($id);
     if ($menu != '') {
         if (JCOMMENTS_JVERSION == '1.5') {
             $params = new JParameter($menu->params);
         } else {
             $params = new mosParameters($menu->params);
         }
         $title = $params->get('page_title');
         if ($title == '') {
             $title = $menu->name;
         }
     }
     return $title;
 }
function virtuemart_is_installed()
{
    global $database, $mosConfig_absolute_path, $mosConfig_dbprefix, $VMVERSION, $shortversion, $myVersion, $version_info;
    if (is_null($database) && class_exists('jfactory')) {
        $database = JFactory::getDBO();
    }
    //add VirtueMart admin menu image
    $database->setQuery("UPDATE #__components SET admin_menu_img = '../components/com_virtuemart/shop_image/ps_image/menu_icon.png' WHERE admin_menu_link = 'option=com_virtuemart'");
    $database->query();
    $option = 'com_virtuemart';
    $installfile = dirname(__FILE__) . "/install.php";
    $database->setQuery("SHOW TABLES LIKE '" . $mosConfig_dbprefix . "vm_%'");
    $vm_tables = $database->loadObjectList();
    if (file_exists($mosConfig_absolute_path . '/administrator/components/' . $option . '/classes/htmlTools.class.php') && count($vm_tables) > 30) {
        // VirtueMart is installed! But is it an older version that needs to be updated?
        $database->setQuery('SELECT id, params FROM `#__components` WHERE name = \'virtuemart_version\'');
        $database->loadObject($old_version);
        if ($old_version && file_exists($mosConfig_absolute_path . '/administrator/components/com_virtuemart/classes/htmlTools.class.php')) {
            $version_info = new mosParameters($old_version->params);
            include_once $mosConfig_absolute_path . '/administrator/components/' . $option . '/version.php';
            $VMVERSION = new vmVersion();
            $result = version_compare($version_info->get('RELEASE'), '1.1.0');
            if ($result == -1) {
                return false;
            }
        }
        @unlink($installfile);
        if (file_exists($installfile) || !file_exists(dirname(__FILE__) . "/virtuemart.cfg.php")) {
            die('<h2>Virtuemart Installation Notice</h2>
			<p>You already have installed VirtueMart.</p>
			<p>You MUST 
			<ol>
				<li>DELETE the file <strong>' . $installfile . '</strong>,</li>
				<li>RENAME the file <strong>virtuemart.cfg-dist.php</strong> to <strong>virtuemart.cfg.php</strong></li>
			</ol>before you can use VirtueMart.
			</p>');
        } else {
            header('Location: index2.php?option=com_virtuemart');
            echo '<script type="text/javascript">document.location=\'' . $GLOBALS['mosConfig_live_site'] . '/administrator/index2.php?option=com_virtuemart\';</script>';
            exit;
        }
    }
    return false;
}
/**
* 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 botSearchContacts($text, $phrase = '', $ordering = '')
{
    global $database, $my, $_MAMBOTS;
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_search_mambot_params['contacts'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'contacts.searchbot'" . "\n AND folder = 'search'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_search_mambot_params['contacts'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_search_mambot_params['contacts'];
    $botParams = new mosParameters($mambot->params);
    $limit = $botParams->def('search_limit', 50);
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $section = _CONTACT_TITLE;
    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';
            break;
    }
    $query = "SELECT a.name AS title," . "\n CONCAT_WS( ', ', a.name, a.con_position, a.misc ) AS text," . "\n '' AS created," . "\n CONCAT_WS( ' / ', " . $database->Quote($section) . ", b.title ) AS section," . "\n '2' AS browsernav," . "\n CONCAT( 'index.php?option=com_contact&task=view&contact_id=', a.id ) AS href" . "\n FROM #__contact_details AS a" . "\n INNER JOIN #__categories AS b ON b.id = a.catid" . "\n WHERE ( a.name LIKE '%{$text}%'" . "\n OR a.misc LIKE '%{$text}%'" . "\n OR a.con_position LIKE '%{$text}%'" . "\n OR a.address LIKE '%{$text}%'" . "\n OR a.suburb LIKE '%{$text}%'" . "\n OR a.state LIKE '%{$text}%'" . "\n OR a.country LIKE '%{$text}%'" . "\n OR a.postcode LIKE '%{$text}%'" . "\n OR a.telephone LIKE '%{$text}%'" . "\n OR a.fax LIKE '%{$text}%' )" . "\n AND a.published = 1" . "\n AND b.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND b.access <= " . (int) $my->gid . "\n GROUP BY a.id" . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $rows = $database->loadObjectList();
    return $rows;
}
function botExtendedMenuSourceWeblinks_onLoadMenu(&$menuLoader, $name = '')
{
    global $database;
    $botName = 'bot_exmenu_source_weblinks';
    // load parameters
    $database->setQuery('SELECT m.params FROM #__mambots AS m WHERE element = \'' . $botName . '\' AND folder = \'exmenu\'');
    $params = new mosParameters($database->loadResult());
    $params->def('source_name', 'weblinks');
    if ($name != $params->get('source_name')) {
        return FALSE;
    }
    $rootMenuNode =& $menuLoader->getRootMenuNode();
    $database->setQuery('SELECT * FROM #__weblinks WHERE published = 1 ORDER BY hits DESC, title LIMIT 10');
    $rows = $database->loadObjectList();
    foreach (array_keys($rows) as $key) {
        $row =& $rows[$key];
        $menuNode =& $menuLoader->getEmptyMenuNode();
        $menuNode->type = 'url';
        $menuNode->link = $row->url;
        $menuNode->name = $row->title;
        $menuLoader->addMenuNode($rootMenuNode, $menuNode);
    }
    return TRUE;
}
/**
* Mambot that loads module positions within content
*/
function botMosLoadPosition($published, &$row, &$params, $page = 0)
{
    global $database, $_MAMBOTS;
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, 'mosloadposition') === false) {
        return true;
    }
    // expression to search for
    $regex = '/{mosloadposition\\s*.*?}/i';
    // check whether mambot has been unpublished
    if (!$published) {
        $row->text = preg_replace($regex, '', $row->text);
        return true;
    }
    // find all instances of mambot and put in $matches
    preg_match_all($regex, $row->text, $matches);
    // Number of mambots
    $count = count($matches[0]);
    // mambot only processes if there are any instances of the mambot in the text
    if ($count) {
        // check if param query has previously been processed
        if (!isset($_MAMBOTS->_content_mambot_params['mosloadposition'])) {
            // load mambot params info
            $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mosloadposition'" . "\n AND folder = 'content'";
            $database->setQuery($query);
            $database->loadObject($mambot);
            // save query to class variable
            $_MAMBOTS->_content_mambot_params['mosloadposition'] = $mambot;
        }
        // pull query data from class variable
        $mambot = $_MAMBOTS->_content_mambot_params['mosloadposition'];
        $botParams = new mosParameters($mambot->params);
        $style = $botParams->def('style', -2);
        processPositions($row, $matches, $count, $regex, $style);
    }
}
 function saveMenu($option, $task)
 {
     global $database;
     $params = mosGetParam($_POST, 'params', '');
     $secids = mosGetParam($_POST, 'secid', array());
     $secid = implode(',', $secids);
     $params[sectionid] = $secid;
     if (is_array($params)) {
         $txt = array();
         foreach ($params as $k => $v) {
             $txt[] = "{$k}={$v}";
         }
         $_POST['params'] = mosParameters::textareaHandling($txt);
     }
     $row = new mosMenu($database);
     if (!$row->bind($_POST)) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     if (count($secids) == 1 && $secids[0] != '') {
         $row->link = str_replace('id=0', 'id=' . $secids[0], $row->link);
         $row->componentid = $secids[0];
     }
     if (!$row->check()) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     if (!$row->store()) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     $row->checkin();
     $row->updateOrder("menutype='{$row->menutype}' AND parent='{$row->parent}'");
     $msg = 'Menu item Saved';
     switch ($task) {
         case 'apply':
             mosRedirect('index2.php?option=' . $option . '&menutype=' . $row->menutype . '&task=edit&id=' . $row->id, $msg);
             break;
         case 'save':
         default:
             mosRedirect('index2.php?option=' . $option . '&menutype=' . $row->menutype, $msg);
             break;
     }
 }
Esempio n. 11
0
 function saveMenu($option, $task)
 {
     global $database;
     $params = mosGetParam($_POST, 'params', '');
     $params[url] = mosGetParam($_POST, 'url', '');
     if (is_array($params)) {
         $txt = array();
         foreach ($params as $k => $v) {
             $txt[] = "{$k}={$v}";
         }
         $_POST['params'] = mosParameters::textareaHandling($txt);
     }
     $row = new mosMenu($database);
     if (!$row->bind($_POST)) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     if (!$row->check()) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     if (!$row->store()) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     $row->checkin();
     $row->updateOrder('menutype = ' . $database->Quote($row->menutype) . ' AND parent = ' . (int) $row->parent);
     $msg = 'Item de menu salvo';
     switch ($task) {
         case 'apply':
             mosRedirect('index2.php?option=' . $option . '&menutype=' . $row->menutype . '&task=edit&id=' . $row->id, $msg);
             break;
         case 'save':
         default:
             mosRedirect('index2.php?option=' . $option . '&menutype=' . $row->menutype, $msg);
             break;
     }
 }
Esempio n. 12
0
function showWrap($option)
{
    global $database, $Itemid, $mainframe;
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('back_button', $mainframe->getCfg('back_button'));
    $params->def('scrolling', 'auto');
    $params->def('page_title', '1');
    $params->def('pageclass_sfx', '');
    $params->def('header', $menu->name);
    $params->def('height', '500');
    $params->def('height_auto', '0');
    $params->def('width', '100%');
    $params->def('add', '1');
    $url = $params->def('url', '');
    $row = new stdClass();
    if ($params->get('add')) {
        // adds 'http://' if none is set
        if (substr($url, 0, 1) == '/') {
            // relative url in component. use server http_host.
            $row->url = 'http://' . $_SERVER['HTTP_HOST'] . $url;
        } elseif (!strstr($url, 'http') && !strstr($url, 'https')) {
            $row->url = 'http://' . $url;
        } else {
            $row->url = $url;
        }
    } else {
        $row->url = $url;
    }
    // auto height control
    if ($params->def('height_auto')) {
        $row->load = 'onload="iFrameHeight()"';
    } else {
        $row->load = '';
    }
    $mainframe->SetPageTitle($menu->name);
    HTML_wrapper::displayWrap($row, $params, $menu);
}
Esempio n. 13
0
/**
* Compiles information to add or edit a section
* @param database A database connector object
* @param string The name of the category section
* @param integer The unique id of the category to edit (0 if new)
* @param string The name of the current user
*/
function editSection($uid = 0, $scope = '', $option)
{
    global $database, $my, $mainframe;
    $row = new mosSection($database);
    // load the row from the db table
    $row->load((int) $uid);
    // fail if checked out not by 'me'
    if ($row->isCheckedOut($my->id)) {
        $msg = 'The section ' . $row->title . ' is currently being edited by another administrator';
        mosRedirect('index2.php?option=' . $option . '&scope=' . $row->scope . '&mosmsg=' . $msg);
    }
    $selected_folders = NULL;
    if ($uid) {
        $row->checkout($my->id);
        if ($row->id > 0) {
            $query = "SELECT *" . "\n FROM #__menu" . "\n WHERE componentid = " . (int) $row->id . "\n AND ( type = 'content_archive_section' OR type = 'content_blog_section' OR type = 'content_section' )";
            $database->setQuery($query);
            $menus = $database->loadObjectList();
            $count = count($menus);
            for ($i = 0; $i < $count; $i++) {
                switch ($menus[$i]->type) {
                    case 'content_section':
                        $menus[$i]->type = 'Section Table';
                        break;
                    case 'content_blog_section':
                        $menus[$i]->type = 'Section Blog';
                        break;
                    case 'content_archive_section':
                        $menus[$i]->type = 'Section Blog Archive';
                        break;
                }
            }
        } else {
            $menus = array();
        }
        // handling for MOSImage directories
        if (trim($row->params)) {
            // get params definitions
            $params = new mosParameters($row->params, $mainframe->getPath('com_xml', 'com_sections'), 'component');
            $temps = $params->get('imagefolders', '');
            $temps = explode(',', $temps);
            foreach ($temps as $temp) {
                $selected_folders[] = mosHTML::makeOption($temp, $temp);
            }
        } else {
            $selected_folders[] = mosHTML::makeOption('*1*');
        }
    } else {
        $row->scope = $scope;
        $row->published = 1;
        $menus = array();
        // handling for MOSImage directories
        $selected_folders[] = mosHTML::makeOption('*1*');
    }
    // build the html select list for section types
    $types[] = mosHTML::makeOption('', 'Select Type');
    $types[] = mosHTML::makeOption('content_section', 'Section List');
    $types[] = mosHTML::makeOption('content_blog_section', 'Section Blog');
    $types[] = mosHTML::makeOption('content_archive_section', 'Section Archive Blog');
    $lists['link_type'] = mosHTML::selectList($types, 'link_type', 'class="inputbox" size="1"', 'value', 'text');
    // build the html select list for ordering
    $query = "SELECT ordering AS value, title AS text" . "\n FROM #__sections" . "\n WHERE scope=" . $database->Quote($row->scope) . " ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $uid, $query);
    // build the select list for the image positions
    $active = $row->image_position ? $row->image_position : 'left';
    $lists['image_position'] = mosAdminMenus::Positions('image_position', $active, NULL, 0);
    // build the html select list for images
    $lists['image'] = mosAdminMenus::Images('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published);
    // build the html select list for menu selection
    $lists['menuselect'] = mosAdminMenus::MenuSelect();
    // list of folders in images/stories/
    $imgFiles = recursive_listdir(COM_IMAGE_BASE);
    $len = strlen(COM_IMAGE_BASE);
    // handling for MOSImage directories
    $folders[] = mosHTML::makeOption('*1*', 'All');
    $folders[] = mosHTML::makeOption('*0*', 'None');
    $folders[] = mosHTML::makeOption('*#*', '---------------------');
    $folders[] = mosHTML::makeOption('/');
    foreach ($imgFiles as $file) {
        $folders[] = mosHTML::makeOption(substr($file, $len));
    }
    $lists['folders'] = mosHTML::selectList($folders, 'folders[]', 'class="inputbox" size="17" multiple="multiple"', 'value', 'text', $selected_folders);
    sections_html::edit($row, $option, $lists, $menus);
}
Esempio n. 14
0
 function vcard()
 {
     $contact = new mosContact();
     $contact->load($this->contact_id);
     $params = new mosParameters($contact->params);
     if (!$params->get('vcard')) {
         echo "<script>alert (\"" . T_('There are no vCards available for download.') . "\"); window.history.go(-1);</script>";
         exit(0);
     }
     $name = explode(' ', $contact->name);
     $firstname = $name[0];
     unset($name[0]);
     $last = count($name);
     if (isset($name[$last])) {
         $surname = $name[$last];
         unset($name[$last]);
     } else {
         $surname = '';
     }
     $middlename = trim(implode(' ', $name));
     $v = new MambovCard();
     $v->setPhoneNumber($contact->telephone, 'PREF;WORK;VOICE');
     $v->setPhoneNumber($contact->fax, 'WORK;FAX');
     $v->setName($surname, $firstname, $middlename, '');
     $v->setAddress('', '', $contact->address, $contact->suburb, $contact->state, $contact->postcode, $contact->country, 'WORK;POSTAL');
     $v->setEmail($contact->email_to);
     $v->setNote($contact->misc);
     $v->setURL(mamboCore::get('mosConfig_live_site'), 'WORK');
     $v->setTitle($contact->con_position);
     $v->setOrg(mamboCore::get('mosConfig_sitename'));
     $filename = str_replace(' ', '_', $contact->name);
     $v->setFilename($filename);
     $output = $v->getVCard(mamboCore::get('mosConfig_sitename'));
     $filename = $v->getFileName();
     // header info for page
     header('Content-Disposition: attachment; filename=' . $filename);
     header('Content-Length: ' . strlen($output));
     header('Connection: close');
     header('Content-Type: text/x-vCard; name=' . $filename);
     print $output;
     //mosRedirect('index.php');
 }
Esempio n. 15
0
/**
* Saves the module after an edit form submit
*/
function saveModule($option, $client, $task)
{
    global $database;
    $params = mosGetParam($_POST, 'params', '', _MOS_ALLOWHTML);
    if (is_array($params)) {
        $txt = array();
        foreach ($params as $k => $v) {
            $txt[] = "{$k}={$v}";
        }
        $_POST['params'] = mosParameters::textareaHandling($txt);
    }
    $row = new mosModule($database);
    if (!$row->bind($_POST, 'selections')) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    // special access groups
    if (is_array($row->groups)) {
        $row->groups = implode(',', $row->groups);
    } else {
        $row->groups = '';
    }
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    if ($client == 'admin') {
        $where = "client_id='1'";
    } else {
        $where = "client_id='0'";
    }
    $row->updateOrder("position='{$row->position}' AND ({$where})");
    $menus = mosGetParam($_POST, 'selections', array());
    $database->setQuery("DELETE FROM #__modules_menu WHERE moduleid='{$row->id}'");
    $database->query();
    foreach ($menus as $menuid) {
        // this check for the blank spaces in the select box that have been added for cosmetic reasons
        if ($menuid != "-999" && $menuid != "-998") {
            $query = "INSERT INTO #__modules_menu SET moduleid='{$row->id}', menuid='{$menuid}'";
            $database->setQuery($query);
            $database->query();
        }
    }
    switch ($task) {
        case 'apply':
            $msg = sprintf(T_('Successfully Saved changes to Module: %s'), $row->title);
            mosRedirect('index2.php?option=' . $option . '&client=' . $client . '&task=editA&hidemainmenu=1&id=' . $row->id, $msg);
            break;
        case 'save':
        default:
            $msg = sprintf(T_('Successfully Saved Module: %s'), $row->title);
            mosRedirect('index2.php?option=' . $option . '&client=' . $client, $msg);
            break;
    }
}
Esempio n. 16
0
/**
* Mambot that Cloaks all emails in content from spambots via javascript
*/
function botMosEmailCloak($published, &$row, &$params, $page = 0)
{
    global $database, $_MAMBOTS;
    // check whether mambot has been unpublished
    if (!$published) {
        return true;
    }
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, '@') === false) {
        return true;
    }
    // simple check to allow disabling of bot
    $regex = '{emailcloak=off}';
    if (strpos($row->text, $regex) !== false) {
        $row->text = str_replace($regex, '', $row->text);
        return true;
    }
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_content_mambot_params['mosemailcloak'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mosemailcloak'" . "\n AND folder = 'content'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_content_mambot_params['mosemailcloak'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_content_mambot_params['mosemailcloak'];
    $botParams = new mosParameters($mambot->params);
    $mode = $botParams->def('mode', 1);
    // any@email.address.com
    $search_email = "([[:alnum:]_\\.\\-]+)(\\@[[:alnum:]\\.\\-]+\\.+)([[:alnum:]\\.\\-]+)";
    // any@email.address.com?subject=anyText
    $search_email_msg = "([[:alnum:]_\\.\\-]+)(\\@[[:alnum:]\\.\\-]+\\.+)([[:alnum:]\\.\\-]+)([[:alnum:][:space:][:punct:]][^\"<>]+)";
    // anyText
    $search_text = "([[:alnum:][:space:][:punct:]][^<>]+)";
    // search for derivativs of link code <a href="mailto:email@amail.com">email@amail.com</a>
    $pattern = botMosEmailCloak_searchPattern($search_email, $search_email);
    while (eregi($pattern, $row->text, $regs)) {
        $mail = $regs[2] . $regs[3] . $regs[4];
        $mail_text = $regs[5] . $regs[6] . $regs[7];
        // check to see if mail text is different from mail addy
        if ($mail_text) {
            $replacement = mosHTML::emailCloaking($mail, $mode, $mail_text);
        } else {
            $replacement = mosHTML::emailCloaking($mail, $mode);
        }
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
    // search for derivativs of link code <a href="mailto:email@amail.com">anytext</a>
    $pattern = botMosEmailCloak_searchPattern($search_email, $search_text);
    while (eregi($pattern, $row->text, $regs)) {
        $mail = $regs[2] . $regs[3] . $regs[4];
        $mail_text = $regs[5];
        $replacement = mosHTML::emailCloaking($mail, $mode, $mail_text, 0);
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
    // search for derivativs of link code <a href="mailto:email@amail.com?subject=Text&body=Text">email@amail.com</a>
    $pattern = botMosEmailCloak_searchPattern($search_email_msg, $search_email);
    while (eregi($pattern, $row->text, $regs)) {
        $mail = $regs[2] . $regs[3] . $regs[4] . $regs[5];
        $mail_text = $regs[6] . $regs[7] . $regs[8];
        //needed for handling of Body parameter
        $mail = str_replace('&amp;', '&', $mail);
        // check to see if mail text is different from mail addy
        if ($mail_text) {
            $replacement = mosHTML::emailCloaking($mail, $mode, $mail_text);
        } else {
            $replacement = mosHTML::emailCloaking($mail, $mode);
        }
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
    // search for derivativs of link code <a href="mailto:email@amail.com?subject=Text&body=Text">anytext</a>
    $pattern = botMosEmailCloak_searchPattern($search_email_msg, $search_text);
    while (eregi($pattern, $row->text, $regs)) {
        $mail = $regs[2] . $regs[3] . $regs[4] . $regs[5];
        $mail_text = $regs[6];
        //needed for handling of Body parameter
        $mail = str_replace('&amp;', '&', $mail);
        $replacement = mosHTML::emailCloaking($mail, $mode, $mail_text, 0);
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
    // search for plain text email@amail.com
    while (eregi($search_email, $row->text, $regs)) {
        $mail = $regs[0];
        $replacement = mosHTML::emailCloaking($mail, $mode);
        // replace the found address with the js cloacked email
        $row->text = str_replace($regs[0], $replacement, $row->text);
    }
}
Esempio n. 17
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
*/
function botSearchContent($text, $phrase = '', $ordering = '')
{
    global $database, $my, $_MAMBOTS;
    // check if param query has previously been processed
    if (!isset($_MAMBOTS->_search_mambot_params['content'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'content.searchbot'" . "\n AND folder = 'search'";
        $database->setQuery($query);
        $database->loadObject($mambot);
        // save query to class variable
        $_MAMBOTS->_search_mambot_params['content'] = $mambot;
    }
    // pull query data from class variable
    $mambot = $_MAMBOTS->_search_mambot_params['content'];
    $botParams = new mosParameters($mambot->params);
    $limit = $botParams->def('search_limit', 50);
    $nonmenu = $botParams->def('nonmenu', 1);
    $nullDate = $database->getNullDate();
    $now = _CURRENT_SERVER_TIME;
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    $wheres = array();
    switch ($phrase) {
        case 'exact':
            $wheres2 = array();
            $wheres2[] = "LOWER(a.title) LIKE LOWER('%{$text}%')";
            $wheres2[] = "LOWER(a.introtext) LIKE LOWER('%{$text}%')";
            $wheres2[] = "LOWER(a.fulltext) LIKE LOWER('%{$text}%')";
            $wheres2[] = "LOWER(a.metakey) LIKE LOWER('%{$text}%')";
            $wheres2[] = "LOWER(a.metadesc) LIKE LOWER('%{$text}%')";
            $where = '(' . implode(') OR (', $wheres2) . ')';
            break;
        case 'all':
        case 'any':
        default:
            $words = explode(' ', $text);
            $wheres = array();
            foreach ($words as $word) {
                $wheres2 = array();
                $wheres2[] = "LOWER(a.title) LIKE LOWER('%{$word}%')";
                $wheres2[] = "LOWER(a.introtext) LIKE LOWER('%{$word}%')";
                $wheres2[] = "LOWER(a.fulltext) LIKE LOWER('%{$word}%')";
                $wheres2[] = "LOWER(a.metakey) LIKE LOWER('%{$word}%')";
                $wheres2[] = "LOWER(a.metadesc) LIKE LOWER('%{$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;
    }
    // search content items
    $query = "SELECT a.title AS title," . "\n a.created AS created," . "\n CONCAT(a.introtext, a.fulltext) AS text," . "\n CONCAT_WS( '/', u.title, b.title ) AS section," . "\n CONCAT( 'index.php?option=com_content&task=view&id=', a.id ) AS href," . "\n '2' AS browsernav," . "\n 'content' AS type" . "\n, u.id AS sec_id, b.id as cat_id" . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS b ON b.id=a.catid" . "\n INNER JOIN #__sections AS u ON u.id = a.sectionid" . "\n WHERE ( {$where} )" . "\n AND a.state = 1" . "\n AND u.published = 1" . "\n AND b.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND b.access <= " . (int) $my->gid . "\n AND u.access <= " . (int) $my->gid . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n GROUP BY a.id" . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $list = $database->loadObjectList();
    // search static content
    $query = "SELECT a.title AS title," . "\n a.created AS created," . "\n a.introtext AS text," . "\n " . $database->Quote(_STATIC_CONTENT) . " AS section," . "\n CONCAT( 'index.php?option=com_content&task=view&id=', a.id, '&Itemid=', m.id ) AS href," . "\n '2' AS browsernav," . "\n a.id" . "\n FROM #__content AS a" . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id" . "\n WHERE ({$where})" . "\n AND a.state = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND m.type = 'content_typed'" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n GROUP BY a.id" . "\n ORDER BY " . ($morder ? $morder : $order);
    $database->setQuery($query, 0, $limit);
    $list2 = $database->loadObjectList();
    // search archived content
    $query = "SELECT a.title AS title," . "\n a.created AS created," . "\n a.introtext AS text," . "\n CONCAT_WS( '/', " . $database->Quote(_SEARCH_ARCHIVED) . ", u.title, b.title ) AS section," . "\n CONCAT('index.php?option=com_content&task=view&id=',a.id) AS href," . "\n '2' AS browsernav," . "\n 'content' AS type" . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS b ON b.id=a.catid" . "\n INNER JOIN #__sections AS u ON u.id = a.sectionid" . "\n WHERE ( {$where} )" . "\n AND a.state = -1" . "\n AND u.published = 1" . "\n AND b.published = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND b.access <= " . (int) $my->gid . "\n AND u.access <= " . (int) $my->gid . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n ORDER BY {$order}";
    $database->setQuery($query, 0, $limit);
    $list3 = $database->loadObjectList();
    // check if search of nonmenu linked static content is allowed
    if ($nonmenu) {
        // collect ids of static content items linked to menu items
        // so they can be removed from query that follows
        $ids = null;
        if (count($list2)) {
            foreach ($list2 as $static) {
                $ids[] = (int) $static->id;
            }
            $ids = "a.id != " . implode(" OR a.id != ", $ids);
        }
        // search static content not connected to a menu
        $query = "SELECT a.title AS title," . "\n a.created AS created," . "\n a.introtext AS text," . "\n '2' as browsernav, " . $database->Quote(_STATIC_CONTENT) . " AS section," . "\n CONCAT( 'index.php?option=com_content&task=view&id=', a.id ) AS href," . "\n a.id" . "\n FROM #__content AS a" . "\n WHERE ({$where})" . ($ids ? "\n AND ( {$ids} )" : '') . "\n AND a.state = 1" . "\n AND a.access <= " . (int) $my->gid . "\n AND a.sectionid = 0" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n ORDER BY " . ($morder ? $morder : $order);
        $database->setQuery($query, 0, $limit);
        $list4 = $database->loadObjectList();
    } else {
        $list4 = array();
    }
    return array_merge($list, $list2, $list3, (array) $list4);
}
Esempio n. 18
0
function pollresult($uid)
{
    global $database, $Itemid;
    global $mainframe;
    $poll = new mosPoll($database);
    $poll->load((int) $uid);
    // if id value is passed and poll not published then exit
    if ($poll->id != '' && !$poll->published) {
        mosNotAuth();
        return;
    }
    $first_vote = '';
    $last_vote = '';
    $votes = '';
    /*
    Check if there is a poll corresponding to id
    and if poll is published
    */
    if (isset($poll->id) && $poll->id != '' && $poll->published == 1) {
        if (empty($poll->title)) {
            $poll->id = '';
            $poll->title = _SELECT_POLL;
        }
        $query = "SELECT MIN( date ) AS mindate, MAX( date ) AS maxdate" . "\n FROM #__poll_date" . "\n WHERE poll_id = " . (int) $poll->id;
        $database->setQuery($query);
        $dates = $database->loadObjectList();
        if (isset($dates[0]->mindate)) {
            $first_vote = mosFormatDate($dates[0]->mindate, _DATE_FORMAT_LC2);
            $last_vote = mosFormatDate($dates[0]->maxdate, _DATE_FORMAT_LC2);
        }
        $query = "SELECT a.id, a.text, a.hits, b.voters" . "\n FROM #__poll_data AS a" . "\n INNER JOIN #__polls AS b ON b.id = a.pollid" . "\n WHERE a.pollid = " . (int) $poll->id . "\n AND a.text != ''" . "\n AND b.published = 1";
        $database->setQuery($query);
        $votes = $database->loadObjectList();
    }
    // list of polls for dropdown selection
    $query = "SELECT id, title" . "\n FROM #__polls" . "\n WHERE published = 1" . "\n ORDER BY id";
    $database->setQuery($query);
    $polls = $database->loadObjectList();
    // Itemid for dropdown
    $_Itemid = '';
    if ($Itemid && $Itemid != 99999999) {
        $_Itemid = '&amp;Itemid=' . $Itemid;
    }
    // dropdown output
    $link = sefRelToAbs('index.php?option=com_poll&amp;task=results&amp;id=\' + this.options[selectedIndex].value + \'' . $_Itemid . '\' + \'');
    $pollist = '<select name="id" class="inputbox" size="1" style="width:200px" onchange="if (this.options[selectedIndex].value != \'\') {document.location.href=\'' . $link . '\'}">';
    $pollist .= '<option value="">' . _SELECT_POLL . '</option>';
    for ($i = 0, $n = count($polls); $i < $n; $i++) {
        $k = $polls[$i]->id;
        $t = $polls[$i]->title;
        $sel = $k == intval($poll->id) ? " selected=\"selected\"" : '';
        $pollist .= "\n\t<option value=\"" . $k . "\"{$sel}>" . $t . "</option>";
    }
    $pollist .= '</select>';
    // Adds parameter handling
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('pageclass_sfx', '');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    $params->def('header', $menu->name);
    $mainframe->SetPageTitle($poll->title);
    poll_html::showResults($poll, $votes, $first_vote, $last_vote, $pollist, $params);
}
Esempio n. 19
0
function listWeblinks($catid)
{
    global $mainframe, $database, $my;
    global $mosConfig_live_site;
    global $Itemid;
    $rows = array();
    $currentcat = null;
    if ($catid) {
        // url links info for category
        $query = "SELECT id, url, title, description, date, hits, params" . "\n FROM #__weblinks" . "\n WHERE catid = " . (int) $catid . "\n AND published = 1" . "\n AND archived = 0" . "\n ORDER BY ordering";
        $database->setQuery($query);
        $rows = $database->loadObjectList();
        // current cate info
        $query = "SELECT *" . "\n FROM #__categories" . "\n WHERE id = " . (int) $catid . "\n AND published = 1" . "\n AND access <= " . (int) $my->gid;
        $database->setQuery($query);
        $database->loadObject($currentcat);
        /*
        Check if the category is published or if access level allows access
        */
        if (!$currentcat->name) {
            mosNotAuth();
            return;
        }
    }
    /* Query to retrieve all categories that belong under the web links section and that are published. */
    $query = "SELECT cc.*, a.catid, a.title, a.url, COUNT(a.id) AS numlinks" . "\n FROM #__categories AS cc" . "\n LEFT JOIN #__weblinks AS a ON a.catid = cc.id" . "\n WHERE a.published = 1" . "\n AND section = 'com_weblinks'" . "\n AND cc.published = 1" . "\n AND cc.access <= " . (int) $my->gid . "\n GROUP BY cc.id" . "\n ORDER BY cc.ordering";
    $database->setQuery($query);
    $categories = $database->loadObjectList();
    // Parameters
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('header', $menu->name);
    $params->def('pageclass_sfx', '');
    $params->def('headings', 1);
    $params->def('hits', $mainframe->getCfg('hits'));
    $params->def('item_description', 1);
    $params->def('other_cat_section', 1);
    $params->def('other_cat', 1);
    $params->def('description', 1);
    $params->def('description_text', _WEBLINKS_DESC);
    $params->def('image', '-1');
    $params->def('weblink_icons', '');
    $params->def('image_align', 'right');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    if ($catid) {
        $params->set('type', 'category');
    } else {
        $params->set('type', 'section');
    }
    // page description
    $currentcat->descrip = '';
    if (@$currentcat->description != '') {
        $currentcat->descrip = $currentcat->description;
    } else {
        if (!$catid) {
            // show description
            if ($params->get('description')) {
                $currentcat->descrip = $params->get('description_text');
            }
        }
    }
    // page image
    $currentcat->img = '';
    $path = $mosConfig_live_site . '/images/stories/';
    if (@$currentcat->image != '') {
        $currentcat->img = $path . $currentcat->image;
        $currentcat->align = $currentcat->image_position;
    } else {
        if (!$catid) {
            if ($params->get('image') != -1) {
                $currentcat->img = $path . $params->get('image');
                $currentcat->align = $params->get('image_align');
            }
        }
    }
    // page header
    $currentcat->header = '';
    if (@$currentcat->name != '') {
        $currentcat->header = $currentcat->name;
    } else {
        $currentcat->header = $params->get('header');
    }
    // used to show table rows in alternating colours
    $tabclass = array('sectiontableentry1', 'sectiontableentry2');
    HTML_weblinks::displaylist($categories, $rows, $catid, $currentcat, $params, $tabclass);
}
Esempio n. 20
0
 $jc_ajax = JCommentsInput::getVar('jtxf', '');
 $app = JCommentsFactory::getApplication('site');
 if ($jc_option == 'com_jcomments' && $jc_ajax == '' && !$app->isAdmin()) {
     $_Itemid = (int) JCommentsInput::getVar('Itemid');
     $_tmpl = JCommentsInput::getVar('tmpl');
     if ($_Itemid !== 0 && $_tmpl !== 'component') {
         if (JCOMMENTS_JVERSION == '1.5') {
             $params = JComponentHelper::getParams('com_jcomments');
         } elseif (JCOMMENTS_JVERSION == '1.7') {
             $params = $app->getParams();
         } else {
             $menu = $app->get('menu');
             if ($menu != null) {
                 $params = new mosParameters($menu->params);
             } else {
                 $params = new mosParameters('');
             }
         }
         $object_group = $params->get('object_group');
         $object_id = (int) $params->get('object_id', 0);
         if ($object_id != 0 && $object_group != '') {
             if ($params->get('language_suffix') != '') {
                 JComments::loadAlternateLanguage($params->get('language_suffix'));
             }
             $keywords = $params->get('keywords');
             $description = $params->get('description');
             $pageTitle = $params->get('page_title');
             $document = JCommentsFactory::getDocument();
             if ($pageTitle != '') {
                 $document->setTitle($pageTitle);
             }
Esempio n. 21
0
 function getParameters($id)
 {
     global $database, $mosConfig_offset, $mosConfig_live_site;
     $feed = new rdRssData($database);
     $feed->load($id);
     $params = new mosParameters($feed->params);
     $params->id = $id;
     $params->catids = $feed->catids;
     $params->published = $feed->published;
     if (method_exists($database, "getNullDate")) {
         $params->nullDate = $database->getNullDate();
     } else {
         $params->nullDate = '0000-00-00 00:00:00';
     }
     $params->now = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60);
     $iso = split('=', _ISO);
     // parameter intilization
     $params->date = date('r');
     $params->year = date('Y');
     $params->encoding = $iso[1];
     $params->link = htmlspecialchars($mosConfig_live_site);
     $params->cache = $params->def('cache', 1);
     $params->cache_time = $params->def('cache_time', 3600);
     $params->count = $params->def('count', 5);
     $params->orderby = $params->def('orderby', '');
     $params->title = $params->def('title', 'Joomla! powered Site');
     $params->description = $params->def('description', 'Joomla! site syndication');
     $params->image_file = $params->def('image_file', 'joomla_rss.png');
     if ($params->image_file == -1) {
         $params->image = NULL;
     } else {
         $params->image = $mosConfig_live_site . '/images/M_images/' . $params->image_file;
     }
     $params->image_alt = $params->def('image_alt', 'Powered by Joomla!');
     $params->limit_text = $params->def('limit_text', 1);
     $params->text_length = $params->def('text_length', 20);
     // get feed type from url
     $params->feed = mosGetParam($_GET, 'feed', 'RSS2.0');
     // live bookmarks
     $params->live_bookmark = $params->def('live_bookmark', '');
     return $params;
 }
Esempio n. 22
0
 }
 // the configuration file for the Shop
 require_once $mosConfig_absolute_path . "/administrator/components/com_virtuemart/virtuemart.cfg.php";
 $GLOBALS['mosConfig_live_site'] = $mosConfig_live_site = substr(URL, 0, strlen(URL) - 1);
 // the global file for VirtueMart
 require_once ADMINPATH . 'global.php';
 if (!vmIsAdminMode() && !is_a($mainframe, 'JAdministrator') && !isset($_REQUEST['page'])) {
     // Get the menu parameters, if any
     if (vmIsJoomla('1.5')) {
         $menuparams = $mainframe->getParams();
     } else {
         $Itemid = (int) vmRequest::getInt('Itemid', '');
         $query = "SELECT params FROM #__menu WHERE id='" . $Itemid . "'";
         $database->setQuery($query);
         $itemparams = $database->loadResult();
         $menuparams = new mosParameters($itemparams);
     }
     $tmp_product_id = $menuparams->get('product_id');
     $tmp_category_id = $menuparams->get('category_id');
     $tmp_flypage = $menuparams->get('flypage');
     $tmp_page = $menuparams->get('page');
     if (!empty($tmp_product_id)) {
         vmRequest::setVar('product_id', $tmp_product_id);
         vmRequest::setVar('page', 'shop.product_details');
     } elseif (!empty($tmp_category_id)) {
         vmRequest::setVar('category_id', $tmp_category_id);
         vmRequest::setVar('page', 'shop.browse');
     }
     if ((!empty($tmp_product_id) || !empty($tmp_category_id)) && !empty($tmp_flypage)) {
         vmRequest::setVar('flypage', $tmp_flypage);
     }
Esempio n. 23
0
 /**
  * Writes the configuration file of the current theme
  *
  * @param array $d
  */
 function writeThemeConfig(&$d)
 {
     global $page, $VM_LANG, $vmLogger;
     $my_config_array = array();
     $config = "<?php\r\nif( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );\r\n/**\r\n* The configuration file for the " . basename(VM_THEMEPATH) . " theme\r\n*\r\n* @package VirtueMart\r\n* @subpackage themes\r\n* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php\r\n* VirtueMart is free software. This version may have been modified pursuant\r\n* to the GNU General Public License, and as distributed it includes or\r\n* is derivative of works licensed under the GNU General Public License or\r\n* other free or open source software licenses.\r\n* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.\r\n*\r\n* http://virtuemart.net\r\n*/\r\n?>\r\n";
     $params = vmGet($_POST, 'params', '');
     if (is_array($params)) {
         $txt = array();
         foreach ($params as $k => $v) {
             $txt[] = "{$k}={$v}";
         }
         if (is_callable(array('mosParameters', 'textareaHandling'))) {
             $_POST['params'] = mosParameters::textareaHandling($txt);
         } else {
             $total = count($txt);
             for ($i = 0; $i < $total; $i++) {
                 if (strstr($txt[$i], "\n")) {
                     $txt[$i] = str_replace("\n", '<br />', $txt[$i]);
                 }
             }
             $_POST['params'] = implode("\n", $txt);
         }
     }
     $config .= $_POST['params'];
     if ($fp = fopen(VM_THEMEPATH . "theme.config.php", "w")) {
         fputs($fp, $config, strlen($config));
         fclose($fp);
         if (!empty($_REQUEST['ajax_request'])) {
             $vmLogger->info($VM_LANG->_('VM_CONFIGURATION_CHANGE_SUCCESS', false));
         } else {
             $task = vmGet($_REQUEST, 'task', '');
             if ($task == 'apply') {
                 $page = 'admin.theme_config_form';
                 $theme = '&theme=' . basename(VM_THEMEURL);
             } else {
                 $page = 'admin.show_cfg';
                 $theme = '';
             }
             if (!empty($_REQUEST['ajax_request'])) {
                 $vmLogger->info($VM_LANG->_('VM_CONFIGURATION_CHANGE_SUCCESS', false));
             } else {
                 vmRedirect($_SERVER['PHP_SELF'] . "?page={$page}{$theme}&option=com_virtuemart", $VM_LANG->_('VM_CONFIGURATION_CHANGE_SUCCESS'));
             }
         }
         return true;
     } else {
         $vmLogger->err($VM_LANG->_('VM_CONFIGURATION_CHANGE_FAILURE', false) . ' (' . VM_THEMEPATH . "theme.config.php)");
         return false;
     }
 }
Esempio n. 24
0
function dofreePDF()
{
    global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset;
    global $mainframe, $database, $my;
    $id = intval(mosGetParam($_REQUEST, 'id', 1));
    $gid = $my->gid;
    $now = _CURRENT_SERVER_TIME;
    $nullDate = $database->getNullDate();
    // query to check for state and access levels
    $query = "SELECT a.*, cc.name AS category, s.name AS section, s.published AS sec_pub, cc.published AS cat_pub," . "\n  s.access AS sec_access, cc.access AS cat_access, s.id AS sec_id, cc.id as cat_id" . "\n FROM #__content AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = 'content'" . "\n WHERE a.id = " . (int) $id . "\n AND a.state = 1" . "\n AND a.access <= " . (int) $gid . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )";
    $database->setQuery($query);
    $row = NULL;
    if ($database->loadObject($row)) {
        /*
         * check whether category is published
         */
        if (!$row->cat_pub && $row->catid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section is published
         */
        if (!$row->sec_pub && $row->sectionid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether category access level allows access
         */
        if ($row->cat_access > $gid && $row->catid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section access level allows access
         */
        if ($row->sec_access > $gid && $row->sectionid) {
            mosNotAuth();
            return;
        }
        include 'includes/class.ezpdf.php';
        $params = new mosParameters($row->attribs);
        $params->def('author', !$mainframe->getCfg('hideAuthor'));
        $params->def('createdate', !$mainframe->getCfg('hideCreateDate'));
        $params->def('modifydate', !$mainframe->getCfg('hideModifyDate'));
        $row->fulltext = pdfCleaner($row->fulltext);
        $row->introtext = pdfCleaner($row->introtext);
        $pdf = new Cezpdf('a4', 'P');
        //A4 Portrait
        $pdf->ezSetCmMargins(2, 1.5, 1, 1);
        $pdf->selectFont('./fonts/Helvetica.afm');
        //choose font
        $all = $pdf->openObject();
        $pdf->saveState();
        $pdf->setStrokeColor(0, 0, 0, 1);
        // footer
        $pdf->addText(250, 822, 6, $mosConfig_sitename);
        $pdf->line(10, 40, 578, 40);
        $pdf->line(10, 818, 578, 818);
        $pdf->addText(30, 34, 6, $mosConfig_live_site);
        $pdf->addText(250, 34, 6, _PDF_POWERED);
        $pdf->addText(450, 34, 6, _PDF_GENERATED . ' ' . date('j F, Y, H:i', time() + $mosConfig_offset * 60 * 60));
        $pdf->restoreState();
        $pdf->closeObject();
        $pdf->addObject($all, 'all');
        $pdf->ezSetDy(30);
        $txt1 = $row->title;
        $pdf->ezText($txt1, 14);
        $txt2 = AuthorDateLine($row, $params);
        $pdf->ezText($txt2, 8);
        $txt3 = $row->introtext . "\n" . $row->fulltext;
        $pdf->ezText($txt3, 10);
        $pdf->ezStream();
    } else {
        mosNotAuth();
        return;
    }
}
Esempio n. 25
0
/**
* Saves the module after an edit form submit
*/
function saveModule($option, $client, $task)
{
    global $database;
    josSpoofCheck();
    $params = mosGetParam($_POST, 'params', '');
    if (is_array($params)) {
        $txt = array();
        foreach ($params as $k => $v) {
            $txt[] = "{$k}={$v}";
        }
        $_POST['params'] = mosParameters::textareaHandling($txt);
    }
    $row = new mosModule($database);
    if (!$row->bind($_POST, 'selections')) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    if ($client == 'admin') {
        $where = "client_id=1";
    } else {
        $where = "client_id=0";
    }
    $row->updateOrder('position=' . $database->Quote($row->position) . " AND ({$where})");
    $menus = josGetArrayInts('selections');
    // delete old module to menu item associations
    $query = "DELETE FROM #__modules_menu" . "\n WHERE moduleid = " . (int) $row->id;
    $database->setQuery($query);
    $database->query();
    // check needed to stop a module being assigned to `All`
    // and other menu items resulting in a module being displayed twice
    if (in_array('0', $menus)) {
        // assign new module to `all` menu item associations
        $query = "INSERT INTO #__modules_menu" . "\n SET moduleid = " . (int) $row->id . ", menuid = 0";
        $database->setQuery($query);
        $database->query();
    } else {
        foreach ($menus as $menuid) {
            // this check for the blank spaces in the select box that have been added for cosmetic reasons
            if ($menuid != "-999") {
                // assign new module to menu item associations
                $query = "INSERT INTO #__modules_menu" . "\n SET moduleid = " . (int) $row->id . ", menuid = " . (int) $menuid;
                $database->setQuery($query);
                $database->query();
            }
        }
    }
    mosCache::cleanCache('com_content');
    switch ($task) {
        case 'apply':
            $msg = 'Successfully Saved changes to Module: ' . $row->title;
            mosRedirect('index2.php?option=' . $option . '&client=' . $client . '&task=editA&hidemainmenu=1&id=' . $row->id, $msg);
            break;
        case 'save':
        default:
            $msg = 'Successfully Saved Module: ' . $row->title;
            mosRedirect('index2.php?option=' . $option . '&client=' . $client, $msg);
            break;
    }
}
Esempio n. 26
0
$atom_image = $params->get('atom_image', '');
$opml_image = $params->get('opml_image', '');
$cur_template = $mainframe->getTemplate();
$t_path = $mosConfig_live_site . '/templates/' . $cur_template . '/images/';
$d_path = $mosConfig_live_site . '/images/M_images/';
// needed to reduce query
if (isset($GLOBALS['syndicateParams'])) {
    // load value stored in GLOBALS
    $syndicateParams = $GLOBALS['syndicateParams'];
} else {
    // query to oull syndication component params
    $query = "SELECT a.*" . "\n FROM #__components AS a" . "\n WHERE ( a.admin_menu_link = 'option=com_syndicate' OR a.admin_menu_link = 'option=com_syndicate&hidemainmenu=1' )" . "\n AND a.option = 'com_syndicate'";
    $database->setQuery($query);
    $database->loadObject($row);
    // get params definitions
    $syndicateParams = new mosParameters($row->params, $mainframe->getPath('com_xml', $row->option), 'component');
}
// check for disabling/enabling of selected feed types
if (!$syndicateParams->get('rss091', 1)) {
    $rss091 = 0;
}
if (!$syndicateParams->get('rss10', 1)) {
    $rss10 = 0;
}
if (!$syndicateParams->get('rss20', 1)) {
    $rss20 = 0;
}
if (!$syndicateParams->get('atom03', 1)) {
    $atom03 = 0;
}
if (!$syndicateParams->get('opml', 1)) {
Esempio n. 27
0
function showFeed($feedid)
{
    global $database, $mainframe, $mosConfig_absolute_path, $mosConfig_cachepath, $Itemid, $my;
    // check if cache directory is writeable
    $cacheDir = $mosConfig_cachepath . '/';
    if (!is_writable($cacheDir)) {
        echo 'Cache Directory Unwriteable';
        return;
    }
    require_once $mainframe->getPath('class');
    $newsfeed = new mosNewsFeed($database);
    $newsfeed->load((int) $feedid);
    /*
     * Check if newsfeed is published
     */
    if (!$newsfeed->published) {
        mosNotAuth();
        return;
    }
    $category = new mosCategory($database);
    $category->load((int) $newsfeed->catid);
    /*
     * Check if newsfeed category is published
     */
    if (!$category->published) {
        mosNotAuth();
        return;
    }
    /*
     * check whether category access level allows access
     */
    if ($category->access > $my->gid) {
        mosNotAuth();
        return;
    }
    // full RSS parser used to access image information
    require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_rss.php';
    $LitePath = $mosConfig_absolute_path . '/includes/Cache/Lite.php';
    // Adds parameter handling
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('header', $menu->name);
    $params->def('pageclass_sfx', '');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    // Feed Display control
    $params->def('feed_image', 1);
    $params->def('feed_descr', 1);
    $params->def('item_descr', 1);
    $params->def('word_count', 0);
    // Encoding
    $params->def('utf8', 1);
    if (!$params->get('page_title')) {
        $params->set('header', '');
    }
    $and = '';
    if ($feedid) {
        $and = "\n AND id = {$feedid}";
    }
    $mainframe->SetPageTitle($menu->name);
    HTML_newsfeed::showNewsfeeds($newsfeed, $LitePath, $cacheDir, $params);
}
Esempio n. 28
0
    /**
     * Display Table of items
     */
    function showTable(&$params, &$rows, $catid, $tabclass)
    {
        global $mosConfig_live_site;
        // icon in table display
        if ($params->get('weblink_icons') != -1) {
            $img = mosAdminMenus::ImageCheck('weblink.png', '/images/M_images/', $params->get('weblink_icons'), '/images/M_images/', 'Link', 'Link');
        } else {
            $img = NULL;
        }
        ?>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<?php 
        if ($params->get('headings')) {
            ?>
			<tr>
				<?php 
            if ($img) {
                ?>
					<td class="sectiontableheader<?php 
                echo $params->get('pageclass_sfx');
                ?>
">&nbsp;

					</td>
					<?php 
            }
            ?>
				<td width="90%" height="20" class="sectiontableheader<?php 
            echo $params->get('pageclass_sfx');
            ?>
">
				<?php 
            echo _HEADER_TITLE_WEBLINKS;
            ?>
				</td>
				<?php 
            if ($params->get('hits')) {
                ?>
					<td width="30" height="20" class="sectiontableheader<?php 
                echo $params->get('pageclass_sfx');
                ?>
" align="right">
					<?php 
                echo _HEADER_HITS;
                ?>
					</td>
					<?php 
            }
            ?>
			</tr>
			<?php 
        }
        $k = 0;
        foreach ($rows as $row) {
            $iparams = new mosParameters($row->params);
            $link = sefRelToAbs('index.php?option=com_weblinks&task=view&catid=' . $catid . '&id=' . $row->id);
            $link = ampReplace($link);
            $menuclass = 'category' . $params->get('pageclass_sfx');
            switch ($iparams->get('target')) {
                // cases are slightly different
                case 1:
                    // open in a new window
                    $txt = '<a href="' . $link . '" target="_blank" class="' . $menuclass . '">' . $row->title . '</a>';
                    break;
                case 2:
                    // open in a popup window
                    $txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"{$menuclass}\">" . $row->title . "</a>\n";
                    break;
                default:
                    // formerly case 2
                    // open in parent window
                    $txt = '<a href="' . $link . '" class="' . $menuclass . '">' . $row->title . '</a>';
                    break;
            }
            ?>
			<tr class="<?php 
            echo $tabclass[$k];
            ?>
">
				<?php 
            if ($img) {
                ?>
					<td width="100" height="20" align="center">
					&nbsp;&nbsp;<?php 
                echo $img;
                ?>
&nbsp;&nbsp;
					</td>
					<?php 
            }
            ?>
				<td height="20">
				<?php 
            echo $txt;
            ?>
				<?php 
            if ($params->get('item_description')) {
                ?>
					<br />
					<?php 
                echo $row->description;
                ?>
					<?php 
            }
            ?>
				</td>
				<?php 
            if ($params->get('hits')) {
                ?>
					<td align="center">
					<?php 
                echo $row->hits;
                ?>
					</td>
					<?php 
            }
            ?>
			</tr>
			<?php 
            $k = 1 - $k;
        }
        ?>
		</table>
		<?php 
    }
Esempio n. 29
0
function plgContentJCommentsLinksJ10($published, &$row, &$params, $page = 0)
{
    global $task, $option, $my;
    // disable comments link in 3rd party components (except Events and AlphaContent)
    if ($option != 'com_content' && $option != 'com_frontpage' && $option != 'com_alphacontent' && $option != 'com_events') {
        return;
    }
    require_once JCOMMENTS_HELPERS . '/content.php';
    require_once JCOMMENTS_LIBRARIES . '/joomlatune/language.tools.php';
    if (!isset($params) || $params == null) {
        $params = new mosParameters('');
    }
    $pvars = array_keys(get_object_vars($params->_params));
    if (!$published || $params->get('popup') || in_array('moduleclass_sfx', $pvars)) {
        JCommentsContentPluginHelper::processForeignTags($row, true);
        JCommentsContentPluginHelper::clear($row, true);
        return;
    }
    /*
    if ($option == 'com_frontpage') {
    	$pluginParams = JCommentsPluginHelper::getParams('jcomments', 'content');
    	if ((int) $pluginParams->get('show_frontpage', 1) == 0) {
    		return;
    	}
    }
    */
    require_once JCOMMENTS_BASE . '/jcomments.config.php';
    require_once JCOMMENTS_BASE . '/jcomments.class.php';
    if ($task != 'view') {
        // replace other comment systems tags to JComments equivalents like {jcomments on}
        JCommentsContentPluginHelper::processForeignTags($row, false);
        // show link to comments only
        if ($row->access <= $my->gid) {
            $readmore_link = JCommentsObjectHelper::getLink($row->id, 'com_content');
            $readmore_register = 0;
        } else {
            $readmore_link = sefRelToAbs('index.php?option=com_registration&amp;task=register');
            $readmore_register = 1;
        }
        $tmpl = JCommentsFactory::getTemplate($row->id, 'com_content', false);
        $tmpl->load('tpl_links');
        $tmpl->addVar('tpl_links', 'comments_link_style', $readmore_register ? -1 : 1);
        $tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
        $tmpl->addVar('tpl_links', 'content-item', $row);
        if ($params->get('readmore') == 0 || @$row->readmore == 0) {
            $tmpl->addVar('tpl_links', 'readmore_link_hidden', 1);
        } else {
            if (@$row->readmore > 0) {
                $tmpl->addVar('tpl_links', 'readmore_link_hidden', 0);
            }
        }
        $config = JCommentsFactory::getConfig();
        $commentsDisabled = false;
        if (!JCommentsContentPluginHelper::checkCategory($row->catid)) {
            $commentsDisabled = true;
        }
        if ($config->getInt('comments_off', 0) == 1) {
            $commentsDisabled = true;
        } else {
            if ($config->getInt('comments_on', 0) == 1) {
                $commentsDisabled = false;
            }
        }
        $tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled));
        $count = 0;
        // do not query comments count if comments disabled and link hidden
        if (!$commentsDisabled) {
            require_once JCOMMENTS_MODELS . '/jcomments.php';
            require_once JCOMMENTS_LIBRARIES . '/joomlatune/language.tools.php';
            $acl = JCommentsFactory::getACL();
            $options = array();
            $options['object_id'] = (int) $row->id;
            $options['object_group'] = 'com_content';
            $options['published'] = $acl->canPublish() || $acl->canPublishForObject($row->id, 'com_content') ? null : 1;
            $count = JCommentsModel::getCommentsCount($options);
            $anchor = $count == 0 ? '#addcomments' : '#comments';
            $link_text = $count == 0 ? JText::_('LINK_ADD_COMMENT') : JText::plural('LINK_READ_COMMENTS', $count);
            $tmpl->addVar('tpl_links', 'link-comment', $readmore_link . $anchor);
            $tmpl->addVar('tpl_links', 'link-comment-text', $link_text);
            $tmpl->addVar('tpl_links', 'link-comments-class', 'comments-link');
            $tmpl->addVar('tpl_links', 'comments-count', $count);
        }
        if ($readmore_register == 1 && $count == 0) {
            $tmpl->addVar('tpl_links', 'comments_link_hidden', 1);
        }
        if ($readmore_register == 1) {
            $readmore_text = JText::_('LINK_REGISTER_TO_READ_MORE');
        } else {
            $readmore_text = JText::_('LINK_READ_MORE');
        }
        $tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
        $tmpl->addVar('tpl_links', 'link-readmore-title', $row->title);
        $tmpl->addVar('tpl_links', 'link-readmore-class', 'readmore-link');
        JCommentsContentPluginHelper::clear($row, true);
        $row->text .= $tmpl->renderTemplate('tpl_links');
        $GLOBALS['jcomments_params_readmore'] = $params->get('readmore');
        $GLOBALS['jcomments_row_readmore'] = $row->readmore;
        $params->set('readmore', 0);
        $row->readmore = 0;
    } else {
        JCommentsContentPluginHelper::processForeignTags($row, true);
        JCommentsContentPluginHelper::clear($row, true);
    }
    return;
}
Esempio n. 30
0
/**
* Page break mambot
*
* <b>Usage:</b>
* <code>{mospagebreak}</code>
* <code>{mospagebreak title=The page title}</code>
* or
* <code>{mospagebreak heading=The first page}</code>
* or
* <code>{mospagebreak title=The page title&heading=The first page}</code>
* or
* <code>{mospagebreak heading=The first page&title=The page title}</code>
*
*/
function botMosPaging($published, &$row, &$params, $page = 0)
{
    global $mainframe, $Itemid, $database, $_MAMBOTS;
    // simple performance check to determine whether bot should process further
    if (strpos($row->text, 'mospagebreak') === false) {
        return true;
    }
    // expression to search for
    $regex = '/{(mospagebreak)\\s*(.*?)}/i';
    // check whether mambot has been unpublished
    if (!$published || $params->get('intro_only') || $params->get('popup')) {
        $row->text = preg_replace($regex, '', $row->text);
        return;
    }
    // find all instances of mambot and put in $matches
    $matches = array();
    preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
    // split the text around the mambot
    $text = preg_split($regex, $row->text);
    // count the number of pages
    $n = count($text);
    // we have found at least one mambot, therefore at least 2 pages
    if ($n > 1) {
        // check if param query has previously been processed
        if (!isset($_MAMBOTS->_content_mambot_params['mospaging'])) {
            // load mambot params info
            $query = "SELECT params" . "\n FROM #__mambots" . "\n WHERE element = 'mospaging'" . "\n AND folder = 'content'";
            $database->setQuery($query);
            $database->loadObject($mambot);
            // save query to class variable
            $_MAMBOTS->_content_mambot_params['mospaging'] = $mambot;
        }
        // pull query data from class variable
        $mambot = $_MAMBOTS->_content_mambot_params['mospaging'];
        $botParams = new mosParameters($mambot->params);
        $title = $botParams->def('title', 1);
        // adds heading or title to <site> Title
        if ($title) {
            $page_text = $page + 1;
            $row->page_title = _PN_PAGE . ' ' . $page_text;
            if (!$page) {
                // processing for first page
                parse_str(html_entity_decode($matches[0][2]), $args);
                if (@$args['heading']) {
                    //$row->page_title = $args['heading'];
                    $row->page_title = '';
                } else {
                    $row->page_title = '';
                }
            } else {
                if ($matches[$page - 1][2]) {
                    parse_str(html_entity_decode($matches[$page - 1][2]), $args);
                    if (@$args['title']) {
                        $row->page_title = ': ' . stripslashes($args['title']);
                    }
                }
            }
        }
        // reset the text, we already hold it in the $text array
        $row->text = '';
        $hasToc = $mainframe->getCfg('multipage_toc');
        if ($hasToc) {
            // display TOC
            createTOC($row, $matches, $page);
        } else {
            $row->toc = '';
        }
        // traditional mos page navigation
        require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php';
        $pageNav = new mosPageNav($n, $page, 1);
        // page counter
        $row->text .= '<div class="pagenavcounter">';
        $row->text .= $pageNav->writeLeafsCounter();
        $row->text .= '</div>';
        // page text
        $row->text .= $text[$page];
        $row->text .= '<br />';
        $row->text .= '<div class="pagenavbar">';
        // adds navigation between pages to bottom of text
        if ($hasToc) {
            createNavigation($row, $page, $n);
        }
        // page links shown at bottom of page if TOC disabled
        if (!$hasToc) {
            $row->text .= $pageNav->writePagesLinks('index.php?option=com_content&amp;task=view&amp;id=' . $row->id . '&amp;Itemid=' . $Itemid);
        }
        $row->text .= '</div><br />';
    }
    return true;
}