Exemple #1
0
 public function get($key)
 {
     if ($key == 'operator') {
         return $this->getOperator();
     }
     return parent::get($key);
 }
 public function get($key)
 {
     if ($key == 'className' || $key == 'class' || $key == 'name') {
         return $this->class;
     }
     return parent::get($key);
 }
 public function get($key)
 {
     if ($key == 'statusString') {
         return str_replace('_', ' ', $this->geocodeStatuses[$this->status]);
     }
     return parent::get($key);
 }
Exemple #4
0
 /**
  * Get a value stored in this Process
  *
  */
 public function get($key)
 {
     if (($value = $this->getFuel($key)) !== null) {
         return $value;
     }
     return parent::get($key);
 }
 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);
 }
 public function __get($key)
 {
     if ($key == 'query') {
         return $this->getQuery();
     } else {
         return parent::__get($key);
     }
 }
 public function __set($key, $value)
 {
     if (array_key_exists($key, $this->mail)) {
         $this->{$key}($value);
     } else {
         parent::__set($key, $value);
     }
 }
 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);
 }
 /**
  * Retrieve a value from the ImageMarker: date, location or notes
  *
  */
 public function get($key)
 {
     $value = parent::get($key);
     // if the page's output formatting is on, then we'll return formatted values
     if ($this->page && $this->page->of()) {
         // int sanitizer
         if ($key == 'info' || $key == 'x' || $key == 'y') {
             $value = (int) $value;
         }
     }
     return $value;
 }
 /**
  * Return the requested path variable
  *
  */
 public function get($key)
 {
     $value = parent::get($key);
     if ($key == 'root') {
         return $value;
     }
     if (!is_null($value)) {
         if ($value[0] == '/' || DIRECTORY_SEPARATOR != '/' && $value[1] == ':') {
             return $value;
         } else {
             $value = $this->root . $value;
         }
     }
     return $value;
 }
 public function __construct()
 {
     if ($this->wire('input')->get('test_notices')) {
         $this->message('Message test');
         $this->message('Message test debug', Notice::debug);
         $this->message('Message test markup <a href="#">example</a>', Notice::allowMarkup);
         $this->warning('Warning test');
         $this->warning('Warning test debug', Notice::debug);
         $this->warning('Warning test markup <a href="#">example</a>', Notice::allowMarkup);
         $this->error('Error test');
         $this->error('Error test debug', Notice::debug);
         $this->error('Error test markup <a href="#">example</a>', Notice::allowMarkup);
     }
     parent::__construct();
 }
 /**
  * Perform a translation, based on text from shared admin file: /wire/templates-admin/default.php
  * 
  * @param string $text
  * @return string
  * 
  */
 public function _($text)
 {
     static $translate = null;
     if (is_null($translate)) {
         $translate = $this->wire('languages') !== null;
     }
     if ($translate === false) {
         return $text;
     }
     $value = __($text, $this->wire('config')->paths->root . 'wire/templates-admin/default.php');
     if ($value === $text) {
         $value = parent::_($text);
     }
     return $value;
 }
 /**
  * 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);
 }
Exemple #14
0
 /**
  * Retrieve a value from the event: date, location or notes
  *
  */
 public function get($key)
 {
     $value = parent::get($key);
     // if the page's output formatting is on, then we'll return formatted values
     if ($this->page && $this->page->of()) {
         if ($key == 'date') {
             // format a unix timestamp to a date string
             $value = date(self::dateFormat, $value);
         } else {
             if ($key == 'location' || $key == 'notes') {
                 // return entity encoded versions of strings
                 $value = $this->sanitizer->entities($value);
             }
         }
     }
     return $value;
 }
 /**
  * Get the language-aware property
  * 
  * @param string $property Either 'title' or 'value'
  * @return string
  * 
  */
 protected function getProperty($property)
 {
     if ($this->wire('languages')) {
         $language = $this->wire('user')->language;
         if ($language->isDefault()) {
             $value = parent::get($property);
         } else {
             $value = parent::get("{$property}{$language}");
             // fallback to default language title if no title present for language
             if (!strlen($value)) {
                 $value = parent::get($property);
             }
         }
     } else {
         $value = parent::get($property);
     }
     if ($this->of) {
         $value = $this->wire('sanitizer')->entities($value);
     }
     return $value;
 }
Exemple #16
0
 /**
  * debugInfo PHP 5.6+ magic method
  *
  * This is used when you print_r() an object instance.
  *
  * @return array
  *
  */
 public function __debugInfo()
 {
     $info = parent::__debugInfo();
     $info['settings'] = $this->settings;
     if ($this->prevTable) {
         $info['prevTable'] = $this->prevTable;
     }
     if ($this->prevFieldtype) {
         $info['prevFieldtype'] = (string) $this->prevFieldtype;
     }
     if (!empty($this->trackGets)) {
         $info['trackGets'] = $this->trackGets;
     }
     if ($this->useRoles) {
         $info['viewRoles'] = $this->viewRoles;
         $info['editRoles'] = $this->editRoles;
     }
     return $info;
 }
Exemple #17
0
 /**
  * Get the value of $property from $item
  *
  * Used by the WireArray::sort method to retrieve a value from a Wire object. 
  * If output formatting is on, we turn it off to ensure that the sorting
  * is performed without output formatting.
  *
  * @param Wire $item
  * @param string $property
  * @return mixed
  *
  */
 protected function getItemPropertyValue(Wire $item, $property)
 {
     if ($item instanceof Page) {
         $value = $item->getUnformatted($property);
     } else {
         if (strpos($property, '.') !== false) {
             $value = WireData::_getDot($property, $item);
         } else {
             if ($item instanceof WireArray) {
                 $value = $item->getProperty($property);
                 if (is_null($value)) {
                     $value = $item->first();
                     $value = $this->getItemPropertyValue($value, $property);
                 }
             } else {
                 $value = $item->{$property};
             }
         }
     }
     if (is_array($value)) {
         $value = implode('|', $value);
     }
     return $value;
 }
Exemple #18
0
 /**
  * Per Saveable interface, get an array of this table's data
  *
  * We override this so that we can add our roles array to it. 
  *
  */
 public function getArray()
 {
     $a = parent::getArray();
     if ($this->useRoles) {
         $a['roles'] = array();
         foreach ($this->getRoles() as $role) {
             $a['roles'][] = $role->id;
         }
     } else {
         unset($a['roles'], $a['editRoles'], $a['addRoles'], $a['createRoles']);
     }
     return $a;
 }
Exemple #19
0
 /**
  * Remove a hook by ID
  * 
  * To remove the hook that this event is for, call it with the $hookId argument as null or blank.
  * 
  * @param string|null $hookId
  * @return $this
  * 
  */
 public function removeHook($hookId)
 {
     if (empty($hookId)) {
         if ($this->object && $this->id) {
             $this->object->removeHook($this->id);
         }
         return $this;
     } else {
         return parent::removeHook($hookId);
     }
 }
Exemple #20
0
 /**
  * Return a unique MD5 hash representing this Pagefile
  *
  */
 public function hash()
 {
     if ($hash = parent::get('hash')) {
         return $hash;
     }
     $this->set('hash', md5($this->basename()));
     return parent::get('hash');
 }
Exemple #21
0
 public function get($key)
 {
     if ($key == 'page') {
         return $this->getPage();
     }
     if ($key == 'field') {
         return $this->getField();
     }
     if ($key == 'value') {
         return $this->getValue();
     }
     return parent::get($key);
 }
Exemple #22
0
 /**
  * Ensures that isset() and empty() work for this classes properties. 
  *
  * See the Page::issetHas property which can be set to adjust the behavior of this function.
  *
  */
 public function __isset($key)
 {
     if (isset($this->settings[$key])) {
         return true;
     }
     if (self::$issetHas && $this->template && $this->template->fieldgroup->hasField($key)) {
         return true;
     }
     return parent::__isset($key);
 }
Exemple #23
0
 public function __isset($key)
 {
     if (parent::__isset($key)) {
         return true;
     }
     return isset($this->settings[$key]);
 }
Exemple #24
0
 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);
 }
Exemple #25
0
 /**
  * Get a property from this Fieldtype's data
  *
  * @param string $key
  * @return mixed
  *
  */
 public function get($key)
 {
     if ($key == 'name') {
         return $this->className();
     }
     if ($key == 'shortName') {
         return str_replace('Fieldtype', '', $this->className());
     }
     return parent::get($key);
 }
Exemple #26
0
 /**
  * Track the change, but only if it was to the 'value' attribute.
  *
  * We don't track changes to any other properties of Inputfields. 
  *
  * @param string $key
  * @return this
  *
  */
 public function trackChange($key)
 {
     if ($key != 'value') {
         return $this;
     }
     return parent::trackChange($key);
 }
Exemple #27
0
 /**
  * Retrieve a value from the Notification
  * 
  * @param string $key
  * @return mixed
  *
  */
 public function get($key)
 {
     if ($key == 'id') {
         return $this->getID();
     }
     if ($key == 'page') {
         return $this->page;
     }
     if ($key == 'hash') {
         return $this->getHash();
     }
     if ($key == 'flagNames') {
         $flags = parent::get('flags');
         $flagNames = array();
         foreach (self::$_flagNames as $val => $name) {
             if ($flags & $val) {
                 $flagNames[$val] = $name;
             }
         }
         return $flagNames;
     }
     $value = parent::get($key);
     // if the page's output formatting is on, then we'll return formatted values
     if ($this->page && $this->page->of()) {
         if ($key == 'created' || $key == 'expires' || $key == 'modified') {
             // format a unix timestamp to a date string
             $value = date('Y-m-d H:i:s', $value);
         } else {
             if ($key == 'title' || $key == 'text' || $key == 'from') {
                 // return entity encoded versions of strings
                 if ($key == 'title' && $this->flags & self::flagAllowMarkup) {
                     // leave title alone when markup is allowed
                 } else {
                     $value = $this->sanitizer->entities($value);
                 }
             }
         }
     } else {
         if ($key == 'created' && !$value) {
             $value = time();
         }
     }
     return $value;
 }
 /**
  * Initialize/create the $options array for executeNavJSON() in Process modules
  * 
  * @param array $options
  * @return array
  *
  */
 public function initNavJSON(array $options = array())
 {
     $page = $this->wire('page');
     $templatesArray = array();
     $bookmarkFields = array();
     $bookmarksArray = array();
     $rolesArray = array();
     $data = $this->wire('modules')->getModuleConfigData($this->process);
     $iconKey = isset($options['iconKey']) ? $options['iconKey'] : '_icon';
     $classKey = isset($options['classKey']) ? $options['classKey'] : '_class';
     $options['classKey'] = $classKey;
     $options['iconKey'] = $iconKey;
     if (!isset($options['defaultIcon'])) {
         $options['defaultIcon'] = 'arrow-circle-right';
     }
     foreach ($this->wire('user')->roles as $role) {
         if ($role->name == 'guest') {
             continue;
         }
         $value = isset($data["bookmarks"]["_{$role->id}"]) ? $data["bookmarks"]["_{$role->id}"] : array();
         if (empty($value)) {
             continue;
         }
         $bookmarkFields[$role->name] = $value;
         $rolesArray[$role->name] = $role;
     }
     $bookmarkFields['bookmarks'] = isset($data['bookmarks']["_0"]) ? $data['bookmarks']["_0"] : array();
     $n = 0;
     foreach ($bookmarkFields as $name => $bookmarkIDs) {
         $bookmarks = count($bookmarkIDs) ? $this->wire('pages')->getById($bookmarkIDs) : array();
         // $className = "separator";
         $role = isset($rolesArray[$name]) ? $rolesArray[$name] : null;
         foreach ($bookmarks as $page) {
             if ($this->process == 'ProcessPageEdit' && !$page->editable()) {
                 continue;
             } else {
                 if ($this->process == 'ProcessPageAdd' && !$page->addable()) {
                     continue;
                 } else {
                     if (!$page->listable()) {
                         continue;
                     }
                 }
             }
             if (isset($bookmarksArray[$page->id])) {
                 continue;
             }
             $icon = $page->template->getIcon();
             if (!$icon) {
                 $icon = $options['defaultIcon'];
             }
             $page->setQuietly($iconKey, $icon);
             // $page->setQuietly($classKey, $className);
             $page->setQuietly('_roleName', $role ? $role->name : $this->labels['all']);
             $className = '';
             $bookmarksArray[$page->id] = $page;
         }
         $n++;
     }
     if (empty($options['add'])) {
         if ($this->wire('user')->isSuperuser()) {
             $options['add'] = 'bookmarks/?role=0';
             $options['addLabel'] = $this->labels['bookmarks'];
             $options['addIcon'] = 'bookmark-o';
         } else {
             $options['add'] = null;
         }
     } else {
         if ($this->wire('user')->isSuperuser()) {
             $add = new WireData();
             $add->set('_icon', 'bookmark-o');
             $add->set('title', $this->labels['bookmarks']);
             $add->set('id', 'bookmark');
             $add->set($classKey, 'highlight separator');
             array_unshift($bookmarksArray, $add);
         }
     }
     if (isset($options['items'])) {
         $options['items'] = $options['items'] + $bookmarksArray;
     } else {
         $options['items'] = $bookmarksArray;
     }
     if (!isset($options['itemLabel'])) {
         $options['itemLabel'] = 'title|name';
     }
     if (!isset($options['sort'])) {
         $options['sort'] = false;
     }
     if (!isset($options['iconKey'])) {
         $options['iconKey'] = '_icon';
     }
     if (empty($options['edit'])) {
         $options['edit'] = $this->wire('config')->urls->admin . 'page/edit/?id={id}';
     }
     return $options;
 }
 /**
  * Set a webmention key
  * @param string $key
  * @param string $value
  * @access public
  */
 public function set($key, $value)
 {
     switch ($key) {
         case 'id':
         case 'status':
         case 'pages_id':
         case 'is_like':
         case 'is_repost':
         case 'is_rsvp':
             $value = (int) $value;
             break;
         case 'source_url':
         case 'target_url':
         case 'vouch_url':
         case 'url':
         case 'author_photo':
         case 'author_logo':
         case 'author_url':
             $value = wire('sanitizer')->url($value, array('allowRelative' => FALSE));
             break;
     }
     if ($key == 'status') {
         $this->prevStatus = $this->status;
     }
     return parent::set($key, $value);
 }
 /**
  * Set or retrieve a config value to be shared with javascript
  * 
  * 1. Specify a $key and $value to set a JS config value. 
  *
  * 2. Specify only a $key and omit the $value in order to retrieve an existing set value.
  *    The $key may also be an array of properties, which will return an array of values. 
  * 
  * 3. Specify boolean true for $value to share the $key with the JS side. If the $key 
  *    specified does not exist then $key=true will be added to the JS config (which can later 
  *    be overwritten with another value, which will still be shared with the JS config). 
  *    The $key property may also be an array of properties to specify multiple. 
  * 
  * 4. Specify no params to retrieve in array of all existing set values.
  *
  * @param string|array $key Property or array of properties
  * @param mixed $value
  * @return array|mixed|null|this
  *
  */
 public function js($key = null, $value = null)
 {
     if (is_null($key)) {
         // return array of all keys and values
         $data = array();
         foreach ($this->jsFields as $field) {
             $data[$field] = $this->get($field);
         }
         return $data;
     } else {
         if (is_null($value)) {
             // return a value or values
             if (is_array($key)) {
                 // return values for multiple keys
                 $a = array();
                 foreach ($key as $k) {
                     $a[$k] = $this->js($k);
                 }
                 return $a;
             } else {
                 // return value for just one key
                 return in_array($key, $this->jsFields) ? $this->get($key) : null;
             }
         } else {
             if ($value === true) {
                 // share an already present value or set a key=true
                 if (is_array($key)) {
                     // sharing multiple keys
                     foreach ($key as $k) {
                         $this->js($k, true);
                     }
                     return $this;
                 } else {
                     if ($this->get($key) !== null) {
                         // share existing config $key with JS side
                         $this->jsFields[] = $key;
                         return $this;
                     } else {
                         // will set $key=true to JS config, which may be overwritten
                         // with a different value during runtime, or maybe true is the
                         // literal value they want stored, in which case it will remain.
                     }
                 }
             }
         }
     }
     $this->jsFields[] = $key;
     return parent::set($key, $value);
 }