Пример #1
0
/**
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
 * @license         GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package         Publisher
 * @since           1.0
 * @author          trabis <*****@*****.**>
 * @version         $Id$
 */
function publisher_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = "", $extra = "")
{
    $publisher = Publisher::getInstance();
    $ret = array();
    if ($queryarray == '' || count($queryarray) == 0) {
        $hightlight_key = '';
    } else {
        $keywords = implode('+', $queryarray);
        $hightlight_key = "&amp;keywords=" . $keywords;
    }
    $itemsObjs = $publisher->getItemHandler()->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra);
    $withCategoryPath = $publisher->getConfig('search_cat_path');
    $usersIds = array();
    /* @var $obj PublisherItem */
    foreach ($itemsObjs as $obj) {
        $item['image'] = "images/item_icon.gif";
        $item['link'] = $obj->getItemUrl();
        $item['link'] .= !empty($hightlight_key) && strpos($item['link'], '.php?') === false ? "?" . ltrim($hightlight_key, '&amp;') : $hightlight_key;
        if ($withCategoryPath) {
            $item['title'] = $obj->getCategoryPath(false) . " > " . $obj->title();
        } else {
            $item['title'] = $obj->title();
        }
        $item['time'] = $obj->getVar('datesub');
        //must go has unix timestamp
        $item['uid'] = $obj->getVar('uid');
        //"Fulltext search/highlight
        $text = $obj->body();
        $sanitized_text = "";
        $text_i = strtolower($text);
        $queryarray = is_array($queryarray) ? $queryarray : array($queryarray);
        //@todo look into xoopslocal
        foreach ($queryarray as $query) {
            $pos = strpos($text_i, strtolower($query));
            //xoops_local("strpos", $text_i, strtolower($query));
            $start = max($pos - 100, 0);
            $length = strlen($query) + 200;
            //xoops_local("strlen", $query) + 200;
            $context = $obj->highlight(XoopsLocale::substr($text, $start, $length, " [...]"), $query);
            $sanitized_text .= "<p>[...] " . $context . "</p>";
        }
        //End of highlight
        $item['text'] = $sanitized_text;
        $item['author'] = $obj->getVar('author_alias');
        $item['datesub'] = $obj->datesub($publisher->getConfig('format_date'));
        $usersIds[$obj->getVar('uid')] = $obj->getVar('uid');
        $ret[] = $item;
        unset($item, $sanitized_text);
    }
    $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true);
    foreach ($ret as $key => $item) {
        if ($item["author"] == '') {
            $ret[$key]["author"] = @$usersNames[$item["uid"]];
        }
    }
    unset($usersNames, $usersIds);
    return $ret;
}
Пример #2
0
 /**
  * @credits Thanks to Mithandir
  *
  * @param string $str
  * @param int    $start
  * @param int    $length
  * @param string $trimmarker
  *
  * @return string
  */
 public static function substr($str, $start, $length, $trimmarker = '...')
 {
     // if the string is empty, let's get out ;-)
     if ($str == '') {
         return $str;
     }
     // reverse a string that is shortened with '' as trimmarker
     $reversed_string = strrev(XoopsLocale::substr($str, $start, $length, ''));
     // find first space in reversed string
     $position_of_space = strpos($reversed_string, " ", 0);
     // truncate the original string to a length of $length
     // minus the position of the last space
     // plus the length of the $trimmarker
     $truncated_string = XoopsLocale::substr($str, $start, $length - $position_of_space + strlen($trimmarker), $trimmarker);
     return $truncated_string;
 }
Пример #3
0
 public function displayReply()
 {
     $xoops = Xoops::getInstance();
     $modid = Request::getInt('com_modid', 0);
     if (empty($modid)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $module = $xoops->getModuleById($modid);
     if (!is_object($module)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     if (!$xoops->isAdminSide && COMMENTS_APPROVENONE == $xoops->getModuleConfig('com_rule', $module->getVar('dirname')) || !$xoops->isUser() && !$xoops->getModuleConfig('com_anonpost', $module->getVar('dirname')) || !$xoops->isModule()) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     //Original comment
     $comment = $this->getHandlerComment()->get(Request::getInt('com_id', 0));
     /* @var $reply CommentsComment */
     $reply = $this->getHandlerComment()->create();
     $title = $comment->getVar('title', 'e');
     if (!preg_match("/^" . XoopsLocale::C_RE . "/i", $title)) {
         $title = XoopsLocale::C_RE . " " . XoopsLocale::substr($title, 0, 56);
     }
     $reply->setVar('title', $title);
     $reply->setVar('modid', $comment->getVar('modid'));
     $reply->setVar('pid', $comment->getVar('id'));
     $reply->setVar('rootid', $comment->getVar('rootid'));
     $reply->setVar('itemid', $comment->getVar('itemid'));
     $xoops->header();
     echo $this->renderHeader($comment->getVar('title'), $comment->getVar('text'), $comment->getVar('uid'), $comment->getVar('created'));
     $this->displayCommentForm($reply);
     $xoops->footer();
 }
Пример #4
0
$module_id = $xoops->module->getVar('mid');
$form = new Xoops\Form\GroupPermissionForm($title_of_form, $module_id, $perm_name, $perm_desc, 'admin/permissions.php', $anonymous);
if ($op === "access") {
    $member_handler = $xoops->getHandlerMember();
    $glist = $member_handler->getGroupList();
    foreach (array_keys($glist) as $i) {
        if ($i != FixedGroups::ANONYMOUS) {
            $form->addItem($i, $glist[$i]);
        }
    }
} else {
    /* @var $profile_handler ProfileProfileHandler */
    $profile_handler = \Xoops::getModuleHelper('profile')->getHandler('profile');
    $fields = $profile_handler->loadFields();
    if ($op !== "search") {
        foreach (array_keys($fields) as $i) {
            if ($restriction == "" || $fields[$i]->getVar($restriction)) {
                $form->addItem($fields[$i]->getVar('field_id'), XoopsLocale::substr($fields[$i]->getVar('field_title'), 0, 25));
            }
        }
    } else {
        $searchable_types = array('textbox', 'select', 'radio', 'yesno', 'date', 'datetime', 'timezone', 'language');
        foreach (array_keys($fields) as $i) {
            if (in_array($fields[$i]->getVar('field_type'), $searchable_types)) {
                $form->addItem($fields[$i]->getVar('field_id'), XoopsLocale::substr($fields[$i]->getVar('field_title'), 0, 25));
            }
        }
    }
}
$form->display();
$xoops->footer();
Пример #5
0
/**
 * @deprecated
 * @param string $str
 * @param int $start
 * @param int $length
 * @param string $trimmarker
 * @return string
 */
function xoops_substr($str, $start, $length, $trimmarker = '...')
{
    $xoops = Xoops::getInstance();
    $xoops->deprecated(__FUNCTION__ . ' is deprecated since XOOPS 2.6.0. See how to replace it in file ' . __FILE__ . ' line ' . __LINE__);
    return XoopsLocale::substr($str, $start, $length, $trimmarker);
}
Пример #6
0
        }
        $edituser->setVar('url', $xoops->formatURL(Request::getUrl('url', '')));
        $edituser->setVar('user_icq', Request::getString('user_icq', ''));
        $edituser->setVar('user_from', Request::getString('user_from', ''));
        $edituser->setVar('user_sig', XoopsLocale::substr(Request::getString('user_sig', ''), 0, 255));
        $edituser->setVar('user_viewemail', Request::getBool('user_viewemail', 0));
        $edituser->setVar('user_aim', Request::getString('user_aim', ''));
        $edituser->setVar('user_yim', Request::getString('user_yim', ''));
        $edituser->setVar('user_msnm', Request::getString('user_msnm', ''));
        $edituser->setVar('attachsig', Request::getBool('attachsig', 0));
        $edituser->setVar('timezone', Request::getString('timezone', 'UTC'));
        $edituser->setVar('uorder', Request::getInt('uorder', 0));
        $edituser->setVar('umode', Request::getString('umode', 'flat'));
        $edituser->setVar('notify_method', Request::getInt('notify_method', 1));
        $edituser->setVar('notify_mode', Request::getInt('notify_mode', 1));
        $edituser->setVar('bio', XoopsLocale::substr(Request::getString('bio', ''), 0, 255));
        $edituser->setVar('user_occ', Request::getString('user_occ', ''));
        $edituser->setVar('user_intrest', Request::getString('user_intrest', ''));
        $edituser->setVar('user_mailok', Request::getBool('user_mailok', 0));
        if (!$member_handler->insertUser($edituser)) {
            $xoops->header();
            echo $edituser->getHtmlErrors();
            $xoops->footer();
        } else {
            $xoops->redirect('userinfo.php?uid=' . $uid, 1, XoopsLocale::S_YOUR_PROFILE_UPDATED);
        }
        exit;
    }
}
if ($op === 'editprofile') {
    $xoops->header('module:system/system_edituser.tpl');