作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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);
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
private function setAction($action)
{
if (String::isEmpty($action)) {
$action = Dispatcher::ACTION_ASTERIX;
}
$this->action = $action;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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);
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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);
}
作者:BGCX26
项目:zibo-svn-to-gi
function smarty_function_scripts_get_url($url, $baseUrl)
{
if (String::looksLikeUrl($url)) {
return $url;
}
return $baseUrl . $url;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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');
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}
作者:BGCX26
项目:zibo-svn-to-gi
/**
* 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;
}