本文整理汇总了PHP中XoopsTree类的典型用法代码示例。如果您正苦于以下问题:PHP XoopsTree类的具体用法?PHP XoopsTree怎么用?PHP XoopsTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XoopsTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: b_gnavi_d3pipes_joints
function b_gnavi_d3pipes_joints($options)
{
global $xoopsDB;
$mydirname = empty($options[0]) ? basename(dirname(dirname(__FILE__))) : $options[0];
if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
die('Invalid mydirname');
}
require dirname(dirname(__FILE__)) . '/include/read_configs.php';
$cat_limitation = empty($options[1]) ? 0 : 1;
$photos_num = empty($options[2]) ? 10 : intval($options[2]);
$show_desc = empty($options[3]) ? 0 : 1;
$query = "ORDER BY unixtime DESC";
$title_max_length = 255;
// Category limitation
if ($cat_limitation) {
include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
$cattree = new XoopsTree($table_cat, "cid", "pid");
$children = $cattree->getAllChildId($cat_limitation);
$whr_cat = "l.cid IN (";
foreach ($children as $child) {
$whr_cat .= "{$child},";
}
$whr_cat .= "{$cat_limitation})";
for ($i = 1; $i <= 4; $i++) {
$whr_cat .= " OR l.cid{$i} IN (";
foreach ($children as $child) {
$whr_cat .= "{$child},";
}
$whr_cat .= "{$cat_limitation})";
}
$whr_cat = "(" . $whr_cat . ")";
} else {
$whr_cat = '1';
}
$block = array();
$myts =& MyTextSanitizer::getInstance();
if ($show_desc) {
$result = $xoopsDB->query("SELECT l.lid , l.cid , l.title , l.ext , l.res_x , l.res_y , l.submitter , l.status , l.date AS unixtime , l.hits , l.rating , l.votes , l.comments , c.title AS cat_title ,t.description ,t.arrowhtml FROM {$table_photos} l LEFT JOIN {$table_cat} c ON l.cid=c.cid LEFT JOIN {$table_text} t ON l.lid=t.lid WHERE l.status>0 AND {$whr_cat} {$query}", $photos_num, 0);
} else {
$result = $xoopsDB->query("SELECT l.lid , l.cid , l.title , l.ext , l.res_x , l.res_y , l.submitter , l.status , l.date AS unixtime , l.hits , l.rating , l.votes , l.comments , c.title AS cat_title FROM {$table_photos} l LEFT JOIN {$table_cat} c ON l.cid=c.cid WHERE l.status>0 AND {$whr_cat} {$query}", $photos_num, 0);
}
$count = 1;
while ($photo = $xoopsDB->fetchArray($result)) {
$photo['title'] = xoops_substr($myts->makeTboxData4Show($photo['title']), 0, $title_max_length + 3);
$photo['cat_title'] = $myts->makeTboxData4Show($photo['cat_title']);
$photo['date'] = formatTimestamp($photo['unixtime'], 's');
if ($show_desc) {
$photo['body'] = xoops_substr(strip_tags($myts->displayTarea($photo['description'], $photo['arrowhtml'], 1, 1, 1, 1, 1)), 0, 512);
} else {
$photo['body'] = '';
}
$photo['date'] = formatTimestamp($photo['unixtime'], 's');
$block['photo'][$count++] = $photo;
}
$block['mod_url'] = $mod_url;
return $block;
}
示例2: b_sitemap_oledrion
/**
* oledrion
*
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Hervé Thouzard (http://www.herve-thouzard.com/)
* @version $Id: oledrion.php 12290 2014-02-07 11:05:17Z beckmi $
*/
function b_sitemap_oledrion()
{
require '../oledrion/header.php';
global $sitemap_configs;
$xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
$table = $xoopsDB->prefix('oledrion_cat');
$id_name = 'cat_cid';
$pid_name = 'cat_pid';
$title_name = 'cat_title';
$url = 'category.php?cat_cid=';
$order = 'cat_title';
include_once XOOPS_ROOT_PATH . '/class/xoopstree.php';
$mytree = new XoopsTree($table, $id_name, $pid_name);
$xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
$sitemap = array();
$myts = MyTextSanitizer::getInstance();
$i = 0;
$sql = "SELECT `{$id_name}`,`{$title_name}` FROM `{$table}` WHERE `{$pid_name}`=0";
if ($order != '') {
$sql .= " ORDER BY `{$order}`";
}
$result = $xoopsDB->query($sql);
while (list($catid, $name) = $xoopsDB->fetchRow($result)) {
$sitemap['parent'][$i]['id'] = $catid;
$sitemap['parent'][$i]['title'] = $myts->htmlSpecialChars($name);
if (oledrion_utils::getModuleOption('urlrewriting') == 1) {
// On utilise l'url rewriting
$url = 'category' . '-' . intval($catid) . oledrion_utils::makeSeoUrl($name) . '.html';
} else {
// Pas d'utilisation de l'url rewriting
$url = 'category.php?cat_cid=' . intval($catid);
}
$sitemap['parent'][$i]['url'] = $url;
if (@$sitemap_configs["show_subcategoris"]) {
$j = 0;
$child_ary = $mytree->getChildTreeArray($catid, $order);
foreach ($child_ary as $child) {
$count = strlen($child['prefix']) + 1;
$sitemap['parent'][$i]['child'][$j]['id'] = $child[$id_name];
$sitemap['parent'][$i]['child'][$j]['title'] = $myts->htmlSpecialChars($child[$title_name]);
$sitemap['parent'][$i]['child'][$j]['image'] = $count > 3 ? 4 : $count;
if (oledrion_utils::getModuleOption('urlrewriting') == 1) {
// On utilise l'url rewriting
$url = 'category' . '-' . intval($child[$id_name]) . oledrion_utils::makeSeoUrl($child[$title_name]) . '.html';
} else {
// Pas d'utilisation de l'url rewriting
$url = 'category.php?cat_cid=' . intval($child[$id_name]);
}
$sitemap['parent'][$i]['child'][$j]['url'] = $url;
$j++;
}
}
$i++;
}
return $sitemap;
}
示例3: makeTopicSelBox
function makeTopicSelBox($none = false, $seltopic = null, $selname = '', $onchange = '')
{
$seltopic = is_null($seltopic) ? intval($this->topic_id) : intval($seltopic);
ob_start();
$tree = new XoopsTree($this->table, "topic_id", "topic_pid");
$tree->makeMySelBox("topic_title", "topic_title", $seltopic, $none, $selname, $onchange);
$ret = ob_get_contents();
ob_end_clean();
//$ret = str_replace('topic_id','topicid', $ret); // non-sense code?
return $ret;
}
示例4: createElements
/**
* created elements
* @license http://www.blags.org/
* @created:2010年05月21日 20时40分
* @copyright 1997-2010 The Martin Group
* @author Martin <china.codehome@gmail.com>
* */
function createElements()
{
global $xoopsDB;
$mytree = new XoopsTree($xoopsDB->prefix("martin_hotel_city"), "city_id", "city_parentid");
// Parent Category
ob_start();
$mytree->makeMySelBox("city_name", "", $this->Obj->city_parentid(), 1, 'city_parentid');
//makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="")
$this->addElement(new XoopsFormLabel("父类", ob_get_contents()));
ob_end_clean();
// City Name
$this->addElement(new XoopsFormText('名称', 'city_name', 50, 255, $this->Obj->city_name()), true);
$this->addElement(new XoopsFormText('网址', 'city_alias', 50, 255, $this->Obj->city_alias()), true);
$this->addElement(new XoopsFormHidden('id', $this->Obj->city_id()));
}
示例5: XmobileTree
function XmobileTree($table_name, $id_name, $pid_name, $title_name = null, $order = null)
{
$myts =& MyTextSanitizer::getInstance();
XoopsTree::XoopsTree($table_name, $id_name, $pid_name);
$this->title = $myts->addSlashes($title_name);
$this->order = $myts->addSlashes($order);
// if(is_object($criteria))
// {
// $this->criteria =& $criteria;
// }
global $xmobileControl;
$this->utils =& $xmobileControl->utils;
}
示例6: b_myalbum_topnews_edit
function b_myalbum_topnews_edit($options)
{
global $xoopsDB;
$mydirname = empty($options[0]) ? basename(dirname(dirname(__FILE__))) : $options[0];
$photos_num = empty($options[1]) ? 5 : intval($options[1]);
$title_max_length = empty($options[2]) ? 20 : intval($options[2]);
$cat_limitation = empty($options[3]) ? 0 : intval($options[3]);
$cat_limit_recursive = empty($options[4]) ? 0 : 1;
$cols = empty($options[6]) ? 1 : intval($options[6]);
include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
if (!preg_match('/^(\\D+)(\\d*)$/', $mydirname, $regs)) {
echo "invalid dirname: " . htmlspecialchars($mydirname);
}
$mydirnumber = $regs[2] === '' ? '' : intval($regs[2]);
$cattree = new XoopsTree($xoopsDB->prefix("myalbum{$mydirnumber}_cat"), "cid", "pid");
ob_start();
$cattree->makeMySelBox("title", "title", $cat_limitation, 1, 'options[3]');
$catselbox = ob_get_contents();
ob_end_clean();
return "\n\t\t" . _ALBM_TEXT_DISP . " \n\t\t<input type='hidden' name='options[0]' value='{$mydirname}' />\n\t\t<input type='text' size='4' name='options[1]' value='{$photos_num}' style='text-align:right;' />\n\t\t<br />\n\t\t" . _ALBM_TEXT_STRLENGTH . " \n\t\t<input type='text' size='6' name='options[2]' value='{$title_max_length}' style='text-align:right;' />\n\t\t<br />\n\t\t" . _ALBM_TEXT_CATLIMITATION . " {$catselbox}\n\t\t" . _ALBM_TEXT_CATLIMITRECURSIVE . "\n\t\t<input type='radio' name='options[4]' value='1' " . ($cat_limit_recursive ? "checked='checked'" : "") . "/>" . _YES . "\n\t\t<input type='radio' name='options[4]' value='0' " . ($cat_limit_recursive ? "" : "checked='checked'") . "/>" . _NO . "\n\t\t<br />\n\t\t<input type='hidden' name='options[5]' value='' />\n\t\t" . _ALBM_TEXT_COLS . " \n\t\t<input type='text' size='2' name='options[6]' value='{$cols}' style='text-align:right;' />\n\t\t<br />\n\t\t\n";
}
示例7: d3forum_updatecategory
function d3forum_updatecategory($mydirname, $cat_id)
{
$db =& Database::getInstance();
$requests = d3forum_get_requests4sql_category($mydirname);
// get children
include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
$mytree = new XoopsTree($db->prefix($mydirname . "_categories"), "cat_id", "pid");
$children = $mytree->getAllChildId($cat_id);
$children[] = $cat_id;
// loop check
if (in_array($requests['pid'], $children)) {
die(_MD_D3FORUM_ERR_PIDLOOP);
}
if (!$db->query("UPDATE " . $db->prefix($mydirname . "_categories") . " SET cat_title='{$requests['title']}', cat_desc='{$requests['desc']}', cat_weight='{$requests['weight']}', cat_options='{$requests['options']}', pid='{$requests['pid']}' WHERE cat_id={$cat_id}")) {
die(_MD_D3FORUM_ERR_SQL . __LINE__);
}
// rebuild category tree
d3forum_sync_cattree($mydirname);
return $cat_id;
}
示例8: delete
function delete(&$post, $isDeleteOne = true)
{
if ($isDeleteOne) {
return $this->_delete($post);
} else {
include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
$mytree = new XoopsTree($this->db->prefix("bb_posts"), "post_id", "pid");
$arr = $mytree->getAllChild($post->getVar('post_id'));
for ($i = 0; $i < count($arr); $i++) {
$childpost =& $this->create(false);
$childpost->assignVars($arr[$i]);
$this->_delete($childpost);
unset($childpost);
}
$this->_delete($post);
}
return true;
}
示例9: delete
function delete(&$post, $isDeleteOne = true, $force = false)
{
if (!is_object($post) || $post->getVar('post_id') == 0) {
return false;
}
if ($isDeleteOne) {
if ($post->isTopic()) {
$criteria = new CriteriaCompo(new Criteria("topic_id", $post->getVar('topic_id')));
$criteria->add(new Criteria('approved', 1));
$criteria->add(new Criteria('pid', 0, ">"));
if ($this->getPostCount($criteria) > 0) {
return false;
}
}
return $this->_delete($post, $force);
} else {
require_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
$mytree = new XoopsTree($this->db->prefix("bb_posts"), "post_id", "pid");
$arr = $mytree->getAllChild($post->getVar('post_id'));
for ($i = 0; $i < count($arr); $i++) {
$childpost =& $this->create(false);
$childpost->assignVars($arr[$i]);
$this->_delete($childpost, $force);
unset($childpost);
}
$this->_delete($post, $force);
}
return true;
}
示例10: XoopsTree
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
include "header.php";
include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
$myts =& MyTextSanitizer::getInstance();
// MyTextSanitizer object
$mytree = new XoopsTree($xoopsDB->prefix("mydownloads_cat"), "cid", "pid");
// Used to view just a single DL file information. Called from the rating pages
$lid = intval($_GET['lid']);
$cid = intval($_GET['cid']);
$xoopsOption['template_main'] = 'mydownloads_singlefile.html';
include XOOPS_ROOT_PATH . "/header.php";
$q = "SELECT d.lid, d.cid, d.title, d.url, d.homepage, d.version, d.size, d.platform, d.logourl, d.status, d.date, d.hits, d.rating, d.votes, d.comments, t.description FROM " . $xoopsDB->prefix("mydownloads_downloads") . " d, " . $xoopsDB->prefix("mydownloads_text") . " t WHERE d.lid={$lid} AND d.lid=t.lid AND status>0";
$result = $xoopsDB->query($q);
list($lid, $cid, $title, $url, $homepage, $version, $size, $platform, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result);
$pathstring = "<a href='index.php'>" . _MD_MAIN . "</a> : ";
$pathstring .= $mytree->getNicePathFromId($cid, "title", "viewcat.php?op=");
$xoopsTpl->assign('category_path', $pathstring);
$path = $mytree->getPathFromId($cid, "title");
$path = substr($path, 1);
$path = str_replace("/", " <img src='" . XOOPS_URL . "/modules/mydownloads/images/arrow.gif' board='0' alt=''> ", $path);
$rating = number_format($rating, 2);
示例11: getNicePathFromId
function getNicePathFromId($funcURL){
$xt = new XoopsTree($this->table, "id", "pid");
$ret = $xt->getNicePathFromId($this->id, "title", $funcURL);
return $ret;
}
示例12: xoops_gethandler
$ams_topics = $xoopsDB->prefix('ams_topics');
$ams_articles = $xoopsDB->prefix('ams_article');
$ams_text = $xoopsDB->prefix('ams_text');
$ams_files = $xoopsDB->prefix('ams_files');
$ams_links = $xoopsDB->prefix('ams_link');
$ams_rating = $xoopsDB->prefix('ams_rating');
// Retreive News tables names
$news_stories_votedata = $xoopsDB->prefix('nw_stories_votedata');
// Misc
$comment_handler =& xoops_gethandler('comment');
$notification_handler =& xoops_gethandler('notification');
$ams_news_topics=array(); // Key => AMS Id, Value => News ID
// The import by itself
// Read topics by their order
$mytree = new XoopsTree($ams_topics,'topic_id','topic_pid');
$ams_topics = $mytree->getChildTreeArray(0,'weight');
foreach($ams_topics as $one_amstopic) {
// First we create the topic
$topicpid=0;
if($one_amstopic['topic_pid']!=0) { // Search for its the parent
if(array_key_exists($one_amstopic['topic_pid'],$ams_news_topics)) {
$topicpid=$ams_news_topics[$one_amstopic['topic_pid']];
}
}
$news_topic = new nw_NewsTopic();
$news_topic->setTopicPid($topicpid);
$news_topic->setTopicTitle($one_amstopic['topic_title']);
$news_topic->setTopicImgurl($one_amstopic['topic_imgurl']);
$news_topic->setMenu(0);
$news_topic->setTopicFrontpage(1);
示例13: editfaq
function editfaq($showmenu = false, $faqid = -1)
{
global $faq_handler, $category_handler, $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $XOOPS_URL, $myts;
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
// If there is a parameter, and the id exists, retrieve data: we're editing a faq
if ($faqid != -1) {
// Creating the FAQ object
$faqObj = new sfFaq($faqid);
if ($faqObj->notLoaded()) {
redirect_header("faq.php", 1, _AM_SF_NOARTTOEDIT);
exit;
}
switch ($faqObj->status()) {
case _SF_STATUS_ASKED:
$breadcrumb_action = _AM_SF_APPROVING;
$collapsableBar_title = _AM_SF_QUESTION_APPROVING;
$collapsableBar_info = _AM_SF_QUESTION_APPROVING_INFO;
$button_caption = _AM_SF_QUEUE;
break;
case "default":
default:
$breadcrumb_action = _AM_SF_EDITING;
$collapsableBar_title = _AM_SF_EDITQUES;
$collapsableBar_info = _AM_SF_EDITING_INFO;
$button_caption = _AM_SF_MODIFY;
break;
}
// Creating the category of this FAQ
$categoryObj =& $category_handler->get($faqObj->categoryid());
if ($showmenu) {
sf_adminMenu(3, _AM_SF_OPEN_QUESTIONS . " > " . $breadcrumb_action);
}
echo "<br />\n";
sf_collapsableBar('bottomtable', 'bottomtableicon');
echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . $collapsableBar_title . "</h3>";
echo "<div id='bottomtable'>";
echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $collapsableBar_info . "</span>";
} else {
// there's no parameter, so we're adding a faq
$faqObj =& $faq_handler->create();
$faqObj->setVar('uid', $xoopsUser->getVar('uid'));
$categoryObj =& $category_handler->create();
$breadcrumb_action = _AM_SF_CREATINGNEW;
$button_caption = _AM_SF_CREATE;
if ($showmenu) {
sf_adminMenu(3, _AM_SF_OPEN_QUESTIONS . " > " . $breadcrumb_action);
}
sf_collapsableBar('bottomtable', 'bottomtableicon');
echo "<img id='bottomtableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif alt='' /></a> " . _AM_SF_CREATEQUESTION . "</h3>";
echo "<div id='bottomtable'>";
}
$sform = new XoopsThemeForm(_AM_SF_OPEN_QUESTION, "op", xoops_getenv('PHP_SELF'));
$sform->setExtra('enctype="multipart/form-data"');
// faq requester
$sform->addElement(new XoopsFormLabel(_AM_SF_REQUESTED_BY, sf_getLinkedUnameFromId($faqObj->uid(), $xoopsModuleConfig['userealname'])));
// CATEGORY
/*
* Get information for pulldown menu using XoopsTree.
* First var is the database table
* Second var is the unique field ID for the categories
* Last one is not set as we do not have sub menus in Smartfaq
*/
$mytree = new XoopsTree($xoopsDB->prefix("smartfaq_categories"), "categoryid", "parentid");
ob_start();
$mytree->makeMySelBox("name", "weight", $categoryObj->categoryid());
$sform->addElement(new XoopsFormLabel(_AM_SF_CATEGORY_QUESTION, ob_get_contents()));
ob_end_clean();
// faq QUESTION
$sform->addElement(new XoopsFormTextArea(_AM_SF_QUESTION, 'question', $faqObj->question(), 7, 60));
// PER ITEM PERMISSIONS
$member_handler =& xoops_gethandler('member');
$group_list =& $member_handler->getGroupList();
$groups_checkbox = new XoopsFormCheckBox(_AM_SF_PERMISSIONS_QUESTION, 'groups[]', $faqObj->getGroups_read());
foreach ($group_list as $group_id => $group_name) {
if ($group_id != XOOPS_GROUP_ADMIN) {
$groups_checkbox->addOption($group_id, $group_name);
}
}
$sform->addElement($groups_checkbox);
// faq ID
$sform->addElement(new XoopsFormHidden('faqid', $faqObj->faqid()));
$button_tray = new XoopsFormElementTray('', '');
$hidden = new XoopsFormHidden('op', 'addfaq');
$button_tray->addElement($hidden);
$sform->addElement(new XoopsFormHidden('status', $faqObj->status()));
// Setting the FAQ Status
/* $status_select = new XoopsFormSelect('', 'status', $status);
$status_select->addOptionArray(sf_getStatusArray());
$status_tray = new XoopsFormElementTray(_AM_SF_STATUS_EXP , ' ');
$status_tray->addElement($status_select);
$sform->addElement($status_tray);
*/
if ($faqid == -1) {
// there's no faqid? Then it's a new faq
// $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SF_CREATE, 'submit' ) );
$butt_create = new XoopsFormButton('', '', _AM_SF_CREATE, 'submit');
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addfaq\'"');
$button_tray->addElement($butt_create);
$butt_clear = new XoopsFormButton('', '', _AM_SF_CLEAR, 'reset');
$button_tray->addElement($butt_clear);
//.........这里部分代码省略.........
示例14: basename
include 'include/read_configs.php';
}
} else {
// when this script is included by core's imagemanager.php
$mydirname = basename(dirname(__FILE__));
include XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/read_configs.php";
}
include XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/get_perms.php";
include_once XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/functions.php";
include_once XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/draw_functions.php";
include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
include_once XOOPS_ROOT_PATH . '/class/template.php';
$myts =& MyTextSanitizer::getInstance();
// MyTextSanitizer object
$cattree = new XoopsTree($table_cat, "cid", "pid");
// Get variables
if (empty($_GET['target'])) {
exit;
}
$num = empty($_GET['num']) ? 10 : intval($_GET['num']);
$cid = !isset($_GET['cid']) ? 0 : intval($_GET['cid']);
$xoopsTpl = new XoopsTpl();
$xoopsTpl->assign('lang_imgmanager', _IMGMANAGER);
$xoopsTpl->assign('sitename', $xoopsConfig['sitename']);
$target = htmlspecialchars($_GET['target'], ENT_QUOTES);
$xoopsTpl->assign('target', $target);
$xoopsTpl->assign('mod_url', $mod_url);
$xoopsTpl->assign('cid', $cid);
$xoopsTpl->assign('can_add', $global_perms & GPERM_INSERTABLE && $cid);
$cats = $cattree->getChildTreeArray(0, 'title');
示例15: edititem
function edititem($showmenu = false, $itemid = 0)
{
global $smartsection_file_handler, $smartsection_item_handler, $smartsection_category_handler, $xoopsUser, $xoopsModule, $xoopsConfig, $xoopsDB;
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
// If there is a parameter, and the id exists, retrieve data: we're editing a item
if ($itemid != 0) {
// Creating the ITEM object
$itemObj = new ssItem($itemid);
if ($itemObj->notLoaded()) {
redirect_header("item.php", 1, _AM_SS_NOITEMSELECTED);
exit;
}
switch ($itemObj->status()) {
case _SS_STATUS_SUBMITTED:
$breadcrumb_action1 = _AM_SS_SUBMITTED;
$breadcrumb_action2 = _AM_SS_APPROVING;
$page_title = _AM_SS_SUBMITTED_TITLE;
$page_info = _AM_SS_SUBMITTED_INFO;
$button_caption = _AM_SS_APPROVE;
$new_status = _SS_STATUS_PUBLISHED;
break;
case _SS_STATUS_PUBLISHED:
$breadcrumb_action1 = _AM_SS_PUBLISHED;
$breadcrumb_action2 = _AM_SS_EDITING;
$page_title = _AM_SS_PUBLISHEDEDITING;
$page_info = _AM_SS_PUBLISHEDEDITING_INFO;
$button_caption = _AM_SS_MODIFY;
$new_status = _SS_STATUS_PUBLISHED;
break;
case _SS_STATUS_OFFLINE:
$breadcrumb_action1 = _AM_SS_OFFLINE;
$breadcrumb_action2 = _AM_SS_EDITING;
$page_title = _AM_SS_OFFLINEEDITING;
$page_info = _AM_SS_OFFLINEEDITING_INFO;
$button_caption = _AM_SS_MODIFY;
$new_status = _SS_STATUS_OFFLINE;
break;
case "default":
default:
break;
}
$categoryObj =& $itemObj->category();
if ($showmenu) {
ss_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
}
echo "<br />\n";
ss_collapsableBar('edititemtable', 'edititemicon', $page_title, $page_info);
} else {
// there's no parameter, so we're adding an item
$itemObj =& $smartsection_item_handler->create();
$categoryObj =& $smartsection_category_handler->create();
$breadcrumb_action1 = _AM_SS_ITEMS;
$breadcrumb_action2 = _AM_SS_CREATINGNEW;
$button_caption = _AM_SS_CREATE;
$new_status = _SS_STATUS_PUBLISHED;
if ($showmenu) {
ss_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
}
$sel_categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0;
$categoryObj->setVar('categoryid', $sel_categoryid);
ss_collapsableBar('createitemtable', 'createitemicon', _AM_SS_ITEM_CREATING, _AM_SS_ITEM_CREATING_DSC);
}
// ITEM FORM
$sform = new XoopsThemeForm(_AM_SS_ITEMS, "op", xoops_getenv('PHP_SELF'));
$sform->setExtra('enctype="multipart/form-data"');
// CATEGORY
$mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid");
ob_start();
$sform->addElement(new XoopsFormHidden('categoryid', $categoryObj->categoryid()));
$mytree->makeMySelBox("name", "weight", $categoryObj->categoryid());
$category_label = new XoopsFormLabel(_AM_SS_CATEGORY, ob_get_contents());
$category_label->setDescription(_AM_SS_CATEGORY_DSC);
$sform->addElement($category_label);
ob_end_clean();
// TITLE
$title_text = new XoopsFormText(_AM_SS_TITLE, 'title', 50, 255, $itemObj->title(0, 'e'));
$sform->addElement($title_text, true);
// SUMMARY
$summary_text = ss_getEditor(_AM_SS_SUMMARY, 'summary', $itemObj->summary(0, 'e'));
$summary_text->setDescription(_AM_SS_SUMMARY_DSC);
$sform->addElement($summary_text, false);
// DISPLAY_SUMMARY
$display_summary_radio = new XoopsFormRadioYN(_AM_SS_DISPLAY_SUMMARY, 'display_summary', $itemObj->display_summary(), ' ' . _AM_SS_YES . '', ' ' . _AM_SS_NO . '');
$sform->addElement($display_summary_radio);
// BODY
$body_text = ss_getEditor(_AM_SS_BODY, 'body', $itemObj->body(0, 'e'));
//$body_text = new XoopsFormDhtmlTextArea(_AM_SS_BODY, 'body', $itemObj->body(0, 'e'), 20, 60);
$body_text->setDescription(_AM_SS_BODY_DSC);
$sform->addElement($body_text, true);
// IMAGE
$image_array =& XoopsLists::getImgListAsArray(ss_getImageDir('item'));
$image_select = new XoopsFormSelect('', 'image', $itemObj->image());
//$image_select -> addOption ('-1', '---------------');
$image_select->addOptionArray($image_array);
$image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/smartsection/images/item/' . "\", \"\", \"" . XOOPS_URL . "\")'");
$image_tray = new XoopsFormElementTray(_AM_SS_IMAGE_ITEM, ' ');
$image_tray->addElement($image_select);
$image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . ss_getImageDir('item', false) . $itemObj->image() . "' name='image3' id='image3' alt='' />"));
$image_tray->setDescription(_AM_SS_IMAGE_ITEM_DSC);
$sform->addElement($image_tray);
//.........这里部分代码省略.........