Exemplo n.º 1
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;
 }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
0
    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;
    }
Exemplo n.º 4
0
 protected function toHidden($exemptVars)
 {
     $hiddenVars = $this->respVars->del($this->navVar)->toHidden(false);
     foreach ($this->formVars as $key => $val) {
         if (!in_array($key, $exemptVars)) {
             $hiddenVars .= Tag::hidden($this->toFormName($key), $val);
         }
     }
     return $hiddenVars;
 }
Exemplo n.º 5
0
 public static function icon($email, $size = 24, $rating = 'PG', $type = null)
 {
     if ($type == null) {
         $type = self::$gravType;
     }
     $gHash = md5(strtolower(trim($email)));
     $tPath = Cfg::get('tmp_path');
     $fName = 'GRAV' . $size . $type . $gHash . '.png';
     $fPath = $tPath . '/' . $fName;
     // Locally Caches the gavatar image
     if (!file_exists($fPath)) {
         copy(sprintf(self::ICO, self::$URL, $gHash, $size, $rating, $type), $fPath);
         if (!file_exists($fPath)) {
             return Tag::img(sprintf(self::ICO, self::$URL, $gHash, $size, $rating, $type));
         }
     }
     return Tag::img(Cfg::get('site_url') . '/' . basename($tPath) . '/' . $fName);
 }
Exemplo n.º 6
0
 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();
 }
Exemplo n.º 7
0
 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 '';
         }
     }
 }
Exemplo n.º 8
0
 /**
  * @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;
 }
Exemplo n.º 9
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();
 }
Exemplo n.º 10
0
 /**
  * @return string
  */
 public function toHidden($guard = true)
 {
     if ($guard) {
         $this->addCSRFGuard();
     }
     TamperGuard::add($this);
     $html = '';
     $this->convertFormVarsToAssocArray();
     foreach ($this->intermediateHiddenArray as $key => $val) {
         $cypherText = $this->encryptValue($key, $val);
         $html .= Tag::hidden($key, $cypherText);
     }
     TamperGuard::del($this);
     if ($guard) {
         $this->delCSRFGuard();
     }
     return $html;
 }
Exemplo n.º 11
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;
 }
Exemplo n.º 12
0
 /**
  * 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');
 }
Exemplo n.º 13
0
    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;
    }
Exemplo n.º 14
0
 /** 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;
 }
Exemplo n.º 15
0
 public function fileChecksum()
 {
     $messageArray = [];
     $dirList = PHPExt::dirSearch(Cfg::get('site_path'), '/^[^_].*$/');
     $len = strlen(Cfg::get('site_path')) + 1;
     foreach ($dirList as &$path) {
         $path = substr($path, $len);
     }
     $tab = new DBTable(DB::DEF, 'SELECT * FROM tblFileCheck');
     foreach ($tab as $row) {
         if (in_array($row['fldFileName'], $dirList)) {
             $fullPath = Cfg::get('site_path') . '/' . $row['fldFileName'];
             $fileSize = filesize($fullPath);
             $sha1 = sha1_file($fullPath);
             if ($fileSize != $row['fldSize']) {
                 $messageArray[$row['fldFileName']] = 'Mismatch file size. was: ' . $row['fldSize'] . ' now: ' . $fileSize;
             } else {
                 if ($sha1 != $row['fldCRC']) {
                     $messageArray[$row['fldFileName']] = 'Mismatch SHA1. was: ' . $row['fldCRC'] . ' now: ' . $sha1;
                 }
             }
         } else {
             $messageArray[$row['fldFileName']] = 'File deleted';
         }
     }
     $oldFileList = $tab->getColumn('fldFileName');
     foreach ($dirList as $fileName) {
         if (!in_array($fileName, $oldFileList)) {
             $messageArray[$fileName] = 'New file';
         }
     }
     $html = '';
     if (count($messageArray) != 0) {
         foreach ($messageArray as $key => $val) {
             $html .= $key . ': ' . $val . '<br/>';
         }
     } else {
         $html = 'No Changes<br/>';
     }
     $rebaseButton = Tag::linkButton('?' . Response::factory()->action(__CLASS__ . '->' . __FUNCTION__ . 'Rebase()'), 'Rebase');
     return $rebaseButton . '<br/>' . $html . $rebaseButton;
 }
Exemplo n.º 16
0
    public static function errorHandler($errno, $errstr, $errfile, $errline)
    {
        if (!preg_match('/^.*\\/3rdparty\\/.*$/', $errfile)) {
            self::$log->error("{$errno}-{$errstr}: {$errfile}({$errline})");
        }
        switch ($errno) {
            case E_STRICT:
            case E_USER_WARNING:
                return;
            default:
                if (self::get('debug')) {
                    $errMsg = sprintf('(!) Fatal error: %s in %s on line: %s', $errstr, $errfile, $errline);
                    $html = Tag::table(['cellpadding' => 3, 'cellspacing' => 0, 'border' => 1]) . Tag::tr(['bgcolor' => 'silver']) . Tag::th(['colspan' => 4, 'align' => 'left']) . $errMsg . Tag::_th() . Tag::_tr() . Tag::tr(['bgcolor' => 'silver']) . Tag::th() . 'Stk' . Tag::_th() . Tag::th() . 'File' . Tag::_th() . Tag::th() . 'Line' . Tag::_th() . Tag::th() . 'Function' . Tag::_th() . Tag::_tr();
                    foreach (debug_backtrace() as $idx => $row) {
                        if ($idx == 0) {
                            continue;
                        }
                        if (isset($row['file'])) {
                            $file = basename($row['file']);
                            $title = $row['file'];
                        } else {
                            $file = '&nbsp;';
                            $title = ' ';
                        }
                        $line = isset($row['line']) ? $row['line'] : '&nbsp;';
                        $function = $row['function'];
                        if (isset($row['class'])) {
                            $function = $row['class'] . $row['type'] . $function;
                        }
                        $style = $idx % 2 == 0 ? [] : ['bgcolor' => 'yellow'];
                        $html .= Tag::tr($style) . Tag::td() . $idx . Tag::_td() . Tag::td(['title' => $title]) . $file . Tag::_td() . Tag::td() . $line . Tag::_td() . Tag::td() . $function . Tag::_td() . Tag::_tr();
                    }
                    $html .= Tag::_table();
                    $html = str_replace(["\n", "'"], ['', "\\'"], $html);
                    $url = self::siteUrl() . '/ajax.php?' . Response::factory()->action('\\Jackbooted\\Html\\WebPage->blank()')->toUrl();
                    $js = <<<JS
                    \$().ready(function() {
                        newWindow = window.open ( '{$url}','Error Output','height=300,width=700');
                        var tmp = newWindow.document;
                        tmp.write ( '<html><head><title>{$errMsg}</title>' );
                        tmp.write ( '<style type="text/css">' );
                        tmp.write ( '</style>');
                        tmp.write ( '</head><body>');
                        tmp.write ( '{$html}' );
                        tmp.write ( '</body></html>');
                        tmp.close();
                    });
JS;
                    echo JS::library(JS::JQUERY) . JS::javaScript($js) . $errMsg;
                }
                break;
        }
    }
Exemplo n.º 17
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;
 }
Exemplo n.º 18
0
 protected function getDisplayName()
 {
     $name = G::get('fldFirstName') . ' ' . G::get('fldLastName');
     if (G::isLoggedIn() && G::accessLevel(Privileges::getSecurityLevel('SITE ADMIN'))) {
         $uName = Tag::hRef('superadmin.php', $name, ['class' => 'admin']);
     } else {
         $uName = Tag::e($name);
     }
     return $uName;
 }
Exemplo n.º 19
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();
 }
Exemplo n.º 20
0
 public function index()
 {
     $sitePath = Cfg::get('site_path');
     $sitePathLen = strlen($sitePath);
     $resp = Response::factory()->action(__CLASS__ . '->zoom()');
     $html = Tag::ul();
     foreach ($this->findImages($sitePath) as $item) {
         $relItemName = substr($item, $sitePathLen);
         $html .= Tag::li() . Tag::hRef('?' . $resp->set('url', $relItemName)->toUrl(), $relItemName) . Tag::_li();
     }
     $html .= Tag::_ul();
     return $html;
 }
Exemplo n.º 21
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);
    }
Exemplo n.º 22
0
 /**
  * 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;
 }
Exemplo n.º 23
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;
 }