ensureString() public static method

Note, a boolean value will be converted to 'true' if it is true and 'false' if it is false.
public static ensureString ( $value ) : string
return string
 /**
  * Updates the options of the jQueryUI widget.
  * @param array list of widget options to change.
  */
 protected function updateJuiOptions($options)
 {
     foreach ($options as $key => $value) {
         $options[$key] = $key . ': ' . (is_string($value) ? "'{$value}'" : TPropertyValue::ensureString($value));
     }
     $code = "jQuery('#{$this->_control->getWidgetID()}').{$this->_control->getWidget()}('option', { " . implode(', ', $options) . " });";
     $this->_control->getPage()->getClientScript()->registerEndScript(sprintf('%08X', crc32($code)), $code);
 }
Beispiel #2
0
 /**
  * Constructor.
  * @param string error message. This can be a string that is listed
  * in the message file. If so, the message in the preferred language
  * will be used as the error message. Any rest parameters will be used
  * to replace placeholders ({0}, {1}, {2}, etc.) in the message.
  */
 public function __construct($errorMessage)
 {
     $this->_errorCode = $errorMessage;
     $errorMessage = $this->translateErrorMessage($errorMessage);
     $args = func_get_args();
     array_shift($args);
     $n = count($args);
     $tokens = array();
     for ($i = 0; $i < $n; ++$i) {
         $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]);
     }
     parent::__construct(strtr($errorMessage, $tokens));
 }
Beispiel #3
0
 /**
  * Constructor, similar to the parent constructor. For parameters that
  * are of SimpleXmlElement, the tag name and its attribute names and values
  * are expanded into a string.
  */
 public function __construct($errorMessage)
 {
     $this->setErrorCode($errorMessage);
     $errorMessage = $this->translateErrorMessage($errorMessage);
     $args = func_get_args();
     array_shift($args);
     $n = count($args);
     $tokens = array();
     for ($i = 0; $i < $n; ++$i) {
         if ($args[$i] instanceof SimpleXMLElement) {
             $tokens['{' . $i . '}'] = $this->implodeNode($args[$i]);
         } else {
             $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]);
         }
     }
     parent::__construct(strtr($errorMessage, $tokens));
 }
Beispiel #4
0
 /**
  * Sets the ID path of the CAPTCHA control to validate.
  * The ID path is the dot-connected IDs of the controls reaching from
  * the validator's naming container to the target control.
  * @param string the ID path
  */
 public function setCaptchaControl($value)
 {
     $this->setViewState('CaptchaControl', TPropertyValue::ensureString($value), '');
 }
 /**
  * @param string cache key to be appended to the default calculation scheme
  */
 public function setCacheKey($value)
 {
     $this->_cacheKey = TPropertyValue::ensureString($value);
 }
Beispiel #6
0
 /**
  * @param string URL for the CSS file including all relevant CSS class definitions.
  */
 public function setCssUrl($value)
 {
     $this->setViewState('CssUrl', TPropertyValue::ensureString($value), '');
 }
Beispiel #7
0
 /**
  * @param string the URL that the browser will be redirected to if the wizard finishes.
  */
 public function setFinishDestinationUrl($value)
 {
     $this->setViewState('FinishDestinationUrl', TPropertyValue::ensureString($value), '');
 }
Beispiel #8
0
 /**
  * @param Sets the css class of the buttons that will be rendered by this pager.
  * @since 3.2.1
  */
 public function setButtonCssClass($value)
 {
     $this->setViewState('ButtonCssClass', TPropertyValue::ensureString($value, ''), '');
 }
Beispiel #9
0
 /**
  * @param string value of the item
  */
 public function setValue($value)
 {
     $this->_value = TPropertyValue::ensureString($value);
 }
Beispiel #10
0
 /**
  * Set the handle id or css class
  * @param string
  */
 public function setHandle($value)
 {
     $this->setViewState('DragHandle', TPropertyValue::ensureString($value), null);
 }
Beispiel #11
0
 /**
  * @param string the tag name of this control.
  */
 public function setTagName($value)
 {
     $this->_tagName = TPropertyValue::ensureString($value);
 }
Beispiel #12
0
 /**
  * @param string hashing algorithm used to generate HMAC.
  */
 public function setHashAlgorithm($value)
 {
     $this->_hashAlgorithm = TPropertyValue::ensureString($value);
 }
Beispiel #13
0
 /**
  * Formats the text value according to a format string.
  * If the format string is empty, the original value is converted into
  * a string and returned.
  * If the format string starts with '#', the string is treated as a PHP expression
  * within which the token '{0}' is translated with the data value to be formated.
  * Otherwise, the format string and the data value are passed
  * as the first and second parameters in {@link sprintf}.
  * @param string format string
  * @param mixed the data to be formatted
  * @return string the formatted result
  */
 protected function formatDataValue($formatString, $value)
 {
     if ($formatString === '') {
         return TPropertyValue::ensureString($value);
     } else {
         if ($formatString[0] === '#') {
             $expression = strtr(substr($formatString, 1), array('{0}' => '$value'));
             try {
                 if (eval("\$result={$expression};") === false) {
                     throw new Exception('');
                 }
                 return $result;
             } catch (Exception $e) {
                 throw new TInvalidDataValueException('listcontrol_expression_invalid', get_class($this), $expression, $e->getMessage());
             }
         } else {
             return sprintf($formatString, $value);
         }
     }
 }
Beispiel #14
0
 /**
  * Sets the PHP expression to be evaluated for conditionally displaying content.
  * The context of the expression is the template control containing TConditional.
  * @param string the PHP expression used for determining which template to use.
  */
 public function setCondition($value)
 {
     $this->_condition = TPropertyValue::ensureString($value);
 }
Beispiel #15
0
 /**
  * Sets the ID path of the {@link TTextBox} control.
  * The ID path is the dot-connected IDs of the controls reaching from
  * the keyboard's naming container to the target control.
  * @param string the ID path
  */
 public function setForControl($value)
 {
     $this->setViewState('ForControl', TPropertyValue::ensureString($value));
 }
 /**
  * @param string sets the text after the close tag in the TWebControl
  */
 public function setPostTagText($value)
 {
     if (!$this->_internalonly && !$this->_control->getIsSkinApplied()) {
         $this->_posttagtext = TPropertyValue::ensureString($value);
     }
 }
Beispiel #17
0
 /**
  * Finds the lowest cardinal index of the item whose text is the one being looked for.
  * @param string the text to be looked for
  * @param boolean whether to look for disabled items also
  * @return integer the index of the item found, -1 if not found.
  */
 public function findIndexByText($text, $includeDisabled = true)
 {
     $text = TPropertyValue::ensureString($text);
     $index = 0;
     foreach ($this as $item) {
         if ($item->getText() === $text && ($includeDisabled || $item->getEnabled())) {
             return $index;
         }
         $index++;
     }
     return -1;
 }
 /**
  * @param string the initial value of the associated input control.
  * If the associated input control does not change from this initial value
  * upon postback, the validation fails.
  */
 public function setInitialValue($value)
 {
     $this->setViewState('InitialValue', TPropertyValue::ensureString($value), '');
 }
Beispiel #19
0
 /**
  * Set the HTTP status code for the response.
  * The code and its reason will be sent to client using the currently requested http protocol version (see {@link THttpRequest::getHttpProtocolVersion})
  * Keep in mind that HTTP/1.0 clients might not understand all status codes from HTTP/1.1
  *
  * @param integer HTTP status code
  * @param string HTTP status reason, defaults to standard HTTP reasons
  */
 public function setStatusCode($status, $reason = null)
 {
     if ($this->_httpHeaderSent) {
         throw new \Exception('Unable to alter response as HTTP header already sent');
     }
     $status = TPropertyValue::ensureInteger($status);
     if (isset(self::$HTTP_STATUS_CODES[$status])) {
         $this->_reason = self::$HTTP_STATUS_CODES[$status];
     } else {
         if ($reason === null || $reason === '') {
             throw new TInvalidDataValueException("response_status_reason_missing");
         }
         $reason = TPropertyValue::ensureString($reason);
         if (strpos($reason, "\r") != false || strpos($reason, "\n") != false) {
             throw new TInvalidDataValueException("response_status_reason_barchars");
         }
         $this->_reason = $reason;
     }
     $this->_status = $status;
 }
 /**
  * @param string state tracker class.
  */
 public function setStateTracker($value)
 {
     $this->_stateTrackerClass = TPropertyValue::ensureString($value);
 }
Beispiel #21
0
 /**
  * Set implementation class of ActiveRecordGateway
  * @param string $value
  */
 public function setGatewayClass($value)
 {
     $this->_gatewayClass = TPropertyValue::ensureString($value);
 }
Beispiel #22
0
 /**
  * Sets the tag used to render the surrounding container.
  * @param string $value container tag
  */
 public function setSurroundingTag($value)
 {
     $this->_surroundingTag = TPropertyValue::ensureString($value);
 }
Beispiel #23
0
 public function setResponse($value)
 {
     $this->setViewState('Response', TPropertyValue::ensureString($value), '');
 }
Beispiel #24
0
 /**
  * @return string word or token separators (delimiters).
  */
 public function setSeparator($value)
 {
     $this->setViewState('tokens', TPropertyValue::ensureString($value), '');
 }
Beispiel #25
0
 public function setCallbackScript($value)
 {
     return $this->setViewState('CallbackScript', TPropertyValue::ensureString($value));
 }
Beispiel #26
0
 /**
  * @param string default scaffold stylesheet name
  */
 public function setDefaultStyle($value)
 {
     $this->setViewState('DefaultStyle', TPropertyValue::ensureString($value), 'style');
 }
Beispiel #27
0
 /**
  * @return string the css class of the control
  */
 public function getCssClass()
 {
     return TPropertyValue::ensureString($this->_cssClass);
 }
Beispiel #28
0
 /**
  * Sets the static text of the TLiteral
  * @param string the text to be set
  */
 public function setText($value)
 {
     $this->setViewState('Text', TPropertyValue::ensureString($value), '');
 }
Beispiel #29
0
 /**
  * @param string attribute name
  * @param string attribute value
  */
 public function setAttribute($name, $value)
 {
     $this->getAttributes()->add($name, TPropertyValue::ensureString($value));
 }