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


PHP Str::length方法代码示例

本文整理汇总了PHP中Str::length方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::length方法的具体用法?PHP Str::length怎么用?PHP Str::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Str的用法示例。


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

示例1: byQuery

 /**
  * Use current dataprovider to perform seacrh
  * by given query and return view with results.
  * 
  * @return View
  */
 public function byQuery()
 {
     $input = (string) Input::get('q');
     if (!$input || Str::length($input) <= 1) {
         return View::make('search.results')->withTerm('');
     }
     if (is_a($this->search, 'Lib\\Services\\Search\\DbSearch')) {
         $encoded = $input;
     } else {
         $encoded = urlencode($input);
     }
     $clean = e($input);
     //make search cache section name
     $section = 'search' . $this->provider;
     if ($encoded) {
         if (Helpers::hasSuperAccess()) {
             $results = $this->search->byQuery($encoded);
         } else {
             if ($this->options->useCache()) {
                 $results = $this->cache->get($section, md5($encoded));
                 if (!$results || count($results) == 0) {
                     $results = $this->search->byQuery($encoded);
                     $this->cache->put($section, md5($encoded), $results);
                 }
             } else {
                 $results = $this->search->byQuery($encoded);
             }
         }
         return View::make('search.results')->withData($results)->withTerm($clean);
     }
     return View::make('search.results')->withTerm($clean);
 }
开发者ID:samirios1,项目名称:niter,代码行数:38,代码来源:SearchController.php

示例2: pageAction

 /**
  * Alliance page action.
  *
  * @return Bengine_Comm_Controller_Alliance
  */
 public function pageAction()
 {
     Core::getLanguage()->load("Alliance");
     Core::getTPL()->clearHTMLHeaderFiles();
     Core::getTPL()->addHTMLHeaderFile("game.css", "css");
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
     $tag = $this->getParam("1");
     $fNumber = array("member", "points", "rpoints", "fpoints", "dpoints");
     $attr = array("a.aid", "a.name", "a.tag", "a.logo", "a.textextern", "a.homepage", "a.showhomepage", "COUNT(u2a.userid) AS member", "SUM(u.points) AS points", "SUM(u.rpoints) AS rpoints", "SUM(u.fpoints) AS fpoints", "SUM(u.dpoints) AS dpoints");
     $joins = "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.aid = a.aid) ";
     $joins .= "LEFT JOIN " . PREFIX . "user u ON (u2a.userid = u.userid) ";
     $result = Core::getQuery()->select("alliance a", $attr, $joins, Core::getDB()->quoteInto("tag = ?", $tag), "", 1, "a.aid");
     $row = $result->fetchRow();
     if ($row) {
         foreach ($fNumber as $field) {
             $row[$field] = fNumber($row[$field]);
         }
         $parser = new Bengine_Game_Alliance_Page_Parser($row["aid"]);
         if (Str::length(strip_tags($row["textextern"])) > 0) {
             $row["textextern"] = $parser->startParser($row["textextern"]);
         } else {
             $row["textextern"] = Core::getLang()->get("WELCOME");
         }
         $row["homepage"] = $row["homepage"] != "" ? Link::get($row["homepage"], $row["homepage"], $row["homepage"]) : "";
         $row["logo"] = $row["logo"] != "" ? Image::getImage($row["logo"], "") : "";
         Hook::event("ShowPublicAlliancePage", array(&$row));
         $this->assign($row);
         $this->setIsAjax();
     } else {
         $this->setNoDisplay(true);
     }
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:38,代码来源:Alliance.php

示例3: action_main

 public function action_main($params = array())
 {
     $config = $this->config;
     $gConfig = \Config::load('novius_social_widget::config', true);
     if (Arr::get($gConfig, 'embed_js', true)) {
         if (!empty($config['js'])) {
             foreach ($config['js'] as $script) {
                 Nos::main_controller()->addJavascript($script);
             }
         }
     }
     $chrome = array();
     $typeList = array('chrome');
     foreach ($params as $param => $value) {
         if ($value) {
             foreach ($typeList as $type) {
                 $typePrefix = "{$type}-";
                 if ($value && \Str::starts_with($param, $typePrefix)) {
                     array_push(${$type}, \Str::sub($param, \Str::length($typePrefix)));
                 }
             }
         }
     }
     return \View::forge('novius_social_widget::front/enhancer/twitter', array('widgetId' => $params['widget-id'], 'chrome' => $chrome, 'limit' => \Arr::get($params, 'limit'), 'width' => \Arr::get($params, 'width'), 'height' => \Arr::get($params, 'height')), false);
 }
开发者ID:novius,项目名称:novius_social_widget,代码行数:25,代码来源:twitter.ctrl.php

示例4: validate

 /**
  * Validate the data.
  *
  * @return boolean
  */
 public function validate()
 {
     if ($this->getData() != "" && !filter_var($this->getData(), FILTER_VALIDATE_URL) || Str::length($this->getData()) > $this->getSetup("max_length", 255)) {
         $this->addError("INVALID_URL");
         return false;
     }
     return true;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:13,代码来源:Url.php

示例5: clean

 /**
  * Remove all elements with no content.
  *
  * @param array $array	Array to be cleaned
  *
  * @return array		Cleaned array
  */
 public static function clean($array)
 {
     $rArray = array();
     for ($i = 0; $i < count($array); $i++) {
         if (Str::length($array[$i]) > 0) {
             $rArray[$i] = $array[$i];
         }
     }
     return $rArray;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:17,代码来源:Arr.util.php

示例6: setDestination

 /**
  * Sets the destination folder.
  *
  * @param string $destination
  * @throws Recipe_Exception_Generic
  * @return Recipe_Language_Exporter
  */
 public function setDestination($destination)
 {
     if (!is_dir($destination) || !is_writable($destination)) {
         throw new Recipe_Exception_Generic("Export destination folder does not exist or is not writable.");
     }
     if (Str::substring($destination, 0, Str::length($destination) - 1) != "/") {
         $destination .= "/";
     }
     $this->destination = $destination;
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:18,代码来源:Exporter.php

示例7: store

 public function store()
 {
     $pass = false;
     $inputs = Input::all();
     if (!array_key_exists('pregunta_1', $inputs) or !array_key_exists('pregunta_2', $inputs) or !array_key_exists('pregunta_3', $inputs) or !array_key_exists('pregunta_4', $inputs)) {
         echo $errors = 'Debe contestar todas las preguntas';
         return Redirect::back()->withErrors($errors)->withInput();
     } else {
         foreach ($inputs as $key => $value) {
             if ($key != '_token') {
                 if (array_get($value, 'value', '') == '') {
                     echo $errors = 'Debe contestar todas las preguntas';
                     return Redirect::back()->withErrors($errors)->withInput();
                 }
             }
         }
     }
     $cr = new ClientesRespuesta();
     $cr->id_cliente = Auth::user()->id_cliente;
     $cr->ultima_respuesta = Carbon::now();
     $cr->id_estado = 15;
     if ($cr->save()) {
         $cli_resp = $cr->id_cliente_respuesta;
     } else {
         Event::fire('form_error');
     }
     if (!is_null($cli_resp)) {
         $respuesta_detalle = array();
         foreach ($inputs as $key => $value) {
             if ($key != '_token') {
                 $respuesta = Respuesta::insertGetId(array('fecha' => Carbon::now(), 'id_estado' => '6', 'id_canal' => Session::get('canal'), 'id_encuesta' => Session::get('encuesta', 1), 'id_pregunta' => (int) str_replace('pregunta_', '', $key), 'id_pregunta_detalle' => 1, 'id_cliente' => Auth::user()->id_cliente, 'id_cliente_respuesta' => $cli_resp, 'created_at' => Carbon::now()));
                 if (!is_null($respuesta)) {
                     $val = array_get($value, 'value');
                     $text = array_get($value, 'text');
                     array_push($respuesta_detalle, array('valor1' => trim($val) != '' ? $val : null, 'valor2' => trim($text) != '' && Str::length($text) > 0 ? $text : null, 'id_respuesta' => $respuesta, 'created_at' => Carbon::now()));
                 } else {
                     Event::fire('form_error');
                 }
             }
         }
     }
     unset($resp_d);
     unset($resp);
     unset($inputs);
     if (RespuestasDetalle::insert($respuesta_detalle)) {
         Session::flush();
         $msg = array('data' => array('type' => 'success', 'text' => '<i class="fa fa-check fa-fw"></i>Gracias por tu tiempo y disponibilidad en responder, ¡Tu opinión es muy importante!'));
         $script = "setTimeout('window.location.href=\"http://www.umayor.cl/\";', 5000); if (typeof window.event == 'undefined'){ document.onkeypress = function(e){ var test_var=e.target.nodeName.toUpperCase(); if (e.target.type) var test_type=e.target.type.toUpperCase(); if ((test_var == 'INPUT' && test_type == 'TEXT') || test_var == 'TEXTAREA'){ return e.keyCode; }else if (e.keyCode == 8 || e.keyCode == 116 || e.keyCode == 122){ e.preventDefault(); } } }else{ document.onkeydown = function(){ var test_var=event.srcElement.tagName.toUpperCase(); if (event.srcElement.type) var test_type=event.srcElement.type.toUpperCase(); if ((test_var == 'INPUT' && test_type == 'TEXT') || test_var == 'TEXTAREA'){ return event.keyCode; } else if (event.keyCode == 8 || e.keyCode == 116 || e.keyCode == 122){ event.returnValue=false; } } } ";
         return View::make('messages', compact('msg', 'script'));
     } else {
         Event::fire('form_error');
     }
 }
开发者ID:mazebeat,项目名称:encuesta_umayor,代码行数:53,代码来源:EncuestasController.php

示例8: validate

 /**
  * Validate the data.
  *
  * @return boolean
  */
 public function validate()
 {
     $text = $this->getData();
     if (Str::length(trim(str_replace("&nbsp;", "", strip_tags($text)))) > 0) {
         if ($this->getSetup("max_length", 10000) < Str::length($text)) {
             $this->addError("TEXT_TOO_LARGE");
             return false;
         }
         $this->setData(richText($text));
     } else {
         $this->setData("");
     }
     return true;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:19,代码来源:Richtext.php

示例9: seekAction

 /**
  * @return Bengine_Admin_Controller_User
  */
 protected function seekAction()
 {
     $username = $this->getParam("username");
     $email = $this->getParam("email");
     if ($this->getParam("delete_user")) {
         $this->deleteUser($this->getParam("delete"));
     }
     $s = false;
     $sr = array();
     if (!$username || !$email) {
         $username = Str::replace("%", "", $username);
         $username = Str::replace("*", "%", $username);
         $userwhere = "";
         if (Str::length(Str::replace("%", "", $username)) > 0) {
             $userwhere = Core::getDB()->quoteInto("username LIKE ?", "%{$username}%");
             $s = true;
         }
         $email = Str::replace("%", "", $email);
         $email = Str::replace("*", "%", $email);
         $mailwhere = "";
         if (Str::length(Str::replace("%", "", $email)) > 0) {
             $mailwhere = Core::getDB()->quoteInto("email LIKE ?", "%{$email}%");
             $s = true;
         }
     }
     if ($s) {
         $where = "";
         if (!empty($userwhere)) {
             $where = $userwhere;
             if (!empty($mailwhere)) {
                 $where .= " OR " . $mailwhere;
             }
         } else {
             if (!empty($mailwhere)) {
                 $where = $mailwhere;
             }
         }
         $result = Core::getQuery()->select("user", array("userid", "username", "email"), "", $where);
         foreach ($result->fetchAll() as $row) {
             $id = $row["userid"];
             $sr[$id]["userid"] = $id;
             $sr[$id]["edit"] = Link::get("admin/user/edit/" . $id, Core::getLanguage()->getItem("Edit"));
             $sr[$id]["username"] = $row["username"];
             $sr[$id]["email"] = "<a href=\"mailto:" . $row["email"] . "\">" . $row["email"] . "</a>";
         }
     }
     Core::getTPL()->addLoop("searchresult", $sr);
     Core::getTPL()->assign("searched", $s);
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:53,代码来源:User.php

示例10: postNew

 /**
  * Post method to process the form
  **/
 public function postNew()
 {
     //first, let's validate the form
     $validation = Validator::make(Input::all(), Question::$add_rules);
     if ($validation->passes()) {
         //First, let's create the question
         $create = Question::create(array('userID' => Sentry::getUser()->id, 'title' => Input::get('title'), 'question' => Input::get('question')));
         //We get the insert id of the question
         $insert_id = $create->id;
         //Now, we need to re-find the question to "attach" the tag to the question
         $question = Question::find($insert_id);
         //Now, we should check if tags column is filled, and split the string and add a new tag and a relation
         if (Str::length(Input::get('tags'))) {
             //let's explode all tags from the comma
             $tags_array = explode(',', Input::get('tags'));
             //if there are any tags, we will check if they are new, if so, we will add them to database
             //After checking the tags, we will have to "attach" tag(s) to the new question
             if (count($tags_array)) {
                 foreach ($tags_array as $tag) {
                     //first, let's trim and get rid of the extra space bars between commas
                     //(tag1, tag2, vs tag1,tag2)
                     $tag = trim($tag);
                     //We should double check its length, because the user may have just typed "tag1,,tag2" (two or more commas) accidentally
                     //We check the slugged version of the tag, because tag string may only be meaningless character(s), like "tag1,+++//,tag2"
                     if (Str::length(Str::slug($tag))) {
                         //the URL-Friendly version of the tag
                         $tag_friendly = Str::slug($tag);
                         //Now let's check if there is a tag with the url friendly version of the provided tag already in our database:
                         $tag_check = Tag::where('tagFriendly', $tag_friendly);
                         //if the tag is a new tag, then we will create a new one
                         if ($tag_check->count() == 0) {
                             $tag_info = Tag::create(array('tag' => $tag, 'tagFriendly' => $tag_friendly));
                             //If the tag is not new, this means There was a tag previously added on the same name to another question previously
                             //We still need to get that tag's info from our database
                         } else {
                             $tag_info = $tag_check->first();
                         }
                     }
                     //Now the attaching the current tag to the question
                     $question->tags()->attach($tag_info->id);
                 }
             }
         }
         //lastly, we should return the user to the asking page with a permalink of the question
         return Redirect::route('ask')->with('success', 'Your question has been created successfully! ' . HTML::linkRoute('question_details', 'Click here to see your question', array('id' => $insert_id, 'title' => Str::slug($question->title))));
     } else {
         return Redirect::route('ask')->withInput()->with('error', $validation->errors()->first());
     }
 }
开发者ID:suchayj,项目名称:easymanage,代码行数:52,代码来源:QuestionController.php

示例11: size

 protected function size($attribute, $value)
 {
     // This method will determine if the attribute is a number, string, or file and
     // return the proper size accordingly. If it is a number, the number itself is
     // the size; if it is a file, the kilobytes is the size; if it is a
     // string, the length is the size.
     if (is_numeric($value) and $this->has_rule($attribute, $this->numeric_rules)) {
         return $this->attributes[$attribute];
     } elseif (array_key_exists($attribute, Input::file())) {
         $key = array_search(max($value['size']), $value['size']);
         return $value['size'][$key] / 1024;
     } else {
         return Str::length(trim($value));
     }
 }
开发者ID:sanneterpstra,项目名称:Kamergenood,代码行数:15,代码来源:validator.php

示例12: assign

 /**
  * @param string|array $variable
  * @param mixed $value
  * @return \Recipe_Template_Adapter_Standard
  */
 public function assign($variable, $value = null)
 {
     if (is_array($variable)) {
         foreach ($variable as $key => $val) {
             if (Str::length($key) > 0) {
                 $this->assign($key, $val);
             }
         }
     } else {
         if (is_string($variable) || is_numeric($variable)) {
             if (Str::length($variable) > 0) {
                 $this->_data[$variable] = $value;
             }
         }
     }
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:22,代码来源:Standard.php

示例13: getImage

 /**
  * Generate image tag in HTML.
  *
  * @param string $url		Image URL
  * @param string $title		Additional title
  * @param integer $width	Image width
  * @param integer $height	Image height
  * @param string $cssClass	Additional CSS class designation
  *
  * @return string			Image tag
  */
 public static function getImage($url, $title, $width = null, $height = null, $cssClass = "")
 {
     $isExternal = Link::isExternal($url);
     if (Core::getUser()->get("theme") != "" && !$isExternal) {
         $url = Core::getUser()->get("theme") . "img/" . $url;
     }
     if (!$isExternal) {
         $url = BASE_URL . "img/" . $url;
     } else {
         $url = BASE_URL . "img/remote.php?file=" . $url;
     }
     if (Str::length($cssClass) == 0) {
         $cssClass = self::IMAGE_CSS_CLASS;
     }
     $width = !is_null($width) ? " width=\"" . $width . "\"" : "";
     $height = !is_null($height) ? " height=\"" . $height . "\"" : "";
     $img = "<img src=\"" . $url . "\" title=\"" . $title . "\" alt=\"" . $title . "\"" . $width . $height . " class=\"" . $cssClass . "\" />";
     return $img;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:30,代码来源:Image.util.php

示例14: send

 /**
  * @return Bengine_Admin_Controller_Globalmail
  */
 protected function send()
 {
     $subject = Str::validateXHTML($this->getParam("subject"));
     $message = richtext(nl2br($this->getParam("message")));
     if (Str::length($message) < 10) {
         Core::getTPL()->assign("messageError", Logger::getMessageField("MESSAGE_TOO_SHORT"));
         $error = true;
     }
     if (Str::length($subject) == 0) {
         Core::getTPL()->assign("subjectError", Logger::getMessageField("SUBJECT_TOO_SHORT"));
         $error = true;
     }
     if (!empty($error)) {
         return $this;
     }
     $sql = "INSERT INTO `" . PREFIX . "message` (`mode`, `time`, `sender`, `receiver`, `subject`, `message`, `read`) SELECT ?, ?, NULL, " . PREFIX . "user.userid, ?, ?, ? FROM " . PREFIX . "user";
     Core::getDB()->query($sql, array(1, TIME, $subject, $message, 0));
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:22,代码来源:Globalmail.php

示例15: get

 /**
  * Set required data for link.
  *
  * @param string $url				URL to link
  * @param string $name				Link name
  * @param string $title				Additional title
  * @param string $cssClass			Particular css class
  * @param string $attachment		Additional attachment for link
  * @param boolean $appendSession	Append session id to url
  * @param boolean $rewrite			Activate URL rewrite
  * @param boolean $refDir			Refer external URLs to "refdir"
  *
  * @return string	HTML link
  */
 public static function get($url, $name, $title = "", $cssClass = "", $attachment = "", $appendSession = false, $rewrite = true, $refDir = true)
 {
     if (Str::length($cssClass) <= 0) {
         if (self::isExternal($url)) {
             $cssClass = self::CSS_EXTERNAL_URL;
         } else {
             $cssClass = self::CSS_NORMAL_URL;
         }
     }
     if (Str::length($attachment) > 0) {
         $attachment = " " . $attachment;
     }
     if (self::isExternal($url) && $refDir) {
         $link = "<a href=\"" . BASE_URL . "refdir.php?url=" . $url . "\" title=\"" . $title . "\" class=\"" . $cssClass . "\"" . $attachment . ">" . $name . "</a>";
     } else {
         $url = self::url($url, $appendSession);
         $link = "<a href=\"" . $url . "\" title=\"" . $title . "\" class=\"" . $cssClass . "\"" . $attachment . ">" . $name . "</a>";
     }
     return $link;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:34,代码来源:Link.util.php


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