当前位置: 首页>>代码示例>>PHP>>正文


PHP sf函数代码示例

本文整理汇总了PHP中sf函数的典型用法代码示例。如果您正苦于以下问题:PHP sf函数的具体用法?PHP sf怎么用?PHP sf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runController

 private static function runController($url)
 {
     bu::lib(sf('%s_application', $url->getBinType()));
     $class_name = sf('%sApplication', ucfirst($url->getBinType()));
     $app = new $class_name();
     $app->runController($url);
 }
开发者ID:Bubujka,项目名称:bubujka.framework,代码行数:7,代码来源:bu_loader.php

示例2: get_sitemap_booklist

 function get_sitemap_booklist()
 {
     global $database;
     $cate1 = $database->clear_param()->select(array('id', 'title'), 'cate1')->fetch();
     foreach ($cate1 as $data1) {
         $this->sitemap[] = ['/' . sf($data1['title'], 0) . '.' . $data1['id'], 'weekly', '0.80'];
         $id_list = [];
         $cate2 = $database->clear_param()->select(array('id', 'title'), 'cate2')->where(array('id1' => array('=', $data1['id'])))->fetch();
         foreach ($cate2 as $data2) {
             $this->sitemap[] = ['/' . sf($data1['title'], 0) . '/' . sf($data2['title'], 0) . '.' . $data2['id'], 'weekly', '0.80'];
             $id_list[] = $data2['id'];
             $num2 = $database->clear_param()->select(array('id'), 'book')->where(['cid' => ['=', $data2['id']]])->num_rows();
             $page2 = ceil($num2 / 12);
             if ($page2 > 1) {
                 for ($i2 = 1; $i2 <= $page2; $i2++) {
                     $this->sitemap[] = ['/' . sf($data1['title'], 0) . '/' . sf($data2['title'], 0) . '.' . $data2['id'] . '/trang-' . $i2, 'weekly', '0.80'];
                 }
             }
         }
         $num = $database->clear_param()->select(array('id'), 'book')->where(['cid' => ['IN', $id_list]])->num_rows();
         $page = ceil($num / 12);
         if ($page > 1) {
             for ($i = 1; $i <= $page; $i++) {
                 $this->sitemap[] = ['/' . sf($data1['title'], 0) . '.' . $data1['id'] . '/trang-' . $i, 'weekly', '0.80'];
             }
         }
     }
 }
开发者ID:h2dvnnet,项目名称:eLib,代码行数:28,代码来源:sitemap.php

示例3: renderElement

 function renderElement()
 {
     $date = $this->getValue();
     $minValue = is_array($date) && array_key_exists('min', $date) ? $date['min'] : null;
     $maxValue = is_array($date) && array_key_exists('max', $date) ? $date['max'] : null;
     $minOptions = sfl("<option value='' >Any</option>");
     for ($i = $this->ageMin; $i <= $this->ageMax; $i++) {
         // TODO: Bug here days don't always return the correct number of days...
         if ($minValue == $i) {
             $minOptions .= sfl("<option value='%s' selected='selected'>%s</option>", $i, $i);
         } else {
             $minOptions .= sfl("<option value='%s'>%s</option>", $i, $i);
         }
     }
     $maxOptions = sfl("<option value='' >Any</option>");
     for ($i = $this->ageMin; $i <= $this->ageMax; $i++) {
         // TODO: Bug here days don't always return the correct number of days...
         if ($maxValue == $i) {
             $maxOptions .= sfl("<option value='%s' selected='selected'>%s</option>", $i, $i);
         } else {
             $maxOptions .= sfl("<option value='%s'>%s</option>", $i, $i);
         }
     }
     $out = sfl("<select name='%s[min]' id='form_%s' %s class='inputAgeRange inputAgeRangeMin' >%s</select>", $this->getName(), $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $minOptions);
     $out .= sfl("<span class='inputAgeRangeSeparator'>%s</span> <select name='%s[max]' id='form_%s' %s class='inputAgeRange inputAgeRangeMax' >%s</select>", $this->separator, $this->getName(), $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $maxOptions);
     return $out;
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:27,代码来源:widget_AgeRangeElement.php

示例4: validate

 public function validate($arr)
 {
     if (empty($arr)) {
         return true;
     }
     $empty = true;
     foreach ($arr as $item) {
         if (!empty($item)) {
             $empty = false;
             break;
         }
     }
     if ($empty) {
         return true;
     }
     if (!is_array($arr)) {
         throw new Exception($this->errorMessage);
     }
     foreach ($this->requiredFields as $key => $value) {
         if (strlen($arr[$value]) > $this->maxChars) {
             throw new Exception(sf("You have entered: '<em>%s</em>'  this is over the allowed %s characters.", $arr[$value], $this->maxChars));
         }
     }
     /*
     
     if(empty($data) || strlen($data) < $this->maxChars)
     	return true;
     else 
     	throw new Exception(sf("You must enter less than %s characters",
     								$this->maxChars
     						));
     */
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:33,代码来源:validate_ArrayMaxChars.php

示例5: render

 public function render($options = array())
 {
     $out = $this->preRender();
     $out .= sf("%s", $this->html);
     $out .= $this->postRender();
     return $out;
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:7,代码来源:widget_HtmlElement.php

示例6: getInstructions

    public function getInstructions($contentType)
    {
        switch ($contentType) {
            default:
            case 'text/plain':
                return sf('--Description\\nYou need to use the $this->setView() method within your function.\\n
--Example Code\\n
	public function %s() {

			$this->setView(string $ViewClassName);
			/* ... put your controller code here ... */

	}\\n', $this->method);
                break;
            case 'text/html':
                return sf('<h4>Description</h4><p>You need to use the $this->setView() method within your function.</p>
<h4>Example Code</h4>
<pre class="code">
public function %s() {

		$this->setView(<strong>string <em>$ViewClassName</em></strong>);
		/* ... put your controller code here ... */

}
</pre>', $this->method);
                break;
        }
    }
开发者ID:jenalgit,项目名称:atsumi,代码行数:28,代码来源:mvc_NoViewSpecifiedException.php

示例7: text

 /**
  * Casts a variable into a MySql text
  * @param string $in String to be casted
  * @return string Casted string
  */
 static function text($in)
 {
     if (!is_string($in)) {
         throw new caster_StrictTypeException('Expected String, received: ' . $in . ' (' . gettype($in) . ')');
     }
     return sf("%s", $in);
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:12,代码来源:caster_MySqlToPhp.php

示例8: renderElement

 function renderElement()
 {
     $address = $this->getValue();
     if (!is_array($address)) {
         $address = array();
     }
     if (!array_key_exists('address1', $address)) {
         $address['address1'] = null;
     }
     if (!array_key_exists('address2', $address)) {
         $address['address2'] = null;
     }
     if (!array_key_exists('postcode', $address)) {
         $address['postcode'] = null;
     }
     if (!array_key_exists('town', $address)) {
         $address['town'] = null;
     }
     /*
      * The rendering of this element is SO messy due to IE compatibility - needs rewriting
      *
      */
     $out = sf("<div style='float:left;'><input type='text' name='%s[address1]' value='%s' %s id='form_%s' class='inputUkAddress inputUkAddress1' /><br />", $this->getName(), parent::makeInputSafe($address['address1']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sf("<input type='text' name='%s[address2]' value='%s' %s id='form_%s' class='text' class='inputUkAddress inputUkAddress2' /><br />", $this->getName(), parent::makeInputSafe($address['address2']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sf("</div><div style='clear:both;'><label for='form_%s'>%s</label>", $this->getName(), "Post Code");
     $out .= sfl("<table style='border:0px; border-spacing:0px;.' cellpadding=0 cellspacing=0><tr><td style=''><input type='text' name='%s[postcode]' value='%s' %s id='form_%s' class='postCode'  class='inputUkAddress inputUkAddressPostCode'  />", $this->getName(), parent::makeInputSafe($address['postcode']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sfl("</td><td class='tRight'><label class='town'>Town</label></td><td><input type='text' name='%s[town]' value='%s' %s id='form_%s' class='town'  class='inputUkAddress inputUkAddressTown' /></td></tr></table></div>", $this->getName(), parent::makeInputSafe($address['town']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     return $out;
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:29,代码来源:widget_UkAddressElement.php

示例9: validate

 public function validate($data)
 {
     // test if the host supports finfo
     try {
         $supportsFinfo = class_exists('finfo');
     } catch (loader_ClassNotFoundException $e) {
         $supportsFinfo = false;
     }
     if ($data == '') {
         return true;
         // if finfo class exists then use that for mime validation
     } elseif ($supportsFinfo && $data['tmp_name']) {
         $finfo = new finfo(FILEINFO_MIME);
         $mime = $finfo->file($data['tmp_name']);
         if (strpos($mime, ';')) {
             $mime = substr($mime, 0, strpos($mime, ';'));
         }
         if (in_array($mime, $this->mimeTypes)) {
             return true;
         }
         $incorrectExtensionArr = $this->getExtensionFromMime($mime);
         // reply on the browsers mime type : not always present & secruity vunrebility
     } elseif (isset($data['type'])) {
         if (in_array($data['type'], $this->mimeTypes)) {
             return true;
         }
         $incorrectExtensionArr = $this->getExtensionFromMime($data['type']);
     }
     throw new ValidationIncorrectFileTypeException(sf('File should be a valid %s%s', $this->extensionText, count($incorrectExtensionArr) ? sf(' (not a %s)', implode('/', $incorrectExtensionArr)) : ''));
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:30,代码来源:validate_FileType.php

示例10: connect

 /**
  * PostgreSql Connect function, config options are:
  *
  * host			: The hostname on which the database server resides
  * port			: The port number where the database server is listening
  * dbname		: The name of the database
  * username		: The name of the user for the connection
  * password		: The password of the user for the connection
  *
  * @param $config array An array of settings
  */
 public function connect($config = array())
 {
     // Build the vender connection string
     $conString = sf('pgsql:%s%s%s', isset($config['host']) ? sf(' host=%s', $config['host']) : '', isset($config['port']) ? sf(' port=%s', $config['port']) : '', isset($config['dbname']) ? sf(' dbname=%s', $config['dbname']) : '');
     // Call the base connection function
     $this->connectReal($conString, $config);
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:18,代码来源:db_PostgreSql.php

示例11: getInstructions

    public function getInstructions($contentType)
    {
        switch ($contentType) {
            default:
            case 'text/plain':
                return sf('--Description\\nThe view class you specified could not be found. Please make sure you have named the class name the same as the filename and the class folder is loaded using Atsumi\'s load method.\\n
--Example basic HTML view\\n
	/*Save this as <strong>%s.php</strong> within a folder within classes/. Make sure you load the directory using Atsumi::load(); */
	class %s extends mvc_HtmlView {
		public function renderBodyContent() {
			/* ... put view code here ... */
		}
	}\\n', $this->viewName, $this->viewName);
                break;
            case 'text/html':
                return sf('<h4>Description</h4><p>The view class you specified could not be found. Please make sure you have named the class name the same as the filename and the class folder is loaded using Atsumi\'s load method.</p>
<h4>Example basic HTML view</h4>
<pre class="code">
/*Save this as <strong>%s.php</strong> within a folder within classes/. Make sure you load the directory using Atsumi::load(); */
class %s extends mvc_HtmlView {
		public function renderBodyContent() {
			/* ... put view code here ... */
		}
}
</pre>', $this->viewName, $this->viewName);
                break;
        }
    }
开发者ID:jenalgit,项目名称:atsumi,代码行数:28,代码来源:mvc_ViewNotFoundException.php

示例12: renderElement

 function renderElement()
 {
     $optionHtml = "";
     $elementValue = $this->getValue();
     if (!$this->defaultValue && $this->blankMessage) {
         $optionHtml .= sfl("<option value='' >%s</option>", $this->blankMessage);
     } elseif ($this->defaultValue) {
         // TODO: put this in a func...
         foreach ($this->defaultValue as $value => $option) {
             if (strval($elementValue) == strval($value)) {
                 $optionHtml .= sfl("<option value='%s' selected='selected'>%s</option>", $value, $option);
             } else {
                 $optionHtml .= sfl("<option value='%s'>%s</option>", $value, $option);
             }
         }
     }
     foreach ($this->options as $value => $option) {
         if (strval($elementValue) == strval($value)) {
             $optionHtml .= sfl("<option value='%s' selected='selected'>%s</option>", $value, $option);
         } else {
             $optionHtml .= sfl("<option value='%s'>%s</option>", $value, $option);
         }
     }
     return sfl("<select name='%s' %s id='form_%s' class='inputSelect'>%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $optionHtml);
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:25,代码来源:widget_SelectElement.php

示例13: renderElement

 function renderElement()
 {
     $name = $this->getValue();
     if (!is_array($name)) {
         $name = array();
     }
     if (!array_key_exists('title', $name)) {
         $name['title'] = null;
     }
     if (!array_key_exists('firstName', $name)) {
         $name['firstName'] = null;
     }
     if (!array_key_exists('lastName', $name)) {
         $name['lastName'] = null;
     }
     $titleOptions = sfl("<option value='' >Title</option>");
     foreach ($this->titles as $title => $data) {
         if ($name['title'] == $title) {
             $titleOptions .= sfl("<option value='%s' selected='selected'>%s</option>", parent::makeInputSafe($title), $data['text']);
         } else {
             $titleOptions .= sfl("<option value='%s'>%s</option>", parent::makeInputSafe($title), $data['text']);
         }
     }
     $out = sfl("<select name='%s[title]' %s id='form_%s' class='inputName inputNameTitle' >%s</select>", $this->getName(), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName(), $titleOptions);
     $out .= sfl("<input type='text' name='%s[firstName]' value='%s' %s id='form_%s' class='inputName inputNameFirst' class='text' />", $this->getName(), parent::makeInputSafe($name['firstName']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     $out .= sfl("<input type='text' name='%s[lastName]' value='%s' %s id='form_%s' class='inputName inputNameLast' class='text' />", $this->getName(), parent::makeInputSafe($name['lastName']), $this->tabindex ? sf('tabindex="%s"', $this->tabindex) : '', $this->getName());
     return $out;
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:28,代码来源:widget_NameElement.php

示例14: validate

 public function validate($data)
 {
     if (empty($data) || str_word_count($data) <= $this->maxWords) {
         return true;
     } else {
         throw new Exception(sf("You must enter %s words or less.", $this->maxWords));
     }
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:8,代码来源:validate_MaxWords.php

示例15: validate

 public function validate($data)
 {
     if (empty($data) || str_word_count($data) >= $this->minWords) {
         return true;
     } else {
         throw new Exception(sf("You must enter %s or more words", $this->minWords));
     }
 }
开发者ID:jenalgit,项目名称:atsumi,代码行数:8,代码来源:validate_MinWords.php


注:本文中的sf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。