/[cvs]/nfo/php/libs/org.netfrag.glib/utils/LinkBuilder.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.glib/utils/LinkBuilder.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Fri Jun 6 04:23:12 2003 UTC (21 years, 1 month ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +5 -1 lines
minor update: comment

1 <?php
2
3 /**
4 * $Id: LinkBuilder.php,v 1.2 2003/04/06 04:35:58 joko Exp $
5 *
6 * $Log: LinkBuilder.php,v $
7 * Revision 1.2 2003/04/06 04:35:58 joko
8 * comments, prepared for phpDocumentor
9 *
10 * Revision 1.1 2003/04/06 01:35:25 jonen
11 * + initial commit
12 *
13 */
14
15 /**
16 * LinkBuilder
17 *
18 * This implements a persistent storage for variables needed at links
19 * where unique id are used to different the temporarly stored variables
20 *
21 * It's similar to James A. Duncan's "Pixie", see
22 * Pixie - The magic data pixie
23 * http://search.cpan.org/author/JDUNCAN/Pixie-2.06/
24 * But that one - of course - is somehow more sophisticated. It offers multiple
25 * storage implementations for your data payloads and also seems to implement
26 * some locking strategies. (Pixie::LockStrat & Co.)
27 *
28 * However, their core concepts are comparable:
29 * Expect an arbitrary variable as "data container" (hash prefered!?) and save it
30 * away assigning an unique identifier for the slot the actual payload lives inside
31 * the storage.
32 * This identifier gets returned as a result of the save/store/create operation and
33 * can be used later to get to the persisted data via a load/restore/retrieve operation.
34 *
35 * @todo prevent HUGE SESSION! delete session entry after all needed stuff(entries) is loaded to!!
36 * @todo is php::CreateGUID expensive? review!
37 * @todo maybe refactor to Data::PhpSpace::Persistent, which inherits from Data::PhpSpace?
38 *
39 * @author Sebastian Utz <seut@tunemedia.de>
40 * @package org.netfrag.glib
41 * @name LinkBuilder
42 *
43 */
44 class LinkBuilder {
45
46 function LinkBuilder() {
47 php::session_register_safe('lb_state');
48 }
49
50 function generate_GUID() {
51 return php::CreateGUID();
52 }
53
54 function save($args, $guid="") {
55 if(!$guid) { $guid = $this->generate_GUID(); }
56 $this->save_to_session($args, $guid);
57 return $guid;
58 }
59
60 function load($guid) {
61 $tmp = $this->load_from_session($guid);
62 //debug
63 //print "LinkBuilder::load($guid)<br>";
64 //print Dumper($tmp);
65 return $tmp;
66 }
67
68 function save_to_session($args, $guid) {
69 global $lb_state;
70 $classname = get_class($this);
71 $lb_state[$classname][$guid] = $args;
72 }
73
74 function load_from_session($guid) {
75 global $lb_state;
76 $classname = get_class($this);
77 //print Dumper($_SESSION);
78 return $lb_state[$classname][$guid];
79 }
80
81 }
82
83
84 ?>

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