当前位置: 首页>>代码示例>>PHP>>正文


PHP XoopsLocale::substr方法代码示例

本文整理汇总了PHP中XoopsLocale::substr方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsLocale::substr方法的具体用法?PHP XoopsLocale::substr怎么用?PHP XoopsLocale::substr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XoopsLocale的用法示例。


在下文中一共展示了XoopsLocale::substr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: publisher_search

/**
 * @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 <lusopoemas@gmail.com>
 * @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;
}
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:66,代码来源:search.inc.php

示例2: substr

 /**
  * @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;
 }
开发者ID:mambax7,项目名称:publisher-26,代码行数:26,代码来源:utils.php

示例3: displayReply

 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();
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:32,代码来源:helper.php

示例4: foreach

$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();
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:31,代码来源:permissions.php

示例5: xoops_substr

/**
 * @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);
}
开发者ID:RanLee,项目名称:XoopsCore,代码行数:14,代码来源:functions.php

示例6:

        }
        $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');
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:31,代码来源:edituser.php


注:本文中的XoopsLocale::substr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。