本文整理匯總了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;
}