Пример #1
0
function data_jstabs($pData, $pParams, $pCommonObject)
{
    global $gBitSmarty;
    $gBitSmarty->loadPlugin('smarty_block_jstab');
    $gBitSmarty->loadPlugin('smarty_block_jstabs');
    // collect all tabs
    $tabs = preg_split("!\n---tab:\\s*!i", $pData);
    $html = '';
    foreach ($tabs as $tab) {
        $tab = trim($tab);
        if (!empty($tab)) {
            // first line of every tab is the title
            preg_match("!(.*?)\n(.*)!s", $tab, $split);
            // we need a valid title and content to work with
            if (!empty($split[1]) && !empty($split[2])) {
                // prepare data for tabification and parsing
                $params['title'] = trim($split[1]);
                $parseHash = $pCommonObject->mInfo;
                $parseHash['no_cache'] = TRUE;
                $parseHash['data'] = $split[2];
                $html .= smarty_block_jstab($params, $pCommonObject->parseData($parseHash), $gBitSmarty, '');
            }
        }
    }
    if (!empty($html)) {
        return smarty_block_jstabs(array(), $html, $gBitSmarty, '');
    } else {
        return ' ';
    }
}
Пример #2
0
function data_addjstabs($data, $params)
{
    global $gBitSmarty;
    $gBitSmarty->loadPlugin('smarty_block_jstab');
    $gBitSmarty->loadPlugin('smarty_block_jstabs');
    extract($params, EXTR_SKIP);
    $id = 1000000 * microtime();
    $html = '';
    $good = false;
    for ($i = 1; $i <= 99; $i++) {
        if (isset(${'tab' . $i})) {
            if (is_numeric(${'tab' . $i})) {
                if ($obj = LibertyBase::getLibertyObject(${'tab' . $i})) {
                    $params['title'] = $obj->getTitle();
                    $html .= smarty_block_jstab($params, $obj->mInfo['parsed_data'], $gBitSmarty, '');
                    $good = True;
                }
            } else {
                $good = false;
            }
        }
    }
    if (!$good) {
        $html = tra("The plugin AddTabs requires valid parameters. Numeric content id numbers can use the parameter names 'tab1' thru 'tab99'");
    }
    if (!empty($html)) {
        return smarty_block_jstabs(array(), $html, $gBitSmarty, '');
    } else {
        return $html;
    }
}