Example #1
0
//require_once(XOOPS_ROOT_PATH . "/class/xoopstree.php");
include_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/class/xoopsformloader.php";
// Form
$form_art = new XoopsThemeForm(art_constant("MD_TOPIC") . " " . $topic_obj->getVar("top_title"), "formtopic", XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/action.topic.php");
$form_art->setExtra("enctype=\"multipart/form-data\"");
// Title
$form_art->addElement(new XoopsFormText(art_constant("MD_TITLE"), "top_title", 50, 255, $topic_obj->getVar("top_title")), true);
// Description
$form_art->addElement(new XoopsFormTextArea(art_constant("MD_DESCRIPTION"), "top_description", $topic_obj->getVar("top_description")));
// Parent category
if (art_isAdministrator()) {
    require_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/class/tree.php";
    $category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $tags = array("cat_id", "cat_pid", "cat_title", "cat_order");
    $categories = $category_handler->getAllByPermission("moderate", $tags);
    $mytree = new artTree($categories, "cat_id");
    $box = $mytree->makeSelBox("cat_id", "--", $topic_obj->getVar("cat_id"));
    $form_art->addElement(new XoopsFormLabel(art_constant("MD_CATEGORY"), $box));
} else {
    $form_art->addElement(new XoopsFormHidden("cat_id", $topic_obj->getVar("cat_id")));
}
// Order
$form_art->addElement(new XoopsFormText(art_constant("MD_ORDER"), "top_order", 20, 20, $topic_obj->getVar("top_order")));
// expire
$top_expire = $topic_obj->isNew() ? (empty($xoopsModuleConfig["topic_expire"]) ? 365 : $xoopsModuleConfig["topic_expire"]) * 3600 * 24 + time() : $topic_obj->getVar("top_expire");
$form_art->addElement(new XoopsFormDateTime(art_constant("MD_EXPIRATION"), "top_expire", 15, intval($top_expire)));
// Template set
$templates =& art_getTemplateList("topic");
if (count($templates) > 0) {
    $template_option_tray = new XoopsFormElementTray(art_constant("MD_TEMPLATE_SELECT"), "<br />");
    $template_select = new XoopsFormSelect("", "top_template", $topic_obj->getVar("top_template"));
Example #2
0
 function art_createSubCategoryList()
 {
     $category_handler =& xoops_getModuleHandler("category", $GLOBALS["artdirname"]);
     $criteria = new CriteriaCompo("1", 1);
     $criteria->setSort("cat_pid ASC, cat_order");
     $criteria->setOrder("ASC");
     $categories_obj = $category_handler->getObjects($criteria);
     require_once XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/class/tree.php";
     $tree = new artTree($categories_obj, "cat_id", "cat_pid");
     $category_array = array();
     foreach (array_keys($categories_obj) as $key) {
         if (!($child = array_keys($tree->getAllChild($categories_obj[$key]->getVar("cat_id"))))) {
             continue;
         }
         $category_array[$categories_obj[$key]->getVar("cat_id")] = $child;
     }
     unset($categories_obj, $tree, $criteria);
     mod_createCacheFile($category_array, "category", $GLOBALS["artdirname"]);
     return $category_array;
 }