Пример #1
0
 public function getName()
 {
     if ($this->validator != null) {
         return $this->validator->getName();
     } else {
         return null;
     }
 }
 public function __construct(MapRequest $mapData, TileSource $source)
 {
     $this->_mapData = $mapData;
     $this->_tileSource = $source;
     if (!is_null($this->_mapData->getZoom())) {
         $this->_worldMap = $source->getWorldMap($this->_mapData->getZoom());
     }
     $this->_requestValidator->check();
 }
Пример #3
0
 private function validatePassword(RequestValidator $validator)
 {
     ClassLoader::import("application.helper.check.PasswordMatchCheck");
     $validator->addCheck('password', new MinLengthCheck(sprintf($this->translate('_err_short_password'), self::PASSWORD_MIN_LENGTH), self::PASSWORD_MIN_LENGTH));
     $validator->addCheck('password', new IsNotEmptyCheck($this->translate('_err_enter_password')));
     $validator->addCheck('confpassword', new IsNotEmptyCheck($this->translate('_err_enter_password')));
     $validator->addCheck('confpassword', new PasswordMatchCheck($this->translate('_err_password_match'), $this->request, 'password', 'confpassword'));
 }
Пример #4
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
require_once '/data/project/hgztools/public_html/general.php';
// create new page object
$page = new HtmlPage('Useless defaultsorts');
// create new database object
$db = new Database();
// create new request validator
$rq = new RequestValidator();
// get parameters
$rq->addAllowed('GET', 'lang', '', '/^[a-z]{1,7}$/', true);
$rq->addAllowed('GET', 'project', '', '/^[a-z]{1,15}$/', true);
$par = $rq->getParams();
$page->openBlock('div', 'iw-content');
$page->addInline('p', 'This tool generates a list of DEFAULTSORT keys that match the page title exactly.');
$page->addInline('h2', 'Options');
$optionForm = new HtmlForm('index.php', 'GET');
$optionForm->addHTML('<table class="iw-nostyle">');
$optionForm->addHTML('<tr><td>');
$optionForm->addLabel('lang', 'Language');
$optionForm->addHTML('</td><td>');
$optionForm->addInput('lang', $par['lang'], 'Language code of the project, e.g. de', 7, true);
$optionForm->addHTML('</td></tr>');
$optionForm->addHTML('<tr><td>');
Пример #5
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
require_once '/data/project/hgztools/public_html/general.php';
// create new page object
$page = new HtmlPage('Category redirects');
// create new database object
$db = new Database();
// create new request validator
$rq = new RequestValidator();
// get parameters
$rq->addAllowed('GET', 'lang', '', '/^[a-z]{1,7}$/', true);
$rq->addAllowed('GET', 'project', '', '/^[a-z]{1,15}$/', true);
$rq->addAllowed('GET', 'sort', 'name', '/^(name|entries|length)$/');
$par = $rq->getParams();
$page->openBlock('div', 'iw-content');
$page->addInline('p', 'This tool shows a list of categories that redirect to another category in the given project and the number of entries in it.');
$page->addInline('h2', 'Options');
$optionForm = new HtmlForm('index.php', 'GET');
$optionForm->addHTML('<table class="iw-nostyle">');
$optionForm->addHTML('<tr><td>');
$optionForm->addLabel('lang', 'Language');
$optionForm->addHTML('</td><td>');
$optionForm->addInput('lang', $par['lang'], 'Language code of the project, e.g. de', 7, true);
$optionForm->addHTML('</td></tr>');
Пример #6
0
 protected function validateAddress(RequestValidator $validator, $prefix)
 {
     $someValidator = $this->getValidator('foo', $this->request);
     ClassLoader::import('application.controller.UserController');
     $con = new UserController($this->application);
     $con->validateAddress($someValidator, $prefix, 'shipping_' == $prefix);
     foreach ($someValidator->getValidatorVars() as $field => $var) {
         foreach ($var->getChecks() as $check) {
             $validator->addCheck($field, new OrCheck(array($field, substr($prefix, 0, -1) . 'Address'), array($check, new IsNotEmptyCheck('')), $this->request));
         }
     }
 }
Пример #7
0
 public function getJSValidatorParams($requestVarName = null)
 {
     $this->processPlugins();
     return parent::getJSValidatorParams($requestVarName);
 }
Пример #8
0
 public function setValidation(RequestValidator $validator, $filtersOnly = false, $fieldPrefix = '')
 {
     $specFields = $this->getSpecificationFieldSet(ActiveRecordModel::LOAD_REFERENCES);
     $application = ActiveRecordModel::getApplication();
     foreach ($specFields as $key => $field) {
         $fieldname = $fieldPrefix . $field->getFormFieldName();
         // validate numeric values
         if (EavFieldCommon::TYPE_NUMBERS_SIMPLE == $field->type->get()) {
             if (!$filtersOnly) {
                 $validator->addCheck($fieldname, new IsNumericCheck($application->translate('_err_numeric')));
             }
             $validator->addFilter($fieldname, new NumericFilter());
         }
         // validate required fields
         if ($field->isRequired->get() && !$filtersOnly) {
             if (!($field->isSelector() && $field->isMultiValue->get())) {
                 $validator->addCheck($fieldname, new IsNotEmptyCheck($application->translate('_err_specfield_required')));
             } else {
                 ClassLoader::import('application.helper.check.SpecFieldIsValueSelectedCheck');
                 $validator->addCheck($fieldname, new SpecFieldIsValueSelectedCheck($application->translate('_err_specfield_multivaluerequired'), $field, $application->getRequest()));
             }
         }
     }
 }
 public function testDataInvalidImageFileType()
 {
     // "uri": "/listings/:listing_id/images"
     $method = 'uploadListingImage';
     $args = array('params' => array('listing_id' => 123456), 'data' => array('image' => array('file.jpg;type=image/jpeg')));
     $result = RequestValidator::validateParams($args, $this->methods[$method]);
     $this->assertArrayHasKey('_invalid', $result, print_r(@$result['_invalid'], true));
     $this->assertCount(1, $result['_invalid']);
     $this->assertRegExp($this->invalidTypeRegExp, $result['_invalid'][0]);
 }
Пример #10
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
require_once '/data/project/hgztools/public_html/general.php';
// create new page object
$page = new HtmlPage('Bot statistics');
// create new database object
$db = new Database();
// create new request validator
$rq = new RequestValidator();
// get parameters
$rq->addAllowed('GET', 'lang', '', '/^[a-z]{1,7}$/', true);
$rq->addAllowed('GET', 'project', '', '/^[a-z]{1,15}$/', true);
$rq->addAllowed('GET', 'sort', 'ec', '/^(name|reg|ec)$/');
$rq->addAllowed('GET', 'dir', 'desc', '/^(asc|desc)$/');
$par = $rq->getParams();
$page->openBlock('div', 'iw-content');
$page->addInline('p', 'This tool generates a list of bots in a given project with their total editcount and registration date.');
$page->addInline('h2', 'Options');
$optionForm = new HtmlForm('index.php', 'GET');
$optionForm->addHTML('<table class="iw-nostyle">');
$optionForm->addHTML('<tr><td>');
$optionForm->addLabel('lang', 'Language');
$optionForm->addHTML('</td><td>');
$optionForm->addInput('lang', $par['lang'], 'Language code of the project, e.g. de', 7, true);
Пример #11
0
 public function setRequest($request)
 {
     self::$_request = $request;
 }
Пример #12
0
 public static function validateData($args, $methodInfo)
 {
     $result = array('_valid' => array());
     if (!is_array($methodInfo)) {
         $result['_invalid'][] = 'Method not found';
         return $result;
     }
     $methodsParams = $methodInfo['params'];
     foreach ($args as $name => $arg) {
         if (isset($methodsParams[$name])) {
             $validType = $methodsParams[$name];
             $type = gettype($arg);
             switch ($type) {
                 case 'integer':
                     $type = 'int';
                     break;
                 case 'double':
                     $type = 'float';
                     break;
                 case 'array':
                     if (count($arg) > 0) {
                         if (preg_match('/@.*?;type=.*?\\/.+$/', @$arg[0])) {
                             $type = 'imagefile';
                             $name = '@' . $name;
                             $arg = @$arg[0];
                         } else {
                             $item_type = gettype($arg[0]);
                             switch ($item_type) {
                                 case 'integer':
                                     $item_type = 'int';
                                     break;
                                 case 'double':
                                     $item_type = 'float';
                                     break;
                             }
                             $type = 'array(' . $item_type . ')';
                         }
                     }
                     break;
             }
             if ($validType !== $type) {
                 if (substr($validType, 0, 4) === 'enum') {
                     if ($arg === 'enum' || !preg_match("@" . preg_quote($arg) . "@", $validType)) {
                         $result['_invalid'][] = 'Invalid enum data param "' . $name . '" value (' . $arg . '): valid values "' . $validType . '"';
                     } else {
                         $result['_valid'][$name] = $arg;
                     }
                 } elseif ($type === 'array' && substr($validType, 0, 5) === 'array' || $type === 'string' && $validType === 'text') {
                     $result['_valid'][$name] = $arg;
                 } else {
                     $result['_invalid'][] = RequestValidator::invalidParamType($name, $arg, $type, $validType);
                 }
             } else {
                 $result['_valid'][$name] = $arg;
             }
         } else {
             $result['_invalid'][] = RequestValidator::invalidParam($name, $arg, gettype($arg));
         }
     }
     return $result;
 }
Пример #13
0
 /**
  * Valida o objeto retornando a mensagem de erro
  * @return string
  */
 public function validAndGetErrorMsg()
 {
     require_once 'CRUD/RequestValidator.php';
     $req = new RequestValidator($this->object);
     $req->init();
     return $req->result();
 }
Пример #14
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
require_once '/data/project/hgztools/public_html/general.php';
// create new page object
$page = new HtmlPage('Wikidata-Auszeichnungs-Abgleich');
// create new database object
$db = new Database();
// create new request validator
$rq = new RequestValidator();
// get parameters
$rq->addAllowed('GET', 'mode', '', '/^(lesenswert|exzellent|informativ|portal)$/', true);
$par = $rq->getParams();
$page->openBlock('div', 'iw-content');
$page->addInline('p', 'Mit diesem Werkzeug lassen sich Unterschiede zwischen den lokalen Auszeichnungsvorlagen und den Daten auf Wikidata feststellen.');
$page->addInline('h2', 'Optionen');
$optionForm = new HtmlForm('index.php', 'GET');
$optionForm->addHTML('<table class="iw-nostyle">');
$optionForm->addHTML('<tr><td>');
$optionForm->addLabel('mode', 'Kategorie');
$optionForm->addHTML('</td><td>');
$optionForm->addHTML('<select id="mode" name="mode">');
$optionForm->addHTML('<option value="lesenswert">lesenswerte Artikel</option>');
$optionForm->addHTML('<option value="exzellent">exzellente Artikel</option>');
$optionForm->addHTML('<option value="informativ">informative Listen</option>');
Пример #15
0
 private function setFieldValidation(RequestValidator $validator, Tax $tax, TaxClass $class = null)
 {
     $field = $this->getFieldName($tax, $class);
     $validator->addCheck($field, new IsNumericCheck($this->translate("_error_rate_should_be_numeric_value")));
     $validator->addCheck($field, new MinValueCheck($this->translate("_error_rate_should_be_greater_than_zero"), 0));
     $validator->addFilter($field, new NumericFilter());
 }
Пример #16
0
 public function addInventoryValidator(RequestValidator $validator)
 {
     if ($this->config->get('INVENTORY_TRACKING') != 'DISABLE') {
         $validator->addCheck('stockCount', new IsNotEmptyCheck($this->translate('_err_stock_required')));
         $validator->addCheck('stockCount', new IsNumericCheck($this->translate('_err_stock_not_numeric')));
         $validator->addCheck('stockCount', new MinValueCheck($this->translate('_err_stock_negative'), 0));
     }
     $validator->addFilter('stockCount', new NumericFilter());
     return $validator;
 }
Пример #17
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
require_once '/data/project/hgztools/public_html/general.php';
// create new page object
$page = new HtmlPage('Contributors');
// create new database object
$db = new Database();
// create new request validator
$rq = new RequestValidator();
// get parameters
$rq->addAllowed('GET', 'lang', '', '/^[a-z]{1,7}$/', true);
$rq->addAllowed('GET', 'project', '', '/^[a-z]{1,15}$/', true);
$rq->addAllowed('GET', 'page', '', '', true, false);
$rq->addAllowed('GET', 'since', '0000-00-00', '/^\\d{4}-\\d{2}-\\d{2}$/', false, false);
$rq->addAllowed('GET', 'until', '0000-00-00', '/^\\d{4}-\\d{2}-\\d{2}$/', false, false);
$par = $rq->getParams();
$page->openBlock('div', 'iw-content');
$page->addInline('p', 'This tool creates a list of contributors to a given article on a given project in wikitext.');
$page->addInline('h2', 'Options');
$optionForm = new HtmlForm('index.php', 'GET');
$optionForm->addHTML('<table class="iw-nostyle">');
$optionForm->addHTML('<tr><td>');
$optionForm->addLabel('lang', 'Language');
$optionForm->addHTML('</td><td>');
Пример #18
0
 public static function addOptionValidation(RequestValidator $validator, $option, $fieldName)
 {
     $app = ActiveRecordModel::getApplication();
     if (ProductOption::TYPE_FILE == $option['type']) {
         $checks = array(new IsFileUploadedCheck($app->translate('_err_option_upload')), new IsNotEmptyCheck($app->translate('_err_option_upload')));
         $validator->addCheck($fieldName, new OrCheck(array('upload_' . $fieldName, $fieldName), $checks, $validator->getRequest()));
         if ($types = ProductOption::getFileExtensions($option['fileExtensions'])) {
             $validator->addCheck('upload_' . $fieldName, new IsFileTypeValidCheck($app->maketext('_err_option_filetype', implode(', ', $types)), $types));
         }
         $validator->addCheck('upload_' . $fieldName, new MaxFileSizeCheck($app->maketext('_err_option_filesize', $option['maxFileSize']), $option['maxFileSize']));
     } else {
         $validator->addCheck($fieldName, new IsNotEmptyCheck($app->translate('_err_option_' . $option['type'])));
     }
 }
Пример #19
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
require_once '/data/project/hgztools/public_html/general.php';
// create new page object
$page = new HtmlPage('Page prop maintenance');
// create new database object
$db = new Database();
// create new request validator
$rq = new RequestValidator();
// get parameters
$rq->addAllowed('GET', 'lang', '', '/^[a-z]{1,7}$/', true);
$rq->addAllowed('GET', 'project', '', '/^[a-z]{1,15}$/', true);
$rq->addAllowed('GET', 'mode', '', '/^(ns0\\-noindex|ns0\\-index|ns0\\-noeditsection|ns0\\-newsectionlink|staticredirect)$/', true);
$par = $rq->getParams();
$page->openBlock('div', 'iw-content');
$page->addInline('p', 'This tool allows to get information about some probably misused magic words in a specific project.');
$page->addInline('h2', 'Options');
$optionForm = new HtmlForm('index.php', 'GET');
$optionForm->addHTML('<table class="iw-nostyle">');
$optionForm->addHTML('<tr><td>');
$optionForm->addLabel('lang', 'Language');
$optionForm->addHTML('</td><td>');
$optionForm->addInput('lang', $par['lang'], 'Language code of the project, e.g. de', 7, true);
$optionForm->addHTML('</td></tr>');