本文整理汇总了PHP中String::indent方法的典型用法代码示例。如果您正苦于以下问题:PHP String::indent方法的具体用法?PHP String::indent怎么用?PHP String::indent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::indent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValidateScript
private function getValidateScript(Rules $rules)
{
$res = '';
foreach ($rules as $rule) {
if (!is_string($rule->operation)) {
continue;
}
if (strcasecmp($rule->operation, 'Nette\\Forms\\InstantClientScript::javascript') === 0) {
$res .= "{$rule->arg}\n";
continue;
}
$script = $this->getClientScript($rule->control, $rule->operation, $rule->arg);
if (!$script) {
continue;
}
if (!empty($rule->message)) {
// this is rule
$res .= "{$script}\n" . "if (" . ($rule->isNegative ? '' : '!') . "res) " . "return " . json_encode((string) vsprintf($rule->control->translate($rule->message, is_int($rule->arg) ? $rule->arg : NULL), (array) $rule->arg)) . ";\n";
}
if ($rule->type === Rule::CONDITION) {
// this is condition
$innerScript = $this->getValidateScript($rule->subRules);
if ($innerScript) {
$res .= "{$script}\nif (" . ($rule->isNegative ? '!' : '') . "res) {\n" . String::indent($innerScript) . "}\n";
if ($rule->control instanceof ISubmitterControl) {
$this->central = FALSE;
}
}
}
}
return $res;
}
示例2:
</div>
<?php
} else {
echo $this->element('header');
?>
<div id="app">
<?php
echo $this->element('mainMenu');
?>
<?php
echo $this->element('flashMessage');
?>
<div id="content">
<?php
echo @$content;
?>
</div>
<?php
echo $this->element('footer');
?>
</div>
<?php
}
if (isset($JavaScript)) {
$JavaScript->addFiles(array('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js', 'js.class.core', 'php.custom.min', 'swfobject.js', 'jquery.placeholder/jquery.placeholder.js', 'jquery.plugin.fieldselection', 'jquery.plugin.dialog', 'jquery.plugin.simplePreview', 'admin', 'tabs'));
echo String::indent($JavaScript->render(), 2, TAB, 1);
}
echo $this->element('debug/dump');
?>
</body>
</html>
示例3: indent
/**
* Indents the HTML content from the left.
* @param string UTF-8 encoding or 8-bit
* @param int
* @param string
* @return string
*/
public static function indent($s, $level = 1, $chars = "\t")
{
if ($level >= 1) {
$s = preg_replace_callback('#<(textarea|pre).*?</\\1#si', array(__CLASS__, 'indentCb'), $s);
$s = String::indent($s, $level, $chars);
$s = strtr($s, "", "\r\n");
}
return $s;
}
示例4: getValidateScript
private function getValidateScript(Rules $rules)
{
$res = '';
foreach ($rules as $rule) {
if (!is_string($rule->operation)) {
continue;
}
if (strcasecmp($rule->operation, 'Nette\\Forms\\InstantClientScript::javascript') === 0) {
$res .= "{$rule->arg}\n";
continue;
}
$script = $this->getClientScript($rule->control, $rule->operation, $rule->arg);
if (!$script) {
continue;
}
if (!empty($rule->message)) {
// this is rule
$message = Rules::formatMessage($rule, FALSE);
$res .= "{$script}\n" . "if (" . ($rule->isNegative ? '' : '!') . "res) " . "return " . json_encode((string) $message) . (strpos($message, '%value') === FALSE ? '' : ".replace('%value', val);\n") . ";\n";
}
if ($rule->type === Rule::CONDITION) {
// this is condition
$innerScript = $this->getValidateScript($rule->subRules);
if ($innerScript) {
$res .= "{$script}\nif (" . ($rule->isNegative ? '!' : '') . "res) {\n" . String::indent($innerScript) . "}\n";
if ($rule->control instanceof ISubmitterControl) {
$this->central = FALSE;
}
}
}
}
return $res;
}
示例5: testIndent
/**
* indent test.
* @return void
*/
public function testIndent()
{
$this->assertEquals("", String::indent(""));
$this->assertEquals("\n", String::indent("\n"));
$this->assertEquals("\tword", String::indent("word"));
$this->assertEquals("\n\tword", String::indent("\nword"));
$this->assertEquals("\n\tword", String::indent("\nword"));
$this->assertEquals("\n\tword\n", String::indent("\nword\n"));
$this->assertEquals("\r\n\tword\r\n", String::indent("\r\nword\r\n"));
$this->assertEquals("\r\n\t\tword\r\n", String::indent("\r\nword\r\n", 2));
$this->assertEquals("\r\n word\r\n", String::indent("\r\nword\r\n", 2, ' '));
}
示例6: indent
/**
* Indents the HTML content from the left.
* @param string UTF-8 encoding or 8-bit
* @param int
* @param string
* @return string
*/
public static function indent($s, $level = 1, $chars = "\t")
{
if ($level >= 1) {
$s = String::replace($s, '#<(textarea|pre).*?</\\1#si', callback(create_function('$m', 'return strtr($m[0], " \\t\\r\\n", "\\x1F\\x1E\\x1D\\x1A");')));
$s = String::indent($s, $level, $chars);
$s = strtr($s, "", " \t\r\n");
}
return $s;
}
示例7: renderOptUsage
private function renderOptUsage(array $optionInfo, $width = 80)
{
$optionValue = '';
if (isset($optionInfo['dest']) && isset($optionInfo['type']) && $optionInfo['type'] != self::TYPE_BOOL) {
$optionValue .= ' ' . strtoupper($optionInfo['dest']);
}
// collect short and long options
$argList = array();
if (!empty($optionInfo['short'])) {
$argList[] = '-' . $optionInfo['short'] . $optionValue;
}
if (!empty($optionInfo['long'])) {
$argList[] = '--' . $optionInfo['long'] . $optionValue;
}
$argListRendered = ' ' . implode(', ', $argList);
$usage = $argListRendered;
// add description to argument hint if set
if (isset($optionInfo['help'])) {
// if the usage parameters is to long, put help to the next line
if (strlen($usage) > 22) {
$usage .= LF;
$helpMessage = wordwrap($optionInfo['help'], $width - 24 - 2, LF, true);
$usage .= String::indent($helpMessage, 24, ' ');
// or add the parameter help message in the next line, indented
} else {
$usage .= str_repeat(' ', 24 - strlen($usage));
$m = wordwrap($optionInfo['help'], $width - 24, LF, true);
$a = explode(LF, $m);
$usage .= array_shift($a);
if (count($a) > 0) {
$usage .= LF;
}
$usage .= String::indent(implode(LF, $a), 24, ' ');
}
}
return $usage;
}