本文整理匯總了PHP中StringUtil類的典型用法代碼示例。如果您正苦於以下問題:PHP StringUtil類的具體用法?PHP StringUtil怎麽用?PHP StringUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了StringUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getStaticStrings
/**
* Loads all the static strings from either the cache or the ini files. Note that ini files in modules are not verified for outdatedness, so if they were updated, just clear all the caches or hard reload a page
* This method should not be called directly from outsite TranslationPeer except for testing and debugging purposes
*/
public static function getStaticStrings($sLanguageId)
{
if (!isset(self::$STATIC_STRINGS[$sLanguageId])) {
$oCache = new Cache($sLanguageId, DIRNAME_LANG);
$aLanguageFiles = ResourceFinder::create()->addPath(DIRNAME_LANG, "{$sLanguageId}.ini")->all()->baseFirst()->find();
if ($oCache->entryExists() && !$oCache->isOutdated($aLanguageFiles)) {
self::$STATIC_STRINGS[$sLanguageId] = $oCache->getContentsAsVariable();
} else {
self::$STATIC_STRINGS[$sLanguageId] = array();
//Get default strings
foreach ($aLanguageFiles as $sLanguageFile) {
self::$STATIC_STRINGS[$sLanguageId] = array_merge(self::$STATIC_STRINGS[$sLanguageId], parse_ini_file($sLanguageFile));
}
//Get strings for modules
foreach (ResourceFinder::create()->addExpression(DIRNAME_MODULES, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN, DIRNAME_LANG, "{$sLanguageId}.ini")->all()->baseFirst()->find() as $sLanguageFile) {
self::$STATIC_STRINGS[$sLanguageId] = array_merge(self::$STATIC_STRINGS[$sLanguageId], parse_ini_file($sLanguageFile));
}
//Fix string encoding
foreach (self::$STATIC_STRINGS[$sLanguageId] as $sStringKey => $sValue) {
self::$STATIC_STRINGS[$sLanguageId][$sStringKey] = StringUtil::encodeForDbFromFile($sValue);
}
$oCache->setContents(self::$STATIC_STRINGS[$sLanguageId]);
}
}
return self::$STATIC_STRINGS[$sLanguageId];
}
示例2: getOptionsForUser
/**
* Returns the image sizes for the given user suitable for widgets.
*
* @param BackendUser $user
*
* @return array
*/
public function getOptionsForUser(BackendUser $user)
{
$this->loadOptions();
$event = new ImageSizesEvent($user->isAdmin ? $this->options : $this->filterOptions(\StringUtil::deserialize($user->imageSizes, true)), $user);
$this->eventDispatcher->dispatch(ContaoCoreEvents::IMAGE_SIZES_USER, $event);
return $event->getImageSizes();
}
示例3: readParameters
/**
* @see Page::readParameters()
*/
public function readParameters()
{
parent::readParameters();
if (isset($_REQUEST['q'])) {
$this->input = StringUtil::trim($_REQUEST['q']);
}
}
示例4: sanitize
/**
* Elimina acento y reemplaza espacio con '-'
*
* @param String word
*/
public static function sanitize($word)
{
$word = StringUtil::eliminateUnwantedChars($word);
$word = str_replace(" ", "-", $word);
$word = strtolower($word);
return $word;
}
示例5: actionIndex
public function actionIndex()
{
if (isset($_GET["pagesize"])) {
$this->setListPageSize($_GET["pagesize"]);
}
$key = StringUtil::filterCleanHtml(EnvUtil::getRequest("keyword"));
$fields = array("frp.runid", "frp.processid", "frp.flowprocess", "frp.flag", "frp.opflag", "frp.processtime", "ft.freeother", "ft.flowid", "ft.name as typeName", "ft.type", "ft.listfieldstr", "fr.name as runName", "fr.beginuser", "fr.begintime", "fr.endtime", "fr.focususer");
$sort = "frp.processtime";
$group = "frp.runid";
$condition = array("and", "fr.delflag = 0", "frp.childrun = 0", sprintf("frp.uid = %d", $this->uid), sprintf("FIND_IN_SET(fr.focususer,'%s')", $this->uid));
if ($key) {
$condition[] = array("like", "fr.runid", "%{$key}%");
$condition[] = array("or like", "fr.name", "%{$key}%");
}
$count = Ibos::app()->db->createCommand()->select("count(*) as count")->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->group($group)->queryScalar();
$pages = PageUtil::create($count, $this->getListPageSize());
if ($key && $count) {
$pages->params = array("keyword" => $key);
}
$offset = $pages->getOffset();
$limit = $pages->getLimit();
$list = Ibos::app()->db->createCommand()->select($fields)->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order($sort)->group($group)->offset($offset)->limit($limit)->queryAll();
$data = array_merge(array("pages" => $pages), $this->handleList($list));
$this->setPageTitle(Ibos::lang("My focus"));
$this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow")), array("name" => Ibos::lang(Ibos::lang("My focus")), "url" => $this->createUrl("focus/index")), array("name" => Ibos::lang("List"))));
$this->render("index", $data);
}
示例6: actionEdit
public function actionEdit()
{
if (EnvUtil::submitCheck("emailSubmit")) {
$setting = array();
foreach ($this->_fields as $field) {
if (array_key_exists($field, $_POST)) {
$setting[$field] = intval($_POST[$field]);
} else {
$setting[$field] = 0;
}
}
$roles = array();
if (isset($_POST["role"])) {
foreach ($_POST["role"] as $role) {
if (!empty($role["positionid"]) && !empty($role["size"])) {
$positionId = StringUtil::getId($role["positionid"]);
$roles[implode(",", $positionId)] = intval($role["size"]);
}
}
}
$setting["emailroleallocation"] = serialize($roles);
foreach ($setting as $key => $value) {
Setting::model()->updateSettingValueByKey($key, $value);
}
CacheUtil::update("setting");
$this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("dashboard/index"));
}
}
示例7: compile
/**
* Generate the module
*/
protected function compile()
{
$this->Template->src = $this->singleSRC;
$this->Template->href = $this->source == 'external' ? $this->url : $this->singleSRC;
$this->Template->alt = $this->altContent;
$this->Template->var = 'swf' . $this->id;
$this->Template->transparent = $this->transparent ? true : false;
$this->Template->interactive = $this->interactive ? true : false;
$this->Template->flashId = $this->flashID ?: 'swf_' . $this->id;
$this->Template->fsCommand = ' ' . preg_replace('/[\\n\\r]/', "\n ", \StringUtil::decodeEntities($this->flashJS));
$this->Template->flashvars = 'URL=' . \Environment::get('base');
$this->Template->version = $this->version ?: '6.0.0';
$size = \StringUtil::deserialize($this->size);
$this->Template->width = $size[0];
$this->Template->height = $size[1];
$intMaxWidth = TL_MODE == 'BE' ? 320 : \Config::get('maxImageWidth');
// Adjust movie size
if ($intMaxWidth > 0 && $size[0] > $intMaxWidth) {
$this->Template->width = $intMaxWidth;
$this->Template->height = floor($intMaxWidth * $size[1] / $size[0]);
}
if (strlen($this->flashvars)) {
$this->Template->flashvars .= '&' . \StringUtil::decodeEntities($this->flashvars);
}
}
示例8: testGetByContentTypeReturnsDefaultWithNoneSet
/**
* @depends testGetByContentTypeReturnsNullWithNoneSetAndNoDefault
*/
public function testGetByContentTypeReturnsDefaultWithNoneSet()
{
$isHtmlContent = false;
$unsubscribeUrlPlaceHolder = static::resolveUnsubscribeMergeTagContent($isHtmlContent);
$manageSubscriptionsUrlPlaceHolder = static::resolveManageSubscriptionMergeTagContent($isHtmlContent);
$recipientMention = 'This email was sent to [[PRIMARY^EMAIL]].';
StringUtil::prependNewLine($unsubscribeUrlPlaceHolder, $isHtmlContent);
StringUtil::prependNewLine($manageSubscriptionsUrlPlaceHolder, $isHtmlContent);
StringUtil::prependNewLine($recipientMention, $isHtmlContent);
$defaultFooter = $unsubscribeUrlPlaceHolder . $manageSubscriptionsUrlPlaceHolder . $recipientMention;
$plainTextFooter = GlobalMarketingFooterUtil::getContentByType($isHtmlContent);
$this->assertNotNull($plainTextFooter);
$this->assertEquals($defaultFooter, $plainTextFooter);
$isHtmlContent = true;
$unsubscribeUrlPlaceHolder = static::resolveUnsubscribeMergeTagContent($isHtmlContent);
$manageSubscriptionsUrlPlaceHolder = static::resolveManageSubscriptionMergeTagContent($isHtmlContent);
$recipientMention = 'This email was sent to [[PRIMARY^EMAIL]].';
StringUtil::prependNewLine($unsubscribeUrlPlaceHolder, $isHtmlContent);
StringUtil::prependNewLine($manageSubscriptionsUrlPlaceHolder, $isHtmlContent);
StringUtil::prependNewLine($recipientMention, $isHtmlContent);
$defaultFooter = $unsubscribeUrlPlaceHolder . $manageSubscriptionsUrlPlaceHolder . $recipientMention;
$richTextFooter = GlobalMarketingFooterUtil::getContentByType($isHtmlContent);
$this->assertNotNull($richTextFooter);
$this->assertEquals($defaultFooter, $richTextFooter);
}
示例9: save
/**
* @see Form::save()
*/
public function save()
{
parent::save();
// send content type
header('Content-Type: text/' . $this->fileType . '; charset=' . CHARSET);
header('Content-Disposition: attachment; filename="export.' . $this->fileType . '"');
if ($this->fileType == 'xml') {
echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<addresses>\n";
}
// get users
$sql = "SELECT\t\temail\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tWHERE\t\tuserID IN (" . $this->userIDs . ")\n\t\t\tORDER BY\temail";
$result = WCF::getDB()->sendQuery($sql);
$i = 0;
$j = WCF::getDB()->countRows($result) - 1;
while ($row = WCF::getDB()->fetchArray($result)) {
if ($this->fileType == 'xml') {
echo "<address><![CDATA[" . StringUtil::escapeCDATA($row['email']) . "]]></address>\n";
} else {
echo $this->textSeparator . $row['email'] . $this->textSeparator . ($i < $j ? $this->separator : '');
}
$i++;
}
if ($this->fileType == 'xml') {
echo "</addresses>";
}
UserEditor::unmarkAll();
$this->saved();
exit;
}
示例10: loadTodo
private function loadTodo($num = 4)
{
$uid = Ibos::app()->user->uid;
$fields = array("frp.runid", "frp.processid", "frp.flowprocess", "ft.type", "frp.flag", "ft.flowid", "fr.name as runName", "fr.beginuser", "fr.focususer");
$condition = array("and", "fr.delflag = 0", "frp.childrun = 0", sprintf("frp.uid = %d", $uid));
$condition[] = array("in", "frp.flag", array(1, 2));
$sort = "frp.createtime DESC";
$group = "frp.id";
$runProcess = Ibos::app()->db->createCommand()->select($fields)->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order($sort)->group($group)->offset(0)->limit($num)->queryAll();
$allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId();
foreach ($runProcess as &$run) {
$run["user"] = User::model()->fetchByUid($run["beginuser"]);
if ($run["type"] == 1) {
if (isset($allProcess[$run["flowid"]][$run["flowprocess"]]["name"])) {
$run["stepname"] = $allProcess[$run["flowid"]][$run["flowprocess"]]["name"];
} else {
$run["stepname"] = Ibos::lang("Process steps already deleted", "workflow.default");
}
} else {
$run["stepname"] = Ibos::lang("Step", "", array("{step}" => $run["processid"]));
}
$run["focus"] = StringUtil::findIn($uid, $run["focususer"]);
$param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]);
$run["key"] = WfCommonUtil::param($param);
}
return $runProcess;
}
示例11: cutText
/**
* Cuts the given text to a specific lenght and adds ... at the and
*
* @param string $_text
* @param int $_lenght
* @param bool $_isFoldable (for unfolding / folding longer texts)
* @return string
*/
public static function cutText($_text, $_length, $_isFoldable = false)
{
$_text = strip_tags($_text);
if (function_exists("mb_strlen")) {
$length = mb_strlen($_text, "utf-8");
} else {
$length = strlen($_text);
}
if ($length > $_length) {
$cutLength = max(1, $_length - 3);
if (function_exists("mb_substr")) {
$text = mb_substr($_text, 0, $cutLength, "utf-8");
$textRest = mb_substr($_text, $cutLength, mb_strlen($_text, "utf-8"), "utf-8");
} else {
$text = substr($_text, 0, $cutLength);
$textRest = substr($_text, $cutLength);
}
if (!$_isFoldable) {
$text .= "...";
} else {
$id = "more_" . StringUtil::getRandom(5);
$text .= " " . "<a style=\"text-decoration: none; font-size: 0.8em;\" id=\"show_" . $id . "\" href=" . CURRENT_PAGE_QS . "/# onclick=\"getById('" . $id . "').style.display = 'inline'; showHide('show_" . $id . "'); showHide('hide_" . $id . "'); return false;\">(" . Lang::get("global.w.more") . ")</a>" . "<b style=\"margin: 0px; font-weight: normal; display: none;\" id=\"" . $id . "\">" . $textRest . "</b>" . "<a style=\"text-decoration: none; font-size: 0.8em; float: left; display: none;\" id=\"hide_" . $id . "\" href=" . CURRENT_PAGE_QS . "/# onclick=\"getById('" . $id . "').style.display = 'none'; showHide('hide_" . $id . "'); showHide('show_" . $id . "'); return false;\">(" . Lang::get("global.w.less") . ")</a>";
}
return $text;
} else {
return $_text;
}
}
示例12: compile
/**
* Generate the content element
*/
protected function compile()
{
/** @var \PageModel $objPage */
global $objPage;
// Clean RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \StringUtil::toXhtml($this->text);
} else {
$this->text = \StringUtil::toHtml5($this->text);
}
$this->Template->text = \StringUtil::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
$objModel = \FilesModel::findByUuid($this->singleSRC);
if ($objModel === null) {
if (!\Validator::isUuid($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
}
} elseif (is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
$classes = deserialize($this->mooClasses);
$this->Template->toggler = $classes[0] ?: 'toggler';
$this->Template->accordion = $classes[1] ?: 'accordion';
$this->Template->headlineStyle = $this->mooStyle;
$this->Template->headline = $this->mooHeadline;
}
示例13: getOutput
/**
* @see UserOptionOutput::getOutput()
*/
public function getOutput(User $user, $optionData, $value)
{
if (empty($value) || $value == '0') {
$value = 0.0;
}
return StringUtil::formatDouble($value, 2);
}
示例14: geturl
function geturl()
{
$phpself = getscripturl();
$isHTTPS = isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off" ? true : false;
$url = StringUtil::ihtmlSpecialChars("http" . ($isHTTPS ? "s" : "") . "://" . $_SERVER["HTTP_HOST"] . $phpself);
return $url;
}
示例15: readParameters
/**
* @see Action::readParameters()
*/
public function readParameters()
{
parent::readParameters();
if (!MODULE_MODERATED_USER_GROUP || !MODULE_PM) {
throw new IllegalLinkException();
}
if (isset($_POST['groupID'])) {
$this->groupID = intval($_POST['groupID']);
}
$this->group = new Group($this->groupID);
if (!$this->group->groupID) {
throw new IllegalLinkException();
}
// check permission
if (!GroupApplicationEditor::isGroupLeader(WCF::getUser(), $this->groupID)) {
throw new PermissionDeniedException();
}
if (isset($_POST['subject'])) {
$this->subject = StringUtil::trim($_POST['subject']);
}
if (isset($_POST['text'])) {
$this->text = StringUtil::trim($_POST['text']);
}
if (empty($this->subject) || empty($this->text)) {
throw new IllegalLinkException();
}
}