| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_App_Html_View_User_Pref |
| 4 |
{ |
| 5 |
protected $ui = NULL; |
| 6 |
protected $settings = NULL; |
| 7 |
|
| 8 |
public function __construct( |
| 9 |
HC3_Hooks $hooks, |
| 10 |
|
| 11 |
HC3_Post $post, |
| 12 |
HC3_Ui $ui, |
| 13 |
HC3_Ui_Layout1 $layout, |
| 14 |
HC3_Time $t, |
| 15 |
|
| 16 |
HC3_Settings $settings |
| 17 |
) |
| 18 |
{ |
| 19 |
$this->ui = $ui; |
| 20 |
$this->layout = $layout; |
| 21 |
$this->t = $t; |
| 22 |
$this->post = $hooks->wrap($post); |
| 23 |
|
| 24 |
$this->settings = $hooks->wrap($settings); |
| 25 |
$this->self = $hooks->wrap($this); |
| 26 |
} |
| 27 |
|
| 28 |
public function post() |
| 29 |
{ |
| 30 |
$take = array( |
| 31 |
'pref_csv_separator', |
| 32 |
); |
| 33 |
|
| 34 |
$session = HC3_Session::instance(); |
| 35 |
foreach( $take as $k ){ |
| 36 |
$v = $this->post->get($k); |
| 37 |
$session->setUserdata( $k, $v ); |
| 38 |
} |
| 39 |
|
| 40 |
$ret = array( 'user/profile/pref', '__Settings Updated__' ); |
| 41 |
return $ret; |
| 42 |
} |
| 43 |
|
| 44 |
public function get() |
| 45 |
{ |
| 46 |
$values = array(); |
| 47 |
$pnames = array( |
| 48 |
'pref_csv_separator' => $this->settings->get('pref_csv_separator'), |
| 49 |
); |
| 50 |
|
| 51 |
$session = HC3_Session::instance(); |
| 52 |
foreach( $pnames as $pname => $v ){ |
| 53 |
$values[ $pname ] = $v; |
| 54 |
$v2 = $session->getUserdata( $pname ); |
| 55 |
if( $v2 ){ |
| 56 |
$values[ $pname ] = $v2; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
$inputs = array(); |
| 61 |
|
| 62 |
$inputs[] = $this->ui->makeInputSelect( |
| 63 |
'pref_csv_separator', |
| 64 |
'__CSV Delimiter__', |
| 65 |
array( |
| 66 |
',' => ',', |
| 67 |
';' => ';', |
| 68 |
), |
| 69 |
$values['pref_csv_separator'] |
| 70 |
); |
| 71 |
|
| 72 |
$inputs = $this->ui->makeList( $inputs ); |
| 73 |
|
| 74 |
$out = $this->ui->makeForm( |
| 75 |
'user/profile/pref', |
| 76 |
$this->ui->makeList( |
| 77 |
array( $inputs, $this->ui->makeInputSubmit('__Save__')->tag('primary') ) |
| 78 |
) |
| 79 |
); |
| 80 |
|
| 81 |
$this->layout |
| 82 |
->setContent( $out ) |
| 83 |
->setBreadcrumb( $this->self->breadcrumb() ) |
| 84 |
->setHeader( $this->self->header() ) |
| 85 |
// ->setMenu( $this->self->menu() ) |
| 86 |
; |
| 87 |
|
| 88 |
$out = $this->layout->render(); |
| 89 |
return $out; |
| 90 |
} |
| 91 |
|
| 92 |
public function header() |
| 93 |
{ |
| 94 |
$out = '__Preferences__'; |
| 95 |
return $out; |
| 96 |
} |
| 97 |
|
| 98 |
public function breadcrumb() |
| 99 |
{ |
| 100 |
$ret = array(); |
| 101 |
$ret['profile'] = array( 'user/profile', '__Profile__' ); |
| 102 |
return $ret; |
| 103 |
} |
| 104 |
} |