Added standard fields, login/reset display improvements
This commit is contained in:
parent
a7616960f0
commit
2b48dde8f7
@ -13,6 +13,8 @@
|
|||||||
abstract class lnApp_Controller_Login extends Controller_TemplateDefault {
|
abstract class lnApp_Controller_Login extends Controller_TemplateDefault {
|
||||||
protected $auth_required = FALSE;
|
protected $auth_required = FALSE;
|
||||||
|
|
||||||
|
protected $login_attribute = 'email';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activate an account so that it can login and use the site
|
* Activate an account so that it can login and use the site
|
||||||
*/
|
*/
|
||||||
@ -208,12 +210,12 @@ abstract class lnApp_Controller_Login extends Controller_TemplateDefault {
|
|||||||
*/
|
*/
|
||||||
public function action_reset() {
|
public function action_reset() {
|
||||||
// Minutes to keep our token
|
// Minutes to keep our token
|
||||||
$token_expire = 15*60;
|
$token_expire = 15;
|
||||||
|
|
||||||
// If the user posted their details to reset their password
|
// If the user posted their details to reset their password
|
||||||
if ($this->request->post()) {
|
if ($this->request->post()) {
|
||||||
// If the username is correct, create a method token
|
// If the username is correct, create a method token
|
||||||
if ($ao=ORM::factory('Account',array('email'=>$this->request->post('username'))) AND $ao->loaded()) {
|
if ($this->request->post('username') AND ($ao=ORM::factory('Account',array($this->login_attribute=>$this->request->post('username')))) AND $ao->loaded()) {
|
||||||
$token = $ao->token($token_expire,'account','user:resetpassword',2);
|
$token = $ao->token($token_expire,'account','user:resetpassword',2);
|
||||||
|
|
||||||
if ($token) {
|
if ($token) {
|
||||||
|
@ -226,6 +226,9 @@ abstract class lnApp_Email extends Kohana_Email {
|
|||||||
* Get email details
|
* Get email details
|
||||||
*/
|
*/
|
||||||
private function email($key) {
|
private function email($key) {
|
||||||
|
if (! isset($this->_email[$key]))
|
||||||
|
return array();
|
||||||
|
|
||||||
if (is_array($this->_email[$key]) AND isset($this->_email[$key]['email']))
|
if (is_array($this->_email[$key]) AND isset($this->_email[$key]['email']))
|
||||||
return $this->_email[$key]['email'];
|
return $this->_email[$key]['email'];
|
||||||
else
|
else
|
||||||
|
@ -10,183 +10,17 @@
|
|||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
abstract class lnApp_Form extends Kohana_Form {
|
abstract class lnApp_Form extends Kohana_Form {
|
||||||
/**
|
|
||||||
* Render our control group form attributes
|
|
||||||
*
|
|
||||||
* @return array((string) control group wrapper,(array) attributes to exclude
|
|
||||||
*/
|
|
||||||
private static function _controlgroup($name,array &$attributes=NULL) {
|
|
||||||
// Bypass this rendering if nocg is set.
|
|
||||||
if (isset($attributes['nocg'])) {
|
|
||||||
unset($attributes['nocg']);
|
|
||||||
return '%s';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! isset($attributes['class']))
|
|
||||||
$attributes['class'] = 'form-control';
|
|
||||||
|
|
||||||
$output = '';
|
|
||||||
|
|
||||||
$output .= '<div class="input-group">';
|
|
||||||
|
|
||||||
// Only need col-md for horizonal forms?
|
|
||||||
if (isset($attributes['label'])) {
|
|
||||||
$output .= Form::label($name,$attributes['label'],array('class'=>'control-label'));
|
|
||||||
unset($attributes['label']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($attributes['help-block'])) {
|
|
||||||
$help = $attributes['help-block'];
|
|
||||||
unset($attributes['help-block']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($attributes['add-on'])) {
|
|
||||||
$addon = $attributes['add-on'];
|
|
||||||
unset($attributes['add-on']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$classdiv = FALSE;
|
|
||||||
if (isset($attributes['divclass'])) {
|
|
||||||
$output .= sprintf('<div class="%s">',$attributes['divclass']);
|
|
||||||
unset($attributes['divclass']);
|
|
||||||
$classdiv = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output .= '%s';
|
|
||||||
|
|
||||||
if (in_array('required',$attributes))
|
|
||||||
$output .= '<div class="help-block with-errors"></div>';
|
|
||||||
|
|
||||||
if ($classdiv)
|
|
||||||
$output .= '</div>';
|
|
||||||
|
|
||||||
if (isset($help))
|
|
||||||
$output .= sprintf('<span class="help-block">%s</span>',$help);
|
|
||||||
|
|
||||||
if (isset($addon))
|
|
||||||
$output .= sprintf('<span class="input-group-addon">%s</span>',$addon);
|
|
||||||
|
|
||||||
$output .= '</div>';
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function button($name,$body,array $attributes=NULL) {
|
|
||||||
return sprintf(self::_controlgroup($name,$attributes),parent::button($name,$body,$attributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrap our Form() functions with boostrap HTML
|
|
||||||
*
|
|
||||||
* @usedby Form::hidden
|
|
||||||
* @usedby Form::password
|
|
||||||
* @usedby Form::file
|
|
||||||
* @usedby Form::checkbox
|
|
||||||
* @usedby Form::radio
|
|
||||||
* @usedby Form::submit
|
|
||||||
* @usedby Form::image
|
|
||||||
*/
|
|
||||||
public static function input($name,$value=NULL,array $attributes=NULL) {
|
|
||||||
return (isset($attributes['type']) AND $attributes['type'] == 'hidden') ? parent::input($name,$value,$attributes) : sprintf(self::_controlgroup($name,$attributes),parent::input($name,$value,$attributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function select($name,array $options=NULL,$selected=NULL,array $attributes=NULL) {
|
|
||||||
// If only 1 record, dont show select, but a hidden attribute and a displayed value.
|
|
||||||
if (isset($attributes['oneonly']) AND $attributes['oneonly']) {
|
|
||||||
$attributes['disabled'] = 'disabled';
|
|
||||||
unset($attributes['oneonly']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($attributes['sort']) AND $attributes['sort']) {
|
|
||||||
asort($options);
|
|
||||||
unset($attributes['sort']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf(self::_controlgroup($name,$attributes),parent::select($name,$options,$selected,$attributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function textarea($name,$body='',array $attributes=NULL,$double_encode=TRUE) {
|
|
||||||
if (! isset($attributes['id']))
|
|
||||||
$attributes['id'] = preg_replace('/[\[\]]/','_',$name);
|
|
||||||
|
|
||||||
if (isset($attributes['editor'])) {
|
|
||||||
switch ($attributes['editor']) {
|
|
||||||
case 'tinymce':
|
|
||||||
Script::factory()
|
|
||||||
->type('file')
|
|
||||||
->data('media/vendor/tinymce/js/tinymce/jquery.tinymce.min.js');
|
|
||||||
|
|
||||||
Script::factory()
|
|
||||||
->type('stdin')
|
|
||||||
->data('$("#'.$attributes['id'].'").tinymce({
|
|
||||||
script_url : "'.URL::site('media/vendor/tinymce/js/tinymce/tinymce.min.js').'",
|
|
||||||
theme : "modern",
|
|
||||||
plugins: [ "code","link","image","preview","table" ],
|
|
||||||
menubar: "",
|
|
||||||
toolbar: "undo redo | styleselect | bold italic | link image | table | preview | code",
|
|
||||||
});');
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'wysihtml5':
|
|
||||||
Style::factory()
|
|
||||||
->type('file')
|
|
||||||
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.css');
|
|
||||||
|
|
||||||
Script::factory()
|
|
||||||
->type('file')
|
|
||||||
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/libs/js/wysihtml5-0.3.0_rc2.min.js');
|
|
||||||
|
|
||||||
Script::factory()
|
|
||||||
->type('file')
|
|
||||||
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.min.js');
|
|
||||||
|
|
||||||
Script::factory()
|
|
||||||
->type('stdin')
|
|
||||||
->data('$("#'.$attributes['id'].'").wysihtml5({
|
|
||||||
html: true,
|
|
||||||
parserRules: {
|
|
||||||
tags: {
|
|
||||||
p: {},
|
|
||||||
strong: {},
|
|
||||||
table: {},
|
|
||||||
tbody: {},
|
|
||||||
thead: {},
|
|
||||||
tr: {},
|
|
||||||
td: {
|
|
||||||
check_attributes: {
|
|
||||||
colspan: "numbers",
|
|
||||||
rowspan: "numbers",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});');
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Kohana_Exception('Unknown editor :editor for textarea',array(':editor'=>$attributes['editor']));
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($attributes['edit']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf(self::_controlgroup($name,$attributes),parent::textarea($name,$body,$attributes,$double_encode));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function textarea_rows($textarea,$min=10,$char="\n") {
|
public static function textarea_rows($textarea,$min=10,$char="\n") {
|
||||||
return ($x=count(explode($char,$textarea))) < $min ? $min : $x;
|
return ($x=count(explode($char,$textarea))) < $min ? $min : $x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function textarea_width($textarea,$min=76,$char="\n") {
|
public static function textarea_cols($textarea,$min=60,$char="\n") {
|
||||||
$x = $min;
|
$x = $min;
|
||||||
foreach (explode($char,$textarea) as $string)
|
foreach (explode($char,$textarea) as $string)
|
||||||
{
|
|
||||||
if (strlen($string) > $x)
|
if (strlen($string) > $x)
|
||||||
$x = strlen($string);
|
$x = strlen($string);
|
||||||
}
|
|
||||||
|
|
||||||
return $x;
|
return $x+2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -16,7 +16,7 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var c=0;
|
var c=0;
|
||||||
var search = _.debounce(function(url,query,process){
|
var search = _.debounce(function(url,query,process,icon){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : site_url+url,
|
url : site_url+url,
|
||||||
type : 'GET',
|
type : 'GET',
|
||||||
@ -25,8 +25,12 @@ var search = _.debounce(function(url,query,process){
|
|||||||
async : true,
|
async : true,
|
||||||
cache : false,
|
cache : false,
|
||||||
beforeSend : function() {
|
beforeSend : function() {
|
||||||
if (c++ == 0)
|
if (c++ == 0) {
|
||||||
|
if (icon)
|
||||||
|
$('i[name='+icon+']').addClass("fa-spin");
|
||||||
|
else
|
||||||
$('i[name=searching]').removeClass("hidden");
|
$('i[name=searching]').removeClass("hidden");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
success : function(data) {
|
success : function(data) {
|
||||||
// if json is null, means no match, won't do again.
|
// if json is null, means no match, won't do again.
|
||||||
@ -46,8 +50,12 @@ var search = _.debounce(function(url,query,process){
|
|||||||
process(userLabels);
|
process(userLabels);
|
||||||
},
|
},
|
||||||
complete : function() {
|
complete : function() {
|
||||||
if (--c == 0)
|
if (--c == 0) {
|
||||||
|
if (icon)
|
||||||
|
$('i[name='+icon+']').removeClass("fa-spin");
|
||||||
|
else
|
||||||
$('i[name=searching]').addClass("hidden");
|
$('i[name=searching]').addClass("hidden");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}, 500);
|
}, 500);
|
||||||
|
@ -82,11 +82,6 @@ table .text-right {
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
.form-group [class*=" fa-spin"] {
|
|
||||||
margin-left: -35px;
|
|
||||||
position: relative;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar .navbar-form .navbar-search-addon [class*=" fa-spin"] {
|
.navbar .navbar-form .navbar-search-addon [class*=" fa-spin"] {
|
||||||
padding: 10px 10px;
|
padding: 10px 10px;
|
||||||
@ -102,7 +97,15 @@ table .text-right {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.form-group {
|
.form-group {
|
||||||
margin-bottom: 25px;
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-horizontal .form-group {
|
||||||
|
margin-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group .input-group .input-group-addon {
|
||||||
|
width: 38px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.typeahead.dropdown-menu {
|
ul.typeahead.dropdown-menu {
|
||||||
|
35
views/field/account.php
Normal file
35
views/field/account.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<!-- field = field name -->
|
||||||
|
<!-- text = field text -->
|
||||||
|
<!-- value = array of values -->
|
||||||
|
<!-- name = account name -->
|
||||||
|
<!-- ajaxurl = ajax URL -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label>
|
||||||
|
<div class="input-group col-md-4">
|
||||||
|
<input type="text" id="<?php echo $data['field']; ?>_label" value="<?php echo $data['name']; ?>" class="form-control" autocomplete="off" placeholder="<?php echo $data['text']; ?>">
|
||||||
|
<span class="input-group-addon"><i class="fa fa-refresh" name="account_lookup"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="<?php echo $data['field']; ?>" value="<?php echo $data['value']; ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
Script::factory()
|
||||||
|
->type('stdin')
|
||||||
|
->data('
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("input[id=account_id_label]").typeahead({
|
||||||
|
minLength: 2,
|
||||||
|
source: function (query,process) {
|
||||||
|
search("'.$data['ajaxurl'].'",query,process,"account_lookup");
|
||||||
|
},
|
||||||
|
|
||||||
|
matcher: function () { return true; },
|
||||||
|
|
||||||
|
updater: function (item) {
|
||||||
|
$("input[name=account_id]").val(users[item]).trigger("change");
|
||||||
|
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});');
|
||||||
|
?>
|
37
views/field/date.php
Normal file
37
views/field/date.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<!-- field = field_name -->
|
||||||
|
<!-- text = field_text -->
|
||||||
|
<!-- value = value -->
|
||||||
|
<!-- enddate = js value -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label>
|
||||||
|
<div class="input-group 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']; ?>">
|
||||||
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="<?php echo $data['field']; ?>" value="<?php echo $data['value']; ?>">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
Script::factory()
|
||||||
|
->type('file')
|
||||||
|
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
|
||||||
|
|
||||||
|
Style::factory()
|
||||||
|
->type('file')
|
||||||
|
->data('media/theme/bootstrap/css/bootstrap.datepicker.css');
|
||||||
|
|
||||||
|
Script::factory()
|
||||||
|
->type('stdin')
|
||||||
|
->data('
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#'.$data['field'].'_label").datepicker({
|
||||||
|
autoclose : true,
|
||||||
|
'.($data['enddate'] ? 'endDate : '.$data['enddate'].',' : '').'
|
||||||
|
todayHighlight: true,
|
||||||
|
format : "dd-M-yyyy",
|
||||||
|
todayBtn : true,
|
||||||
|
}).on("hide",function(ev) {
|
||||||
|
$("input[name='.$data['field'].']").val(ev.date.valueOf()/1000);
|
||||||
|
});
|
||||||
|
});');
|
||||||
|
?>
|
10
views/field/money.php
Normal file
10
views/field/money.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!-- field = field_name -->
|
||||||
|
<!-- text = field_text -->
|
||||||
|
<!-- value = value -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label>
|
||||||
|
<div class="input-group col-md-2">
|
||||||
|
<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']; ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
10
views/field/number.php
Normal file
10
views/field/number.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!-- field = field_name -->
|
||||||
|
<!-- text = field_text -->
|
||||||
|
<!-- value = value -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label>
|
||||||
|
<div class="input-group col-md-2">
|
||||||
|
<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']; ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
11
views/field/select.php
Normal file
11
views/field/select.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!-- field = field name -->
|
||||||
|
<!-- text = field text -->
|
||||||
|
<!-- value = array of values -->
|
||||||
|
<!-- default = value -->
|
||||||
|
<!-- class = col-md class -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="<?php echo $data['field']; ?>_label" class="col-md-2 control-label"><?php echo $data['text']; ?></label>
|
||||||
|
<div class="input-group <?php echo $data['class']; ?>">
|
||||||
|
<?php echo Form::select($data['field'],$data['value'],$data['default'],array('class'=>'form-control','placeholder'=>$data['text'])); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
4
views/field/submit.php
Normal file
4
views/field/submit.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<div class="row">
|
||||||
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||||
|
<button type="button" class="btn">Cancel</button>
|
||||||
|
</div>
|
9
views/field/text.php
Normal file
9
views/field/text.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<!-- field = field_name -->
|
||||||
|
<!-- text = field_text -->
|
||||||
|
<!-- value = value -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="cert" class="col-md-2 control-label"><?php echo $data['text']; ?></label>
|
||||||
|
<div class="<?php echo $data['class']; ?>" 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']; ?>" >
|
||||||
|
</div>
|
||||||
|
</div>
|
7
views/field/textarea.php
Normal file
7
views/field/textarea.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<!-- field = field_name -->
|
||||||
|
<!-- text = field_text -->
|
||||||
|
<!-- value = value -->
|
||||||
|
<div class="form-group" style="margin-left: 0px">
|
||||||
|
<label for="cert"><?php echo $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>
|
||||||
|
</div>
|
@ -14,7 +14,7 @@
|
|||||||
<p>To start this process, please enter your Username. If you dont know your Username, please contact us.</p>
|
<p>To start this process, please enter your Username. If you dont know your Username, please contact us.</p>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
|
<span class="input-group-addon"><i class="fa fa-user"></i></span>
|
||||||
<input type="text" id="username" name="username" value="" placeholder="Username" class="form-control" required />
|
<input type="text" id="username" name="username" value="" placeholder="Username" class="form-control" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user