1<?php 2/** 3 * pfccontainerinterface.class.php 4 * 5 * Copyright © 2006 Stephane Gully <stephane.gully@gmail.com> 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the 19 * Free Software Foundation, 51 Franklin St, Fifth Floor, 20 * Boston, MA 02110-1301 USA 21 */ 22 23/** 24 * pfcContainerInterface is an interface implemented by pfcContainer and each pfcContainer concrete isntances (File,Mysql...) 25 * 26 * @author Stephane Gully <stephane.gully@gmail.com> 27 * @abstract 28 */ 29class pfcContainerInterface 30{ 31 function pfcContainerInterface() { } 32 function getDefaultConfig() { return array(); } 33 function init(&$c) { return array(); } 34 35 /** 36 * Write a meta data value identified by a group / subgroup / leaf [with a value] 37 * As an example in the default file container this arborescent structure is modelised by simple directories 38 * group1/subgroup1/leaf1 39 * /leaf2 40 * /subgroup2/... 41 * Each leaf can contain or not a value. 42 * However each leaf and each group/subgroup must store the lastmodified time (timestamp). 43 * @param $group root arborescent element 44 * @param $subgroup is the root first child which contains leafs 45 * @param $leaf is the only element which can contain values 46 * @param $leafvalue NULL means the leaf will not contain any values 47 * @return 1 if the old leaf has been overwritten, 0 if a new leaf has been created 48 */ 49 function setMeta($group, $subgroup, $leaf, $leafvalue = NULL) 50 { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } 51 52 53 /** 54 * Read meta data identified by a group [/ subgroup [/ leaf]] 55 * @param $group is mandatory, it's the arborescence's root 56 * @param $subgroup if null then the subgroup list names are returned 57 * @param $leaf if null then the leaf names are returned 58 * @param $withleafvalue if set to true the leaf value will be returned 59 * @return array which contains two subarray 'timestamp' and 'value' 60 */ 61 function getMeta($group, $subgroup = null, $leaf = null, $withleafvalue = false) 62 { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } 63 64 65 /** 66 * Remove a meta data or a group of metadata 67 * @param $group if null then it will remove all the possible groups (all the created metadata) 68 * @param $subgroup if null then it will remove the $group's childs (all the subgroup contained by $group) 69 * @param $leaf if null then it will remove all the $subgroup's childs (all the leafs contained by $subgroup) 70 * @return true on success, false on error 71 */ 72 function rmMeta($group, $subgroup = null, $leaf = null) 73 { die(_pfc("%s must be implemented", get_class($this)."::".__FUNCTION__)); } 74 75 76 /** 77 * In the default File container: used to encode UTF8 strings to ASCII filenames 78 * This method can be overridden by the concrete container 79 */ 80 function encode($str) 81 { 82 return $str; 83 } 84 85 /** 86 * In the default File container: used to decode ASCII filenames to UTF8 strings 87 * This method can be overridden by the concrete container 88 */ 89 function decode($str) 90 { 91 return $str; 92 } 93} 94 95?>