Improvements to field views and minor updates

This commit is contained in:
Deon George 2016-08-25 23:24:44 +10:00
parent 2b48dde8f7
commit 68d96ca85f
14 changed files with 86 additions and 47 deletions

4
classes/Arr.php Normal file
View File

@ -0,0 +1,4 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
class Arr extends lnApp_Arr {}
?>

20
classes/lnApp/Arr.php Normal file
View File

@ -0,0 +1,20 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends Kohana's Arr
*
* @package lnApp
* @category Modifications
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class lnApp_Arr extends Kohana_Arr {
/**
* Convert an array into a string with key=value
*/
public static function convert(array $array) {
return implode(' ',array_map(function ($v, $k) { return sprintf('%s="%s"', $k, $v); },$array,array_keys($array)));
}
}
?>

View File

@ -13,8 +13,8 @@ abstract class lnApp_Controller_User_Account extends Controller_Account {
protected $auth_required = TRUE; protected $auth_required = TRUE;
protected $secure_actions = array( protected $secure_actions = array(
'edit'=>0, 'edit'=>TRUE,
'resetpassword'=>0, 'resetpassword'=>TRUE,
); );
/** /**
@ -58,10 +58,9 @@ abstract class lnApp_Controller_User_Account extends Controller_Account {
// Log the password reset // Log the password reset
$this->ao->log('Password reset'); $this->ao->log('Password reset');
}
HTTP::redirect('login'); HTTP::redirect('login');
} }
}
Block::factory() Block::factory()
->title(sprintf('Password Reset: %s',$this->ao->refnum())) ->title(sprintf('Password Reset: %s',$this->ao->refnum()))

View File

@ -54,7 +54,7 @@ abstract class lnApp_SystemMessage extends HTMLRender {
$output = ''; $output = '';
$output .= sprintf('<div class="alert %s">',empty($record['type']) ? '' : 'alert-'.$record['type']); $output .= sprintf('<div class="alert %s">',empty($record['type']) ? '' : 'alert-'.($record['type'] == 'error' ? 'danger' : $record['type']));
$output .= '<button type="button" class="close" data-dismiss="alert">&times;</button>'; $output .= '<button type="button" class="close" data-dismiss="alert">&times;</button>';
switch ($record['type']) { switch ($record['type']) {
case 'error': case 'error':

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,14 @@
<fieldset> <div class="col-md-12">
<div class="row">
<fieldset class="col-md-5">
<legend>Reset Password</legend> <legend>Reset Password</legend>
<?php echo Form::input('password','',array('label'=>'Password','divclass'=>'col-md-3','placeholder'=>'Login Password','type'=>'password','required','id'=>'password','data-minlength'=>8)); ?> <?php
<?php echo Form::input('password_confirm','',array('label'=>'Confirm','divclass'=>'col-md-3','placeholder'=>'Confirm Password','type'=>'password','required','data-match'=>'#password','data-match-error'=>'Whoops, these don\'t match!')); ?> echo View::factory('field/password')->set('data',['field'=>'password','value'=>'','text'=>'Password','class'=>'col-md-9','classlabelnum'=>'3','attr'=>['required'=>'required','data-minlength'=>8]]);
</fieldset> echo View::factory('field/password')->set('data',['field'=>'password_confirm','value'=>'','text'=>'Confirm ','class'=>'col-md-9','classlabelnum'=>'3','attr'=>['required'=>'required','data-match'=>'#password_label','data-match-error'=>'They dont match!']]);
?>
<div class="row"> </fieldset>
<div class="col-md-offset-1">
<button type="submit" class="btn btn-primary">Save changes</button>
</div> </div>
<?php echo View::factory('field/submit'); ?>
</div> </div>

View File

@ -4,12 +4,13 @@
<!-- name = account name --> <!-- name = account name -->
<!-- ajaxurl = ajax URL --> <!-- ajaxurl = ajax URL -->
<div class="form-group"> <div class="form-group">
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label> <label for="<?php echo Arr::get($data,'field'); ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<div class="input-group col-md-4"> <div class="input-group <?php echo Arr::get($data,'class','col-md-5'); ?>">
<input type="text" id="<?php echo $data['field']; ?>_label" value="<?php echo $data['name']; ?>" class="form-control" autocomplete="off" placeholder="<?php echo $data['text']; ?>"> <input type="text" id="<?php echo Arr::get($data,'field'); ?>_label" value="<?php echo Arr::get($data,'name'); ?>" class="form-control" placeholder="<?php echo Arr::get($data,'text'); ?>" autocomplete="off" <?php echo Arr::convert(Arr::get($data,'attr',[])); ?>>
<span class="input-group-addon"><i class="fa fa-refresh" name="account_lookup"></i></span> <span class="input-group-addon"><i class="fa fa-refresh" name="account_lookup"></i></span>
</div> </div>
<input type="hidden" name="<?php echo $data['field']; ?>" value="<?php echo $data['value']; ?>"> <span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
<input type="hidden" name="<?php echo Arr::get($data,'field'); ?>" value="<?php echo Arr::get($data,'value'); ?>">
</div> </div>
<?php <?php
@ -20,7 +21,7 @@ $(document).ready(function() {
$("input[id=account_id_label]").typeahead({ $("input[id=account_id_label]").typeahead({
minLength: 2, minLength: 2,
source: function (query,process) { source: function (query,process) {
search("'.$data['ajaxurl'].'",query,process,"account_lookup"); search("'.Arr::get($data,'ajaxurl').'",query,process,"account_lookup");
}, },
matcher: function () { return true; }, matcher: function () { return true; },

View File

@ -3,12 +3,13 @@
<!-- value = value --> <!-- value = value -->
<!-- enddate = js value --> <!-- enddate = js value -->
<div class="form-group"> <div class="form-group">
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label> <label for="<?php echo Arr::get($data,'field'); ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<div class="input-group col-md-2"> <div class="input-group <?php echo Arr::get($data,'class','col-md-2'); ?>">
<input type="text" id="<?php echo $data['field']; ?>_label" value="<?php echo Site::date($data['value']); ?>" class="form-control" placeholder="<?php echo $data['text']; ?>"> <input type="text" id="<?php echo Arr::get($data,'field'); ?>_label" value="<?php echo Site::date(Arr::get($data,'value',time())); ?>" class="form-control" placeholder="<?php echo Arr::get($data,'text'); ?>" <?php echo Arr::convert(Arr::get($data,'attr',[])); ?>>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div> </div>
<input type="hidden" name="<?php echo $data['field']; ?>" value="<?php echo $data['value']; ?>"> <span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
<input type="hidden" name="<?php echo Arr::get($data,'field'); ?>" value="<?php echo Arr::get($data,'value'); ?>">
</div> </div>
<?php <?php

View File

@ -1,10 +1,11 @@
<!-- field = field_name --> <!-- field = field name -->
<!-- text = field_text --> <!-- text = field text -->
<!-- value = value --> <!-- value = value -->
<div class="form-group"> <div class="form-group">
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label> <label for="<?php echo Arr::get($data,'field'); ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<div class="input-group col-md-2"> <div class="input-group <?php echo Arr::get($data,'class','col-md-2'); ?>">
<div class="input-group-addon"><i class="fa fa-dollar"></i></div> <div class="input-group-addon"><i class="fa fa-dollar"></i></div>
<input type="text" id="<?php echo $data['field']; ?>_label" name="<?php echo $data['field']; ?>" value="<?php echo $data['value']; ?>" class="form-control" placeholder="<?php echo $data['text']; ?>"> <input type="text" id="<?php echo Arr::get($data,'field'); ?>_label" name="<?php echo Arr::get($data,'field'); ?>" value="<?php echo Arr::get($data,'value'); ?>" class="form-control" placeholder="<?php echo Arr::get($data,'text'); ?>" autocomplete="off" <?php echo Arr::convert(Arr::get($data,'attr',[])); ?>>
</div> </div>
<span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
</div> </div>

View File

@ -1,10 +1,11 @@
<!-- field = field_name --> <!-- field = field name -->
<!-- text = field_text --> <!-- text = field text -->
<!-- value = value --> <!-- value = value -->
<div class="form-group"> <div class="form-group">
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label> <label for="<?php echo Arr::get($data,'field'); ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<div class="input-group col-md-2"> <div class="input-group <?php echo Arr::get($data,'class','col-md-2'); ?>">
<div class="input-group-addon"><i class="fa fa-sliders"></i></div> <div class="input-group-addon"><i class="fa fa-sliders"></i></div>
<input type="text" id="<?php echo $data['field']; ?>_label" name="<?php echo $data['field']; ?>" value="<?php echo $data['value']; ?>" class="form-control" placeholder="<?php echo $data['text']; ?>"> <input type="text" id="<?php echo Arr::get($data,'field'); ?>_label" name="<?php echo Arr::get($data,'field'); ?>" value="<?php echo Arr::get($data,'value'); ?>" class="form-control" placeholder="<?php echo Arr::get($data,'text'); ?>" autocomplete="off" <?php echo Arr::convert(Arr::get($data,'attr',[])); ?>>
</div> </div>
<span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
</div> </div>

10
views/field/password.php Normal file
View File

@ -0,0 +1,10 @@
<!-- field = field name -->
<!-- text = field text -->
<!-- value = value -->
<div class="form-group">
<label for="<?php echo Arr::get($data,'field'); ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<div class="<?php echo Arr::get($data,'class','col-md-9'); ?>">
<input type="password" id="<?php echo Arr::get($data,'field'); ?>_label" name="<?php echo Arr::get($data,'field'); ?>" value="<?php echo Arr::get($data,'value'); ?>" class="form-control" placeholder="<?php echo Arr::get($data,'text'); ?>" <?php echo Arr::convert(Arr::get($data,'attr',[])); ?>>
</div>
<span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
</div>

View File

@ -2,10 +2,10 @@
<!-- text = field text --> <!-- text = field text -->
<!-- value = array of values --> <!-- value = array of values -->
<!-- default = value --> <!-- default = value -->
<!-- class = col-md class -->
<div class="form-group"> <div class="form-group">
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label> <label for="<?php echo Arr::get($data,'field'); ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<div class="input-group <?php echo $data['class']; ?>"> <div class="input-group <?php echo Arr::get($data,'class','col-md-2'); ?>">
<?php echo Form::select($data['field'],$data['value'],$data['default'],array('class'=>'form-control','placeholder'=>$data['text'])); ?> <?php echo Form::select($data['field'],$data['value'],$data['default'],array('class'=>'form-control','placeholder'=>$data['text'])); ?>
</div> </div>
<span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
</div> </div>

View File

@ -1,9 +1,10 @@
<!-- field = field_name --> <!-- field = field name -->
<!-- text = field_text --> <!-- text = field text -->
<!-- value = value --> <!-- value = value -->
<div class="form-group"> <div class="form-group">
<label for="cert" class="col-md-2 control-label"><?php echo $data['text']; ?></label> <label for="<?php echo Arr::get($data,'field'); ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<div class="<?php echo $data['class']; ?>" style="padding-left: 0px"> <div class="<?php echo Arr::get($data,'class','col-md-6'); ?>" style="padding-left: 0px">
<input type="text" class="form-control" id="cert" name="<?php echo $data['field']; ?>" placeholder="<?php echo $data['text']; ?>" value="<?php echo $data['value']; ?>" > <input type="text" id="<?php echo Arr::get($data,'field'); ?>_label" name="<?php echo Arr::get($data,'field'); ?>" value="<?php echo Arr::get($data,'value'); ?>" class="form-control" placeholder="<?php echo Arr::get($data,'text'); ?>" autocomplete="off" <?php echo Arr::convert(Arr::get($data,'attr',[])); ?>>
</div> </div>
<span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
</div> </div>

View File

@ -1,7 +1,8 @@
<!-- field = field_name --> <!-- field = field name -->
<!-- text = field_text --> <!-- text = field text -->
<!-- value = value --> <!-- value = value -->
<div class="form-group" style="margin-left: 0px"> <div class="form-group" style="margin-left: 0px">
<label for="cert"><?php echo $data['text']; ?></label> <label for="<?php echo Arr::get($data,'field'); ?>_label" class="col-md-<?php echo Arr::get($data,'classlabelnum',2); ?> control-label"><?php echo Arr::get($data,'text'); ?></label>
<textarea class="form-control" id="cert" name="<?php echo $data['field']; ?>" placeholder="<?php echo $data['text']; ?>" style="font-family: monospace; width: auto; resize: none;" rows="<?php echo Form::textarea_rows($data['value']); ?>" cols="<?php echo Form::textarea_cols($data['value'],78); ?>"><?php echo $data['value']; ?></textarea> <textarea id="<?php echo Arr::get($data,'field'); ?>_label" name="<?php echo Arr::get($data,'field'); ?>" class="form-control" placeholder="<?php echo Arr::get($data,'text'); ?>" style="font-family: monospace; width: auto; resize: none;" rows="<?php echo Form::textarea_rows(Arr::get($data,'value')); ?>" cols="<?php echo Form::textarea_cols(Arr::get($data,'value'),78); ?>" <?php echo Arr::convert(Arr::get($data,'attr',[])); ?>><?php echo Arr::get($data,'value'); ?></textarea>
<span class="col-md-offset-<?php echo Arr::get($data,'classlabelnum',2); ?> help-block with-errors"></span>
</div> </div>