public static function display($menuClasses = null) { $id = 'MenuUtils_display' . Invocation::next(); $jsLibraries = JS::libraryWithDependancies(JS::JQUERY_UI); $activeMenu = Request::get(self::ACTIVE_MENU, 0); $js = <<<JS \$().ready ( function () { \$( '#{$id}' ).show() .accordion({ collapsible: true, active: {$activeMenu} }); }); JS; $html = ''; $html .= Tag::div(['id' => $id, 'style' => 'font-size: 0.8em; width:250px; text-align:left; display:none;']); foreach (self::getMenuItems($menuClasses) as $header => $menuList) { $html .= Tag::hTag('h3') . Tag::hRef('#', $header) . Tag::_hTag('h3') . Tag::div() . Tag::ul(); foreach ($menuList as $row) { $html .= Tag::li(); if (isset($row['slug'])) { $html .= Tag::hRef(Cfg::siteUrl() . '/menu.php?S=' . $row['slug'], $row['name'], $row['attribs']); } else { $html .= Tag::hRef($row['url'], $row['name'], $row['attribs']); } $html .= Tag::_li(); } $html .= Tag::_ul() . Tag::_div(); } $html .= Tag::_div(); return $jsLibraries . JS::javaScript($js) . $html; }
public static function menu() { if (Privileges::access(__METHOD__) !== true || !G::isLoggedIn()) { return ''; } $resp = new Response(); $html = Tag::hTag('b') . 'Super Admin Menu' . Tag::_hTag('b') . Tag::ul(['id' => 'menuList']); foreach (self::getMenu() as $title => $action) { $html .= Tag::li() . Tag::hRef('?' . $resp->action($action)->toUrl(), $title) . Tag::_li(); } $html .= Tag::_ul(); return $html; }
public function index($tName = '') { if (($tableName = Request::get('tblName', $tName)) == '') { return ''; } $crud = CRUD::factory($tableName, ['topPager' => false])->copyVarsFromRequest('tblName'); if (preg_match('/^tblMod([A-Z]+[a-z]+)/', $tableName, $matches)) { foreach (Cfg::get('modules', []) as $moduleClass) { eval($moduleClass . '::' . Module::CRUD_MOD . '($crud);'); } } else { switch ($tableName) { case 'tblNextNumber': $crud->setColDisplay('fldTable', [CRUD::SELECT, DBMaintenance::getTableList(), true]); break; case 'tblSecPrivUserMap': $userSql = DB::driver() == DB::MYSQL ? Admin::USER_SQL_MYSQL : Admin::USER_SQL_MYSQL; $crud->setColDisplay('fldUserID', [CRUD::SELECT, $userSql, true]); $crud->setColDisplay('fldGroupID', [CRUD::SELECT, Admin::GROUP_SQL, true]); $crud->setColDisplay('fldPrivilegeID', [CRUD::SELECT, Admin::PRIV_SQL, true]); $crud->setColDisplay('fldLevelID', [CRUD::SELECT, Admin::LEVEL_SQL]); break; case 'tblUserGroupMap': $userSql = DB::driver() == DB::MYSQL ? Admin::USER_SQL_MYSQL : Admin::USER_SQL_SQLITE; $crud->setColDisplay('fldUserID', [CRUD::SELECT, $userSql, true]); $crud->setColDisplay('fldGroupID', [CRUD::SELECT, Admin::GROUP_SQL, true]); break; case 'tblUser': $crud->setColDisplay('fldLevel', [CRUD::SELECT, Admin::LEVEL_SQL]); $crud->setColDisplay('fldTimeZone', [CRUD::SELECT, Admin::TZ_SQL]); break; } } $resp = Response::factory()->set('tblName', $tableName); return Tag::hTag('b') . 'Editing Table: ' . $tableName . Tag::_hTag('b') . ' ' . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->csv()'), 'CSV') . ' ' . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->xls()'), 'XLS') . $crud->index(); }
/** * @param $columnName * @param $columnDisplay * @return string */ public function toHtml($columnName, $columnDisplay = null) { if ($columnDisplay == null) { $columnDisplay = $columnName; } $savedFormVars = $this->formVars; $this->set(self::SORT_COL, $columnName); if ($this->sortColumn == $columnName) { $this->set(self::SORT_ORDER, $this->sortOrder == 'ASC' ? 'DESC' : 'ASC'); $sortDirectionName = $this->sortOrder == 'ASC' ? 'Decending' : 'Ascending'; $title = 'Click here to sort ' . $sortDirectionName . ' By ' . $columnDisplay; $button = $this->sortOrder == 'ASC' ? '^' : 'v'; $url = $this->toUrl(); $html = Tag::hTag('a', array_merge($this->attribs, ['href' => $url, 'class' => $this->styles[self::COL_LINK_CLASS], 'title' => $title])) . $columnDisplay . Tag::_hTag('a') . Tag::linkButton($url, $button, array_merge($this->attribs, ['class' => $this->styles[self::COL_BUTTON_CLASS], 'title' => $title])); } else { $this->set(self::SORT_ORDER, $this->sortOrder); $sortDirectionName = $this->sortOrder == 'ASC' ? 'Decending' : 'Ascending'; $title = 'Sort ' . $sortDirectionName . ' By ' . $columnDisplay; $url = $this->toUrl(); $html = Tag::hTag('a', array_merge($this->attribs, ['href' => $url, 'class' => $this->styles[self::COL_LINK_CLASS], 'title' => $title])) . $columnDisplay . Tag::_hTag('a'); } $this->formVars = $savedFormVars; return $html; }
public function newRegistration() { // Initialise the $msg and $action and $disclaimer variables $disclaimer = Cfg::get('disclaimer'); $formName = 'FancyLogin_newRegistration'; $valid = Validator::factory($formName, 'NR')->addExists('fldEmail', 'Email field is empty. Please insert valid email and resubmit')->addEmail('fldEmail', 'Email needs to exist and be correct format')->addExists('fldFirstName', 'First Name must exist')->addExists('fldCaptcha', 'You must enter Captcha Code')->addExists('fldLastName', 'Last Name must exist'); $cap = new Captcha(); $html = $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . Response::factory()->set(self::ACTION, __CLASS__ . '->signUp()')->set('_CAP', $cap->getValue())->toHidden() . Tag::table(['align' => 'center', 'border' => 0, 'cellspacing' => 0, 'cellpadding' => 2]) . Tag::tr() . Tag::td() . 'Email:' . Tag::_td() . Tag::td() . Tag::text('fldEmail', Request::get('fldEmail')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'First Name:' . Tag::_td() . Tag::td() . Tag::text('fldFirstName', Request::get('fldFirstName')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Last Name:' . Tag::_td() . Tag::td() . Tag::text('fldLastName', Request::get('fldLastName')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . Tag::img($cap->imageUrl()) . Tag::_td() . Tag::td() . Tag::text('fldCaptcha') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2, 'nowrap' => 'nowrap', 'valign' => 'top']) . 'Please Read Disclaimer:' . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2]) . Tag::hTag('iframe', ['src' => $disclaimer, 'width' => '100%']) . Tag::_hTag('iframe') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2, 'align' => 'center']) . 'By clicking below, you are stating that you understand and agree to the Disclamer above' . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2, 'align' => 'center']) . Tag::submit('New Account') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form(); return $html; }
/** * Generates the HTML for a label element * @param string $for ID of the element that this label is for * @param string $display Text to display * @return string */ static function label($for, $display, $attribs = []) { $attribs['for'] = $for; return Tag::hTag('label', $attribs) . $display . Tag::_hTag('label'); }
public function editJSONEditForm($currentConfigKey) { $json = json_encode(Config::get($currentConfigKey)); $js = <<<JS var json = {$json}; main.load(json); main.resize(); var pageDirty = false; \$().ready(function() { window.onbeforeunload = function () { if ( ! pageDirty ) return; return 'Changes have been made on this page and will be discarded.' }; \$('textarea.jsonformatter-textarea').change( function() { pageDirty = true; }); \$('div.jsoneditor-value').change( function() { pageDirty = true; }); \$('#fldCfgValue').val( editor.get() ); }); function submitClicked () { var button = \$('#editJSONEditFormButton').attr('disabled',true); var orig = \$('#fldCfgValue').val(); var ed = editor.get(); // JSON Editor, RHS fields labels var form = formatter.get(); // Formatted Text Editor LHS if ( orig == ed && orig == form ) { pageDirty = false; alert( 'No changes, nothing to save' ); button.attr('disabled',false ); return false; } else if ( orig != ed && orig == form ) { if ( confirm( 'Looks like you have made changes in the JSON Editor on right pane and not copied to Formatted Text Editor on left pane. Ok to save changes?' ) ) { pageDirty = false; \$('#fldCfgValue').val( ed ); \$('#editJSONEditForm').submit(); return true; } else { button.attr('disabled',false ); return false; } } else if ( orig == ed && orig != form ) { if ( confirm( 'Looks like you have made changes in the Formatted Text Editor on left pane and not copied to the JSON Editor on right pane. Ok to save?' ) ) { pageDirty = false; \$('#fldCfgValue').val( form ); \$('#editJSONEditForm').submit(); return true; } else { button.attr('disabled',false ); return false; } } else if ( orig != ed && orig != form ) { if ( ed == form ) { pageDirty = false; \$('#fldCfgValue').val( ed ); \$('#editJSONEditForm').submit(); return true; } else { alert( 'You have changed both the JSON Editor on right pane and the Formatted Text Editor on left pane and they are inconsistent. ' + 'Please press one of the arrow buttons to fix and re-submit' ); button.attr('disabled',false ); return false; } } } \$('body') .on( 'focus', '[contenteditable]', function() { var t = \$(this); t.data('before', t.html()); return t; }) .on( 'blur keyup paste input', '[contenteditable]', function() { var t = \$(this); if (t.data('before') !== t.html() ) { t.data('before', t.html()); t.trigger('change'); } return t; }); JS; return JS::library(JS::JQUERY) . JS::library('jsoneditor.css') . JS::library('interface.css') . JS::library('jsoneditor.js') . JS::library('interface.js') . Tag::div(['id' => 'auto']) . Tag::div(['id' => 'contents', 'height' => '100%']) . Tag::table(['border' => '0', 'height' => '100%', 'width' => '100%']) . Tag::tr() . Tag::td(['valign' => 'top', 'width' => '45%', 'height' => '100%']) . Tag::hTag('b') . ' Formatted Text Editor' . Tag::_hTag('b') . Tag::div(['id' => 'jsonformatter']) . Tag::_div() . Tag::_td() . Tag::td(['valign' => 'top', 'width' => '10%', 'align' => 'center']) . Tag::div(['id' => 'splitter']) . Tag::_div() . Tag::_td() . Tag::td(['valign' => 'top', 'width' => '45%', 'height' => '100%']) . Tag::hTag('b') . ' JSON Editor' . Tag::_hTag('b') . Tag::div(['id' => 'jsoneditor']) . Tag::_div() . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_div() . Tag::_div() . Tag::form(['id' => 'editJSONEditForm'], false) . MenuUtils::responseObject()->set('fldCfgKey', $currentConfigKey)->action(__CLASS__ . '->saveConfig()')->toHidden() . Tag::textArea('fldCfgValue', '', ['id' => 'fldCfgValue', 'style' => 'display: none;']) . '<b>Currently editing : <i>' . $currentConfigKey . '</i></b> ' . Tag::button('Save', ['onClick' => 'submitClicked();', 'id' => 'editJSONEditFormButton']) . Tag::_form() . JS::javaScript($js); }
/** * Generates a drop down box from almost anything * @param string $name nameof the select * @param array $displayList * @param array $attribs html attributes to generate * @param string $defaultValue matches the key in the displayList * @param boolean $blank true if you want to generate a blank row * @returns string The resulting HTML */ static function selectWithCategories($name, $resultset, $attribs = array()) { if (isset($attribs['default'])) { $defaultValue = $attribs['default']; unset($attribs['default']); } else { $defaultValue = Request::get($name, null); } $hasBlank = false; if (isset($attribs['hasBlank'])) { $hasBlank = $attribs['hasBlank']; unset($attribs['hasBlank']); } $optGroupAttrib = array(); if (isset($attribs['optGroupAttrib'])) { $optGroupAttrib = $attribs['optGroupAttrib']; unset($attribs['optGroupAttrib']); } if (is_array($resultset)) { if (count($resultset) == 0) { $tag = "* None Available *"; if ($defaultValue != null) { $tag .= Tag::hidden($name, $defaultValue); } } else { $tag = Tag::select($name, $attribs); if ($hasBlank) { $tag .= Tag::optiontag(' ', '', !isset($defaultValue) || $defaultValue == false); } foreach ($resultset as $category => $list) { $tag .= Tag::hTag('optgroup', array_merge($optGroupAttrib, array('label' => $category))); foreach ($list as $key => $val) { $tag .= Tag::optiontag(trim($key), $val, $defaultValue == $key); } $tag .= Tag::_hTag('optgroup'); } $tag .= Tag::_select(); } } else { if (is_object($resultset)) { /** FIXME **/ $table = new DBTable($resultset, DB::FETCH_NUM); if ($table->rowCount() == 0) { $tag = "* None Available *"; if ($defaultValue != null) { $tag .= Tag::hidden($name, $defaultValue); } } else { $tag = Tag::select($name, $attribs); if ($hasBlank) { $tag .= Tag::optiontag(' ', '', !isset($defaultValue) || $defaultValue == false); } $prevCategory = ''; foreach ($table as $row) { if ($prevCategory != $row[0]) { if ($prevCategory != '') { $tag .= Tag::_hTag('optgroup'); } $tag .= Tag::hTag('optgroup', array('label' => $row[0])); $prevCategory = $row[0]; } $tag .= Tag::optiontag($row[1], $row[2], $defaultValue == $row[1]); } $tag .= Tag::_hTag('optgroup'); $tag .= Tag::_select(); } } } return $tag; }
public function index() { if (!$this->ok) { return 'Invalid table: ' . $this->tableName; } $html = $this->controller(); $paginationHtml = $this->paginator->toHtml(); $html .= Tag::form(['action' => $this->formAction, 'onSubmit' => "if (!checkIfADelete('{$this->delTag}')) return false; return true;"]) . Tag::table(array_merge(['id' => 'CRUD' . $this->suffix], $this->styles[self::TABLE_C])) . Tag::tr(); if ($this->canDelete) { $js = "\$().ready(function() { \$('input[type=checkbox][name^={$this->delTag}]').shiftClick(); });"; $html .= JS::library('jquery.shiftclick.js') . JS::javaScript($js) . Tag::th() . Tag::hTag('span', ['title' => 'Click here to Toggle all the Delete checkboxes']) . 'D' . Tag::_hTag('span') . Tag::br() . Tag::checkBox('_dcheck', 'Y', false, ['onClick' => "toggleAll(this,'{$this->delTag}','{$this->submitId}')", 'title' => 'Toggle all the Delete checkboxes.']) . Tag::_th(); } if ($this->canUpdate) { $js = "\$().ready(function() { \$('input[type=checkbox][name^={$this->updTag}]').shiftClick(); });"; $html .= JS::library('jquery.shiftclick.js') . JS::javaScript($js) . Tag::th() . Tag::hTag('span', ['title' => 'Click here to Toggle all the Update checkboxes']) . 'U' . Tag::_hTag('span') . Tag::br() . Tag::checkBox('_ucheck', 'Y', false, ['onClick' => "toggleAll(this,'{$this->updTag}','{$this->submitId}')", 'title' => 'Toggle all the Update checkboxes.']) . Tag::_th(); } foreach ($this->columnTitles as $colName => $title) { if (isset($this->displayType[$colName])) { if (is_string($this->displayType[$colName])) { $type = $this->displayType[$colName]; } else { $type = $this->displayType[$colName][0]; } } else { $type = self::DISPLAY; } if (!in_array($type, [self::HIDDEN, self::NONE])) { $html .= Tag::th() . $this->columnator->toHtml($colName, $title) . Tag::_th(); } } foreach ($this->extraCols as $title => $col) { $html .= Tag::th(); if (isset($this->columnTitles[$title])) { $html .= $this->columnator->toHtml($title, $this->columnTitles[$title]); } else { $html .= $title; } $html .= Tag::_th(); } $html .= Tag::_tr() . "\n"; $tab = $this->createSQLResult(); $this->calculateColumnWidths($tab); foreach ($tab as $idx => $row) { $html .= Tag::tr(); if ($this->canDelete) { $html .= Tag::td(['align' => 'center']) . Tag::checkBox("{$this->delTag}[{$idx}]", $row[$this->primaryKey], false, ['id' => "{$this->delTag}_{$idx}", 'onClick' => "showSubmit('{$this->submitId}')", 'title' => 'Toggle to delete this row.']) . Tag::_td(); } if ($this->canUpdate) { $html .= Tag::td(['align' => 'center']) . Tag::checkBox("{$this->updTag}[{$idx}]", $row[$this->primaryKey], false, ['id' => "{$this->updTag}_{$idx}", 'onClick' => "showSubmit('{$this->submitId}')", 'title' => 'Toggle to update this row.']) . Tag::_td(); } foreach ($row as $key => $value) { $html .= $this->renderValue($idx, $key, $value); } foreach ($this->extraCols as $col) { $html .= Tag::td() . call_user_func_array($col, [$idx, $row[$this->primaryKey]]) . Tag::_td(); } $html .= Tag::_tr() . "\n"; } $this->resp->set($this->action, 'applyChanges'); $html .= Tag::_table() . $this->resp->toHidden() . Tag::submit('Apply Changes', ['style' => 'display: none', 'id' => $this->submitId, 'title' => 'Click here to apply the changes to this table']) . Tag::_form(); return self::header() . Widget::styleTable('#CRUD' . $this->suffix) . ($this->topPage ? $paginationHtml : '') . $html . ($this->bottomPage ? $paginationHtml : '') . $this->insertForm(); }
public static function reload($callBack, $url, $numOfSeconds = 20, $css = 'ReloadWidget') { $id = '_' . Invocation::next(); $js = <<<JS var countDownInterval{$id} = {$numOfSeconds}; //configure refresh interval (in seconds) var countDownTime{$id} = countDownInterval{$id} + 1; var reloadTimes{$id} = 0; var counter{$id}; function countDown{$id}(){ countDownTime{$id}--; \$('#stop{$id}').show(); \$('#start{$id}').hide(); if ( countDownTime{$id} <= 0 ) { clearTimeout(counter{$id}); updateReloadArea{$id}(); return; } \$('#countDownText{$id}').html( countDownTime{$id} + '' ); counter{$id} = setTimeout( "countDown{$id}()", 1000 ); } function stopCount{$id}(){ clearTimeout(counter{$id}) \$('#stop{$id}').hide(); \$('#start{$id}').show(); } function updateReloadArea{$id}(){ countDownTime{$id} = countDownInterval{$id} + 1; reloadTimes{$id} = reloadTimes{$id} + 1; \$('#reload{$id}').load('{$url}&R='+reloadTimes{$id}, function() { countDown{$id} (); }); } \$().ready ( function () { countDown{$id} (); }); JS; $html = 'Next ' . Tag::hRef("javascript:countDownTime{$id}=0", 'refresh', ['title' => 'Click here to refresh now.', 'class' => $css]) . ' in ' . Tag::hTag('span', ['id' => "countDownText{$id}", 'class' => $css]) . $numOfSeconds . Tag::_hTag('span') . ' seconds ' . Tag::hRef("javascript:stopCount{$id}()", 'Stop', ['id' => "stop{$id}", 'title' => 'Click here to stop the timer.', 'class' => $css]) . Tag::hRef("javascript:countDown{$id}()", 'Start', ['id' => "start{$id}", 'title' => 'Click here to start the timer.', 'class' => $css]) . '<br/>' . Tag::div(['id' => "reload{$id}", 'class' => $css]) . call_user_func($callBack) . Tag::_div(); return JS::library(JS::JQUERY) . JS::javaScript($js) . $html; }
public function manageUsersToGroups() { $key = Request::get('KEY'); if ($key == '') { return 'KEY missing'; } $userSql = DB::driver() == DB::MYSQL ? self::USER_SQL_MYSQL : self::USER_SQL_SQLITE; $row = DB::oneRow(DB::DEF, 'SELECT * FROM tblGroup WHERE fldGroupID=?', $key); return Tag::hTag('h4') . Tag::e('Editing Users in ' . $row['fldName'] . '(' . $row['fldLongName'] . ')') . Tag::_hTag('h4') . CRUD::factory('tblUserGroupMap', ['topPager' => false, 'where' => ['fldGroupID' => $key]])->setColDisplay('fldUserID', [CRUD::SELECT, $userSql, true])->setColDisplay('fldGroupID', CRUD::DISPLAY)->copyVarsFromRequest('KEY')->index(); }
static function library($lib, $force = false) { if (!$force && isset(self::$displayedLibraries[$lib])) { return ''; } self::$displayedLibraries[$lib] = true; if (!preg_match('/^http(s)?:\\/\\/.*$/i', $lib)) { $lib = Cfg::get('js_url') . '/' . $lib; } if (preg_match('/^.*\\.js$/i', $lib) || preg_match('/^.*\\jsapi$/i', $lib)) { return Tag::hTag('script', ['type' => 'text/javascript', 'src' => $lib]) . Tag::_hTag('script') . self::$LF; } else { if (preg_match('/^.*\\.css$/i', $lib)) { $attribs = ['type' => 'text/css', 'href' => $lib, 'rel' => 'stylesheet']; if (preg_match('/^.*\\.print\\.css$/i', $lib)) { $attribs['media'] = 'print'; } return Tag::hTag('link', $attribs) . Tag::_hTag('link') . self::$LF; } else { return ''; } } }
/** * Calls the function specified by the incoming ajax request * */ public function execute() { if ($this->executed) { return; } $this->executed = true; if (($function = Request::get('plxf')) == '') { return; } $args = Request::get('plxa', array()); if (function_exists("json_decode")) { foreach ($args as &$val) { if (preg_match('/<plxobj[^>]*>(.|\\n|\\t|\\r)*?<\\/plxobj>/', $val, $matches)) { $val = json_decode(substr($matches[0], 8, -9)); } } } $response = ''; $parts = explode("::", $function); switch (count($parts)) { // Function Call case 1: $response = call_user_func_array($function, $args); break; // Object Call // Object Call case 2: if (isset($this->objectMethods[$parts[0]])) { $objectInfo = $this->objectMethods[$parts[0]]; $response = call_user_func_array(array($objectInfo['ref'], $parts[1]), $args); } else { $response = call_user_func_array(array($parts[0], $parts[1]), $args); } break; default: $response = ''; break; } if (is_bool($response)) { $response = (int) $response; } else { if (function_exists("json_encode") && (is_array($response) || is_object($response))) { $response = json_encode($response); } } echo Tag::hTag('phplivex'), $response, Tag::_hTag('phplivex'); exit; }