Exemplo n.º 1
0
function createDir()
{
    // auto crate folders
    $thePath = smartsection_getUploadDir();
    if (smartsection_admin_getPathStatus('root', true) < 0) {
        $thePath = smartsection_getUploadDir();
        $res = smartsection_admin_mkdir($thePath);
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
    if (smartsection_admin_getPathStatus('images', true) < 0) {
        $thePath = smartsection_getImageDir();
        $res = smartsection_admin_mkdir($thePath);
        if ($res) {
            $source = SMARTSECTION_ROOT_PATH . "images/blank.png";
            $dest = $thePath . "blank.png";
            smartsection_copyr($source, $dest);
        }
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
    if (smartsection_admin_getPathStatus('images/category', true) < 0) {
        $thePath = smartsection_getImageDir('category');
        $res = smartsection_admin_mkdir($thePath);
        if ($res) {
            $source = SMARTSECTION_ROOT_PATH . "images/blank.png";
            $dest = $thePath . "blank.png";
            smartsection_copyr($source, $dest);
        }
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
    if (smartsection_admin_getPathStatus('images/item', true) < 0) {
        $thePath = smartsection_getImageDir('item');
        $res = smartsection_admin_mkdir($thePath);
        if ($res) {
            $source = SMARTSECTION_ROOT_PATH . "images/blank.png";
            $dest = $thePath . "blank.png";
            smartsection_copyr($source, $dest);
        }
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
    if (smartsection_admin_getPathStatus('content', true) < 0) {
        $thePath = smartsection_getUploadDir(true, 'content');
        $res = smartsection_admin_mkdir($thePath);
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
}
Exemplo n.º 2
0
 function createElements()
 {
     global $xoopsDB;
     $mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid");
     // Parent Category
     ob_start();
     $mytree->makeMySelBox("name", "weight", $this->targetObject->parentid(), 1, 'parentid');
     //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="")
     $this->addElement(new XoopsFormLabel(_AM_SSECTION_PARENT_CATEGORY_EXP, ob_get_contents()));
     ob_end_clean();
     // Name
     $this->addElement(new XoopsFormText(_AM_SSECTION_CATEGORY, 'name', 50, 255, $this->targetObject->name('e')), true);
     // Description
     $this->addElement(new XoopsFormTextArea(_AM_SSECTION_COLDESCRIPT, 'description', $this->targetObject->description('e'), 7, 60));
     if (SMARTSECTION_LEVEL > 0) {
         // Header
         $text_header = smartsection_getEditor(_AM_SSECTION_CATEGORY_HEADER, 'header', $this->targetObject->header('e'));
         $text_header->setDescription(_AM_SSECTION_CATEGORY_HEADER_DSC);
         $this->addElement($text_header);
     }
     // IMAGE
     $image_array = XoopsLists::getImgListAsArray(smartsection_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/smartsection/images/category/' . "\", \"\", \"" . XOOPS_URL . "\")'");
     $image_tray = new XoopsFormElementTray(_AM_SSECTION_IMAGE, '&nbsp;');
     $image_tray->addElement($image_select);
     $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartsection_getImageDir('category', false) . $this->targetObject->image() . "' name='image3' id='image3' alt='' />"));
     $image_tray->setDescription(_AM_SSECTION_IMAGE_DSC);
     $this->addElement($image_tray);
     // IMAGE UPLOAD
     $max_size = 5000000;
     $file_box = new XoopsFormFile(_AM_SSECTION_IMAGE_UPLOAD, "image_file", $max_size);
     $file_box->setExtra("size ='45'");
     $file_box->setDescription(_AM_SSECTION_IMAGE_UPLOAD_DSC);
     $this->addElement($file_box);
     if (SMARTSECTION_LEVEL > 0) {
         // Short url
         $text_short_url = new XoopsFormText(_AM_SSECTION_CATEGORY_SHORT_URL, 'short_url', 50, 255, $this->targetObject->short_url('e'));
         $text_short_url->setDescription(_AM_SSECTION_CATEGORY_SHORT_URL_DSC);
         $this->addElement($text_short_url);
         // Meta Keywords
         $text_meta_keywords = new XoopsFormTextArea(_AM_SSECTION_CATEGORY_META_KEYWORDS, 'meta_keywords', $this->targetObject->meta_keywords('e'), 7, 60);
         $text_meta_keywords->setDescription(_AM_SSECTION_CATEGORY_META_KEYWORDS_DSC);
         $this->addElement($text_meta_keywords);
         // Meta Description
         $text_meta_description = new XoopsFormTextArea(_AM_SSECTION_CATEGORY_META_DESCRIPTION, 'meta_description', $this->targetObject->meta_description('e'), 7, 60);
         $text_meta_description->setDescription(_AM_SSECTION_CATEGORY_META_DESCRIPTION_DSC);
         $this->addElement($text_meta_description);
     }
     // Weight
     $this->addElement(new XoopsFormText(_AM_SSECTION_COLPOSIT, 'weight', 4, 4, $this->targetObject->weight()));
     if (SMARTSECTION_LEVEL > 0) {
         // Added by skalpa: custom template support
         $this->addElement(new XoopsFormText("Custom template", 'template', 50, 255, $this->targetObject->template('e')), false);
     }
     // READ PERMISSIONS
     $groups_read_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PERMISSIONS_CAT_READ, 'groups_read[]', $this->targetObject->getGroups_read());
     foreach ($this->userGroups as $group_id => $group_name) {
         if ($group_id != XOOPS_GROUP_ADMIN) {
             $groups_read_checkbox->addOption($group_id, $group_name);
         }
     }
     $this->addElement($groups_read_checkbox);
     // Apply permissions on all items
     $apply = isset($_POST['applyall']) ? intval($_POST['applyall']) : 0;
     $addapplyall_radio = new XoopsFormRadioYN(_AM_SSECTION_PERMISSIONS_APPLY_ON_ITEMS, 'applyall', $apply, ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . '');
     $this->addElement($addapplyall_radio);
     // SUBMIT PERMISSIONS
     $groups_submit_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PERMISSIONS_CAT_SUBMIT, 'groups_submit[]', $this->targetObject->getGroups_submit());
     $groups_submit_checkbox->setDescription(_AM_SSECTION_PERMISSIONS_CAT_SUBMIT_DSC);
     foreach ($this->userGroups as $group_id => $group_name) {
         if ($group_id != XOOPS_GROUP_ADMIN) {
             $groups_submit_checkbox->addOption($group_id, $group_name);
         }
     }
     $this->addElement($groups_submit_checkbox);
     if (SMARTSECTION_LEVEL > 0) {
         // Added by fx2024
         // sub Categories
         $cat_tray = new XoopsFormElementTray(_AM_SSECTION_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), true);
         }
         $t = new XoopsFormText('', 'nb_subcats', 3, 2);
         $l = new XoopsFormLabel('', sprintf(_AM_SSECTION_ADD_OPT, $t->render()));
         $b = new XoopsFormButton('', 'submit', _AM_SSECTION_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);
         //End of fx2024 code
     }
     /*
     $module_id = $xoopsModule->getVar('mid');	
     $gperm_handler = &xoops_gethandler('groupperm');
     $mod_perms = $gperm_handler->getGroupIds('category_moderation', $categoryid, $module_id);
     
     $moderators_select = new XoopsFormSelect('', 'moderators', $moderators, 5, true);
     $moderators_tray->addElement($moderators_select);
     
     $butt_mngmods = new XoopsFormButton('', '', 'Manage mods', 'button');
     $butt_mngmods->setExtra('onclick="javascript:small_window(\'pop.php\', 370, 350);"');
     $moderators_tray->addElement($butt_mngmods);
     
     $butt_delmod = new XoopsFormButton('', '', 'Delete mod', 'button');
     $butt_delmod->setExtra('onclick="javascript:deleteSelectedItemsFromList(this.form.elements[\'moderators[]\']);"');
     $moderators_tray->addElement($butt_delmod);
     
     $this->addElement($moderators_tray);
     */
     $this->addElement(new XoopsFormHidden('categoryid', $this->targetObject->categoryid()));
     //$parentid = $this->targetObject->parentid('s');
     //$this -> addElement( new XoopsFormHidden( 'parentid', $parentid ) );
     $this->addElement(new XoopsFormHidden('nb_sub_yet', $this->subCatsCount));
 }
Exemplo n.º 3
0
 function toArray($item_page_id = -1, $max_char_title = 0)
 {
     global $xoopsModuleConfig, $xoopsUser;
     $item = array();
     $item['id'] = $this->itemid();
     $item['categoryid'] = $this->categoryid();
     $item['categoryPath'] = $this->getCategoryPath(smartsection_getConfig('linkedPath'));
     $item['categoryname'] = $this->getCategoryName();
     $item['title'] = $this->title();
     $item['clean_title'] = $this->title();
     $item['itemurl'] = $this->getItemUrl();
     $item['titlelink'] = $this->getItemLink(false, $max_char_title);
     $item['summary'] = $this->summary();
     $item['display_summary'] = $this->getVar('display_summary');
     $item['meta_keywords'] = $this->meta_keywords();
     $item['meta_description'] = $this->meta_description();
     $item['short_url'] = $this->short_url();
     if ($this->showPartial_view()) {
         $body = smartsection_getConfig('partial_view_text');
     } else {
         $body = $this->body();
     }
     $item['body'] = $body;
     $item['maintext'] = $this->buildmaintext($item_page_id, $body);
     if ($this->image() != 'blank.png') {
         $item['image_path'] = smartsection_getImageDir('item', false) . $this->image();
     } else {
         $item['image_path'] = '';
     }
     $item['posterName'] = $this->posterName();
     $item['itemid'] = $this->itemid();
     $item['counter'] = $this->counter();
     $item['cancomment'] = $this->cancomment();
     $item['comments'] = $this->comments();
     $item['datesub'] = $this->datesub();
     $item['adminlink'] = $this->getAdminLinks();
     // Hightlighting searched words
     $highlight = true;
     if ($highlight && isset($_GET['keywords'])) {
         $myts =& MyTextSanitizer::getInstance();
         $keywords = $myts->htmlSpecialChars(trim(urldecode($_GET['keywords'])));
         $h = new SmartsectionKeyhighlighter($keywords, true, 'smartsection_highlighter');
         $item['title'] = $h->highlight($item['title']);
         $item['summary'] = $h->highlight($item['summary']);
         $item['maintext'] = $h->highlight($item['maintext']);
     }
     return $item;
 }
Exemplo n.º 4
0
 // Retreive the filename to be uploaded
 if (isset($_FILES['image_file']['name']) && $_FILES['image_file']['name'] != "") {
     $filename = $_POST["xoops_upload_file"][0];
     if (!empty($filename) || $filename != "") {
         global $xoopsModuleConfig;
         // TODO : implement smartsection mimetype management
         $max_size = $xoopsModuleConfig['maximum_filesize'];
         $max_imgwidth = $xoopsModuleConfig['maximum_image_width'];
         $max_imgheight = $xoopsModuleConfig['maximum_image_height'];
         $allowed_mimetypes = smartsection_getAllowedImagesTypes();
         include_once XOOPS_ROOT_PATH . "/class/uploader.php";
         if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) {
             redirect_header('javascript:history.go(-1)', 2, _AM_SSECTION_FILEUPLOAD_ERROR);
             exit;
         }
         $uploader = new XoopsMediaUploader(smartsection_getImageDir('category'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
         if ($uploader->fetchMedia($filename) && $uploader->upload()) {
             $categoryObj->setVar('image', $uploader->getSavedFileName());
         } else {
             redirect_header('javascript:history.go(-1)', 2, _AM_SSECTION_FILEUPLOAD_ERROR . $uploader->getErrors());
             exit;
         }
     }
 } else {
     if (isset($_POST['image'])) {
         $categoryObj->setVar('image', $_POST['image']);
     }
 }
 $categoryObj->setVar('parentid', isset($_POST['parentid']) ? intval($_POST['parentid']) : 0);
 $applyall = isset($_POST['applyall']) ? intval($_POST['applyall']) : 0;
 $categoryObj->setVar('weight', isset($_POST['weight']) ? intval($_POST['weight']) : 1);
Exemplo n.º 5
0
 function toArray($category = array())
 {
     global $myts;
     $category['categoryid'] = $this->categoryid();
     $category['name'] = $this->name();
     $category['categorylink'] = $this->getCategoryLink();
     $category['total'] = $this->getVar('itemcount') > 0 ? $this->getVar('itemcount') : '';
     $category['description'] = $this->description();
     $category['header'] = $this->header();
     $category['meta_keywords'] = $this->meta_keywords();
     $category['meta_description'] = $this->meta_description();
     $category['short_url'] = $this->short_url();
     if ($this->getVar('last_itemid') > 0) {
         $category['last_itemid'] = $this->getVar('last_itemid', 'n');
         $category['last_title_link'] = $this->getVar('last_title_link', 'n');
     }
     if ($this->image() != 'blank.png') {
         $category['image_path'] = smartsection_getImageDir('category', false) . $this->image();
     } else {
         $category['image_path'] = '';
     }
     $category['lang_subcategories'] = sprintf(_MD_SSECTION_SUBCATEGORIES_INFO, $this->name());
     return $category;
 }
Exemplo n.º 6
0
function edititem($showmenu = false, $itemid = 0, $clone = false)
{
    global $smartsection_current_page, $smartsection_file_handler, $smartsection_item_handler, $smartsection_category_handler, $xoopsUser, $xoopsModule, $xoopsConfig, $xoopsDB;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    include_once SMARTSECTION_ROOT_PATH . '/class/formdatetime.php';
    // if there is a parameter, and the id exists, retrieve data: we're editing a item
    if ($itemid != 0) {
        // Creating the ITEM object
        $itemObj = $smartsection_item_handler->get($itemid);
        if (!$itemObj) {
            redirect_header("item.php", 1, _AM_SSECTION_NOITEMSELECTED);
            exit;
        }
        if ($clone) {
            $itemObj->setNew();
            $itemObj->setVar('status', _SSECTION_STATUS_NOTSET);
            $itemObj->setVar('datesub', time());
        }
        switch ($itemObj->status()) {
            case _SSECTION_STATUS_SUBMITTED:
                $breadcrumb_action1 = _AM_SSECTION_SUBMITTED;
                $breadcrumb_action2 = _AM_SSECTION_APPROVING;
                $page_title = _AM_SSECTION_SUBMITTED_TITLE;
                $page_info = _AM_SSECTION_SUBMITTED_INFO;
                $button_caption = _AM_SSECTION_APPROVE;
                $new_status = _SSECTION_STATUS_PUBLISHED;
                break;
            case _SSECTION_STATUS_PUBLISHED:
                $breadcrumb_action1 = _AM_SSECTION_PUBLISHED;
                $breadcrumb_action2 = _AM_SSECTION_EDITING;
                $page_title = _AM_SSECTION_PUBLISHEDEDITING;
                $page_info = _AM_SSECTION_PUBLISHEDEDITING_INFO;
                $button_caption = _AM_SSECTION_MODIFY;
                $new_status = _SSECTION_STATUS_PUBLISHED;
                break;
            case _SSECTION_STATUS_OFFLINE:
                $breadcrumb_action1 = _AM_SSECTION_OFFLINE;
                $breadcrumb_action2 = _AM_SSECTION_EDITING;
                $page_title = _AM_SSECTION_OFFLINEEDITING;
                $page_info = _AM_SSECTION_OFFLINEEDITING_INFO;
                $button_caption = _AM_SSECTION_MODIFY;
                $new_status = _SSECTION_STATUS_OFFLINE;
                break;
            case _SSECTION_STATUS_REJECTED:
                $breadcrumb_action1 = _AM_SSECTION_REJECTED;
                $breadcrumb_action2 = _AM_SSECTION_REJECTED;
                $page_title = _AM_SSECTION_REJECTED_EDIT;
                $page_info = _AM_SSECTION_REJECTED_EDIT_INFO;
                $button_caption = _AM_SSECTION_MODIFY;
                $new_status = _SSECTION_STATUS_REJECTED;
                break;
            case _SSECTION_STATUS_NOTSET:
                // Then it's a clone...
                $breadcrumb_action1 = _AM_SSECTION_ITEMS;
                $breadcrumb_action2 = _AM_SSECTION_CLONE_NEW;
                $button_caption = _AM_SSECTION_CREATE;
                $new_status = _SSECTION_STATUS_PUBLISHED;
                $page_title = _AM_SSECTION_ITEM_DUPLICATING;
                $page_info = _AM_SSECTION_ITEM_DUPLICATING_DSC;
                break;
            case "default":
            default:
                $breadcrumb_action1 = _AM_SSECTION_ITEMS;
                $breadcrumb_action2 = _AM_SSECTION_EDITING;
                $page_title = _AM_SSECTION_PUBLISHEDEDITING;
                $page_info = _AM_SSECTION_PUBLISHEDEDITING_INFO;
                $button_caption = _AM_SSECTION_MODIFY;
                $new_status = _SSECTION_STATUS_PUBLISHED;
                break;
        }
        $categoryObj = $itemObj->category();
        if ($showmenu) {
            smartsection_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        echo "<br />\n";
        smartsection_collapsableBar('edititemtable', 'edititemicon', $page_title, $page_info);
        if (!$clone) {
            echo "<form><div style=\"margin-bottom: 10px;\">";
            echo "<input type='button' name='button' onclick=\"location='item.php?op=clone&itemid=" . $itemObj->itemid() . "'\" value='" . _AM_SSECTION_CLONE_ITEM . "'>&nbsp;&nbsp;";
            echo "</div></form>";
        }
    } else {
        // there's no parameter, so we're adding an item
        $itemObj =& $smartsection_item_handler->create();
        $itemObj->setVar('uid', $xoopsUser->uid());
        $categoryObj =& $smartsection_category_handler->create();
        $breadcrumb_action1 = _AM_SSECTION_ITEMS;
        $breadcrumb_action2 = _AM_SSECTION_CREATINGNEW;
        $button_caption = _AM_SSECTION_CREATE;
        $new_status = _SSECTION_STATUS_PUBLISHED;
        if ($showmenu) {
            smartsection_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        $sel_categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0;
        $categoryObj->setVar('categoryid', $sel_categoryid);
        smartsection_collapsableBar('createitemtable', 'createitemicon', _AM_SSECTION_ITEM_CREATING, _AM_SSECTION_ITEM_CREATING_DSC);
    }
    // ITEM FORM
    $sform = new XoopsThemeForm(_AM_SSECTION_ITEMS, "op", xoops_getenv('PHP_SELF'));
    $sform->setExtra('enctype="multipart/form-data"');
    // CATEGORY
    $mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid");
    ob_start();
    //$sform->addElement(new XoopsFormHidden('categoryid', $categoryObj->categoryid()));
    $mytree->makeMySelBox("name", "weight", $categoryObj->categoryid());
    $category_label = new XoopsFormLabel(_AM_SSECTION_CATEGORY, ob_get_contents());
    $category_label->setDescription(_AM_SSECTION_CATEGORY_DSC);
    $sform->addElement($category_label);
    ob_end_clean();
    // TITLE
    $title_text = new XoopsFormText(_AM_SSECTION_TITLE, 'title', 50, 255, $itemObj->title(0, 'e'));
    $sform->addElement($title_text, true);
    if (SMARTSECTION_LEVEL >= 5) {
        // SUMMARY
        $summary_text = smartsection_getEditor(_AM_SSECTION_SUMMARY, 'summary', $itemObj->getVar('summary', 'e'));
        $summary_text->setDescription(_AM_SSECTION_SUMMARY_DSC);
        $sform->addElement($summary_text, false);
        // DISPLAY_SUMMARY
        $display_summary_radio = new XoopsFormRadioYN(_AM_SSECTION_DISPLAY_SUMMARY, 'display_summary', $itemObj->display_summary(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . '');
        $sform->addElement($display_summary_radio);
    }
    // BODY
    /*if ($itemObj->address()) {
    		// Main body : pagewrap
    		$address_select = new XoopsFormSelect(_AM_SSECTION_BODY_SELECTFILE, "address", $itemObj->address());
    		$address_select->setDescription(_AM_SSECTION_BODY_SELECTFILE_DSC);
    	    $dir = smartsection_getUploadDir(true, 'content');
    		$folder = dir($dir);
    		while($file = $folder->read()) {
    	      if ($file != "." && $file != "..") {
    		     $address_select->addOption($file, "".$file."");
    		  }
    		}
    	    $folder->close();
    		$sform->addElement($address_select);
    
    		$sform->addElement(new XoopsFormHidden('body', ''));
    	} else {*/
    $body_text = smartsection_getEditor(_AM_SSECTION_BODY, 'body', $itemObj->getVar('body', 'e'));
    if (SMARTSECTION_LEVEL >= 5) {
        $body_text->setDescription(sprintf(_AM_SSECTION_BODY_DSC, SMARTSECTION_URL . "/admin/pagewrap_lookup.php"));
    }
    $sform->addElement($body_text);
    //}
    if (SMARTSECTION_LEVEL >= 5) {
        // Available pages to wrap
        $wrap_pages = XoopsLists::getHtmlListAsArray(smartsection_getUploadDir(true, 'content'));
        $available_wrap_pages_text = array();
        foreach ($wrap_pages as $page) {
            $available_wrap_pages_text[] = "<span onclick='smartsectionPageWrap(\"body\", \"[pagewrap={$page}] \");' onmouseover='style.cursor=\"pointer\"'>{$page}</span>";
        }
        $available_wrap_pages = new XoopsFormLabel(_AM_SSECTION_AVAILABLE_PAGE_WRAP, implode(', ', $available_wrap_pages_text));
        $available_wrap_pages->setDescription(_AM_SSECTION_AVAILABLE_PAGE_WRAP_DSC);
        $sform->addElement($available_wrap_pages);
        // Tags
        if (smartsection_tag_module_included()) {
            include_once XOOPS_ROOT_PATH . "/modules/tag/include/formtag.php";
            $text_tags = new XoopsFormTag("item_tag", 60, 255, $itemObj->getVar('item_tag', 'e'), 0);
            $sform->addElement($text_tags);
        }
        // IMAGE
        $image_array = XoopsLists::getImgListAsArray(smartsection_getImageDir('item'));
        $image_select = new XoopsFormSelect('', 'image', $itemObj->image());
        //$image_select -> addOption ('-1', '---------------');
        $image_select->addOptionArray($image_array);
        $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/smartsection/images/item/' . "\", \"\", \"" . XOOPS_URL . "\")'");
        $image_tray = new XoopsFormElementTray(_AM_SSECTION_IMAGE_ITEM, '&nbsp;');
        $image_tray->addElement($image_select);
        $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartsection_getImageDir('item', false) . $itemObj->image() . "' name='image3' id='image3' alt='' />"));
        $image_tray->setDescription(_AM_SSECTION_IMAGE_ITEM_DSC);
        $sform->addElement($image_tray);
        // IMAGE UPLOAD
        $max_size = 5000000;
        $image_file_box = new XoopsFormFile(_AM_SSECTION_IMAGE_UPLOAD, "image_file", $max_size);
        $image_file_box->setExtra("size ='50'");
        $image_file_box->setDescription(_AM_SSECTION_IMAGE_UPLOAD_ITEM_DSC);
        $sform->addElement($image_file_box);
    }
    // File upload UPLOAD
    $file_box = new XoopsFormFile(smartsection_new_feature_tag() . _AM_SSECTION_ITEM_UPLOAD_FILE, "userfile", 0);
    $file_box->setDescription(_AM_SSECTION_ITEM_UPLOAD_FILE_DSC . smartsection_new_feature_tag());
    $file_box->setExtra("size ='50'");
    $sform->addElement($file_box);
    // 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
    	*/
    $uid = $itemObj->uid();
    $uid_select = new XoopsFormSelect(_AM_SSECTION_UID, 'uid', $uid, 1, false);
    $uid_select->setDescription(_AM_SSECTION_UID_DSC);
    $sql = "SELECT uid, uname FROM " . $xoopsDB->prefix('users') . " ORDER BY uname ASC";
    $result = $xoopsDB->query($sql);
    $users_array = array();
    $users_array[0] = $xoopsConfig['anonymous'];
    while ($myrow = $xoopsDB->fetchArray($result)) {
        $users_array[$myrow['uid']] = $myrow['uname'];
    }
    $uid_select->addOptionArray($users_array);
    $sform->addElement($uid_select);
    // Datesub
    $datesub = $itemObj->getVar('datesub') == 0 ? time() : $itemObj->getVar('datesub');
    $datesub_datetime = new SmartsectionFormDateTime(_AM_SSECTION_DATESUB, 'datesub', $size = 15, $datesub);
    $datesub_datetime->setDescription(_AM_SSECTION_DATESUB_DSC);
    $sform->addElement($datesub_datetime);
    // STATUS
    $options = array(_SSECTION_STATUS_PUBLISHED => _AM_SSECTION_PUBLISHED, _SSECTION_STATUS_OFFLINE => _AM_SSECTION_OFFLINE, _SSECTION_STATUS_SUBMITTED => _AM_SSECTION_SUBMITTED, _SSECTION_STATUS_REJECTED => _AM_SSECTION_REJECTED);
    $status_select = new XoopsFormSelect(_AM_SSECTION_STATUS, 'status', $new_status);
    $status_select->addOptionArray($options);
    $status_select->setDescription(_AM_SSECTION_STATUS_DSC);
    $sform->addElement($status_select);
    if (SMARTSECTION_LEVEL > 0) {
        // Short url
        $text_short_url = new XoopsFormText(_AM_SSECTION_ITEM_SHORT_URL, 'short_url', 50, 255, $itemObj->short_url('e'));
        $text_short_url->setDescription(_AM_SSECTION_ITEM_SHORT_URL_DSC);
        $sform->addElement($text_short_url);
        // Meta Keywords
        $text_meta_keywords = new XoopsFormTextArea(_AM_SSECTION_ITEM_META_KEYWORDS, 'meta_keywords', $itemObj->meta_keywords('e'), 7, 60);
        $text_meta_keywords->setDescription(_AM_SSECTION_ITEM_META_KEYWORDS_DSC);
        $sform->addElement($text_meta_keywords);
        // Meta Description
        $text_meta_description = new XoopsFormTextArea(_AM_SSECTION_ITEM_META_DESCRIPTION, 'meta_description', $itemObj->meta_description('e'), 7, 60);
        $text_meta_description->setDescription(_AM_SSECTION_ITEM_META_DESCRIPTION_DSC);
        $sform->addElement($text_meta_description);
    }
    // WEIGHT
    $sform->addElement(new XoopsFormText(_AM_SSECTION_WEIGHT, 'weight', 5, 5, $itemObj->weight()), true);
    if (SMARTSECTION_LEVEL >= 5) {
        // COMMENTS
        $addcomments_radio = new XoopsFormRadioYN(_AM_SSECTION_ALLOWCOMMENTS, 'cancomment', $itemObj->cancomment(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . '');
        $sform->addElement($addcomments_radio);
    }
    // PER ITEM PERMISSIONS
    $member_handler =& xoops_gethandler('member');
    $group_list = $member_handler->getGroupList();
    $groups_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PERMISSIONS_ITEM, 'groups[]', $itemObj->getGroups_read());
    $groups_checkbox->setDescription(_AM_SSECTION_PERMISSIONS_ITEM_DSC);
    foreach ($group_list as $group_id => $group_name) {
        if ($group_id != XOOPS_GROUP_ADMIN) {
            $groups_checkbox->addOption($group_id, $group_name);
        }
    }
    $sform->addElement($groups_checkbox);
    $p_view_checkbox = new XoopsFormCheckBox(_AM_SSECTION_PARTIAL_VIEW, 'partial_view[]', $itemObj->partial_view());
    $p_view_checkbox->setDescription(_AM_SSECTION_PARTIAL_VIEWDSC);
    foreach ($group_list as $group_id => $group_name) {
        if ($group_id != XOOPS_GROUP_ADMIN) {
            $p_view_checkbox->addOption($group_id, $group_name);
        }
    }
    $sform->addElement($p_view_checkbox);
    /*$partial_view_radio = new XoopsFormRadioYN(_AM_SSECTION_PARTIAL_VIEW, 'partial_view', $itemObj->partial_view(), ' ' . _AM_SSECTION_YES . '', ' ' . _AM_SSECTION_NO . '');
    	$partial_view_radio->setDescription(_AM_SSECTION_PARTIAL_VIEWDSC);
    	$sform->addElement($partial_view_radio);*/
    if (SMARTSECTION_LEVEL >= 5) {
        // VARIOUS OPTIONS
        $options_tray = new XoopsFormElementTray(_AM_SSECTION_OPTIONS, '<br />');
        $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $itemObj->dohtml());
        $html_checkbox->addOption(1, _AM_SSECTION_DOHTML);
        $options_tray->addElement($html_checkbox);
        $smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $itemObj->dosmiley());
        $smiley_checkbox->addOption(1, _AM_SSECTION_DOSMILEY);
        $options_tray->addElement($smiley_checkbox);
        $xcodes_checkbox = new XoopsFormCheckBox('', 'doxcode', $itemObj->doxcode());
        $xcodes_checkbox->addOption(1, _AM_SSECTION_DOXCODE);
        $options_tray->addElement($xcodes_checkbox);
        $images_checkbox = new XoopsFormCheckBox('', 'doimage', $itemObj->doimage());
        $images_checkbox->addOption(1, _AM_SSECTION_DOIMAGE);
        $options_tray->addElement($images_checkbox);
        $linebreak_checkbox = new XoopsFormCheckBox('', 'dobr', $itemObj->dobr());
        $linebreak_checkbox->addOption(1, _AM_SSECTION_DOLINEBREAK);
        $options_tray->addElement($linebreak_checkbox);
        $sform->addElement($options_tray);
    }
    // item ID
    if ($clone) {
        $itemid = 0;
    }
    $sform->addElement(new XoopsFormHidden('itemid', $itemid));
    $button_tray = new XoopsFormElementTray('', '');
    $hidden = new XoopsFormHidden('op', 'additem');
    $button_tray->addElement($hidden);
    if (!$itemid) {
        // there's no itemid? Then it's a new item
        // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SSECTION_CREATE, 'submit' ) );
        $butt_create = new XoopsFormButton('', '', _AM_SSECTION_CREATE, 'submit');
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"');
        $button_tray->addElement($butt_create);
        $butt_clear = new XoopsFormButton('', '', _AM_SSECTION_CLEAR, 'reset');
        $button_tray->addElement($butt_clear);
        $butt_cancel = new XoopsFormButton('', '', _AM_SSECTION_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
        $sform->addElement($button_tray);
        $sform->display();
        smartsection_close_collapsable('createitemtable', 'createitemicon');
    } else {
        // else, we're editing an existing item
        // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SSECTION_MODIFY, 'submit' ) );
        $butt_create = new XoopsFormButton('', '', $button_caption, 'submit');
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"');
        $button_tray->addElement($butt_create);
        $butt_cancel = new XoopsFormButton('', '', _AM_SSECTION_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
        $sform->addElement($button_tray);
        $sform->display();
        smartsection_close_collapsable('edititemtable', 'edititemicon');
    }
    if (SMARTSECTION_LEVEL >= 5) {
        smartsection_collapsableBar('pagewraptable', 'pagewrapicon', _AM_SSECTION_PAGEWRAP, _AM_SSECTION_PAGEWRAPDSC);
        $dir = smartsection_getUploadDir(true, 'content');
        if (!eregi("777", decoct(fileperms($dir)))) {
            echo "<font color='FF0000'><h4>" . _AM_SSECTION_PERMERROR . "</h4></font>";
        }
        // Upload File
        echo "<form name='form_name2' id='form_name2' action='pw_upload_file.php' method='post' enctype='multipart/form-data'>";
        echo "<table cellspacing='1' width='100%' class='outer'>";
        echo "<tr><th colspan='2'>" . _AM_SSECTION_UPLOAD_FILE . "</th></tr>";
        echo "<tr valign='top' align='left'><td class='head'>" . _AM_SSECTION_SEARCH_PW . "</td><td class='even'><input type='file' name='fileupload' id='fileupload' size='30' /></td></tr>";
        echo "<tr valign='top' align='left'><td class='head'><input type='hidden' name='MAX_FILE_SIZE' id='op' value='500000' /></td><td class='even'><input type='submit' name='submit' value='" . _AM_SSECTION_UPLOAD . "' /></td></tr>";
        echo "<input type='hidden' name='backto' value='{$smartsection_current_page}'/>";
        echo "</table>";
        echo "</form>";
        // Delete File
        $form = new XoopsThemeForm(_AM_SSECTION_DELETEFILE, "form_name", "pw_delete_file.php");
        $pWrap_select = new XoopsFormSelect(smartsection_getUploadDir(true, 'content'), "address");
        $folder = dir($dir);
        while ($file = $folder->read()) {
            if ($file != "." && $file != "..") {
                $pWrap_select->addOption($file, $file);
            }
        }
        $folder->close();
        $form->addElement($pWrap_select);
        $delfile = "delfile";
        $form->addElement(new XoopsFormHidden('op', $delfile));
        $submit = new XoopsFormButton("", "submit", _AM_SSECTION_BUTTON_DELETE, "submit");
        $form->addElement($submit);
        $form->addElement(new XoopsFormHidden('backto', $smartsection_current_page));
        $form->display();
        smartsection_close_collapsable('pagewraptable', 'pagewrapicon');
    }
    unset($hidden);
    if ($itemid != 0) {
        showfiles($itemObj);
    }
}
Exemplo n.º 7
0
$summary_text->setDescription(_MD_SSECTION_SUMMARY_DSC);
$sform->addElement($summary_text, false);
// BODY
//$body_text = new XoopsFormDhtmlTextArea(_MD_SSECTION_BODY, 'body', '', 15, 60);
$body_text = smartsection_getEditor(_MD_SSECTION_BODY_REQ, 'body', $itemObj->getVar('body'));
$body_text->setDescription(_MD_SSECTION_BODY_DSC);
$sform->addElement($body_text);
// IMAGE
$image_array =& XoopsLists::getImgListAsArray(smartsection_getImageDir('item'));
$image_select = new XoopsFormSelect('', 'image', $itemObj->image());
//$image_select -> addOption ('-1', '---------------');
$image_select->addOptionArray($image_array);
$image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/smartsection/images/item/' . "\", \"\", \"" . XOOPS_URL . "\")'");
$image_tray = new XoopsFormElementTray(_MD_SSECTION_IMAGE_ITEM, '&nbsp;');
$image_tray->addElement($image_select);
$image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . smartsection_getImageDir('item', false) . $itemObj->image() . "' name='image3' id='image3' alt='' />"));
$image_tray->setDescription(_MD_SSECTION_IMAGE_ITEM_DSC);
$sform->addElement($image_tray);
// IMAGE UPLOAD
$max_size = 5000000;
$file_box = new XoopsFormFile(_MD_SSECTION_IMAGE_UPLOAD, "image_file", $max_size);
$file_box->setExtra("size ='45'");
$file_box->setDescription(_MD_SSECTION_IMAGE_UPLOAD_ITEM_DSC);
$sform->addElement($file_box);
if (SMARTSECTION_LEVEL > 0) {
    // VARIOUS OPTIONS
    $options_tray = new XoopsFormElementTray(_AM_SSECTION_OPTIONS, '<br />');
    $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $itemObj->dohtml());
    $html_checkbox->addOption(1, _AM_SSECTION_DOHTML);
    $options_tray->addElement($html_checkbox);
    $smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $itemObj->dosmiley());