public function index() { $schedulerList = Scheduler::getList(true); $formName = 'SchedulerManager_index'; $id = 'SchedulerManager_table'; $js = "\$().ready ( function () {\n"; $valid = Validator::factory($formName); $html = Tag::table(['id' => $id]) . Tag::tr() . Tag::th() . 'Upd' . Tag::_th() . Tag::th() . 'Del' . Tag::_th() . Tag::th() . 'Command' . Tag::_th() . Tag::th() . 'Start Date' . Tag::_th() . Tag::th() . 'Cron' . Tag::_th() . Tag::th() . 'Active' . Tag::_th() . Tag::th() . 'Last Run' . Tag::_th() . Tag::_tr(); if (count($schedulerList) == 0) { $html .= Tag::tr() . Tag::td(['colspan' => 20]) . 'No Scheduled Tasks' . Tag::_td() . Tag::_tr(); } else { $js .= <<<JS \$('input[type=checkbox][name^=fldUpd]').shiftClick(); JS; $rowIdx = 0; foreach ($schedulerList as $idx => $schedulerItem) { $row = '_' . $idx; $valid->addExists('fldCommand' . $row, 'Command must exist')->addExists('fldCron' . $row, 'Interval must exist'); $js .= <<<JS \$( '#fldStartDate{$row}' ).datetimepicker({ dateFormat: 'yy-mm-dd', timeFormat: 'HH:mm' }); JS; $lastRun = $schedulerItem->lastRun == '' ? '*Never*' : $schedulerItem->lastRun; $html .= Tag::tr() . Tag::td() . Tag::checkBox('fldUpd[]', $idx, false, ['id' => 'U' . $rowIdx]) . Tag::_td() . Tag::td() . Tag::linkButton('?' . Response::factory()->set('fldID', $idx)->action(__CLASS__ . '->deleteItem()'), 'Delete', ['onClick' => "confirm('Are you sure?')"]) . Tag::_td() . Tag::td(['width' => '100%', 'nowrap' => 'nowrap']) . Tag::text('fldCommand' . $row, $schedulerItem->cmd, ['style' => 'width:100%;', 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Tag::text('fldStartDate' . $row, $schedulerItem->start, ['id' => 'fldStartDate' . $row, 'size' => '18', 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Tag::text('fldCron' . $row, $schedulerItem->cron, ['onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Lists::select('fldActive' . $row, ['Yes', 'No'], ['default' => $schedulerItem->active, 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . $lastRun . Tag::_td() . Tag::_tr(); $rowIdx++; } } $html .= Tag::_table(); $js .= '});'; return JS::libraryWithDependancies(JS::JQUERY_UI_DATETIME) . JS::library('jquery.shiftclick.js') . JS::javaScript($js) . $valid->toHtml() . Widget::styleTable('#' . $id) . Tag::form(['name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $html . Response::factory()->action(__CLASS__ . '->save()')->toHidden() . Tag::submit('Save') . Tag::linkButton('?' . Response::factory()->action(__CLASS__ . '->newItem()'), 'New Item') . Tag::_form(); }
public static function menu() { if (Privileges::access(__METHOD__) !== true || !G::isLoggedIn()) { return ''; } $html = Tag::hTag('b') . 'Database Menu' . Tag::_hTag('b') . Tag::form(['method' => 'get']) . Response::factory()->action(__CLASS__ . '->index()')->toHidden(false) . Lists::select('tblName', self::TABLES_SQL, ['size' => '10', 'onClick' => 'submit();']) . Tag::_form(); return $html; }
public function browse() { $classes = array(); foreach (ClassLocator::getDefaultClassLocator()->getLocatorArray() as $className => $fileName) { if (preg_match(AutoLoader::THIRD_PARTY_REGEX, $fileName)) { continue; } $classes[$fileName] = $className; } asort($classes); $html = '<H4>Below are a list of classes, Click on class to view source</h4>' . Tag::form(array('method' => 'get')) . MenuUtils::responseObject()->action(__CLASS__ . '->' . __FUNCTION__ . '()')->toHidden(false) . Lists::select('fldFileName', $classes, array('size' => '7', 'onClick' => 'submit();')) . Tag::_form(); return $html . $this->sourceCode(); }
public function editConfigForm($currentConfigKey) { return JS::library(JS::JQUERY) . JS::javaScript("\$().ready( function(){ \$('#fldCfgKey').focus (); });") . Tag::hTag('b') . 'Config Keys' . Tag::_hTag('b') . Tag::form(['method' => 'get']) . MenuUtils::responseObject()->action(self::DEF)->toHidden(false) . Lists::select('fldCfgKey', 'SELECT DISTINCT fldKey FROM tblConfig ORDER BY 1', ['style' => 'height: 100%', 'default' => $currentConfigKey, 'size' => 26, 'id' => 'fldCfgKey', 'onChange' => 'submit();']) . Tag::_form() . '<br/>' . Tag::hRef('?' . MenuUtils::responseObject()->action(__CLASS__ . '->reload()')->toUrl(), 'Reload Config', ['title' => 'reloads the configuration', 'onClick' => 'return confirm("Are You Sure you want to reload all configuration?")']); }
/** Creates a Dual Select windows * @param string $lName Left Column name * @param array $lList Left Column name * @param string $rName Right Column name * @param array $rList Right Column name * @param int $ht Height * @returns String The Html pf a dual select */ public static function dualSelect($lName, $lList, $rName, $rList, $ht = 8) { $title = array("title" => "Select items is the left list to move to the selected list. " . "Move items in the right list to remove from the selected list. " . "Select buttons in the moddle to move all the items in the list"); $msg = ""; $msg .= Tag::table($title); $msg .= Tag::tr(); $msg .= Tag::td("align=center"); $msg .= "Out of List<br>"; $msg .= Lists::select($lName, $lList, "onChange=\"selMove ( '{$lName}','{$rName}',false );\" Size={$ht} Multiple"); $msg .= Tag::_td(); $msg .= Tag::td("valign=middle"); $msg .= "<br>" . Tag::button(">>", "onClick=\"selMove ( '{$lName}','{$rName}',true );\""); $msg .= "<br>" . Tag::button("<<", "onClick=\"selMove ( '{$rName}','{$lName}',true );\""); $msg .= Tag::_td(); $msg .= Tag::td("align=center"); $msg .= "In the List<br>"; $msg .= Lists::select($rName, $rList, "onChange=\"selMove ( '{$rName}','{$lName}',false );\" Size={$ht} Multiple"); $msg .= Tag::hidden($rName . "Result"); $msg .= Tag::_td(); $msg .= Tag::_tr(); $msg .= Tag::_table(); return $msg; }
private function renderValue($rowIdx, $colName, $value) { $html = ''; $name = $this->gridTag . '[' . $rowIdx . '][' . $colName . ']'; $autoUpdateJS = "autoUpdate({$rowIdx},'{$this->updTag}','{$this->delTag}','{$this->submitId}');"; $id = $this->gridTag . '_' . $rowIdx . '_' . $colName; $updClickAttrib = ['onClick' => $autoUpdateJS, 'id' => $id]; $updCheckAttrib = ['onChange' => $autoUpdateJS, 'id' => $id]; $type = $this->getColumnType($colName); switch ($type) { case self::NONE: break; case self::DISPLAY: $html .= $value == '' ? ' ' : Tag::e($value); break; case self::HIDDEN: $this->resp->set($name, $value); break; case self::RADIO: $dispList = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : null; $updCheckAttrib['default'] = $value; $html .= Tag::table() . Tag::tr() . Tag::td(['nowrap' => 'nowrap']) . implode(Tag::_td() . Tag::td(['nowrap' => 'nowrap']), Lists::radio($name, $dispList, $updCheckAttrib)) . Tag::_td() . Tag::_tr() . Tag::_table(); break; case self::SELECT: $dispList = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : null; $blankLine = isset($this->displayType[$colName][2]) ? $this->displayType[$colName][2] : false; $updCheckAttrib['default'] = $value; $updCheckAttrib['hasBlank'] = $blankLine; $html .= Lists::select($name, $dispList, $updCheckAttrib); break; case self::CHECKBOX: $checkValue = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : 'YES'; $html .= Tag::checkBox($name, $checkValue, $value == $checkValue, $updClickAttrib); break; case self::TIMESTAMP: $attribs = array_merge($updCheckAttrib, $this->cellAttributes[$colName]); $attribs['value'] = strftime('%Y-%m-%d %H:%M:%S', (int) $value); $attribs['size'] = strlen($attribs['value']) + 1; $html .= Tag::text($name, $attribs); break; case self::ENCTEXT: $value = Cryptography::de((string) $value); // Fall through to output text field // Fall through to output text field case self::TEXT: default: $updCheckAttrib['value'] = (string) $value; $html .= Tag::text($name, array_merge($updCheckAttrib, $this->cellAttributes[$colName])); break; } if (!in_array($type, [self::HIDDEN, self::NONE])) { $html = Tag::td() . $html . Tag::_td(); } return $html; }
/** * @return string */ public function toHtml() { $this->auditStartRow(); $rowsPerPage = intval($this->getPageSize()); $startingRow = intval($this->getStart()); $startingPage = intval($this->get(self::STARTING_PAGE)); $totalRows = intval($this->getRows()); $saveStartingRow = intval($this->getStart()); if ($rowsPerPage <= 0) { $rowsPerPage = self::$pagination[self::ROWS_PER_PAGE]; } // Not enough rows for pagination if ($totalRows <= $rowsPerPage) { if ($this->dispPageSize && $totalRows > 10) { return Tag::div($this->attribs) . Tag::form(['method' => 'get']) . $this->toHidden([self::ROWS_PER_PAGE]) . ' Max Rows: ' . Lists::select($this->toFormName(self::ROWS_PER_PAGE), self::$itemsPerPageList, ['default' => $rowsPerPage, 'onChange' => 'submit();']) . Tag::_form() . Tag::_div(); } else { return ''; } } if ($startingPage > 0) { $startingRow = ($startingPage - 1) * $rowsPerPage; $this->set(self::STARTING_PAGE, 0); } if ($startingRow >= $totalRows) { $startingRow = $totalRows - 1; } $pageContainingStartRow = intval($startingRow / $rowsPerPage); $this->set(self::SQL_START, $rowsPerPage * $pageContainingStartRow); // Get number of pages $numberOfPages = intval($totalRows / $rowsPerPage); if ($totalRows % $rowsPerPage != 0) { $numberOfPages++; } $previousPage = ''; $nextPage = ''; $firstPage = ''; $lastPage = ''; $pageSizeHtml = ''; $html = [[], []]; // This is the navigation from the current page forward for ($currentPage = $pageContainingStartRow + 1, $incr = 1; $currentPage < $numberOfPages - 1; $currentPage += $incr) { $startingRowForThisPage = $currentPage * $rowsPerPage; $currentPageDisplay = $currentPage + 1; $this->set(self::STARTING_ROW, $startingRowForThisPage); $html[1][] = Tag::hRef($this->toUrl(), number_format($currentPageDisplay), ['title' => 'Go to Page ' . $currentPageDisplay, 'class' => $this->styles[self::PAGE_LINK_CLASS]]); $incr *= count($html[1]); } // This is the navigation for next and last page if ($pageContainingStartRow + 1 < $numberOfPages) { $this->setStart($rowsPerPage * ($numberOfPages - 1)); $lastPage = Tag::button('>> ' . number_format($numberOfPages), ['onclick' => "location.href='" . $this->toUrl() . "';return true;", 'title' => 'Go to Last Page - ' . $numberOfPages, 'class' => $this->styles[self::PAGE_BUTTON_CLASS]]); $this->setStart($rowsPerPage * ($pageContainingStartRow + 1)); $nextPage = Tag::button('>', ['onclick' => "location.href='" . $this->toUrl() . "';return true;", 'title' => 'Go to Next Page - ' . ($pageContainingStartRow + 2), 'class' => $this->styles[self::PAGE_BUTTON_CLASS]]); } // Navigation for the current page nackwards for ($currentPage = $pageContainingStartRow - 1, $incr = 1; $currentPage > 0; $currentPage -= $incr) { $startingRowForThisPage = $currentPage * $rowsPerPage; $currentPageDisplay = $currentPage + 1; $this->setStart($startingRowForThisPage); $html[0][] = Tag::hRef($this->toUrl(), number_format($currentPageDisplay), ['title' => 'Go to Page ' . $currentPageDisplay, 'class' => $this->styles[self::PAGE_LINK_CLASS]]); $incr *= count($html[0]); } // Reverse the array so that it appears in correct order for pagination $html[0] = array_reverse($html[0]); // Navigation for previous and first pages if ($pageContainingStartRow != 0) { // Calculate navigation for first page $this->setStart(0); $firstPage = Tag::button('<< 1', ['onclick' => "location.href='" . $this->toUrl() . "';return true;", 'title' => 'Go to First Page - 1', 'class' => $this->styles[self::PAGE_BUTTON_CLASS]]); // Calculate navigation for previous page $this->setStart($rowsPerPage * ($pageContainingStartRow - 1)); $previousPage = Tag::button('< ', ['onclick' => "location.href='" . $this->toUrl() . "';return true;", 'title' => 'Go to Previous Page - ' . ($pageContainingStartRow - 1), 'class' => $this->styles[self::PAGE_BUTTON_CLASS]]); } $this->setStart($saveStartingRow); $curPage = (string) ($pageContainingStartRow + 1); $exemptVars = [self::STARTING_PAGE]; // Create the drop down to set the number of rows displayed per page if ($this->dispPageSize) { $exemptVars[] = self::ROWS_PER_PAGE; $pageSizeHtml = ' Rows: ' . Lists::select($this->toFormName(self::ROWS_PER_PAGE), self::$itemsPerPageList, ['default' => $rowsPerPage, 'title' => 'This changes the number of rows to display', 'onChange' => 'submit();']); } return Tag::div($this->attribs) . Tag::form(['method' => 'get']) . $this->toHidden($exemptVars) . $firstPage . $previousPage . ' ' . join(' · ', $html[0]) . ' ' . Tag::text($this->toFormName(self::STARTING_PAGE), ['value' => $curPage, 'align' => 'middle', 'size' => 1 + max(1, strlen($curPage) - 1), 'title' => 'Manually enter the page number that you want and press enter', 'style' => 'font-weight:bold;']) . ' ' . join(' · ', $html[1]) . ' ' . $nextPage . $lastPage . $pageSizeHtml . Tag::_form() . Tag::_div(); }
public function editAccount() { $resp = new Response(); $uid = G::get('fldUserID'); $html = ''; $props = []; $jsUrl = Cfg::get('js_url'); $jQuery = <<<JS \$().ready(function() { \$('a.facebox').facebox({closeImage: '{$jsUrl}/images/closelabel.png', loadingImage: '{$jsUrl}/images/loading.gif' }); }); JS; $userSql = DB::driver() == DB::MYSQL ? self::USER_SQL_MYSQL : self::USER_SQL_SQLITE; if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) { $uid = Request::get('fldUserID', G::get('fldUserID')); $props['where'] = ['fldUserID' => G::get('fldUserID')]; $html .= Tag::form() . $resp->action(sprintf('%s->%s()', __CLASS__, __FUNCTION__))->toHidden() . Tag::table() . Tag::tr() . Tag::th() . 'User to edit' . Tag::_th() . Tag::td() . Lists::select('fldUserID', $userSql, ['onChange' => 'submit()', 'default' => $uid]) . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form(); } $formName = 'Admin_editAccount'; $valid = Validator::factory($formName)->addEqual('fldPassword', 'fldPassword_CHK', 'Your passwords do not match')->addLength('fldPassword', 'Password must be at least 6 characters', 6, null, true)->addExists('fldFirstName', 'You must enter your first name')->addExists('fldLastName', 'You must enter your last name'); $row = DB::oneRow(DB::DEF, 'SELECT * FROM tblUser WHERE fldUserID=?', $uid); $html .= '<h2>Edit User Account</h2>' . $valid->toHtml() . Tag::form(['name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $resp->action(sprintf('%s->%sSave()', __CLASS__, __FUNCTION__))->set('fldUserID', $uid)->toHidden() . Tag::table(); $html .= Tag::tr() . Tag::td() . Tag::table() . Tag::tr() . Tag::td() . 'User Name/Email' . Tag::_td() . Tag::td() . Tag::text('fldUser', $row['fldUser']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Old Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword_OLD') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Confirm Password' . Tag::_td() . Tag::td() . Tag::password('fldPassword_CHK') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Title' . Tag::_td() . Tag::td() . Tag::text('fldSalutation', $row['fldSalutation']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'First Name' . Tag::_td() . Tag::td() . Tag::text('fldFirstName', $row['fldFirstName']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Last Name' . Tag::_td() . Tag::td() . Tag::text('fldLastName', $row['fldLastName']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Time Zone' . Tag::_td() . Tag::td() . Lists::select('fldTimeZone', self::TZ_SQL, ['default' => $row['fldTimeZone']]) . Tag::_td() . Tag::_tr(); if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) { $html .= Tag::tr() . Tag::td() . 'Security Level' . Tag::_td() . Tag::td() . Lists::select('fldLevel', self::LEVEL_SQL, ['default' => $row['fldLevel']]) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Login Fails' . Tag::_td() . Tag::td() . Tag::text('fldFails', $row['fldFails']) . Tag::_td() . Tag::_tr(); } else { $html .= Tag::tr() . Tag::td() . 'Security Level' . Tag::_td() . Tag::td() . Privileges::getSecurityLevel($row['fldLevel']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Login Fails' . Tag::_td() . Tag::td() . $row['fldFails'] . Tag::_td() . Tag::_tr(); } $html .= Tag::tr() . Tag::td(['colspan' => 2]) . Tag::submit('Save') . Tag::_td() . Tag::_tr(); if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) { $html .= Tag::tr() . Tag::td(['colspan' => 2]) . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->newUser()')->toUrl(), 'Create New User', ['class' => 'facebox']) . Tag::_td() . Tag::_tr(); } $html .= Tag::_table() . Tag::_td() . Tag::td(['valign' => 'top', 'align' => 'center']) . Tag::table() . Tag::tr() . Tag::td(['valign' => 'top', 'align' => 'center']) . Gravatar::icon($row['fldUser'], 128) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . Tag::linkButton(Gravatar::getURL(), 'Change Picture', ['target' => '_blank', 'title' => 'your gravatar is associated with your email address ' . $row['fldUser'] . ' (up to 24 hrs to change)']) . Tag::_td() . Tag::_tr(); if (G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN')) && $uid != G::get('fldUserID')) { $name = $row['fldFirstName'] . ' ' . $row['fldLastName']; $html .= Tag::tr() . Tag::td() . Tag::linkButton('?' . $resp->action(__CLASS__ . '->loginAs()')->set('fldUser', $row['fldUser'])->toUrl(), 'Login as this User', ['title' => "Login as this user ({$name})"]) . Tag::_td() . Tag::_tr(); } $html .= Tag::_table() . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form(); return JS::library(JS::JQUERY) . JS::libraryWithDependancies(JS::FACEBOX) . JS::javaScript($jQuery) . $html; }