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 pico_main_get_wraps_files_recursively($mydirname, $dir_path = '/') { $full_dir_path = XOOPS_TRUST_PATH . _MD_PICO_WRAPBASE . '/' . $mydirname . $dir_path; if (!is_dir($full_dir_path)) { return array(); } $ret = array(); $db =& Database::getInstance(); // parse currenct directry $dir_tmps = array(); $file_tmps = array(); $dh = opendir($full_dir_path); while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) == '.') { continue; } if (is_dir($full_dir_path . $file)) { $dir_tmps[] = $file; } else { if (is_file($full_dir_path . $file)) { $ext = strtolower(substr(strrchr($file, '.'), 1)); if (in_array($ext, explode('|', _MD_PICO_EXTS4HTMLWRAPPING))) { $file_tmps[] = $file; } } } } closedir($dh); // files foreach ($file_tmps as $file_tmp) { $file_path4key = $dir_path . $file_tmp; $ret[$file_path4key] = htmlspecialchars('XOOPS_TRUST_PATH' . _MD_PICO_WRAPBASE . '/' . $mydirname . $file_path4key, ENT_QUOTES); $myrow = $db->fetchArray($db->query("SELECT subject FROM " . $db->prefix($mydirname . "_contents") . " WHERE vpath='" . addslashes($file_path4key) . "'")); if (!empty($myrow)) { $ret[$file_path4key] .= ' (' . htmlspecialchars(xoops_substr($myrow['subject'], 0, 20), ENT_QUOTES) . ')'; } } // subdirs foreach ($dir_tmps as $dir_tmp) { $ret += pico_main_get_wraps_files_recursively($mydirname, $dir_path . $dir_tmp . '/'); } return $ret; }