/**
 * @param $errors
 *
 * @return bool
 */
function publisher_pagewrap_upload(&$errors)
{
    //    include_once PUBLISHER_ROOT_PATH . '/class/uploader.php';
    xoops_load('XoopsMediaUploader');
    $publisher =& PublisherPublisher::getInstance();
    $postField = 'fileupload';
    $maxFileSize = $publisher->getConfig('maximum_filesize');
    $maxImageWidth = $publisher->getConfig('maximum_image_width');
    $maxImageHeight = $publisher->getConfig('maximum_image_height');
    if (!is_dir(publisherGetUploadDir(true, 'content'))) {
        mkdir(publisherGetUploadDir(true, 'content'), 0757);
    }
    $allowedMimeTypes = array('text/html', 'text/plain', 'application/xhtml+xml');
    $uploader = new XoopsMediaUploader(publisherGetUploadDir(true, 'content') . '/', $allowedMimeTypes, $maxFileSize, $maxImageWidth, $maxImageHeight);
    if ($uploader->fetchMedia($postField)) {
        $uploader->setTargetFileName($uploader->getMediaName());
        if ($uploader->upload()) {
            return true;
        } else {
            $errors = array_merge($errors, $uploader->getErrors(false));
            return false;
        }
    } else {
        $errors = array_merge($errors, $uploader->getErrors(false));
        return false;
    }
}
Esempio n. 2
0
function publisher_latest_files_show($options)
{
    $publisher = PublisherPublisher::getInstance();
    /**
     * $options[0] : Category
     * $options[1] : Sort order - datesub | counter
     * $options[2] : Number of files to display
     * $oprions[3] : bool TRUE to link to the file download, FALSE to link to the article
     */
    $block = array();
    $sort = $options[1];
    $order = publisher_getOrderBy($sort);
    $limit = $options[2];
    $directDownload = $options[3];
    // creating the files objects
    $filesObj = $publisher->getHandler('file')->getAllFiles(0, _PUBLISHER_STATUS_FILE_ACTIVE, $limit, 0, $sort, $order, explode(',', $options[0]));
    foreach ($filesObj as $fileObj) {
        $aFile = array();
        $aFile['link'] = $directDownload ? $fileObj->getFileLink() : $fileObj->getItemLink();
        if ($sort == "datesub") {
            $aFile['new'] = $fileObj->datesub();
        } elseif ($sort == "counter") {
            $aFile['new'] = $fileObj->counter();
        } elseif ($sort == "weight") {
            $aFile['new'] = $fileObj->weight();
        }
        $block['files'][] = $aFile;
    }
    return $block;
}
Esempio n. 3
0
 /**
  * Delete all permission for a specific item
  *  deletePermissions()
  *
  * @param integer $itemid : id of the item for which to delete the permissions
  * @param string  $gperm_name
  *
  * @return boolean : TRUE if the no errors occured
  */
 public function deletePermissions($itemid, $gperm_name)
 {
     $result = true;
     $gperm_handler = xoops_gethandler('groupperm');
     $gperm_handler->deleteByModule($this->publisher->getModule()->getVar('mid'), $gperm_name, $itemid);
     return $result;
 }
Esempio n. 4
0
/**
 * @param $options
 *
 * @return array
 */
function publisher_items_menu_show($options)
{
    $block = array();
    $publisher =& PublisherPublisher::getInstance();
    // Getting all top cats
    $blockCategoriesObj =& $publisher->getHandler('category')->getCategories(0, 0, 0);
    if (count($blockCategoriesObj) == 0) {
        return $block;
    }
    // Are we in Publisher ?
    $block['inModule'] = isset($GLOBALS['xoopsModule']) && $GLOBALS['xoopsModule']->getVar('dirname') == $publisher->getModule()->getVar('dirname');
    $catLinkClass = 'menuMain';
    $categoryid = 0;
    if ($block['inModule']) {
        // Are we in a category and if yes, in which one ?
        $categoryid = XoopsRequest::getInt('categoryid', 0, 'GET');
        if ($categoryid != 0) {
            // if we are in a category, then the $categoryObj is already defined in publisher/category.php
            global $categoryObj;
            $block['currentcat'] = $categoryObj->getCategoryLink('menuTop');
            $catLinkClass = 'menuSub';
        }
    }
    foreach ($blockCategoriesObj as $catid => $blockCategoryObj) {
        if ($catid != $categoryid) {
            $block['categories'][$catid]['categoryLink'] = $blockCategoryObj->getCategoryLink($catLinkClass);
        }
    }
    return $block;
}
Esempio n. 5
0
/**
 * @param        $queryarray
 * @param        $andor
 * @param        $limit
 * @param        $offset
 * @param        $userid
 * @param array  $categories
 * @param int    $sortby
 * @param string $searchin
 * @param string $extra
 *
 * @return array
 */
function publisher_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = '', $extra = '')
{
    $publisher =& PublisherPublisher::getInstance();
    $ret = array();
    if ($queryarray == '' || count($queryarray) == 0) {
        $hightlightKey = '';
    } else {
        $keywords = implode('+', $queryarray);
        $hightlightKey = '&keywords=' . $keywords;
    }
    $itemsObjs =& $publisher->getHandler('item')->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra);
    $withCategoryPath = $publisher->getConfig('search_cat_path');
    //xoops_load("xoopslocal");
    $usersIds = array();
    foreach ($itemsObjs as $obj) {
        $item['image'] = 'assets/images/item_icon.gif';
        $item['link'] = $obj->getItemUrl();
        $item['link'] .= !empty($hightlightKey) && strpos($item['link'], '.php?') === false ? '?' . ltrim($hightlightKey, '&') : $hightlightKey;
        if ($withCategoryPath) {
            $item['title'] = $obj->getCategoryPath(false) . ' > ' . $obj->getTitle();
        } else {
            $item['title'] = $obj->getTitle();
        }
        $item['time'] = $obj->getVar('datesub');
        //must go has unix timestamp
        $item['uid'] = $obj->uid();
        //"Fulltext search/highlight
        $text = $obj->getBody();
        $sanitizedText = '';
        $textLower = strtolower($text);
        $queryarray = is_array($queryarray) ? $queryarray : array($queryarray);
        if ($queryarray[0] != '' && count($queryarray) > 0) {
            foreach ($queryarray as $query) {
                $pos = strpos($textLower, strtolower($query));
                //xoops_local("strpos", $textLower, strtolower($query));
                $start = max($pos - 100, 0);
                $length = strlen($query) + 200;
                //xoops_local("strlen", $query) + 200;
                $context = $obj->highlight(xoops_substr($text, $start, $length, ' [...]'), $query);
                $sanitizedText .= '<p>[...] ' . $context . '</p>';
            }
        }
        //End of highlight
        $item['text'] = $sanitizedText;
        $item['author'] = $obj->author_alias();
        $item['datesub'] = $obj->getDatesub($publisher->getConfig('format_date'));
        $usersIds[$obj->uid()] = $obj->uid();
        $ret[] = $item;
        unset($item, $sanitizedText);
    }
    xoops_load('XoopsUserUtility');
    $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true);
    foreach ($ret as $key => $item) {
        if ($item['author'] == '') {
            $ret[$key]['author'] = isset($usersNames[$item['uid']]) ? $usersNames[$item['uid']] : '';
        }
    }
    unset($usersNames, $usersIds);
    return $ret;
}
Esempio n. 6
0
function publisher_seo_genUrl($op, $id, $short_url = "")
{
    $publisher = PublisherPublisher::getInstance();
    if ($publisher->getConfig('seo_url_rewrite') != 'none') {
        if (!empty($short_url)) {
            $short_url = $short_url . '.html';
        }
        if ($publisher->getConfig('seo_url_rewrite') == 'htaccess') {
            // generate SEO url using htaccess
            return XOOPS_URL . '/' . $publisher->getConfig('seo_module_name') . ".{$op}.{$id}/{$short_url}";
        } else {
            if ($publisher->getConfig('seo_url_rewrite') == 'path-info') {
                // generate SEO url using path-info
                return PUBLISHER_URL . "/index.php/{$op}.{$id}/{$short_url}";
            } else {
                die('Unknown SEO method.');
            }
        }
    } else {
        // generate classic url
        switch ($op) {
            case 'category':
                return PUBLISHER_URL . "/{$op}.php?categoryid={$id}";
            case 'item':
            case 'print':
                return PUBLISHER_URL . "/{$op}.php?itemid={$id}";
            default:
                die('Unknown SEO operation.');
        }
    }
}
Esempio n. 7
0
function publisher_date_to_date_show($options)
{
    $myts = MyTextSanitizer::getInstance();
    $publisher = PublisherPublisher::getInstance();
    $block = array();
    $criteria = new CriteriaCompo();
    $criteria->add(new Criteria('datesub', strtotime($options[0]), '>'));
    $criteria->add(new Criteria('datesub', strtotime($options[1]), '<'));
    $criteria->setSort('datesub');
    $criteria->setOrder('DESC');
    // creating the ITEM objects that belong to the selected category
    $itemsObj = $publisher->getHandler('item')->getObjects($criteria);
    $totalItems = count($itemsObj);
    if ($itemsObj) {
        for ($i = 0; $i < $totalItems; $i++) {
            $newItems['itemid'] = $itemsObj[$i]->itemid();
            $newItems['title'] = $itemsObj[$i]->title();
            $newItems['categoryname'] = $itemsObj[$i]->getCategoryName();
            $newItems['categoryid'] = $itemsObj[$i]->categoryid();
            $newItems['date'] = $itemsObj[$i]->datesub();
            $newItems['poster'] = $itemsObj[$i]->linkedPosterName();
            $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65);
            $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink();
            $block['items'][] = $newItems;
        }
        $block['lang_title'] = _MB_PUBLISHER_ITEMS;
        $block['lang_category'] = _MB_PUBLISHER_CATEGORY;
        $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY;
        $block['lang_date'] = _MB_PUBLISHER_DATE;
        $modulename = $myts->displayTarea($publisher->getModule()->getVar('name'));
        $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . " " . $modulename;
        $block['lang_articles_from_to'] = sprintf(_MB_PUBLISHER_ARTICLES_FROM_TO, $options[0], $options[1]);
    }
    return $block;
}
Esempio n. 8
0
 /**
  * @param $target
  */
 public function __construct(&$target)
 {
     $this->publisher =& PublisherPublisher::getInstance();
     $this->targetObject =& $target;
     parent::__construct(_AM_PUBLISHER_UPLOAD_FILE, 'form', xoops_getenv('PHP_SELF'));
     $this->setExtra('enctype="multipart/form-data"');
     $this->createElements();
     $this->createButtons();
 }
Esempio n. 9
0
 /**
  * @return string
  */
 public function createMetaKeywords()
 {
     $keywords = $this->findMetaKeywords($this->originalTitle . ' ' . $this->description, $this->minChar);
     $moduleKeywords = $this->publisher->getConfig('seo_meta_keywords');
     if ($moduleKeywords != '') {
         $moduleKeywords = explode(',', $moduleKeywords);
         $keywords = array_merge($keywords, array_map('trim', $moduleKeywords));
     }
     $ret = implode(',', $keywords);
     return $ret;
 }
Esempio n. 10
0
function publisher_items_random_item_show($options)
{
    $block = array();
    $publisher = PublisherPublisher::getInstance();
    // creating the ITEM object
    $itemsObj = $publisher->getHandler('item')->getRandomItem('', array(_PUBLISHER_STATUS_PUBLISHED));
    if (!is_object($itemsObj)) {
        return $block;
    }
    $block['content'] = $itemsObj->getBlockSummary(300, true);
    //show complete summary  but truncate to 300 if only body available
    $block['id'] = $itemsObj->itemid();
    $block['url'] = $itemsObj->getItemUrl();
    $block['lang_fullitem'] = _MB_PUBLISHER_FULLITEM;
    return $block;
}
Esempio n. 11
0
/**
 * @param $options
 *
 * @return array
 */
function publisher_items_recent_show($options)
{
    $publisher =& PublisherPublisher::getInstance();
    $myts = MyTextSanitizer::getInstance();
    $block = array();
    $selectedcatids = explode(',', $options[0]);
    if (in_array(0, $selectedcatids)) {
        $allcats = true;
    } else {
        $allcats = false;
    }
    $sort = $options[1];
    $order = publisherGetOrderBy($sort);
    $limit = $options[2];
    $start = 0;
    // creating the ITEM objects that belong to the selected category
    if ($allcats) {
        $criteria = null;
    } else {
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN'));
    }
    $itemsObj =& $publisher->getHandler('item')->getItems($limit, $start, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true);
    $totalItems = count($itemsObj);
    if ($itemsObj && $totalItems > 1) {
        for ($i = 0; $i < $totalItems; ++$i) {
            $newItems['itemid'] = $itemsObj[$i]->itemid();
            $newItems['title'] = $itemsObj[$i]->getTitle();
            $newItems['categoryname'] = $itemsObj[$i]->getCategoryName();
            $newItems['categoryid'] = $itemsObj[$i]->categoryid();
            $newItems['date'] = $itemsObj[$i]->getDatesub();
            $newItems['poster'] = $itemsObj[$i]->getLinkedPosterName();
            $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65);
            $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink();
            $block['items'][] = $newItems;
        }
        $block['lang_title'] = _MB_PUBLISHER_ITEMS;
        $block['lang_category'] = _MB_PUBLISHER_CATEGORY;
        $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY;
        $block['lang_date'] = _MB_PUBLISHER_DATE;
        $modulename = $myts->displayTarea($publisher->getModule()->getVar('name'));
        $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . ' ' . $modulename;
    }
    return $block;
}
Esempio n. 12
0
 /**
  * @param null|array $allowed_mimetypes
  * @param bool       $force
  * @param bool       $doupload
  *
  * @return bool
  */
 public function store($allowed_mimetypes = null, $force = true, $doupload = true)
 {
     if ($this->isNew()) {
         $errors = array();
         if ($doupload) {
             $ret = $this->storeUpload('item_upload_file', $allowed_mimetypes, $errors);
         } else {
             $ret = true;
         }
         if (!$ret) {
             foreach ($errors as $error) {
                 $this->setErrors($error);
             }
             return false;
         }
     }
     return $this->publisher->getHandler('file')->insert($this, $force);
 }
Esempio n. 13
0
function publisher_category_items_sel_show($options)
{
    $publisher = PublisherPublisher::getInstance();
    $block = array();
    $categories = $publisher->getHandler('category')->getCategories(0, 0, -1);
    if (count($categories) == 0) {
        return $block;
    }
    $selectedcatids = explode(',', $options[0]);
    $sort = $options[1];
    $order = publisher_getOrderBy($sort);
    $limit = $options[2];
    $start = 0;
    // creating the ITEM objects that belong to the selected category
    $block['categories'] = array();
    foreach ($categories as $catID => $catObj) {
        if (!in_array(0, $selectedcatids) && !in_array($catID, $selectedcatids)) {
            continue;
        }
        $criteria = new Criteria('categoryid', $catID);
        $items = $publisher->getHandler('item')->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true);
        unset($criteria);
        if (count($items) == 0) {
            continue;
        }
        $item['title'] = $catObj->name();
        $item['itemurl'] = 'none';
        $block['categories'][$catID]['items'][] = $item;
        foreach ($items as $itemObj) {
            $item['title'] = $itemObj->title(isset($options[3]) ? $options[3] : 0);
            $item['itemurl'] = $itemObj->getItemUrl();
            $block['categories'][$catID]['items'][] = $item;
        }
        $block['categories'][$catID]['name'] = $catObj->name();
    }
    unset($items, $categories);
    if (count($block['categories']) == 0) {
        return $block;
    }
    return $block;
}
Esempio n. 14
0
function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
{
    $publisher = PublisherPublisher::getInstance();
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    // if there is a parameter, and the id exists, retrieve data: we're editing a file
    if ($fileid != 0) {
        // Creating the File object
        $fileObj = $publisher->getHandler('file')->get($fileid);
        if ($fileObj->notLoaded()) {
            redirect_header("javascript:history.go(-1)", 1, _AM_PUBLISHER_NOFILESELECTED);
            exit;
        }
        if ($showmenu) {
            //publisher_adminMenu(2, _AM_PUBLISHER_FILE . " > " . _AM_PUBLISHER_EDITING);
        }
        echo "<br />\n";
        echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 06 0 0; '>" . _AM_PUBLISHER_FILE_EDITING . "</span>";
        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_PUBLISHER_FILE_EDITING_DSC . "</span>";
        publisher_openCollapsableBar('editfile', 'editfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
    } else {
        // there's no parameter, so we're adding an item
        $fileObj = $publisher->getHandler('file')->create();
        $fileObj->setVar('itemid', $itemid);
        if ($showmenu) {
            //publisher_adminMenu(2, _AM_PUBLISHER_FILE . " > " . _AM_PUBLISHER_FILE_ADD);
        }
        echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 06 0 0; '>" . _AM_PUBLISHER_FILE_ADDING . "</span>";
        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_PUBLISHER_FILE_ADDING_DSC . "</span>";
        publisher_openCollapsableBar('addfile', 'addfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
    }
    // FILES UPLOAD FORM
    $files_form = $fileObj->getForm();
    $files_form->display();
    if ($fileid != 0) {
        publisher_closeCollapsableBar('editfile', 'editfileicon');
    } else {
        publisher_closeCollapsableBar('addfile', 'addfileicon');
    }
}
Esempio n. 15
0
function publisher_items_columns_show($options)
{
    //    global $xoTheme;
    $publisher =& PublisherPublisher::getInstance();
    //Column Settings
    $optNumColumns = isset($options[0]) ? (int) $options[0] : '2';
    $selCategories = isset($options[1]) ? explode(',', $options[1]) : array();
    $optCatItems = (int) $options[2];
    $optCatTruncate = isset($options[3]) ? (int) $options[3] : '0';
    $block = array();
    $block['lang_reads'] = _MB_PUBLISHER_READS;
    $block['lang_comments'] = _MB_PUBLISHER_COMMENTS;
    $block['lang_readmore'] = _MB_PUBLISHER_READMORE;
    $selCategoriesObj = array();
    //get permited categories only once
    $categoriesObj =& $publisher->getHandler('category')->getCategories(0, 0, -1);
    //if not selected 'all', let's get the selected ones
    if (!in_array(0, $selCategories)) {
        foreach ($categoriesObj as $key => $value) {
            if (in_array($key, $selCategories)) {
                $selCategoriesObj[$key] = $value;
            }
        }
    } else {
        $selCategoriesObj =& $categoriesObj;
    }
    unset($key, $value);
    $ccount = count($selCategoriesObj);
    if ($ccount === 0) {
        return false;
    }
    if ($ccount < $optNumColumns) {
        $optNumColumns = $ccount;
    }
    $k = 0;
    $columns = array();
    foreach ($selCategoriesObj as $categoryId => $mainitemCatObj) {
        $categoryItemsObj =& $publisher->getHandler('item')->getAllPublished($optCatItems, 0, $categoryId);
        $scount = count($categoryItemsObj);
        if ($scount > 0 && is_array($categoryItemsObj)) {
            reset($categoryItemsObj);
            //First Item
            list($itemid, $thisitem) = each($categoryItemsObj);
            $mainitem['item_title'] = $thisitem->getTitle();
            $mainitem['item_cleantitle'] = strip_tags($thisitem->getTitle());
            $mainitem['item_link'] = $thisitem->itemid();
            $mainitem['itemurl'] = $thisitem->getItemUrl();
            $mainImage = $thisitem->getMainImage();
            // check to see if GD function exist
            $mainitem['item_image'] = $mainImage['image_path'];
            if (!empty($mainImage['image_path']) && function_exists('imagecreatetruecolor')) {
                $mainitem['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . '&amp;w=100';
            }
            $mainitem['item_summary'] = $thisitem->getBlockSummary($optCatTruncate);
            $mainitem['item_cat_name'] = $mainitemCatObj->name();
            $mainitem['item_cat_description'] = $mainitemCatObj->description() !== '' ? $mainitemCatObj->description() : $mainitemCatObj->name();
            $mainitem['item_cat_link'] = $mainitemCatObj->getCategoryLink();
            $mainitem['categoryurl'] = $mainitemCatObj->getCategoryUrl();
            //The Rest
            if ($scount > 1) {
                while ((list($itemid, $thisitem) = each($categoryItemsObj)) !== false) {
                    $subitem['title'] = $thisitem->getTitle();
                    $subitem['cleantitle'] = strip_tags($thisitem->getTitle());
                    $subitem['link'] = $thisitem->getItemLink();
                    $subitem['itemurl'] = $thisitem->getItemUrl();
                    $subitem['summary'] = $thisitem->getBlockSummary($optCatTruncate);
                    $mainitem['subitem'][] = $subitem;
                    unset($subitem);
                }
            }
            $columns[$k][] = $mainitem;
            unset($thisitem, $mainitem);
            ++$k;
            if ($k == $optNumColumns) {
                $k = 0;
            }
        }
    }
    unset($categoryId, $mainitemCatObj);
    $block['template'] = $options[4];
    $block['columns'] = $columns;
    $block['columnwidth'] = (int) (100 / $optNumColumns);
    $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME . '/assets/css/publisher.css');
    return $block;
}
Esempio n. 16
0
 /**
  * @param array  $queryarray
  * @param string $andor
  * @param int    $limit
  * @param int    $offset
  * @param int    $userid
  * @param array  $categories
  * @param int    $sortby
  * @param string $searchin
  * @param string $extra
  *
  * @return array
  */
 public function getItemsFromSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0, $categories = array(), $sortby = 0, $searchin = '', $extra = '')
 {
     //        global $publisherIsAdmin;
     $ret = array();
     $gpermHandler =& xoops_getHandler('groupperm');
     $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
     $searchin = empty($searchin) ? array('title', 'body', 'summary') : (is_array($searchin) ? $searchin : array($searchin));
     if (in_array('all', $searchin) || count($searchin) == 0) {
         $searchin = array('title', 'subtitle', 'body', 'summary', 'meta_keywords');
     }
     if (is_array($userid) && count($userid) > 0) {
         $userid = array_map('intval', $userid);
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
     } elseif (is_numeric($userid) && $userid > 0) {
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('uid', $userid), 'OR');
     }
     $count = count($queryarray);
     if (is_array($queryarray) && $count > 0) {
         $criteriaKeywords = new CriteriaCompo();
         $elementCount = count($queryarray);
         for ($i = 0; $i < $elementCount; ++$i) {
             $criteriaKeyword = new CriteriaCompo();
             if (in_array('title', $searchin)) {
                 $criteriaKeyword->add(new Criteria('title', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('subtitle', $searchin)) {
                 $criteriaKeyword->add(new Criteria('subtitle', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('body', $searchin)) {
                 $criteriaKeyword->add(new Criteria('body', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('summary', $searchin)) {
                 $criteriaKeyword->add(new Criteria('summary', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('meta_keywords', $searchin)) {
                 $criteriaKeyword->add(new Criteria('meta_keywords', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             $criteriaKeywords->add($criteriaKeyword, $andor);
             unset($criteriaKeyword);
         }
     }
     if (!$GLOBALS['publisherIsAdmin'] && count($categories) > 0) {
         $criteriaPermissions = new CriteriaCompo();
         // Categories for which user has access
         $categoriesGranted = $gpermHandler->getItemIds('category_read', $groups, $this->publisher->getModule()->getVar('mid'));
         if (count($categories) > 0) {
             $categoriesGranted = array_intersect($categoriesGranted, $categories);
         }
         if (count($categoriesGranted) == 0) {
             return $ret;
         }
         $grantedCategories = new Criteria('categoryid', '(' . implode(',', $categoriesGranted) . ')', 'IN');
         $criteriaPermissions->add($grantedCategories, 'AND');
     } elseif (count($categories) > 0) {
         $criteriaPermissions = new CriteriaCompo();
         $grantedCategories = new Criteria('categoryid', '(' . implode(',', $categories) . ')', 'IN');
         $criteriaPermissions->add($grantedCategories, 'AND');
     }
     $criteriaItemsStatus = new CriteriaCompo();
     $criteriaItemsStatus->add(new Criteria('status', PublisherConstants::PUBLISHER_STATUS_PUBLISHED));
     $criteria = new CriteriaCompo();
     if (!empty($criteriaUser)) {
         $criteria->add($criteriaUser, 'AND');
     }
     if (!empty($criteriaKeywords)) {
         $criteria->add($criteriaKeywords, 'AND');
     }
     if (!empty($criteriaPermissions)) {
         $criteria->add($criteriaPermissions);
     }
     if (!empty($criteriaItemsStatus)) {
         $criteria->add($criteriaItemsStatus, 'AND');
     }
     $criteria->setLimit($limit);
     $criteria->setStart($offset);
     if (empty($sortby)) {
         $sortby = 'datesub';
     }
     $criteria->setSort($sortby);
     $order = 'ASC';
     if ($sortby === 'datesub') {
         $order = 'DESC';
     }
     $criteria->setOrder($order);
     $ret =& $this->getObjects($criteria);
     return $ret;
 }
Esempio n. 17
0
 * @since           1.0
 * @author          trabis <*****@*****.**>
 * @version         $Id$
 */
defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined");
define("PUBLISHER_DIRNAME", basename(dirname(dirname(__FILE__))));
define("PUBLISHER_URL", XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME);
define("PUBLISHER_IMAGES_URL", PUBLISHER_URL . '/images');
define("PUBLISHER_ADMIN_URL", PUBLISHER_URL . '/admin');
define("PUBLISHER_UPLOADS_URL", XOOPS_URL . '/uploads/' . PUBLISHER_DIRNAME);
define("PUBLISHER_ROOT_PATH", XOOPS_ROOT_PATH . '/modules/' . PUBLISHER_DIRNAME);
define("PUBLISHER_UPLOADS_PATH", XOOPS_ROOT_PATH . '/uploads/' . PUBLISHER_DIRNAME);
xoops_loadLanguage('common', PUBLISHER_DIRNAME);
include_once PUBLISHER_ROOT_PATH . '/include/functions.php';
include_once PUBLISHER_ROOT_PATH . '/include/constants.php';
include_once PUBLISHER_ROOT_PATH . '/include/seo_functions.php';
include_once PUBLISHER_ROOT_PATH . '/class/metagen.php';
include_once PUBLISHER_ROOT_PATH . '/class/session.php';
include_once PUBLISHER_ROOT_PATH . '/class/publisher.php';
include_once PUBLISHER_ROOT_PATH . '/class/request.php';
$debug = true;
$publisher = PublisherPublisher::getInstance($debug);
//This is needed or it will not work in blocks.
global $publisher_isAdmin;
// Load only if module is installed
if (is_object($publisher->getModule())) {
    // Find if the user is admin of the module
    $publisher_isAdmin = publisher_userIsAdmin();
    // get current page
    $publisher_current_page = publisher_getCurrentPage();
}
Esempio n. 18
0
function publisher_editItem($showmenu = false, $itemid = 0, $clone = false)
{
    $publisher = PublisherPublisher::getInstance();
    global $publisher_current_page, $xoopsUser;
    xoops_load('XoopsFormLoader');
    $formTpl = new XoopsTpl();
    //publisher_submit.html
    // if there is a parameter, and the id exists, retrieve data: we're editing a item
    if ($itemid != 0) {
        // Creating the ITEM object
        $itemObj = $publisher->getHandler('item')->get($itemid);
        if (!$itemObj) {
            redirect_header("item.php", 1, _AM_PUBLISHER_NOITEMSELECTED);
            exit;
        }
        if ($clone) {
            $itemObj->setNew();
            $itemObj->setVar('itemid', 0);
            $itemObj->setVar('status', _PUBLISHER_STATUS_NOTSET);
            $itemObj->setVar('datesub', time());
        }
        switch ($itemObj->status()) {
            case _PUBLISHER_STATUS_SUBMITTED:
                $breadcrumb_action1 = _CO_PUBLISHER_SUBMITTED;
                $breadcrumb_action2 = _AM_PUBLISHER_APPROVING;
                $page_title = _AM_PUBLISHER_SUBMITTED_TITLE;
                $page_info = _AM_PUBLISHER_SUBMITTED_INFO;
                $button_caption = _AM_PUBLISHER_APPROVE;
                $new_status = _PUBLISHER_STATUS_PUBLISHED;
                break;
            case _PUBLISHER_STATUS_PUBLISHED:
                $breadcrumb_action1 = _CO_PUBLISHER_PUBLISHED;
                $breadcrumb_action2 = _AM_PUBLISHER_EDITING;
                $page_title = _AM_PUBLISHER_PUBLISHEDEDITING;
                $page_info = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
                $button_caption = _AM_PUBLISHER_MODIFY;
                $new_status = _PUBLISHER_STATUS_PUBLISHED;
                break;
            case _PUBLISHER_STATUS_OFFLINE:
                $breadcrumb_action1 = _CO_PUBLISHER_OFFLINE;
                $breadcrumb_action2 = _AM_PUBLISHER_EDITING;
                $page_title = _AM_PUBLISHER_OFFLINEEDITING;
                $page_info = _AM_PUBLISHER_OFFLINEEDITING_INFO;
                $button_caption = _AM_PUBLISHER_MODIFY;
                $new_status = _PUBLISHER_STATUS_OFFLINE;
                break;
            case _PUBLISHER_STATUS_REJECTED:
                $breadcrumb_action1 = _CO_PUBLISHER_REJECTED;
                $breadcrumb_action2 = _AM_PUBLISHER_REJECTED;
                $page_title = _AM_PUBLISHER_REJECTED_EDIT;
                $page_info = _AM_PUBLISHER_REJECTED_EDIT_INFO;
                $button_caption = _AM_PUBLISHER_MODIFY;
                $new_status = _PUBLISHER_STATUS_REJECTED;
                break;
            case _PUBLISHER_STATUS_NOTSET:
                // Then it's a clone...
                $breadcrumb_action1 = _AM_PUBLISHER_ITEMS;
                $breadcrumb_action2 = _AM_PUBLISHER_CLONE_NEW;
                $button_caption = _AM_PUBLISHER_CREATE;
                $new_status = _PUBLISHER_STATUS_PUBLISHED;
                $page_title = _AM_PUBLISHER_ITEM_DUPLICATING;
                $page_info = _AM_PUBLISHER_ITEM_DUPLICATING_DSC;
                break;
            case "default":
            default:
                $breadcrumb_action1 = _AM_PUBLISHER_ITEMS;
                $breadcrumb_action2 = _AM_PUBLISHER_EDITING;
                $page_title = _AM_PUBLISHER_PUBLISHEDEDITING;
                $page_info = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
                $button_caption = _AM_PUBLISHER_MODIFY;
                $new_status = _PUBLISHER_STATUS_PUBLISHED;
                break;
        }
        $categoryObj = $itemObj->category();
        if ($showmenu) {
            //publisher_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        echo "<br />\n";
        publisher_openCollapsableBar('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_PUBLISHER_CLONE_ITEM . "'>&nbsp;&nbsp;";
            echo "</div></form>";
        }
    } else {
        // there's no parameter, so we're adding an item
        $itemObj = $publisher->getHandler('item')->create();
        $itemObj->setVarsFromRequest();
        $categoryObj = $publisher->getHandler('category')->create();
        $breadcrumb_action1 = _AM_PUBLISHER_ITEMS;
        $breadcrumb_action2 = _AM_PUBLISHER_CREATINGNEW;
        $button_caption = _AM_PUBLISHER_CREATE;
        $new_status = _PUBLISHER_STATUS_PUBLISHED;
        if ($showmenu) {
            //publisher_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        $sel_categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0;
        $categoryObj->setVar('categoryid', $sel_categoryid);
        publisher_openCollapsableBar('createitemtable', 'createitemicon', _AM_PUBLISHER_ITEM_CREATING, _AM_PUBLISHER_ITEM_CREATING_DSC);
    }
    $sform = $itemObj->getForm(_AM_PUBLISHER_ITEMS);
    $sform->assign($formTpl);
    $formTpl->display('db:publisher_submit.html');
    publisher_closeCollapsableBar('edititemtable', 'edititemicon');
    publisher_openCollapsableBar('pagewraptable', 'pagewrapicon', _AM_PUBLISHER_PAGEWRAP, _AM_PUBLISHER_PAGEWRAPDSC);
    $dir = publisher_getUploadDir(true, 'content');
    if (!preg_match('/777/i', decoct(fileperms($dir)))) {
        echo "<font color='FF0000'><h4>" . _AM_PUBLISHER_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_PUBLISHER_UPLOAD_FILE . "</th></tr>";
    echo "<tr valign='top' align='left'><td class='head'>" . _AM_PUBLISHER_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_PUBLISHER_UPLOAD . "' /></td></tr>";
    echo "<input type='hidden' name='backto' value='{$publisher_current_page}'/>";
    echo "</table>";
    echo "</form>";
    // Delete File
    $form = new XoopsThemeForm(_CO_PUBLISHER_DELETEFILE, "form_name", "pw_delete_file.php");
    $pWrap_select = new XoopsFormSelect(publisher_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_PUBLISHER_BUTTON_DELETE, "submit");
    $form->addElement($submit);
    $form->addElement(new XoopsFormHidden('backto', $publisher_current_page));
    $form->display();
    publisher_closeCollapsableBar('pagewraptable', 'pagewrapicon');
}
Esempio n. 19
0
/**
 * @param  int $itemId
 * @return string
 */
function publisherRatingBar($itemId)
{
    $publisher =& PublisherPublisher::getInstance();
    $ratingUnitWidth = 30;
    $units = 5;
    $criteria = new Criteria('itemid', $itemId);
    $ratingObjs =& $publisher->getHandler('rating')->getObjects($criteria);
    unset($criteria);
    $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
    $count = count($ratingObjs);
    $currentRating = 0;
    $voted = false;
    $ip = getenv('REMOTE_ADDR');
    $rating1 = $rating2 = $ratingWidth = 0;
    foreach ($ratingObjs as $ratingObj) {
        $currentRating += $ratingObj->getVar('rate');
        if ($ratingObj->getVar('ip') == $ip || $uid > 0 && $uid == $ratingObj->getVar('uid')) {
            $voted = true;
        }
    }
    $tense = $count == 1 ? _MD_PUBLISHER_VOTE_VOTE : _MD_PUBLISHER_VOTE_VOTES;
    //plural form votes/vote
    // now draw the rating bar
    if ($count != 0) {
        $ratingWidth = number_format($currentRating / $count, 2) * $ratingUnitWidth;
        $rating1 = number_format($currentRating / $count, 1);
        $rating2 = number_format($currentRating / $count, 2);
    }
    $groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
    $gpermHandler =& $publisher->getHandler('groupperm');
    if (!$gpermHandler->checkRight('global', PublisherConstants::PUBLISHER_RATE, $groups, $publisher->getModule()->getVar('mid'))) {
        $staticRater = array();
        $staticRater[] .= "\n" . '<div class="publisher_ratingblock">';
        $staticRater[] .= '<div id="unit_long' . $itemId . '">';
        $staticRater[] .= '<div id="unit_ul' . $itemId . '" class="publisher_unit-rating" style="width:' . $ratingUnitWidth * $units . 'px;">';
        $staticRater[] .= '<div class="publisher_current-rating" style="width:' . $ratingWidth . 'px;">' . _MD_PUBLISHER_VOTE_RATING . ' ' . $rating2 . '/' . $units . '</div>';
        $staticRater[] .= '</div>';
        $staticRater[] .= '<div class="publisher_static">' . _MD_PUBLISHER_VOTE_RATING . ': <strong> ' . $rating1 . '</strong>/' . $units . ' (' . $count . ' ' . $tense . ') <br /><em>' . _MD_PUBLISHER_VOTE_DISABLE . '</em></div>';
        $staticRater[] .= '</div>';
        $staticRater[] .= '</div>' . "\n\n";
        return implode("\n", $staticRater);
    } else {
        $rater = '';
        $rater .= '<div class="publisher_ratingblock">';
        $rater .= '<div id="unit_long' . $itemId . '">';
        $rater .= '<div id="unit_ul' . $itemId . '" class="publisher_unit-rating" style="width:' . $ratingUnitWidth * $units . 'px;">';
        $rater .= '<div class="publisher_current-rating" style="width:' . $ratingWidth . 'px;">' . _MD_PUBLISHER_VOTE_RATING . ' ' . $rating2 . '/' . $units . '</div>';
        for ($ncount = 1; $ncount <= $units; ++$ncount) {
            // loop from 1 to the number of units
            if (!$voted) {
                // if the user hasn't yet voted, draw the voting stars
                $rater .= '<div><a href="' . PUBLISHER_URL . '/rate.php?itemid=' . $itemId . '&amp;rating=' . $ncount . '" title="' . $ncount . ' ' . _MD_PUBLISHER_VOTE_OUTOF . ' ' . $units . '" class="publisher_r' . $ncount . '-unit rater" rel="nofollow">' . $ncount . '</a></div>';
            }
        }
        $ncount = 0;
        // resets the count
        $rater .= '  </div>';
        $rater .= '  <div';
        if ($voted) {
            $rater .= ' class="publisher_voted"';
        }
        $rater .= '>' . _MD_PUBLISHER_VOTE_RATING . ': <strong> ' . $rating1 . '</strong>/' . $units . ' (' . $count . ' ' . $tense . ')';
        $rater .= '  </div>';
        $rater .= '</div>';
        $rater .= '</div>';
        return $rater;
    }
}
Esempio n. 20
0
function publisher_search_show($options)
{
    $block = array();
    $publisher = PublisherPublisher::getInstance();
    $categories = $publisher->getHandler('category')->getCategoriesForSearch();
    if (count($categories) == 0) {
        return $block;
    }
    xoops_loadLanguage('search');
    $andor = isset($_POST["andor"]) ? $_POST["andor"] : (isset($_GET["andor"]) ? $_GET["andor"] : "");
    $category = isset($_POST["category"]) ? $_POST["category"] : (isset($_GET["category"]) ? $_GET["category"] : null);
    $username = isset($_POST["uname"]) ? $_POST["uname"] : (isset($_GET["uname"]) ? $_GET["uname"] : null);
    $searchin = isset($_POST["searchin"]) ? $_POST["searchin"] : (isset($_GET["searchin"]) ? explode("|", $_GET["searchin"]) : array());
    $sortby = isset($_POST["sortby"]) ? $_POST["sortby"] : (isset($_GET["sortby"]) ? $_GET["sortby"] : null);
    $term = isset($_POST["term"]) ? $_POST["term"] : (isset($_GET["term"]) ? $_GET["term"] : "");
    if (empty($category) || is_array($category) && in_array("all", $category)) {
        $category = array();
    } else {
        $category = !is_array($category) ? explode(",", $category) : $category;
        $category = array_map("intval", $category);
    }
    $andor = in_array(strtoupper($andor), array("OR", "AND", "EXACT")) ? strtoupper($andor) : "OR";
    $sortby = in_array(strtolower($sortby), array("itemid", "datesub", "title", "categoryid")) ? strtolower($sortby) : "itemid";
    /* type */
    $type_select = "<select name=\"andor\">";
    $type_select .= "<option value=\"OR\"";
    if ("OR" == $andor) {
        $type_select .= " selected=\"selected\"";
    }
    $type_select .= ">" . _SR_ANY . "</option>";
    $type_select .= "<option value=\"AND\"";
    if ("AND" == $andor) {
        $type_select .= " selected=\"selected\"";
    }
    $type_select .= ">" . _SR_ALL . "</option>";
    $type_select .= "<option value=\"EXACT\"";
    if ("exact" == $andor) {
        $type_select .= " selected=\"selected\"";
    }
    $type_select .= ">" . _SR_EXACT . "</option>";
    $type_select .= "</select>";
    /* category */
    $select_category = "<select name=\"category[]\" size=\"5\" multiple=\"multiple\" width=\"150\" style=\"width:150px;\">";
    $select_category .= "<option value=\"all\"";
    if (empty($category) || count($category) == 0) {
        $select_category .= "selected=\"selected\"";
    }
    $select_category .= ">" . _ALL . "</option>";
    foreach ($categories as $id => $cat) {
        $select_category .= "<option value=\"" . $id . "\"";
        if (in_array($id, $category)) {
            $select_category .= "selected=\"selected\"";
        }
        $select_category .= ">" . $cat . "</option>";
    }
    $select_category .= "</select>";
    /* scope */
    $searchin_select = "";
    $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"title\"";
    if (in_array("title", $searchin)) {
        $searchin_select .= " checked";
    }
    $searchin_select .= " />" . _CO_PUBLISHER_TITLE . "&nbsp;&nbsp;";
    $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"subtitle\"";
    if (in_array("subtitle", $searchin)) {
        $searchin_select .= " checked";
    }
    $searchin_select .= " />" . _CO_PUBLISHER_SUBTITLE . "&nbsp;&nbsp;";
    $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"summary\"";
    if (in_array("summary", $searchin)) {
        $searchin_select .= " checked";
    }
    $searchin_select .= " />" . _CO_PUBLISHER_SUMMARY . "&nbsp;&nbsp;";
    $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\"";
    if (in_array("body", $searchin)) {
        $searchin_select .= " checked";
    }
    $searchin_select .= " />" . _CO_PUBLISHER_BODY . "&nbsp;&nbsp;";
    $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"keywords\"";
    if (in_array("meta_keywords", $searchin)) {
        $searchin_select .= " checked";
    }
    $searchin_select .= " />" . _CO_PUBLISHER_ITEM_META_KEYWORDS . "&nbsp;&nbsp;";
    $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\"";
    if (in_array("all", $searchin) || empty($searchin)) {
        $searchin_select .= " checked";
    }
    $searchin_select .= " />" . _ALL . "&nbsp;&nbsp;";
    /* sortby */
    $sortby_select = "<select name=\"sortby\">";
    $sortby_select .= "<option value=\"itemid\"";
    if ("itemid" == $sortby || empty($sortby)) {
        $sortby_select .= " selected=\"selected\"";
    }
    $sortby_select .= ">" . _NONE . "</option>";
    $sortby_select .= "<option value=\"datesub\"";
    if ("datesub" == $sortby) {
        $sortby_select .= " selected=\"selected\"";
    }
    $sortby_select .= ">" . _CO_PUBLISHER_DATESUB . "</option>";
    $sortby_select .= "<option value=\"title\"";
    if ("title" == $sortby) {
        $sortby_select .= " selected=\"selected\"";
    }
    $sortby_select .= ">" . _CO_PUBLISHER_TITLE . "</option>";
    $sortby_select .= "<option value=\"categoryid\"";
    if ("categoryid" == $sortby) {
        $sortby_select .= " selected=\"selected\"";
    }
    $sortby_select .= ">" . _CO_PUBLISHER_CATEGORY . "</option>";
    $sortby_select .= "</select>";
    $block["type_select"] = $type_select;
    $block["searchin_select"] = $searchin_select;
    $block["category_select"] = $select_category;
    $block["sortby_select"] = $sortby_select;
    $block["search_term"] = $term;
    $block["search_user"] = $username;
    $block["publisher_url"] = PUBLISHER_URL;
    return $block;
}
Esempio n. 21
0
 public static function updateMimeValue()
 {
     $mimeId = 0;
     $publisher =& PublisherPublisher::getInstance();
     $limit = XoopsRequest::getInt('limit', 0, 'GET');
     $start = XoopsRequest::getInt('start', 0, 'GET');
     if (!XoopsRequest::getString('id', '', 'GET')) {
         redirect_header(PUBLISHER_ADMIN_URL . '/mimetypes.php', 3, _AM_PUBLISHER_MESSAGE_NO_ID);
     } else {
         $mimeId = XoopsRequest::getInt('id', 0, 'GET');
     }
     $mimeTypeObj =& $publisher->getHandler('mimetype')->get($mimeId);
     if ('' !== ($mimeAdmin = XoopsRequest::getString('mime_admin', '', 'GET'))) {
         //            $mimeAdmin = XoopsRequest::getInt('mime_admin', 0, 'GET');
         $mimeAdmin = self::changeMimeValue($mimeAdmin);
         $mimeTypeObj->setVar('mime_admin', $mimeAdmin);
     }
     if ('' !== ($mimeUser = XoopsRequest::getString('mime_user', '', 'GET'))) {
         //            $mimeUser = XoopsRequest::getInt('mime_user', 0, 'GET');
         $mimeUser = self::changeMimeValue($mimeUser);
         $mimeTypeObj->setVar('mime_user', $mimeUser);
     }
     if ($publisher->getHandler('mimetype')->insert($mimeTypeObj, true)) {
         header('Location: ' . PUBLISHER_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}");
     } else {
         redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}", 3);
     }
 }
Esempio n. 22
0
function updateMimeValue()
{
    $publisher = PublisherPublisher::getInstance();
    $start = $limit = 0;
    if (isset($_GET['limit'])) {
        $limit = intval($_GET['limit']);
    }
    if (isset($_GET['start'])) {
        $start = intval($_GET['start']);
    }
    if (!isset($_REQUEST['id'])) {
        redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php", 3, _AM_PUBLISHER_MESSAGE_NO_ID);
    } else {
        $mime_id = intval($_REQUEST['id']);
    }
    $mimetype = $publisher->getHandler('mimetype')->get($mime_id);
    if (isset($_REQUEST['mime_admin'])) {
        $mime_admin = intval($_REQUEST['mime_admin']);
        $mime_admin = _changeMimeValue($mime_admin);
        $mimetype->setVar('mime_admin', $mime_admin);
    }
    if (isset($_REQUEST['mime_user'])) {
        $mime_user = intval($_REQUEST['mime_user']);
        $mime_user = _changeMimeValue($mime_user);
        $mimetype->setVar('mime_user', $mime_user);
    }
    if ($publisher->getHandler('mimetype')->insert($mimetype, true)) {
        header("Location: " . PUBLISHER_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}");
    } else {
        redirect_header(PUBLISHER_ADMIN_URL . "/mimetypes.php?limit={$limit}&start={$start}", 3);
    }
}
Esempio n. 23
0
 /**
  * @param int    $catId
  * @param string $status
  *
  * @return mixed
  */
 public function itemsCount($catId = 0, $status = '')
 {
     return $this->publisher->getHandler('item')->getCountsByCat($catId, $status);
 }
Esempio n. 24
0
 /**
  * @param bool $showmenu
  * @param int  $categoryId
  * @param int  $nbSubCats
  * @param null $categoryObj
  */
 public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCats = 4, $categoryObj = null)
 {
     $publisher =& PublisherPublisher::getInstance();
     // if there is a parameter, and the id exists, retrieve data: we're editing a category
     if ($categoryId != 0) {
         // Creating the category object for the selected category
         $categoryObj =& $publisher->getHandler('category')->get($categoryId);
         if ($categoryObj->notLoaded()) {
             redirect_header('category.php', 1, _AM_PUBLISHER_NOCOLTOEDIT);
             //            exit();
         }
     } else {
         if (!$categoryObj) {
             $categoryObj =& $publisher->getHandler('category')->create();
         }
     }
     if ($categoryId != 0) {
         if ($showmenu) {
             //publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES . " > " . _AM_PUBLISHER_EDITING);
         }
         echo "<br />\n";
         publisherOpenCollapsableBar('edittable', 'edittableicon', _AM_PUBLISHER_EDITCOL, _AM_PUBLISHER_CATEGORY_EDIT_INFO);
     } else {
         if ($showmenu) {
             //publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES . " > " . _AM_PUBLISHER_CREATINGNEW);
         }
         publisherOpenCollapsableBar('createtable', 'createtableicon', _AM_PUBLISHER_CATEGORY_CREATE, _AM_PUBLISHER_CATEGORY_CREATE_INFO);
     }
     $sform = $categoryObj->getForm($nbSubCats);
     $sform->display();
     if (!$categoryId) {
         publisherCloseCollapsableBar('createtable', 'createtableicon');
     } else {
         publisherCloseCollapsableBar('edittable', 'edittableicon');
     }
     //Added by fx2024
     if ($categoryId) {
         $selCat = $categoryId;
         publisherOpenCollapsableBar('subcatstable', 'subcatsicon', _AM_PUBLISHER_SUBCAT_CAT, _AM_PUBLISHER_SUBCAT_CAT_DSC);
         // Get the total number of sub-categories
         $categoriesObj =& $publisher->getHandler('category')->get($selCat);
         $totalsubs =& $publisher->getHandler('category')->getCategoriesCount($selCat);
         // creating the categories objects that are published
         $subcatsObj =& $publisher->getHandler('category')->getCategories(0, 0, $categoriesObj->categoryid());
         $totalSCOnPage = count($subcatsObj);
         echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
         echo '<tr>';
         echo "<td width='60' class='bg3' align='left'><strong>" . _AM_PUBLISHER_CATID . '</strong></td>';
         echo "<td width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_CATCOLNAME . '</strong></td>';
         echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_SUBDESCRIPT . '</strong></td>';
         echo "<td width='60' class='bg3' align='right'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
         echo '</tr>';
         if ($totalsubs > 0) {
             foreach ($subcatsObj as $subcat) {
                 $modify = "<a href='category.php?op=mod&amp;categoryid=" . $subcat->categoryid() . "'><img src='" . XOOPS_URL . '/modules/' . $publisher->getModule()->dirname() . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_MODIFY . "' alt='" . _AM_PUBLISHER_MODIFY . "' /></a>";
                 $delete = "<a href='category.php?op=del&amp;categoryid=" . $subcat->categoryid() . "'><img src='" . XOOPS_URL . '/modules/' . $publisher->getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETE . "' alt='" . _AM_PUBLISHER_DELETE . "' /></a>";
                 echo '<tr>';
                 echo "<td class='head' align='left'>" . $subcat->categoryid() . '</td>';
                 echo "<td class='even' align='left'><a href='" . XOOPS_URL . '/modules/' . $publisher->getModule()->dirname() . '/category.php?categoryid=' . $subcat->categoryid() . '&amp;parentid=' . $subcat->parentid() . "'>" . $subcat->name() . '</a></td>';
                 echo "<td class='even' align='left'>" . $subcat->description() . '</td>';
                 echo "<td class='even' align='right'> {$modify} {$delete} </td>";
                 echo '</tr>';
             }
             //                unset($subcat);
         } else {
             echo '<tr>';
             echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOSUBCAT . '</td>';
             echo '</tr>';
         }
         echo "</table>\n";
         echo "<br />\n";
         publisherCloseCollapsableBar('subcatstable', 'subcatsicon');
         publisherOpenCollapsableBar('bottomtable', 'bottomtableicon', _AM_PUBLISHER_CAT_ITEMS, _AM_PUBLISHER_CAT_ITEMS_DSC);
         $startitem = XoopsRequest::getInt('startitem');
         // Get the total number of published ITEMS
         $totalitems =& $publisher->getHandler('item')->getItemsCount($selCat, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED));
         // creating the items objects that are published
         $itemsObj =& $publisher->getHandler('item')->getAllPublished($publisher->getConfig('idxcat_perpage'), $startitem, $selCat);
         $totalitemsOnPage = count($itemsObj);
         $allcats =& $publisher->getHandler('category')->getObjects(null, true);
         echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
         echo '<tr>';
         echo "<td width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
         echo "<td width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCOLNAME . '</strong></td>';
         echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMDESC . '</strong></td>';
         echo "<td width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
         echo "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
         echo '</tr>';
         if ($totalitems > 0) {
             for ($i = 0; $i < $totalitemsOnPage; ++$i) {
                 $categoryObj = $allcats[$itemsObj[$i]->categoryid()];
                 $modify = "<a href='item.php?op=mod&amp;itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . XOOPS_URL . '/modules/' . $publisher->getModule()->dirname() . "/assets/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITITEM . "' alt='" . _AM_PUBLISHER_EDITITEM . "' /></a>";
                 $delete = "<a href='item.php?op=del&amp;itemid=" . $itemsObj[$i]->itemid() . "'><img src='" . XOOPS_URL . '/modules/' . $publisher->getModule()->dirname() . "/assets/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "'/></a>";
                 echo '<tr>';
                 echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
                 echo "<td class='even' align='left'>" . $categoryObj->name() . '</td>';
                 echo "<td class='even' align='left'>" . $itemsObj[$i]->getitemLink() . '</td>';
                 echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub('s') . '</td>';
                 echo "<td class='even' align='center'> {$modify} {$delete} </td>";
                 echo '</tr>';
             }
         } else {
             $itemid = -1;
             echo '<tr>';
             echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS . '</td>';
             echo '</tr>';
         }
         echo "</table>\n";
         echo "<br />\n";
         $parentid = XoopsRequest::getInt('parentid', 0, 'GET');
         $pagenavExtraArgs = "op=mod&categoryid={$selCat}&parentid={$parentid}";
         xoops_load('XoopsPageNav');
         $pagenav = new XoopsPageNav($totalitems, $publisher->getConfig('idxcat_perpage'), $startitem, 'startitem', $pagenavExtraArgs);
         echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
         echo "<input type='button' name='button' onclick=\"location='item.php?op=mod&categoryid=" . $selCat . "'\" value='" . _AM_PUBLISHER_CREATEITEM . "'>&nbsp;&nbsp;";
         echo '</div>';
     }
     //end of fx2024 code
 }
Esempio n. 25
0
function publisher_items_new_show($options)
{
    $publisher = PublisherPublisher::getInstance();
    $selectedcatids = explode(',', $options[0]);
    $block = array();
    if (in_array(0, $selectedcatids)) {
        $allcats = true;
    } else {
        $allcats = false;
    }
    $sort = $options[1];
    $order = publisher_getOrderBy($sort);
    $limit = $options[3];
    $start = 0;
    $image = $options[5];
    // creating the ITEM objects that belong to the selected category
    if ($allcats) {
        $criteria = null;
    } else {
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN'));
    }
    $itemsObj = $publisher->getHandler('item')->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true);
    $totalitems = count($itemsObj);
    if ($itemsObj) {
        for ($i = 0; $i < $totalitems; $i++) {
            $item = array();
            $item['link'] = $itemsObj[$i]->getItemLink(false, isset($options[4]) ? $options[4] : 65);
            $item['id'] = $itemsObj[$i]->itemid();
            $item['poster'] = $itemsObj[$i]->posterName();
            // for make poster name linked, use linkedPosterName() instead of posterName()
            if ($image == 'article') {
                $item['image'] = XOOPS_URL . '/uploads/blank.gif';
                $item['image_name'] = '';
                $images = $itemsObj[$i]->getImages();
                if (is_object($images['main'])) {
                    // check to see if GD function exist
                    if (!function_exists('imagecreatetruecolor')) {
                        $item['image'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name');
                    } else {
                        $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name') . '&amp;w=50';
                    }
                    $item['image_name'] = $images['main']->getVar('image_nicename');
                }
            } elseif ($image == 'category') {
                $item['image'] = $itemsObj[$i]->getCategoryImagePath();
                $item['image_name'] = $itemsObj[$i]->getCategoryName();
            } elseif ($image == 'avatar') {
                if ($itemsObj[$i]->uid() == '0') {
                    $item['image'] = XOOPS_URL . '/uploads/blank.gif';
                    $images = $itemsObj[$i]->getImages();
                    if (is_object($images['main'])) {
                        // check to see if GD function exist
                        if (!function_exists('imagecreatetruecolor')) {
                            $item['image'] = XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name');
                        } else {
                            $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $images['main']->getVar('image_name') . '&amp;w=50';
                        }
                    }
                } else {
                    // check to see if GD function exist
                    if (!function_exists('imagecreatetruecolor')) {
                        $item['image'] = XOOPS_URL . '/uploads/' . $itemsObj[$i]->posterAvatar();
                    } else {
                        $item['image'] = PUBLISHER_URL . '/thumb.php?src=' . XOOPS_URL . '/uploads/' . $itemsObj[$i]->posterAvatar() . '&amp;w=50';
                    }
                }
                $item['image_name'] = $itemsObj[$i]->posterName();
            }
            $item['title'] = $itemsObj[$i]->title();
            if ($sort == "datesub") {
                $item['new'] = $itemsObj[$i]->datesub();
            } elseif ($sort == "counter") {
                $item['new'] = $itemsObj[$i]->counter();
            } elseif ($sort == "weight") {
                $item['new'] = $itemsObj[$i]->weight();
            }
            $block['newitems'][] = $item;
        }
    }
    $block['show_order'] = $options[2];
    return $block;
}
Esempio n. 26
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;
    }
Esempio n. 27
0
 /**
  * @param array  $queryarray
  * @param string $andor
  * @param int    $limit
  * @param int    $offset
  * @param int    $userid
  * @param array  $categories
  * @param int    $sortby
  * @param string $searchin
  * @param string $extra
  *
  * @return array
  */
 public function getItemsFromSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0, $categories = array(), $sortby = 0, $searchin = "", $extra = "")
 {
     global $xoopsUser, $publisher_isAdmin;
     $ret = array();
     $gperm_handler =& xoops_gethandler('groupperm');
     $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
     $searchin = empty($searchin) ? array("title", "body", "summary") : (is_array($searchin) ? $searchin : array($searchin));
     if (in_array("all", $searchin) || count($searchin) == 0) {
         $searchin = array("title", "subtitle", "body", "summary", "meta_keywords");
     }
     if (is_array($userid) && count($userid) > 0) {
         $userid = array_map("intval", $userid);
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
     } elseif (is_numeric($userid) && $userid > 0) {
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('uid', $userid), 'OR');
     }
     $count = count($queryarray);
     if (is_array($queryarray) && $count > 0) {
         $criteriaKeywords = new CriteriaCompo();
         for ($i = 0; $i < count($queryarray); $i++) {
             $criteriaKeyword = new CriteriaCompo();
             if (in_array('title', $searchin)) {
                 $criteriaKeyword->add(new Criteria('title', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('subtitle', $searchin)) {
                 $criteriaKeyword->add(new Criteria('subtitle', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('body', $searchin)) {
                 $criteriaKeyword->add(new Criteria('body', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('summary', $searchin)) {
                 $criteriaKeyword->add(new Criteria('summary', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             if (in_array('meta_keywords', $searchin)) {
                 $criteriaKeyword->add(new Criteria('meta_keywords', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             }
             $criteriaKeywords->add($criteriaKeyword, $andor);
             unset($criteriaKeyword);
         }
     }
     if (!$publisher_isAdmin && count($categories) > 0) {
         $criteriaPermissions = new CriteriaCompo();
         // Categories for which user has access
         $categoriesGranted = $gperm_handler->getItemIds('category_read', $groups, $this->publisher->getModule()->getVar('mid'));
         if (count($categories) > 0) {
             $categoriesGranted = array_intersect($categoriesGranted, $categories);
         }
         if (count($categoriesGranted) == 0) {
             return $ret;
         }
         $grantedCategories = new Criteria('categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN');
         $criteriaPermissions->add($grantedCategories, 'AND');
     } elseif (count($categories) > 0) {
         $criteriaPermissions = new CriteriaCompo();
         $grantedCategories = new Criteria('categoryid', "(" . implode(',', $categories) . ")", 'IN');
         $criteriaPermissions->add($grantedCategories, 'AND');
     }
     $criteriaItemsStatus = new CriteriaCompo();
     $criteriaItemsStatus->add(new Criteria('status', _PUBLISHER_STATUS_PUBLISHED));
     $criteria = new CriteriaCompo();
     if (!empty($criteriaUser)) {
         $criteria->add($criteriaUser, 'AND');
     }
     if (!empty($criteriaKeywords)) {
         $criteria->add($criteriaKeywords, 'AND');
     }
     if (!empty($criteriaPermissions)) {
         $criteria->add($criteriaPermissions);
     }
     if (!empty($criteriaItemsStatus)) {
         $criteria->add($criteriaItemsStatus, 'AND');
     }
     $criteria->setLimit($limit);
     $criteria->setStart($offset);
     if (empty($sortby)) {
         $sortby = "datesub";
     }
     $criteria->setSort($sortby);
     $order = 'ASC';
     if ($sortby == "datesub") {
         $order = 'DESC';
     }
     $criteria->setOrder($order);
     $ret = $this->getObjects($criteria);
     return $ret;
 }
Esempio n. 28
0
/**
 * @param $options
 *
 * @return array
 */
function publisher_latest_news_show($options)
{
    $block = array();
    xoops_loadLanguage('main', 'publisher');
    $publisher =& PublisherPublisher::getInstance();
    $start = $options[0];
    // You can show articles from specified range
    $limit = $options[1];
    $columnCount = $options[2];
    $letters = $options[3];
    $selectedStories = $options[4];
    $sort = $options[9];
    $order = publisherGetOrderBy($sort);
    $imgWidth = $options[11];
    $imgHeight = $options[12];
    $border = $options[13];
    $bordercolor = $options[14];
    $block['spec']['columnwidth'] = (int) (1 / $columnCount * 100);
    $allcats = false;
    if (!isset($options[29])) {
        $allcats = true;
    } elseif (in_array(0, explode(',', $options[29]))) {
        $allcats = true;
    }
    // creating the ITEM objects that belong to the selected category
    if ($allcats) {
        $criteria = null;
    } else {
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('categoryid', '(' . $options[29] . ')', 'IN'));
    }
    // Use specific ITEMS
    if ($selectedStories != 0) {
        unset($criteria);
        //removes category option
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('itemid', '(' . $selectedStories . ')', 'IN'));
    }
    $itemsObj =& $publisher->getHandler('item')->getItems($limit, $start, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, 'itemid');
    $scount = count($itemsObj);
    if ($scount == 0) {
        return false;
    }
    $k = 0;
    $columns = array();
    foreach ($itemsObj as $itemid => $itemObj) {
        $item = array();
        $item['itemurl'] = $itemObj->getItemUrl();
        $item['title'] = $itemObj->getItemLink();
        $item['alt'] = strip_tags($itemObj->getItemLink());
        $mainImage = $itemObj->getMainImage();
        // check to see if GD function exist
        if (!function_exists('imagecreatetruecolor')) {
            $item['item_image'] = $mainImage['image_path'];
        } else {
            $item['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . '&amp;w=' . $imgWidth;
            // No $imgHeight for autoheight option
        }
        $item['text'] = $itemObj->getBlockSummary($letters);
        $item = $itemObj->getMainImage($item);
        //returns an array
        $lsHeight = '';
        if ($options[12] != 0) {
            $lsHeight = 'height="' . $imgHeight . '" ';
        }
        // set height = 0 in block option for auto height
        if ($options[15] === 'LEFT') {
            $imgPosition = 'float: left';
            $lsMargin = '-right';
        }
        if ($options[15] === 'CENTER') {
            $imgPosition = 'text-align:center';
            $lsMargin = '';
        }
        if ($options[15] === 'RIGHT') {
            $imgPosition = 'float: right';
            $lsMargin = '-left';
        }
        //Image
        if ($options[10] == 1 && $item['image_path'] != '') {
            $startdiv = '<div style="' . $imgPosition . '"><a href="' . $item['itemurl'] . '">';
            $style = 'style="margin' . $lsMargin . ': 10px; padding: 2px; border: ' . $border . 'px solid #' . $bordercolor . '"';
            $enddiv = 'width="' . $imgWidth . '" ' . $lsHeight . '/></a></div>';
            $image = $startdiv . '<img ' . $style . ' src="' . $item['item_image'] . '" alt="' . $item['image_name'] . '" ' . $enddiv;
            $item['image'] = $image;
        }
        if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin(-1)) {
            $item['admin'] = "<a href='" . PUBLISHER_URL . '/submit.php?itemid=' . $itemObj->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif'" . " title='" . _CO_PUBLISHER_EDIT . "' alt='" . _CO_PUBLISHER_EDIT . "' /></a>&nbsp;";
            $item['admin'] .= "<a href='" . PUBLISHER_URL . '/admin/item.php?op=del&amp;itemid=' . $itemObj->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png'" . " title='" . _CO_PUBLISHER_DELETE . "' alt='" . _CO_PUBLISHER_DELETE . "' /></a>";
        } else {
            $item['admin'] = '';
        }
        $block['topiclink'] = '';
        /*
                if ($options[16] == 1) {
        $block['topiclink'] = '| <a href="'.XOOPS_URL.'/modules/news/topics_directory.php">'._AM_NEWS_TOPICS_DIRECTORY.'</a> ';
        }
        */
        $block['archivelink'] = '';
        if ($options[17] == 1) {
            $block['archivelink'] = '| <a href="' . PUBLISHER_URL . '/archive.php">' . _MB_PUBLISHER_ARCHIVE . '</a> ';
        }
        //TODO: Should we not show link to Anonymous?
        $block['submitlink'] = '';
        if ($options[18] == 1 && $GLOBALS['xoopsUser']) {
            $block['submitlink'] = '| <a href="' . PUBLISHER_URL . '/submit.php">' . _MB_PUBLISHER_SUBMITNEWS . '</a> ';
        }
        $item['poster'] = '';
        if ($options[19] == 1) {
            $item['poster'] = _MB_PUBLISHER_POSTER . ' ' . $itemObj->posterName();
        }
        $item['posttime'] = '';
        if ($options[20] == 1) {
            $item['posttime'] = _ON . ' ' . $itemObj->getDatesub();
        }
        $item['topic_title'] = '';
        if ($options[21] == 1) {
            $item['topic_title'] = $itemObj->getCategoryLink() . _MB_PUBLISHER_SP;
        }
        $item['read'] = '';
        if ($options[22] == 1) {
            $item['read'] = '&nbsp;(' . $itemObj->counter() . ' ' . _READS . ')';
        }
        $item['more'] = '';
        if ($itemObj->body() != '' || $itemObj->comments() > 0) {
            $item['more'] = '<a class="publisher_spotlight_readmore" href="' . $itemObj->getItemUrl() . '">' . _MB_PUBLISHER_READMORE . '</a>';
        }
        $comments = $itemObj->comments();
        if ($options[23] == 1) {
            if ($comments > 0) {
                //shows 1 comment instead of 1 comm. if comments ==1
                //langugage file modified accordingly
                if ($comments == 1) {
                    $item['comment'] = '&nbsp;' . _MB_PUBLISHER_ONECOMMENT . '&nbsp;';
                } else {
                    $item['comment'] = '&nbsp;' . $comments . '&nbsp;' . _MB_PUBLISHER_COMMENTS . '&nbsp;';
                }
            } else {
                $item['comment'] = '&nbsp;' . _MB_PUBLISHER_NO_COMMENTS . '&nbsp;';
            }
        }
        $item['print'] = '';
        if ($options[24] == 1) {
            $item['print'] = '<a href="' . PublisherSeo::generateUrl('print', $itemObj->itemid(), $itemObj->short_url()) . '" rel="nofollow"><img src="' . PUBLISHER_URL . '/assets/images/links/print.gif" title="' . _CO_PUBLISHER_PRINT . '" alt="' . _CO_PUBLISHER_PRINT . '" /></a>&nbsp;';
        }
        $item['pdf'] = '';
        if ($publisher->getConfig('display_pdf')) {
            if ($options[25] == 1) {
                $item['pdf'] = "<a href='" . PUBLISHER_URL . '/makepdf.php?itemid=' . $itemObj->itemid() . "' rel='nofollow'><img src='" . PUBLISHER_URL . "/assets/images/links/pdf.gif' title='" . _CO_PUBLISHER_PDF . "' alt='" . _CO_PUBLISHER_PDF . "' /></a>&nbsp;";
            }
        }
        $item['email'] = '';
        if ($options[26] == 1 && xoops_isActiveModule('tellafriend')) {
            $subject = sprintf(_CO_PUBLISHER_INTITEMFOUND, $GLOBALS['xoopsConfig']['sitename']);
            $subject = $itemObj->convertForJapanese($subject);
            $maillink = publisherTellAFriend($subject);
            $item['email'] = '<a href="' . $maillink . '"><img src="' . PUBLISHER_URL . '/assets/images/links/friend.gif" title="' . _CO_PUBLISHER_MAIL . '" alt="' . _CO_PUBLISHER_MAIL . '" /></a>&nbsp;';
        }
        $block['morelink'] = '';
        if ($options[27] == 1) {
            $block['morelink'] = '<a href="' . PUBLISHER_URL . '/index.php">' . _MB_PUBLISHER_MORE_ITEMS . '</a> ';
        }
        $block['latestnews_scroll'] = false;
        if ($options[5] == 1) {
            $block['latestnews_scroll'] = true;
        }
        $block['scrollheight'] = $options[6];
        $block['scrollspeed'] = $options[7];
        $block['scrolldir'] = $options[8];
        $block['template'] = $options[28];
        $block['imgwidth'] = $options[11];
        $block['imgheight'] = $options[12];
        $block['letters'] = $letters;
        $columns[$k][] = $item;
        ++$k;
        if ($k == $columnCount) {
            $k = 0;
        }
    }
    unset($item);
    $block['columns'] = $columns;
    return $block;
}
Esempio n. 29
0
function publisher_items_spot_edit($options)
{
    include_once PUBLISHER_ROOT_PATH . '/class/blockform.php';
    xoops_load('XoopsFormLoader');
    $form = new PublisherBlockForm();
    $autoEle = new XoopsFormRadioYN(_MB_PUBLISHER_AUTO_LAST_ITEMS, 'options[0]', $options[0]);
    $countEle = new XoopsFormText(_MB_PUBLISHER_LAST_ITEMS_COUNT, 'options[1]', 2, 255, $options[1]);
    $catEle = new XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, publisher_createCategorySelect($options[2], 0, true, 'options[2]'));
    $publisher = PublisherPublisher::getInstance();
    $criteria = new CriteriaCompo();
    $criteria->setSort('datesub');
    $criteria->setOrder('DESC');
    $itemsObj = $publisher->getHandler('item')->getList($criteria);
    $keys = array_keys($itemsObj);
    unset($criteria);
    if (empty($options[3]) || $options[3] == 0) {
        $sel_items = isset($keys[0]) ? $keys[0] : 0;
    } else {
        $sel_items = explode(',', $options[3]);
    }
    $itemEle = new XoopsFormSelect(_MB_PUBLISHER_SELECT_ITEMS, 'options[3]', $sel_items, 10, true);
    $itemEle->addOptionArray($itemsObj);
    $whoEle = new XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_WHO_AND_WHEN, 'options[4]', $options[4]);
    $comEle = new XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_COMMENTS, 'options[5]', $options[5]);
    $typeEle = new XoopsFormSelect(_MB_PUBLISHER_DISPLAY_TYPE, 'options[6]', $options[6]);
    $typeEle->addOptionArray(array('block' => _MB_PUBLISHER_DISPLAY_TYPE_BLOCK, 'bullet' => _MB_PUBLISHER_DISPLAY_TYPE_BULLET));
    $truncateEle = new XoopsFormText(_MB_PUBLISHER_TRUNCATE, 'options[7]', 4, 255, $options[7]);
    $imageEle = new XoopsFormRadioYN(_MB_PUBLISHER_DISPLAY_CATIMAGE, 'options[8]', $options[8]);
    $form->addElement($autoEle);
    $form->addElement($countEle);
    $form->addElement($catEle);
    $form->addElement($itemEle);
    $form->addElement($whoEle);
    $form->addElement($comEle);
    $form->addElement($typeEle);
    $form->addElement($truncateEle);
    $form->addElement($imageEle);
    return $form->render();
}
Esempio n. 30
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));
 }