Пример #1
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;
    }
Пример #2
0
 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;
 }
Пример #3
0
    private function loginForm()
    {
        $jsUrl = Cfg::get('js_url');
        $jQuery = <<<JS
    \$().ready(function() {
        \$('#hoverimage').hover ( function () { \$('#extralinks').fadeIn('fast'); },
                                 function () { setTimeout("\$('#extralinks').fadeOut();", 3000 ); });
        \$('a.facebox').facebox({closeImage:   '{$jsUrl}/images/closelabel.png',
                                loadingImage: '{$jsUrl}/images/loading.gif'

        });
    });
JS;
        $formName = 'FancyLogin_loginForm';
        $valid = Validator::factory($formName, 'LF')->addExists(self::LOGIN_FNAME, 'Email field must not be empty')->addExists(self::PASSW_FNAME, 'Password field must not be empty');
        $resp = new Response();
        $html = JS::library(JS::JQUERY) . JS::libraryWithDependancies(JS::FACEBOX) . JS::javaScript($jQuery) . Tag::table() . Tag::tr() . Tag::td(['id' => 'hoverimage', 'class' => 'login', 'nowrap' => 'nowrap']) . $valid->toHtml() . Tag::form(['id' => $formName, 'name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $resp->set(self::ACTION, __CLASS__ . '->checkLogin()')->toHidden() . Tag::table() . Tag::tr() . Tag::td() . 'Email' . Tag::_td() . Tag::td() . Tag::text(self::LOGIN_FNAME, ['size' => 10, 'style' => 'opacity:0.5;filter:alpha(opacity=50)']) . Tag::_td() . Tag::td() . 'Password:'******'size' => 10, 'style' => 'opacity:0.5;filter:alpha(opacity=50)']) . Tag::_td() . Tag::td() . Tag::submit('Go') . Tag::_td() . Tag::_tr() . Tag::_table() . Tag::_form() . Tag::_td() . Tag::_tr() . Tag::tr() . Tag::td(['id' => 'extralinks', 'style' => 'display: none;']) . Tag::ul(['id' => 'vertMenu']);
        if (Cfg::get('jb_self_register', false)) {
            $html .= Tag::li() . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->newRegistration()')->toUrl(), 'Register New Account', ['class' => 'facebox']) . Tag::_li();
        }
        $html .= Tag::li() . Tag::hRef('ajax.php?' . $resp->action(__CLASS__ . '->forgotPassword()')->toUrl(), 'Forgot My Password', ['class' => 'facebox']) . Tag::_li() . Tag::_ul() . Tag::_td() . Tag::_tr() . Tag::_table();
        return $html;
    }
Пример #4
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();
 }
Пример #5
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;
 }
Пример #6
0
 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?")']);
 }
Пример #7
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;
 }
Пример #8
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();
 }
Пример #9
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;
    }
Пример #10
0
    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;
    }