예제 #1
0
function topicsmanager()
{
    global $xoopsModule, $xoopsModuleConfig, $xoopsDB;
    include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
    //$uploadfolder=sprintf(_AMS_AM_UPLOAD_WARNING,XOOPS_URL . "/modules/" . $xoopsModule -> dirname().'/images/topics');
    $uploadirectory = "/modules/" . $xoopsModule->dirname() . '/images/topics';
    $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
    include_once XOOPS_ROOT_PATH . "/class/tree.php";
    $xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
    $allTopics = $xt->getAllTopics();
    $totaltopics = count($allTopics);
    if ($totaltopics > 0) {
        $topic_obj_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid');
        $topics_arr = $topic_obj_tree->getAllChild(0);
    }
    echo "<form action='index.php' method='POST'>";
    echo "<div class=\"odd\">";
    echo "<div style='text-align: center;'><b>" . _AMS_AM_TOPICSMNGR . ' (' . ($start + 1) . '-' . ($start + $xoopsModuleConfig['storycountadmin'] > $totaltopics ? $totaltopics : $start + $xoopsModuleConfig['storycountadmin']) . ' ' . _AMS_AM_OF . ' ' . $totaltopics . ')' . "</b><br /><br />";
    echo "<table border='1' width='100%'><tr class='bg3'><td align='center'>" . _AMS_AM_TOPIC . "</td><td align='left'>" . _AMS_AM_TOPICNAME . "</td><td align='center'>" . _AMS_AM_PARENTTOPIC . "</td><td> " . _AMS_AM_WEIGHT . " </td><td align='center'>" . _AMS_AM_ACTION . "</td></tr>";
    //If topic not empty
    if ($totaltopics > 0) {
        $i = 0;
        foreach ($topics_arr as $thisTopic) {
            $i++;
            if ($i > $start && $i - $start <= $xoopsModuleConfig['storycountadmin']) {
                $linkedit = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/index.php?op=topicsmanager&amp;topic_id=' . $thisTopic->topic_id();
                $linkdelete = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/index.php?op=delTopic&amp;topic_id=' . $thisTopic->topic_id();
                $action = sprintf("<a href='%s'>%s</a> - <a href='%s'>%s</a>", $linkedit, _AMS_AM_EDIT, $linkdelete, _AMS_AM_DELETE);
                $parent = '&nbsp;';
                $pid = $thisTopic->topic_pid();
                if ($pid > 0) {
                    $parent = $topics_arr[$pid]->topic_title();
                    $thisTopic->prefix = str_replace(".", "-", $thisTopic->prefix) . '&nbsp;&nbsp;';
                } else {
                    $thisTopic->prefix = str_replace(".", "", $thisTopic->prefix);
                }
                echo "<tr><td>" . $thisTopic->topic_id() . "</td><td align='left'>" . $thisTopic->prefix() . $thisTopic->topic_title() . "</td><td align='left'>" . $parent . "</td><td align='center'><input type='text' name='weight[" . $thisTopic->topic_id() . "]' value='" . $thisTopic->weight . "' size='10' maxlength='10' /> </td><td>" . $action . "</td></tr>";
            }
        }
        echo "<tr><td colspan='3'></td><td><input type='hidden' name='op' value='reorder' />\r\n                <input type='submit' name='submit' value='" . _AMS_AM_SUBMIT . "' /></td><td></td></tr>";
    }
    echo "</table></div></div></form>";
    if ($totaltopics > $xoopsModuleConfig['storycountadmin']) {
        $pagenav = new XoopsPageNav($totaltopics, $xoopsModuleConfig['storycountadmin'], $start, 'start', 'op=topicsmanager');
        echo "<div align='right'>";
        echo $pagenav->renderNav() . '</div><br />';
    }
    $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0;
    if ($topic_id > 0) {
        $xtmod = $topics_arr[$topic_id];
        $topic_title = $xtmod->topic_title('E');
        $op = 'modTopicS';
        if (trim($xtmod->topic_imgurl()) != '') {
            $topicimage = $xtmod->topic_imgurl();
        } else {
            $topicimage = "blank.png";
        }
        $btnlabel = _AMS_AM_MODIFY;
        $parent = $xtmod->topic_pid();
        $formlabel = _AMS_AM_MODIFYTOPIC;
        $banner = $xtmod->banner;
        $banner_inherit = $xtmod->banner_inherit;
        $forum = $xtmod->forum_id;
        unset($xtmod);
    } else {
        $topic_title = '';
        $op = 'addTopic';
        $topicimage = 'xoops.gif';
        $btnlabel = _AMS_AM_ADD;
        $parent = 0;
        $formlabel = _AMS_AM_ADD_TOPIC;
        $banner = '';
        $banner_inherit = 0;
        $forum = 0;
    }
    $sform = new XoopsThemeForm($formlabel, "topicform", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php', 'post');
    $sform->setExtra('enctype="multipart/form-data"');
    $sform->addElement(new XoopsFormText(_AMS_AM_TOPICNAME . ' ' . _AMS_AM_MAX40CHAR, 'topic_title', 40, 50, $topic_title), true);
    $sform->addElement(new XoopsFormHidden('op', $op), false);
    $sform->addElement(new XoopsFormHidden('topic_id', $topic_id), false);
    if ($totaltopics > 0) {
        $sform->addElement(new XoopsFormLabel(_AMS_AM_PARENTTOPIC, $topic_obj_tree->makeSelBox('topic_pid', 'topic_title', '--', $parent, true)));
    } else {
        $sform->addElement(new XoopsFormHidden('topic_pid', 0));
    }
    // ********** Picture
    $imgtray = new XoopsFormElementTray(_AMS_AM_TOPICIMG, '<br />');
    $imgpath = sprintf(_AMS_AM_IMGNAEXLOC, "modules/" . $xoopsModule->dirname() . "/images/topics/");
    $imageselect = new XoopsFormSelect($imgpath, 'topic_imgurl', $topicimage);
    $topics_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . "/modules/AMS/images/topics/");
    foreach ($topics_array as $image) {
        $imageselect->addOption("{$image}", $image);
    }
    $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"topic_imgurl\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'");
    $imgtray->addElement($imageselect, false);
    $imgtray->addElement(new XoopsFormLabel('', "<br /><img src='" . XOOPS_URL . "/" . $uploadirectory . "/" . $topicimage . "' name='image3' id='image3' alt='' />"));
    $uploadfolder = sprintf(_AMS_AM_UPLOAD_WARNING, XOOPS_URL . "/modules/" . $xoopsModule->dirname() . '/images/topics');
    $fileseltray = new XoopsFormElementTray('', '<br />');
    $fileseltray->addElement(new XoopsFormFile(_AMS_AM_TOPIC_PICTURE, 'attachedfile', $xoopsModuleConfig['maxuploadsize']), false);
    $fileseltray->addElement(new XoopsFormLabel($uploadfolder), false);
    $imgtray->addElement($fileseltray);
    $sform->addElement($imgtray);
    //Forum linking
    $module_handler =& xoops_gethandler('module');
    $forum_module =& $module_handler->getByDirname('newbb');
    if (is_object($forum_module) && $forum_module->getVar('version') >= 200) {
        $forum_handler =& xoops_getmodulehandler('forum', 'newbb', true);
        if (is_object($forum_handler)) {
            $forums = $forum_handler->getForums();
            if (count($forums) > 0) {
                $forum_tree = new XoopsObjectTree($forums, 'forum_id', 'parent_forum');
                $sform->addElement(new XoopsFormLabel(_AMS_AM_LINKEDFORUM, $forum_tree->makeSelBox('forum_id', 'forum_name', '--', $forum, true)));
            }
        }
    }
    //Banner
    $sform->addElement(new XoopsFormDhtmlTextArea(_AMS_AM_TOPICBANNER, 'banner', $banner));
    $inherit_checkbox = new XoopsFormCheckBox(_AMS_AM_BANNERINHERIT, 'banner_inherit', $banner_inherit);
    $inherit_checkbox->addOption(1, _YES);
    $sform->addElement($inherit_checkbox);
    //Added in AMS 2.50 Final. Use News 1.62 permission style
    //Enhance in AMS 3.0 Beta 1. Add default permission for approval=admin, submit=admin,User.
    // Permissions
    $member_handler =& xoops_gethandler('member');
    $group_list =& $member_handler->getGroupList();
    $gperm_handler =& xoops_gethandler('groupperm');
    $group_type_ref =& $member_handler->getGroups(null, true);
    $admin_list = array();
    $user_list = array();
    $full_list = array();
    $admincount = 1;
    $usercount = 1;
    $fullcount = 1;
    foreach (array_keys($group_type_ref) as $i) {
        if ($group_type_ref[$i]->getVar('group_type') == 'Admin') {
            $admin_list[$i] = $group_list[$i];
            $admincount++;
            $user_list[$i] = $group_list[$i];
            $usercount++;
        }
        if ($group_type_ref[$i]->getVar('group_type') == 'User') {
            $user_list[$i] = $group_list[$i];
            $usercount++;
        }
        $full_list[$i] = $group_list[$i];
        $fullcount++;
    }
    $admin_list = array_keys($admin_list);
    $user_list = array_keys($user_list);
    $full_list = array_keys($full_list);
    $groups_ids = array();
    if ($topic_id > 0) {
        // Edit mode
        $groups_ids = $gperm_handler->getGroupIds('ams_approve', $topic_id, $xoopsModule->getVar('mid'));
        $groups_ids = array_values($groups_ids);
        $groups_AMS_can_approve_checkbox = new XoopsFormCheckBox(_AMS_AM_APPROVEFORM, 'groups_AMS_can_approve[]', $groups_ids);
    } else {
        // Creation mode
        $groups_AMS_can_approve_checkbox = new XoopsFormCheckBox(_AMS_AM_APPROVEFORM, 'groups_AMS_can_approve[]', $admin_list);
    }
    $groups_AMS_can_approve_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_AMS_can_approve_checkbox);
    $groups_ids = array();
    if ($topic_id > 0) {
        // Edit mode
        $groups_ids = $gperm_handler->getGroupIds('ams_submit', $topic_id, $xoopsModule->getVar('mid'));
        $groups_ids = array_values($groups_ids);
        $groups_AMS_can_submit_checkbox = new XoopsFormCheckBox(_AMS_AM_SUBMITFORM, 'groups_AMS_can_submit[]', $groups_ids);
    } else {
        // Creation mode
        $groups_AMS_can_submit_checkbox = new XoopsFormCheckBox(_AMS_AM_SUBMITFORM, 'groups_AMS_can_submit[]', $user_list);
    }
    $groups_AMS_can_submit_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_AMS_can_submit_checkbox);
    $groups_ids = array();
    if ($topic_id > 0) {
        // Edit mode
        $groups_ids = $gperm_handler->getGroupIds('ams_view', $topic_id, $xoopsModule->getVar('mid'));
        $groups_ids = array_values($groups_ids);
        $groups_AMS_can_view_checkbox = new XoopsFormCheckBox(_AMS_AM_VIEWFORM, 'groups_AMS_can_view[]', $groups_ids);
    } else {
        // Creation mode
        $groups_AMS_can_view_checkbox = new XoopsFormCheckBox(_AMS_AM_VIEWFORM, 'groups_AMS_can_view[]', $full_list);
    }
    $groups_AMS_can_view_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_AMS_can_view_checkbox);
    // Submit buttons
    $button_tray = new XoopsFormElementTray('', '');
    $submit_btn = new XoopsFormButton('', 'post', $btnlabel, 'submit');
    $button_tray->addElement($submit_btn);
    $sform->addElement($button_tray);
    $sform->display();
}
예제 #2
0
}
if (empty($modules)) {
	$criteria = new CriteriaCompo();
	$criteria->add(new Criteria('hassearch', 1));
	$criteria->add(new Criteria('isactive', 1));
	if (!empty($available_modules)) {
		$criteria->add(new Criteria('mid', "(".implode(',', $available_modules).")", 'IN'));
	}
	$db =& Database::getInstance();
	$result = $db->query("SELECT mid FROM ".$db->prefix("search")." WHERE notshow!=0");
    	while (list($badmid) = $db->fetchRow($result)) {
		$criteria->add(new Criteria('mid', $badmid, '!='));
	}
	$module_handler =& xoops_gethandler('module');
	$mod_arr = $module_handler->getList($criteria);
	$mods_checkbox->addOptionArray($mod_arr);
	if( count($mod_arr) == 0){
		$mods_checkbox = new XoopsFormLabel(_MD_SEARCHIN,_MD_UNABLE_TO_SEARCH);
	}
}
else {
    foreach ($modules as $mid => $module) {
        if (!is_object($module)) continue;
        $module_array[$mid] = $module->getVar('name');
    }
    $mods_checkbox->addOptionArray($module_array);
}
$search_form->addElement($mods_checkbox);
if( $xoopsModuleConfig['search_display_text'] == 1 ){
	$search_form->addElement(new XoopsFormRadioYN(_MD_SHOW_CONTEXT, "showcontext", $showcontext));
}
예제 #3
0
    $temp_queries = preg_split('/[\\s,]+/', mb_convert_kana($query, 's'));
    foreach ($temp_queries as $q) {
        $queries[] = addSlashes(trim($q));
    }
} else {
    $queries = array(addSlashes(trim($query)));
}
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
// create form
$search_form = new XoopsThemeForm(_SR_SEARCH, "search", "index.php", 'get');
$search_form->addElement(new XoopsFormText(_SR_KEYWORDS, "query", 30, 255, htmlspecialchars(stripslashes(implode(" ", $queries)), ENT_QUOTES)), true);
$type_select = new XoopsFormSelect(_SR_TYPE, "andor", $andor);
$type_select->addOptionArray(array("AND" => _SR_ALL, "OR" => _SR_ANY, "exact" => _SR_EXACT));
$search_form->addElement($type_select);
$mods_checkbox = new XoopsFormCheckBox(_SR_SEARCHIN, "mids[]", $mids);
$mods_checkbox->addOptionArray($modules_name);
$search_form->addElement($mods_checkbox);
$search_form->addElement(new XoopsFormHidden("action", "results"));
$search_form->addElement(new XoopsFormHidden("page", "search"));
$search_form->addElement(new XoopsFormButton("", "submit", _SR_SEARCH, "submit"));
$search_form->display();
if ($action == 'results') {
    echo '<div style="font-size:small">';
    echo "<h3>" . _SR_SEARCHRESULTS . "</h3>";
    echo _SR_KEYWORDS . ':';
    if ($andor != 'exact') {
        foreach ($queries as $q) {
            echo ' <b>' . htmlspecialchars(stripslashes($q)) . '</b>';
        }
    } else {
        echo ' "<b>' . htmlspecialchars(stripslashes($queries[0])) . '</b>"';
예제 #4
0
파일: item.php 프로젝트: RanLee/Xoops_demo
 function itemForm($action = false)
 {
     global $xoopsModuleConfig, $item_id;
     if ($action === false) {
         $action = $_SERVER['REQUEST_URI'];
     }
     include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
     include_once XOOPS_ROOT_PATH . "/modules/catalog/include/functions.render.php";
     $category_handler = xoops_getmodulehandler('category', 'catalog');
     $brand_handler = xoops_getmodulehandler('brand', 'catalog');
     $pictures_handler = xoops_getmodulehandler('picture', 'catalog');
     $country_handler = xoops_getmodulehandler('country', 'catalog');
     $link_handler =& xoops_getmodulehandler('symbol', 'symbol');
     $reseller_handler =& xoops_getmodulehandler('reseller', 'reseller');
     $cat_handler =& xoops_getmodulehandler('category', 'catalog');
     $greenep_handler = xoops_getmodulehandler('greenep', 'catalog');
     $att_handler =& xoops_getmodulehandler('attachment', 'catalog');
     $title = $this->isNew() ? _AM_CATALOG_ADDITEM : _AM_CATALOG_UPDATEITEM;
     $format = empty($format) ? "e" : $format;
     $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
     $form->setExtra("enctype=\"multipart/form-data\"");
     if ($xoopsModuleConfig['display'] == 1) {
         $countries =& $country_handler->getList();
         $country_select = new XoopsFormSelect(_AM_CATALOG_BELONGCOUNTRY, "country_id", $this->getVar("country_id"));
         $country_select->addOption('', _NONE);
         $country_select->addOptionArray($countries);
         $form->addElement($country_select, true);
         $brand_select = new XoopsFormSelect(_AM_CATALOG_ITEMBRAND, "brand_id", $this->getVar("brand_id"));
         $brand_select->addOption('', _NONE);
         if ($this->getVar("country_id")) {
             $criteria = new CriteriaCompo();
             $criteria->add(new Criteria('country_id', $this->getVar("country_id")));
             $brands =& $brand_handler->getList($criteria);
             unset($criteria);
             $brand_select->addOptionArray($brands);
         }
         $form->addElement($brand_select, true);
     }
     //关联分类
     $categories =& $category_handler->getTrees(0, "--");
     $cat_options = array();
     if ($categories) {
         foreach ($categories as $id => $cat) {
             $cat_options[$id] = $cat["prefix"] . $cat["cat_name"];
         }
     }
     $cat_id = empty($_REQUEST['cat_id']) ? "" : $_REQUEST['cat_id'];
     $cat_select = new XoopsFormSelect(_AM_CATALOG_ITEMCAT, "cat_id", $this->getVar("cat_id") != 0 ? $this->getVar("cat_id") : $cat_id);
     $cat_select->addOption('', _AM_CATALOG_CHOICE);
     $cat_select->addOptionArray($cat_options);
     $form->addElement($cat_select, true);
     /*
     $form->addElement(new XoopsFormText(_AM_CATALOG_ITEMNAME, 'item_name', 60, 255, $this->getVar('item_name')), true);
     $form->addElement(new XoopsFormDateTime("產品建立日期", 'create_time', 15, $this->getVar('create_time', $format)));
     $form->addElement(new XoopsFormText(_AM_CATALOG_MADEIN, 'shop_price', 40, 60, $this->getVar('shop_price')));  
     $form->addElement(new XoopsFormText(_AM_CATALOG_ITEMPACK, 'item_repairtime', 40, 60, $this->getVar('item_repairtime')));
     $form->addElement(new XoopsFormText(_AM_CATALOG_MAINFUNCTION, 'item_size', 100, 255, $this->getVar('item_size')));
     $form->addElement(new XoopsFormText(_AM_CATALOG_SHOPPRICE, 'item_weight', 40, 60, $this->getVar('item_weight')));
     */
     $form->addElement(new XoopsFormText('商品名稱', 'item_name', 60, 255, $this->getVar('item_name')), true);
     $form->addElement(new XoopsFormDateTime("建立日期", 'create_time', 15, $this->getVar('create_time', $format)));
     $form->addElement(new XoopsFormText('型號', 'item_repairtime', 40, 60, $this->getVar('item_repairtime')));
     $form->addElement(new XoopsFormText('產品顏色', 'item_weight', 40, 60, $this->getVar('item_weight')));
     $form->addElement(new XoopsFormText('外觀', 'shop_price', 40, 60, $this->getVar('shop_price')));
     $form->addElement(new XoopsFormText('尺寸', 'item_weights', 40, 255, $this->getVar('item_weights')));
     $form->addElement(new XoopsFormText('材質', 'item_size', 40, 60, $this->getVar('item_size')));
     $form->addElement(new XoopsFormText('重量', 'item_weight2', 40, 255, $this->getVar('item_weight2')));
     $form->addElement(new XoopsFormText('包裝', 'item_weightss', 40, 255, $this->getVar('item_weightss')));
     $form->addElement(new XoopsFormText('附註', 'item_weightsss', 40, 255, $this->getVar('item_weightsss')));
     /*
     $criteria2 = new CriteriaCompo();
     	    $criteria2->setSort('greenep_weight');
     	    $criteria2->setOrder('ASC');
     $greeneps =& $greenep_handler->getList($criteria2);
     $greenep_select = new XoopsFormRadio('供應綠環保程度', "greenep_id", $this->getVar("greenep_id"));
     $greenep_select->addOptionArray($greeneps);
     $form->addElement($greenep_select);
     */
     $format = empty($format) ? "e" : $format;
     $form->addElement(new XoopsFormEditor(_AM_CATALOG_FUNCTIONDESC, "item_summary", array('editor' => 'ckeditor', 'width' => '100%', 'height' => '150px', 'name' => 'item_summary', 'value' => $this->getVar('item_summary', $format)), false));
     $form->addElement(new XoopsFormEditor(_AM_CATALOG_DETAILSPEC_DESC, "item_description", array('editor' => 'ckeditor', 'width' => '100%', 'height' => '200px', 'name' => 'item_description', 'value' => $this->getVar('item_description', $format)), false));
     $form->addElement(new XoopsFormEditor(_AM_CATALOG_AFTERSERVICE_DESC, "item_service", array('editor' => 'ckeditor', 'width' => '100%', 'height' => '200px', 'name' => 'item_service', 'value' => $this->getVar('item_service', $format)), false));
     $links =& $link_handler->getList();
     $link_select = new XoopsFormSelect(' ', "link_id", $this->getVar("link_id"));
     $link_select->addOption('', _NONE);
     $link_select->addOptionArray($links);
     /*
     $link_tray = new XoopsFormElementTray("環保標章選擇", "&nbsp;<br />");
     $link_tray->addElement($link_select);
     if ($this->getVar("link_id")) {
         $link_obj =& $link_handler->get($this->getVar("link_id"));
         $link_img = XOOPS_URL . "/uploads/symbol/" . $link_obj->getVar("link_image");
         $link_tray->addElement(new XoopsFormLabel('','<span id="symbol_img"><img src="'.$link_img.'" /></span>'));
     } 
     else {
         $link_tray->addElement(new XoopsFormLabel('','<span id="symbol_img"></span>'));
     }
     $form->addElement($link_tray);
     */
     /*
     $links =& $link_handler->getList();
     $link_select = new XoopsFormCheckBox('環保標章選擇', "link_id", explode(",",$this->getVar("link_id")));
     $link_select->addOptionArray($links);
     $form->addElement($link_select);
     
     $resellers =& $reseller_handler->getList();
     $reseller_select = new XoopsFormCheckBox('優質店家選擇', "reseller_ids", explode(",",$this->getVar("reseller_ids")));
     $reseller_select->addOptionArray($resellers);
     $form->addElement($reseller_select);
     */
     $item_image = new XoopsFormElementTray(_AM_CATALOG_ITEMIMAGE);
     if ($this->getVar('item_picture')) {
         $item_image->addElement(new XoopsFormLabel('', '<img src="' . XOOPS_URL . '/uploads/gallery/thumb_' . $this->getVar('item_picture') . '"><br><br>'));
         /*  $display = _AM_CATALOG_REUPLOAD; */
     } else {
         $display = '';
     }
     $item_image->addElement(new XoopsFormFile('', 'item_image', 10240 * 10240 * 2));
     $item_image->addElement(new XoopsFormLabel('', _AM_CATALOG_UPLOADTYPE));
     $item_image->addElement(new XoopsFormLabel('', $display));
     $form->addElement($item_image);
     $gallery = new XoopsFormElementTray(_AM_CATALOG_PICUPLOAD);
     $gallery_file = new XoopsFormFile('', 'pic', 10240 * 10240 * 2);
     $gallery_multiLabel = new XoopsFormLabel('', '<div><a id="addMore" href="javascript:void(0);">' . _AM_CATALOG_ADDMORE . '</a></div>');
     $gallery->addElement($gallery_file);
     $gallery->addElement(new XoopsFormLabel('', _AM_CATALOG_UPLOADTYPE));
     $gallery->addElement($gallery_multiLabel);
     if (!$this->isNew()) {
         $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('item_id', $item_id));
         $fields = array('pic_id', 'item_id', 'pic_description', 'pic_path', 'pic_thumb_path');
         $pictures = $pictures_handler->getAll($criteria, $fields, false, false);
         if (!empty($pictures)) {
             $form_checkbox = new XoopsFormCheckBox('<br>' . _AM_CATALOG_UPLOAD . '<input id="check" name="check" type="checkbox" onclick="xoopsCheckAll(\'form\',\'check\');" />' . _ALL . '<br>', 'del_pictures_id', '', '');
             foreach ($pictures as $k => $v) {
                 $form_checkbox->addOption($v['pic_id'], '<img width=50 src="' . XOOPS_URL . '/uploads/gallery/' . $v['pic_path'] . '"> ');
             }
             $gallery->addElement($form_checkbox);
             $gallery->addElement(new XoopsFormLabel('', _AM_CATALOG_AFTERCHOICED_DEL));
         }
     }
     $form->addElement($gallery);
     // file
     $annex = new XoopsFormElementTray(_AM_CATALOG_ANNEXUPLOAD, '', 'annex');
     $annex_file = new XoopsFormFile('', 'annex', '');
     $annex_multiLabel = new XoopsFormLabel('', '<div><a id="addMoreAnnex" href="javascript:void(0);">' . _AM_CATALOG_ADDMORE . '</a></div>');
     $annex->addElement($annex_file);
     $annex->addElement($annex_multiLabel);
     $criteria = new Criteria('item_id', $this->getVar('item_id') ? $this->getVar('item_id') : 0);
     $files = $att_handler->getAll($criteria, null, false);
     if (!empty($files)) {
         foreach ($files as $id => $file) {
             $list[$id] = "<a href='" . XOOPS_URL . "/modules/catalog/downloads.php?id=" . $file['att_id'] . "'>" . $file["att_filename"] . "</a>";
         }
         $ann_select = new XoopsFormCheckBox(_AM_CATALOG_UPLOAD, "att_ids", '');
         $ann_select->addOptionArray($list);
         $annex->addElement($ann_select);
         $annex->addElement(new XoopsFormLabel('', _AM_CATALOG_AFTERCHOICED_DEL));
     }
     $form->addElement($annex);
     /*
     $cstatus_select = new XoopsFormSelect('選擇比較商品形態', "compare_status", $this->getVar("compare_status"));
     $cstatus_select->addOption(1, '售價');
     $cstatus_select->addOption(2, '尺寸');
     $cstatus_select->addOption(3, '重量');
     $cstatus_select->addOption(4, '保修年份');
     $cstatus_select->addOption(5, '綠環保程度');
     $cstatus_select->addOption(6, '評價');
     $form->addElement($cstatus_select);
     */
     $form->addElement(new XoopsFormRadioYN(_AM_CATALOG_DOBEST, 'item_best', $this->getVar('item_best')));
     //        $form->addElement(new XoopsFormRadioYN(_AM_CATALOG_DONEW, 'item_newarrival',$this->getVar('item_newarrival')));
     //        $form->addElement(new XoopsFormRadioYN(_AM_CATALOG_DOHOT, 'item_hot',$this->getVar('item_hot')));
     //        $form->addElement(new XoopsFormText(_AM_CATALOG_SORT, 'weight', 40, 60, $this->getVar('weight')));
     if ($this->isNew()) {
         $form->addElement(new XoopsFormHidden('item_buildtime', time()));
     }
     $form->addElement(new XoopsFormHidden('modify_time', time()));
     $form->addElement(new XoopsFormHidden('item_id', $this->getVar('item_id')));
     $form->addElement(new XoopsFormHidden('ac', 'insert'));
     $btn_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
     //        $btn_preview = new XoopsFormButton("", "btn_preview", _PREVIEW, "button");
     //        $btn_preview->setExtra('onclick="window.document.' . $form->getName() . '.preview.value=1; window.document.' . $form->getName() . '.submit()"');
     //        $form->addElement(new XoopsFormHidden('preview', 0));
     $button_tray = new XoopsFormElementTray("");
     //        $button_tray->addElement($btn_preview);
     $button_tray->addElement($btn_save);
     $form->addElement($button_tray);
     return $form;
 }
예제 #5
0
 /**
  * Returns a {@link XoopsFormElement} for editing the value of this field
  *
  * @param XoopsUser $user {@link XoopsUser} object to edit the value of
  * @param ProfileProfile $profile {@link ProfileProfile} object to edit the value of
  *
  * @return XoopsFormElement
  **/
 function getEditElement($user, $profile)
 {
     $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
     $caption = $this->getVar('field_title');
     $caption = defined($caption) ? constant($caption) : $caption;
     $name = $this->getVar('field_name', 'e');
     $options = $this->getVar('field_options');
     if (is_array($options)) {
         //asort($options);
         foreach (array_keys($options) as $key) {
             $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
             $optkey = defined($key) ? constant($key) : $key;
             unset($options[$key]);
             $options[$optkey] = $optval;
         }
     }
     include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
     switch ($this->getVar('field_type')) {
         default:
         case "autotext":
             //autotext is not for editing
             $element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
             break;
         case "textbox":
             $element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
             break;
         case "textarea":
             $element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
             break;
         case "dhtml":
             $element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
             break;
         case "select":
             $element = new XoopsFormSelect($caption, $name, $value);
             // If options do not include an empty element, then add a blank option to prevent any default selection
             if (!in_array('', array_keys($options))) {
                 $element->addOption('', _NONE);
                 $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_ENTER, $caption);
                 $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg));
                 $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" . "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
             }
             $element->addOptionArray($options);
             break;
         case "select_multi":
             $element = new XoopsFormSelect($caption, $name, $value, 5, true);
             $element->addOptionArray($options);
             break;
         case "radio":
             $element = new XoopsFormRadio($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case "checkbox":
             $element = new XoopsFormCheckBox($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case "yesno":
             $element = new XoopsFormRadioYN($caption, $name, $value);
             break;
         case "group":
             $element = new XoopsFormSelectGroup($caption, $name, true, $value);
             break;
         case "group_multi":
             $element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
             break;
         case "language":
             $element = new XoopsFormSelectLang($caption, $name, $value);
             break;
         case "date":
             $element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
             break;
         case "longdate":
             $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
             break;
         case "datetime":
             $element = new XoopsFormDatetime($caption, $name, 15, $value);
             break;
         case "list":
             $element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
             break;
         case "timezone":
             $element = new XoopsFormSelectTimezone($caption, $name, $value);
             $element->setExtra("style='width: 280px;'");
             break;
         case "rank":
             $element = new XoopsFormSelect($caption, $name, $value);
             include_once $GLOBALS['xoops']->path('class/xoopslists.php');
             $ranks = XoopsLists::getUserRankList();
             $element->addOption(0, "--------------");
             $element->addOptionArray($ranks);
             break;
         case 'theme':
             $element = new XoopsFormSelect($caption, $name, $value);
             $element->addOption("0", _PROFILE_MA_SITEDEFAULT);
             $handle = opendir(XOOPS_THEME_PATH . '/');
             $dirlist = array();
             while (false !== ($file = readdir($handle))) {
                 if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}\$/", $file) && strtolower($file) != 'cvs') {
                     if (file_exists(XOOPS_THEME_PATH . "/" . $file . "/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
                         $dirlist[$file] = $file;
                     }
                 }
             }
             closedir($handle);
             if (!empty($dirlist)) {
                 asort($dirlist);
                 $element->addOptionArray($dirlist);
             }
             break;
     }
     if ($this->getVar('field_description') != "") {
         $element->setDescription($this->getVar('field_description'));
     }
     return $element;
 }
예제 #6
0
function usercsv_form()
{
    $form = new XoopsThemeForm(_AM_UCSV_EXPORT, 'index_form', basename(__FILE__), 'post', true);
    $element = new XoopsFormCheckBox('', 'fields', null, '&nbsp;');
    $element->addOptionArray(usercsv_getFormFields());
    $ele_options = $element->getOptions();
    $i = 0;
    $option_ids = array();
    foreach ($ele_options as $value => $name) {
        $i++;
        $option_ids[] = 'fields' . $i;
    }
    $option_ids_str = implode("', '", $option_ids);
    $element2 = new XoopsFormLabel(_AM_UCSV_FIELDS, '
    <div id="checkfields">' . $element->render() . '
    <input name="usercsv_checkall" id="usercsv_checkall" value="" type="checkbox" onclick="var optionids = new Array(\'' . $option_ids_str . '\'); xoopsCheckAllElements(optionids, \'usercsv_checkall\');")>
    ' . _ALL . '&nbsp;</div>');
    $form->addElement($element2);
    unset($element, $element2);
    $tray = new XoopsFormElementTray('', '');
    $tray->addElement(new XoopsFormButton('', 'usercsv_button', _SUBMIT, 'submit'));
    $form->addElement($tray);
    $form->addElement(new XoopsFormHidden('op', 'export'));
    return $form->render();
}
예제 #7
0
 function constructElement($form_ele_id, $admin = false, $qcm)
 {
     global $xoopsUser, $xoopsModuleConfig, $separ, $myts;
     $myts =& MyTextSanitizer::getInstance();
     $id_form = $this->_ele->getVar('id_form');
     $ele_caption = $this->_ele->getVar('ele_caption', 'e');
     $ele_caption = preg_replace('/\\{null\\}/', '', $ele_caption);
     $ele_caption = stripslashes($ele_caption);
     $ele_value = $this->_ele->getVar('ele_value');
     $e = $this->_ele->getVar('ele_type');
     // required elements have a '*' after the text
     $req = intval($this->_ele->getVar('ele_req'));
     if ($req) {
         $ele_caption = $ele_caption . ' *';
     }
     $ele_caption = $myts->displayTarea($ele_caption);
     switch ($e) {
         case 'text':
             $ele_value[2] = eregi_replace("’", "'", $ele_value[2]);
             $ele_value[2] = stripslashes($ele_value[2]);
             $ele_value[2] = $myts->displayTarea($ele_value[2]);
             if (!is_object($xoopsUser)) {
                 $ele_value[2] = preg_replace('/\\{NAME\\}/', '', $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{name\\}/', '', $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{UNAME\\}/', '', $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{uname\\}/', '', $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{EMAIL\\}/', '', $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{email\\}/', '', $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{MAIL\\}/', '', $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{mail\\}/', '', $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{DATE\\}/', '', $ele_value[2]);
             } elseif (!$admin) {
                 $ele_value[2] = preg_replace('/\\{NAME\\}/', $xoopsUser->getVar('name', 'e'), $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{name\\}/', $xoopsUser->getVar('name', 'e'), $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{UNAME\\}/', $xoopsUser->getVar('uname', 'e'), $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{uname\\}/', $xoopsUser->getVar('uname', 'e'), $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{MAIL\\}/', $xoopsUser->getVar('email', 'e'), $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{mail\\}/', $xoopsUser->getVar('email', 'e'), $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{EMAIL\\}/', $xoopsUser->getVar('email', 'e'), $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{email\\}/', $xoopsUser->getVar('email', 'e'), $ele_value[2]);
                 $ele_value[2] = preg_replace('/\\{DATE\\}/', date("d-m-Y"), $ele_value[2]);
             }
             $form_ele = new XoopsFormText($ele_caption, $form_ele_id, $ele_value[0], $ele_value[1], stripslashes($ele_value[2]));
             break;
         case 'textarea':
             $ele_value[0] = stripslashes($ele_value[0]);
             $ele_value[0] = $myts->displayTarea($ele_value[0]);
             $form_ele = new XoopsFormTextArea($ele_caption, $form_ele_id, $ele_value[0], $ele_value[1], $ele_value[2]);
             break;
         case 'areamodif':
             $ele_value[0] = stripslashes($ele_value[0]);
             $ele_value[0] = $myts->displayTarea($ele_value[0]);
             $form_ele = new XoopsFormLabel($ele_caption, $ele_value[0]);
             break;
         case 'select':
             $selected = array();
             $options = array();
             $opt_count = 1;
             while ($i = each($ele_value[2])) {
                 $options[$opt_count] = $myts->stripSlashesGPC($i['key']);
                 if ($i['value'] > 0) {
                     $selected[] = $opt_count;
                 }
                 $opt_count++;
             }
             if ($qcm == '1') {
                 $form_ele = new XoopsFormSelect($ele_caption, $form_ele_id, '', $ele_value[0], $ele_value[1]);
             } else {
                 $form_ele = new XoopsFormSelect($ele_caption, $form_ele_id, $selected, $ele_value[0], $ele_value[1]);
             }
             if ($ele_value[1]) {
                 $this->_ele->setVar('ele_req', 0);
             }
             $form_ele->addOptionArray($options);
             break;
         case 'checkbox':
             $selected = array();
             $options = array();
             $opt_count = 1;
             while ($i = each($ele_value)) {
                 $options[$opt_count] = $myts->stripSlashesGPC($i['key']);
                 if ($i['value'] > 0) {
                     $selected[] = $opt_count;
                 }
                 $opt_count++;
             }
             switch ($xoopsModuleConfig['delimeter']) {
                 case 'br':
                     $form_ele = new XoopsFormElementTray($ele_caption, '<br />');
                     while ($o = each($options)) {
                         if ($qcm == '1') {
                             $t =& new XoopsFormCheckBox('', $form_ele_id . '[]');
                         } else {
                             $t =& new XoopsFormCheckBox('', $form_ele_id . '[]', $selected);
                         }
                         $t->addOption($o['key'], $o['value']);
                         $form_ele->addElement($t);
                     }
                     break;
                 default:
                     if ($qcm == '1') {
                         $form_ele = new XoopsFormCheckBox($ele_caption, $form_ele_id);
                     } else {
                         $form_ele = new XoopsFormCheckBox($ele_caption, $form_ele_id, $selected);
                     }
                     $form_ele->addOptionArray($options);
                     break;
             }
             break;
         case 'mail':
             $selected = array();
             $options = array();
             $opt_count = 1;
             while ($i = each($ele_value)) {
                 $options[$opt_count] = $myts->stripSlashesGPC($i['key']);
                 if ($i['value'] > 0) {
                     $selected[] = $opt_count;
                 }
                 $opt_count++;
             }
             $form_ele = new XoopsFormElementTray($ele_caption, '<br />');
             while ($o = each($options)) {
                 $t =& new XoopsFormCheckBox('', $form_ele_id . '[]', $selected);
                 $o['value'] = split(" - ", $o['value']);
                 $t->addOption($o['key'], $o['value'][0]);
                 $form_ele->addElement($t);
             }
             break;
         case 'mailunique':
         case 'radio':
         case 'yn':
             $selected = '';
             $options = array();
             $opt_count = 1;
             while ($i = each($ele_value)) {
                 switch ($e) {
                     case 'radio':
                         $options[$opt_count] = $myts->stripSlashesGPC($i['key']);
                         $options[$opt_count] = $myts->displayTarea($options[$opt_count]);
                         break;
                     case 'mailunique':
                         $options[$opt_count] = $myts->stripSlashesGPC($i['key']);
                         $options[$opt_count] = split(" - ", $options[$opt_count]);
                         $options[$opt_count] = $myts->displayTarea($options[$opt_count][0]);
                         break;
                     case 'yn':
                         $options[$opt_count] = constant($i['key']);
                         $options[$opt_count] = $myts->stripSlashesGPC($options[$opt_count]);
                         break;
                 }
                 if ($i['value'] > 0) {
                     $selected = $opt_count;
                 }
                 $opt_count++;
             }
             switch ($xoopsModuleConfig['delimeter']) {
                 case 'br':
                     $form_ele = new XoopsFormElementTray($ele_caption, '<br />');
                     while ($o = each($options)) {
                         if ($qcm == '1') {
                             $t =& new XoopsFormRadio('', $form_ele_id);
                         } else {
                             $t =& new XoopsFormRadio('', $form_ele_id, $selected);
                         }
                         $t->addOption($o['key'], $o['value']);
                         $form_ele->addElement($t);
                     }
                     break;
                 default:
                     if ($qcm == '1') {
                         $form_ele = new XoopsFormRadio($ele_caption, $form_ele_id);
                     } else {
                         $form_ele = new XoopsFormRadio($ele_caption, $form_ele_id, $selected);
                     }
                     $form_ele->addOptionArray($options);
                     break;
             }
             break;
         case 'date':
             $form_ele = new XoopsFormTextDateSelect($ele_caption, $form_ele_id, 15, strtotime($ele_value[0]));
             break;
         case 'sep':
             $ele_value[0] = eregi_replace('@font', '', $ele_value[0]);
             $ele_value[0] = $myts->xoopsCodeDecode($ele_value[0]);
             $form_ele = new XoopsFormLabel($ele_caption, $ele_value[0]);
             break;
         case 'upload':
             $form_ele = new XoopsFormElementTray($ele_caption, '');
             $form_ele->addElement(new XoopsFormFile('', $form_ele_id, $ele_value[1]));
             $pds = $ele_value[1] / 1024;
             $form_ele->addElement(new XoopsFormLabel('&nbsp;&nbsp;&nbsp;' . $pds . ' ko max.', ''));
             break;
         default:
             return false;
             break;
     }
     return $form_ele;
 }
예제 #8
0
 /**
  * @param bool $action
  *
  * @return XoopsThemeForm
  */
 public function getForm($action = false)
 {
     if ($action === false) {
         $action = $_SERVER['REQUEST_URI'];
     }
     if ($this->isNew()) {
         $s_cat_value = '';
         $a_mod_value = array();
         $r_mod_value = array();
         $r_block_value = array();
     } else {
         $sysperm_handler = xoops_getHandler('groupperm');
         $s_cat_value = $sysperm_handler->getItemIds('system_admin', $this->getVar('groupid'));
         $member_handler = xoops_getHandler('member');
         $thisgroup = $member_handler->getGroup($this->getVar('groupid'));
         $moduleperm_handler = xoops_getHandler('groupperm');
         $a_mod_value = $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid'));
         $r_mod_value = $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid'));
         $gperm_handler = xoops_getHandler('groupperm');
         $r_block_value = $gperm_handler->getItemIds('block_read', $this->getVar('groupid'));
     }
     xoops_load('XoopsFormLoader');
     xoops_load('XoopsLists');
     include_once XOOPS_ROOT_PATH . '/modules/system/constants.php';
     $title = $this->isNew() ? sprintf(_AM_SYSTEM_GROUPS_ADD) : sprintf(_AM_SYSTEM_GROUPS_EDIT);
     $form = new XoopsThemeForm($title, 'groupform', $action, 'post', true);
     $form->setExtra('enctype="multipart/form-data"');
     $name_text = new XoopsFormText(_AM_SYSTEM_GROUPS_NAME, 'name', 30, 50, $this->getVar('name'));
     $desc_text = new XoopsFormTextArea(_AM_SYSTEM_GROUPS_DESCRIPTION, 'desc', $this->getVar('description'));
     $system_catids = new XoopsFormElementTray(_AM_SYSTEM_GROUPS_SYSTEMRIGHTS, '');
     $s_cat_checkbox_all = new XoopsFormCheckBox('', 'catbox', 1);
     $s_cat_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL);
     $s_cat_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"catbox\" , \"system_catids[]\");' ");
     $s_cat_checkbox_all->setClass('xo-checkall');
     $system_catids->addElement($s_cat_checkbox_all);
     $s_cat_checkbox = new XoopsFormCheckBox('', 'system_catids', $s_cat_value);
     $s_cat_checkbox->columns = 6;
     $admin_dir = XOOPS_ROOT_PATH . '/modules/system/admin/';
     $dirlist = XoopsLists::getDirListAsArray($admin_dir);
     foreach ($dirlist as $file) {
         include XOOPS_ROOT_PATH . '/modules/system/admin/' . $file . '/xoops_version.php';
         if (!empty($modversion['category'])) {
             if (xoops_getModuleOption('active_' . $file, 'system') == 1) {
                 $s_cat_checkbox->addOption($modversion['category'], $modversion['name']);
             }
         }
         unset($modversion);
     }
     unset($dirlist);
     $system_catids->addElement($s_cat_checkbox);
     $admin_mids = new XoopsFormElementTray(_AM_SYSTEM_GROUPS_ACTIVERIGHTS, '');
     $s_admin_checkbox_all = new XoopsFormCheckBox('', 'adminbox', 1);
     $s_admin_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL);
     $s_admin_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"adminbox\" , \"admin_mids[]\");' ");
     $s_admin_checkbox_all->setClass('xo-checkall');
     $admin_mids->addElement($s_admin_checkbox_all);
     $a_mod_checkbox = new XoopsFormCheckBox('', 'admin_mids[]', $a_mod_value);
     $a_mod_checkbox->columns = 5;
     $module_handler = xoops_getHandler('module');
     $criteria = new CriteriaCompo(new Criteria('hasadmin', 1));
     $criteria->add(new Criteria('isactive', 1));
     $criteria->add(new Criteria('dirname', 'system', '<>'));
     $a_mod_checkbox->addOptionArray($module_handler->getList($criteria));
     $admin_mids->addElement($a_mod_checkbox);
     $read_mids = new XoopsFormElementTray(_AM_SYSTEM_GROUPS_ACCESSRIGHTS, '');
     $s_mod_checkbox_all = new XoopsFormCheckBox('', 'readbox', 1);
     $s_mod_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL);
     $s_mod_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"readbox\" , \"read_mids[]\");' ");
     $s_mod_checkbox_all->setClass('xo-checkall');
     $read_mids->addElement($s_mod_checkbox_all);
     $r_mod_checkbox = new XoopsFormCheckBox('', 'read_mids[]', $r_mod_value);
     $r_mod_checkbox->columns = 5;
     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
     $criteria->add(new Criteria('isactive', 1));
     $r_mod_checkbox->addOptionArray($module_handler->getList($criteria));
     $read_mids->addElement($r_mod_checkbox);
     $criteria = new CriteriaCompo(new Criteria('isactive', 1));
     $criteria->setSort('mid');
     $criteria->setOrder('ASC');
     $module_list = $module_handler->getList($criteria);
     $module_list[0] = _AM_SYSTEM_GROUPS_CUSTOMBLOCK;
     $block_handler = xoops_getHandler('block');
     $blocks_obj = $block_handler->getObjects(new Criteria('mid', "('" . implode("', '", array_keys($module_list)) . "')", 'IN'), true);
     $blocks_module = array();
     foreach (array_keys($blocks_obj) as $bid) {
         $title = $blocks_obj[$bid]->getVar('title');
         $blocks_module[$blocks_obj[$bid]->getVar('mid')][$blocks_obj[$bid]->getVar('bid')] = empty($title) ? $blocks_obj[$bid]->getVar('name') : $title;
     }
     ksort($blocks_module);
     $r_block_tray = new XoopsFormElementTray(_AM_SYSTEM_GROUPS_BLOCKRIGHTS, '<br><br>');
     $s_checkbox_all = new XoopsFormCheckBox('', 'blocksbox', 1);
     $s_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL);
     $s_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"blocksbox\" , \"read_bids[]\");' ");
     $s_checkbox_all->setClass('xo-checkall');
     $r_block_tray->addElement($s_checkbox_all);
     foreach (array_keys($blocks_module) as $mid) {
         $new_blocks_array = array();
         foreach ($blocks_module[$mid] as $key => $value) {
             $new_blocks_array[$key] = "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&amp;op=edit&amp;bid={$key}' title='ID: {$key}' rel='external'>{$value}</a>";
         }
         $r_block_checkbox = new XoopsFormCheckBox('<strong>' . $module_list[$mid] . '</strong><br>', 'read_bids[]', $r_block_value);
         $r_block_checkbox->columns = 5;
         $r_block_checkbox->addOptionArray($new_blocks_array);
         $r_block_tray->addElement($r_block_checkbox);
         unset($r_block_checkbox);
     }
     if (!$this->isNew()) {
         $form->addElement(new XoopsFormHidden('g_id', $this->getVar('groupid')));
         $form->addElement(new XoopsFormHidden('op', 'groups_save_update'));
     } else {
         $form->addElement(new XoopsFormHidden('op', 'groups_save_add'));
     }
     $form->addElement($name_text, true);
     $form->addElement($desc_text);
     $form->addElement($system_catids);
     $form->addElement($admin_mids);
     $form->addElement($read_mids);
     $form->addElement($r_block_tray);
     $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
     return $form;
 }
예제 #9
0
function topicsmanager()
{
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    xoops_cp_header();
    adminmenu(0);
    $uploadfolder = sprintf(_AM_UPLOAD_WARNING, XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/images/topics');
    $uploadirectory = '/modules/' . $xoopsModule->dirname() . '/images/topics';
    $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
    $xt = new XoopsTree($xoopsDB->prefix('topics'), 'topic_id', 'topic_pid');
    $topics_arr = $xt->getChildTreeArray(0, 'topic_title');
    $totaltopics = count($topics_arr);
    $class = '';
    echo '<h4>' . _AM_CONFIG . '</h4>';
    news_collapsableBar('topicsmanager', 'toptopicsmanager');
    echo "<img onclick=\"toggle('toptable'); toggleIcon('toptableicon');\" id='toptopicsmanager' name='toptopicsmanager' src='" . XOOPS_URL . "/modules/news/images/close12.gif' alt='' /></a>&nbsp;" . _AM_TOPICSMNGR . ' (' . $totaltopics . ')' . "</h4>";
    echo "<div id='topicsmanager'>";
    echo '<br />';
    echo "<div style='text-align: center;'>";
    echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'><tr class='bg3'><td align='center'>" . _AM_TOPIC . "</td><td align='left'>" . _AM_TOPICNAME . "</td><td align='center'>" . _AM_PARENTTOPIC . "</td><td align='center'>" . _AM_SUB_MENU_YESNO . "</td><td align='center'>" . _AM_ACTION . "</td></tr>";
    if (is_array($topics_arr) && $totaltopics) {
        $cpt = 1;
        $tmpcpt = $start;
        $ok = true;
        $output = '';
        while ($ok) {
            if ($tmpcpt < $totaltopics) {
                $linkedit = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/index.php?op=topicsmanager&amp;topic_id=' . $topics_arr[$tmpcpt]['topic_id'];
                $linkdelete = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/index.php?op=delTopic&amp;topic_id=' . $topics_arr[$tmpcpt]['topic_id'];
                $action = sprintf("<a href='%s'>%s</a> - <a href='%s'>%s</a>", $linkedit, _AM_EDIT, $linkdelete, _AM_DELETE);
                $parent = '&nbsp;';
                if ($topics_arr[$tmpcpt]['topic_pid'] > 0) {
                    $xttmp = new XoopsTopic($xoopsDB->prefix('topics'), $topics_arr[$tmpcpt]['topic_pid']);
                    $parent = $xttmp->topic_title();
                    unset($xttmp);
                }
                if ($topics_arr[$tmpcpt]['topic_pid'] != 0) {
                    $topics_arr[$tmpcpt]['prefix'] = str_replace('.', '-', $topics_arr[$tmpcpt]['prefix']) . '&nbsp;';
                } else {
                    $topics_arr[$tmpcpt]['prefix'] = str_replace('.', '', $topics_arr[$tmpcpt]['prefix']);
                }
                $submenu = $topics_arr[$tmpcpt]['menu'] ? _YES : _NO;
                $class = $class == 'even' ? 'odd' : 'even';
                $output = $output . "<tr class='" . $class . "'><td>" . $topics_arr[$tmpcpt]['topic_id'] . "</td><td align='left'>" . $topics_arr[$tmpcpt]['prefix'] . $myts->displayTarea($topics_arr[$tmpcpt]['topic_title']) . "</td><td align='left'>" . $parent . "</td><td>" . $submenu . "</td><td>" . $action . "</td></tr>";
            } else {
                $ok = false;
            }
            if ($cpt >= news_getmoduleoption('storycountadmin')) {
                $ok = false;
            }
            $tmpcpt++;
            $cpt++;
        }
        echo $output;
    }
    $pagenav = new XoopsPageNav($totaltopics, news_getmoduleoption('storycountadmin'), $start, 'start', 'op=topicsmanager');
    echo "</table><div align='right'>" . $pagenav->renderNav() . '</div><br />';
    echo "</div></div><br />\n";
    $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0;
    if ($topic_id > 0) {
        $xtmod = new NewsTopic($topic_id);
        $topic_title = $xtmod->topic_title('E');
        $topic_description = $xtmod->topic_description('E');
        $topic_rssfeed = $xtmod->topic_rssurl('E');
        $op = 'modTopicS';
        if (xoops_trim($xtmod->topic_imgurl()) != '') {
            $topicimage = $xtmod->topic_imgurl();
        } else {
            $topicimage = 'blank.png';
        }
        $btnlabel = _AM_MODIFY;
        $parent = $xtmod->topic_pid();
        $formlabel = _AM_MODIFYTOPIC;
        $submenu = $xtmod->menu();
        $topic_frontpage = $xtmod->topic_frontpage();
        $topic_color = $xtmod->topic_color();
        unset($xtmod);
    } else {
        $topic_title = '';
        $topic_frontpage = 1;
        $topic_description = '';
        $op = 'addTopic';
        $topicimage = 'xoops.gif';
        $btnlabel = _AM_ADD;
        $parent = -1;
        $submenu = 0;
        $topic_rssfeed = '';
        $formlabel = _AM_ADD_TOPIC;
        $topic_color = '000000';
    }
    $sform = new XoopsThemeForm($formlabel, 'topicform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php', 'post');
    $sform->setExtra('enctype="multipart/form-data"');
    $sform->addElement(new XoopsFormText(_AM_TOPICNAME, 'topic_title', 50, 255, $topic_title), true);
    $editor = news_getWysiwygForm(_AM_TOPIC_DESCR, 'topic_description', $topic_description, 15, 60, 'hometext_hidden');
    if ($editor) {
        $sform->addElement($editor, false);
    }
    $sform->addElement(new XoopsFormHidden('op', $op), false);
    $sform->addElement(new XoopsFormHidden('topic_id', $topic_id), false);
    include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php';
    $xt = new NewsTopic();
    $sform->addElement(new XoopsFormLabel(_AM_PARENTTOPIC, $xt->MakeMyTopicSelBox(1, $parent, 'topic_pid', '', false)));
    // Topic's color
    // Code stolen to Zoullou, thank you Zoullou ;-)
    $select_color = "\n<select name='topic_color'  onchange='xoopsGetElementById(\"NewsColorSelect\").style.backgroundColor = \"#\" + this.options[this.selectedIndex].value;'>\n<option value='000000'>" . _AM_NEWS_COLOR . "</option>\n";
    $color_values = array('000000', '000033', '000066', '000099', '0000CC', '0000FF', '003300', '003333', '003366', '0033CC', '0033FF', '006600', '006633', '006666', '006699', '0066CC', '0066FF', '009900', '009933', '009966', '009999', '0099CC', '0099FF', '00CC00', '00CC33', '00CC66', '00CC99', '00CCCC', '00CCFF', '00FF00', '00FF33', '00FF66', '00FF99', '00FFCC', '00FFFF', '330000', '330033', '330066', '330099', '3300CC', '3300FF', '333300', '333333', '333366', '333399', '3333CC', '3333FF', '336600', '336633', '336666', '336699', '3366CC', '3366FF', '339900', '339933', '339966', '339999', '3399CC', '3399FF', '33CC00', '33CC33', '33CC66', '33CC99', '33CCCC', '33CCFF', '33FF00', '33FF33', '33FF66', '33FF99', '33FFCC', '33FFFF', '660000', '660033', '660066', '660099', '6600CC', '6600FF', '663300', '663333', '663366', '663399', '6633CC', '6633FF', '666600', '666633', '666666', '666699', '6666CC', '6666FF', '669900', '669933', '669966', '669999', '6699CC', '6699FF', '66CC00', '66CC33', '66CC66', '66CC99', '66CCCC', '66CCFF', '66FF00', '66FF33', '66FF66', '66FF99', '66FFCC', '66FFFF', '990000', '990033', '990066', '990099', '9900CC', '9900FF', '993300', '993333', '993366', '993399', '9933CC', '9933FF', '996600', '996633', '996666', '996699', '9966CC', '9966FF', '999900', '999933', '999966', '999999', '9999CC', '9999FF', '99CC00', '99CC33', '99CC66', '99CC99', '99CCCC', '99CCFF', '99FF00', '99FF33', '99FF66', '99FF99', '99FFCC', '99FFFF', 'CC0000', 'CC0033', 'CC0066', 'CC0099', 'CC00CC', 'CC00FF', 'CC3300', 'CC3333', 'CC3366', 'CC3399', 'CC33CC', 'CC33FF', 'CC6600', 'CC6633', 'CC6666', 'CC6699', 'CC66CC', 'CC66FF', 'CC9900', 'CC9933', 'CC9966', 'CC9999', 'CC99CC', 'CC99FF', 'CCCC00', 'CCCC33', 'CCCC66', 'CCCC99', 'CCCCCC', 'CCCCFF', 'CCFF00', 'CCFF33', 'CCFF66', 'CCFF99', 'CCFFCC', 'CCFFFF', 'FF0000', 'FF0033', 'FF0066', 'FF0099', 'FF00CC', 'FF00FF', 'FF3300', 'FF3333', 'FF3366', 'FF3399', 'FF33CC', 'FF33FF', 'FF6600', 'FF6633', 'FF6666', 'FF6699', 'FF66CC', 'FF66FF', 'FF9900', 'FF9933', 'FF9966', 'FF9999', 'FF99CC', 'FF99FF', 'FFCC00', 'FFCC33', 'FFCC66', 'FFCC99', 'FFCCCC', 'FFCCFF', 'FFFF00', 'FFFF33', 'FFFF66', 'FFFF99', 'FFFFCC', 'FFFFFF');
    foreach ($color_values as $color_value) {
        if ($topic_color == $color_value) {
            $selected = " selected='selected'";
        } else {
            $selected = '';
        }
        $select_color .= "<option" . $selected . " value='" . $color_value . "' style='background-color:#" . $color_value . ";color:#" . $color_value . ";'>#" . $color_value . "</option>\n";
    }
    $select_color .= "</select>&nbsp;\n<span id='NewsColorSelect'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
    $sform->addElement(new XoopsFormLabel(_AM_NEWS_TOPIC_COLOR, $select_color));
    // Sub menu ?
    $sform->addElement(new XoopsFormRadioYN(_AM_SUB_MENU, 'submenu', $submenu, _YES, _NO));
    $sform->addElement(new XoopsFormRadioYN(_AM_PUBLISH_FRONTPAGE, 'topic_frontpage', $topic_frontpage, _YES, _NO));
    // Unused for this moment... sorry
    //$sform->addElement(new XoopsFormText(_AM_NEWS_RSS_URL, 'topic_rssfeed', 50, 255, $topic_rssfeed), false);
    // ********** Picture
    $imgtray = new XoopsFormElementTray(_AM_TOPICIMG, '<br />');
    $imgpath = sprintf(_AM_IMGNAEXLOC, 'modules/' . $xoopsModule->dirname() . '/images/topics/');
    $imageselect = new XoopsFormSelect($imgpath, 'topic_imgurl', $topicimage);
    $topics_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/news/images/topics/');
    foreach ($topics_array as $image) {
        $imageselect->addOption("{$image}", $image);
    }
    $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"topic_imgurl\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'");
    $imgtray->addElement($imageselect, false);
    $imgtray->addElement(new XoopsFormLabel('', "<br /><img src='" . XOOPS_URL . "/" . $uploadirectory . "/" . $topicimage . "' name='image3' id='image3' alt='' />"));
    $uploadfolder = sprintf(_AM_UPLOAD_WARNING, XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/images/topics');
    $fileseltray = new XoopsFormElementTray('', '<br />');
    $fileseltray->addElement(new XoopsFormFile(_AM_TOPIC_PICTURE, 'attachedfile', news_getmoduleoption('maxuploadsize')), false);
    $fileseltray->addElement(new XoopsFormLabel($uploadfolder), false);
    $imgtray->addElement($fileseltray);
    $sform->addElement($imgtray);
    // Permissions
    $member_handler =& xoops_gethandler('member');
    $group_list =& $member_handler->getGroupList();
    $gperm_handler =& xoops_gethandler('groupperm');
    $full_list = array_keys($group_list);
    $groups_ids = array();
    if ($topic_id > 0) {
        // Edit mode
        $groups_ids = $gperm_handler->getGroupIds('news_approve', $topic_id, $xoopsModule->getVar('mid'));
        $groups_ids = array_values($groups_ids);
        $groups_news_can_approve_checkbox = new XoopsFormCheckBox(_AM_APPROVEFORM, 'groups_news_can_approve[]', $groups_ids);
    } else {
        // Creation mode
        $groups_news_can_approve_checkbox = new XoopsFormCheckBox(_AM_APPROVEFORM, 'groups_news_can_approve[]', $full_list);
    }
    $groups_news_can_approve_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_news_can_approve_checkbox);
    $groups_ids = array();
    if ($topic_id > 0) {
        // Edit mode
        $groups_ids = $gperm_handler->getGroupIds('news_submit', $topic_id, $xoopsModule->getVar('mid'));
        $groups_ids = array_values($groups_ids);
        $groups_news_can_submit_checkbox = new XoopsFormCheckBox(_AM_SUBMITFORM, 'groups_news_can_submit[]', $groups_ids);
    } else {
        // Creation mode
        $groups_news_can_submit_checkbox = new XoopsFormCheckBox(_AM_SUBMITFORM, 'groups_news_can_submit[]', $full_list);
    }
    $groups_news_can_submit_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_news_can_submit_checkbox);
    $groups_ids = array();
    if ($topic_id > 0) {
        // Edit mode
        $groups_ids = $gperm_handler->getGroupIds('news_view', $topic_id, $xoopsModule->getVar('mid'));
        $groups_ids = array_values($groups_ids);
        $groups_news_can_view_checkbox = new XoopsFormCheckBox(_AM_VIEWFORM, 'groups_news_can_view[]', $groups_ids);
    } else {
        // Creation mode
        $groups_news_can_view_checkbox = new XoopsFormCheckBox(_AM_VIEWFORM, 'groups_news_can_view[]', $full_list);
    }
    $groups_news_can_view_checkbox->addOptionArray($group_list);
    $sform->addElement($groups_news_can_view_checkbox);
    // Submit buttons
    $button_tray = new XoopsFormElementTray('', '');
    $submit_btn = new XoopsFormButton('', 'post', $btnlabel, 'submit');
    $button_tray->addElement($submit_btn);
    $sform->addElement($button_tray);
    $sform->display();
    echo "<script type='text/javascript'>\n";
    echo 'xoopsGetElementById("NewsColorSelect").style.backgroundColor = "#' . $topic_color . '";';
    echo "</script>\n";
}
예제 #10
0
파일: case.php 프로젝트: yunsite/xoopsdc
 function getForm($action = false)
 {
     global $xoopsModuleConfig;
     include_once XOOPS_ROOT_PATH . "/modules/portfolio/include/functions.render.php";
     include_once XOOPS_ROOT_PATH . "/modules/portfolio/include/functions.php";
     include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
     $service_handler = xoops_getmodulehandler('service', 'portfolio');
     $cs_handler = xoops_getmodulehandler('cs', 'portfolio');
     $images_handler = xoops_getmodulehandler('images', 'portfolio');
     if ($action === false) {
         $action = $_SERVER['REQUEST_URI'];
     }
     $title = $this->isNew() ? '添加案例' : '更新案例';
     $format = empty($format) ? "e" : $format;
     $status = $this->isNew() ? 1 : $this->getVar('case_status');
     $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
     $form->setExtra("enctype=\"multipart/form-data\"");
     //名称
     $form->addElement(new XoopsFormText('案例名称', 'case_title', 60, 255, $this->getVar('case_title', $format)), true);
     $form->addElement(new XoopsFormText('页面标题', 'case_menu_title', 60, 255, $this->getVar('case_menu_title', $format)));
     //所属服务
     $service_ids = array();
     $cs = '';
     if ($this->getVar('case_id')) {
         $cs = $cs_handler->getServerIds(array($this->getVar('case_id')));
     }
     if (!empty($cs)) {
         foreach ($cs as $k => $v) {
             $service_ids[$v['service_id']] = $v['service_id'];
         }
     }
     $services = $service_handler->getTrees(0, "--");
     $service_options = array();
     if (!empty($services)) {
         foreach ($services as $id => $cat) {
             $service_options[$id] = $cat["prefix"] . $cat["service_menu_name"];
         }
     }
     $service_select = new XoopsFormCheckBox("所属服务", "service_ids", array_keys($service_ids));
     $service_select->addOptionArray($service_options);
     $form->addElement($service_select);
     //题头图片
     $case_image = new XoopsFormElementTray('题头图片', '', 'image');
     if ($this->getVar('case_image')) {
         $case_image->addElement(new XoopsFormLabel('', '<img  width="100" src="' . XOOPS_URL . '/uploads/portfolio/' . $this->getVar('case_image') . '"><br><br>'));
         $delete_check = new XoopsFormCheckBox('', 'delete_image');
         $delete_check->addOption(1, _DELETE);
         $case_image->addElement($delete_check);
         $display = '从新上传将会覆盖现有文件';
     } else {
         $display = '';
     }
     $case_image->addElement(new XoopsFormFile('', 'case_image', 1024 * 1024 * 2));
     $case_image->addElement(new XoopsFormLabel('', '允许上传的类型为jpeg,pjpeg,gif,png文件'));
     $case_image->addElement(new XoopsFormLabel('', $display));
     $form->addElement($case_image);
     //案例相册
     $gallery = new XoopsFormElementTray('案例相册', '', 'gallery');
     if (!$this->isNew()) {
         $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('case_id', $this->getVar('case_id')));
         $images = $images_handler->getAll($criteria, null, false, false);
         if (!empty($images)) {
             $list = '已有图片列表<input id="check" name="check" type="checkbox" onclick="xoopsCheckAll(\'form\',\'check\');" />全部';
             $list .= '<ul class="ItemsList">';
             foreach ($images as $k => $v) {
                 $list .= '<li>';
                 $list .= '
                     <img width=100 height="80" src="' . XOOPS_URL . '/uploads/portfolio/gallery/' . $v['image_file'] . '">
                     <div align="center">
                         <input type="checkbox" value="' . $v['image_id'] . '" name="del_image_ids[]">
                         名称:&nbsp;<input type="text" value="' . $v['image_title'] . '" maxlength="255" size="10" name="image_title[' . $v['image_id'] . ']"><br />
                         图片描述:&nbsp;<textarea cols="50" rows="5" name=image_desc[' . $v['image_id'] . ']">' . $v['image_desc'] . '</textarea>
                     </div>
                 ';
                 $list .= '</li>';
             }
             $list .= '</ul>';
             $gallery->addElement(new XoopsFormLabel('', $list));
             $gallery->addElement(new XoopsFormLabel('', '<br style="clear: both;"/><br />(勾选图片提交后将被清除)'));
         }
     }
     $gallery->addElement(new XoopsFormLabel('', '<div><a id="addMore" href="javascript:void(0);">添加相册内容</a></div>'));
     $form->addElement($gallery);
     //摘要
     $form->addElement(new XoopsFormTextArea('案例摘要', 'case_summary', $this->getVar('case_summary'), 5, 100));
     //案例介绍
     $configs = array('editor' => 'fckeditor', 'width' => '100%', 'height' => '500px', 'value' => $this->getVar('case_description'));
     $form->addElement(new XoopsFormEditor('案例介绍', 'case_description', $configs));
     //模板选择
     $templates = portfolio_getTemplateList("case");
     if (count($templates) > 0) {
         $template_select = new XoopsFormSelect("案例模板", "case_tpl", $this->getVar("case_tpl"));
         $template_select->addOptionArray($templates);
         $form->addElement($template_select);
     }
     //状态
     $form->addElement(new XoopsFormRadioYN('是否显示', 'case_status', 1));
     //创建时间
     if ($this->isNew()) {
         $form->addElement(new XoopsFormHidden('case_pushtime', time()));
     }
     $form->addElement(new XoopsFormHidden('case_id', $this->getVar('case_id')));
     $form->addElement(new XoopsFormHidden('ac', 'insert'));
     $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
     return $form;
 }
예제 #11
0
/**
 * Get {@link XoopsThemeForm} for adding/editing fields
 *
 * @param object $field {@link ProfileField} object to get edit form for
 * @param mixed $action URL to submit to - or false for $_SERVER['REQUEST_URI']
 *
 * @return object
 */
function profile_getFieldForm(&$field, $action = false)
{
    if ($action === false) {
        $action = $_SERVER['REQUEST_URI'];
    }
    $title = $field->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_FIELD) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_FIELD);
    include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
    $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
    $form->addElement(new XoopsFormText(_PROFILE_AM_TITLE, 'field_title', 35, 255, $field->getVar('field_title', 'e')));
    $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DESCRIPTION, 'field_description', $field->getVar('field_description', 'e')));
    if (!$field->isNew()) {
        $fieldcat_id = $field->getVar('cat_id');
    } else {
        $fieldcat_id = 0;
    }
    $category_handler =& xoops_getmodulehandler('category');
    $cat_select = new XoopsFormSelect(_PROFILE_AM_CATEGORY, 'field_category', $fieldcat_id);
    $cat_select->addOption(0, _PROFILE_AM_DEFAULT);
    $cat_select->addOptionArray($category_handler->getList());
    $form->addElement($cat_select);
    $form->addElement(new XoopsFormText(_PROFILE_AM_WEIGHT, 'field_weight', 10, 10, $field->getVar('field_weight', 'e')));
    if ($field->getVar('field_config') || $field->isNew()) {
        if (!$field->isNew()) {
            $form->addElement(new XoopsFormLabel(_PROFILE_AM_NAME, $field->getVar('field_name')));
            $form->addElement(new XoopsFormHidden('id', $field->getVar('field_id')));
        } else {
            $form->addElement(new XoopsFormText(_PROFILE_AM_NAME, 'field_name', 35, 255, $field->getVar('field_name', 'e')));
        }
        //autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think)
        $fieldtypes = array('checkbox' => _PROFILE_AM_CHECKBOX, 'date' => _PROFILE_AM_DATE, 'datetime' => _PROFILE_AM_DATETIME, 'longdate' => _PROFILE_AM_LONGDATE, 'group' => _PROFILE_AM_GROUP, 'group_multi' => _PROFILE_AM_GROUPMULTI, 'language' => _PROFILE_AM_LANGUAGE, 'radio' => _PROFILE_AM_RADIO, 'select' => _PROFILE_AM_SELECT, 'select_multi' => _PROFILE_AM_SELECTMULTI, 'textarea' => _PROFILE_AM_TEXTAREA, 'dhtml' => _PROFILE_AM_DHTMLTEXTAREA, 'textbox' => _PROFILE_AM_TEXTBOX, 'timezone' => _PROFILE_AM_TIMEZONE, 'yesno' => _PROFILE_AM_YESNO);
        $element_select = new XoopsFormSelect(_PROFILE_AM_TYPE, 'field_type', $field->getVar('field_type', 'e'));
        $element_select->addOptionArray($fieldtypes);
        $form->addElement($element_select);
        switch ($field->getVar('field_type')) {
            case "textbox":
                $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_FLOAT => _PROFILE_AM_FLOAT, XOBJ_DTYPE_DECIMAL => _PROFILE_AM_DECIMAL, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER, XOBJ_DTYPE_UNICODE_ARRAY => _PROFILE_AM_UNICODE_ARRAY, XOBJ_DTYPE_UNICODE_TXTBOX => _PROFILE_AM_UNICODE_TXTBOX, XOBJ_DTYPE_UNICODE_TXTAREA => _PROFILE_AM_UNICODE_TXTAREA, XOBJ_DTYPE_UNICODE_EMAIL => _PROFILE_AM_UNICODE_EMAIL, XOBJ_DTYPE_UNICODE_URL => _PROFILE_AM_UNICODE_URL);
                $type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
                $type_select->addOptionArray($valuetypes);
                $form->addElement($type_select);
                break;
            case "select":
            case "radio":
                $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_FLOAT => _PROFILE_AM_FLOAT, XOBJ_DTYPE_DECIMAL => _PROFILE_AM_DECIMAL, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER, XOBJ_DTYPE_UNICODE_ARRAY => _PROFILE_AM_UNICODE_ARRAY, XOBJ_DTYPE_UNICODE_TXTBOX => _PROFILE_AM_UNICODE_TXTBOX, XOBJ_DTYPE_UNICODE_TXTAREA => _PROFILE_AM_UNICODE_TXTAREA, XOBJ_DTYPE_UNICODE_EMAIL => _PROFILE_AM_UNICODE_EMAIL, XOBJ_DTYPE_UNICODE_URL => _PROFILE_AM_UNICODE_URL);
                $type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
                $type_select->addOptionArray($valuetypes);
                $form->addElement($type_select);
                break;
        }
        //$form->addElement(new XoopsFormRadioYN(_PROFILE_AM_NOTNULL, 'field_notnull', $field->getVar('field_notnull', 'e') ));
        if ($field->getVar('field_type') == "select" || $field->getVar('field_type') == "select_multi" || $field->getVar('field_type') == "radio" || $field->getVar('field_type') == "checkbox") {
            $options = $field->getVar('field_options');
            if (count($options) > 0) {
                $remove_options = new XoopsFormCheckBox(_PROFILE_AM_REMOVEOPTIONS, 'removeOptions');
                $remove_options->columns = 3;
                asort($options);
                foreach (array_keys($options) as $key) {
                    $options[$key] .= "[{$key}]";
                }
                $remove_options->addOptionArray($options);
                $form->addElement($remove_options);
            }
            $option_text = "<table  cellspacing='1'><tr><td class='width20'>" . _PROFILE_AM_KEY . "</td><td>" . _PROFILE_AM_VALUE . "</td></tr>";
            for ($i = 0; $i < 3; $i++) {
                $option_text .= "<tr><td><input type='text' name='addOption[{$i}][key]' id='addOption[{$i}][key]' size='15' /></td><td><input type='text' name='addOption[{$i}][value]' id='addOption[{$i}][value]' size='35' /></td></tr>";
                $option_text .= "<tr height='3px'><td colspan='2'> </td></tr>";
            }
            $option_text .= "</table>";
            $form->addElement(new XoopsFormLabel(_PROFILE_AM_ADDOPTION, $option_text));
        }
    }
    if ($field->getVar('field_edit')) {
        switch ($field->getVar('field_type')) {
            case "textbox":
            case "textarea":
            case "dhtml":
                $form->addElement(new XoopsFormText(_PROFILE_AM_MAXLENGTH, 'field_maxlength', 35, 35, $field->getVar('field_maxlength', 'e')));
                $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "checkbox":
            case "select_multi":
                $def_value = $field->getVar('field_default', 'e') != null ? unserialize($field->getVar('field_default', 'n')) : null;
                $element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $def_value, 8, true);
                $options = $field->getVar('field_options');
                asort($options);
                // If options do not include an empty element, then add a blank option to prevent any default selection
                if (!in_array('', array_keys($options))) {
                    $element->addOption('', _NONE);
                }
                $element->addOptionArray($options);
                $form->addElement($element);
                break;
            case "select":
            case "radio":
                $def_value = $field->getVar('field_default', 'e') != null ? $field->getVar('field_default') : null;
                $element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $def_value);
                $options = $field->getVar('field_options');
                asort($options);
                // If options do not include an empty element, then add a blank option to prevent any default selection
                if (!in_array('', array_keys($options))) {
                    $element->addOption('', _NONE);
                }
                $element->addOptionArray($options);
                $form->addElement($element);
                break;
            case "date":
                $form->addElement(new XoopsFormTextDateSelect(_PROFILE_AM_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
                break;
            case "longdate":
                $form->addElement(new XoopsFormTextDateSelect(_PROFILE_AM_DEFAULT, 'field_default', 15, strtotime($field->getVar('field_default', 'e'))));
                break;
            case "datetime":
                $form->addElement(new XoopsFormDateTime(_PROFILE_AM_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
                break;
            case "yesno":
                $form->addElement(new XoopsFormRadioYN(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "timezone":
                $form->addElement(new XoopsFormSelectTimezone(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "language":
                $form->addElement(new XoopsFormSelectLang(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "group":
                $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e')));
                break;
            case "group_multi":
                $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, unserialize($field->getVar('field_default', 'n')), 5, true));
                break;
            case "theme":
                $form->addElement(new XoopsFormSelectTheme(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "autotext":
                $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
        }
    }
    $groupperm_handler =& xoops_gethandler('groupperm');
    $searchable_types = array('textbox', 'select', 'radio', 'yesno', 'date', 'datetime', 'timezone', 'language');
    if (in_array($field->getVar('field_type'), $searchable_types)) {
        $search_groups = $groupperm_handler->getGroupIds('profile_search', $field->getVar('field_id'), $GLOBALS['xoopsModule']->getVar('mid'));
        $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_SEARCH, 'profile_search', true, $search_groups, 5, true));
    }
    if ($field->getVar('field_edit') || $field->isNew()) {
        if (!$field->isNew()) {
            //Load groups
            $editable_groups = $groupperm_handler->getGroupIds('profile_edit', $field->getVar('field_id'), $GLOBALS['xoopsModule']->getVar('mid'));
        } else {
            $editable_groups = array();
        }
        $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_EDITABLE, 'profile_edit', false, $editable_groups, 5, true));
        $form->addElement(new XoopsFormRadioYN(_PROFILE_AM_REQUIRED, 'field_required', $field->getVar('field_required', 'e')));
        $regstep_select = new XoopsFormSelect(_PROFILE_AM_PROF_REGISTER, 'step_id', $field->getVar('step_id', 'e'));
        $regstep_select->addOption(0, _NO);
        $regstep_handler = xoops_getmodulehandler('regstep');
        $regstep_select->addOptionArray($regstep_handler->getList());
        $form->addElement($regstep_select);
    }
    $form->addElement(new XoopsFormHidden('op', 'save'));
    $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
    return $form;
}
예제 #12
0
파일: index.php 프로젝트: yunsite/xoopsdc
 * @author          Susheng Yang <*****@*****.**>
 * @version         $Id$
 */
include 'header.php';
xoops_cp_header();
loadModuleAdminMenu(1, "");
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : 'index';
switch ($op) {
    default:
    case "index":
        include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
        $form = new XoopsThemeForm(_MI_TOOLS_INDEX, "updatecache", "index.php", "post", true);
        $form->addElement(new XoopsFormLabel(_AM_TOOLS_TIP, _AM_TOOLS_TIPS));
        $checkbox_options = array("updatexoopscache" => _AM_TOOLS_UPDATEXOOPSCACHE, "updatesmartycache" => _AM_TOOLS_UPDATESMARTYCACHE, "updatesmartycompile" => _AM_TOOLS_UPDATESMARTYCOMPILE);
        $checkbox = new XoopsFormCheckBox(_AM_TOOLS_OPTIONS, "options", array_keys($checkbox_options));
        $checkbox->addOptionArray($checkbox_options);
        $form->addElement($checkbox);
        $form->addElement(new XoopsFormHidden("op", "updatecache"));
        $form->addElement(new XoopsFormHidden("step", "1"));
        $form->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit"));
        $form->display();
        break;
    case "updatecache":
        if ($_REQUEST['step'] == 1) {
            $options = implode('_', $_REQUEST['options']);
            $url = XOOPS_URL . "/modules/tools/admin/index.php?op=updatecache&step=2&options={$options}";
            $updating = _AM_TOOLS_UPDATING;
            $msg = <<<EOF
\t<div class="loading" style="text-align:center">
    <img src="../images/loader.gif" />
    <p>{$updating}</P>
예제 #13
0
 /**
  * Returns a {@link XoopsFormElement} for editing the value of this field
  *
  * @param XoopsUser      $user    {@link XoopsUser} object to edit the value of
  * @param ProfileProfile $profile {@link ProfileProfile} object to edit the value of
  *
  * @return XoopsFormElement
  **/
 public function getEditElement($user, $profile)
 {
     $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
     $caption = $this->getVar('field_title');
     $caption = defined($caption) ? constant($caption) : $caption;
     $name = $this->getVar('field_name', 'e');
     $options = $this->getVar('field_options');
     if (is_array($options)) {
         //asort($options);
         foreach (array_keys($options) as $key) {
             $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
             $optkey = defined($key) ? constant($key) : $key;
             unset($options[$key]);
             $options[$optkey] = $optval;
         }
     }
     include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
     switch ($this->getVar('field_type')) {
         default:
         case 'autotext':
             //autotext is not for editing
             $element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
             break;
         case 'textbox':
             $element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
             break;
         case 'textarea':
             $element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
             break;
         case 'dhtml':
             $element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
             break;
         case 'select':
             $element = new XoopsFormSelect($caption, $name, $value);
             // If options do not include an empty element, then add a blank option to prevent any default selection
             //                if (!in_array('', array_keys($options))) {
             if (!array_key_exists('', $options)) {
                 $element->addOption('', _NONE);
                 $eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_ENTER, $caption);
                 $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg));
                 $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" . "for (i = 0; i < selectBox.options.length; i++) { if (selectBox.options[i].selected == true && selectBox.options[i].value != '') { hasSelected = true; break; } }" . "if (!hasSelected) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
             }
             $element->addOptionArray($options);
             break;
         case 'select_multi':
             $element = new XoopsFormSelect($caption, $name, $value, 5, true);
             $element->addOptionArray($options);
             break;
         case 'radio':
             $element = new XoopsFormRadio($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case 'checkbox':
             $element = new XoopsFormCheckBox($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case 'yesno':
             $element = new XoopsFormRadioYN($caption, $name, $value);
             break;
         case 'group':
             $element = new XoopsFormSelectGroup($caption, $name, true, $value);
             break;
         case 'group_multi':
             $element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
             break;
         case 'language':
             $element = new XoopsFormSelectLang($caption, $name, $value);
             break;
         case 'date':
             $element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
             break;
         case 'longdate':
             $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace('-', '/', $value));
             break;
         case 'datetime':
             $element = new XoopsFormDatetime($caption, $name, 15, $value);
             break;
         case 'list':
             $element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
             break;
         case 'timezone':
             $element = new XoopsFormSelectTimezone($caption, $name, $value);
             $element->setExtra("style='width: 280px;'");
             break;
         case 'rank':
             $element = new XoopsFormSelect($caption, $name, $value);
             include_once $GLOBALS['xoops']->path('class/xoopslists.php');
             $ranks = XoopsLists::getUserRankList();
             $element->addOption(0, '--------------');
             $element->addOptionArray($ranks);
             break;
         case 'theme':
             $element = new XoopsFormSelectTheme($caption, $name, $value, 1, true);
             break;
     }
     if ($this->getVar('field_description') != '') {
         $element->setDescription($this->getVar('field_description'));
     }
     return $element;
 }
예제 #14
0
파일: search.php 프로젝트: jlm69/alumni-26x
 public function alumni_getSearchFrom($andor, $queries, $mids, $mid, $bycat)
 {
     $xoops = Xoops::getInstance();
     $alumni = Alumni::getInstance();
     // create form
     parent::__construct(XoopsLocale::SEARCH, 'alumni', 'search.php', 'get');
     // create form elements
     $this->addElement(new XoopsFormText(XoopsLocale::KEYWORDS, 'query', 30, 255, htmlspecialchars(stripslashes(implode(' ', $queries)), ENT_QUOTES)), true);
     $type_select = new XoopsFormSelect(XoopsLocale::TYPE, 'andor', $andor);
     $type_select->addOptionArray(array('AND' => XoopsLocale::ALL_AND, 'OR' => XoopsLocale::ANY_OR, 'exact' => XoopsLocale::EXACT_MATCH));
     $this->addElement($type_select);
     $by_cat = Request::getInt('by_cat', 0);
     $categoriesHandler = $xoops->getModuleHandler('category', 'alumni');
     $search = Search::getInstance();
     $module_id = $xoops->module->getVar('mid');
     $groups = $xoops->isUser() ? $xoops->user->getGroups() : '3';
     $alumni_ids = $alumni->getGrouppermHandler()->getItemIds('alumni_view', $groups, $module_id);
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('cid', '(' . implode(', ', $alumni_ids) . ')', 'IN'));
     $criteria->setOrder($xoops->getModuleConfig('alumni_csortorder'));
     $category_arr = $categoriesHandler->getall($criteria);
     foreach (array_keys($category_arr) as $i) {
         $cid = $category_arr[$i]->getVar('cid');
         $pid = $category_arr[$i]->getVar('pid');
         $title = $category_arr[$i]->getVar('title');
     }
     $categories = $alumni->getCategoryHandler()->getCategoriesForSearch();
     $category_select = new XoopsFormSelect(AlumniLocale::L_ALUMNI_CATEGORIES, 'by_cat', $by_cat);
     foreach ($categories as $cid => $title) {
         $category_select->addOption('0', XoopsLocale::ALL);
         $category_select->addOptionArray(array($cid => $title));
     }
     $this->addElement($category_select);
     if (!empty($mids)) {
         $mods_checkbox = new XoopsFormCheckBox(XoopsLocale::SEARCH_IN, 'mids[]', $mids);
     } else {
         $mods_checkbox = new XoopsFormCheckBox(XoopsLocale::SEARCH_IN, 'mids[]', $mid);
     }
     if (empty($modules)) {
         $gperm_handler = $xoops->getHandlerGroupPermission();
         $available_modules = $gperm_handler->getItemIds('module_read', $xoops->getUserGroups());
         $available_plugins = Xoops\Module\Plugin::getPlugins('search');
         $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('dirname', '(\'' . implode('\',\'', array_keys($available_plugins)) . '\')', 'IN'));
         if (isset($available_modules) && !empty($available_modules)) {
             $criteria->add(new Criteria('mid', '(' . implode(',', $available_modules) . ')', 'IN'));
         }
         $module_handler = $xoops->getHandlerModule();
         $mods_checkbox->addOptionArray($module_handler->getNameList($criteria));
     } else {
         /* @var $module XoopsModule */
         $module_array = array();
         foreach ($modules as $mid => $module) {
             $module_array[$mid] = $module->getVar('name');
         }
         $mods_checkbox->addOptionArray($module_array);
     }
     $this->addElement($mods_checkbox);
     if ($search->getConfig('keyword_min') > 0) {
         $this->addElement(new XoopsFormLabel(XoopsLocale::SEARCH_RULE, sprintf(XoopsLocale::EF_KEYWORDS_MUST_BE_GREATER_THAN, $search->getConfig('keyword_min'))));
     }
     $this->addElement(new XoopsFormHidden('action', 'results'));
     $this->addElement(new XoopsFormHiddenToken('id'));
     $this->addElement(new XoopsFormButton('', 'submit', XoopsLocale::SEARCH, 'submit'));
     return $this;
 }
예제 #15
0
//                                                                           //
//  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_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
// create form
$search_form = new XoopsThemeForm(_SR_SEARCH, "search_form", $_SERVER['PHP_SELF'], 'POST');
// create form elements
$search_form->addElement(new XoopsFormText(_SR_KEYWORDS, "query", 30, 255, htmlspecialchars(stripslashes(implode(" ", $queries)), ENT_QUOTES)), true);
$search_form->addElement(new XoopsFormText(_AMS_NW_USERNAME, "username", 30, 255, $username), false);
$type_select = new XoopsFormSelect(_SR_TYPE, "andor", $andor);
$type_select->addOptionArray(array("AND" => _SR_ALL, "OR" => _SR_ANY, "exact" => _SR_EXACT));
$search_form->addElement($type_select);
if (!empty($mids)) {
    $mods_checkbox = new XoopsFormCheckBox(_SR_SEARCHIN, "mids[]", $mids);
} else {
    $mods_checkbox = new XoopsFormCheckBox(_SR_SEARCHIN, "mids[]", $xoopsModule->mid());
}
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('hassearch', 1));
$criteria->add(new Criteria('isactive', 1));
$module_handler =& xoops_gethandler('module');
$mods_checkbox->addOptionArray($module_handler->getList($criteria));
$search_form->addElement($mods_checkbox);
if ($xoopsConfigSearch['keyword_min'] > 0) {
    $search_form->addElement(new XoopsFormLabel(_SR_SEARCHRULE, sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min'])));
}
$search_form->addElement(new XoopsFormHidden("op", "results"));
$search_form->addElement(new XoopsFormHidden('storyid', $article->storyid()));
$search_form->addElement(new XoopsFormButton("", "submit", _SR_SEARCH, "submit"));
예제 #16
0
 /**
  * Returns a {@link XoopsFormElement} for editing the value of this field
  *
  * @param object $user {@link XoopsUser} object to edit the value of
  *
  * @return object
  **/
 function getEditElement(&$user)
 {
     $value = $user->getVar($this->getVar('field_name'), 'e');
     $caption = $this->getVar('field_title');
     $caption = defined($caption) ? constant($caption) : $caption;
     $name = $this->getVar('field_name', 'e');
     $options = $this->getVar('field_options');
     asort($options);
     foreach (array_keys($options) as $key) {
         $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
         $optkey = defined($key) ? constant($key) : $key;
         unset($options[$key]);
         $options[$optkey] = $optval;
     }
     include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
     switch ($this->getVar('field_type')) {
         default:
         case "autotext":
             //autotext is not for editing
             $element = new XoopsFormLabel($caption, $this->getOutputValue($user));
             break;
         case "textbox":
             $element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
             break;
         case "textarea":
             $element = new XoopsFormTextArea($caption, $name, $value, 10, 50);
             break;
         case "dhtml":
             $element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50);
             break;
         case "select":
             $element = new XoopsFormSelect($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case "select_multi":
             $element = new XoopsFormSelect($caption, $name, $value, 5, true);
             $element->addOptionArray($options);
             break;
         case "radio":
             $element = new XoopsFormRadio($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case "checkbox":
             $element = new XoopsFormCheckBox($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case "yesno":
             $element = new XoopsFormRadioYN($caption, $name, $value);
             break;
         case "group":
             $element = new XoopsFormSelectGroup($caption, $name, true, $value);
             break;
         case "group_multi":
             $element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
             break;
         case "language":
             $element = new XoopsFormSelectLang($caption, $name, $value);
             break;
         case "date":
             $element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
             break;
             //            case "longdate":
             //            $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
             //            break;
         //            case "longdate":
         //            $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
         //            break;
         case "datetime":
             $element = new XoopsFormDatetime($caption, $name, 15, $value);
             break;
         case "list":
             $element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
             break;
         case "timezone":
             $element = new XoopsFormSelectTimezone($caption, $name, $value);
             break;
         case 'theme':
             $element = new XoopsFormSelect($caption, $name, $value);
             $element->addOption("0", _SITEDEFAULT);
             $theme_list = XoopsLists::getThemesList();
             foreach ($theme_list as $key => $val) {
                 if (!in_array($key, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
                     continue;
                 }
                 $element->addOption($key, $val);
             }
             /*
             $handle = opendir(XOOPS_THEME_PATH.'/');
             $dirlist = array();
             while (false !== ($file = readdir($handle))) {
                 if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/",$file) && strtolower($file) != 'cvs') {
                     if (file_exists(XOOPS_THEME_PATH."/".$file."/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
                         $dirlist[$file]=$file;
                     }
                 }
             }
             closedir($handle);
             if (!empty($dirlist)) {
                 asort($dirlist);
                 $element->addOptionArray($dirlist);
             }
             */
             break;
     }
     if ($this->getVar('field_description') != "") {
         $element->setDescription($this->getVar('field_description'));
     }
     return $element;
 }
예제 #17
0
    $image_tray->addElement($image_select);
    if (!empty($cat_image) && file_exists(XOOPS_ROOT_PATH . "/" . $path_image . "/" . $cat_image)) {
        $image_tray->addElement(new XoopsFormLabel("", "<div style=\"padding: 8px;\"><img src=\"" . XOOPS_URL . "/" . $path_image . "/" . $cat_image . "\" name=\"img\" id=\"img\" alt=\"\" /></div>"));
    } else {
        $image_tray->addElement(new XoopsFormLabel("", "<div style=\"padding: 8px;\"><img src=\"" . XOOPS_URL . "/images/blank.gif\" name=\"img\" id=\"img\" alt=\"\" /></div>"));
    }
    $image_option_tray->addElement($image_tray);
    $form_art->addElement($image_option_tray);
}
// The moderator
if (art_isAdministrator()) {
    $form_art->addElement(new XoopsFormSelectUser(art_constant("MD_MODERATOR"), 'cat_moderator', false, $category_obj->getVar("cat_moderator"), 5, true));
} else {
    if ($moderators = $category_obj->getVar("cat_moderator")) {
        $moderator_checkbox = new XoopsFormCheckBox(art_constant("MD_MODERATOR"), "cat_moderator", array_keys($moderators));
        $moderator_checkbox->addOptionArray(art_getUnameFromId($moderators));
        $moderator_checkbox->setExtra("\"disabled\"");
        $form_art->addElement($moderator_checkbox);
    }
}
// Entry article
$limit_article = 100;
if ($category_obj->getVar("cat_id")) {
    $article_handler =& xoops_getmodulehandler("article", $GLOBALS["artdirname"]);
    $criteria_article = new Criteria("cat_id", $category_obj->getVar("cat_id"));
    $article_count = $article_handler->getCount($criteria_article);
    if ($article_count > 0) {
        $article_list[0] = _NONE;
        if ($article_count > $limit_article) {
            $article_list = $article_list + $article_handler->getList(new Criteria("art_id", $category_obj->getVar("cat_entry")));
            $article_option_tray = new XoopsFormElementTray(art_constant("MD_ENTRY_SELECT"));
예제 #18
0
/**
 * Get {@link XoopsThemeForm} for adding/editing fields
 *
 * @param object $field {@link XoopsProfileField} object to get edit form for
 * @param mixed $action URL to submit to - or false for $_SERVER['REQUEST_URI']
 *
 * @return object
 */
function getFieldForm(&$field, $action = false)
{
    if ($action === false) {
        $action = $_SERVER['REQUEST_URI'];
    }
    $title = $field->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_FIELD) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_FIELD);
    include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
    $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
    $form->addElement(new XoopsFormText(sprintf(_PROFILE_AM_TITLE, _PROFILE_AM_FIELD), 'field_title', 35, 255, $field->getVar('field_title', 'e')));
    $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DESCRIPTION, 'field_description', $field->getVar('field_description', 'e')));
    if (!$field->isNew()) {
        $fieldcat_handler =& xoops_getmodulehandler('fieldcategory');
        $fieldcat =& $fieldcat_handler->get($field->getVar('fieldid'));
        $fieldcatid = $fieldcat->getVar('catid');
    } else {
        $fieldcatid = 0;
    }
    $category_handler =& xoops_getmodulehandler('category');
    $cat_select = new XoopsFormSelect(_PROFILE_AM_CATEGORY, 'field_category', $fieldcatid);
    $cat_select->addOption(0, _PROFILE_AM_DEFAULT);
    $cat_select->addOptionArray($category_handler->getList());
    $form->addElement($cat_select);
    if ($field->getVar('field_config') || $field->isNew()) {
        if (!$field->isNew()) {
            $form->addElement(new XoopsFormLabel(sprintf(_PROFILE_AM_NAME, _PROFILE_AM_FIELD), $field->getVar('field_name')));
            $form->addElement(new XoopsFormHidden('id', $field->getVar('fieldid')));
        } else {
            $form->addElement(new XoopsFormText(sprintf(_PROFILE_AM_NAME, _PROFILE_AM_FIELD), 'field_name', 35, 255, $field->getVar('field_name', 'e')));
        }
        //autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think)
        $fieldtypes = array('checkbox' => _PROFILE_AM_CHECKBOX, 'date' => _PROFILE_AM_DATE, 'datetime' => _PROFILE_AM_DATETIME, 'group' => _PROFILE_AM_GROUP, 'group_multi' => _PROFILE_AM_GROUPMULTI, 'language' => _PROFILE_AM_LANGUAGE, 'radio' => _PROFILE_AM_RADIO, 'select' => _PROFILE_AM_SELECT, 'select_multi' => _PROFILE_AM_SELECTMULTI, 'textarea' => _PROFILE_AM_TEXTAREA, 'dhtml' => _PROFILE_AM_DHTMLTEXTAREA, 'textbox' => _PROFILE_AM_TEXTBOX, 'timezone' => _PROFILE_AM_TIMEZONE, 'yesno' => _PROFILE_AM_YESNO);
        $element_select = new XoopsFormSelect(_PROFILE_AM_TYPE, 'field_type', $field->getVar('field_type', 'e'));
        $element_select->addOptionArray($fieldtypes);
        //$form->addElement($type_select);
        $form->addElement($element_select);
        switch ($field->getVar('field_type')) {
            case "textbox":
                /*
                $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY,
                            XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL,
                            XOBJ_DTYPE_INT => _PROFILE_AM_INT,
                            XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA,
                            XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX,
                            XOBJ_DTYPE_URL => _PROFILE_AM_URL,
                            XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
                $type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
                $type_select->addOptionArray($valuetypes);
                $form->addElement($type_select);
                break;
                */
            /*
            $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY,
                        XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL,
                        XOBJ_DTYPE_INT => _PROFILE_AM_INT,
                        XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA,
                        XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX,
                        XOBJ_DTYPE_URL => _PROFILE_AM_URL,
                        XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
            $type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
            $type_select->addOptionArray($valuetypes);
            $form->addElement($type_select);
            break;
            */
            case "select":
            case "radio":
                $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
                $type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
                $type_select->addOptionArray($valuetypes);
                $form->addElement($type_select);
                break;
        }
        //$form->addElement(new XoopsFormRadioYN(_PROFILE_AM_NOTNULL, 'field_notnull', $field->getVar('field_notnull', 'e')));
        if ($field->getVar('field_type') == "select" || $field->getVar('field_type') == "select_multi" || $field->getVar('field_type') == "radio" || $field->getVar('field_type') == "checkbox") {
            if (count($field->getVar('field_options')) > 0) {
                $remove_options = new XoopsFormCheckBox(_PROFILE_AM_REMOVEOPTIONS, 'removeOptions');
                $options = $field->getVar('field_options');
                asort($options);
                $remove_options->addOptionArray($options);
                $form->addElement($remove_options);
            }
            $option_tray = new XoopsFormElementTray(_PROFILE_AM_ADDOPTION);
            $option_tray->addElement(new XoopsFormText(_PROFILE_AM_KEY, 'addOption[key]', 15, 35));
            $option_tray->addElement(new XoopsFormText(_PROFILE_AM_VALUE, 'addOption[value]', 35, 255));
            $form->addElement($option_tray);
        }
    }
    if ($field->getVar('field_edit')) {
        switch ($field->getVar('field_type')) {
            case "textbox":
                //proceed to next cases
            //proceed to next cases
            case "textarea":
            case "dhtml":
                $form->addElement(new XoopsFormText(_PROFILE_AM_MAXLENGTH, 'field_maxlength', 35, 35, $field->getVar('field_maxlength', 'e')));
                $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "checkbox":
            case "select_multi":
                $def_value = $field->getVar('field_default', 'e') != null ? unserialize($field->getVar('field_default', 'n')) : null;
                $element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $def_value, 8, true);
                $options = $field->getVar('field_options');
                asort($options);
                $element->addOptionArray($options);
                $form->addElement($element);
                break;
            case "select":
            case "radio":
                $def_value = $field->getVar('field_default', 'e') != null ? $field->getVar('field_default') : null;
                $element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $def_value);
                $options = $field->getVar('field_options');
                asort($options);
                $element->addOptionArray($options);
                $form->addElement($element);
                break;
            case "date":
                $form->addElement(new XoopsFormTextDateSelect(_PROFILE_AM_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
                break;
            case "datetime":
                $form->addElement(new XoopsFormDateTime(_PROFILE_AM_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
                break;
            case "yesno":
                $form->addElement(new XoopsFormRadioYN(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "timezone":
                $form->addElement(new XoopsFormSelectTimezone(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "language":
                $form->addElement(new XoopsFormSelectLang(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "group":
                $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e')));
                break;
            case "group_multi":
                $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e'), 5, true));
                break;
            case "theme":
                $element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e'));
                $element->addOption("0", _SITEDEFAULT);
                $theme_list = XoopsLists::getThemesList();
                foreach ($theme_list as $key => $val) {
                    if (!in_array($key, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
                        continue;
                    }
                    $element->addOption($key, $val);
                }
                $form->addElement($element);
                //$form->addElement(new XoopsFormSelectTheme(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "autotext":
                $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
        }
    }
    $groupperm_handler =& xoops_gethandler('groupperm');
    $searchable_types = array('textbox', 'select', 'radio', 'yesno', 'date', 'datetime', 'timezone', 'language');
    if (in_array($field->getVar('field_type'), $searchable_types)) {
        $search_groups = $groupperm_handler->getGroupIds('profile_search', $field->getVar('fieldid'), $GLOBALS['xoopsModule']->getVar('mid'));
        $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_SEARCH, 'profile_search', true, $search_groups, 5, true));
    }
    if ($field->getVar('field_show') || $field->getVar('field_edit')) {
        //$form->addElement(new XoopsFormText(_PROFILE_AM_FIELD." "._PROFILE_AM_WEIGHT, 'field_weight', 35, 35, $field->getVar('field_weight', 'e')));
        if (!$field->isNew()) {
            //Load groups
            $show_groups = $groupperm_handler->getGroupIds('profile_show', $field->getVar('fieldid'), $GLOBALS['xoopsModule']->getVar('mid'));
            $editable_groups = $groupperm_handler->getGroupIds('profile_edit', $field->getVar('fieldid'), $GLOBALS['xoopsModule']->getVar('mid'));
            $visible_groups = $groupperm_handler->getGroupIds('profile_visible', $field->getVar('fieldid'), $GLOBALS['xoopsModule']->getVar('mid'));
        } else {
            $visible_groups = array();
            $show_groups = array();
            $editable_groups = array();
        }
        if ($field->getVar('field_show')) {
            //            Leave out categories for now
            //            $cat_select = new XoopsFormSelect(_PROFILE_AM_CATEGORY, 'catid', $field->getVar('catid'));
            //            $category_handler =& xoops_getmodulehandler('category');
            //            $categories =& $category_handler->getObjects(null, true);
            //            foreach (array_keys($categories) as $i) {
            //                $cat_select->addOption($i, $categories[$i]->getVar('cat_title'));
            //            }
            //            $form->addElement($cat_select);
            $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_VISIBLE_ON, 'profile_show', false, $show_groups, 5, true));
            $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_VISIBLE_FOR, 'profile_visible', true, $visible_groups, 5, true));
        }
        if ($field->getVar('field_edit')) {
            $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_EDITABLE, 'profile_edit', false, $editable_groups, 5, true));
            $form->addElement(new XoopsFormRadioYN(_PROFILE_AM_REQUIRED, 'field_required', $field->getVar('field_required', 'e')));
            $form->addElement(new XoopsFormRadioYN(_PROFILE_AM_PROF_REGISTER, 'field_register', $field->getVar('field_register', 'e')));
        }
    }
    $form->addElement(new XoopsFormHidden('op', 'save'));
    $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
    return $form;
}