本文整理汇总了PHP中Nette\String::indent方法的典型用法代码示例。如果您正苦于以下问题:PHP String::indent方法的具体用法?PHP String::indent怎么用?PHP String::indent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\String
的用法示例。
在下文中一共展示了String::indent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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', function ($m) {
return strtr($m[0], " \t\r\n", "");
});
$s = String::indent($s, $level, $chars);
$s = strtr($s, "", " \t\r\n");
}
return $s;
}
示例3: 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 " . Nette\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" . Nette\String::indent($innerScript) . "}\n";
if ($rule->control instanceof ISubmitterControl) {
$this->central = FALSE;
}
}
}
}
return $res;
}