Example #1
0
 /**
  * Constructs a new XML-RPC client view
  * @param zibo\xmlrpc\form\ClientForm $form The form of the client
  * @param zibo\library\xmlrpc\Request $request
  * @param zibo\library\xmlrpc\Response $response
  * @param string $responseString
  * @param float $time Time spent on the request in seconds
  * @return null
  */
 public function __construct(ClientForm $form, Request $request = null, Response $response = null, $responseString = null, $time = null)
 {
     parent::__construct(self::TEMPLATE);
     $this->set('form', $form);
     $this->set('time', $time);
     $this->set('requestString', null);
     $this->set('responseString', null);
     if ($request) {
         $this->set('requestString', String::addLineNumbers(trim($request->getXmlString())));
     }
     if ($responseString && !$response) {
         $this->set('responseString', String::addLineNumbers(trim($responseString)));
     } elseif ($response) {
         $this->set('responseString', String::addLineNumbers(trim($response->getXmlString())));
         $errorCode = $response->getErrorCode();
         if ($errorCode) {
             $this->set('error', $errorCode . ': ' . $response->getErrorMessage());
         } else {
             $parser = new ParameterParser();
             $result = $parser->unparse($response->getValue(), true);
             $this->set('result', $result);
         }
     }
     $this->addStyle(self::STYLE);
 }
 /**
  * Adds a custom validator for a specified field
  * @param string $fieldName Name of the field
  * @param zibo\library\validation\validator\Validator $validator The validator for the field
  * @return null
  */
 public function addValidator($fieldName, Validator $validator)
 {
     if (String::isEmpty($fieldName)) {
         throw new ZiboException('Cannot add the validator: provided fieldname is empty');
     }
     $this->validators[$fieldName][] = $validator;
 }
 /**
  * Set the name of this field
  * @param string $name
  * @return null
  * @throws zibo\library\database\exception\DatabaseException when the name is empty or not a string
  */
 private function setName($name)
 {
     if (!String::isString($name, String::NOT_EMPTY)) {
         throw new DatabaseException('Provided name is empty');
     }
     $this->name = $name;
 }
 /**
  * Set the name of the validator
  * @param string $name
  * @return null
  * @throws zibo\ZiboException when $name is not a string
  * @throws zibo\library\orm\exception\ModelException when $name is empty
  */
 private function setName($name)
 {
     if (String::isEmpty($name)) {
         throw new OrmException('Name is empty');
     }
     $this->name = $name;
 }
 /**
  * Sets the field name for objects or arrays passed to this decorator
  * @param string $fieldName
  * @return null
  * @throws zibo\ZiboException when the field name is empty or an object
  */
 protected function setFieldName($fieldName)
 {
     if ($fieldName != null && String::isEmpty($fieldName)) {
         throw new ZiboException('Provided field name is empty');
     }
     $this->fieldName = $fieldName;
 }
Example #6
0
 private function setAction($action)
 {
     if (String::isEmpty($action)) {
         $action = Dispatcher::ACTION_ASTERIX;
     }
     $this->action = $action;
 }
Example #7
0
 /**
  * Sets the method name for the request
  * @param string $methodName
  * @return null
  * @throws zibo\library\xmlrpc\exception\XmlRpcException when the provided method name is empty
  */
 protected function setMethodName($methodName)
 {
     if (String::isEmpty($methodName)) {
         throw new XmlRpcException('Method name cannot be empty');
     }
     $this->methodName = $methodName;
 }
Example #8
0
 /**
  * Process the request, get the field value
  * @return null
  */
 public function processRequest()
 {
     parent::processRequest();
     if ($this->value && !String::looksLikeUrl($this->value)) {
         $this->value = 'http://' . $this->value;
     }
 }
 /**
  * Register a new thumbnailer into this factory
  * @param string name name of the thumbnailer
  * @param Thumbnailer thumbnailer Thumbnailer instance
  */
 public function register($name, Thumbnailer $thumbnailer)
 {
     if (String::isEmpty($name)) {
         throw new ThumbnailException('Name is empty');
     }
     $this->thumbnailers[$name] = $thumbnailer;
 }
 /**
  * Sets the expression string
  * @param string $expression
  * @return null
  * @throws zibo\ZiboException when the expression is empty or invalid
  */
 private function setExpression($expression)
 {
     if (String::isEmpty($expression)) {
         throw new OrmException('Provided expression is empty');
     }
     $this->expression = $expression;
 }
Example #11
0
 /**
  * Parses the tag
  * @param string $content Content of the tag
  * @param array $parameters Parameters of the tag
  * @return string HTML replacement for the tag
  */
 public function parseTag($content, array $parameters)
 {
     if (!$content || !String::looksLikeUrl($content)) {
         return false;
     }
     $width = null;
     $height = null;
     $alt = null;
     if (array_key_exists(0, $parameters) && strpos($parameters[0], 'x')) {
         // [img=<width>x<height>]url[/img]
         list($width, $height) = explode($parameters[0]);
     } else {
         if (array_key_exists('width', $parameters)) {
             // [img width=<width>]url[/img]
             $width = $parameters['width'];
         } elseif (array_key_exists('w', $parameters)) {
             // [img w=<width>]url[/img]
             $width = $parameters['w'];
         }
         if (array_key_exists('height', $parameters)) {
             // [img height=<height>]url[/img]
             $height = $parameters['height'];
         } elseif (array_key_exists('h', $parameters)) {
             // [img h=<height>]url[/img]
             $height = $parameters['h'];
         }
     }
     if (array_key_exists('alt', $parameters)) {
         $alt = $parameters['alt'];
     }
     return $this->getImageHtml($content, $width, $height, $alt);
 }
Example #12
0
 /**
  * Sets the host of this connection
  * @param string $host
  * @return null
  * @throws zibo\library\network\exception\ConnectionException when the host is invalid
  */
 protected function setHost($host)
 {
     if (String::isEmpty($host)) {
         throw new ConnectionException('Could not set the host: invalid host provided');
     }
     $this->host = $host;
 }
 /**
  * Quotes a database identifier
  * @param string $identifier Identifier to quote
  * @return string Quoted identifier
  * @throws zibo\library\database\exception\DatabaseException when the provided identifier is empty or not a scalar value
  */
 public function quoteIdentifier($identifier)
 {
     if (!String::isString($identifier, String::NOT_EMPTY)) {
         throw new DatabaseException('Provided identifier is empty');
     }
     return $identifier;
 }
Example #14
0
 /**
  * Sets the label for this field
  * @param string $label Translation key for the name of this field
  * @return null
  */
 public function setLabel($label)
 {
     if ($label !== null && String::isEmpty($label)) {
         throw new OrmException('Provided label is empty');
     }
     $this->label = $label;
 }
 /**
  * Sets the name of the namespace
  * @param string $name
  * @return null
  * @throws zibo\ZiboException when the provided name is empty or invalid
  */
 private function setName($name)
 {
     if (String::isEmpty($name)) {
         throw new ZiboException('Provided name is empty');
     }
     $this->name = $name;
 }
Example #16
0
 /**
  * Checks if a manager exists
  * @param string $name name of the manager
  * @return boolean
  * @throws zibo\ZiboException when the name is empty or not a string
  */
 public function hasManager($name)
 {
     if (String::isEmpty($name)) {
         throw new ZiboException('Name is empty');
     }
     return array_key_exists($name, $this->managers);
 }
function smarty_function_scripts_get_url($url, $baseUrl)
{
    if (String::looksLikeUrl($url)) {
        return $url;
    }
    return $baseUrl . $url;
}
Example #18
0
 /**
  * Constructs a new address
  * @param string $address The email address in one of the supported formats
  * @return null
  * @throws zibo\library\mail\exception\MailException when the provided address is empty or invalid
  */
 public function __construct($address)
 {
     try {
         if (String::isEmpty($address)) {
             throw new MailException('address is empty');
         }
     } catch (ZiboException $exception) {
         throw new MailException('Invalid address provided', 0, $exception);
     }
     $validator = ValidationFactory::getInstance()->createValidator('email');
     $address = trim($address);
     $address = str_replace(array("\n", "\r"), '', $address);
     $matches = array();
     if (preg_match(self::REGEX_ADDRESS, $address, $matches)) {
         $this->displayName = trim($matches[1]);
         $address = $matches[3];
     }
     if ($validator->isValid($address)) {
         $this->emailAddress = $address;
         if (empty($this->displayName) && strpos($address, '@') !== false) {
             list($this->displayName, $null) = explode('@', $address);
         }
         return;
     }
     throw new MailException('Provided address ' . $address . ' is invalid');
 }
Example #19
0
 /**
  * Sets the name of the queue
  * @param string $name The name of the queue
  * @return null
  */
 protected function setName($name)
 {
     if (String::isEmpty($name)) {
         throw new ZiboException('Could not set the name of the queue worker: provided name is empty');
     }
     $this->name = $name;
 }
Example #20
0
 /**
  * Sets the date format
  * @param string $format
  * @return null
  * @throws zibo\ZiboException when an invalid format is provided
  */
 private function setFormat($format = null)
 {
     if ($format !== null && String::isEmpty($format)) {
         throw new ZiboException('Provided format is empty');
     }
     $this->format = $format;
 }
 /**
  * Sets the method name of this callback
  * @param string $methodName A method name
  * @return null
  */
 public function setMethodName($methodName)
 {
     if (!String::isString($methodName, String::NOT_EMPTY)) {
         throw new ZiboException('Provided class name is empty or invalid');
     }
     $this->methodName = $methodName;
 }
Example #22
0
 /**
  * Set the name of this theme
  * @param string $name
  * @return null
  * @throws zibo\ZiboException when the provided name is invalid
  */
 private function setName($name)
 {
     if (String::isEmpty($name)) {
         throw new ZiboException('Name of the region is empty');
     }
     $this->name = $name;
 }
Example #23
0
 /**
  * Sets the SQL for this condition
  * @param string $sql The SQL
  * @return null
  * @throws zibo\library\database\exception\DatabaseException when the provided SQL is empty or not a string
  */
 private function setSql($sql)
 {
     if (!String::isString($sql, String::NOT_EMPTY)) {
         throw new DatabaseException('Provided sql is empty or not a valid string');
     }
     $this->sql = $sql;
 }
 /**
  * Set the translation key of the label
  * @param string $labelTranslationKey
  * @return null
  * @throws zibo\ZiboException when invalid label provided
  */
 private function setLabelTranslationKey($labelTranslationKey)
 {
     if (String::isEmpty($labelTranslationKey)) {
         throw new ZiboException('Provided label is empty');
     }
     $this->labelTranslationKey = $labelTranslationKey;
 }
Example #25
0
 /**
  * Sets the format string
  * @param string $format
  * @return null
  * @throws zibo\ZiboException when the provided format is empty or not a string
  */
 protected function setFormat($format)
 {
     if (String::isEmpty($format)) {
         throw new ZiboException('Provided format is empty');
     }
     $this->format = $format;
 }
Example #26
0
 /**
  * Sets the order statement string for the relation
  * @param string $order
  * @return null
  */
 public function setRelationOrder($order)
 {
     if ($order !== null && String::isEmpty($order)) {
         throw new OrmException('Provided order statement is empty');
     }
     $this->relationOrder = $order;
 }
Example #27
0
 public function setTitle($title)
 {
     if (!$title instanceof Exception && String::isEmpty($title)) {
         throw new ZiboException('Empty title provided');
     }
     $this->title = $title;
 }
Example #28
0
 /**
  * Set the date format used to write the timestamp of the log item
  */
 public function setDateFormat($dateFormat)
 {
     if (String::isEmpty($dateFormat)) {
         throw new ZiboException('Provided date format is empty');
     }
     $this->dateFormat = $dateFormat;
 }
Example #29
0
 /**
  * Sets the label of this anchor element
  * @param string $label
  * @return null
  * @throws zibo\ZiboException when the label is empty or not a string
  */
 public function setLabel($label)
 {
     if (String::isEmpty($label)) {
         throw new ZiboException('Provided label is empty');
     }
     $this->label = $label;
 }
Example #30
0
 /**
  * Set the type of this message
  * @param string $type
  * @return null
  */
 public function setType($type = null)
 {
     if ($type !== null && !String::isString($type, String::NOT_EMPTY)) {
         throw new ZiboException('The provided type is invalid or empty');
     }
     $this->type = $type;
 }