本文整理汇总了PHP中Validate::isString方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isString方法的具体用法?PHP Validate::isString怎么用?PHP Validate::isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
public function getContent()
{
$this->_html = '<h2>' . $this->displayName . '</h2>';
if (Tools::isSubmit('submitUpdate')) {
if (Tools::getValue('STORE_DELIVERY_SEND_MAIL') !== false && Validate::isBool(Tools::getValue('STORE_DELIVERY_SEND_MAIL'))) {
Configuration::updateValue('STORE_DELIVERY_SEND_MAIL', Tools::getValue('STORE_DELIVERY_SEND_MAIL'));
}
if (Tools::getValue('STORE_DELIVERY_CARRIER') != false && Validate::isInt(Tools::getValue('STORE_DELIVERY_CARRIER'))) {
Configuration::updateValue('STORE_DELIVERY_CARRIER', Tools::getValue('STORE_DELIVERY_CARRIER'));
$carrierObj = new Carrier((int) Tools::getValue('STORE_DELIVERY_CARRIER'));
Configuration::updateValue('STORE_DELIVERY_CARRIER_REFERENCE', $carrierObj->id_reference);
}
if (Tools::getValue('STORE_DELIVERY_DISPLAY_MAP') !== false && Validate::isBool(Tools::getValue('STORE_DELIVERY_DISPLAY_MAP'))) {
Configuration::updateValue('STORE_DELIVERY_DISPLAY_MAP', Tools::getValue('STORE_DELIVERY_DISPLAY_MAP'));
}
if (Tools::getValue('STORE_DELIVERY_HEIGHT_MAP') !== false && Validate::isString(Tools::getValue('STORE_DELIVERY_HEIGHT_MAP'))) {
Configuration::updateValue('STORE_DELIVERY_HEIGHT_MAP', Tools::getValue('STORE_DELIVERY_HEIGHT_MAP'));
}
if (Tools::getValue('STORE_DELIVERY_WIDTH_MAP') !== false && Validate::isString(Tools::getValue('STORE_DELIVERY_WIDTH_MAP'))) {
Configuration::updateValue('STORE_DELIVERY_WIDTH_MAP', Tools::getValue('STORE_DELIVERY_WIDTH_MAP'));
}
if (!Validate::isBool(Tools::getValue('STORE_DELIVERY_SEND_MAIL')) || !Validate::isInt(Tools::getValue('STORE_DELIVERY_CARRIER')) || !Validate::isBool(Tools::getValue('STORE_DELIVERY_DISPLAY_MAP')) || !Validate::isString(Tools::getValue('STORE_DELIVERY_HEIGHT_MAP')) || !Validate::isString(Tools::getValue('STORE_DELIVERY_WIDTH_MAP'))) {
$this->_html .= '<div class="alert">' . $this->l('Error! An information is invalid') . '</div>';
}
}
return $this->_displayForm();
}
示例2: _update_configuration
protected function _update_configuration($key, $value)
{
$interface = PS_CLI_Interface::getInterface();
$validValue = false;
switch ($key) {
case 'PS_STORE_DISPLAY_FOOTER':
case 'PS_STORE_DISPLAY_SITEMAP':
case 'PS_STORE_SIMPLIFIED':
$validValue = Validate::isBool($value);
break;
case 'PS_STORES_CENTER_LAT':
case 'PS_STORES_CENTER_LONG':
$validValue = Validate::isCoordinate($value);
break;
case 'PS_SHOP_NAME':
$validValue = Validate::isName($value);
break;
case 'PS_SHOP_EMAIL':
$validValue = Validate::isEmail($value);
break;
case 'PS_SHOP_DETAILS':
$validValue = Validate::isString($value);
break;
case 'PS_SHOP_ADDR1':
case 'PS_SHOP_ADDR2':
$validValue = Validate::isAddress($value);
break;
case 'PS_SHOP_CODE':
$validValue = Validate::isPostCode($value);
break;
case 'PS_SHOP_CITY':
$validValue = Validate::isCityName($value);
break;
case 'PS_SHOP_COUNTRY_ID':
if (Validate::isUnsignedId($value)) {
$obj = new Country((int) $value);
$validValue = Validate::isLoadedObject($obj);
}
break;
case 'PS_SHOP_STATE_ID':
$validValue = Validate::isUnsignedId($value);
break;
case 'PS_SHOP_PHONE':
case 'PS_SHOP_FAX':
$validValue = Validate::isPhoneNumber($value);
break;
default:
$interface->error("Configuration key '{$key}' is not handled by this command");
break;
}
if (!$validValue) {
$interface->error("value '{$value}' is not a valid value for configuration key '{$key}'");
}
if (PS_CLI_Utils::update_configuration_value($key, $value)) {
$interface->success("Successfully updated '{$key}' configuration");
} else {
$interface->error("Could not update configuration key '{$key}'");
}
}
示例3: parseConnectionString
/**
* Parses the connection string into a collection of key/value pairs.
*
* @param string $argumentName Name of the argument to be used in error
* messages.
* @param string $connectionString Connection string.
*
* @return array
*
* @static
*/
public static function parseConnectionString($argumentName, $connectionString)
{
Validate::isString($argumentName, 'argumentName');
Validate::notNullOrEmpty($argumentName, 'argumentName');
Validate::isString($connectionString, 'connectionString');
Validate::notNullOrEmpty($connectionString, 'connectionString');
$parser = new ConnectionStringParser($argumentName, $connectionString);
return $parser->_parse();
}
示例4: getContent
public function getContent()
{
$errors = array();
$this->_html = '<h2>' . $this->displayName . '</h2>';
/* Update values in DB */
if (Tools::isSubmit('submitExportCSV')) {
$send_copy = (int) Tools::getValue('send_copy');
$email = (string) Tools::getValue('email');
if (!Validate::isInt($send_copy) || !Validate::isString($email)) {
$errors[] = $this->l('Invalid data');
} else {
Configuration::updateValue('PS_SCE_SEND_COPY', $send_copy);
Configuration::updateValue('PS_SCE_EMAIL', $email);
}
if (isset($errors) && count($errors)) {
$this->_html .= $this->displayError(implode('<br />', $errors));
} else {
$this->_html .= $this->displayConfirmation($this->l('Settings updated'));
}
}
$this->displayForm();
return $this->_html;
}
示例5: getContent
public function getContent()
{
if (Tools::isSubmit('submitReferralProgram')) {
$this->_postValidation();
if (!sizeof($this->_errors)) {
$this->_postProcess();
} else {
foreach ($this->_errors as $err) {
$this->_html .= '<div class="errmsg">' . $err . '</div>';
}
}
} elseif (Tools::isSubmit('submitText')) {
foreach ($_POST as $key => $value) {
if (!is_array(Tools::getValue($key)) && !Validate::isString(Tools::getValue($key))) {
$this->_html .= $this->displayError($this->l('Invalid html field, javascript is forbidden'));
$this->_displayForm();
return $this->_html;
}
}
$this->_writeXml();
}
$this->_html .= '<h2>' . $this->displayName . '</h2>';
$this->_displayForm();
$this->_displayFormRules();
return $this->_html;
}
示例6: getContent
function getContent()
{
/* display the module name */
$this->_html = '<h2>' . $this->displayName . '</h2>';
$errors = '';
/* update the editorial xml */
if (isset($_POST['submitUpdate'])) {
// Forbidden key
$forbidden = array('submitUpdate');
foreach ($_POST as $key => $value) {
if (!Validate::isString($_POST[$key])) {
$this->_html .= $this->displayError($this->l('Invalid html field, javascript is forbidden'));
$this->_displayForm();
return $this->_html;
}
}
// Generate new XML data
$newXml = '<?xml version=\'1.0\' encoding=\'utf-8\' ?>' . "\n";
$newXml .= '<editorial>' . "\n";
$newXml .= ' <header>';
// Making header data
foreach ($_POST as $key => $field) {
if ($line = $this->putContent($newXml, $key, $field, $forbidden, 'header')) {
$newXml .= $line;
}
}
$newXml .= "\n" . ' </header>' . "\n";
$newXml .= ' <body>';
// Making body data
foreach ($_POST as $key => $field) {
if ($line = $this->putContent($newXml, $key, $field, $forbidden, 'body')) {
$newXml .= $line;
}
}
$newXml .= "\n" . ' </body>' . "\n";
$newXml .= '</editorial>' . "\n";
/* write it into the editorial xml file */
if ($fd = @fopen(dirname(__FILE__) . '/editorial.xml', 'w')) {
if (!@fwrite($fd, $newXml)) {
$errors .= $this->displayError($this->l('Unable to write to the editor file.'));
}
if (!@fclose($fd)) {
$errors .= $this->displayError($this->l('Can\'t close the editor file.'));
}
} else {
$errors .= $this->displayError($this->l('Unable to update the editor file.<br />Please check the editor file\'s writing permissions.'));
}
/* upload the image */
if (isset($_FILES['body_homepage_logo']) and isset($_FILES['body_homepage_logo']['tmp_name']) and !empty($_FILES['body_homepage_logo']['tmp_name'])) {
Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
if ($error = checkImage($_FILES['body_homepage_logo'], $this->maxImageSize)) {
$errors .= $error;
} elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) {
return false;
} elseif (!imageResize($tmpName, dirname(__FILE__) . '/homepage_logo.jpg')) {
$errors .= $this->displayError($this->l('An error occurred during the image upload.'));
}
unlink($tmpName);
}
$this->_html .= $errors == '' ? $this->displayConfirmation('Settings updated successfully') : $errors;
}
/* display the editorial's form */
$this->_displayForm();
return $this->_html;
}
示例7: _postValidation
private function _postValidation()
{
if (Tools::getValue('yamarket_с_shop') && !Validate::isString(Tools::getValue('yamarket_с_shop'))) {
$this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Shop Name');
}
if (Tools::getValue('yamarket_с_company') && !Validate::isString(Tools::getValue('yamarket_с_company'))) {
$this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Сompany name');
}
if (Tools::getValue('yamarket_с_shippingcost') && !Validate::isString(Tools::getValue('yamarket_с_shippingcost'))) {
$this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Shipping cost');
}
if (Tools::getValue('yamarket_с_info') && !Validate::isString(Tools::getValue('yamarket_с_info'))) {
$this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Information');
}
if (Tools::getValue('yamarket_с_gzip') && !Validate::isBool(Tools::getValue('yamarket_с_gzip'))) {
$this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Gzip compression');
}
if (Tools::getValue('yamarket_с_combinations') && !Validate::isBool(Tools::getValue('yamarket_с_combinations'))) {
$this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Combinations');
}
if (Tools::getValue('yamarket_с_currencies') && !Validate::isBool(Tools::getValue('yamarket_с_currencies'))) {
$this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Currencies');
}
if (Tools::getValue('yamarket_с_availability') && !Validate::isInt(Tools::getValue('yamarket_с_availability'))) {
$this->post_errors[] = $this->l('Invalid') . ' ' . $this->l('Availability');
}
}
示例8: _update_configuration
protected function _update_configuration($key, $value)
{
$interface = PS_CLI_Interface::getInterface();
$validValue = false;
switch ($key) {
case 'PS_SEARCH_INDEXIATION':
case 'PS_SEARCH_AJAX':
case 'PS_INSTANCE_SEARCH':
$validValue = Validate::isBool($value);
break;
case 'PS_SEARCH_WEIGHT_PNAME':
case 'PS_SEARCH_WEIGHT_REF':
case 'PS_SEARCH_WEIGHT_SHORTDESC':
case 'PS_SEARCH_WEIGHT_DESC':
case 'PS_SEARCH_WEIGHT_CNAME':
case 'PS_SEARCH_WEIGHT_MNAME':
case 'PS_SEARCH_WEIGHT_TAG':
case 'PS_SEARCH_WEIGHT_ATTRIBUTE':
case 'PS_SEARCH_WEIGHT_FEATURE':
case 'PS_SEARCH_MINWORDLEN':
$validValue = Validate::isUnsignedInt($value);
break;
case 'PS_SEARCH_BLACKLIST':
$validValue = Validate::isString($value);
break;
default:
$interface->error("Configuration key '{$key}' is not handled by this command");
break;
}
if (!$validValue) {
$interface->error("'{$value}' is not a valid value for configuration key '{$key}'");
}
if (PS_CLI_Utils::update_configuration_value($key, $value)) {
$interface->success("Successfully updated configuration key '{$key}'");
} else {
$interface->error("Could not update configuration key '{$key}'");
}
}
示例9: __construct
/**
* Creates new media services settings instance.
*
* @param string $accountName The user provided account name.
* @param string $accessKey The user provided primary access key
* @param string $endpointUri The service management endpoint uri.
* @param string $oauthEndpointUri The OAuth service endpoint uri.
*/
public function __construct($accountName, $accessKey, $endpointUri = null, $oauthEndpointUri = null)
{
Validate::notNullOrEmpty($accountName, 'accountName');
Validate::notNullOrEmpty($accessKey, 'accountKey');
Validate::isString($accountName, 'accountName');
Validate::isString($accessKey, 'accountKey');
if ($endpointUri != null) {
Validate::isValidUri($endpointUri);
} else {
$endpointUri = Resources::MEDIA_SERVICES_URL;
}
if ($oauthEndpointUri != null) {
Validate::isValidUri($oauthEndpointUri);
} else {
$oauthEndpointUri = Resources::MEDIA_SERVICES_OAUTH_URL;
}
$this->_accountName = $accountName;
$this->_accessKey = $accessKey;
$this->_endpointUri = $endpointUri;
$this->_oauthEndpointUri = $oauthEndpointUri;
}
示例10: _postValidation
private function _postValidation()
{
if (Tools::getValue('robokassa_login') && !Validate::isString(Tools::getValue('robokassa_login'))) {
$this->_postErrors[] = $this->l('Invalid') . ' ' . $this->l('Merchant login');
}
if (Tools::getValue('robokassa_password1') && !Validate::isString(Tools::getValue('robokassa_password1'))) {
$this->_postErrors[] = $this->l('Invalid') . ' ' . $this->l('Password #1');
}
if (Tools::getValue('robokassa_password2') && !Validate::isString(Tools::getValue('robokassa_password2'))) {
$this->_postErrors[] = $this->l('Invalid') . ' ' . $this->l('Password #2');
}
}
示例11: environmentSource
/**
* Gets a connection string value from the system environment.
*
* @param string $key The connection string name.
*
* @return string
*/
public static function environmentSource($key)
{
Validate::isString($key, 'key');
return getenv($key);
}
示例12: base256ToDec
/**
* Convert base 256 number to decimal number.
*
* @param string $number Base 256 number
*
* @return string Decimal number
*/
public static function base256ToDec($number)
{
Validate::isString($number, 'number');
$result = 0;
$base = 1;
for ($i = strlen($number) - 1; $i >= 0; --$i) {
$result = bcadd($result, bcmul(ord($number[$i]), $base));
$base = bcmul($base, 256);
}
return $result;
}
示例13: update_configuration
protected function update_configuration($key, $value)
{
$interface = PS_CLI_Interface::getInterface();
$validValue = false;
switch ($key) {
case 'PS_SMARTY_CACHE':
case 'PS_CSS_THEME_CACHE':
case 'PS_JS_THEME_CACHE':
$validValue = Validate::isBool($value);
break;
case 'PS_SMARTY_CACHING_TYPE':
switch ($value) {
case 'filesytem':
case 'mysql':
$validValue = true;
break;
default:
$validValue = false;
break;
}
break;
case 'PS_SMARTY_CONSOLE':
case 'PS_SMARTY_FORCE_COMPILE':
$validValue = Validate::isUnsignedInt($value) && $value <= 2;
break;
case 'PS_SMARTY_CONSOLE_KEY':
$validValue = Validate::isString($value);
break;
default:
$interface->error("Configuration key '{$key}' is not handled by this plugin");
break;
}
if (!$validValue) {
$configuration->error("'{$value}' is not a valid value for configuration key '{$key}'");
}
// todo: callbacks ?
if (PS_CLI_Utils::update_configuration_value($key, $value)) {
$interface->success("Successfully updated configuration key '{$key}'");
} else {
$interface->error("Could not update configuration key '{$key}'");
}
}
示例14: _postValidation
/**
* Process vadiation before saving data
*/
private function _postValidation()
{
if (Validate::isString(Tools::getValue('entity'))) {
$this->_postErrors[] = $this->l('Please, choice Entity');
}
}
示例15: postValidation
private function postValidation()
{
$errors = array();
if (Tools::isSubmit('submitSettings')) {
$token_public = Tools::getValue('TAXAMOEUVAT_TOKENPUBLIC');
if (!$token_public || empty($token_public) || !Validate::isString($token_public)) {
$errors[] = $this->l('Key public invalid value');
}
$token_private = Tools::getValue('TAXAMOEUVAT_TOKENPRIVATE');
if (!$token_private || empty($token_private) || !Validate::isString($token_private)) {
$errors[] = $this->l('Key private invalid value');
}
$generic_name = Tools::getValue('TAXAMOEUVAT_GENERICNAME');
if (!$generic_name || empty($generic_name) || !Validate::isString($generic_name)) {
$errors[] = $this->l('Generic name invalid value');
}
$process = Tools::getValue('TAXAMOEUVAT_PROCESS');
if (is_null($process) || !Validate::isInt($process) || $process != 0 && $process != 1) {
$errors[] = $this->l('Process invalid value');
}
} elseif (Tools::isSubmit('submitOrderState')) {
if (Tools::isSubmit('id_taxamo_orderstateoperation')) {
$id_taxamo_orderstateoperation = Tools::getValue('id_taxamo_orderstateoperation');
if (!$id_taxamo_orderstateoperation || empty($id_taxamo_orderstateoperation) || !Validate::isInt($id_taxamo_orderstateoperation)) {
$errors[] = $this->l('Invalid id_taxamo_orderstateoperation');
}
}
$id_order_state = Tools::getValue('id_order_state');
if (!$id_order_state || empty($id_order_state) || !Validate::isInt($id_order_state)) {
$errors[] = $this->l('Order State invalid value');
}
$operation = Tools::getValue('operation');
if (!$operation || empty($operation) || !in_array($operation, array(1, 2))) {
$errors[] = $this->l('Operation invalid value');
}
} elseif (Tools::isSubmit('delete_id_taxamo_orderstateoperation')) {
$delete_id_taxamo_orderstateoperation = Tools::getValue('delete_id_taxamo_orderstateoperation');
if (!$delete_id_taxamo_orderstateoperation || empty($delete_id_taxamo_orderstateoperation) || !Validate::isInt($delete_id_taxamo_orderstateoperation)) {
$errors[] = $this->l('Invalid delete_id_taxamo_orderstateoperation');
}
}
/* Display errors if needed */
if (count($errors)) {
$this->_html .= $this->displayError(implode('<br />', $errors));
return false;
}
/* Returns if validation is ok */
return true;
}