本文整理汇总了PHP中Horde_String::wordwrap方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_String::wordwrap方法的具体用法?PHP Horde_String::wordwrap怎么用?PHP Horde_String::wordwrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_String
的用法示例。
在下文中一共展示了Horde_String::wordwrap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deflist
public function deflist($block)
{
$elements = explode($this->wiki->delim, $block);
$term = false;
$list = array();
foreach ($elements as $element) {
if ($term === false) {
$term = $element;
} else {
$list[$term] = $element;
$term = false;
}
}
$term_length = max(array_map('strlen', array_keys($list)));
$result = '';
foreach ($list as $term => $info) {
$lead = Horde_String::pad($term . ': ', $term_length + 2);
$definition = Horde_String::wordwrap($lead . $info, max(80, $term_length + 30), "\n" . str_repeat(' ', $term_length + 3));
$result .= ':' . $definition . "\n";
}
$result .= "\n";
return $result;
}
示例2: _exportvData
//.........这里部分代码省略.........
$value = $this->_exportUtcOffset($value);
break;
// Integer fields.
// Integer fields.
case 'PERCENT-COMPLETE':
case 'PRIORITY':
case 'REPEAT':
case 'SEQUENCE':
$value = "{$value}";
break;
// Geo fields.
// Geo fields.
case 'GEO':
if ($this->_oldFormat) {
$value = $value['longitude'] . ',' . $value['latitude'];
} else {
$value = $value['latitude'] . ';' . $value['longitude'];
}
break;
// Recurrence fields.
// Recurrence fields.
case 'EXRULE':
case 'RRULE':
break;
default:
if ($this->_oldFormat) {
if (is_array($attribute['values']) && count($attribute['values']) > 1) {
$values = $attribute['values'];
if ($name == 'N' || $name == 'ADR' || $name == 'ORG') {
$glue = ';';
} else {
$glue = ',';
}
$values = str_replace(';', '\\;', $values);
$value = implode($glue, $values);
} else {
/* vcard 2.1 and vcalendar 1.0 escape only
* semicolons */
$value = str_replace(';', '\\;', $value);
}
// Text containing newlines or ASCII >= 127 must be BASE64
// or QUOTED-PRINTABLE encoded. Currently we use
// QUOTED-PRINTABLE as default.
if (preg_match("/[^ -]/", $value) && empty($params['ENCODING'])) {
$params['ENCODING'] = 'QUOTED-PRINTABLE';
$params_str .= ';ENCODING=QUOTED-PRINTABLE';
// Add CHARSET as well. At least the synthesis client
// gets confused otherwise
if (empty($params['CHARSET'])) {
$params['CHARSET'] = 'UTF-8';
$params_str .= ';CHARSET=' . $params['CHARSET'];
}
}
} else {
if (is_array($attribute['values']) && count($attribute['values'])) {
$values = $attribute['values'];
if ($name == 'N' || $name == 'ADR' || $name == 'ORG') {
$glue = ';';
} else {
$glue = ',';
}
// As of rfc 2426 2.5 semicolon and comma must be
// escaped.
$values = str_replace(array('\\', ';', ','), array('\\\\', '\\;', '\\,'), $values);
$value = implode($glue, $values);
} else {
// As of rfc 2426 2.5 semicolon and comma must be
// escaped.
$value = str_replace(array('\\', ';', ','), array('\\\\', '\\;', '\\,'), $value);
}
$value = preg_replace('/\\r?\\n/', '\\n', $value);
}
break;
}
$value = str_replace("\r", '', $value);
if (!empty($params['ENCODING']) && $params['ENCODING'] == 'QUOTED-PRINTABLE' && strlen(trim($value))) {
$result .= $name . $params_str . ':' . preg_replace(array('/(?<!\\r)\\n/', '/(?<!=)\\r\\n/'), array("\r\n", "=0D=0A=\r\n "), quoted_printable_encode($value)) . $this->_newline;
} else {
$attr_string = $name . $params_str . ':' . $value;
if (!$this->_oldFormat) {
if (isset($params['ENCODING']) && $params['ENCODING'] == 'b') {
$attr_string = trim(chunk_split($attr_string, 75, $this->_newline . ' '));
} else {
$attr_string = Horde_String::wordwrap($attr_string, 75, $this->_newline . ' ', true, true);
}
}
$result .= $attr_string . $this->_newline;
}
}
$tzs = array();
foreach ($this->_components as $component) {
if (!$component instanceof Horde_Icalendar_Vtimezone || !isset($tzs[$component->getAttribute('TZID')])) {
$result .= $component->exportvCalendar();
if ($component instanceof Horde_Icalendar_Vtimezone) {
$tzs[$component->getAttribute('TZID')] = true;
}
}
}
return $result . 'END:' . $base . $this->_newline;
}
示例3: handle
/**
* Determine if this module should act. Run all required actions if it has
* been instructed to do so.
*
* @param Components_Config $config The configuration.
*
* @return boolean True if the module performed some action.
*/
public function handle(Components_Config $config)
{
$arguments = $config->getArguments();
if (isset($arguments[0]) && $arguments[0] == 'help') {
if (isset($arguments[1])) {
$action = $arguments[1];
} else {
$action = '';
}
$modules = $this->_dependencies->getModules();
foreach ($modules->getModules()->listModules() as $module) {
$element = $modules->getProvider()->getModule($module);
if (in_array($action, $element->getActions())) {
$title = "ACTION \"" . $action . "\"";
$sub = str_repeat('-', strlen($title));
$help = "\n" . $title . "\n" . $sub . "\n\n";
$help .= Horde_String::wordwrap($element->getHelp($action), 75, "\n", true);
$options = $element->getContextOptionHelp();
if (!empty($options)) {
$formatter = new Horde_Argv_IndentedHelpFormatter();
$parser = $this->_dependencies->getParser();
$title = "OPTIONS for \"" . $action . "\"";
$sub = str_repeat('-', strlen($title));
$help .= "\n\n\n" . $title . "\n" . $sub . "";
foreach ($options as $option => $help_text) {
$argv_option = $parser->getOption($option);
$help .= "\n\n " . $formatter->formatOptionStrings($argv_option) . "\n\n ";
if (empty($help_text)) {
$help .= Horde_String::wordwrap($argv_option->help, 75, "\n ", true);
} else {
$help .= Horde_String::wordwrap($help_text, 75, "\n ", true);
}
}
}
$help .= "\n";
$this->_dependencies->getOutput()->help($help);
return true;
}
}
return false;
}
}
示例4: wrap
/**
* Wraps the text of a message.
*
* @param string $text Horde_String containing the text to wrap.
* @param integer $length Wrap $text at this number of characters.
* @param string $break_char Character(s) to use when breaking lines.
* @param string $charset Character set to use when breaking lines.
* @param boolean $quote Ignore lines that are wrapped with the '>'
* character (RFC 2646)? If true, we don't
* remove any padding whitespace at the end of
* the string.
*
* @return string Horde_String containing the wrapped text.
*/
public function wrap($text, $length = 80, $break_char = "\n", $charset = null, $quote = false)
{
$paragraphs = array();
foreach (preg_split('/\\r?\\n/', $text) as $input) {
if ($quote && strpos($input, '>') === 0) {
$line = $input;
} else {
/* We need to handle the Usenet-style signature line
* separately; since the space after the two dashes is
* REQUIRED, we don't want to trim the line. */
if ($input != '-- ') {
$input = rtrim($input);
}
$line = Horde_String::wordwrap($input, $length, $break_char, false, $charset);
}
$paragraphs[] = $line;
}
return implode($break_char, $paragraphs);
}