Ejemplo n.º 1
0
 function getContents4assign($whr_append = '1', $order = 'weight', $offset = 0, $limit = 100, $return_prohibited_also = false)
 {
     $db =& Database::getInstance();
     $sql = "SELECT content_id FROM " . $db->prefix($this->mydirname . "_contents") . " o WHERE ({$whr_append}) ORDER BY {$order}";
     if (!($ors = $db->query($sql))) {
         if ($GLOBALS['xoopsUser']->isAdmin()) {
             echo $db->logger->dumpQueries();
         }
         exit;
     }
     $ret = array();
     $waiting = $offset;
     while (list($content_id) = $db->fetchRow($ors)) {
         if (sizeof($ret) >= $limit) {
             break;
         }
         $objTemp = new PicoContent($this->mydirname, $content_id);
         if ($return_prohibited_also || $objTemp->data['can_read']) {
             if (--$waiting < 0) {
                 $ret[$content_id] = $objTemp->getData4html();
             }
         }
         unset($objTemp);
     }
     return $ret;
 }
 function processPreview($request)
 {
     // Ticket Check
     if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) {
         redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors());
     }
     // initialize
     $cat_data = $this->currentCategoryObj->getData();
     $myts =& PicoTextSanitizer::getInstance();
     // assigning other than preview/request
     // parent::execute( $request ) ;
     // permission check (can_edit) done
     // request
     $request = pico_get_requests4content($this->mydirname, $errors = array(), $cat_data['post_auto_approved'], $cat_data['isadminormod'], $this->assign['content']['id']);
     $request['body_raw'] = $request['body'];
     $request['subject_raw'] = $request['subject'];
     $request4assign = array_map('htmlspecialchars_ent', $request);
     $this->assign['request'] = $request4assign;
     // override content data for edit
     $this->assign['content'] = $request4assign + $this->assign['content'];
     $this->assign['content']['filter_infos'] = pico_main_get_filter_infos($request['filters'], $cat_data['isadminormod']);
     $this->assign['content']['body_raw'] = $request['body'];
     $this->assign['content']['extra_fields'] = $request['extra_fields'];
     $this->assign['content']['ef'] = pico_common_unserialize($request['extra_fields']);
     // temporary $contentObj
     $tmpContentObj = new PicoContent($this->mydirname, 0, $this->currentCategoryObj, true);
     // preview
     $this->assign['preview'] = array('errors' => $errors, 'htmlheader' => $request['htmlheader'], 'subject' => $myts->makeTboxData4Show($request['subject'], 1, 1), 'body' => $tmpContentObj->filterBody($this->assign['content']));
 }
Ejemplo n.º 3
0
function b_pico_content_show($options)
{
    // options
    $mytrustdirname = basename(dirname(dirname(__FILE__)));
    $mydirname = empty($options[0]) ? $mytrustdirname : $options[0];
    $content_id = intval(@$options[1]);
    $this_template = empty($options[2]) ? 'db:' . $mydirname . '_block_content.html' : trim($options[2]);
    $process_body = empty($options[3]) ? false : true;
    // mydirname check
    if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
        die('Invalid mydirname');
    }
    // $contentObj
    $contentObj = new PicoContent($mydirname, $content_id);
    $content_data = $contentObj->getData();
    // permission check
    if (empty($content_data['can_read']) || empty($content_data['can_readfull'])) {
        return array();
    }
    // check existence
    if ($contentObj->isError()) {
        return array('content' => 'invalid block id');
    }
    // module config (overridden)
    $configs = $contentObj->categoryObj->getOverriddenModConfig();
    // constpref
    $constpref = '_MB_' . strtoupper($mydirname);
    // assigning (process_body)
    $content4assign = $contentObj->getData4html($process_body);
    // convert links from relative to absolute (wraps mode only)
    if ($configs['use_wraps_mode']) {
        $content_url = XOOPS_URL . '/modules/' . $mydirname . '/' . $content4assign['link'];
        $wrap_base_url = substr($content_url, 0, strrpos($content_url, '/'));
        $pattern = "/(\\s+href|\\s+src)\\=(\"|\\')?(?![a-z]+:|\\/|\\#)([^, \r\n\"\\(\\)'<>]+)/i";
        $replacement = "\\1=\\2{$wrap_base_url}/\\3";
        $content4assign['body'] = preg_replace($pattern, $replacement, $content4assign['body']);
    }
    // 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, 'content' => $content4assign);
    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;
    }
}
Ejemplo n.º 4
0
 function pico_notify_base($mydirname, $category, $item_id)
 {
     include_once dirname(__FILE__) . '/include/common_functions.php';
     $db =& Database::getInstance();
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($mydirname);
     $picoPermission =& PicoPermission::getInstance();
     $permissions = $picoPermission->getPermissions($mydirname);
     // global
     if ($category == 'global') {
         $item['name'] = '';
         $item['url'] = '';
     }
     // category
     if ($category == 'category') {
         // Assume we have a valid cat_id
         $cat_id = intval($item_id);
         $currentCategoryObj = new PicoCategory($mydirname, intval($cat_id), $permissions);
         $cat_data = $currentCategoryObj->getData();
         if (!$cat_data['can_read']) {
             return false;
         }
         $category4assign = $currentCategoryObj->getData4html();
         // $item should be assigned HTML escaped data
         $item['name'] = $category4assign['cat_title'];
         $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . $category4assign['link'];
     }
     // content
     if ($category == 'content') {
         // Assume we have a valid content_id
         $content_id = intval($item_id);
         $cat_id = pico_common_get_cat_id_from_content_id($mydirname, $content_id);
         $currentCategoryObj = new PicoCategory($mydirname, intval($cat_id), $permissions);
         $cat_data = $currentCategoryObj->getData();
         if (!$cat_data['can_read']) {
             return false;
         }
         $contentObj = new PicoContent($mydirname, $content_id, $currentCategoryObj);
         $content4assign = $contentObj->getData4html();
         if (!$content4assign['can_read']) {
             return false;
         }
         // $item should be assigned HTML escaped data
         $item['name'] = $content4assign['subject'];
         $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/' . $content4assign['link'];
     }
     return $item;
 }
 function execute($request)
 {
     parent::execute($request);
     // makecontent/contentmanager
     $page = empty($request['makecontent']) ? 'contentmanager' : 'makecontent';
     // $contentObj
     $contentObj = new PicoContent($this->mydirname, $request['content_id'], $this->currentCategoryObj, $page == 'makecontent');
     // check existence
     if ($contentObj->isError()) {
         redirect_header(XOOPS_URL . "/modules/{$this->mydirname}/index.php", 2, _MD_PICO_ERR_READCONTENT);
         exit;
     }
     // fetch data from DB
     $cat_data = $this->currentCategoryObj->getData();
     $this->assign['category'] = $this->currentCategoryObj->getData4html();
     $content_data = $contentObj->getData();
     $this->assign['content_base'] = $contentObj->getData4html(true);
     $this->contentObjs['content_base'] =& $contentObj;
     $this->assign['content'] = $contentObj->getData4edit();
     // permission check
     if ($page == 'makecontent') {
         if (empty($cat_data['can_post'])) {
             redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_CREATECONTENT);
         }
     } else {
         if (empty($content_data['can_edit'])) {
             redirect_header(XOOPS_URL . '/', 2, $content_data['locked'] ? _MD_PICO_ERR_LOCKEDCONTENT : _MD_PICO_ERR_EDITCONTENT);
         }
     }
     // category list can be read for category jumpbox etc.
     $categoryHandler = new PicoCategoryHandler($this->mydirname, $this->permissions);
     $categories = $categoryHandler->getAllCategories();
     $this->assign['categories_can_post'] = array();
     foreach ($categories as $tmpObj) {
         $tmp_data = $tmpObj->getData();
         if (empty($tmp_data['can_post']) && empty($tmp_data['can_edit'])) {
             continue;
         }
         $this->assign['categories_can_post'][$tmp_data['id']] = str_repeat('--', $tmp_data['cat_depth_in_tree']) . $tmp_data['cat_title'];
     }
     // vpath options
     $this->assign['content']['wraps_files'] = array('' => '---') + pico_main_get_wraps_files_recursively($this->mydirname, '/');
     // breadcrumbs
     $breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
     if ($page == 'makecontent') {
         $breadcrumbsObj->appendPath('', _MD_PICO_LINK_MAKECONTENT);
         $this->assign['xoops_pagetitle'] = _MD_PICO_LINK_MAKECONTENT;
     } else {
         $breadcrumbsObj->appendPath(XOOPS_URL . '/modules/' . $this->mydirname . '/' . $this->assign['content']['link'], $this->assign['content']['subject']);
         $breadcrumbsObj->appendPath('', _MD_PICO_CONTENTMANAGER);
         $this->assign['xoops_pagetitle'] = _MD_PICO_CONTENTMANAGER;
     }
     $this->assign['xoops_breadcrumbs'] = $breadcrumbsObj->getXoopsbreadcrumbs();
     // misc assigns
     $this->assign['content_histories'] = pico_get_content_histories4assign($this->mydirname, $content_data['id']);
     $this->assign['page'] = $page;
     $this->assign['formtitle'] = $page == 'makecontent' ? _MD_PICO_LINK_MAKECONTENT : _MD_PICO_LINK_EDITCONTENT;
     $this->assign['gticket_hidden'] = $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__, 1800, 'pico');
     // views
     $this->template_name = $this->mydirname . '_main_content_form.html';
     $this->is_need_header_footer = true;
     // preview
     $this->processPreview($request);
     // editor (wysiwyg etc)
     $editor_assigns = $this->getEditorAssigns('body', $this->assign['content']['body_raw']);
     $this->assign['body_wysiwyg'] = $editor_assigns['body'];
     $this->html_header .= $editor_assigns['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(__FILE__) . '/' . $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 = $this->mydirname . '_main_viewcontent.html';
             $this->is_need_header_footer = true;
             break;
     }
     // htmlheader
     if (!empty($this->mod_config['allow_each_htmlheader'])) {
         $this->html_header .= $content_data['htmlheader'];
     }
 }