/**
 * @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;
    }
}
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         Publisher
 * @since           1.0
 * @author          trabis <*****@*****.**>
 * @author          The SmartFactory <www.smartfactory.ca>
 * @version         $Id: pw_delete_file.php 10374 2012-12-12 23:39:48Z trabis $
 */
include_once __DIR__ . '/admin_header.php';
if ('delfileok' === XoopsRequest::getString('op', '', 'POST')) {
    $dir = publisherGetUploadDir(true, 'content');
    $filename = XoopsRequest::getString('address', '', 'POST');
    if (file_exists($dir . '/' . $filename)) {
        unlink($dir . '/' . $filename);
    }
    redirect_header(XoopsRequest::getString('backto', '', 'POST'), 2, _AM_PUBLISHER_FDELETED);
} else {
    xoops_cp_header();
    xoops_confirm(array('backto' => XoopsRequest::getString('backto', '', 'POST'), 'address' => XoopsRequest::getString('address', '', 'POST'), 'op' => 'delfileok'), 'pw_delete_file.php', _AM_PUBLISHER_RUSUREDELF, _YES);
    xoops_cp_footer();
}
Example #3
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;
    }
Example #4
0
/**
 * @param bool $showmenu
 * @param int  $itemid
 * @param bool $clone
 */
function publisher_editItem($showmenu = false, $itemid = 0, $clone = false)
{
    $publisher =& PublisherPublisher::getInstance();
    global $publisherCurrentPage;
    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', PublisherConstants::PUBLISHER_STATUS_NOTSET);
            $itemObj->setVar('datesub', time());
        }
        switch ($itemObj->status()) {
            case PublisherConstants::PUBLISHER_STATUS_SUBMITTED:
                $breadcrumbAction1 = _CO_PUBLISHER_SUBMITTED;
                $breadcrumbAction2 = _AM_PUBLISHER_APPROVING;
                $pageTitle = _AM_PUBLISHER_SUBMITTED_TITLE;
                $pageInfo = _AM_PUBLISHER_SUBMITTED_INFO;
                $buttonCaption = _AM_PUBLISHER_APPROVE;
                $newStatus = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
                break;
            case PublisherConstants::PUBLISHER_STATUS_PUBLISHED:
                $breadcrumbAction1 = _CO_PUBLISHER_PUBLISHED;
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
                $pageTitle = _AM_PUBLISHER_PUBLISHEDEDITING;
                $pageInfo = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
                $buttonCaption = _AM_PUBLISHER_MODIFY;
                $newStatus = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
                break;
            case PublisherConstants::PUBLISHER_STATUS_OFFLINE:
                $breadcrumbAction1 = _CO_PUBLISHER_OFFLINE;
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
                $pageTitle = _AM_PUBLISHER_OFFLINEEDITING;
                $pageInfo = _AM_PUBLISHER_OFFLINEEDITING_INFO;
                $buttonCaption = _AM_PUBLISHER_MODIFY;
                $newStatus = PublisherConstants::PUBLISHER_STATUS_OFFLINE;
                break;
            case PublisherConstants::PUBLISHER_STATUS_REJECTED:
                $breadcrumbAction1 = _CO_PUBLISHER_REJECTED;
                $breadcrumbAction2 = _AM_PUBLISHER_REJECTED;
                $pageTitle = _AM_PUBLISHER_REJECTED_EDIT;
                $pageInfo = _AM_PUBLISHER_REJECTED_EDIT_INFO;
                $buttonCaption = _AM_PUBLISHER_MODIFY;
                $newStatus = PublisherConstants::PUBLISHER_STATUS_REJECTED;
                break;
            case PublisherConstants::PUBLISHER_STATUS_NOTSET:
                // Then it's a clone...
                $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
                $breadcrumbAction2 = _AM_PUBLISHER_CLONE_NEW;
                $buttonCaption = _AM_PUBLISHER_CREATE;
                $newStatus = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
                $pageTitle = _AM_PUBLISHER_ITEM_DUPLICATING;
                $pageInfo = _AM_PUBLISHER_ITEM_DUPLICATING_DSC;
                break;
            case 'default':
            default:
                $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
                $pageTitle = _AM_PUBLISHER_PUBLISHEDEDITING;
                $pageInfo = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
                $buttonCaption = _AM_PUBLISHER_MODIFY;
                $newStatus = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
                break;
        }
        $categoryObj = $itemObj->getCategory();
        if ($showmenu) {
            //publisher_adminMenu(2, $breadcrumbAction1 . " > " . $breadcrumbAction2);
        }
        echo "<br />\n";
        publisherOpenCollapsableBar('edititemtable', 'edititemicon', $pageTitle, $pageInfo);
        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();
        $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
        $breadcrumbAction2 = _AM_PUBLISHER_CREATINGNEW;
        $buttonCaption = _AM_PUBLISHER_CREATE;
        $newStatus = PublisherConstants::PUBLISHER_STATUS_PUBLISHED;
        if ($showmenu) {
            //publisher_adminMenu(2, $breadcrumbAction1 . " > " . $breadcrumbAction2);
        }
        $categoryObj->setVar('categoryid', XoopsRequest::getInt('categoryid', 0, 'GET'));
        publisherOpenCollapsableBar('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.tpl');
    publisherCloseCollapsableBar('edititemtable', 'edititemicon');
    publisherOpenCollapsableBar('pagewraptable', 'pagewrapicon', _AM_PUBLISHER_PAGEWRAP, _AM_PUBLISHER_PAGEWRAPDSC);
    $dir = publisherGetUploadDir(true, 'content');
    if (false !== strpos(decoct(fileperms($dir)), '755')) {
        echo "<span style='color:#ff0000;'><h4>" . _AM_PUBLISHER_PERMERROR . '</h4></span>';
    }
    // 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='{$publisherCurrentPage}'/>";
    echo '</table>';
    echo '</form>';
    // Delete File
    $form = new XoopsThemeForm(_CO_PUBLISHER_DELETEFILE, 'form_name', 'pw_delete_file.php');
    $pWrapSelect = new XoopsFormSelect(publisherGetUploadDir(true, 'content'), 'address');
    $folder = dir($dir);
    while (($file = $folder->read()) !== false) {
        if ($file !== '.' && $file !== '..') {
            $pWrapSelect->addOption($file, $file);
        }
    }
    $folder->close();
    $form->addElement($pWrapSelect);
    $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', $publisherCurrentPage));
    $form->display();
    publisherCloseCollapsableBar('pagewraptable', 'pagewrapicon');
}
Example #5
0
 public static function createDir()
 {
     // auto crate folders
     //        $thePath = publisherGetUploadDir();
     if (publisherGetPathStatus('root', true) < 0) {
         $thePath = publisherGetUploadDir();
         $res = publisherMkdir($thePath);
         $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
     }
     if (publisherGetPathStatus('images', true) < 0) {
         $thePath = publisherGetImageDir();
         $res = publisherMkdir($thePath);
         if ($res) {
             $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png';
             $dest = $thePath . 'blank.png';
             publisherCopyr($source, $dest);
         }
         $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
     }
     if (publisherGetPathStatus('images/category', true) < 0) {
         $thePath = publisherGetImageDir('category');
         $res = publisherMkdir($thePath);
         if ($res) {
             $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png';
             $dest = $thePath . 'blank.png';
             publisherCopyr($source, $dest);
         }
         $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
     }
     if (publisherGetPathStatus('images/item', true) < 0) {
         $thePath = publisherGetImageDir('item');
         $res = publisherMkdir($thePath);
         if ($res) {
             $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png';
             $dest = $thePath . 'blank.png';
             publisherCopyr($source, $dest);
         }
         $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
     }
     if (publisherGetPathStatus('content', true) < 0) {
         $thePath = publisherGetUploadDir(true, 'content');
         $res = publisherMkdir($thePath);
         $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
     }
 }
Example #6
0
/**
 * @param  string $item
 * @param  bool   $hasPath
 * @return string
 */
function publisherGetImageDir($item = '', $hasPath = true)
{
    if ($item) {
        $item = "images/{$item}";
    } else {
        $item = 'images';
    }
    return publisherGetUploadDir($hasPath, $item);
}
Example #7
0
 /**
  * @return string
  */
 public function getFilePath()
 {
     return publisherGetUploadDir() . $this->filename();
 }
Example #8
0
publisherOpenCollapsableBar('pagewraptable', 'pagewrapicon', _AM_PUBLISHER_PAGEWRAP, _AM_PUBLISHER_PAGEWRAPDSC);
$dir = publisherGetUploadDir(true, 'content');
if (false !== strpos(decoct(fileperms($dir)), '777')) {
    echo "<span style='color:#ff0000;'><h4>" . _AM_PUBLISHER_PERMERROR . '</h4></span>';
}
// 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 . "</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 '</table>';
echo '</form>';
// Delete File
$form = new XoopsThemeForm(_CO_PUBLISHER_DELETEFILE, 'form_name', 'pw_delete_file.php');
$pWrapSelect = new XoopsFormSelect(publisherGetUploadDir(true, 'content'), 'address');
$folder = dir($dir);
while ($file == $folder->read()) {
    if ($file !== '.' && $file !== '..') {
        $pWrapSelect->addOption($file, $file);
    }
}
$folder->close();
$form->addElement($pWrapSelect);
$delfile = 'delfile';
$form->addElement(new XoopsFormHidden('op', $delfile));
$submit = new XoopsFormButton('', 'submit', _AM_PUBLISHER_BUTTON_DELETE, 'submit');
$form->addElement($submit);
$form->display();
publisherCloseCollapsableBar('pagewraptable', 'pagewrapicon');
include_once __DIR__ . '/admin_footer.php';
Example #9
0
 /**
  * @param string $fileName
  *
  * @return string
  */
 public function wrapPage($fileName)
 {
     $content = '';
     $page = publisherGetUploadDir(true, 'content') . $fileName;
     if (file_exists($page)) {
         // this page uses smarty template
         ob_start();
         include $page;
         $content = ob_get_contents();
         ob_end_clean();
         // Cleaning the content
         $bodyStartPos = strpos($content, '<body>');
         if ($bodyStartPos) {
             $bodyEndPos = strpos($content, '</body>', $bodyStartPos);
             $content = substr($content, $bodyStartPos + strlen('<body>'), $bodyEndPos - strlen('<body>') - $bodyStartPos);
         }
         // Check if ML Hack is installed, and if yes, parse the $content in formatForML
         $myts = MyTextSanitizer::getInstance();
         if (method_exists($myts, 'formatForML')) {
             $content = $myts->formatForML($content);
         }
     }
     return $content;
 }