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


PHP CMbString::truncate方法代码示例

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


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

示例1: getHtmlValue

 /**
  * @see parent::getHtmlValue()
  */
 function getHtmlValue($object, $smarty = null, $params = array())
 {
     $value = $object->{$this->fieldName};
     // Empty value: no paragraph
     if (!$value) {
         return "";
     }
     // Truncate case: no breakers but inline bullets instead
     if ($truncate = CValue::read($params, "truncate")) {
         $value = CMbString::truncate($value, $truncate === true ? null : $truncate);
         $value = CMbString::nl2bull($value);
         return CMbString::htmlSpecialChars($value);
     }
     // Markdown case: full delegation
     if ($this->markdown) {
         // In order to prevent from double escaping
         $content = CMbString::markdown(html_entity_decode($value));
         return "<div class='markdown'>{$content}</div>";
     }
     // Standard case: breakers and paragraph enhancers
     $text = "";
     $value = str_replace(array("\r\n", "\r"), "\n", $value);
     $paragraphs = preg_split("/\n{2,}/", $value);
     foreach ($paragraphs as $_paragraph) {
         if (!empty($_paragraph)) {
             $_paragraph = nl2br(CMbString::htmlSpecialChars($_paragraph));
             $text .= "<p>{$_paragraph}</p>";
         }
     }
     return $text;
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:34,代码来源:CTextSpec.class.php

示例2: updateFormFields

 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = CMbString::truncate($this->traitement, 40);
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:8,代码来源:CTraitement.class.php

示例3: truncate

 /**
  * Truncate a string to a given maximum length
  *
  * @param string $string The string to truncate
  *
  * @return string The truncated string
  */
 public static function truncate($string)
 {
     if (!is_string($string)) {
         return $string;
     }
     // Truncate
     $max = 1024;
     $result = CMbString::truncate($string, $max);
     // Indicate true size
     $length = strlen($string);
     if ($length > 1024) {
         $result .= " [{$length} bytes]";
     }
     return $result;
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:22,代码来源:CSOAPClient.class.php

示例4: updateFormFields

 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = $this->_name;
     $this->_shortview = CMbString::truncate($this->_name);
     $this->_cp_court = substr($this->cp, 0, 2);
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:10,代码来源:CGroups.class.php

示例5: check

 /**
  * Check all properties according to specification
  *
  * @return string|null Store-like message, null when no problem
  */
 function check()
 {
     $debug = CAppUI::conf("debug");
     $msg = "";
     // Property level checking
     foreach ($this->_props as $name => $prop) {
         if ($name[0] !== '_') {
             if (!property_exists($this, $name)) {
                 trigger_error("La spécification cible la propriété '{$name}' inexistante dans la classe '{$this->_class}'", E_USER_WARNING);
             } else {
                 $value = $this->{$name};
                 if (!$this->_id || $value !== null) {
                     $msgProp = $this->checkProperty($name);
                     $truncated = CMbString::truncate($value);
                     $debugInfo = $debug ? "(val:\"{$truncated}\", prop:\"{$prop}\")" : "(valeur: \"{$truncated}\")";
                     $fieldName = CAppUI::tr("{$this->_class}-{$name}");
                     $msg .= $msgProp ? " &bull; <strong title='{$name}'>{$fieldName}</strong> : {$msgProp} {$debugInfo} <br/>" : null;
                 }
             }
         }
     }
     if ($this->_merging) {
         return $msg;
     }
     // Class level unique checking
     foreach ($this->_spec->uniques as $unique => $names) {
         /** @var self $other */
         $other = new $this->_class();
         $values = array();
         foreach ($names as $name) {
             $this->completeField($name);
             $other->{$name} = addslashes($this->{$name});
             $value = "";
             if ($this->_specs[$name] instanceof CRefSpec) {
                 $fwd = $this->loadFwdRef($name);
                 if ($fwd) {
                     $value = $fwd->_view;
                 }
             } else {
                 $value = $this->{$name};
             }
             $values[] = $value;
         }
         $other->loadMatchingObject();
         if ($other->_id && $this->_id != $other->_id) {
             return CAppUI::tr("{$this->_class}-failed-{$unique}") . " : " . implode(", ", $values);
         }
     }
     // Class-level xor checking
     foreach ($this->_spec->xor as $xor => $names) {
         $n = 0;
         $fields = array();
         foreach ($names as $name) {
             $this->completeField($name);
             $fields[] = CAppUI::tr("{$this->_class}-{$name}");
             if ($this->{$name}) {
                 $n++;
             }
         }
         if ($n != 1) {
             return CAppUI::tr("{$this->_class}-xorFailed-{$xor}") . ": " . implode(", ", $fields) . ")";
         }
     }
     return $msg;
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:70,代码来源:CStoredObject.class.php

示例6: updateFormFields

 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = ucwords(strtolower($this->text));
     $this->_shortview = CMbString::truncate($this->_view);
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:9,代码来源:CDiscipline.class.php

示例7: updateFormFields

 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = $this->title ? $this->title : CMbString::truncate($this->text, 30);
     $this->_no_size = true;
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:9,代码来源:CExClassMessage.class.php

示例8: checkParam

 /**
  * Check a parameter
  *
  * @param string $name  Name of the parameter
  * @param string $prop  Property specification of the parameter
  * @param string $value Value of the paramter
  *
  * @return any
  */
 public static function checkParam($name, $prop, $value)
 {
     self::$params->{$name} =& $value;
     // Check the name
     if (in_array($name, self::$protected_names)) {
         $error = "View parameter '{$name}' is a protected name and should NOT be used.";
         trigger_error($error, E_USER_WARNING);
     }
     // Check duplicates
     if (array_key_exists($name, self::$props)) {
         $error = "View parameter '{$name}' is already in use.";
         trigger_error($error, E_USER_WARNING);
     }
     // Get Specification
     self::$props[$name] = $prop;
     $spec = CMbFieldSpecFact::getSpecWithClassName("stdClass", $name, $prop);
     // Defaults the value when available
     if (empty($value) && $spec->default) {
         $value = $spec->default;
     }
     // Could be null
     if ($value === "" || $value === null) {
         if (!$spec->notNull) {
             return $value;
         }
     }
     // Check the value
     if ($msg = $spec->checkPropertyValue(self::$params)) {
         $truncated = CMbString::truncate($value);
         $error = "View parameter '{$name}' with spec '{$prop}' has inproper value '{$truncated}': {$msg}";
         trigger_error($error, E_USER_WARNING);
     }
     return $value;
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:43,代码来源:CView.class.php


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