/[cvs]/nfo/php/libs/org.netfrag.flib/Site/Handler.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.flib/Site/Handler.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Tue Nov 12 05:42:31 2002 UTC (21 years, 9 months ago) by joko
Branch: MAIN
+ initial checkin

1 joko 1.1 <?
2     // -------------------------------------------------------------------------
3     // $Id$
4     // -------------------------------------------------------------------------
5     // $Log$
6     // -------------------------------------------------------------------------
7    
8    
9     class Site_Handler {
10    
11     var $s = array();
12     var $enc = array(
13     map => array(),
14     id => 70841,
15     enabled => 0,
16     );
17    
18     function _getid() {
19     $this->enc[id]++;
20     $dummyId = 's' . $this->enc[id];
21     return $dummyId;
22     }
23    
24     function setHandler($ident, $attribs) {
25     //$this->site->log( get_class($this) . "->setHandler( ident $ident, attribs $attribs)", LOG_DEBUG );
26     if (!is_array($attribs)) { $attribs = array(); }
27     $newid = $this->_getid();
28     // store handler
29     $attribs[id] = $newid;
30     $this->s[$ident] = $attribs;
31     // create/store mapping
32     $this->enc[map][$newid] = $ident;
33     }
34    
35     function getHandler($ident) {
36     if (count($this->s) == 0) {
37     $this->site->log( get_class($this) . "->getHandler: called before any setHandler", LOG_WARNING );
38     }
39     return $this->s[$ident];
40     }
41    
42     function getPageIdentifier() {
43     global $site_state;
44     return $site_state[page];
45     }
46    
47     function checkIdentifier($ident) {
48     return isset($this->s[$ident]);
49     }
50    
51     function decodeIdentifier($arg) {
52     if ($this->enc[enabled]) {
53     $args = split('_', $arg);
54     $ident_enc = array_shift($args);
55     $ident = $this->enc[map][$ident_enc];
56     array_unshift($args, $ident);
57     $result = join('/', $args);
58     return $result;
59     } else {
60     //$arg = str_replace('_', '/', $arg);
61     return $arg;
62     }
63     }
64    
65     function encodeIdentifier($arg) {
66     if ($this->enc[enabled]) {
67     $result = $this->s[$arg][id];
68     // strip action from arg, if present
69     if (!$result && (substr($arg, -1) != '/') ) {
70     $divpos = strrpos($arg, '/') + 1;
71     $ident = substr($arg, 0, $divpos);
72     $ident_enc = $this->s[$ident][id];
73     $action = substr($arg, $divpos);
74     $result = $ident_enc . '_' . $action;
75     }
76     return $result;
77     } else {
78     //$arg = str_replace('/', '_', $arg);
79     return $arg;
80     }
81     }
82    
83     }
84     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed