function b_pico_list_show($options) { // options $mytrustdirname = basename(dirname(dirname(__FILE__))); $mydirname = empty($options[0]) ? $mytrustdirname : $options[0]; $categories = trim(@$options[1]) === '' ? array() : array_map('intval', explode(',', $options[1])); $selected_order = empty($options[2]) || !in_array($options[2], b_pico_list_allowed_order()) ? 'o.created_time DESC' : $options[2]; $limit_offset = empty($options[3]) ? '10' : preg_replace('/[^0-9,]/', '', $options[3]); if (strstr($limit_offset, ',')) { list($offset, $limit) = array_map('intval', explode(',', $limit_offset)); } else { $offset = 0; $limit = intval($limit_offset); } $this_template = empty($options[4]) ? 'db:' . $mydirname . '_block_list.html' : trim($options[4]); $display_body = empty($options[5]) ? false : true; // mydirname check if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } // content handler $content_handler = new PicoContentHandler($mydirname); // contentObjects if (sizeof($categories) == 0) { // no category specified $contents4assign = $content_handler->getContents4assign('1', $selected_order, $offset, $limit, false); } else { if (sizeof($categories) == 1) { // single category $contents4assign = $content_handler->getContents4assign('o.cat_id=' . $categories[0], $selected_order, $offset, $limit, false); } else { // multi category $contents4assign = $content_handler->getContents4assign('o.cat_id IN (' . implode(',', $categories) . ')', $selected_order, $offset, $limit, false); } } // compatibility for 1.5/1.6 foreach (array_keys($contents4assign) as $i) { $contents4assign[$i]['body'] = $display_body ? $contents4assign[$i]['body_cached'] : ''; } // module config (not overridden yet) $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($mydirname); $config_handler =& xoops_gethandler('config'); $configs = $config_handler->getConfigList($module->mid()); // constpref $constpref = '_MB_' . strtoupper($mydirname); // make an array named 'block' $block = array('mytrustdirname' => $mytrustdirname, 'mydirname' => $mydirname, 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $configs['images_dir'], 'mod_config' => $configs, 'contents' => $contents4assign, 'display_body' => $display_body, 'lang_category' => constant($constpref . '_CATEGORY'), 'lang_topcategory' => constant($constpref . '_TOPCATEGORY')); if (empty($options['disable_renderer'])) { // render it require_once XOOPS_ROOT_PATH . '/class/template.php'; $tpl = new XoopsTpl(); $tpl->assign('block', $block); $ret['content'] = $tpl->fetch($this_template); return $ret; } else { // just assign it return $block; } }
function syncCatvpath($cat_id, $cat_vpath, $wrap_dir) { $content_handler = new PicoContentHandler($this->mydirname); $registered_vpaths = array_flip($content_handler->getAutoRegisteredContents($cat_id)); $removal_vpaths = $registered_vpaths; $affected_rows = 0; $dh = opendir($wrap_dir); $additional_vpaths = array(); while (($file = readdir($dh)) !== false) { if (preg_match(_MD_PICO_AUTOREGIST4PREGEX, $file)) { $vpath = $cat_vpath . '/' . $file; if (isset($removal_vpaths[$vpath])) { // already registered unset($removal_vpaths[$vpath]); $affected_rows += $this->updateContent($registered_vpaths[$vpath], $vpath); } else { // to be registered $additional_vpaths[$vpath] = 0; } } } closedir($dh); // remove foreach ($removal_vpaths as $vpath => $content_id) { $this->removeContent($content_id); $affected_rows++; } // register foreach ($additional_vpaths as $vpath => $content_id) { if ($this->registerContent($cat_id, $vpath)) { $affected_rows++; } } return $affected_rows; }
function execute($request) { parent::execute($request); $whr = '1'; $queries = array(); // query type "tag" if (!empty($request['tag'])) { $queries[] = array('type' => 'tag', 'value' => $request['tag']); // get content_ids $tag_handler = new PicoTagHandler($this->mydirname); $content_ids_sc = $tag_handler->getContentIdsCS($request['tag']); if ($content_ids_sc) { $whr .= " AND (`content_id` IN (" . $content_ids_sc . "))"; } else { $whr .= " AND 0"; } } // content handler $content_handler = new PicoContentHandler($this->mydirname); // contents (order by modified_time DESC) $this->assign['contents'] = array(); $contents4assign = $content_handler->getContents4assign($whr); foreach ($contents4assign as $content4assign) { $this->assign['contents'][] = $content4assign; } // render $queries $query4assign = $this->renderQueries($queries); $this->assign['query'] = $query4assign; // breadcrumbs $breadcrumbsObj =& AltsysBreadcrumbs::getInstance(); $breadcrumbsObj->appendPath('', $query4assign['title']); $this->assign['xoops_breadcrumbs'] = $breadcrumbsObj->getXoopsbreadcrumbs(); $this->assign['xoops_pagetitle'] = $query4assign['title']; // views ('list') $this->template_name = $this->mydirname . '_main_querycontents.html'; $this->is_need_header_footer = true; }
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; }
function getLatestContents($num = 0, $fetch_from_subcategories = false) { $content_handler = new PicoContentHandler($this->mydirname); return $content_handler->getCategoryLatestContents($this, $num, $fetch_from_subcategories); }