function b_tinycontent_content_show($options)
 {
     global $xoopsDB, $xoopsConfig;
     $mydirname = $options[0];
     if (!preg_match('/^(\\D+)(\\d*)$/', $mydirname, $regs)) {
         echo "invalid dirname: " . htmlspecialchars($mydirname);
     }
     $mydirnumber = $regs[2] === '' ? '' : intval($regs[2]);
     $mytablename = $xoopsDB->prefix("tinycontent{$mydirnumber}");
     $mymodpath = XOOPS_ROOT_PATH . "/modules/{$mydirname}";
     $mymoddir = XOOPS_URL . "/modules/{$mydirname}";
     if (!class_exists('TinyDTextSanitizer')) {
         include_once "{$mymodpath}/class/tinyd.textsanitizer.php";
     }
     if (!defined('TC_RENDER_FUNCTIONS_INCLUDED')) {
         include_once "{$mymodpath}/include/render_function.inc.php";
     }
     if (!defined('TINYCONTENT_MB_LOADED')) {
         if (file_exists("{$mymodpath}/language/{$xoopsConfig['language']}/main.php")) {
             include_once "{$mymodpath}/language/{$xoopsConfig['language']}/main.php";
         } else {
             include_once "{$mymodpath}/language/english/main.php";
         }
     }
     // get my config
     $module_handler =& xoops_gethandler('module');
     $config_handler =& xoops_gethandler('config');
     $module =& $module_handler->getByDirname($mydirname);
     $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     $space2nbsp = empty($config['tc_space2nbsp']) ? 0 : 1;
     $result = $xoopsDB->query("SELECT text,title,link,nohtml,nosmiley,nobreaks,address FROM {$mytablename} WHERE storyid='{$options[1]}'");
     list($text, $title, $link, $nohtml, $nosmiley, $nobreaks, $address) = $xoopsDB->fetchRow($result);
     // getting "content"
     if ($link > 0) {
         // external (=wrapped) content
         $wrap_file = "{$mymodpath}/content/{$address}";
         if (!file_exists($wrap_file)) {
             redirect_header(XOOPS_URL . '/', 2, _TC_FILENOTFOUND);
             exit;
         }
         ob_start();
         include $wrap_file;
         $content = tc_convert_wrap_to_ie(ob_get_contents());
         /* if( $link == TC_WRAPTYPE_CHANGESRCHREF ) */
         $content = tc_change_srchref($content, "{$mymoddir}/content");
         ob_end_clean();
     } else {
         $myts =& TinyDTextSanitizer::getInstance();
         $shorten_text = $myts->tinyExtractSummary($text);
         $is_summary = $shorten_text != $text;
         $content = tc_content_render($shorten_text, $nohtml, $nosmiley, $nobreaks, $space2nbsp);
     }
     // if template file exists, parse it.
     if (file_exists("{$mymodpath}/templates/blocks/tinycontent_content_block.html")) {
         $myts =& TinyDTextSanitizer::getInstance();
         $tpl = new XoopsTpl();
         $tpl->assign(array('storyid' => $options[1], 'mymoddir' => $mymoddir, 'is_summary' => $is_summary, 'lang_more' => _MORE, 'title' => $myts->makeTboxData4Show($title), 'content' => $content));
         $block['content'] = $tpl->fetch("file:{$mymodpath}/templates/blocks/tinycontent_content_block.html");
     } else {
         $block['content'] = $content;
     }
     return $block;
 }
Ejemplo n.º 2
0
 function tinyd_search_base($mydirname, $mydirnumber, $keywords, $andor, $limit, $offset, $userid)
 {
     // get my config
     $module_handler =& xoops_gethandler('module');
     $config_handler =& xoops_gethandler('config');
     $module =& $module_handler->getByDirname($mydirname);
     $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     $myts =& TinyDTextSanitizer::getInstance();
     $db =& Database::getInstance();
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "text" : "'' AS text";
     $sql = "SELECT storyid,title,link,UNIX_TIMESTAMP(last_modified),{$select4con} FROM " . $db->prefix("tinycontent{$mydirnumber}") . " WHERE visible AND ! (nohtml & 8) ";
     if (!empty($userid)) {
         $sql .= " AND 0 ";
     }
     $whr = "";
     if (is_array($keywords) && count($keywords) > 0) {
         $whr = "AND (";
         switch (strtolower($andor)) {
             case "and":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(title,' ',text) LIKE '%{$keyword}%' AND ";
                 }
                 $whr = substr($whr, 0, -5);
                 break;
             case "or":
                 foreach ($keywords as $keyword) {
                     $whr .= "CONCAT(title,' ',text) LIKE '%{$keyword}%' OR ";
                 }
                 $whr = substr($whr, 0, -4);
                 break;
             default:
                 $whr .= "CONCAT(title,' ',text) LIKE '%{$keywords[0]}%'";
                 break;
         }
         $whr .= ")";
     }
     $sql = "{$sql} {$whr} ORDER BY storyid ASC";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     while (list($id, $title, $link, $timestamp, $text) = $db->fetchRow($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             $full_context = strip_tags($myts->displayTarea($text, 1, 1, 1, 1, 1));
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         }
         if (!empty($config['tc_force_mod_rewrite'])) {
             if (!empty($config['tc_modulesless_dir'])) {
                 $href = '../../' . $config['tc_modulesless_dir'] . '/' . sprintf(TC_REWRITE_FILENAME_FMT, $id);
             } else {
                 $href = TC_REWRITE_DIR . sprintf(TC_REWRITE_FILENAME_FMT, $id);
             }
         } else {
             if ($link == TC_WRAPTYPE_USEREWRITE) {
                 $href = TC_REWRITE_DIR . sprintf(TC_REWRITE_FILENAME_FMT, $id);
             } else {
                 if ($link == TC_WRAPTYPE_CONTENTBASE) {
                     $href = "content/index.php?id={$id}";
                 } else {
                     $href = "index.php?id={$id}";
                 }
             }
         }
         $ret[] = array("image" => "images/content.gif", "link" => $href, "title" => $title, "time" => $timestamp, "uid" => "0", "context" => $context);
     }
     return $ret;
 }
Ejemplo n.º 3
0
 function contentRender($text, $nohtml, $nosmiley, $nobreaks, $nbsp = 0)
 {
     $myts =& TinyDTextSanitizer::getInstance();
     if ($nohtml >= 16) {
         // db content (PEAR wiki)
         if (!defined('PATH_SEPARATOR')) {
             define('PATH_SEPARATOR', DIRECTORY_SEPARATOR == '/' ? ':' : ';');
         }
         ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . XOOPS_ROOT_PATH . '/common/PEAR');
         include_once 'Text/Wiki.php';
         // include_once "Text/sunday_Wiki.php";
         $wiki = new Text_Wiki();
         // create instance
         // Configuration
         $wiki->deleteRule('Wikilink');
         // remove a rule for auto-linking
         $wiki->setFormatConf('Xhtml', 'translate', false);
         // remove HTML_ENTITIES
         // $wiki = new sunday_Text_Wiki(); // create instance
         //$text = str_replace ( "\r\n", "\n", $text );
         //$text = str_replace ( "~\n", "[br]", $text );
         //$text = $wiki->transform($text);
         //$content = str_replace ( "[br]", "<br/>", $text );
         // special thx to minahito! you are great!!
         $content = $wiki->transform($text);
         if ($nohtml & 2) {
             $content = $myts->displayTarea($content, 1, !$nosmiley, 1, 1, !$nobreaks, $nbsp);
         }
     } else {
         if ($nohtml >= 8) {
             // db content (PHP)
             ob_start();
             eval($text);
             $content = ob_get_contents();
             ob_end_clean();
             if ($nohtml & 2) {
                 $content = $myts->displayTarea($content, 1, !$nosmiley, 1, 1, !$nobreaks, $nbsp);
             }
         } else {
             if ($nohtml < 4) {
                 //			echo "go...".$nohtml;
                 switch ($nohtml) {
                     case 0:
                         // HTML with BB
                         $content = $myts->displayTarea($text, 1, !$nosmiley, 1, 1, !$nobreaks, $nbsp);
                         break;
                     case 1:
                         // Text with BB
                         $content = $myts->displayTarea($text, 0, !$nosmiley, 1, 1, !$nobreaks, $nbsp);
                         break;
                     case 2:
                         // HTML without BB
                         //					$content = '<pre>'.$text.'</pre>';
                         $content = $myts->displayTarea($text, 1, !$nosmiley, 0, 1, !$nobreaks, $nbsp);
                         break;
                     case 3:
                         // Text without BB
                         $content = $myts->makeTboxData4Show($text);
                         break;
                 }
             } else {
                 $content = $text;
             }
         }
     }
     //echo "in=".$text;
     //echo "out=".$content;
     return $content;
 }
Ejemplo n.º 4
0
if (!empty($_POST['preview']) && $op == 'editit') {
    $op = 'edit';
}
if (!empty($_POST['moveto']) && $op == 'update') {
    $op = 'moveto';
}
if (!empty($_POST['cancel'])) {
    redirect_header('index.php?op=show', 0, _CANCEL);
    exit;
}
// utility variables
$mymodpath = XOOPS_ROOT_PATH . "/modules/{$mydirname}";
$mymodurl = XOOPS_URL . "/modules/{$mydirname}";
$wrap_path = XOOPS_ROOT_PATH . "/modules/{$mydirname}/content";
$mytablename = $xoopsDB->prefix("tinycontent{$mydirnumber}");
$myts =& TinyDTextSanitizer::getInstance();
// ------------------------------------------------------------------------- //
// Switch Statement for the different operations                             //
// ------------------------------------------------------------------------- //
$xoopsDB =& Database::getInstance();
switch ($op) {
    // ------------------------------------------------------------------------- //
    // Show Content Page -> Overview                                             //
    // ------------------------------------------------------------------------- //
    default:
        $mymenu_fake_uri = $_SERVER['REQUEST_URI'] . '?op=show';
    case "show":
        xoops_cp_header();
        include dirname(__FILE__) . '/mymenu.php';
        if (tinyd_check_browser_can_use_spaw()) {
            $can_use_spaw = true;