Ejemplo n.º 1
0
/**
* Mambot that loads module positions within content
*/
function botMosLoadPosition($published, &$row, &$cparams, $page = 0, $params)
{
    global $database;
    // expression to search for
    $regex = '/{mosloadposition\\s*.*?}/i';
    if (is_callable(array($row, 'getText'))) {
        $localtext = $row->getText();
    } else {
        $localtext = $row->text;
    }
    // find all instances of mambot and put in $matches
    preg_match_all($regex, $localtext, $matches);
    // Number of mambots
    $count = count($matches[0]);
    // mambot only processes if there are any instances of the mambot in the text
    if ($count) {
        // load mambot params info
        /*$query = "SELECT id FROM #__mambots WHERE element = 'mosloadposition' AND folder = 'content'";
        		$database->setQuery( $query );
        		$id 	= $database->loadResult();
        		$mambot = new mosMambot( $database );
        		$mambot->load( $id );*/
        $mambots =& mosMambotHandler::getInstance();
        $mambot = $mambots->getBot('mosloadposition', 'content');
        $params =& new mosParameters(isset($mambot->params) ? $mambot->params : '');
        $style = $params->def('style', -2);
        processPositions($localtext, $matches, $count, $regex, $style);
    }
    // Save the results of processing
    if (is_callable(array($row, 'saveText'))) {
        $row->saveText($localtext);
    } else {
        $row->text = $localtext;
    }
}
Ejemplo n.º 2
0
/**
* 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);
    }
}