function fetchSummary($external_link_id)
 {
     $myts =& MyTextsanitizer::getInstance();
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($this->mydirname);
     $config_handler =& xoops_gethandler('config');
     $configs = $config_handler->getConfigList($module->mid());
     // external_link_id means $content_id
     $content_id = intval($external_link_id);
     $mydirname = $this->mydirname;
     if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
         die('Invalid mydirname');
     }
     // get categoryObject and contentObject
     list($categoryObj, $contentObj) = pico_common_get_objects_from_content_id($mydirname, $content_id);
     // existence check
     if (!is_object($categoryObj) || !is_object($contentObj)) {
         return '';
     }
     // permission check
     $content_data = $contentObj->getData();
     if (empty($content_data['can_read'])) {
         return '';
     }
     // dare to convert it irregularly
     $summary = str_replace('&', '&', htmlspecialchars(xoops_substr(strip_tags($content_data['body_cached']), 0, 255), ENT_QUOTES));
     return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $myts->makeTboxData4Show($content_data['subject_raw'], 1, 1), 'uri' => XOOPS_URL . '/modules/' . $mydirname . '/' . pico_common_make_content_link4html($configs, $content_data), 'summary' => $summary);
 }
 function execute($request)
 {
     // Ticket Check
     if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) {
         redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors());
     }
     parent::execute($request);
     // initialize
     $cat_data = $this->currentCategoryObj->getData();
     $picoPermission =& PicoPermission::getInstance();
     // permission check
     if (empty($cat_data['can_post'])) {
         redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_MAKECONTENT);
     }
     // insert a content
     $content_id = pico_makecontent($this->mydirname);
     $content_uri4html = XOOPS_URL . "/modules/{$this->mydirname}/" . pico_common_make_content_link4html($this->mod_config, $content_id, $this->mydirname);
     // get contentObj
     $this->contentObj =& new PicoContent($this->mydirname, $content_id, $this->currentCategoryObj);
     $content_data = $this->contentObj->getData();
     // return uri
     if (!empty($_GET['ret']) && ($ret_uri = pico_main_parse_ret2uri($this->mydirname, $_GET['ret']))) {
         $ret_uri4html = htmlspecialchars($ret_uri, ENT_QUOTES);
     } else {
         $ret_uri4html = $content_uri4html;
     }
     // calling a delegate
     if (class_exists('XCube_DelegateUtils')) {
         XCube_DelegateUtils::raiseEvent('ModuleClass.Pico.Contentman.InsertSuccess', $this->mydirname, $content_id, $cat_data, $ret_uri4html);
     }
     // create extra_tags for notifications
     $extra_tags = array('CONTENT_URL' => pico_common_unhtmlspecialchars($content_uri4html), 'APPROVAL_URL' => XOOPS_URL . "/modules/{$this->mydirname}/index.php?page=contentmanager&content_id={$content_id}", 'CAT_TITLE' => $cat_data['cat_title'], 'CONTENT_SUBJECT' => $content_data['subject_raw']);
     // users2notify (can_readfull only)
     $users2notify = $picoPermission->getUidsFromCatid($this->mydirname, $cat_data['id'], 'can_readfull');
     if ($cat_data['post_auto_approved']) {
         // Notify for new content 'global'
         pico_main_trigger_event($this->mydirname, 'global', 0, 'newcontent', $extra_tags, $users2notify, 0);
         // Notify for new content 'category' of all parental categories
         foreach (array_keys($cat_data['paths_raw']) as $cat_id) {
             pico_main_trigger_event($this->mydirname, 'category', $cat_id, 'newcontent', $extra_tags, $users2notify, 0);
         }
         // message "registered"
         redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTMADE);
     } else {
         // Notify for new waiting content (only for admin or mod)
         $users2notify = pico_main_get_moderators($this->mydirname, $cat_data['id']);
         if (empty($users2notify)) {
             $users2notify = array(0);
         }
         pico_main_trigger_event($this->mydirname, 'global', 0, 'waitingcontent', $extra_tags, $users2notify);
         // message "waiting approval"
         redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTWAITINGREGISTER);
     }
     // view
     $this->is_need_header_footer = false;
 }
 function execute($request)
 {
     // Ticket Check
     if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) {
         redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors());
     }
     parent::execute($request);
     // contentObj
     $cat_data = $this->currentCategoryObj->getData();
     $this->contentObj =& new PicoContent($this->mydirname, $request['content_id'], $this->currentCategoryObj);
     // check existence
     if ($this->contentObj->isError()) {
         redirect_header(XOOPS_URL . "/modules/{$this->mydirname}/index.php", 2, _MD_PICO_ERR_READCONTENT);
         exit;
     }
     $content_data = $this->contentObj->getData();
     // permission check
     if (empty($content_data['can_edit'])) {
         if ($content_data['locked']) {
             redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_LOCKEDCONTENT);
             exit;
         } else {
             redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_EDITCONTENT);
             exit;
         }
     }
     // update the content
     pico_updatecontent($this->mydirname, $request['content_id'], $cat_data['post_auto_approved'], $cat_data['isadminormod']);
     $content_uri4html = XOOPS_URL . "/modules/{$this->mydirname}/" . pico_common_make_content_link4html($this->mod_config, $request['content_id'], $this->mydirname);
     // return uri
     if (!empty($_GET['ret']) && ($ret_uri = pico_main_parse_ret2uri($this->mydirname, $_GET['ret']))) {
         $ret_uri4html = htmlspecialchars($ret_uri, ENT_QUOTES);
     } else {
         $ret_uri4html = $content_uri4html;
     }
     // calling a delegate
     if (class_exists('XCube_DelegateUtils')) {
         XCube_DelegateUtils::raiseEvent('ModuleClass.Pico.Contentman.UpdateSuccess', $this->mydirname, $request['content_id'], $cat_data, $ret_uri4html);
     }
     if ($cat_data['post_auto_approved']) {
         // message "modified"
         redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTUPDATED);
     } else {
         // Notify for new waiting content (only for admin or mod)
         $users2notify = pico_main_get_moderators($this->mydirname, $cat_data['id']);
         if (empty($users2notify)) {
             $users2notify = array(0);
         }
         pico_main_trigger_event($this->mydirname, 'global', 0, 'waitingcontent', array('CONTENT_URL' => XOOPS_URL . "/modules/{$this->mydirname}/index.php?page=contentmanager&content_id=" . $request['content_id']), $users2notify);
         // message "waiting approval"
         redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTWAITINGUPDATE);
     }
     // view
     $this->is_need_header_footer = false;
 }
Ejemplo n.º 4
0
 function getData4html($process_body = false)
 {
     $myts =& PicoTextSanitizer::getInstance();
     $user_handler =& xoops_gethandler('user');
     $mod_config = $this->categoryObj->getOverriddenModConfig();
     $cat_data = $this->categoryObj->getData();
     // poster & modifier uname
     $poster =& $user_handler->get($this->data['poster_uid']);
     $poster_uname = is_object($poster) ? $poster->getVar('uname') : @_MD_PICO_REGISTERED_AUTOMATICALLY;
     $modifier =& $user_handler->get($this->data['modifier_uid']);
     $modifier_uname = is_object($modifier) ? $modifier->getVar('uname') : @_MD_PICO_REGISTERED_AUTOMATICALLY;
     $ret4html = array('link' => pico_common_make_content_link4html($mod_config, $this->data), 'poster_uname' => $poster_uname, 'modifier_uname' => $modifier_uname, 'votes_avg' => $this->data['votes_count'] ? $this->data['votes_sum'] / doubleval($this->data['votes_count']) : 0, 'subject' => $myts->makeTboxData4Show($this->data['subject'], 1, 1), 'body' => $this->data['body_cached'], 'tags_array' => $this->data['tags'] ? explode(' ', htmlspecialchars($this->data['tags'], ENT_QUOTES)) : array(), 'cat_title' => $myts->makeTboxData4Show($cat_data['cat_title'], 1, 1), 'can_vote' => is_object($GLOBALS['xoopsUser']) || $mod_config['guest_vote_interval'] ? true : false) + $this->data;
     // process body
     if ($this->data['last_cached_time'] < $this->data['modified_time'] || $process_body && !$this->data['use_cache']) {
         if (is_object(@$GLOBALS['xoopsTpl'])) {
             $ret4html['body'] = $this->filterBody($ret4html);
         } else {
             // process filterBody() after including XOOPS_ROOT_PATH/header.php
             $this->need_filter_body = true;
         }
     }
     return $ret4html;
 }
Ejemplo n.º 5
0
function pico_common_get_submenu($mydirname, $caller = 'xoops_version')
{
    static $submenus_cache;
    if (!empty($submenus_cache[$caller][$mydirname])) {
        return $submenus_cache[$caller][$mydirname];
    }
    $module_handler =& xoops_gethandler('module');
    $module =& $module_handler->getByDirname($mydirname);
    if (!is_object($module)) {
        return array();
    }
    $config_handler =& xoops_gethandler('config');
    $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
    $db =& Database::getInstance();
    $myts =& MyTextSanitizer::getInstance();
    $whr_read = '`cat_id` IN (' . implode(",", pico_common_get_categories_can_read($mydirname)) . ')';
    $categories = array(0 => array('pid' => -1, 'name' => '', 'url' => '', 'sub' => array()));
    // categories query
    $sql = "SELECT cat_id,pid,cat_title,cat_vpath FROM " . $db->prefix($mydirname . "_categories") . " WHERE ({$whr_read}) ORDER BY cat_order_in_tree";
    $crs = $db->query($sql);
    if ($crs) {
        while ($cat_row = $db->fetchArray($crs)) {
            $cat_id = intval($cat_row['cat_id']);
            $categories[$cat_id] = array('name' => $myts->makeTboxData4Show($cat_row['cat_title'], 1, 1), 'url' => pico_common_make_category_link4html($mod_config, $cat_row), 'is_category' => true, 'pid' => $cat_row['pid']);
        }
    }
    if (!($caller == 'sitemap_plugin' && !@$mod_config['sitemap_showcontents']) && !($caller == 'xoops_version' && !@$mod_config['submenu_showcontents'])) {
        // contents query
        $ors = $db->query("SELECT cat_id,content_id,vpath,subject FROM " . $db->prefix($mydirname . "_contents") . " WHERE show_in_menu AND visible AND created_time <= UNIX_TIMESTAMP() AND expiring_time > UNIX_TIMESTAMP() AND {$whr_read} ORDER BY weight,content_id");
        if ($ors) {
            while ($content_row = $db->fetchArray($ors)) {
                $cat_id = intval($content_row['cat_id']);
                $categories[$cat_id]['sub'][] = array('name' => $myts->makeTboxData4Show($content_row['subject'], 1, 1), 'url' => pico_common_make_content_link4html($mod_config, $content_row), 'is_category' => false);
            }
        }
    }
    // restruct categories
    $top_sub = !empty($categories[0]['sub']) ? $categories[0]['sub'] : array();
    $submenus_cache[$caller][$mydirname] = array_merge($top_sub, pico_common_restruct_categories($categories, 0));
    return $submenus_cache[$caller][$mydirname];
}
Ejemplo n.º 6
0
    }
    redirect_header(XOOPS_URL . "/modules/{$mydirname}/admin/index.php?page=contents&amp;cat_id={$cat_id}", 3, _MD_A_PICO_MSG_CONTENTSEXPORTED);
    exit;
}
//
// form stage
//
// category options as array
$cat_options = pico_common_get_cat_options($mydirname);
// fetch contents
if ($cat_id == SPECIAL_CAT_ID_DELETED) {
    $ors = $db->query("SELECT oh.*,up.uname AS poster_uname,um.uname AS modifier_uname,c.cat_title,c.cat_depth_in_tree,1 AS is_deleted  FROM " . $db->prefix($mydirname . "_content_histories") . " oh LEFT JOIN " . $db->prefix("users") . " up ON oh.poster_uid=up.uid LEFT JOIN " . $db->prefix("users") . " um ON oh.modifier_uid=um.uid LEFT JOIN " . $db->prefix($mydirname . "_categories") . " c ON oh.cat_id=c.cat_id LEFT JOIN " . $db->prefix($mydirname . "_contents") . " o ON o.content_id=oh.content_id WHERE o.content_id IS NULL GROUP BY oh.content_id ORDER BY oh.modified_time DESC");
} else {
    $whr_cat_id = $cat_id == SPECIAL_CAT_ID_ALL ? "1" : "o.cat_id={$cat_id}";
    $ors = $db->query("SELECT o.*,up.uname AS poster_uname,um.uname AS modifier_uname,c.cat_title,c.cat_depth_in_tree,0 AS is_deleted  FROM " . $db->prefix($mydirname . "_contents") . " o LEFT JOIN " . $db->prefix("users") . " up ON o.poster_uid=up.uid LEFT JOIN " . $db->prefix("users") . " um ON o.modifier_uid=um.uid LEFT JOIN " . $db->prefix($mydirname . "_categories") . " c ON o.cat_id=c.cat_id WHERE ({$whr_cat_id}) ORDER BY c.cat_depth_in_tree,o.weight,o.content_id");
}
$contents4assign = array();
while ($content_row = $db->fetchArray($ors)) {
    $wrap_full_path = XOOPS_TRUST_PATH . _MD_PICO_WRAPBASE . '/' . $mydirname . str_replace('..', '', $content_row['vpath']);
    $content4assign = array('id' => intval($content_row['content_id']), 'link' => pico_common_make_content_link4html($xoopsModuleConfig, $content_row), 'cat_title' => $myts->makeTboxData4Show($content_row['cat_title'], 1, 1), 'created_time_formatted' => formatTimestamp($content_row['created_time'], 'm'), 'modified_time_formatted' => formatTimestamp($content_row['modified_time'], 'm'), 'expiring_time_formatted' => formatTimestamp(@$content_row['expiring_time'], 'm'), 'poster_uname' => $content_row['poster_uid'] ? $myts->makeTboxData4Show($content_row['poster_uname']) : _MD_PICO_REGISTERED_AUTOMATICALLY, 'modifier_uname' => $content_row['modifier_uid'] ? $myts->makeTboxData4Show($content_row['modifier_uname']) : _MD_PICO_REGISTERED_AUTOMATICALLY, 'subject' => $myts->makeTboxData4Edit($content_row['subject']), 'vpath' => htmlspecialchars($content_row['vpath']), 'wrap_file' => is_file($wrap_full_path) ? array('mtime_formatted' => formatTimestamp(filemtime($wrap_full_path), 'm'), 'size' => filesize($wrap_full_path)) : false, 'histories' => $content_row['is_deleted'] ? pico_get_content_histories4assign($mydirname, intval($content_row['content_id'])) : array(), 'ef' => pico_common_unserialize($content_row['extra_fields']));
    $contents4assign[] = $content4assign + $content_row;
}
//
// display stage
//
xoops_cp_header();
include dirname(__FILE__) . '/mymenu.php';
$tpl =& new XoopsTpl();
$tpl->assign(array('mydirname' => $mydirname, 'mod_name' => $xoopsModule->getVar('name'), 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $xoopsModuleConfig['images_dir'], 'mod_config' => $xoopsModuleConfig, 'cat_id' => $cat_id, 'cat_link' => pico_common_make_category_link4html($xoopsModuleConfig, $cat_id, $mydirname), 'cat_title' => htmlspecialchars($cat_title, ENT_QUOTES), 'cat_options' => $cat_options + array(SPECIAL_CAT_ID_ALL => _MD_PICO_ALLCONTENTS, SPECIAL_CAT_ID_DELETED => _MD_PICO_DELETEDCONTENTS), 'cat_options4move' => $cat_options, 'module_options' => $exportable_modules, 'contents' => $contents4assign, 'gticket_hidden' => $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'pico_admin')));
$tpl->display('db:' . $mydirname . '_admin_contents.html');
xoops_cp_footer();
 function render()
 {
     redirect_header(XOOPS_URL . "/modules/{$this->mydirname}/" . pico_common_make_content_link4html($this->mod_config, $this->contentObj->getData()), 0, _MD_PICO_MSG_VOTEACCEPTED);
     exit;
 }
Ejemplo n.º 8
0
// pagenav
$pagenav = '' ;
$pagenav_obj = new XoopsPageNav( $hit , $num , $pos , 'pos', "page=extras&amp;num=$num&amp;content_id=$content_id&amp;order=".urlencode($order)."&amp;txt=".urlencode($txt) ) ;
$pagenav = $pagenav_obj->renderNav() ;

// main query
$ers = $db->query( "SELECT ce.*,o.vpath,o.subject AS content_subject FROM ".$db->prefix($mydirname."_content_extras")." ce LEFT JOIN ".$db->prefix($mydirname."_contents")." o ON o.content_id=ce.content_id WHERE $whr_extra_id AND $whr_content_id AND $whr_txt ORDER BY $order LIMIT $pos,$num" ) ;

$extras4assign = array() ;
while( $extra_row = $db->fetchArray( $ers ) ) {
	$data = pico_common_unserialize( $extra_row['data'] ) ;
	if( empty( $data ) ) $data = $extra_row['data'] ;
	$extra4assign = array(
		'id' => intval( $extra_row['content_extra_id'] ) ,
		'link' => pico_common_make_content_link4html( $xoopsModuleConfig , $extra_row ) ,
		'extra_type_formatted' => str_replace( '::' , '<br />' , htmlspecialchars( $extra_row['extra_type'] , ENT_QUOTES ) ) ,
		'created_time_formatted' => formatTimestamp( $extra_row['created_time'] ) ,
		'data' => $data ,
		'data_summary_short_raw' => xoops_substr( pico_admin_make_summary4extras( $data ) , 0 , 100 ) ,
		'data_summary_raw' => pico_admin_make_summary4extras( $data ) ,
	) ;
	$extras4assign[] = $extra4assign + $extra_row ;
}


//
// display stage
//

xoops_cp_header();
 function execute($request)
 {
     parent::execute($request);
     // $contentObj
     $contentObj =& new PicoContent($this->mydirname, $request['content_id'], $this->currentCategoryObj);
     // check existence
     if ($contentObj->isError()) {
         redirect_header(XOOPS_URL . "/modules/{$this->mydirname}/index.php", 2, _MD_PICO_ERR_READCONTENT);
         exit;
     }
     $cat_data = $this->currentCategoryObj->getData();
     $this->assign['category'] = $this->currentCategoryObj->getData4html();
     $content_data = $contentObj->getData();
     $this->assign['content'] = $contentObj->getData4html(true);
     $this->contentObjs['content'] =& $contentObj;
     // permission check
     if (empty($content_data['can_read']) || empty($content_data['can_readfull'])) {
         if ($this->uid > 0) {
             redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_PERMREADFULL);
         } else {
             redirect_header(XOOPS_URL . '/user.php', 2, _MD_PICO_ERR_LOGINTOREADFULL);
         }
         exit;
     }
     // auto-register
     if (!empty($this->mod_config['wraps_auto_register']) && @$cat_data['cat_vpath'][0] == '/' && $content_data['poster_uid'] == 0 && $content_data['vpath'] != '') {
         $register_class = empty($this->mod_config['auto_register_class']) ? 'PicoAutoRegisterWraps' : $this->mod_config['auto_register_class'];
         require_once dirname(dirname(__FILE__)) . '/class/' . $register_class . '.class.php';
         $register_obj =& new $register_class($this->mydirname, $this->mod_config);
         $is_updated = $register_obj->updateContent($content_data['content_id'], $content_data['vpath']);
         if ($is_updated > 0) {
             // reload if the content is updated
             header('Location: ' . pico_common_unhtmlspecialchars($this->assign['mod_url']) . '/' . pico_common_unhtmlspecialchars($this->assign['content']['link']));
             exit;
         }
     }
     // prev/next content
     $prevContentObj =& $contentObj->getPrevContent();
     $this->assign['prev_content'] = is_object($prevContentObj) ? $prevContentObj->getData4html() : array();
     $this->contentObjs['prev_content'] =& $prevContentObj;
     $nextContentObj =& $contentObj->getNextContent();
     $this->assign['next_content'] = is_object($nextContentObj) ? $nextContentObj->getData4html() : array();
     $this->contentObjs['next_content'] =& $nextContentObj;
     // link for "tell to friends"
     if ($this->mod_config['use_taf_module']) {
         $this->assign['content']['tellafriend_uri'] = XOOPS_URL . '/modules/tellafriend/index.php?target_uri=' . rawurlencode(XOOPS_URL . "/modules/{$this->mydirname}/" . pico_common_make_content_link4html($this->mod_config, $content_data)) . '&amp;subject=' . rawurlencode(sprintf(_MD_PICO_FMT_TELLAFRIENDSUBJECT, @$GLOBALS['xoopsConfig']['sitename']));
     } else {
         $this->assign['content']['tellafriend_uri'] = 'mailto:?subject=' . pico_main_escape4mailto(sprintf(_MD_PICO_FMT_TELLAFRIENDSUBJECT, @$GLOBALS['xoopsConfig']['sitename'])) . '&amp;body=' . pico_main_escape4mailto(sprintf(_MD_PICO_FMT_TELLAFRIENDBODY, $content_data['subject'])) . '%0A' . XOOPS_URL . "/modules/{$this->mydirname}/" . rawurlencode(pico_common_make_content_link4html($this->mod_config, $content_data));
     }
     // category list can be read for category jumpbox etc.
     $categoryHandler =& new PicoCategoryHandler($this->mydirname, $this->permissions);
     $categories = $categoryHandler->getAllCategories();
     $this->assign['categories_can_read'] = array();
     foreach ($categories as $tmpObj) {
         $tmp_data = $tmpObj->getData();
         $this->assign['categories_can_read'][$tmp_data['id']] = str_repeat('--', $tmp_data['cat_depth_in_tree']) . $tmp_data['cat_title'];
     }
     // count up 'viewed'
     if ($content_data['modifier_ip'] != @$_SERVER['REMOTE_ADDR']) {
         $contentObj->incrementViewed();
     }
     // breadcrumbs
     $breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
     $breadcrumbsObj->appendPath('', $this->assign['content']['subject']);
     $this->assign['xoops_breadcrumbs'] = $breadcrumbsObj->getXoopsbreadcrumbs();
     $this->assign['xoops_pagetitle'] = $this->assign['content']['subject'];
     // views
     switch ($request['view']) {
         case 'singlecontent':
             $this->template_name = 'db:' . $this->mydirname . '_independent_singlecontent.html';
             $this->is_need_header_footer = false;
             break;
         case 'print':
             $this->template_name = 'db:' . $this->mydirname . '_independent_print.html';
             $this->is_need_header_footer = false;
             break;
         default:
             $this->template_name = empty($this->mod_config['tpl_viewcontent']) ? $this->mydirname . '_main_viewcontent.html' : $this->mod_config['tpl_viewcontent'];
             $this->is_need_header_footer = true;
             break;
     }
     // htmlheader
     if (!empty($this->mod_config['allow_each_htmlheader'])) {
         $this->html_header .= $content_data['htmlheader'];
     }
 }
Ejemplo n.º 10
0
$whr_txt = $txt ? "ce.data LIKE '%" . addslashes($txt) . "%'" : '1';
// pre query
list($hit) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix($mydirname . "_content_extras") . " ce LEFT JOIN " . $db->prefix($mydirname . "_contents") . " o ON o.content_id=ce.content_id WHERE {$whr_extra_id} AND {$whr_content_id} AND {$whr_txt}"));
// pagenav
$pagenav = '';
$pagenav_obj = new XoopsPageNav($hit, $num, $pos, 'pos', "page=extras&amp;num={$num}&amp;content_id={$content_id}&amp;order=" . urlencode($order) . "&amp;txt=" . urlencode($txt));
$pagenav = $pagenav_obj->renderNav();
// main query
$ers = $db->query("SELECT ce.*,o.vpath,o.subject AS content_subject FROM " . $db->prefix($mydirname . "_content_extras") . " ce LEFT JOIN " . $db->prefix($mydirname . "_contents") . " o ON o.content_id=ce.content_id WHERE {$whr_extra_id} AND {$whr_content_id} AND {$whr_txt} ORDER BY {$order} LIMIT {$pos},{$num}");
$extras4assign = array();
while ($extra_row = $db->fetchArray($ers)) {
    $data = pico_common_unserialize($extra_row['data']);
    if (empty($data)) {
        $data = $extra_row['data'];
    }
    $extra4assign = array('id' => intval($extra_row['content_extra_id']), 'link' => pico_common_make_content_link4html($xoopsModuleConfig, $extra_row), 'extra_type_formatted' => str_replace('::', '<br />', htmlspecialchars($extra_row['extra_type'], ENT_QUOTES)), 'created_time_formatted' => formatTimestamp($extra_row['created_time']), 'data' => $data, 'data_summary_short_raw' => xoops_substr(pico_admin_make_summary4extras($data), 0, 100), 'data_summary_raw' => pico_admin_make_summary4extras($data));
    $extras4assign[] = $extra4assign + $extra_row;
}
//
// display stage
//
xoops_cp_header();
include dirname(__FILE__) . '/mymenu.php';
$tpl = new XoopsTpl();
$tpl->assign(array('mydirname' => $mydirname, 'mod_name' => $xoopsModule->getVar('name'), 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $xoopsModuleConfig['images_dir'], 'mod_config' => $xoopsModuleConfig, 'extras' => $extras4assign, 'num' => $num, 'order' => $order, 'pagenav' => $pagenav, 'content_id' => $content_id, 'txt_raw' => $txt, 'gticket_hidden' => $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'pico_admin')));
if ($extra_id) {
    $tpl->display('db:' . $mydirname . '_admin_extras_detail.html');
} else {
    $tpl->display('db:' . $mydirname . '_admin_extras.html');
}
xoops_cp_footer();
 function modifyRequest($request, &$currentCategoryObj)
 {
     $this->config = $currentCategoryObj->getOverriddenModConfig();
     $cat_data = $currentCategoryObj->getData();
     if (empty($this->config['show_listasindex']) && $request['controller'] == 'category' && $request['view'] == 'list' && empty($request['content_id'])) {
         $content_ids = $currentCategoryObj->getContentIdsInNavi();
         $top_content_id = @$content_ids[0];
         if ($top_content_id > 0) {
             // redirect to the top of the content
             $redirect_uri = XOOPS_URL . '/modules/' . $this->mydirname . '/' . pico_common_make_content_link4html($this->config, $top_content_id, $this->mydirname);
             if (headers_sent()) {
                 redirect_header($redirect_uri, 0, '&nbsp;');
             } else {
                 header('Location: ' . $redirect_uri);
             }
         } else {
             $request['controller'] = 'category';
             $request['view'] = 'list';
             $request['content_id'] = 0;
         }
     }
     return $request;
 }
Ejemplo n.º 12
0
 function pico_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $uid)
 {
     // get this module's config
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($mydirname);
     $config_handler =& xoops_gethandler('config');
     $configs = $config_handler->getConfigList($module->mid());
     // check xmobile or not
     $is_xmobile = false;
     if (function_exists('debug_backtrace') && ($backtrace = debug_backtrace())) {
         if (strstr($backtrace[2]['file'], '/xmobile/actions/')) {
             $is_xmobile = true;
         }
     }
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     // where by uid
     if (!empty($uid)) {
         if (empty($configs['search_by_uid'])) {
             return array();
         }
         $whr_uid = 'o.poster_uid=' . intval($uid);
     } else {
         $whr_uid = '1';
     }
     // where by keywords
     if (is_array($keywords) && count($keywords) > 0) {
         switch (strtolower($andor)) {
             case "and":
                 $whr_kw = "";
                 foreach ($keywords as $keyword) {
                     $whr_kw .= "(`for_search` LIKE '%{$keyword}%') AND ";
                 }
                 $whr_kw .= "1";
                 break;
             case "or":
                 $whr_kw = "";
                 foreach ($keywords as $keyword) {
                     $whr_kw .= "(`for_search` LIKE '%{$keyword}%') OR ";
                 }
                 $whr_kw .= "0";
                 break;
             default:
                 $whr_kw = "(`for_search` LIKE '%{$keywords['0']}%')";
                 break;
         }
     } else {
         $whr_kw = 1;
     }
     $content_handler =& new PicoContentHandler($mydirname);
     $contents4assign = $content_handler->getContents4assign("({$whr_kw}) AND ({$whr_uid})", 'created_time DESC', $offset, $limit, false);
     $ret = array();
     foreach ($contents4assign as $content) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext && $content['can_readfull']) {
             $full_context = strip_tags(@$content['body_cached']);
             if (function_exists('easiestml')) {
                 $full_context = easiestml($full_context);
             }
             $context = search_make_context($full_context, $keywords);
         } else {
             $context = '';
         }
         $ret[] = array('image' => '', 'link' => $is_xmobile ? 'index.php?cat_id=' . $content['cat_id'] . '&content_id=' . $content['content_id'] : pico_common_make_content_link4html($configs, $content), 'title' => $content['subject'], 'time' => $content['created_time'], 'uid' => empty($configs['search_by_uid']) ? 0 : $content['poster_uid'], 'context' => $context);
     }
     return $ret;
 }
Ejemplo n.º 13
0
$pos = empty($_GET['pos']) ? 0 : intval($_GET['pos']);
$num = empty($_GET['num']) ? 30 : intval($_GET['num']);
$order = in_array(@$_GET['order'], $allowed_orders) ? $_GET['order'] : $allowed_orders[0];
// pre query
list($hit) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix($mydirname . "_tags")));
// pagenav
$pagenav = '';
$pagenav_obj = new XoopsPageNav($hit, $num, $pos, 'pos', "page=tags&amp;num={$num}&amp;order=" . urlencode($order));
$pagenav = $pagenav_obj->renderNav();
// main query
$trs = $db->query("SELECT * FROM " . $db->prefix($mydirname . "_tags") . " ORDER BY {$order} LIMIT {$pos},{$num}");
$tags4assign = array();
while ($tag_row = $db->fetchArray($trs)) {
    // get contents
    $contents4assign = array();
    $ors = $db->query("SELECT content_id,vpath,subject FROM " . $db->prefix($mydirname . "_contents") . " WHERE content_id IN (" . $tag_row['content_ids'] . ") LIMIT 10");
    while ($content_row = $db->fetchArray($ors)) {
        $contents4assign[] = array('id' => intval($content_row['content_id']), 'link' => pico_common_make_content_link4html($xoopsModuleConfig, $content_row), 'subject' => $myts->makeTboxData4Show($content_row['subject'], 1, 1)) + $content_row;
    }
    $tag4assign = array('label_raw' => $tag_row['label'], 'label' => htmlspecialchars($tag_row['label'], ENT_QUOTES), 'contents' => $contents4assign);
    $tags4assign[] = $tag4assign + $tag_row;
}
//
// display stage
//
xoops_cp_header();
include dirname(__FILE__) . '/mymenu.php';
$tpl =& new XoopsTpl();
$tpl->assign(array('mydirname' => $mydirname, 'mod_name' => $xoopsModule->getVar('name'), 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $xoopsModuleConfig['images_dir'], 'mod_config' => $xoopsModuleConfig, 'tags' => $tags4assign, 'num' => $num, 'order' => $order, 'allowed_orders' => $allowed_orders, 'pagenav' => $pagenav, 'gticket_hidden' => $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'pico_admin')));
$tpl->display('db:' . $mydirname . '_admin_tags.html');
xoops_cp_footer();