Beispiel #1
0
        $newsauthor = $xoopsUser->getVar('uid');
    }
    $member_handler =& xoops_gethandler('member');
    $usercount = $member_handler->getUserCount();
    if ($usercount < $cfg['config_max_users_list']) {
        $sform->addElement(new XoopsFormSelectUser(_NW_AUTHOR, 'author', true, $newsauthor), false);
    } else {
        $sform->addElement(new XoopsFormText(_NW_AUTHOR_ID, 'author', 10, 10, $newsauthor), false);
    }
}
$editor = news_getWysiwygForm(_NW_THESCOOP, 'hometext', $hometext, 15, 60, 'hometext_hidden');
$sform->addElement($editor, true);
//Extra info
//If admin -> if submit privilege
if ($approveprivilege) {
    $editor2 = news_getWysiwygForm(_AM_EXTEXT, 'bodytext', $bodytext, 15, 60, 'bodytext_hidden');
    $sform->addElement($editor2, false);
    if (news_getmoduleoption('tags')) {
        $itemIdForTag = isset($storyid) ? $storyid : 0;
        require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php';
        $sform->addElement(new XoopsFormTag('item_tag', 60, 255, $itemIdForTag, 0));
    }
    if (news_getmoduleoption('metadata')) {
        $sform->addElement(new xoopsFormText(_NW_META_DESCRIPTION, 'description', 50, 255, $description), false);
        $sform->addElement(new xoopsFormText(_NW_META_KEYWORDS, 'keywords', 50, 255, $keywords), false);
    }
}
// Manage upload(s)
$allowupload = false;
switch ($xoopsModuleConfig['uploadgroups']) {
    case 1:
Beispiel #2
0
function topicsmanager()
{
    global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $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 >= $xoopsModuleConfig['storycountadmin']) {
                $ok = false;
            }
            $tmpcpt++;
            $cpt++;
        }
        echo $output;
    }
    $pagenav = new XoopsPageNav($totaltopics, $xoopsModuleConfig['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', $xoopsModuleConfig['maxuploadsize']), false);
    $fileseltray->addElement(new XoopsFormLabel($uploadfolder), false);
    $imgtray->addElement($fileseltray);
    $sform->addElement($imgtray);
    // 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";
}