當前位置: 首頁>>代碼示例>>PHP>>正文


PHP String::indent方法代碼示例

本文整理匯總了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;
 }
開發者ID:romcok,項目名稱:treeview,代碼行數:32,代碼來源:InstantClientScript.php

示例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>
開發者ID:Ephigenia,項目名稱:harrison,代碼行數:31,代碼來源:default.php

示例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;
 }
開發者ID:jakubkulhan,項目名稱:shopaholic,代碼行數:16,代碼來源:TemplateHelpers.php

示例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;
 }
開發者ID:regiss,項目名稱:texyla-s-Nete1-PhP-5.2,代碼行數:33,代碼來源:InstantClientScript.php

示例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, '   '));
 }
開發者ID:vrana,項目名稱:nette,代碼行數:16,代碼來源:NetteStringTest.php

示例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;
 }
開發者ID:radypala,項目名稱:maga-website,代碼行數:16,代碼來源:TemplateHelpers.php

示例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;
 }
開發者ID:Ephigenia,項目名稱:PHPOptParse,代碼行數:37,代碼來源:PHPOptParse.php


注:本文中的String::indent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。