Changeset 685 for trunk/lib


Ignore:
Timestamp:
May 23, 2019 6:40:04 PM (5 years ago)
Author:
anonymous
Message:

Various minor changes:

  • Allow $app->ohref() with no value to return a link to the current page (REQUEST_URI but without the QUERY_STRING).
  • Add some classes to HTML output to support Zurb Foundation 6.
  • Stop prepending scheme://host:port to URLs because we can't guess hte port at a proxy.
  • Include Auth_Simple.inc.php (copied from control.strangecode.com). $auth->login() now requires a callback funtion to verify credentials.
Location:
trunk/lib
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r683 r685  
    764764                switch ($m['type']) {
    765765                case MSG_ERR:
    766                     echo '<div data-alert class="sc-msg-error alert-box alert">' . $m['message'] . '<a href="#" class="close">&times;</a></div>';
     766                    echo '<div data-alert data-closable class="sc-msg-error alert-box callout alert">' . $m['message'] . '<a class="close close-button" aria-label="Dismiss alert" data-close><span aria-hidden="true">&times;</span></a></div>';
    767767                    break;
    768768
    769769                case MSG_WARNING:
    770                     echo '<div data-alert class="sc-msg-warning alert-box warning">' . $m['message'] . '<a href="#" class="close">&times;</a></div>';
     770                    echo '<div data-alert data-closable class="sc-msg-warning alert-box callout warning">' . $m['message'] . '<a class="close close-button" aria-label="Dismiss alert" data-close><span aria-hidden="true">&times;</span></a></div>';
    771771                    break;
    772772
    773773                case MSG_SUCCESS:
    774                     echo '<div data-alert class="sc-msg-success alert-box success">' . $m['message'] . '<a href="#" class="close">&times;</a></div>';
     774                    echo '<div data-alert data-closable class="sc-msg-success alert-box callout success">' . $m['message'] . '<a class="close close-button" aria-label="Dismiss alert" data-close><span aria-hidden="true">&times;</span></a></div>';
    775775                    break;
    776776
    777777                case MSG_NOTICE:
    778778                default:
    779                     echo '<div data-alert class="sc-msg-notice alert-box info">' . $m['message'] . '<a href="#" class="close">&times;</a></div>';
     779                    echo '<div data-alert data-closable class="sc-msg-notice alert-box callout primary info">' . $m['message'] . '<a class="close close-button" aria-label="Dismiss alert" data-close><span aria-hidden="true">&times;</span></a></div>';
    780780                    break;
    781781                }
     
    10791079     * @return string url with attached queries and, if not using cookies, the session id
    10801080     */
    1081     public function url($url, $carry_args=null, $always_include_sid=false, $include_csrf_token=false)
     1081    public function url($url='', $carry_args=null, $always_include_sid=false, $include_csrf_token=false)
    10821082    {
    10831083        if (!$this->running) {
     
    11181118        }
    11191119
     1120        // If the URL is empty, use REQUEST_URI without the QUERY_STRING.
     1121        if ('' == $url) {
     1122            $url = str_replace([getenv('QUERY_STRING'), '?'], '', getenv('REQUEST_URI'));
     1123        }
     1124
    11201125        // Get the first delimiter that is needed in the url.
    11211126        $delim = mb_strpos($url, '?') !== false ? ini_get('arg_separator.output') : '?';
     
    11411146        $url = $parts[0];
    11421147        $anchor = isset($parts[1]) ? $parts[1] : '';
    1143 
    11441148        // $anchor =
    11451149
     
    11771181        }
    11781182
     1183        if ('' == $url) {
     1184            $this->logMsg(sprintf('Generated empty URL. Args: %s', getDump(func_get_args())), LOG_NOTICE, __FILE__, __LINE__);
     1185        }
     1186
    11791187        return $url;
    11801188    }
     
    11891197     * @since   09 Dec 2005 17:58:45
    11901198     */
    1191     public function oHREF($url, $carry_args=null, $always_include_sid=false, $include_csrf_token=false)
     1199    public function oHREF($url='', $carry_args=null, $always_include_sid=false, $include_csrf_token=false)
    11921200    {
    11931201        // Process the URL.
     
    14061414        }
    14071415
    1408         if (preg_match('!^/!', $url)) {
    1409             // If relative URL is given, prepend site_url, which contains: scheme://hostname[:port]
    1410             $url = sprintf('%s%s', $this->getParam('site_url'), $url);
    1411         }
     1416        // FIXME: actually, it seems better to continue using a relative URL since we can't guess the port at the reverse proxy (e.g., port 3000 for browser-sync).
     1417        // if (preg_match('!^/!', $url)) {
     1418        //     // If relative URL is given, prepend site_url, which contains: scheme://hostname[:port]
     1419        //     $url = sprintf('%s%s', $this->getParam('site_url'), $url);k
     1420        // }
    14121421
    14131422        $url = $this->url($url, $carry_args, $always_include_sid);
  • trunk/lib/FormValidator.inc.php

    r665 r685  
    219219                    switch ($e['type']) {
    220220                    case MSG_ERR:
    221                         echo '<div data-alert class="sc-msg-error alert-box alert">' . $e['message'] . '<a href="#" class="close">&times;</a></div>';
     221                        echo '<div data-alert data-closable class="sc-msg-error alert-box callout alert">' . $e['message'] . '<a class="close close-button" aria-label="Dismiss alert" data-close><span aria-hidden="true">&times;</span></a></div>';
    222222                        break;
    223223
    224224                    case MSG_WARNING:
    225                         echo '<div data-alert class="sc-msg-warning alert-box warning">' . $e['message'] . '<a href="#" class="close">&times;</a></div>';
     225                        echo '<div data-alert data-closable class="sc-msg-warning alert-box callout warning">' . $e['message'] . '<a class="close close-button" aria-label="Dismiss alert" data-close><span aria-hidden="true">&times;</span></a></div>';
    226226                        break;
    227227
    228228                    case MSG_SUCCESS:
    229                         echo '<div data-alert class="sc-msg-success alert-box alert">' . $e['message'] . '<a href="#" class="close">&times;</a></div>';
     229                        echo '<div data-alert data-closable class="sc-msg-success alert-box callout success">' . $e['message'] . '<a class="close close-button" aria-label="Dismiss alert" data-close><span aria-hidden="true">&times;</span></a></div>';
    230230                        break;
    231231
    232232                    case MSG_NOTICE:
    233233                    default:
    234                         echo '<div data-alert class="sc-msg-notice alert-box info">' . $e['message'] . '<a href="#" class="close">&times;</a></div>';
     234                        echo '<div data-alert data-closable class="sc-msg-notice alert-box callout primary info">' . $e['message'] . '<a class="close close-button" aria-label="Dismiss alert" data-close><span aria-hidden="true">&times;</span></a></div>';
    235235                        break;
    236236                    }
  • trunk/lib/HTML.inc.php

    r666 r685  
    6464        if (!isset($buttons[0]) || !is_array($buttons[0])) {
    6565            $app =& App::getInstance();
    66             $app->logMsg(sprintf('Incorrect parameters passed to HTML::buttons(): %s', getDump($buttons)), LOG_DEBUG, __FILE__, __LINE__);
     66            $app->logMsg(sprintf('Incorrect parameters passed to %s: %s', __METHHOD__, getDump($options)), LOG_NOTICE, __FILE__, __LINE__);
    6767            return false;
    6868        }
     
    237237        if (!isset($options) || !is_array($options)) {
    238238            $app =& App::getInstance();
    239             $app->logMsg(sprintf('Incorrect parameters passed to HTML::printSelectOptions(): %s', getDump($options)), LOG_DEBUG, __FILE__, __LINE__);
     239            $app->logMsg(sprintf('Incorrect parameters passed to %s: %s', __METHHOD__, getDump($options)), LOG_NOTICE, __FILE__, __LINE__);
    240240            return false;
    241241        }
  • trunk/lib/Lock.inc.php

    r601 r685  
    272272
    273273        $this->initDB();
     274
     275        if ($this->_auth->get('user_id') == '' || filter_var($this->_auth->get('user_id'), FILTER_VALIDATE_INT) === false) {
     276            $app->logMsg(sprintf("auth->get('user_id') returns a non-integer: %s", $this->_auth->get('user_id')), LOG_ERR, __FILE__, __LINE__);
     277            return false;
     278        }
    274279
    275280        // Expire old locks.
  • trunk/lib/SortOrder.inc.php

    r681 r685  
    213213            if ($this->sort_by == $col) {
    214214                if (mb_strtolower($this->order) == 'desc') {
    215                     ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=ASC'); ?>" title="<?php echo _("Change to ascending sort order"); ?>" class="sc-sort sc-desc"><?php echo $this->desc_widget; ?></a><?php echo $col_name; ?><?php
     215                    ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=ASC'); ?>" data-tooltip title="<?php echo _("Change to ascending sort order"); ?>" class="sc-sort sc-desc"><?php echo $this->desc_widget; ?></a><?php echo $col_name; ?><?php
    216216                } else {
    217                     ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=DESC'); ?>" title="<?php echo _("Change to descending sort order"); ?>" class="sc-sort sc-asc"><?php echo $this->asc_widget; ?></a><?php echo $col_name; ?><?php
     217                    ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=DESC'); ?>" data-tooltip title="<?php echo _("Change to descending sort order"); ?>" class="sc-sort sc-asc"><?php echo $this->asc_widget; ?></a><?php echo $col_name; ?><?php
    218218                }
    219219            } else {
    220                 ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>" class="sc-sort"><?php echo $col_name; ?></a><?php
     220                ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" data-tooltip title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>" class="sc-sort"><?php echo $col_name; ?></a><?php
    221221            }
    222222        } else {
Note: See TracChangeset for help on using the changeset viewer.