Exemplo n.º 1
0
 function form_edit($bid, $mode = 'edit')
 {
     $bid = intval($bid);
     //HACK by domifara
     $block = new XoopsBlock($bid);
     if (!$block->getVar('bid')) {
         // new defaults
         $bid = 0;
         $mode = 'new';
         $block->setVar('mid', 0);
         $block->setVar('block_type', 'C');
     }
     switch ($mode) {
         case 'clone':
             $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM;
             $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE;
             $next_op = 'clone_ok';
             // breadcrumbs
             $breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
             $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM);
             break;
         case 'new':
             $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM;
             $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW;
             $next_op = 'new_ok';
             // breadcrumbs
             $breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
             $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM);
             break;
         case 'edit':
         default:
             $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM;
             $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT;
             $next_op = 'edit_ok';
             // breadcrumbs
             $breadcrumbsObj =& AltsysBreadcrumbs::getInstance();
             $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM);
             break;
     }
     $is_custom = in_array($block->getVar('block_type'), array('C', 'E')) ? true : false;
     $block_template = $block->getVar('template', 'n');
     $block_template_tplset = '';
     if (!$is_custom && $block_template) {
         // find template of the block
         $tplfile_handler =& xoops_gethandler('tplfile');
         $found_templates = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', null, null, $block_template);
         $block_template_tplset = count($found_templates) > 0 ? $GLOBALS['xoopsConfig']['template_set'] : 'default';
     }
     //HACK by domifara
     /*
     	if ( !($block->getVar('c_type')) ){
     		$block->setVar('c_type','S');
     	}
     */
     $block_data = $this->preview_request + array('bid' => $bid, 'name' => $block->getVar('name', 'n'), 'title' => $block->getVar('title', 'n'), 'weight' => intval($block->getVar('weight')), 'bcachetime' => intval($block->getVar('bcachetime')), 'side' => intval($block->getVar('side')), 'visible' => intval($block->getVar('visible')), 'template' => $block_template, 'template_tplset' => $block_template_tplset, 'options' => $block->getVar('options'), 'content' => $block->getVar('content', 'n'), 'is_custom' => $is_custom, 'type' => $block->getVar('block_type'), 'ctype' => $block->getVar('c_type'));
     $block4assign = array('name_raw' => $block_data['name'], 'title_raw' => $block_data['title'], 'content_raw' => $block_data['content'], 'cell_position' => $this->renderCell4BlockPosition($block_data), 'cell_module_link' => $this->renderCell4BlockModuleLink($block_data), 'cell_group_perm' => $this->renderCell4BlockReadGroupPerm($block_data), 'cell_options' => $this->renderCell4BlockOptions($block_data), 'content_preview' => $this->previewContent($block_data)) + $block_data;
     // display
     require_once XOOPS_TRUST_PATH . '/libs/altsys/class/D3Tpl.class.php';
     $tpl = new D3Tpl();
     //dhtml
     include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
     if ($block_data['ctype'] == 'H' || empty($block_data['ctype'])) {
         $editor_configs = array();
         $editor_configs["name"] = "content_block";
         $editor_configs["value"] = $block_data['content'];
         $editor_configs["rows"] = 20;
         $editor_configs["cols"] = 100;
         $editor_configs["width"] = "100%";
         $editor_configs["height"] = "400px";
         $editor_configs["editor"] = xoops_getModuleOption('blocks_editor', 'system');
         $form = new XoopsFormEditor('', "textarea_content", $editor_configs);
         $rendered = $form->render();
         $tpl->assign('altsys_x25_dhtmltextarea', $rendered);
     } else {
         $form = new XoopsFormDhtmlTextArea('', 'textarea_content', $block_data['content'], 80, 20);
         $rendered = $form->render();
         $rendered = '<div id="textarea_content_bbcode_buttons_pre" style="display:block;">' . str_replace(array('<textarea', '</textarea><br />'), array('</div><textarea', '</textarea><div id="textarea_content_bbcode_buttons_post" style="display:block;">'), $rendered) . '</div>';
         $tpl->assign('altsys_x25_dhtmltextarea', $rendered);
     }
     $tpl->assign(array('target_dirname' => $this->target_dirname, 'target_mname' => $this->target_mname, 'language' => $this->lang, 'cachetime_options' => $this->cachetime_options, 'ctype_options' => $this->ctype_options, 'block' => $block4assign, 'op' => $next_op, 'form_title' => $form_title, 'submit_button' => $button_value, 'common_fck_installed' => file_exists(XOOPS_ROOT_PATH . '/common/fckeditor/fckeditor.js'), 'gticket_hidden' => $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__, 1800, 'myblocksadmin')));
     //HACK by domifara
     $tpl->display('db:altsys_main_myblocksadmin_edit_4x25.html');
     return;
 }
Exemplo n.º 2
0
function formVideo($video_id)
{
    $module_handler =& xoops_gethandler('module');
    $xoModule = $module_handler->getByDirname('vidshop');
    $config_handler =& xoops_gethandler('config');
    $xoConfigs = $config_handler->getConfigList($xoModule->getVar('mid'));
    $cform = new XoopsThemeForm(_VSP_FRM_VIDSHOP_FORM, 'vidshop');
    $cform->setExtra('enctype="multipart/form-data"');
    $videoHandler =& xoops_getmodulehandler('video', 'vidshop');
    if (intval($_REQUEST['id']) != 0) {
        $video =& $videoHandler->get(intval($_REQUEST['id']));
    } else {
        $video =& $videoHandler->create();
    }
    $description_editor = !isset($_REQUEST['description_editor']) ? 'xinha' : $_REQUEST['description_editor'];
    $cat = new VidshopFormSelectCategory(_VSP_FRM_CATEGORY, 'cid', $video->getVar('cid'));
    $cat->setDescription(_VSP_FRM_CATEGORY_DESC);
    $cform->addElement($cat);
    $cform->addElement(new XoopsFormText(_VSP_FRM_VIDSHOP_NAME, 'name', 70, 128, !isset($_REQUEST['name']) ? $video->getVar('name') : $_REQUEST['name']));
    if (strlen($video->getVar('image'))) {
        $cform->addElement(new XoopsFormLabel(_VSP_FRM_VIDSHOP_CURRENT_IMAGE, "<img src='" . XOOPS_URL . "/uploads/" . $video->getVar('image') . "' width='160px'>"), false);
    }
    $cform->addElement(new XoopsFormFile(_VSP_FRM_VIDSHOP_IMAGE, 'image', 1024 * 1024 * 3), false);
    $cform->addElement(new XoopsFormSelectEditor($cform, 'description_editor', $description_editor));
    $description_config['name'] = 'description';
    $description_config['editor'] = $description_editor;
    $description_config['value'] = !isset($_REQUEST['description']) ? $video->getVar('description') : $_REQUEST['description'];
    $description_config['width'] = 379;
    $description_config['height'] = 479;
    $ele_description = new XoopsFormEditor(_VSP_FRM_VIDSHOP_DESCRIPTION, 'description', $description_config);
    $ele_description->setDescription(_VSP_FRM_VIDSHOP_DESCRIPTION_DESC);
    $cform->addElement($ele_description);
    $value = (string) $video->getVar('download');
    $file = new VidshopFormSelectFiles(_VSP_FRM_DOWNLOAD, 'file', $value, 1, false);
    $file->setValue($value);
    $file->setDescription(_VSP_FRM_DOWNLOAD_DESC);
    $cform->addElement($file);
    $cform->addElement(new XoopsFormText(_VSP_FRM_VIDSHOP_PRICE, 'price', 13, 10, !isset($_REQUEST['price']) ? $video->getVar('price') : $_REQUEST['price']));
    $cform->addElement(new XoopsFormTextArea(_VSP_FRM_VIDSHOP_EMBEDDED, 'embedded', !isset($_REQUEST['embedded']) ? $video->getVar('embedded') : $_REQUEST['embedded'], 5, 70));
    if (class_exists('XoopsFormTag')) {
        $cform->addElement(new XoopsFormTag('video_tags', 70, 255, $_REQUEST['id']));
    }
    $cform->addElement(new XoopsFormHidden('description_editor_current', $description_editor));
    $cform->addElement(new XoopsFormHidden('id', $_REQUEST['id']));
    $cform->addElement(new XoopsFormHidden('op', $_REQUEST['op']));
    $cform->addElement(new XoopsFormHidden('fct', 'save'));
    $cform->addElement(new XoopsFormButton('', 'contents_submit', _SUBMIT, "submit"));
    return $cform->render();
}
Exemplo n.º 3
0
/**
 * Obtenemos el editor correcto
 */
function rmmf_select_editor($name, $type = 'dhtml', $value = '', $width = '100%', $height = '400px', $addon = '')
{
    $editor = false;
    $caption = '';
    $x22 = false;
    $xv = str_replace('XOOPS ', '', XOOPS_VERSION);
    if (substr($xv, 2, 1) == '2') {
        $x22 = true;
    }
    $editor_configs = array();
    $editor_configs["name"] = $name;
    $editor_configs["value"] = $value;
    $editor_configs["rows"] = 15;
    $editor_configs["cols"] = 50;
    $editor_configs["width"] = $width;
    $editor_configs["height"] = $height;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    switch (strtolower($type)) {
        case "spaw":
            if (!$x22) {
                if (is_readable(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php")) {
                    include_once XOOPS_ROOT_PATH . "/class/spaw/formspaw.php";
                    $editor = new XoopsFormSpaw($caption, $name, $value);
                }
            } else {
                $editor = new XoopsFormEditor($caption, "spaw", $editor_configs);
            }
            break;
        case "fck":
            if (!$x22) {
                if (is_readable(XOOPS_ROOT_PATH . "/class/fckeditor/formfckeditor.php")) {
                    include_once XOOPS_ROOT_PATH . "/class/fckeditor/formfckeditor.php";
                    $editor = new XoopsFormFckeditor($caption, $name, $value);
                }
            } else {
                $editor = new XoopsFormEditor($caption, "fckeditor", $editor_configs);
            }
            break;
        case "htmlarea":
            if (!$x22) {
                if (is_readable(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php")) {
                    include_once XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php";
                    $editor = new XoopsFormHtmlarea($caption, $name, $value);
                }
            } else {
                $editor = new XoopsFormEditor($caption, "htmlarea", $editor_configs);
            }
            break;
        case "dhtml":
            if (!$x22) {
                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental);
            } else {
                $editor = new XoopsFormEditor($caption, "dhtmltextarea", $editor_configs);
            }
            break;
        case "textarea":
            $editor = new XoopsFormTextArea($caption, $name, $value);
            break;
        case "koivi":
            if (!$x22) {
                if (is_readable(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php")) {
                    include_once XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php";
                    $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px', '');
                }
            } else {
                $editor = new XoopsFormEditor($caption, "koivi", $editor_configs);
            }
            break;
    }
    return $editor->render();
}
Exemplo n.º 4
0
    /**
     * @param $obj
     *
     * @return $this
     */
    public function createElements($obj)
    {
        $publisher =& PublisherPublisher::getInstance();
        $allowedEditors = publisherGetEditors($publisher->getHandler('permission')->getGrantedItems('editors'));
        if (!is_object($GLOBALS['xoopsUser'])) {
            $group = array(XOOPS_GROUP_ANONYMOUS);
        } else {
            $group = $GLOBALS['xoopsUser']->getGroups();
        }
        $this->setExtra('enctype="multipart/form-data"');
        $this->startTab(_CO_PUBLISHER_TAB_MAIN);
        // Category
        $categoryFormSelect = new XoopsFormSelect(_CO_PUBLISHER_CATEGORY, 'categoryid', $obj->getVar('categoryid', 'e'));
        $categoryFormSelect->setDescription(_CO_PUBLISHER_CATEGORY_DSC);
        $categoryFormSelect->addOptionArray($publisher->getHandler('category')->getCategoriesForSubmit());
        $this->addElement($categoryFormSelect);
        // ITEM TITLE
        $this->addElement(new XoopsFormText(_CO_PUBLISHER_TITLE, 'title', 50, 255, $obj->getVar('title', 'e')), true);
        // SUBTITLE
        if ($this->isGranted(PublisherConstants::PUBLISHER_SUBTITLE)) {
            $this->addElement(new XoopsFormText(_CO_PUBLISHER_SUBTITLE, 'subtitle', 50, 255, $obj->getVar('subtitle', 'e')));
        }
        // SHORT URL
        if ($this->isGranted(PublisherConstants::PUBLISHER_ITEM_SHORT_URL)) {
            $textShortUrl = new XoopsFormText(_CO_PUBLISHER_ITEM_SHORT_URL, 'item_short_url', 50, 255, $obj->short_url('e'));
            $textShortUrl->setDescription(_CO_PUBLISHER_ITEM_SHORT_URL_DSC);
            $this->addElement($textShortUrl);
        }
        // TAGS
        if (xoops_isActiveModule('tag') && $this->isGranted(PublisherConstants::PUBLISHER_ITEM_TAG)) {
            include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php');
            $textTags = new XoopsFormTag('item_tag', 60, 255, $obj->getVar('item_tag', 'e'), 0);
            $this->addElement($textTags);
        }
        // SELECT EDITOR
        $nohtml = !$obj->dohtml();
        if (count($allowedEditors) === 1) {
            $editor = $allowedEditors[0];
        } elseif (count($allowedEditors) > 0) {
            $editor = XoopsRequest::getString('editor', '', 'POST');
            if (!empty($editor)) {
                publisherSetCookieVar('publisher_editor', $editor);
            } else {
                $editor = publisherGetCookieVar('publisher_editor');
                if (empty($editor) && is_object($GLOBALS['xoopsUser'])) {
                    //                    $editor = @ $GLOBALS['xoopsUser']->getVar('publisher_editor'); // Need set through user profile
                    $editor = null !== $GLOBALS['xoopsUser']->getVar('publisher_editor') ? $GLOBALS['xoopsUser']->getVar('publisher_editor') : '';
                    // Need set through user profile
                }
            }
            $editor = empty($editor) || !in_array($editor, $allowedEditors) ? $publisher->getConfig('submit_editor') : $editor;
            $formEditor = new XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowedEditors);
            $this->addElement($formEditor);
        } else {
            $editor = $publisher->getConfig('submit_editor');
        }
        $editorConfigs = array();
        $editorConfigs['rows'] = !$publisher->getConfig('submit_editor_rows') ? 35 : $publisher->getConfig('submit_editor_rows');
        $editorConfigs['cols'] = !$publisher->getConfig('submit_editor_cols') ? 60 : $publisher->getConfig('submit_editor_cols');
        $editorConfigs['width'] = !$publisher->getConfig('submit_editor_width') ? '100%' : $publisher->getConfig('submit_editor_width');
        $editorConfigs['height'] = !$publisher->getConfig('submit_editor_height') ? '400px' : $publisher->getConfig('submit_editor_height');
        // SUMMARY
        if ($this->isGranted(PublisherConstants::PUBLISHER_SUMMARY)) {
            // Description
            //$summaryText = new XoopsFormTextArea(_CO_PUBLISHER_SUMMARY, 'summary', $obj->getVar('summary', 'e'), 7, 60);
            $editorConfigs['name'] = 'summary';
            $editorConfigs['value'] = $obj->getVar('summary', 'e');
            $summaryText = new XoopsFormEditor(_CO_PUBLISHER_SUMMARY, $editor, $editorConfigs, $nohtml, $onfailure = null);
            $summaryText->setDescription(_CO_PUBLISHER_SUMMARY_DSC);
            $this->addElement($summaryText);
        }
        // BODY
        $editorConfigs['name'] = 'body';
        $editorConfigs['value'] = $obj->getVar('body', 'e');
        $bodyText = new XoopsFormEditor(_CO_PUBLISHER_BODY, $editor, $editorConfigs, $nohtml, $onfailure = null);
        $bodyText->setDescription(_CO_PUBLISHER_BODY_DSC);
        $this->addElement($bodyText);
        // VARIOUS OPTIONS
        if ($this->isGranted(PublisherConstants::PUBLISHER_DOHTML) || $this->isGranted(PublisherConstants::PUBLISHER_DOSMILEY) || $this->isGranted(PublisherConstants::PUBLISHER_DOXCODE) || $this->isGranted(PublisherConstants::PUBLISHER_DOIMAGE) || $this->isGranted(PublisherConstants::PUBLISHER_DOLINEBREAK)) {
            if ($this->isGranted(PublisherConstants::PUBLISHER_DOHTML)) {
                $html_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOHTML, 'dohtml', $obj->dohtml(), _YES, _NO);
                $this->addElement($html_radio);
            }
            if ($this->isGranted(PublisherConstants::PUBLISHER_DOSMILEY)) {
                $smiley_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOSMILEY, 'dosmiley', $obj->dosmiley(), _YES, _NO);
                $this->addElement($smiley_radio);
            }
            if ($this->isGranted(PublisherConstants::PUBLISHER_DOXCODE)) {
                $xcode_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOXCODE, 'doxcode', $obj->doxcode(), _YES, _NO);
                $this->addElement($xcode_radio);
            }
            if ($this->isGranted(PublisherConstants::PUBLISHER_DOIMAGE)) {
                $image_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOIMAGE, 'doimage', $obj->doimage(), _YES, _NO);
                $this->addElement($image_radio);
            }
            if ($this->isGranted(PublisherConstants::PUBLISHER_DOLINEBREAK)) {
                $linebreak_radio = new XoopsFormRadioYN(_CO_PUBLISHER_DOLINEBREAK, 'dolinebreak', $obj->dobr(), _YES, _NO);
                $this->addElement($linebreak_radio);
            }
        }
        // Available pages to wrap
        if ($this->isGranted(PublisherConstants::PUBLISHER_AVAILABLE_PAGE_WRAP)) {
            $wrapPages = XoopsLists::getHtmlListAsArray(publisherGetUploadDir(true, 'content'));
            $availableWrapPagesText = array();
            foreach ($wrapPages as $page) {
                $availableWrapPagesText[] = "<span onclick='publisherPageWrap(\"body\", \"[pagewrap={$page}] \");' onmouseover='style.cursor=\"pointer\"'>{$page}</span>";
            }
            $availableWrapPages = new XoopsFormLabel(_CO_PUBLISHER_AVAILABLE_PAGE_WRAP, implode(', ', $availableWrapPagesText));
            $availableWrapPages->setDescription(_CO_PUBLISHER_AVAILABLE_PAGE_WRAP_DSC);
            $this->addElement($availableWrapPages);
        }
        // Uid
        /*  We need to retreive the users manually because for some reason, on the frxoops.org server,
            the method users::getobjects encounters a memory error
            */
        // Trabis : well, maybe is because you are getting 6000 objects into memory , no??? LOL
        if ($this->isGranted(PublisherConstants::PUBLISHER_UID)) {
            $uidSelect = new XoopsFormSelect(_CO_PUBLISHER_UID, 'uid', $obj->uid(), 1, false);
            $uidSelect->setDescription(_CO_PUBLISHER_UID_DSC);
            $sql = 'SELECT uid, uname FROM ' . $obj->db->prefix('users') . ' ORDER BY uname ASC';
            $result = $obj->db->query($sql);
            $usersArray = array();
            $usersArray[0] = $GLOBALS['xoopsConfig']['anonymous'];
            while (($myrow = $obj->db->fetchArray($result)) !== false) {
                $usersArray[$myrow['uid']] = $myrow['uname'];
            }
            $uidSelect->addOptionArray($usersArray);
            $this->addElement($uidSelect);
        }
        /* else {
           $hidden = new XoopsFormHidden('uid', $obj->uid());
           $this->addElement($hidden);
           unset($hidden);
           }*/
        // Author ALias
        if ($this->isGranted(PublisherConstants::PUBLISHER_AUTHOR_ALIAS)) {
            $element = new XoopsFormText(_CO_PUBLISHER_AUTHOR_ALIAS, 'author_alias', 50, 255, $obj->getVar('author_alias', 'e'));
            $element->setDescription(_CO_PUBLISHER_AUTHOR_ALIAS_DSC);
            $this->addElement($element);
            unset($element);
        }
        // STATUS
        if ($this->isGranted(PublisherConstants::PUBLISHER_STATUS)) {
            $options = array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED => _CO_PUBLISHER_PUBLISHED, PublisherConstants::PUBLISHER_STATUS_OFFLINE => _CO_PUBLISHER_OFFLINE, PublisherConstants::PUBLISHER_STATUS_SUBMITTED => _CO_PUBLISHER_SUBMITTED, PublisherConstants::PUBLISHER_STATUS_REJECTED => _CO_PUBLISHER_REJECTED);
            $statusSelect = new XoopsFormSelect(_CO_PUBLISHER_STATUS, 'status', $obj->getVar('status'));
            $statusSelect->addOptionArray($options);
            $statusSelect->setDescription(_CO_PUBLISHER_STATUS_DSC);
            $this->addElement($statusSelect);
            unset($statusSelect);
        }
        // Datesub
        if ($this->isGranted(PublisherConstants::PUBLISHER_DATESUB)) {
            if ($obj->isNew()) {
                $datesub = time();
            } else {
                $datesub = $obj->getVar('datesub') == 0 ? time() : $obj->getVar('datesub');
            }
            $datesub_datetime = new PublisherFormDateTime(_CO_PUBLISHER_DATESUB, 'datesub', $size = 15, $datesub, true, true);
            // $datesub_datetime = new XoopsFormDateTime(_CO_PUBLISHER_DATESUB, 'datesub', $size = 15, $datesub, true, true);
            $datesub_datetime->setDescription(_CO_PUBLISHER_DATESUB_DSC);
            $this->addElement($datesub_datetime);
        }
        // NOTIFY ON PUBLISH
        if ($this->isGranted(PublisherConstants::PUBLISHER_NOTIFY)) {
            $notify_radio = new XoopsFormRadioYN(_CO_PUBLISHER_NOTIFY, 'notify', $obj->notifypub(), _YES, _NO);
            $this->addElement($notify_radio);
        }
        if ($this->hasTab(_CO_PUBLISHER_TAB_IMAGES)) {
            $this->startTab(_CO_PUBLISHER_TAB_IMAGES);
        }
        // IMAGE
        if ($this->isGranted(PublisherConstants::PUBLISHER_IMAGE_ITEM)) {
            $objimages = $obj->getImages();
            $mainarray = is_object($objimages['main']) ? array($objimages['main']) : array();
            $mergedimages = array_merge($mainarray, $objimages['others']);
            $objimage_array = array();
            foreach ($mergedimages as $imageObj) {
                $objimage_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename');
            }
            $imgcatHandler =& xoops_getHandler('imagecategory');
            if (method_exists($imgcatHandler, 'getListByPermission')) {
                $catlist = $imgcatHandler->getListByPermission($group, 'imgcat_read', 1);
            } else {
                $catlist = $imgcatHandler->getList($group, 'imgcat_read', 1);
            }
            $catids = array_keys($catlist);
            $imageObjs = array();
            if (!empty($catids)) {
                $imageHandler =& xoops_getHandler('image');
                $criteria = new CriteriaCompo(new Criteria('imgcat_id', '(' . implode(',', $catids) . ')', 'IN'));
                $criteria->add(new Criteria('image_display', 1));
                $criteria->setSort('image_nicename');
                $criteria->setOrder('ASC');
                $imageObjs = $imageHandler->getObjects($criteria, true);
                unset($criteria);
            }
            $image_array = array();
            foreach ($imageObjs as $imageObj) {
                $image_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename');
            }
            $image_array = array_diff($image_array, $objimage_array);
            $imageSelect = new XoopsFormSelect('', 'image_notused', '', 5);
            $imageSelect->addOptionArray($image_array);
            $imageSelect->setExtra("onchange='showImgSelected(\"image_display\", \"image_notused\", \"uploads/\", \"\", \"" . XOOPS_URL . "\")'");
            //$imageSelect->setExtra( "onchange='appendMySelectOption(\"image_notused\", \"image_item\")'");
            unset($image_array);
            $imageSelect2 = new XoopsFormSelect('', 'image_item', '', 5, true);
            $imageSelect2->addOptionArray($objimage_array);
            $imageSelect2->setExtra("onchange='publisher_updateSelectOption(\"image_item\", \"image_featured\"), showImgSelected(\"image_display\", \"image_item\", \"uploads/\", \"\", \"" . XOOPS_URL . "\")'");
            $buttonadd = new XoopsFormButton('', 'buttonadd', _CO_PUBLISHER_ADD);
            $buttonadd->setExtra("onclick='publisher_appendSelectOption(\"image_notused\", \"image_item\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'");
            $buttonremove = new XoopsFormButton('', 'buttonremove', _CO_PUBLISHER_REMOVE);
            $buttonremove->setExtra("onclick='publisher_appendSelectOption(\"image_item\", \"image_notused\"), publisher_updateSelectOption(\"image_item\", \"image_featured\")'");
            $opentable = new XoopsFormLabel('', '<table><tr><td>');
            $addcol = new XoopsFormLabel('', '</td><td>');
            $addbreak = new XoopsFormLabel('', '<br />');
            $closetable = new XoopsFormLabel('', '</td></tr></table>');
            $GLOBALS['xoTheme']->addScript(PUBLISHER_URL . '/assets/js/ajaxupload.3.9.js');
            $js_data = new XoopsFormLabel('', '
<script type= "text/javascript">/*<![CDATA[*/
$publisher(document).ready(function () {
    var button = $publisher("#publisher_upload_button"), interval;
    new AjaxUpload(button,{
        action: "' . PUBLISHER_URL . '/include/ajax_upload.php", // I disabled uploads in this example for security reasons
        responseType: "text/html",
        name: "publisher_upload_file",
        onSubmit : function (file, ext) {
            // change button text, when user selects file
            $publisher("#publisher_upload_message").html(" ");
            button.html("<img src=\'' . PUBLISHER_URL . '/assets/images/loadingbar.gif\'/>"); this.setData({
                "image_nicename": $publisher("#image_nicename").val(),
                "imgcat_id" : $publisher("#imgcat_id").val()
            });
            // If you want to allow uploading only 1 file at time,
            // you can disable upload button
            this.disable();
            interval = window.setInterval(function () {
            }, 200);
        },
        onComplete: function (file, response) {
            button.text("' . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . '");
            window.clearInterval(interval);
            // enable upload button
            this.enable();
            // add file to the list
            var result = eval(response);
            if ("success" == result[0]) {
                 $publisher("#image_item").append("<option value=\'" + result[1] + "\' selected=\'selected\'>" + result[2] + "</option>");
                 publisher_updateSelectOption(\'image_item\', \'image_featured\');
                 showImgSelected(\'image_display\', \'image_item\', \'uploads/\', \'\', \'' . XOOPS_URL . '\')
            } else {
                 $publisher("#publisher_upload_message").html("<div class=\'errorMsg\'>" + result[1] + "</div>");
            }
        }
    });
});
/*]]>*/</script>
');
            $messages = new XoopsFormLabel('', "<div id='publisher_upload_message'></div>");
            $button = new XoopsFormLabel('', "<div id='publisher_upload_button'>" . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . '</div>');
            $nicename = new XoopsFormText('', 'image_nicename', 30, 30, _CO_PUBLISHER_IMAGE_NICENAME);
            $imgcatHandler =& xoops_getHandler('imagecategory');
            if (method_exists($imgcatHandler, 'getListByPermission')) {
                $catlist = $imgcatHandler->getListByPermission($group, 'imgcat_read', 1);
            } else {
                $catlist = $imgcatHandler->getList($group, 'imgcat_read', 1);
            }
            $imagecat = new XoopsFormSelect('', 'imgcat_id', '', 1);
            $imagecat->addOptionArray($catlist);
            $imageUploadTray = new XoopsFormElementTray(_CO_PUBLISHER_IMAGE_UPLOAD, '');
            $imageUploadTray->addElement($js_data);
            $imageUploadTray->addElement($messages);
            $imageUploadTray->addElement($opentable);
            $imageUploadTray->addElement($imagecat);
            $imageUploadTray->addElement($addbreak);
            $imageUploadTray->addElement($nicename);
            $imageUploadTray->addElement($addbreak);
            $imageUploadTray->addElement($button);
            $imageUploadTray->addElement($closetable);
            $this->addElement($imageUploadTray);
            $imageTray = new XoopsFormElementTray(_CO_PUBLISHER_IMAGE_ITEMS, '');
            $imageTray->addElement($opentable);
            $imageTray->addElement($imageSelect);
            $imageTray->addElement($addbreak);
            $imageTray->addElement($buttonadd);
            $imageTray->addElement($addcol);
            $imageTray->addElement($imageSelect2);
            $imageTray->addElement($addbreak);
            $imageTray->addElement($buttonremove);
            $imageTray->addElement($closetable);
            $imageTray->setDescription(_CO_PUBLISHER_IMAGE_ITEMS_DSC);
            $this->addElement($imageTray);
            $imagename = is_object($objimages['main']) ? $objimages['main']->getVar('image_name') : '';
            $imageforpath = $imagename != '' ? $imagename : 'blank.gif';
            $imageSelect3 = new XoopsFormSelect(_CO_PUBLISHER_IMAGE_ITEM, 'image_featured', $imagename, 1);
            $imageSelect3->addOptionArray($objimage_array);
            $imageSelect3->setExtra("onchange='showImgSelected(\"image_display\", \"image_featured\", \"uploads/\", \"\", \"" . XOOPS_URL . "\")'");
            $imageSelect3->setDescription(_CO_PUBLISHER_IMAGE_ITEM_DSC);
            $this->addElement($imageSelect3);
            $image_preview = new XoopsFormLabel(_CO_PUBLISHER_IMAGE_PREVIEW, "<img src='" . XOOPS_URL . '/uploads/' . $imageforpath . "' name='image_display' id='image_display' alt='' />");
            $this->addElement($image_preview);
        }
        if ($this->hasTab(_CO_PUBLISHER_TAB_FILES)) {
            $this->startTab(_CO_PUBLISHER_TAB_FILES);
        }
        // File upload UPLOAD
        if ($this->isGranted(PublisherConstants::PUBLISHER_ITEM_UPLOAD_FILE)) {
            // NAME
            $nameText = new XoopsFormText(_CO_PUBLISHER_FILENAME, 'item_file_name', 50, 255, '');
            $nameText->setDescription(_CO_PUBLISHER_FILE_NAME_DSC);
            $this->addElement($nameText);
            unset($nameText);
            // DESCRIPTION
            $descriptionText = new XoopsFormTextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'item_file_description', '');
            $descriptionText->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC);
            $this->addElement($descriptionText);
            unset($descriptionText);
            $statusSelect = new XoopsFormRadioYN(_CO_PUBLISHER_FILE_STATUS, 'item_file_status', 1);
            //1 - active
            $statusSelect->setDescription(_CO_PUBLISHER_FILE_STATUS_DSC);
            $this->addElement($statusSelect);
            unset($statusSelect);
            $fileBox = new XoopsFormFile(_CO_PUBLISHER_ITEM_UPLOAD_FILE, 'item_upload_file', 0);
            $fileBox->setDescription(_CO_PUBLISHER_ITEM_UPLOAD_FILE_DSC);
            $fileBox->setExtra("size ='50'");
            $this->addElement($fileBox);
            unset($fileBox);
            if (!$obj->isNew()) {
                $filesObj =& $publisher->getHandler('file')->getAllFiles($obj->itemid());
                if (count($filesObj) > 0) {
                    $table = '';
                    $table .= "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
                    $table .= '<tr>';
                    $table .= "<td width='50' class='bg3' align='center'><strong>ID</strong></td>";
                    $table .= "<td width='150' class='bg3' align='left'><strong>" . _AM_PUBLISHER_FILENAME . '</strong></td>';
                    $table .= "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_DESCRIPTION . '</strong></td>';
                    $table .= "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_HITS . '</strong></td>';
                    $table .= "<td width='100' class='bg3' align='center'><strong>" . _AM_PUBLISHER_UPLOADED_DATE . '</strong></td>';
                    $table .= "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
                    $table .= '</tr>';
                    foreach ($filesObj as $fileObj) {
                        $modify = "<a href='file.php?op=mod&fileid=" . $fileObj->fileid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif' title='" . _CO_PUBLISHER_EDITFILE . "' alt='" . _CO_PUBLISHER_EDITFILE . "' /></a>";
                        $delete = "<a href='file.php?op=del&fileid=" . $fileObj->fileid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png' title='" . _CO_PUBLISHER_DELETEFILE . "' alt='" . _CO_PUBLISHER_DELETEFILE . "'/></a>";
                        if ($fileObj->status() == 0) {
                            $not_visible = "<img src='" . PUBLISHER_URL . "/assets/images/no.gif'/>";
                        } else {
                            $not_visible = '';
                        }
                        $table .= '<tr>';
                        $table .= "<td class='head' align='center'>" . $fileObj->getVar('fileid') . '</td>';
                        $table .= "<td class='odd' align='left'>" . $not_visible . $fileObj->getFileLink() . '</td>';
                        $table .= "<td class='even' align='left'>" . $fileObj->description() . '</td>';
                        $table .= "<td class='even' align='center'>" . $fileObj->counter() . '';
                        $table .= "<td class='even' align='center'>" . $fileObj->getDatesub() . '</td>';
                        $table .= "<td class='even' align='center'> {$modify} {$delete} </td>";
                        $table .= '</tr>';
                    }
                    $table .= '</table>';
                    $files_box = new XoopsFormLabel(_CO_PUBLISHER_FILES_LINKED, $table);
                    $this->addElement($files_box);
                    unset($files_box, $filesObj, $fileObj);
                }
            }
        }
        if ($this->hasTab(_CO_PUBLISHER_TAB_OTHERS)) {
            $this->startTab(_CO_PUBLISHER_TAB_OTHERS);
        }
        //$this->startTab(_CO_PUBLISHER_TAB_META);
        // Meta Keywords
        if ($this->isGranted(PublisherConstants::PUBLISHER_ITEM_META_KEYWORDS)) {
            $text_meta_keywords = new XoopsFormTextArea(_CO_PUBLISHER_ITEM_META_KEYWORDS, 'item_meta_keywords', $obj->meta_keywords('e'), 7, 60);
            $text_meta_keywords->setDescription(_CO_PUBLISHER_ITEM_META_KEYWORDS_DSC);
            $this->addElement($text_meta_keywords);
        }
        // Meta Description
        if ($this->isGranted(PublisherConstants::PUBLISHER_ITEM_META_DESCRIPTION)) {
            $text_meta_description = new XoopsFormTextArea(_CO_PUBLISHER_ITEM_META_DESCRIPTION, 'item_meta_description', $obj->meta_description('e'), 7, 60);
            $text_meta_description->setDescription(_CO_PUBLISHER_ITEM_META_DESCRIPTION_DSC);
            $this->addElement($text_meta_description);
        }
        //$this->startTab(_CO_PUBLISHER_TAB_PERMISSIONS);
        // COMMENTS
        if ($this->isGranted(PublisherConstants::PUBLISHER_ALLOWCOMMENTS)) {
            $addcomments_radio = new XoopsFormRadioYN(_CO_PUBLISHER_ALLOWCOMMENTS, 'allowcomments', $obj->cancomment(), _YES, _NO);
            $this->addElement($addcomments_radio);
        }
        // WEIGHT
        if ($this->isGranted(PublisherConstants::PUBLISHER_WEIGHT)) {
            $this->addElement(new XoopsFormText(_CO_PUBLISHER_WEIGHT, 'weight', 5, 5, $obj->weight()));
        }
        $this->endTabs();
        //COMMON TO ALL TABS
        $button_tray = new XoopsFormElementTray('', '');
        if (!$obj->isNew()) {
            $button_tray->addElement(new XoopsFormButton('', 'additem', _SUBMIT, 'submit'));
            //orclone
        } else {
            $button_tray->addElement(new XoopsFormButton('', 'additem', _CO_PUBLISHER_CREATE, 'submit'));
            $button_tray->addElement(new XoopsFormButton('', '', _CO_PUBLISHER_CLEAR, 'reset'));
        }
        $button_tray->addElement(new XoopsFormButton('', 'preview', _CO_PUBLISHER_PREVIEW, 'submit'));
        $butt_cancel = new XoopsFormButton('', '', _CO_PUBLISHER_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
        $this->addElement($button_tray);
        $hidden = new XoopsFormHidden('itemid', $obj->itemid());
        $this->addElement($hidden);
        unset($hidden);
        return $this;
    }
Exemplo n.º 5
0
function send_form()
{
    global $xoopsModuleConfig;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    $this_handler =& xoops_getModuleHandler('user', 'subscribers');
    $form = new XoopsThemeForm(_AM_SUBSCRIBERS_SEND, 'send_form', 'admin_send.php', "post");
    $element = new XoopsFormLabel(_MI_SUBSCRIBERS_CONF_FROMNAME, $xoopsModuleConfig['fromname']);
    $form->addElement($element);
    unset($element);
    $element = new XoopsFormLabel(_MI_SUBSCRIBERS_CONF_FROMEMAIL, $xoopsModuleConfig['fromemail']);
    $form->addElement($element);
    unset($element);
    // Country
    include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
    $countries = array("ALL" => _AM_SUBSCRIBERS_ALL_COUNTRIES);
    $countries2 = XoopsLists::getCountryList();
    array_shift($countries2);
    $countries += $countries2;
    $element = new XoopsFormSelect(_AM_SUBSCRIBERS_COUNTRY, 'country', 'ALL');
    $element->addOptionArray($countries);
    $form->addElement($element);
    unset($element, $countries);
    // Subject
    $form->addElement(new XoopsFormText(_AM_SUBSCRIBERS_EMAIL_SUBJECT, 'subject', 75, 150, ''), true);
    // Body
    $editor_configs = array();
    $editor_configs['rows'] = 35;
    $editor_configs['cols'] = 60;
    $editor_configs['width'] = '100%';
    $editor_configs['height'] = '400px';
    $editor_configs['name'] = 'body';
    $editor_configs['value'] = '';
    $element = new XoopsFormEditor(_AM_SUBSCRIBERS_EMAIL_BODY, $xoopsModuleConfig['editor'], $editor_configs, $nohtml = false, $onfailure = null);
    $element->setDescription(_AM_SUBSCRIBERS_EMAIL_BODY_DSC);
    $form->addElement($element);
    unset($element);
    // Priority
    $priorities = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    unset($priorities[0]);
    $element = new XoopsFormSelect(_AM_SUBSCRIBERS_EMAIL_PRIORITY, 'priority', 5);
    $element->setDescription(_AM_SUBSCRIBERS_EMAIL_PRIORITY_DSC);
    $element->addOptionArray($priorities);
    $form->addElement($element);
    unset($element, $priorities);
    // Groups
    $groups = array(_AM_SUBSCRIBERS_SUBSCRIBERS, _AM_SUBSCRIBERS_USERS, _AM_SUBSCRIBERS_BOTH);
    $element = new XoopsFormSelect(_AM_SUBSCRIBERS_EMAIL_GROUPS, 'groups', 0);
    $element->setDescription(_AM_SUBSCRIBERS_EMAIL_GROUPS_DSC);
    $element->addOptionArray($groups);
    $form->addElement($element);
    unset($element, $groups);
    // Buttons
    $tray = new XoopsFormElementTray('', '');
    $tray->addElement(new XoopsFormButton('', 'submit_button', _SUBMIT, 'submit'));
    $btn = new XoopsFormButton('', 'reset', _CANCEL, 'button');
    $btn->setExtra('onclick="document.location.href=\'admin_send.php\'"');
    $tray->addElement($btn);
    $form->addElement($tray);
    $form->addElement(new XoopsFormHidden('op', 'email'));
    return $form->render();
}
Exemplo n.º 6
0
 function createElements()
 {
     global $xoopsUser;
     // Category
     $criteria = new Criteria(null);
     $criteria->setSort('weight');
     $criteria->setOrder('ASC');
     $mytree = new XoopsObjectTree($this->publisher->getHandler('category')->getObjects($criteria), "categoryid", "parentid");
     $cat_select = $mytree->makeSelBox('parentid', 'name', '--', $this->targetObject->parentid(), true);
     $this->addElement(new XoopsFormLabel(_AM_PUBLISHER_PARENT_CATEGORY_EXP, $cat_select));
     // Name
     $this->addElement(new XoopsFormText(_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $this->targetObject->name('e')), true);
     // Description
     $this->addElement(new XoopsFormTextArea(_AM_PUBLISHER_COLDESCRIPT, 'description', $this->targetObject->description('e'), 7, 60));
     // EDITOR
     $groups = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
     $gperm_handler = $this->publisher->getHandler('groupperm');
     $module_id = $this->publisher->getModule()->mid();
     $allowed_editors = publisher_getEditors($gperm_handler->getItemIds('editors', $groups, $module_id));
     $nohtml = false;
     if (count($allowed_editors) > 0) {
         $editor = @$_POST['editor'];
         if (!empty($editor)) {
             publisher_setCookieVar('publisher_editor', $editor);
         } else {
             $editor = publisher_getCookieVar('publisher_editor');
             if (empty($editor) && is_object($xoopsUser)) {
                 $editor = @$xoopsUser->getVar('publisher_editor');
                 // Need set through user profile
             }
         }
         $editor = empty($editor) || !in_array($editor, $allowed_editors) ? $this->publisher->getConfig('submit_editor') : $editor;
         $form_editor = new XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowed_editors);
         $this->addElement($form_editor);
     } else {
         $editor = $this->publisher->getConfig('submit_editor');
     }
     $editor_configs = array();
     $editor_configs['rows'] = $this->publisher->getConfig('submit_editor_rows') == '' ? 35 : $this->publisher->getConfig('submit_editor_rows');
     $editor_configs['cols'] = $this->publisher->getConfig('submit_editor_cols') == '' ? 60 : $this->publisher->getConfig('submit_editor_cols');
     $editor_configs['width'] = $this->publisher->getConfig('submit_editor_width') == '' ? "100%" : $this->publisher->getConfig('submit_editor_width');
     $editor_configs['height'] = $this->publisher->getConfig('submit_editor_height') == '' ? "400px" : $this->publisher->getConfig('submit_editor_height');
     $editor_configs['name'] = 'header';
     $editor_configs['value'] = $this->targetObject->header('e');
     $text_header = new XoopsFormEditor(_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editor_configs, $nohtml, $onfailure = null);
     $text_header->setDescription(_AM_PUBLISHER_CATEGORY_HEADER_DSC);
     $this->addElement($text_header);
     // IMAGE
     $image_array = XoopsLists::getImgListAsArray(publisher_getImageDir('category'));
     $image_select = new XoopsFormSelect('', 'image', $this->targetObject->image());
     //$image_select -> addOption ('-1', '---------------');
     $image_select->addOptionArray($image_array);
     $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . PUBLISHER_DIRNAME . '/images/category/' . "\", \"\", \"" . XOOPS_URL . "\")'");
     $image_tray = new XoopsFormElementTray(_AM_PUBLISHER_IMAGE, '&nbsp;');
     $image_tray->addElement($image_select);
     $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . publisher_getImageDir('category', false) . $this->targetObject->image() . "' name='image3' id='image3' alt='' />"));
     $image_tray->setDescription(_AM_PUBLISHER_IMAGE_DSC);
     $this->addElement($image_tray);
     // IMAGE UPLOAD
     $max_size = 5000000;
     $file_box = new XoopsFormFile(_AM_PUBLISHER_IMAGE_UPLOAD, "image_file", $max_size);
     $file_box->setExtra("size ='45'");
     $file_box->setDescription(_AM_PUBLISHER_IMAGE_UPLOAD_DSC);
     $this->addElement($file_box);
     // Short url
     $text_short_url = new XoopsFormText(_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $this->targetObject->short_url('e'));
     $text_short_url->setDescription(_AM_PUBLISHER_CATEGORY_SHORT_URL_DSC);
     $this->addElement($text_short_url);
     // Meta Keywords
     $text_meta_keywords = new XoopsFormTextArea(_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $this->targetObject->meta_keywords('e'), 7, 60);
     $text_meta_keywords->setDescription(_AM_PUBLISHER_CATEGORY_META_KEYWORDS_DSC);
     $this->addElement($text_meta_keywords);
     // Meta Description
     $text_meta_description = new XoopsFormTextArea(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $this->targetObject->meta_description('e'), 7, 60);
     $text_meta_description->setDescription(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION_DSC);
     $this->addElement($text_meta_description);
     // Weight
     $this->addElement(new XoopsFormText(_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $this->targetObject->weight()));
     // Added by skalpa: custom template support
     //todo, check this
     $this->addElement(new XoopsFormText("Custom template", 'template', 50, 255, $this->targetObject->template('e')), false);
     // READ PERMISSIONS
     $groups_read_checkbox = new XoopsFormCheckBox(_AM_PUBLISHER_PERMISSIONS_CAT_READ, 'groups_read[]', $this->targetObject->getGroups_read());
     foreach ($this->userGroups as $group_id => $group_name) {
         $groups_read_checkbox->addOption($group_id, $group_name);
     }
     $this->addElement($groups_read_checkbox);
     // SUBMIT PERMISSIONS
     $groups_submit_checkbox = new XoopsFormCheckBox(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT, 'groups_submit[]', $this->targetObject->getGroups_submit());
     $groups_submit_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT_DSC);
     foreach ($this->userGroups as $group_id => $group_name) {
         $groups_submit_checkbox->addOption($group_id, $group_name);
     }
     $this->addElement($groups_submit_checkbox);
     // MODERATION PERMISSIONS
     $groups_moderation_checkbox = new XoopsFormCheckBox(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR, 'groups_moderation[]', $this->targetObject->getGroups_moderation());
     $groups_moderation_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR_DSC);
     foreach ($this->userGroups as $group_id => $group_name) {
         $groups_moderation_checkbox->addOption($group_id, $group_name);
     }
     $this->addElement($groups_moderation_checkbox);
     $moderator = new XoopsFormSelectUser(_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $this->targetObject->moderator('e'), 1, false);
     $moderator->setDescription(_AM_PUBLISHER_CATEGORY_MODERATOR_DSC);
     $this->addElement($moderator);
     $cat_tray = new XoopsFormElementTray(_AM_PUBLISHER_SCATEGORYNAME, '<br /><br />');
     for ($i = 0; $i < $this->subCatsCount; $i++) {
         if ($i < (isset($_POST['scname']) ? sizeof($_POST['scname']) : 0)) {
             $subname = isset($_POST['scname']) ? $_POST['scname'][$i] : '';
         } else {
             $subname = '';
         }
         $cat_tray->addElement(new XoopsFormText('', 'scname[' . $i . ']', 50, 255, $subname));
     }
     $t = new XoopsFormText('', 'nb_subcats', 3, 2);
     $l = new XoopsFormLabel('', sprintf(_AM_PUBLISHER_ADD_OPT, $t->render()));
     $b = new XoopsFormButton('', 'submit_subcats', _AM_PUBLISHER_ADD_OPT_SUBMIT, 'submit');
     if (!$this->targetObject->categoryid()) {
         $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"');
     } else {
         $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"');
     }
     $r = new XoopsFormElementTray('');
     $r->addElement($l);
     $r->addElement($b);
     $cat_tray->addElement($r);
     $this->addElement($cat_tray);
     $this->addElement(new XoopsFormHidden('categoryid', $this->targetObject->categoryid()));
     $this->addElement(new XoopsFormHidden('nb_sub_yet', $this->subCatsCount));
 }
Exemplo n.º 7
0
 public function createElements()
 {
     include_once dirname(dirname(__DIR__)) . '/include/common.php';
     // Category
     $criteria = new Criteria(null);
     $criteria->setSort('weight');
     $criteria->setOrder('ASC');
     $myTree = new XoopsObjectTree($this->publisher->getHandler('category')->getObjects($criteria), 'categoryid', 'parentid');
     $catSelect = $myTree->makeSelBox('parentid', 'name', '--', $this->targetObject->parentid(), true);
     $this->addElement(new XoopsFormLabel(_AM_PUBLISHER_PARENT_CATEGORY_EXP, $catSelect));
     // Name
     $this->addElement(new XoopsFormText(_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $this->targetObject->name('e')), true);
     // Description
     $this->addElement(new XoopsFormTextArea(_AM_PUBLISHER_COLDESCRIPT, 'description', $this->targetObject->description('e'), 7, 60));
     // EDITOR
     $groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
     $gpermHandler =& $this->publisher->getHandler('groupperm');
     $moduleId = $this->publisher->getModule()->mid();
     $allowedEditors = publisherGetEditors($gpermHandler->getItemIds('editors', $groups, $moduleId));
     $nohtml = false;
     if (count($allowedEditors) > 0) {
         $editor = XoopsRequest::getString('editor', '', 'POST');
         if (!empty($editor)) {
             publisherSetCookieVar('publisher_editor', $editor);
         } else {
             $editor = publisherGetCookieVar('publisher_editor');
             if (empty($editor) && is_object($GLOBALS['xoopsUser'])) {
                 $editor = null !== $GLOBALS['xoopsUser']->getVar('publisher_editor') ? $GLOBALS['xoopsUser']->getVar('publisher_editor') : '';
                 // Need set through user profile
             }
         }
         $editor = empty($editor) || !in_array($editor, $allowedEditors) ? $this->publisher->getConfig('submit_editor') : $editor;
         $formEditor = new XoopsFormSelectEditor($this, 'editor', $editor, $nohtml, $allowedEditors);
         $this->addElement($formEditor);
     } else {
         $editor = $this->publisher->getConfig('submit_editor');
     }
     $editorConfigs = array();
     $editorConfigs['rows'] = $this->publisher->getConfig('submit_editor_rows') == '' ? 35 : $this->publisher->getConfig('submit_editor_rows');
     $editorConfigs['cols'] = $this->publisher->getConfig('submit_editor_cols') == '' ? 60 : $this->publisher->getConfig('submit_editor_cols');
     $editorConfigs['width'] = $this->publisher->getConfig('submit_editor_width') == '' ? '100%' : $this->publisher->getConfig('submit_editor_width');
     $editorConfigs['height'] = $this->publisher->getConfig('submit_editor_height') == '' ? '400px' : $this->publisher->getConfig('submit_editor_height');
     $editorConfigs['name'] = 'header';
     $editorConfigs['value'] = $this->targetObject->header('e');
     $textHeader = new XoopsFormEditor(_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editorConfigs, $nohtml, $onfailure = null);
     $textHeader->setDescription(_AM_PUBLISHER_CATEGORY_HEADER_DSC);
     $this->addElement($textHeader);
     // IMAGE
     $imageArray = XoopsLists::getImgListAsArray(publisherGetImageDir('category'));
     $imageSelect = new XoopsFormSelect('', 'image', $this->targetObject->getImage());
     //$imageSelect -> addOption ('-1', '---------------');
     $imageSelect->addOptionArray($imageArray);
     $imageSelect->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . PUBLISHER_DIRNAME . '/images/category/' . "\", \"\", \"" . XOOPS_URL . "\")'");
     $imageTray = new XoopsFormElementTray(_AM_PUBLISHER_IMAGE, '&nbsp;');
     $imageTray->addElement($imageSelect);
     $imageTray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . publisherGetImageDir('category', false) . $this->targetObject->getImage() . "' name='image3' id='image3' alt='' />"));
     $imageTray->setDescription(_AM_PUBLISHER_IMAGE_DSC);
     $this->addElement($imageTray);
     // IMAGE UPLOAD
     $max_size = 5000000;
     $fileBox = new XoopsFormFile(_AM_PUBLISHER_IMAGE_UPLOAD, 'image_file', $max_size);
     $fileBox->setExtra("size ='45'");
     $fileBox->setDescription(_AM_PUBLISHER_IMAGE_UPLOAD_DSC);
     $this->addElement($fileBox);
     // Short url
     $textShortUrl = new XoopsFormText(_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $this->targetObject->short_url('e'));
     $textShortUrl->setDescription(_AM_PUBLISHER_CATEGORY_SHORT_URL_DSC);
     $this->addElement($textShortUrl);
     // Meta Keywords
     $textMetaKeywords = new XoopsFormTextArea(_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $this->targetObject->meta_keywords('e'), 7, 60);
     $textMetaKeywords->setDescription(_AM_PUBLISHER_CATEGORY_META_KEYWORDS_DSC);
     $this->addElement($textMetaKeywords);
     // Meta Description
     $textMetaDescription = new XoopsFormTextArea(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $this->targetObject->meta_description('e'), 7, 60);
     $textMetaDescription->setDescription(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION_DSC);
     $this->addElement($textMetaDescription);
     // Weight
     $this->addElement(new XoopsFormText(_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $this->targetObject->weight()));
     // Added by skalpa: custom template support
     //todo, check this
     $this->addElement(new XoopsFormText('Custom template', 'template', 50, 255, $this->targetObject->template('e')), false);
     // READ PERMISSIONS
     $readPermissionsTray = new XoopsFormElementTray(_AM_PUBLISHER_PERMISSIONS_CAT_READ, '');
     $selectAllReadCheckbox = new XoopsFormCheckBox('', "adminbox", 1);
     $selectAllReadCheckbox->addOption('allbox', _AM_SYSTEM_ALL);
     $selectAllReadCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox\" , \"groupsRead[]\");' ");
     $selectAllReadCheckbox->setClass('xo-checkall');
     $readPermissionsTray->addElement($selectAllReadCheckbox);
     $groupsReadCheckbox = new XoopsFormCheckBox('', 'groupsRead[]', $this->targetObject->getGroupsRead());
     foreach ($this->userGroups as $group_id => $group_name) {
         $groupsReadCheckbox->addOption($group_id, $group_name);
     }
     $readPermissionsTray->addElement($groupsReadCheckbox);
     $this->addElement($readPermissionsTray);
     // SUBMIT PERMISSIONS
     $submitPermissionsTray = new XoopsFormElementTray(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT, '');
     $submitPermissionsTray->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT_DSC);
     $selectAllSubmitCheckbox = new XoopsFormCheckBox('', "adminbox2", 1);
     $selectAllSubmitCheckbox->addOption('allbox', _AM_SYSTEM_ALL);
     $selectAllSubmitCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox2\" , \"groupsSubmit[]\");' ");
     $selectAllSubmitCheckbox->setClass('xo-checkall');
     $submitPermissionsTray->addElement($selectAllSubmitCheckbox);
     $groupsSubmitCheckbox = new XoopsFormCheckBox('', 'groupsSubmit[]', $this->targetObject->getGroupsSubmit());
     foreach ($this->userGroups as $group_id => $group_name) {
         $groupsSubmitCheckbox->addOption($group_id, $group_name);
     }
     $submitPermissionsTray->addElement($groupsSubmitCheckbox);
     $this->addElement($submitPermissionsTray);
     // MODERATION PERMISSIONS
     $moderatePermissionsTray = new XoopsFormElementTray(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR, '');
     $moderatePermissionsTray->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR_DSC);
     $selectAllModerateCheckbox = new XoopsFormCheckBox('', "adminbox3", 1);
     $selectAllModerateCheckbox->addOption('allbox', _AM_SYSTEM_ALL);
     $selectAllModerateCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox3\" , \"groupsModeration[]\");' ");
     $selectAllModerateCheckbox->setClass('xo-checkall');
     $moderatePermissionsTray->addElement($selectAllModerateCheckbox);
     $groupsModerationCheckbox = new XoopsFormCheckBox('', 'groupsModeration[]', $this->targetObject->getGroupsModeration());
     foreach ($this->userGroups as $group_id => $group_name) {
         $groupsModerationCheckbox->addOption($group_id, $group_name);
     }
     $moderatePermissionsTray->addElement($groupsModerationCheckbox);
     $this->addElement($moderatePermissionsTray);
     $moderator = new XoopsFormSelectUser(_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $this->targetObject->moderator('e'), 1, false);
     $moderator->setDescription(_AM_PUBLISHER_CATEGORY_MODERATOR_DSC);
     $this->addElement($moderator);
     //SUBCATEGORY
     $catTray = new XoopsFormElementTray(_AM_PUBLISHER_SCATEGORYNAME, '<br /><br />');
     for ($i = 0; $i < $this->subCatsCount; ++$i) {
         $subname = '';
         if ($i < (($scname = XoopsRequest::getArray('scname', array(), 'POST')) ? count($scname) : 0)) {
             $temp = XoopsRequest::getArray('scname', array(), 'POST');
             $subname = ($scname = XoopsRequest::getArray('scname', '', 'POST')) ? $temp[$i] : '';
         }
         $catTray->addElement(new XoopsFormText('', 'scname[' . $i . ']', 50, 255, $subname));
     }
     $t = new XoopsFormText('', 'nb_subcats', 3, 2);
     $l = new XoopsFormLabel('', sprintf(_AM_PUBLISHER_ADD_OPT, $t->render()));
     $b = new XoopsFormButton('', 'submit_subcats', _AM_PUBLISHER_ADD_OPT_SUBMIT, 'submit');
     if (!$this->targetObject->categoryid()) {
         $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"');
     } else {
         $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"');
     }
     $r = new XoopsFormElementTray('');
     $r->addElement($l);
     $r->addElement($b);
     $catTray->addElement($r);
     $this->addElement($catTray);
     $this->addElement(new XoopsFormHidden('categoryid', $this->targetObject->categoryid()));
     $this->addElement(new XoopsFormHidden('nb_sub_yet', $this->subCatsCount));
 }