public function getfooter() { if (is_null($this->footer) === true) { $this->footer = html::cardFooter(); } return $this->footer; }
public function __call($name, $parameters) { $index = array_shift($parameters); $paths = array_shift($parameters); $page = null; if (isset($paths[$index + 1]) === true) { $page = $paths[$index + 1]; } $structure_index = implode('/', array_splice($paths, 0, $index + 1)); $structure = isset($this->structure[$structure_index]) === true ? $this->structure[$structure_index] : false; if ($structure === false) { return; } $html = ''; foreach ($structure['links'] as $url => $allowed) { if ($allowed === true) { $link = html::navAnchor('#!' . $url, lucid::$app->i18n()->translate('navigation:' . $url)); #lucid::$app->log($url.'=='.$page); if ($url == $page) { #lucid::$app->log($url.' is the active link'); $link->setactive(true); } $html .= html::navItem()->add($link)->render(); } } lucid::$app->response()->replace($structure['selector'], $html); }
public function init() { parent::init(); $this->addClass('btn-group'); $this->addClass('pull-right'); $this->attributes['role'] = 'group'; $this->add(html::button(lucid::$app->i18n()->translate('button:cancel'), 'secondary', 'history.go(-1);')); $this->add(html::submit(lucid::$app->i18n()->translate('button:save'))); }
public function _loginForm() { $card = html::card(); $card->add(html::cardHeader(lucid::$app->i18n()->translate('navigation:authentication.view.login'))); $card->add(html::cardBlock()); $card->lastChild()->add(html::form('authform', '#!authentication.controller.process')); $form = $card->lastChild()->lastChild(); $form->add(html::formGroup(lucid::$app->i18n()->translate('model:users:email'), html::input('email', 'email')->preAddon('@'))); $form->add(html::formGroup(lucid::$app->i18n()->translate('model:users:password'), html::input('password', 'password')->preAddon(html::icon('lock')))); $form->add(html::submit(lucid::$app->i18n()->translate('button:login'))->pull('right')); $this->ruleset('login')->send($form->name); return $card; }
public function setType($type) { parent::settype($type); if ($type == 'date') { $this->attributes['type'] = 'text'; $this->postAddon = html::icon('calendar'); # { format:'Y-m-d H:i'} if (is_null($this->id)) { $this->id = 'datetimepicker-' . uniqid(); } html::$config['hooks']['javascript']("window.jQuery('#" . $this->id . "').datetimepicker({format:'" . html::$config->get('formats')['datetime'] . "',showMeridian: true, todayBtn:true});"); } return $this; }
function setVertical($val) { html::errorBoolean($this, 'vertical', $val); return $this->toggleClass('btn-group-vertical', $val); }
public function edit(int $role_id) { # By default, require that the user be logged in to access the edit form. If you want additional # permissions, use the lucid::$app->$security->requirePermission() function. #lucid::$app->permission()->requireLogin(); # lucid::$app->$security->requirePermission('roles-select'); # Set the title tag for the page. Optionally, you can also set the description or keywords meta tag # by calling lucid::$app->$response->description() or lucid::$app->$response->keywords() lucid::$app->response()->title(lucid::$app->i18n()->translate('branding:app_name') . ' - Roles'); # Render the navigation controller. lucid::$app->factory()->view('navigation')->render('dashboard.view.admin', 'roles.view.table', 'roles.view.edit'); # Load the model. If $role_id == 0, then the model's ->create method will be called. $data = $this->controller()->getOne($role_id); # the ->notFound method will throw an error if the first parameter === false, which will be the case # if the model function is passed an ID that is not zero, but is not able to retrieve a row for that ID #lucid::$app->$error->notFound($data, '#body'); # Based on whether or not the primary key for the model == 0, the header message will either be the dictionary # key form:edit_new or form::edit_existing. $headerMsg = lucid::$app->i18n()->translate('form:edit_' . ($data->role_id == 0 ? 'new' : 'existing'), ['type' => 'roles', 'name' => $data->name]); # Construct the form and retrieve the ruleset for the controller. You can have multiple functions in your # controller if you want to have that controller accept submissions from different forms with different numbers # of fields, but the auto-generated ruleset-returning function is simply called ->ruleset(). The ->send() # method of the ruleset object packages up the rules into json, and sends them to the client so that they can be # used clientside when the form submits. $form = html::form('roles-edit', '#!roles.controller.save'); $this->ruleset('edit')->send($form->name); # create the main structure for the form $card = html::card(); $card->header()->add($headerMsg); $card->block()->add([html::formGroup(lucid::$app->i18n()->translate('model:roles:name'), html::input('text', 'name', $data->name)), html::input('hidden', 'role_id', $data->role_id)]); $card->footer()->add(html::formButtons()); $form->add($card); lucid::$app->response()->replace('#main-rightcol', $form); }
public function enableAddNewButton($url, $label = 'Add New', $modifier = 'primary') { $this->components['add_new'] = html::anchorButton($url, $label, 'primary'); return $this; }
public function enableSearchFilter($fields, $filter_name = 'search') { $id = $this->id . '-filter-' . $filter_name; $value = $this->determineFilterValue($filter_name); $this->components['filter_search'] = html::input('text', $filter_name, $value)->id($id)->preAddon(\Lucid\html\html::icon('search'))->size('sm')->style('width:auto;')->onkeyup('lucid.html.dataTable.filter(this, true);'); $this->filters[$filter_name] = ['field' => $fields, 'operator' => 'like', 'value' => $value]; return $this; }
public function paragraph($text) : TagInterface { if ($this->allowChildren === false) { throw new Exception\ChildrenNotAllowed(get_class($this)); } $this->add(html::p($text)); return $this; }
public function user() { lucid::$app->factory()->view('navigation')->render('dashboard.view.user', 'dashboard.view.user'); lucid::$app->response()->replace('#main-fullwidth', html::h1('User dashboard')); }
public function addPane() { $pane = html::tabPane($this->lastChild()->href); $pane->parent = $this; $this->panes[] = $pane; return $this; }
<?php use Lucid\Lucid; use Lucid\Html\html; html::init(new \Lucid\Component\Container\PrefixDecorator('html/', Lucid::$app->config()), 'bootstrap'); html::addFlavor('lucid', realpath(__DIR__ . '/../vendor/devlucid/lucid/html/') . '/'); html::addFlavor('app', realpath(__DIR__ . '/../app/') . '/'); html::$config->get('hooks')['form__create'] = function ($obj) { $obj->onsubmit = 'return lucid.submit(this);'; }; html::$config->get('hooks')['javascript'] = function ($js) { Lucid::$app->response()->javascript($js); };
public function edit(int $user_id) { # By default, require that the user be logged in to access the edit form. If you want additional # permissions, use the lucid::$app->$security->requirePermission() function. #lucid::$app->permission()->requireLogin(); # lucid::$app->$security->requirePermission('users-select'); # Set the title tag for the page. Optionally, you can also set the description or keywords meta tag # by calling lucid::$app->$response->description() or lucid::$app->$response->keywords() lucid::$app->response()->title(lucid::$app->i18n()->translate('branding:app_name') . ' - Users'); # Render the navigation controller. lucid::$app->factory()->view('navigation')->render('users.view.table', 'users.view.edit'); # Load the model. If $user_id == 0, then the model's ->create method will be called. $data = $this->controller()->getOne($user_id); # the ->notFound method will throw an error if the first parameter === false, which will be the case # if the model function is passed an ID that is not zero, but is not able to retrieve a row for that ID #lucid::$app->$error->notFound($data, '#body'); # Based on whether or not the primary key for the model == 0, the header message will either be the dictionary # key form:edit_new or form::edit_existing. $headerMsg = lucid::$app->i18n()->translate('form:edit_' . ($data->user_id == 0 ? 'new' : 'existing'), ['type' => 'users', 'name' => $data->email]); # Construct the form and retrieve the ruleset for the controller. You can have multiple functions in your # controller if you want to have that controller accept submissions from different forms with different numbers # of fields, but the auto-generated ruleset-returning function is simply called ->ruleset(). The ->send() # method of the ruleset object packages up the rules into json, and sends them to the client so that they can be # used clientside when the form submits. $form = html::form('users-edit', '#!users.controller.save'); $this->ruleset('edit')->send($form->name); $org_id_options = lucid::$app->factory()->model('organizations')->select('org_id', 'value')->select('name', 'label')->order_by_asc('name')->find_array(); $org_id_options = array_merge([0, ''], $org_id_options); # create the main structure for the form $card = html::card(); $card->header()->add($headerMsg); $card->block()->add([html::formGroup(lucid::$app->i18n()->translate('model:users:org_id'), html::select('org_id', $data->org_id, $org_id_options)), html::formGroup(lucid::$app->i18n()->translate('model:users:email'), html::input('text', 'email', $data->email)), html::formGroup(lucid::$app->i18n()->translate('model:users:password'), html::input('text', 'password', $data->password)), html::formGroup(lucid::$app->i18n()->translate('model:users:first_name'), html::input('text', 'first_name', $data->first_name)), html::formGroup(lucid::$app->i18n()->translate('model:users:last_name'), html::input('text', 'last_name', $data->last_name)), html::formGroup(lucid::$app->i18n()->translate('model:users:is_enabled'), html::input('checkbox', 'is_enabled', $data->is_enabled)), html::formGroup(lucid::$app->i18n()->translate('model:users:last_login'), html::input('date', 'last_login', (new \DateTime($data->last_login))->format('Y-m-d H:i'))), html::formGroup(lucid::$app->i18n()->translate('model:users:created_on'), html::input('date', 'created_on', (new \DateTime($data->created_on))->format('Y-m-d H:i'))), html::formGroup(lucid::$app->i18n()->translate('model:users:force_password_change'), html::input('checkbox', 'force_password_change', $data->force_password_change)), html::formGroup(lucid::$app->i18n()->translate('model:users:register_key'), html::input('text', 'register_key', $data->register_key)), html::input('hidden', 'user_id', $data->user_id)]); $card->footer()->add(html::formButtons()); $form->add($card); lucid::$app->response()->replace('#main-fullwidth', $form); }