예제 #1
0
function smartsection_seo_genUrl($op, $id, $short_url = "")
{
    $smartModuleConfig = smartsection_getModuleConfig();
    if (defined('SMARTSECTION_SEO_ENABLED')) {
        if (!empty($short_url)) {
            $short_url = $short_url . '.html';
        }
        if (SMARTSECTION_SEO_ENABLED == 'rewrite') {
            // generate SEO url using htaccess
            return XOOPS_URL . "/" . $smartModuleConfig['module_seo_modulename'] . ".{$op}.{$id}/{$short_url}";
        } else {
            if (SMARTSECTION_SEO_ENABLED == 'path-info') {
                // generate SEO url using path-info
                return XOOPS_URL . "/modules/smartsection/seo.php/{$op}.{$id}/{$short_url}";
            } else {
                die('Unknown SEO method.');
            }
        }
    } else {
        // generate classic url
        switch ($op) {
            case 'category':
                return XOOPS_URL . "/modules/smartsection/{$op}.php?categoryid={$id}";
            case 'item':
            case 'print':
                return XOOPS_URL . "/modules/smartsection/{$op}.php?itemid={$id}";
            default:
                die('Unknown SEO operation.');
        }
    }
}
예제 #2
0
function smartsection_pagewrap_upload(&$errors)
{
    include_once SMARTSECTION_ROOT_PATH . "class/uploader.php";
    global $xoopsUser, $xoopsDB, $xoopsModule, $xoopsModule, $xoopsModuleConfig;
    include_once SMARTSECTION_ROOT_PATH . 'class/uploader.php';
    $config =& smartsection_getModuleConfig();
    $post_field = 'fileupload';
    //$allowed_mimetypes = '';
    // TODO : this needs to be managed by the MimeType section but we need a new parameter for allowed mimetype for pagewrap
    /*	if(!isset($allowed_mimetypes)){
           $hMime =& xoops_getmodulehandler('mimetype');
           $allowed_mimetypes = $hMime->checkMimeTypes($post_field);
           if(!$allowed_mimetypes){
           	$errors[] = _SMARTSECTION_MESSAGE_WRONG_MIMETYPE;
               return false;
           }
       }*/
    /*$maxfilesize = $config['xhelp_uploadSize'];
      $maxfilewidth = $config['xhelp_uploadWidth'];
      $maxfileheight = $config['xhelp_uploadHeight'];*/
    $max_size = $xoopsModuleConfig['maximum_filesize'];
    $max_imgwidth = $xoopsModuleConfig['maximum_image_width'];
    $max_imgheight = $xoopsModuleConfig['maximum_image_height'];
    if (!is_dir(smartsection_getUploadDir(true, 'content'))) {
        mkdir(smartsection_getUploadDir(true, 'content'), 0757);
    }
    $allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml');
    $uploader = new XoopsMediaUploader(smartsection_getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
    if ($uploader->fetchMedia($post_field)) {
        $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;
    }
}
예제 #3
0
 function storeUpload($post_field, $allowed_mimetypes = null, &$errors)
 {
     global $xoopsUser, $xoopsDB, $xoopsModule;
     include_once SMARTSECTION_ROOT_PATH . 'class/uploader.php';
     $config =& smartsection_getModuleConfig();
     $itemid = $this->getVar('itemid');
     if (!isset($allowed_mimetypes)) {
         $hMime =& xoops_getmodulehandler('mimetype');
         $allowed_mimetypes = $hMime->checkMimeTypes($post_field);
         if (!$allowed_mimetypes) {
             return false;
         }
     }
     /*$maxfilesize = $config['xhelp_uploadSize'];
       $maxfilewidth = $config['xhelp_uploadWidth'];
       $maxfileheight = $config['xhelp_uploadHeight'];*/
     $maxfilesize = $config['maximum_filesize'];
     $maxfilewidth = $config['maximum_image_width'];
     $maxfileheight = $config['maximum_image_height'];
     if (!is_dir(smartsection_getUploadDir())) {
         mkdir(smartsection_getUploadDir(), 0757);
     }
     $uploader = new XoopsMediaUploader(smartsection_getUploadDir() . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
     if ($uploader->fetchMedia($post_field)) {
         $uploader->setTargetFileName($itemid . "_" . $uploader->getMediaName());
         if ($uploader->upload()) {
             $this->setVar('filename', $uploader->getSavedFileName());
             if ($this->getVar('name') == '') {
                 $this->setVar('name', $this->getNameFromFilename());
             }
             $this->setVar('mimetype', $uploader->getMediaType());
             return true;
         } else {
             $errors = array_merge($errors, $uploader->getErrors(false));
             return false;
         }
     } else {
         $errors = array_merge($errors, $uploader->getErrors(false));
         return false;
     }
 }
예제 #4
0
 function getWhoAndWhen($users = array())
 {
     $smartModuleConfig =& smartsection_getModuleConfig();
     $posterName = smartsection_getLinkedUnameFromId($this->uid(), $smartModuleConfig['userealname'], $users);
     $postdate = $this->datesub();
     return sprintf(_MD_SSECTION_POSTEDBY, $posterName, $postdate);
 }
예제 #5
0
if (!file_exists(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php')) {
    trigger_error('SmartObject Framework not found.', E_USER_ERROR);
}
include_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
include_once SMARTSECTION_ROOT_PATH . "include/functions.php";
// Check XOOPS version to see if we are on XOOPS 2.2.x plateform
$xoops22 = smartsection_isXoops22();
include_once SMARTSECTION_ROOT_PATH . "include/seo_functions.php";
include_once SMARTSECTION_ROOT_PATH . "class/keyhighlighter.class.php";
// Creating the SmartModule object
$smartModule =& smartsection_getModuleInfo();
// Find if the user is admin of the module
$smartsection_isAdmin = smartsection_userIsAdmin();
$smartsection_moduleName = $smartModule->getVar('name');
// Creating the SmartModule config Object
$smartConfig =& smartsection_getModuleConfig();
include_once SMARTSECTION_ROOT_PATH . "class/smartmetagen.php";
include_once SMARTSECTION_ROOT_PATH . "class/permission.php";
include_once SMARTSECTION_ROOT_PATH . "class/category.php";
include_once SMARTSECTION_ROOT_PATH . "class/item.php";
include_once SMARTSECTION_ROOT_PATH . "class/file.php";
include_once SMARTSECTION_ROOT_PATH . "class/session.php";
// Creating the item handler object
$smartsection_item_handler =& xoops_getmodulehandler('item', SMARTSECTION_DIRNAME);
// Creating the category handler object
$smartsection_category_handler =& xoops_getmodulehandler('category', SMARTSECTION_DIRNAME);
// Creating the permission handler object
$smartsection_permission_handler =& xoops_getmodulehandler('permission', SMARTSECTION_DIRNAME);
// Creating the file handler object
$smartsection_file_handler =& xoops_getmodulehandler('file', SMARTSECTION_DIRNAME);
// get current page
예제 #6
0
function smartsection_getHelpPath()
{
    $smartConfig =& smartsection_getModuleConfig();
    switch ($smartConfig['helppath_select']) {
        case 'docs.xoops.org':
            return 'http://docs.xoops.org/help/ssectionh/index.htm';
            break;
        case 'inside':
            return XOOPS_URL . "/modules/smartsection/doc/";
            break;
        case 'custom':
            return $smartConfig['helppath_custom'];
            break;
    }
}
예제 #7
0
 /**
  * storeFaq: store the FAQ in the application's specific database (required)
  * @param xhelpFaq $faq The faq to add
  * @return bool true (success) / false (failure)
  * @access public
  */
 function storeFaq(&$faq)
 {
     global $xoopsUser, $smartsection_item_handler;
     $uid = $xoopsUser->getVar('uid');
     //fix for smartsectionItem::store assuming that smartsection handlers are globalized
     $GLOBALS['smartsection_item_handler'] =& smartsection_gethandler('item');
     $GLOBALS['smartsection_category_handler'] =& smartsection_gethandler('category');
     $ssConfig =& smartsection_getModuleConfig();
     // Create page in smartsection from xhelpFAQ object
     $hSSItem =& smartsection_gethandler('item');
     $itemObj =& $hSSItem->create();
     //$faq->getVar('categories') is an array. If your application
     //only supports single categories use the first element
     //in the array
     $categories = $faq->getVar('categories');
     $categories = intval($categories[0]);
     // Change array of categories to 1 category
     // Putting the values about the ITEM in the ITEM object
     $itemObj->setVar('categoryid', $categories);
     $itemObj->setVar('title', $faq->getVar('subject', 'e'));
     $itemObj->setVar('summary', '[b]' . ucfirst(_XHELP_TEXT_PROBLEM) . "[/b]\r\n" . $faq->getVar('problem', 'e'));
     $itemObj->setVar('body', '[b]' . ucfirst(_XHELP_TEXT_SOLUTION) . "[/b]\r\n" . $faq->getVar('solution', 'e'));
     $itemObj->setVar('dohtml', XHELP_SSECTION_DOHTML);
     $itemObj->setVar('dosmiley', XHELP_SSECTION_DOSMILEY);
     $itemObj->setVar('doxcode', XHELP_SSECTION_DOBBCODE);
     $itemObj->setVar('doimage', XHELP_SSECTION_DOIMAGE);
     $itemObj->setVar('dobr', XHELP_SSECTION_DOBR);
     $itemObj->setVar('notifypub', XHELP_SSECTION_NOTIFYPUB);
     $itemObj->setVar('uid', $uid);
     $itemObj->setVar('datesub', time());
     // Setting the status of the item
     if ($this->_articleNeedsApproval()) {
         $itemObj->setVar('status', _SSECTION_STATUS_SUBMITTED);
     } else {
         $itemObj->setVar('status', _SSECTION_STATUS_PUBLISHED);
     }
     // Storing the item object in the database
     if ($ret = $itemObj->store()) {
         $faq->setVar('id', $itemObj->getVar('itemid'));
         $faq->setVar('url', $this->makeFaqUrl($faq));
         if (!$this->_articleNeedsApproval()) {
             // Send notifications
             $itemObj->sendNotifications(array(_SSECTION_NOT_ITEM_PUBLISHED));
         } else {
             if (XHELP_SSECTION_NOTIFYPUB) {
                 include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
                 $notification_handler =& xoops_gethandler('notification');
                 $notification_handler->subscribe('item', $itemObj->itemid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
             }
             // Send notifications
             $itemObj->sendNotifications(array(_SSECTION_NOT_ITEM_SUBMITTED));
         }
     }
     return $ret;
 }