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


PHP WireData::set方法代码示例

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


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

示例1: set

 public function set($key, $value)
 {
     if ($key == 'lat' || $key == 'lng') {
         // if value isn't numeric, then it's not valid: make it blank
         if (strpos($value, ',') !== false) {
             $value = str_replace(',', '.', $value);
         }
         // convert 123,456 to 123.456
         if (!is_numeric($value)) {
             $value = '';
         }
     } else {
         if ($key == 'address') {
             $value = wire('sanitizer')->text($value);
         } else {
             if ($key == 'status') {
                 $value = (int) $value;
                 if (!isset($this->geocodeStatuses[$value])) {
                     $value = -1;
                 }
                 // -1 = unknown
             } else {
                 if ($key == 'zoom') {
                     $value = (int) $value;
                 }
             }
         }
     }
     return parent::set($key, $value);
 }
开发者ID:ryancramerdesign,项目名称:FieldtypeMapMarker,代码行数:30,代码来源:MapMarker.php

示例2: set

 /**
  * Set a native setting or a dynamic data property for this Field
  *
  */
 public function set($key, $value)
 {
     if ($key == 'name') {
         return $this->setName($value);
     } else {
         if ($key == 'type' && $value) {
             return $this->setFieldtype($value);
         } else {
             if ($key == 'prevTable') {
                 $this->prevTable = $value;
                 return $this;
             } else {
                 if ($key == 'prevFieldtype') {
                     $this->prevFieldtype = $value;
                     return $this;
                 } else {
                     if (in_array($key, array('id', 'flags'))) {
                         $value = (int) $value;
                     }
                 }
             }
         }
     }
     if (isset($this->settings[$key])) {
         $this->settings[$key] = $value;
     } else {
         return parent::set($key, $value);
     }
     return $this;
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:34,代码来源:Field.php

示例3: set

 public function set($key, $value)
 {
     if ($key == 'fieldChanges') {
         // convert string changes list of field names to array
         if (is_array($value)) {
             if (!trim(implode('', $value))) {
                 $value = array();
             }
         } else {
             $value = explode(' ', $value);
         }
         // sanitize
         foreach ($value as $k => $v) {
             $required = strpos($v, '+') === 0;
             if ($required) {
                 $v = ltrim($v, '+');
             }
             $v = $this->wire('sanitizer')->fieldName($v);
             if (empty($v)) {
                 continue;
             }
             $value[$k] = ($required ? '+' : '') . $v;
         }
     }
     return parent::set($key, $value);
 }
开发者ID:arjenblokzijl,项目名称:IftRunner,代码行数:26,代码来源:IftTrigger.php

示例4: set

 public function set($key, $value)
 {
     if (strpos($key, 'title') === 0 || strpos($key, 'value') === 0) {
         if (strpos($value, '|') !== false) {
             $this->error("{$key} may not contain the character '|'");
             $value = str_replace('|', ' ', $value);
         }
     }
     return parent::set($key, $value);
 }
开发者ID:Rizsti,项目名称:Processwire_Compatibility,代码行数:10,代码来源:SelectableOption.php

示例5: set

 public function set($key, $value)
 {
     if ($key == 'id' || $key == 'modules_id') {
         $value = (int) $value;
     } else {
         if ($key == 'name') {
             $value = $this->fuel('sanitizer')->name($value);
         }
     }
     return parent::set($key, $value);
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:11,代码来源:Permission.php

示例6: set

 /**
  * Set a value to the ImageMarker: date, location or notes
  *
  */
 public function set($key, $value)
 {
     if ($key == 'page') {
         $this->page = $value;
         return $this;
     } else {
         if ($key == 'info' || $key == 'x' || $key == 'y') {
             // int sanitizer
             $value = (int) $value;
         }
     }
     return parent::set($key, $value);
 }
开发者ID:kongondo,项目名称:FieldtypeImageMarker,代码行数:17,代码来源:ImageMarker.php

示例7: js

 /**
  * Set a config field that is shared in Javascript, OR retrieve one or all params already set
  *
  * Specify only a $key and omit the $value in order to retrieve an existing set value.
  * Specify no params to retrieve in array of all existing set values.
  *
  * @param string $key 
  * @param mixed $value
  *
  */
 public function js($key = null, $value = null)
 {
     if (is_null($key)) {
         $data = array();
         foreach ($this->jsFields as $field) {
             $data[$field] = $this->get($field);
         }
         return $data;
     } else {
         if (is_null($value)) {
             return in_array($key, $this->jsFields) ? $this->get($key) : null;
         }
     }
     $this->jsFields[] = $key;
     return parent::set($key, $value);
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:26,代码来源:Config.php

示例8: set

 /**
  * Set a user setting or data value
  *
  */
 public function set($key, $value)
 {
     if ($key == 'id') {
         $value = (int) $value;
     } else {
         if ($key == 'name') {
             $value = $this->fuel('sanitizer')->username($value);
         }
     }
     if (isset($this->settings[$key])) {
         if ($this->settings[$key] != $value) {
             $this->trackChange($key);
         }
         $this->settings[$key] = $value;
     } else {
         parent::set($key, $value);
     }
     return $this;
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:23,代码来源:User.php

示例9: set

 /**
  * Set a value to the event: date, location or notes
  *
  */
 public function set($key, $value)
 {
     if ($key == 'page') {
         $this->page = $value;
         return $this;
     } else {
         if ($key == 'date') {
             // convert date string to unix timestamp
             if ($value && !ctype_digit("{$value}")) {
                 $value = strtotime($value);
             }
             // sanitized date value is always an integer
             $value = (int) $value;
         } else {
             if ($key == 'location' || $key == 'notes') {
                 // regular text sanitizer
                 $value = $this->sanitizer->text($value);
             }
         }
     }
     return parent::set($key, $value);
 }
开发者ID:bensssyde,项目名称:FieldtypeEvents,代码行数:26,代码来源:Event.php

示例10: set

 public function set($key, $value)
 {
     if ($key == 'action') {
         if (!in_array($value, array('+', '-'))) {
             throw new WireException("PageRole::action must be either '+' or '-'");
         }
     } else {
         if ($key == 'pages_id') {
             $value = (int) $value;
             $this->page = null;
         } else {
             if ($key == 'roles_id') {
                 $value = (int) $value;
                 $this->role = null;
             } else {
                 if ($key == 'page' && $value instanceof Page) {
                     if (!$this->page || !$this->page->id || $value->id != $this->page->id) {
                         $this->trackChange('page');
                     }
                     $this->page = $value;
                     return $this;
                 } else {
                     if ($key == 'role' && $value instanceof Role) {
                         if (!$this->role || !$this->role->id || $value->id != $this->role->id) {
                             $this->trackChange('role');
                         }
                         $this->role = $value;
                         return $this;
                     }
                 }
             }
         }
     }
     parent::set($key, $value);
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:35,代码来源:PageRole.php

示例11: set

 /**
  * Set the Inputfield's parent, set a new/existing attribute, or set a custom data value
  *
  */
 public function set($key, $value)
 {
     if ($key == 'parent' && $value instanceof Inputfield) {
         return $this->setParent($value);
     }
     if (array_key_exists($key, $this->attributes)) {
         return $this->setAttribute($key, $value);
     }
     if ($key == 'required' && $value) {
         $this->attr('class', 'required');
     }
     return parent::set($key, $value);
 }
开发者ID:nicolasleon,项目名称:P21,代码行数:17,代码来源:Inputfield.php

示例12: set

 /**
  * Sets a value in this Pagefile
  *
  * Externally, this would be used to set the file's basename or description
  *
  * @param string $key
  * @param mixed $value
  * @return this
  *
  */
 public function set($key, $value)
 {
     if ($key == 'basename') {
         $value = $this->pagefiles->cleanBasename($value, false);
     }
     if ($key == 'description') {
         $value = $this->fuel('sanitizer')->textarea($value);
     }
     return parent::set($key, $value);
 }
开发者ID:nicolasleon,项目名称:P21,代码行数:20,代码来源:Pagefile.php

示例13: set

 public function set($key, $value)
 {
     if (in_array($key, array('id', 'status', 'pages_id', 'created', 'created_users_id'))) {
         $value = (int) $value;
     } else {
         if ($key == 'text') {
             $value = $this->cleanCommentString($value);
         } else {
             if ($key == 'cite') {
                 $value = str_replace(array("\r", "\n", "\t"), ' ', substr(strip_tags($value), 0, 128));
             } else {
                 if ($key == 'email') {
                     $value = $this->sanitizer->email($value);
                 } else {
                     if ($key == 'ip') {
                         $value = filter_var($value, FILTER_VALIDATE_IP);
                     } else {
                         if ($key == 'user_agent') {
                             $value = str_replace(array("\r", "\n", "\t"), ' ', substr(strip_tags($value), 0, 255));
                         } else {
                             if ($key == 'website') {
                                 $value = wire('sanitizer')->url($value, array('allowRelative' => false, 'allowQuerystring' => false));
                             }
                         }
                     }
                 }
             }
         }
     }
     // save the state so that modules can identify when a comment that was identified as spam
     // is then set to not-spam, or when a misidentified 'approved' comment is actually spam
     if ($key == 'status') {
         $this->prevStatus = $this->status;
     }
     return parent::set($key, $value);
 }
开发者ID:avatar382,项目名称:fablab_site,代码行数:36,代码来源:Comment.php

示例14: set

 /**
  * Set the Inputfield's parent, set a new/existing attribute, or set a custom data value
  *
  */
 public function set($key, $value)
 {
     if ($key == 'parent' && $value instanceof Inputfield) {
         return $this->setParent($value);
     }
     if (array_key_exists($key, $this->attributes)) {
         return $this->setAttribute($key, $value);
     }
     if ($key == 'required' && $value) {
         $this->attr('class', 'required');
     }
     if ($key == 'columnWidth') {
         $value = (int) $value;
         if ($value < 10 || $value > 99) {
             $value = '';
         }
     }
     return parent::set($key, $value);
 }
开发者ID:nightsh,项目名称:ProcessWire,代码行数:23,代码来源:Inputfield.php

示例15: set

 public function set($property, $value)
 {
     if ($property == 'halt') {
         $this->halt($value);
         return $this;
     }
     return parent::set($property, $value);
 }
开发者ID:posixpascal,项目名称:TrooperCMS,代码行数:8,代码来源:TemplateFile.php


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