Subversion Repositories Applications.papyrus

Rev

Rev 848 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 848 Rev 1713
Line 40... Line 40...
40
/**
40
/**
41
 * Two constants used to guess the path- and file-name of the page
41
 * Two constants used to guess the path- and file-name of the page
42
 * when the user doesn't set any other value
42
 * when the user doesn't set any other value
43
 */
43
 */
44
if (substr($_SERVER['PHP_SELF'], -1) == '/') {
44
if (substr($_SERVER['PHP_SELF'], -1) == '/') {
-
 
45
    $http = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';
45
    define('CURRENT_FILENAME', '');
46
    define('CURRENT_FILENAME', '');
46
    define('CURRENT_PATHNAME', 'http://'.$_SERVER['HTTP_HOST'].str_replace('\\', '/', $_SERVER['PHP_SELF']));
47
    define('CURRENT_PATHNAME', $http.$_SERVER['HTTP_HOST'].str_replace('\\', '/', $_SERVER['PHP_SELF']));
47
} else {
48
} else {
48
    define('CURRENT_FILENAME', preg_replace('/(.*)\?.*/', '\\1', basename($_SERVER['PHP_SELF'])));
49
    define('CURRENT_FILENAME', preg_replace('/(.*)\?.*/', '\\1', basename($_SERVER['PHP_SELF'])));
49
    define('CURRENT_PATHNAME', str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])));
50
    define('CURRENT_PATHNAME', str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])));
50
}
51
}
51
/**
52
/**
Line 197... Line 198...
197
    /**
198
    /**
198
     * @var string extra attributes for the <a> tag
199
     * @var string extra attributes for the <a> tag
199
     * @access private
200
     * @access private
200
     */
201
     */
201
    var $_attributes  = '';
202
    var $_attributes  = '';
-
 
203
    
-
 
204
    /**
-
 
205
     * @var string onclick
-
 
206
     * @access private
-
 
207
     */
-
 
208
    var $_onclick = '';
Line 202... Line 209...
202
 
209
 
203
    /**
210
    /**
204
     * @var string alt text for "first page" (use "%d" placeholder for page number)
211
     * @var string alt text for "first page" (use "%d" placeholder for page number)
205
     * @access private
212
     * @access private
Line 443... Line 450...
443
        'prevImg',
450
        'prevImg',
444
        'nextImg',
451
        'nextImg',
445
        'expanded',
452
        'expanded',
446
        'accesskey',
453
        'accesskey',
447
        'attributes',
454
        'attributes',
-
 
455
        'onclick',
448
        'separator',
456
        'separator',
449
        'spacesBeforeSeparator',
457
        'spacesBeforeSeparator',
450
        'spacesAfterSeparator',
458
        'spacesAfterSeparator',
451
        'curPageLinkClassName',
459
        'curPageLinkClassName',
452
        'curPageSpanPre',
460
        'curPageSpanPre',
Line 473... Line 481...
473
        'currentPage',
481
        'currentPage',
474
    );
482
    );
Line 475... Line 483...
475
 
483
 
476
    // }}}
484
    // }}}
477
    // {{{ build()
485
    // {{{ build()
478
    
486
 
479
    /**
487
    /**
480
     * Generate or refresh the links and paged data after a call to setOptions()
488
     * Generate or refresh the links and paged data after a call to setOptions()
481
     *
489
     *
482
     * @access public
490
     * @access public
483
     */
491
     */
484
    function build()
492
    function build()
-
 
493
    {
-
 
494
        //reset
-
 
495
        $this->_pageData = array();
-
 
496
        $this->links = '';
485
    {
497
 
-
 
498
        $this->_generatePageData();
-
 
499
        $this->_setFirstLastText();
-
 
500
 
486
        $msg = '<b>PEAR::Pager Error:</b>'
501
        if ($this->_totalPages > (2 * $this->_delta + 1)) {
-
 
502
            $this->links .= $this->_printFirstPage();
-
 
503
        }
-
 
504
 
-
 
505
        $this->links .= $this->_getBackLink();
-
 
506
        $this->links .= $this->_getPageLinks();
-
 
507
        $this->links .= $this->_getNextLink();
-
 
508
 
-
 
509
        $this->linkTags .= $this->_getFirstLinkTag();
-
 
510
        $this->linkTags .= $this->_getPrevLinkTag();
-
 
511
        $this->linkTags .= $this->_getNextLinkTag();
-
 
512
        $this->linkTags .= $this->_getLastLinkTag();
-
 
513
 
487
              .' function "build()" not implemented.';
514
        if ($this->_totalPages > (2 * $this->_delta + 1)) {
-
 
515
            $this->links .= $this->_printLastPage();
488
        return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
516
        }
Line 489... Line 517...
489
    }
517
    }
490
 
518
 
Line 750... Line 778...
750
            if ($this->_append) {
778
            if ($this->_append) {
751
                $href = '?' . $this->_http_build_query_wrapper($this->_linkData);
779
                $href = '?' . $this->_http_build_query_wrapper($this->_linkData);
752
            } else {
780
            } else {
753
                $href = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_fileName);
781
                $href = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_fileName);
754
            }
782
            }
-
 
783
            $onclick = '';
-
 
784
            if (array_key_exists($this->_urlVar, $this->_linkData)) {
-
 
785
                $onclick = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_onclick);
-
 
786
            }
755
            return sprintf('<a href="%s"%s%s%s title="%s">%s</a>',
787
            return sprintf('<a href="%s"%s%s%s%s title="%s">%s</a>',
756
                           htmlentities($this->_url . $href),
788
                           htmlentities($this->_url . $href),
757
                           empty($this->_classString) ? '' : ' '.$this->_classString,
789
                           empty($this->_classString) ? '' : ' '.$this->_classString,
758
                           empty($this->_attributes)  ? '' : ' '.$this->_attributes,
790
                           empty($this->_attributes)  ? '' : ' '.$this->_attributes,
759
                           empty($this->_accesskey)   ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"',
791
                           empty($this->_accesskey)   ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"',
-
 
792
                           empty($onclick)            ? '' : ' onclick="'.$onclick.'"',
760
                           $altText,
793
                           $altText,
761
                           $linkText
794
                           $linkText
762
            );
795
            );
763
        } elseif ($this->_httpMethod == 'POST') {
796
        } elseif ($this->_httpMethod == 'POST') {
764
            return sprintf("<a href='javascript:void(0)' onclick='%s'%s%s%s title='%s'>%s</a>",
797
            return sprintf("<a href='javascript:void(0)' onclick='%s'%s%s%s title='%s'>%s</a>",
Line 892... Line 925...
892
                $qs = $_POST;
925
                $qs = $_POST;
893
            } elseif ($this->_httpMethod == 'GET') {
926
            } elseif ($this->_httpMethod == 'GET') {
894
                $qs = $_GET;
927
                $qs = $_GET;
895
            }
928
            }
896
        }
929
        }
897
        if (count($this->_extraVars)){
-
 
898
            $this->_recursive_urldecode($this->_extraVars);
-
 
899
        }
-
 
900
        $qs = array_merge($qs, $this->_extraVars);
-
 
901
        foreach ($this->_excludeVars as $exclude) {
930
        foreach ($this->_excludeVars as $exclude) {
902
            if (array_key_exists($exclude, $qs)) {
931
            if (array_key_exists($exclude, $qs)) {
903
                unset($qs[$exclude]);
932
                unset($qs[$exclude]);
904
            }
933
            }
905
        }
934
        }
-
 
935
        if (count($this->_extraVars)){
-
 
936
            $this->_recursive_urldecode($this->_extraVars);
-
 
937
            $qs = array_merge($qs, $this->_extraVars);
-
 
938
        }
906
        if (count($qs) && get_magic_quotes_gpc()){
939
        if (count($qs) && get_magic_quotes_gpc()){
907
            $this->_recursive_stripslashes($qs);
940
            $this->_recursive_stripslashes($qs);
908
        }
941
        }
909
        return $qs;
942
        return $qs;
910
    }
943
    }
Line 1291... Line 1324...
1291
     * @access private
1324
     * @access private
1292
     */
1325
     */
1293
    function __http_build_query($array, $name)
1326
    function __http_build_query($array, $name)
1294
    {
1327
    {
1295
        $tmp = array ();
1328
        $tmp = array ();
-
 
1329
        $separator = ini_get('arg_separator.output');
-
 
1330
        if ($separator == '&amp;') {
-
 
1331
            $separator = '&'; //the string is escaped by htmlentities anyway...
-
 
1332
        }
1296
        foreach ($array as $key => $value) {
1333
        foreach ($array as $key => $value) {
1297
            if (is_array($value)) {
1334
            if (is_array($value)) {
1298
                //array_push($tmp, $this->__http_build_query($value, sprintf('%s[%s]', $name, $key)));
1335
                //array_push($tmp, $this->__http_build_query($value, sprintf('%s[%s]', $name, $key)));
1299
                array_push($tmp, $this->__http_build_query($value, $name.'%5B'.$key.'%5D'));
1336
                array_push($tmp, $this->__http_build_query($value, $name.'%5B'.$key.'%5D'));
1300
            } elseif (is_scalar($value)) {
1337
            } elseif (is_scalar($value)) {
Line 1303... Line 1340...
1303
            } elseif (is_object($value)) {
1340
            } elseif (is_object($value)) {
1304
                //array_push($tmp, $this->__http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key)));
1341
                //array_push($tmp, $this->__http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key)));
1305
                array_push($tmp, $this->__http_build_query(get_object_vars($value), $name.'%5B'.$key.'%5D'));
1342
                array_push($tmp, $this->__http_build_query(get_object_vars($value), $name.'%5B'.$key.'%5D'));
1306
            }
1343
            }
1307
        }
1344
        }
1308
        return implode(ini_get('arg_separator.output'), $tmp);
1345
        return implode($separator, $tmp);
1309
    }
1346
    }
Line 1310... Line 1347...
1310
 
1347
 
1311
    // }}}
1348
    // }}}
Line 1384... Line 1421...
1384
        } else {
1421
        } else {
1385
            $this->_url = $this->_path;
1422
            $this->_url = $this->_path;
1386
            if (strncasecmp($this->_fileName, 'javascript', 10) != 0) {
1423
            if (strncasecmp($this->_fileName, 'javascript', 10) != 0) {
1387
                $this->_url .= '/';
1424
                $this->_url .= '/';
1388
            }
1425
            }
1389
            if (!strstr($this->_fileName, '%d')) {
1426
            if (strpos($this->_fileName, '%d') === false) {
1390
                trigger_error($this->errorMessage(ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);
1427
                trigger_error($this->errorMessage(ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);
1391
            }
1428
            }
1392
        }
1429
        }
Line 1393... Line 1430...
1393
 
1430