当前位置: 首页>>代码示例>>PHP>>正文


PHP Filter::filterValue方法代码示例

本文整理汇总了PHP中Filter::filterValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::filterValue方法的具体用法?PHP Filter::filterValue怎么用?PHP Filter::filterValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Filter的用法示例。


在下文中一共展示了Filter::filterValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addmethodAction

 /**
  * Add new object method
  */
 public function addmethodAction()
 {
     $project = $this->_getProject();
     $objectName = Request::post('object', 'string', '');
     $objectMethodSrc = Request::post('method', 'string', '');
     $objectMethod = Filter::filterValue(Filter::FILTER_ALPHANUM, $objectMethodSrc);
     if (!strlen($objectName) || !$project->objectExists($objectName)) {
         Response::jsonError($this->_lang->get('WRONG_REQUEST'));
     }
     if (!strlen($objectMethodSrc)) {
         Response::jsonError($this->_lang->get('CANT_BE_EMPTY'));
     }
     if ($objectMethodSrc !== $objectMethod) {
         Response::jsonError($this->_lang->get('INVALID_VALUE'));
     }
     $methodsManager = $project->getMethodManager();
     if ($methodsManager->methodExists($objectName, $objectMethod)) {
         Response::jsonError($this->_lang->get('SB_UNIQUE'));
     }
     if (!$methodsManager->addMethod($objectName, $objectMethod)) {
         Response::jsonError($this->_lang->get('CANT_EXEC'));
     }
     $this->_storeProject();
     Response::jsonSuccess();
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:28,代码来源:Methods.php

示例2: deleteAction

 /**
  * Remove configuration record
  */
 public function deleteAction()
 {
     $this->_checkCanDelete();
     $data = Request::post('data', 'raw', false);
     if ($data === false) {
         Response::jsonSuccess();
     }
     $dataType = json_decode($data);
     if (!is_array($dataType)) {
         $data = array(json_decode($data, true));
     } else {
         $data = json_decode($data, true);
     }
     $media = Model::factory('Medialib');
     $configImage = $media->getConfig()->get('image');
     foreach ($data as $item) {
         $code = Filter::filterValue('pagecode', $item['code']);
         unset($configImage['sizes'][$code]);
         unset($configImage['thumb_types'][$code]);
     }
     $config = $media->getConfig();
     $config->set('image', $configImage);
     if (!$config->save()) {
         Response::jsonError($this->_lang->CANT_WRITE_FS);
     }
     Response::jsonSuccess();
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:30,代码来源:Controller.php

示例3: setAdvancedProperty

 /**
  * Set advanced property
  * @param string $key
  * @param mixed $value
  * @return boolean - success flag
  */
 public function setAdvancedProperty($key, $value)
 {
     if (!isset(self::$advancedProperties[$key])) {
         return false;
     }
     $this->_advancedPropertyValues[$key] = Filter::filterValue(self::$advancedProperties[$key], $value);
     return true;
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:14,代码来源:Grid.php

示例4: checkcodeAction

 /**
  * Check if page code is unique
  */
 public function checkcodeAction()
 {
     $id = Request::post('id', 'int', 0);
     $code = Request::post('code', 'string', false);
     $code = Filter::filterValue('pagecode', $code);
     $model = Model::factory('Page');
     if ($model->checkUnique($id, 'code', $code)) {
         Response::jsonSuccess(array('code' => $code));
     } else {
         Response::jsonError($this->_lang->SB_UNIQUE);
     }
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:15,代码来源:Controller.php

示例5: subAction

 public function subAction()
 {
     $subController = Request::getInstance()->getPart(3);
     $subAction = Request::getInstance()->getPart(4);
     if ($subController === false || !strlen($subController) || $subAction === false || !strlen($subAction)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $subController = 'Backend_Designer_Sub_' . ucfirst(Filter::filterValue('pagecode', $subController));
     $subAction = Filter::filterValue('pagecode', $subAction) . 'Action';
     if (!class_exists($subController) || !method_exists($subController, $subAction)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $sub = new $subController();
     $sub->{$subAction}();
     exit;
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:16,代码来源:Controller.php

示例6: indexAction

 public function indexAction()
 {
     $controller = Filter::filterValue('pagecode', Request::getInstance()->getPart(1));
     $action = Filter::filterValue('pagecode', Request::getInstance()->getPart(2));
     if (!strlen($controller) || !strlen($action)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' c1');
     }
     $apiController = 'Api_' . ucfirst($controller);
     $apiAction = $action . 'Action';
     if (!class_exists($apiController)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' c2');
     }
     $controller = new $apiController(Registry::get('main', 'config'), $this->_db);
     if (!method_exists($controller, $apiAction)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' c3 ' . $apiAction);
     }
     $controller->{$apiAction}();
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:18,代码来源:Controller.php

示例7: route

 /**
  * Route request to the Controller
  * @return void
  */
 public function route()
 {
     $cfg = Registry::get('backend', 'config');
     $controller = $this->_request->getPart(1);
     $controller = Utils_String::formatClassName(Filter::filterValue('pagecode', $controller));
     if (in_array('Backend_' . $controller . '_Controller', $cfg->get('system_controllers'))) {
         $controller = 'Backend_' . $controller . '_Controller';
     } else {
         $manager = new Backend_Modules_Manager();
         $controller = $manager->getModuleController($controller);
         if ($controller === false) {
             if (Request::isAjax()) {
                 Response::jsonError(Lang::lang()->get('WRONG_REQUEST') . ' ' . Request::getInstance()->getUri());
             }
             $controller = 'Backend_Index_Controller';
         }
     }
     $this->runController($controller, $this->_request->getPart(2));
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:23,代码来源:Router.php

示例8: testFilterValue

 public function testFilterValue()
 {
     $this->assertEquals(Filter::filterValue('integer', 123), (int) 123);
     $this->assertEquals(Filter::filterValue('float', 12.2), (double) 12.2);
     $this->assertEquals(Filter::filterValue('str', 333), (string) 333);
     $this->assertEquals(Filter::filterValue('cleaned_string', " <a href='test'>Test</a>"), '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;');
     $this->assertEquals(Filter::filterValue('email', 'cmd<03>@aa.ss'), 'cmd03@aa.ss');
     $this->assertEquals(Filter::filterValue('raw', 'saa'), 'saa');
     $this->assertEquals(Filter::filterValue('alphanum', 'pOl$1@_!;l'), 'pOl1_l');
     $this->assertEquals(Filter::filterValue('alpha', 'pOl$1@_!;4l'), 'pOll');
     $this->assertEquals(Filter::filterValue('somefilter', '11asdasd 2 d'), 11);
     $this->assertEquals(Filter::filterValue('alphanum', '~!@#$%^&*()234admin@mail.ru'), '234adminmailru');
     $this->assertEquals(Filter::filterValue('login', '~!@#$%^&*()admin@mail.ru\\,\''), '@admin@mail.ru');
     $this->assertTrue(is_array(Filter::filterValue('array', 'asd')));
     Filter::setDelimiter('-');
     $this->assertEquals(Filter::filterValue('pagecode', 'p_Ol$ 1@_!;L'), 'p_ol1_l');
     Filter::setDelimiter('_');
     $this->assertEquals(Filter::filterValue('pagecode', 'p-Ol$ 1@_!;L'), 'p-ol1-l');
     Filter::setDelimiter('/');
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:20,代码来源:FilterTest.php

示例9: _cleanFilters

 /**
  * Prepare filter values , clean empty filters
  * @param array $filters
  * @return array
  */
 protected function _cleanFilters(array $filters)
 {
     foreach ($filters as $field => $val) {
         if (!$val instanceof Db_Select_Filter && !is_null($val) && (!is_array($val) && !strlen((string) $val))) {
             unset($filters[$field]);
             continue;
         }
         if ($this->_objectConfig->fieldExists($field) && $this->_objectConfig->isBoolean($field)) {
             $filters[$field] = Filter::filterValue(Filter::FILTER_BOOLEAN, $val);
         }
     }
     return $filters;
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:18,代码来源:Model.php

示例10: savefieldAction

 /**
  * Save field config
  */
 public function savefieldAction()
 {
     $this->_checkCanEdit();
     $part = Request::post('part', 'string', false);
     $fieldOption = Request::post('fieldoption', 'string', '');
     $field = Request::post('field', 'string', '');
     $value = Request::post('value', 'string', '');
     $accepted = array('select', 'title', 'alias');
     if (!$part || !$field || !in_array($fieldOption, $accepted, true)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' 1');
     }
     if ($fieldOption === 'select') {
         $value = Filter::filterValue('boolean', $value);
     }
     $this->_checkLoaded();
     $query = $this->_session->get('query');
     $part = $query->getPart($part);
     if ($part === false) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' 3');
     }
     $part->setFieldCfg($field, $fieldOption, $value);
     $this->_session->set('query', $query);
     Response::jsonSuccess();
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:27,代码来源:Controller.php

示例11: __set

 public function __set($name, $value)
 {
     if (!$this->_properties->isValid($name)) {
         throw new Exception('Trying to set undefined property ' . get_class($this->_properties) . '->' . $name);
     }
     switch ($this->_properties->{$name}) {
         case Ext_Property::Boolean:
             if (is_string($value) && strlen($value) || !is_string($value)) {
                 $value = Filter::filterValue('boolean', $value);
             }
             break;
     }
     return $this->_data[$name] = $value;
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:14,代码来源:Config.php

示例12: _routeConfig

 public function _routeConfig()
 {
     $controller = $this->_request->getPart(0);
     $pathCode = Filter::filterValue('pagecode', $controller);
     $routes = Config::factory(Config::File_Array, $this->_appConfig->get('frontend_modules'))->__toArray();
     if (isset($routes[$pathCode]) && class_exists($routes[$pathCode]['class'])) {
         $controllerClass = $routes[$pathCode]['class'];
     } else {
         $controllerClass = 'Frontend_Index_Controller';
     }
     $this->runController($controllerClass, $this->_request->getPart(1));
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:12,代码来源:Router.php

示例13: extFilters

 /**
  * Get data from Ext Grid Filters Feature
  * @param string $container
  * @param string $method
  */
 public static function extFilters($container = 'filterfeature', $method = 'POST')
 {
     if ($method == 'POST') {
         $filter = self::post($container, 'array', array());
     } else {
         $filter = self::get($container, 'array', array());
     }
     if (empty($filter)) {
         return array();
     }
     $result = array();
     foreach ($filter as $data) {
         $type = $data['data']['type'];
         $value = $data['data']['value'];
         $field = $data['field'];
         switch ($type) {
             case 'string':
                 $result[] = new Db_Select_Filter($field, '%' . $value . '%', Db_Select_Filter::LIKE);
                 break;
             case 'list':
                 if (is_array($value)) {
                     $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::IN);
                     break;
                 }
                 if (strpos($value, ',') !== false) {
                     $list = explode(',', $value);
                     $result[] = new Db_Select_Filter($field, $list, Db_Select_Filter::IN);
                     break;
                 }
                 $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::EQ);
                 break;
             case 'boolean':
                 $result[] = new Db_Select_Filter($field, Filter::filterValue(Filter::FILTER_BOOLEAN, $value), Db_Select_Filter::EQ);
                 break;
             case 'numeric':
                 switch ($data['data']['comparison']) {
                     case 'ne':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::NOT);
                         break;
                     case 'eq':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::EQ);
                         break;
                     case 'lt':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::LT);
                         break;
                     case 'gt':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::GT);
                         break;
                 }
                 break;
             case 'datetime':
                 $value = date('Y-m-d H:i:s', strtotime($value));
                 switch ($data['data']['comparison']) {
                     case 'ne':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::NOT);
                         break;
                     case 'eq':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::EQ);
                         break;
                     case 'lt':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::LT);
                         break;
                     case 'gt':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::GT);
                         break;
                 }
                 break;
             case 'date':
                 $value = date('Y-m-d', strtotime($value));
                 switch ($data['data']['comparison']) {
                     case 'ne':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::NOT);
                         break;
                     case 'eq':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::EQ);
                         break;
                     case 'lt':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::LT);
                         break;
                     case 'gt':
                         $result[] = new Db_Select_Filter($field, $value, Db_Select_Filter::GT);
                         break;
                 }
                 break;
         }
     }
     return $result;
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:93,代码来源:Request.php

示例14: addlocaleventAction

 /**
  * Create local event fore extended object
  */
 public function addlocaleventAction()
 {
     $project = $this->_getProject();
     $event = Filter::filterValue(Filter::FILTER_ALPHANUM, $this->_getEvent());
     $object = $this->_getObject();
     $eventManager = $project->getEventManager();
     if ($eventManager->eventExists($object->getName(), $event) || $object->getConfig()->getEvents()->isValid($event)) {
         Response::jsonError($this->_lang->get('SB_UNIQUE'));
     }
     $eventManager->setEvent($object->getName(), $event, '', '', true);
     $this->_storeProject();
     Response::jsonSuccess();
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:16,代码来源:Events.php

示例15: filter

 /**
  * Property filter
  * @param array $fieldInfo - property config data
  * @param mixed $value
  * @throws Exception
  * @return mixed
  */
 public static function filter($fieldInfo, $value)
 {
     switch (strtolower($fieldInfo['db_type'])) {
         case 'tinyint':
         case 'smallint':
         case 'mediumint':
         case 'int':
         case 'bigint':
             $value = Filter::filterValue('int', $value);
             break;
         case 'float':
         case 'double':
         case 'decimal':
             $value = Filter::filterValue('float', $value);
             break;
         case 'bool':
         case 'boolean':
             $value = Filter::filterValue('boolean', $value);
             break;
         case 'date':
         case 'time':
         case 'timestamp':
         case 'datetime':
             $value = Filter::filterValue('string', $value);
             break;
         case 'tinytext':
         case 'text':
         case 'bit':
         case 'char':
         case 'varchar':
         case 'mediumtext':
         case 'longtext':
         case 'char':
         case 'varchar':
             if (!isset($fieldInfo['allow_html']) || !$fieldInfo['allow_html']) {
                 $value = Filter::filterValue('string', $value);
             }
             break;
             //  case 'bit':
             //		$value = preg_replace ('/[^01]*/', '', $value);
             break;
         default:
             throw new Exception('Invalid property type "' . $fieldInfo['db_type'] . '"');
     }
     return $value;
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:53,代码来源:Property.php


注:本文中的Filter::filterValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。