function render() { /* tabs */ $id = $this->id(); if (!$id) { $id = 'nts' . hc_random(); } $tabs = HC_Html_Factory::widget('list')->add_attr('class', array('nav'))->add_attr('class', array('nav-tabs'))->add_attr('class', array('hc-tab-links'))->add_attr('id', $id); $my_tabs = $this->tabs(); reset($my_tabs); foreach ($my_tabs as $key => $tab_array) { list($tab_label, $tab_content) = $tab_array; $tabs->add_item($key, HC_Html_Factory::widget('titled', 'a')->add_attr('href', '#' . $key)->add_attr('class', 'tab-toggler')->add_attr('data-toggle-tab', $key)->add_child($tab_label)); } $active = $this->active(); $tabs->add_item_attr($active, 'class', 'active'); /* content */ $content = HC_Html_Factory::element('div')->add_attr('class', 'hc-tab-content')->add_attr('style', 'overflow: visible;'); reset($my_tabs); foreach ($my_tabs as $key => $tab_array) { list($tab_label, $tab_content) = $tab_array; $tab = HC_Html_Factory::element('div')->add_attr('class', 'hc-tab-pane')->add_attr('id', $key)->add_attr('data-tab-id', $key); if ($active == $key) { $tab->add_attr('class', 'active'); } $tab->add_child($tab_content); $content->add_child($tab); } /* javascript */ /* out */ $out = HC_Html_Factory::widget('list')->add_attr('class', array('list-unstyled'))->add_attr('class', array('hc-tabs')); $out->add_item($tabs); $out->add_item($content); return $out->render(); }
static function tab_content($tabs, $shown = '', $id = '') { if (!strlen($id)) { $id = hc_random(); } if (!$shown) { $all_tabs = array_keys($tabs); $shown = $all_tabs[0]; } $out = array(); $out[] = '<div class="tab-content" style="overflow: visible;">'; reset($tabs); foreach ($tabs as $tab_id => $t) { // $full_tab_id = $id . '_' . $tab_id; if (!is_array($t)) { $t = array('content' => $t); } if (!isset($t['attr'])) { $t['attr'] = array(); } if (!isset($t['attr']['class'])) { $t['attr']['class'] = array(); } else { $t['attr']['class'] = array($t['attr']['class']); } $t['attr']['class'][] = 'tab-pane'; if ($tab_id == $shown) { $t['attr']['class'][] = 'active'; } $t['attr']['class'] = join(' ', $t['attr']['class']); $full_tab_id = $tab_id; $t['attr']['id'] = $full_tab_id; $attr = array(); foreach ($t['attr'] as $k => $v) { $attr[] = $k . '="' . $v . '"'; } $full_tab_id = $tab_id; $out[] = '<div ' . join(' ', $attr) . '>'; $out[] = $t['content']; $out[] = '</div>'; } $out[] = '</div>'; $out = join("\n", $out); return $out; }
public function login($user_id) { $current_user_id = $this->check(); if ($user_id && ($user_id != $current_user_id or !isset($_SESSION['NTS_SESSION_REF']))) { $session_data = array('user_id' => $user_id); $this->session->set_userdata($session_data); $_SESSION['NTS_SESSION_REF'] = hc_random(16); if (method_exists($this->auth_model, 'trigger_event')) { $this->auth_model->trigger_event('after_login', $this->auth_model); } } return TRUE; }
if ($trade_menu) { $tabs['trades'] = $trade_menu; } } /* HISTORY */ if ($this->hc_modules->exists('logaudit')) { $tabs['history'] = '<i class="fa fa-list-ul"></i> ' . lang('common_history'); $tab_content['history'] = Modules::run('logaudit/admin/index', $object); } /* DELETE SERIES */ if ($group_count > 1 && $this->hc_modules->exists('shift_groups')) { $tabs['delete'] = '<i class="fa fa-times text-danger"></i> ' . lang('common_delete'); $tab_content['delete'] = Modules::run('shift_groups/admin/delete_form', $object); } ?> <?php $tabs_id = hc_random(); echo Hc_bootstrap::nav_tabs($tabs, '', '', $tabs_id); echo hc_bootstrap::tab_content($tab_content); ?> <script language="JavaScript"> if ( window.location.hash ) { jQuery('#<?php echo $tabs_id; ?> a[href="' + window.location.hash + '"]').tab("show"); } </script>
function __construct() { $this->id = hc_random(); }
function __construct() { parent::__construct(); $this->id = 'nts_' . hc_random(); }
public function sync($id, $force_level = NULL) { $wuser = get_user_by('id', $id); $user = HC_App::model('user'); $user->where('id', $id)->get(); $is_new = $user->exists() ? FALSE : TRUE; if ($is_new) { $user->id = $id; if ($force_level) { $user_level = $force_level; } else { /* check new user level */ $app_conf = HC_App::app_conf(); $wp_role = $wuser->roles && is_array($wuser->roles) && isset($wuser->roles[0]) ? $wuser->roles[0] : ''; $k = 'wordpress_' . 'role_' . $wp_role; $user_level = $app_conf->get($k); if ($wp_role == 'administrator') { $user_level = $user->_const('LEVEL_ADMIN'); } } if (!$user_level) { return; } $user->level = $user_level; $password = hc_random(); $user->password = $password; $user->confirm_password = $password; } else { if ($force_level) { $user->level = $force_level; } } if ($wuser->user_firstname) { $user->first_name = $wuser->user_firstname; $user->last_name = $wuser->user_lastname; } else { $user->first_name = $wuser->display_name; } if ($wuser->user_email) { if ($is_new or $wuser->user_email != $user->email) { // check if this email already exists $um = HC_App::model('user'); $um->where('email', $wuser->user_email)->get(); if ($um->exists()) { if ($is_new) { // update id in our table $um->where('id', $um->id)->update('id', $id); $user->id = $id; } else { $user->id = $um->id; } $is_new = FALSE; } $user->email = $wuser->user_email; } } $user->active = $user->_const('STATUS_ACTIVE'); $user->remove_validation('email'); $user->remove_validation('username'); $user->remove_validation('confirm_password'); /* if( $is_new ){ if( $user->save_as_new() ){ $return = TRUE; } else { $return = $user->errors(); } } else { if( $user->save() ){ $return = TRUE; } else { $return = $user->errors(); } } */ if ($is_new && $user->save_as_new() or !$is_new && $user->save()) { $return = TRUE; } else { $return = $user->errors(); } return $return; }
function render() { $enabled = $this->enabled(); $value = $this->value(TRUE); $t = HC_Lib::time(); if (isset($value['datestart'])) { $t->setDateDb($value['datestart']); } /* single date part */ $wrap_single = HC_Html_Factory::widget('list')->add_attr('class', array('list-unstyled', 'list-separated')); $wrap_single->add_item($this->fields['datesingle']); /* recurring part */ $wrap = HC_Html_Factory::widget('list')->add_attr('class', array('list-unstyled', 'list-separated'))->add_attr('class', 'hc-radio-info-container'); /* DATES */ $item_dates = HC_Html_Factory::widget('list')->add_attr('class', array('list-inline', 'list-separated')); $item_dates->add_item($this->fields['datestart']); $item_dates->add_item(' - '); $item_dates->add_item($this->fields['dateend']); $wrap->add_item($item_dates); /* RECURRING OPTIONS */ $repeat = clone $this->fields['repeat']; $repeat->add_option('daily', HCM::__('Daily')); $repeat->add_option('weekday', HCM::__('Every Weekday') . ' (' . $t->formatWeekdayShort(1) . ' - ' . $t->formatWeekdayShort(5) . ')'); $repeat->add_option('weekly', HCM::__('Weekly') . ' (' . $t->formatWeekdayShort() . ')'); $wkds = array(0, 1, 2, 3, 4, 5, 6); $wkds = $t->sortWeekdays($wkds); /* weekly custom */ $weekly_custom = clone $this->fields['weeklycustom']; $this_weekday = $t->getWeekday(); if (!$weekly_custom->value()) { $weekly_custom->set_value(array($this_weekday)); } reset($wkds); foreach ($wkds as $wkd) { $weekly_custom->add_option($wkd, $t->formatWeekdayShort($wkd)); } // $weekly_custom->set_readonly($this_weekday); $repeat->add_option('weeklycustom', HCM::__('Weekly') . ' (' . HCM::__('Selected Days') . ')', $weekly_custom); /* biweekly custom */ $this_weekday = $t->getWeekday(); $biweekly_custom1 = clone $this->fields['biweeklycustom1']; if (!$biweekly_custom1->value()) { $biweekly_custom1->set_value(array($this_weekday)); } $biweekly_custom2 = clone $this->fields['biweeklycustom2']; if (!$biweekly_custom2->value()) { $biweekly_custom2->set_value(array($this_weekday)); } reset($wkds); foreach ($wkds as $wkd) { $biweekly_custom1->add_option($wkd, $t->formatWeekdayShort($wkd)); $biweekly_custom2->add_option($wkd, $t->formatWeekdayShort($wkd)); } // $weekly_custom->set_readonly($this_weekday); $repeat->add_option('biweeklycustom', HCM::__('Biweekly') . ' (' . HCM::__('Selected Days') . ')', array($biweekly_custom1, $biweekly_custom2)); /* in/out */ if (!$this->fields['inoutin']->value()) { $this->fields['inoutin']->set_value(2); } if (!$this->fields['inoutout']->value()) { $this->fields['inoutout']->set_value(2); } $repeat->add_option('inout', join(' / ', array(sprintf(HCM::_n('%s Day On', '%s Days On', 100), 'X'), sprintf(HCM::_n('%s Day Off', '%s Days Off', 100), 'Y'))), HC_Html_Factory::widget('list')->add_attr('class', array('list-inline', 'list-separated'))->add_item($this->fields['inoutin']->add_attr('size', 2))->add_item('/')->add_item($this->fields['inoutout']->add_attr('size', 2))); $repeat->add_option('monthlyday', HCM::__('Monthly') . ' (' . join(', ', array($t->formatWeekdayShort(), $t->formatWeekOfMonth())) . ')'); $repeat->add_option('monthlydayend', HCM::__('Monthly') . ' (' . join(', ', array($t->formatWeekdayShort(), $t->formatWeekOfMonthFromEnd())) . ')'); $repeat->add_option('monthlydate', HCM::__('Monthly') . ' (' . HCM::__('Day') . ': ' . $t->getDay() . ')'); $wrap->add_item($repeat); /* build output */ // $recurring_part = $wrap->render(); // $recurring_part = $this->decorate( $recurring_part ); // $single_part = $wrap_single->render(); // $single_part = $this->decorate( $wrap_single ); $return = HC_Html_Factory::widget('container'); if (count($enabled) > 1) { $tabs = HC_Html_Factory::widget('tabs'); $tabs_id = 'nts' . hc_random(); $tabs->set_id($tabs_id); $tabs->add_tab('single', HCM::__('Single Day'), $wrap_single); $tabs->add_tab('recurring', HCM::__('Multiple Days'), $wrap); $value_recurring = $value['recurring']; $tabs->set_active($value_recurring); $return->add_item($this->fields['recurring']); $return->add_item($tabs); $name_recurring = $this->fields['recurring']->name(); $tabs_js = <<<EOT <script language="JavaScript"> jQuery('#{$tabs_id}').closest('form').find('[name={$name_recurring}]').val( "{$value_recurring}" ) jQuery('#{$tabs_id} a.hc-tab-toggler').on('shown.hc.tab', function(e) { \tvar active_tab = jQuery(this).data('toggle-tab'); \tjQuery(this).closest('form').find('[name={$name_recurring}]').val( active_tab ); }); </script> EOT; $return->add_item($tabs_js); } else { if (in_array('single', $enabled)) { $return->add_item($wrap_single); } if (in_array('recurring', $enabled)) { $return->add_item($wrap); } } $return = $return->render(); // return $return; return $this->decorate($return); }