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


PHP Valid::digit方法代码示例

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


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

示例1: to_user

 /**
  * Send x copies of the registered item to a user.
  *
  * @param integer|Model_User $user
  * @param integer            $amount
  * @param string             $location
  *
  * @throws Item_Exception
  */
 public function to_user($user, $origin = "app", $amount = 1, $location = 'inventory')
 {
     if (!Valid::digit($amount)) {
         throw new Item_Exception('The supplied amount should be a number.');
     }
     if (Valid::digit($user)) {
         $user = ORM::factory('User', $user);
     } elseif (!is_a($user, 'Model_User')) {
         throw new Item_Exception('The supplied user does not come from a model.');
     }
     if (!$user->loaded()) {
         throw new Item_Exception('The supplied user does not exist.');
     } else {
         $user_item = ORM::factory('User_Item')->where('user_id', '=', $user->id)->where('item_id', '=', $this->_item->id)->where('location', '=', $location)->find();
         $action = $amount > 0 ? '+' : '-';
         if ($user_item->loaded()) {
             // update item amount
             $user_item->amount($action, $amount);
         } elseif ($action == '+') {
             $id = $this->_item->id;
             // create new copy
             $user_item = ORM::factory('User_Item')->values(array('user_id' => $user->id, 'item_id' => $id, 'location' => $location, 'amount' => $amount))->save();
         }
         return Journal::log('item.in.' . $origin, 'item', 'Player received :amount :item_name @ :origin', array(':amount' => $amount, ':item_name' => $user_item->item->name($amount, FALSE), ':origin' => str_replace('.', ' ', $origin)));
     }
 }
开发者ID:modulargaming,项目名称:item,代码行数:35,代码来源:Item.php

示例2: validate

 protected function validate($value)
 {
     if (!Valid::digit($value)) {
         return 'digit';
     }
     if (!$this->repo->exists($value)) {
         return 'exists';
     }
 }
开发者ID:tobiasziegler,项目名称:platform,代码行数:9,代码来源:Media.php

示例3: validate_material_amounts

 public static function validate_material_amounts($validation, $materials, $amount_key = 'amount', $name_key = 'name')
 {
     $status = TRUE;
     foreach ($materials as $material) {
         if (!Valid::digit($material[$amount_key])) {
             $status = $false;
             $validation->error('materials', $material[$name_key] . '\'s amount should be a number.');
         }
     }
     return $status;
 }
开发者ID:modulargaming,项目名称:item,代码行数:11,代码来源:Recipe.php

示例4: validate

 protected function validate($value)
 {
     if (!Valid::digit($value)) {
         return 'digit';
     }
     if (!$this->repo->exists($value)) {
         return 'exists';
     }
     $post = $this->repo->get($value);
     if (is_int($this->config['input']['form']) && $post->form_id !== $this->config['input']['form']) {
         return 'invalidForm';
     }
 }
开发者ID:gjorgiev,项目名称:platform,代码行数:13,代码来源:Relation.php

示例5: check_data

 public static function check_data($value, $data)
 {
     switch ($data['type']) {
         case 'static':
             return TRUE;
         case 'module':
             return Valid::not_empty($value) and Valid::alpha_dash($value) and $value != '-';
         case 'page':
             return Valid::not_empty($value) and Valid::digit($value) and $value != '-' and $data['id'] != $value;
         case 'url':
             return Valid::not_empty($value) and Model_Page::check_link($value) and $value != '-';
     }
     return FALSE;
 }
开发者ID:greor,项目名称:satin-spb,代码行数:14,代码来源:page.php

示例6: init

 /**
  * Initialise the plugin and register all events that were defined in $this->_events.
  *
  * @return Kohana_Plugin
  * @throws Kohana_Exception
  */
 public final function init()
 {
     if ($this->_init() == true) {
         if (count($this->_events) > 0) {
             foreach ($this->_events as $id => $event) {
                 $class_event = Valid::digit($id) ? str_replace('.', '_', $event) : $id;
                 Plug::listen($event, array($this, 'on_' . $class_event));
             }
         }
         return $this;
     } else {
         throw new Kohana_Exception('Failed to initialise the ":plugin" plugin', array(':plugin' => $this->info['name']));
     }
 }
开发者ID:vheissu,项目名称:kohana-plugin-system,代码行数:20,代码来源:Plugin.php

示例7: btns_top

 /**
  * Top buttons
  *
  * @param array $links
  *
  * @return string
  */
 public static function btns_top(array $links = [])
 {
     $class = ['class' => 'btn btn-default btn-sm'];
     $html = PHP_EOL;
     foreach ($links as $url => $title) {
         if (!$title) {
             continue;
         }
         $action = explode('/', $url);
         $count = count($action) - 1;
         if (Valid::digit($action[$count])) {
             $action = $action[$count - 1];
         } else {
             $action = end($action);
         }
         switch ($action) {
             case 'add':
                 $html .= HTML::anchor($url, '<i class="fa fa-plus fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 break;
             case 'edit':
                 $html .= HTML::anchor($url, '<i class="fa fa-edit fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 break;
             case 'password':
                 $html .= HTML::anchor($url, '<i class="fa fa-key fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 break;
             case 'profile':
                 $html .= HTML::anchor($url, '<i class="fa fa-user fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 break;
             case 'filter':
                 if (Request::current()->action() == 'filter') {
                     $html .= HTML::anchor($url, '<i class="fa fa-filter fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 }
                 break;
             case 'order':
                 $html .= HTML::anchor($url, '<i class="fa fa-sort fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 break;
             case 'npupdate':
                 $html .= HTML::anchor($url, '<i class="fa fa-refresh fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 break;
             case 'list':
                 if (Request::current()->query('colunm') and Request::current()->query('order')) {
                     $html .= HTML::anchor(Request::detect_uri(), '<i class="fa fa-angle-right fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 } elseif (Request::current()->action() == 'deleted') {
                     $html .= HTML::anchor($url, '<i class="fa fa-list-ul fa-fw"></i> ' . $title, $class) . PHP_EOL;
                 }
                 break;
         }
     }
     return '<div class="btn-group">' . $html . '</div>';
 }
开发者ID:eok8177,项目名称:shopCMS,代码行数:57,代码来源:TB.php

示例8: factory

 public static function factory($object, $config = array(), Request $request = NULL, $query = FALSE)
 {
     $instance = parent::factory($object);
     $instance->set_config();
     $instance->set_config($config);
     $instance->query = $query;
     if ($request === NULL) {
         $request = Request::initial();
     }
     $instance->request = $request;
     $instance->route = $request->route();
     // Assign default route params
     $instance->route_params = array('directory' => $request->directory(), 'controller' => $request->controller(), 'action' => $request->action()) + $request->param();
     // get the current page
     $page = $request->param($instance->config['param']);
     if (!Valid::digit($page)) {
         $page = 1;
     }
     $instance->current_page = (int) $page;
     // limit the pagination results
     $instance->limit(($page - 1) * $instance->config['total_items'], $instance->config['total_items']);
     return $instance;
 }
开发者ID:modulargaming,项目名称:core,代码行数:23,代码来源:Paginate.php

示例9: action_password

 /**
  * Action: Password lost
  */
 public function action_password()
 {
     $this->history = false;
     $email = $message = '';
     // Handle request
     if ($_POST && ($email = trim(Arr::get($_POST, 'email', '')))) {
         $message = new View_Alert(__('We could not find any user or the user is missing email address, sorry.'), __('Uh oh,'));
         // Find the user, accept only strings
         $user = Valid::digit($email) ? false : Model_User::find_user(trim($email));
         // Send email
         if ($user && Valid::email($user->email)) {
             $subject = __('Your new :site password', array(':site' => Kohana::$config->load('site.site_name')));
             $mail = __("Forgot your password, :username?\n\nWe received a request to generate a new password for your :site account, please sign in and change your password. You should also delete this email.\n\nUsername: :username\nPassword: :password", array(':site' => Kohana::$config->load('site.site_name'), ':username' => Text::clean($user->username), ':password' => Visitor::generate_password($user->password)));
             if (Email::send($user->email, Kohana::$config->load('site.email_invitation'), $subject, $mail)) {
                 $message = new View_Alert(__(':email should soon receive the generated password in their inbox.', array(':email' => $email)), __('Mission accomplished!'), View_Alert::SUCCESS);
                 $email = '';
             }
         }
     }
     // Build page
     $this->view = View_Page::factory(__('Misplaced your password?'));
     $this->view->add(View_Page::COLUMN_MAIN, $this->section_password($message, $email));
 }
开发者ID:anqh,项目名称:core,代码行数:26,代码来源:sign.php

示例10: validate

 public function validate($param)
 {
     return Valid::digit($param) and $param > 0;
 }
开发者ID:modulargaming,项目名称:item,代码行数:4,代码来源:Play.php

示例11: validate

 protected function validate($value)
 {
     if (!Valid::digit($value)) {
         return 'digit';
     }
 }
开发者ID:gjorgiev,项目名称:platform,代码行数:6,代码来源:Int.php

示例12: requestData

 /**
  * @param null|string|array $key
  * @param null              $default
  * @param null              $delimiter
  *
  * @return array|mixed
  */
 protected function requestData($key = NULL, $default = NULL, $delimiter = NULL)
 {
     if (NULL === $this->_requestData) {
         $this->_requestData = Helpers_Arr::merge($this->request->query(), $this->request->post(), $this->_parse_request_body());
     }
     if (Kohana_Arr::is_array($key)) {
         $result = [];
         foreach ($key as $idx => $value) {
             if (!Valid::digit($idx)) {
                 $_key = $idx;
                 $_default = $value;
             } else {
                 $_key = $value;
                 $_default = $default;
             }
             $result[$_key] = Kohana_Arr::path($this->requestData(), $_key, $_default, $delimiter);
         }
     } else {
         $result = NULL === $key ? $this->_requestData : Kohana_Arr::path($this->requestData(), $key, $default, $delimiter);
     }
     return $result;
 }
开发者ID:vspvt,项目名称:kohana-restfulapi,代码行数:29,代码来源:RestfulAPI.php

示例13: isset

<?php

include Kohana::find_file('views', 'errors/partial');
if (isset($oaclient->id) and Valid::digit($oaclient->id)) {
    $parms = array('id' => $oaclient->id, 'action' => 'edit');
    $btntxt = __("Save Changes");
} else {
    $parms = array('action' => 'register');
    $btntxt = __("Register");
}
echo Form::open(Route::get('oauth2/client')->uri($parms), array('class' => 'form form-horizontal', 'enctype' => 'multipart/form-data'));
?>
	<div class="row-fluid">
		<div class="form-group <?php 
echo isset($errors['title']) ? 'error' : '';
?>
">
			<?php 
echo Form::label('title', __('Title'), array('class' => 'control-label1'));
?>
			<div class="controls ">
				<?php 
echo Form::input('title', $oaclient->title, array('class' => 'col-sm-5'));
?>
			</div>
		</div>
		
		<div class="form-group <?php 
echo isset($errors['redirect_uri']) ? 'error' : '';
?>
">
开发者ID:MenZil-Team,项目名称:cms,代码行数:31,代码来源:form.php

示例14: action_consume

 public function action_consume()
 {
     $item = ORM::factory('User_Item', $this->request->param('id'));
     $action = $this->request->post('action');
     $errors = array();
     if (!$item->loaded()) {
         Hint::error('You can\'t use an item that does not exist');
     } elseif ($item->user_id != $this->user->id) {
         Hint::error('You can\'t access another player\'s item');
     } elseif ($item->location != 'inventory') {
         Hint::error('The item you want to view is not located in your inventory');
     } elseif ($action == NULL) {
         Hint::error('No action to perform has been specified');
     } else {
         $def_cmd = Item_Command::factory($item->item->type->default_command);
         if (Valid::digit($action)) {
             // we'll want to perform an action on a pet
             $pet = ORM::factory('User_Pet', $action);
             if (!$pet->loaded()) {
                 Hint::error('No existing pet has been specified');
             } elseif ($pet->user_id != $this->user->id) {
                 Hint::error('You can\'t let a pet comsume this item if it\'s not yours');
             } elseif ($def_cmd->pets_required() == FALSE) {
                 Hint::error('can\'t perform this item action on a pet');
             } else {
                 $commands = $item->item->commands;
                 $results = array();
                 $db = Database::instance();
                 $db->begin();
                 $error = FALSE;
                 foreach ($commands as $command) {
                     $cmd = Item_Command::factory($command['name']);
                     $res = $cmd->perform($item, $command['param'], $pet);
                     if ($res == FALSE) {
                         // the command couldn't be performed, spit out error, rollback changes and break the loop
                         Hint::error(__(':item_name could not be used on :pet_name', array(':item_name' => $item->item->name, ':pet_name' => $pet->name)));
                         $error = TRUE;
                         $db->rollback();
                         break;
                     } else {
                         $results[] = $res;
                     }
                 }
                 if ($error == FALSE) {
                     $log = Journal::log('consume', 'item', ':item_name consumed', array(':item_name' => $item->item->name));
                     $log->notify('consume' . $item->item_id, 'item', ':item_name consumed');
                     if ($def_cmd->delete_after_consume == TRUE) {
                         $item->amount('-', 1);
                     }
                     $db->commit();
                 }
             }
         } else {
             $results = array();
             switch ($action) {
                 case 'consume':
                     $commands = $item->item->commands;
                     $results = array();
                     $db = Database::instance();
                     $db->begin();
                     $error = FALSE;
                     foreach ($commands as $command) {
                         $cmd = Item_Command::factory($command['name']);
                         $res = $cmd->perform($item, $command['param']);
                         if ($res == FALSE) {
                             // the command couldn't be performed, spit out error, rollback changes and break the loop
                             Hint::error(__(':item_name could not be used', array(':item_name' => $item->name)));
                             $db->rollback();
                             $error = TRUE;
                             break;
                         } else {
                             $results[] = $res;
                         }
                     }
                     if ($error = FALSE) {
                         Journal::log('consume' . $item->item_id, 'item', ':item_name consumed', array(':item_name' => $item->item->name));
                         if ($def_cmd->delete_after_consume == TRUE) {
                             $item->amount('-', 1);
                         }
                         $db->commit();
                     }
                     break;
                 case 'remove':
                     // takes an amount
                     $amount = $this->request->post('amount');
                     if ($amount == NULL) {
                         $amount = 1;
                     }
                     if (!Valid::digit($amount)) {
                         Hint::error('The amount you submitted isn\'t a number.');
                     } elseif ($amount <= 0 or $amount > $item->amount) {
                         Hint::error('You only have ' . $item->name() . ', not ' . $amount);
                     } else {
                         if ($amount > 1) {
                             $name = Inflector::plural($item->name(), $amount);
                             $verb = 'were';
                         } else {
                             $name = $item->item->name(1);
                             $verb = 'was';
                         }
//.........这里部分代码省略.........
开发者ID:modulargaming,项目名称:item,代码行数:101,代码来源:Inventory.php

示例15: isset

<?php

if (isset($widget->id) and Valid::digit($widget->id)) {
    $parms = array('id' => $widget->id, 'action' => 'edit');
    $split_name = explode('/', $widget->name);
    $static = ($split_name and $split_name[0] == 'static') ? TRUE : FALSE;
} else {
    $parms = array('action' => 'add');
    $static = TRUE;
}
echo Form::open(Route::get('admin/widget')->uri($parms), array('id' => 'widget-form', 'class' => 'form'));
?>

	<?php 
include Kohana::find_file('views', 'errors/partial');
?>

	<div class="row">
		<div class="col-md-6">

			<div class="form-group <?php 
echo isset($errors['title']) ? 'has-error' : '';
?>
">
				<?php 
echo Form::label('title', __('Title'), array('class' => 'control-label'));
?>
				<?php 
echo Form::input('title', $widget->title, array('class' => 'form-control'));
?>
			</div>
开发者ID:MenZil-Team,项目名称:cms,代码行数:31,代码来源:form.php


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