示例#1
0
    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();
    }
示例#2
0
 public function reset()
 {
     $resp = MenuUtils::responseObject();
     $html = '';
     $html .= '<H4>***WARNING*** You are about to reset configuration</h4>' . Tag::form() . $resp->action(sprintf('%s->%sSave()', __CLASS__, __FUNCTION__))->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Please type "RESET CONFIG" without the quotes for finalise reset.' . Tag::_td() . Tag::td() . Tag::text('fldConfirm') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2]) . Tag::submit('Confirm Reset') . Tag::linkButton('?' . $resp->action(__CLASS__ . '->resetCancelled()'), 'Cancel Reset') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }
示例#3
0
 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;
 }
示例#4
0
 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();
 }
示例#5
0
 public function forgotPassword()
 {
     // Initialise the $msg and $action and $disclaimer variables
     $formName = 'FancyLogin_forgotPassword';
     $valid = Validator::factory($formName, 'FP')->addExists('fldEmail', 'Email field is empty. Please insert valid email and resubmit')->addEmail('fldEmail', 'Email is in valid format. Must be of the form a@b.com');
     $html = $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . Response::factory()->set(self::ACTION, __CLASS__ . '->sendPW()')->toHidden() . Tag::table(['align' => 'center', 'border' => 0, 'cellspacing' => 0, 'cellpadding' => 2]) . Tag::tr() . Tag::td() . 'Email' . Tag::_td() . Tag::td() . Tag::text('fldEmail') . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2, 'align' => 'center']) . 'Your Password will be reset and sent to you via email you have provided' . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2, 'align' => 'center']) . Tag::submit('Send Password') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }
示例#6
0
    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') . '&nbsp;&nbsp;&nbsp;&nbsp;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') . '&nbsp;&nbsp;&nbsp;&nbsp;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);
    }
示例#7
0
 protected function askCommand()
 {
     $text = Request::get('CMDTEXT');
     $html = '<b>Direct Command Access</b><br/>' . Tag::form() . Response::factory()->action(__CLASS__ . '->runCommand()')->toHidden() . Tag::textArea('CMDTEXT', $text, ['rows' => 5, 'cols' => 40]) . '<br/>' . Tag::submit('Go') . Tag::_form();
     return $html;
 }
示例#8
0
 private function insertForm()
 {
     if (!$this->canInsert) {
         return '';
     }
     $this->resp->set($this->action, 'insertRows');
     $html = Tag::form(['action' => $this->formAction]) . Tag::text('rows', ['value' => '1', 'size' => '3']) . $this->resp->toHidden() . Tag::submit('Insert') . Tag::_form();
     return $html;
 }
示例#9
0
 public function forgotPassword()
 {
     // Initialise the $msg and $action and $disclaimer variables
     $formName = 'Login_forgotPassword';
     $valid = Validator::factory($formName, 'FP')->addExists('fldEmail', 'Email field is empty. Please insert valid email and resubmit')->addEmail('fldEmail', 'Email is in valid format. Must be of the form a@b.com');
     $html = '<h2>Password Reset</h2>' . $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . Response::factory()->action(__CLASS__ . '->sendPW()')->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Email' . Tag::_td() . Tag::td() . Tag::text('fldEmail', ['title' => 'Your Password will be reset and sent to you via email you have provided']) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['align' => 'left']) . Tag::submit('Reset PW') . Tag::_td() . Tag::td(['align' => 'right']) . Tag::linkButton('?' . Response::factory()->action(__CLASS__ . '->index()')->toUrl(), 'Back to Login') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }
示例#10
0
 /**
  * @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]) . '&nbsp;Max Rows:&nbsp;' . 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 = '&nbsp;Rows:&nbsp;' . 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 . '&nbsp;' . join('&nbsp;&#183;&nbsp;', $html[0]) . '&nbsp;' . 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;']) . '&nbsp;' . join('&nbsp;&#183;&nbsp;', $html[1]) . '&nbsp;' . $nextPage . $lastPage . $pageSizeHtml . Tag::_form() . Tag::_div();
 }
示例#11
0
 public function newUser()
 {
     $formName = 'Admin_newUser';
     $valid = Validator::factory($formName)->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');
     $html = $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . Response::factory()->action(__CLASS__ . '->newUserSave()')->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Email:' . Tag::_td() . Tag::td() . Tag::text('fldEmail', Request::get('fldEmail')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'First&nbsp;Name:' . Tag::_td() . Tag::td() . Tag::text('fldFirstName', Request::get('fldFirstName')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td() . 'Last&nbsp;Name:' . Tag::_td() . Tag::td() . Tag::text('fldLastName', Request::get('fldLastName')) . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['colspan' => 2]) . Tag::submit('Create Account') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form();
     return $html;
 }