/[cvs]/nfo/php/libs/org.netfrag.glib/Application/AbstractHandler.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.glib/Application/AbstractHandler.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sun Feb 9 16:58:01 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
Changes since 1.1: +7 -3 lines
+ minor update related to new log level constants

1 joko 1.1 <?
2     // -------------------------------------------------------------------------
3 joko 1.2 // $Id: AbstractHandler.php,v 1.1 2003/02/04 08:24:37 joko Exp $
4 joko 1.1 // -------------------------------------------------------------------------
5 joko 1.2 // $Log: AbstractHandler.php,v $
6     // Revision 1.1 2003/02/04 08:24:37 joko
7     // + initial commit
8     // + refactored from flib/Site/Request.php and flib/Site/Handler.php
9     //
10 joko 1.1 // Revision 1.2 2002/12/13 00:23:08 jonen
11     // - removed $site_state vars
12     // changes related to new Session class
13     //
14     // Revision 1.1 2002/11/12 05:42:31 joko
15     // + initial checkin
16     //
17     // -------------------------------------------------------------------------
18    
19    
20     class Application_AbstractHandler {
21    
22     // parent's instance
23     var $parent;
24    
25     var $s = array();
26     var $enc = array(
27     map => array(),
28     id => 70841,
29     enabled => 0,
30     );
31    
32     function _getid() {
33     $this->enc[id]++;
34     $dummyId = 's' . $this->enc[id];
35     return $dummyId;
36     }
37    
38     function setHandler($ident, $attribs) {
39     //$this->site->log( get_class($this) . "->setHandler( ident $ident, attribs $attribs)", LOG_DEBUG );
40     if (!is_array($attribs)) { $attribs = array(); }
41     $newid = $this->_getid();
42     // store handler
43     $attribs[id] = $newid;
44     $this->s[$ident] = $attribs;
45     // create/store mapping
46     $this->enc[map][$newid] = $ident;
47     }
48    
49     function getHandler($ident) {
50     $parent = $this->parent;
51     if (count($this->s) == 0) {
52 joko 1.2 $this->$parent->log( get_class($this) . "->getHandler: called before any setHandler", PEAR_LOG_WARNING );
53 joko 1.1 }
54     return $this->s[$ident];
55     }
56    
57     function getPageIdentifier() {
58     $parent = $this->parent;
59     //global $site_state;
60     //return $site_state[page];
61     return $this->$parent->session->get('page');
62     }
63    
64     function checkIdentifier($ident) {
65     return isset($this->s[$ident]);
66     }
67    
68     function decodeIdentifier($arg) {
69     if ($this->enc[enabled]) {
70     $args = split('_', $arg);
71     $ident_enc = array_shift($args);
72     $ident = $this->enc[map][$ident_enc];
73     array_unshift($args, $ident);
74     $result = join('/', $args);
75     return $result;
76     } else {
77     //$arg = str_replace('_', '/', $arg);
78     return $arg;
79     }
80     }
81    
82     function encodeIdentifier($arg) {
83     if ($this->enc[enabled]) {
84     $result = $this->s[$arg][id];
85     // strip action from arg, if present
86     if (!$result && (substr($arg, -1) != '/') ) {
87     $divpos = strrpos($arg, '/') + 1;
88     $ident = substr($arg, 0, $divpos);
89     $ident_enc = $this->s[$ident][id];
90     $action = substr($arg, $divpos);
91     $result = $ident_enc . '_' . $action;
92     }
93     return $result;
94     } else {
95     //$arg = str_replace('/', '_', $arg);
96     return $arg;
97     }
98     }
99    
100     }
101     ?>

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