Thread: [CS-Project-svn_notify] SF.net SVN: cs-project:[910] releases/1.2/lib
Brought to you by:
crazedsanity
From: <cra...@us...> - 2008-08-28 03:59:43
|
Revision: 910 http://cs-project.svn.sourceforge.net/cs-project/?rev=910&view=rev Author: crazedsanity Date: 2008-08-28 03:59:39 +0000 (Thu, 28 Aug 2008) Log Message: ----------- Remove svn:externals definition for the release (so they can be exported/imported). Added Paths: ----------- releases/1.2/lib/cs-arrayToPath/ releases/1.2/lib/cs-arrayToPath/LICENSE releases/1.2/lib/cs-arrayToPath/VERSION releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php releases/1.2/lib/cs-arrayToPath/cs_versionAbstract.class.php releases/1.2/lib/cs-content/ releases/1.2/lib/cs-content/LICENSE releases/1.2/lib/cs-content/README.txt releases/1.2/lib/cs-content/VERSION releases/1.2/lib/cs-content/contentSystemClass.php releases/1.2/lib/cs-content/cs_bbCodeParser.class.php releases/1.2/lib/cs-content/cs_fileSystemClass.php releases/1.2/lib/cs-content/cs_genericPageClass.php releases/1.2/lib/cs-content/cs_globalFunctions.php releases/1.2/lib/cs-content/cs_phpDB.php releases/1.2/lib/cs-content/cs_sessionClass.php releases/1.2/lib/cs-content/cs_tabsClass.php releases/1.2/lib/cs-content/cs_versionAbstract.class.php releases/1.2/lib/cs-content/db_types/ releases/1.2/lib/cs-content/db_types/cs_phpDB__mysql.class.php releases/1.2/lib/cs-content/db_types/cs_phpDB__pgsql.class.php releases/1.2/lib/cs-content/db_types/cs_phpDB__sqlite.class.php releases/1.2/lib/cs-content/sample_files/ releases/1.2/lib/cs-content/sample_files/public_html/ releases/1.2/lib/cs-content/sample_files/public_html/.htaccess releases/1.2/lib/cs-content/sample_files/public_html/content releases/1.2/lib/cs-content/sample_files/public_html/index.php releases/1.2/lib/cs-content/sample_files/templates/ releases/1.2/lib/cs-content/sample_files/templates/content/ releases/1.2/lib/cs-content/sample_files/templates/content/index.content.tmpl releases/1.2/lib/cs-content/sample_files/templates/footer.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/header.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/infobar.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/main.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/menu.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/ releases/1.2/lib/cs-content/sample_files/templates/system/404.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/construction.content.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/db_error.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/message_box.tmpl releases/1.2/lib/cs-content/template.inc releases/1.2/lib/cs-phpxml/ releases/1.2/lib/cs-phpxml/LICENSE releases/1.2/lib/cs-phpxml/README.txt releases/1.2/lib/cs-phpxml/VERSION releases/1.2/lib/cs-phpxml/xmlAbstract.class.php releases/1.2/lib/cs-phpxml/xmlBuilderClass.php releases/1.2/lib/cs-phpxml/xmlCreatorClass.php releases/1.2/lib/cs-phpxml/xmlParserClass.php Property Changed: ---------------- releases/1.2/lib/ Property changes on: releases/1.2/lib ___________________________________________________________________ Deleted: svn:externals - cs-content https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/0.10 cs-phpxml https://cs-phpxml.svn.sourceforge.net/svnroot/cs-phpxml/trunk cs-arrayToPath https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk Added: releases/1.2/lib/cs-arrayToPath/LICENSE =================================================================== --- releases/1.2/lib/cs-arrayToPath/LICENSE (rev 0) +++ releases/1.2/lib/cs-arrayToPath/LICENSE 2008-08-28 03:59:39 UTC (rev 910) @@ -0,0 +1,291 @@ +NOTE: a full HTML version of this license can be found at: +http://www.opensource.org/licenses/gpl-license.php + +It has been reproduced below without any HTML. +========================================================================== + +The GNU General Public License (GPL) + +Version 2, June 1991 + + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS Added: releases/1.2/lib/cs-arrayToPath/VERSION =================================================================== --- releases/1.2/lib/cs-arrayToPath/VERSION (rev 0) +++ releases/1.2/lib/cs-arrayToPath/VERSION 2008-08-28 03:59:39 UTC (rev 910) @@ -0,0 +1,5 @@ +## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. + +VERSION: 0.2.2 +PROJECT: cs-arrayToPath +$HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/VERSION $ \ No newline at end of file Added: releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php =================================================================== --- releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php (rev 0) +++ releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php 2008-08-28 03:59:39 UTC (rev 910) @@ -0,0 +1,379 @@ +<?php +/* + * Created on Nov 20, 2006 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author: crazedsanity $ + * Current Revision:::: $Revision: 17 $ + * Repository Location: $HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/arrayToPathClass.php $ + * Last Updated:::::::: $Date: 2007-09-12 14:24:46 -0500 (Wed, 12 Sep 2007) $ + * + * + * Basically traverses an array as though it were a filesystem. In the given example, it looks + * more complex than necessary, but the "NEW WAY" is very programatic, whereas the "OLD WAY" is + * just that: OLD. Also, the new way is very extensible, and is handy when performing a LOT of + * complex operations on an array. + * Example: + * OLD WAY: + * $my_data = $array['path']['to']['your']['hidden']['data']; + * $my_vault = $array['path']['to']['your']['hidden']['vault']; + * $my_other = $array['path']['to']['your']['hidden']['other']; + * + * $array['path']['to']['my'] = array(); + * $array['path']['to']['my']['data'] = array(); + * $array['path']['to']['my']['data']['is'] = "here"; + * NEW WAY: + * $arrayToPath = new arrayToPath($array); + * $my_data = $arrayToPath('/path/to/your/hidden/data'); + * $my_vault = $arrayToPath('/path/to/your/hidden/vault'); + * $my_other = $arrayToPath('/path/to/your/hidden/other'); + * + * $arrayToPath->set_data('/path/to/my/data/is', 'here'); + */ + + +require_once(dirname(__FILE__) .'/cs_versionAbstract.class.php'); + +class arrayToPath extends cs_a2p_versionAbstract { + + private $prefix = NULL; //the first directory to use. + private $data; + private $iteration = 0; + + //====================================================================================== + /** + * The constructor. + * + * @param $array (array) The data that will be used when + * + * TODO::: there is a strange recursion issue when $prefix is non-null: prefix is presently hardwired as NULL for now... + */ + public function __construct($array, $prefix=NULL) { + if($array === 'unit_test') { + //it's a unit test. + $this->isTest = TRUE; + } + else { + $this->get_version(); + $prefix=NULL; + if(!is_array($array)) { + //I don't deal with non-arrays. Idiot. + exit('arrayToPath{}->__construct(): got an invalid datatype.'); + } + //create a reference to the data, so if it changes, the class doesn't have to be re-initialized. + $this->data = $array; + + //now set the prefix ONLY if the prefix is valid. + if(!is_null($prefix) && strlen($prefix)) { + //got a good prefix, so use it. + $this->prefix = $prefix; + } + } + }//end __construct() + //====================================================================================== + + + //====================================================================================== + /** + * Takes a path & returns the appropriate index in the session. + * + * @param $path <str> path to the appropriate section in the session. + * + * @return <NULL> FAIL: unable to find requested index. + * @return <mixed> PASS: this is the value of the index. + */ + public function get_data($path=NULL) { + $myIndexList = array(); + $path = $this->fix_path($path); + + if(is_null($path) || (strlen($path) < 1)) { + //they just want ALL THE DATA. + $retval = $this->data; + } + else { + //get the list of indices in our data that we have to traverse. + $myIndexList = $this->explode_path($path); + + //set an initial retval. + $retval = $this->get_data_segment($this->data, $myIndexList[0]); + unset($myIndexList[0]); + + if(count($myIndexList) > 0) { + foreach($myIndexList as $indexName) { + $retval = $this->get_data_segment($retval, $indexName); + if(is_null($retval)) { + //hmm... well, if it's null, it's nothing which can have a sub-index. Stop here. + break; + } + } + } + } + + return($retval); + + }//end get_data() + //====================================================================================== + + + + //====================================================================================== + /** + * Returns a given index from a piece of data, used by get_data(). + */ + private function get_data_segment($fromThis, $indexName) { + if(is_array($fromThis)) { + //it's an array. + $retval = $fromThis[$indexName]; + } + elseif(is_object($fromThis)) { + //it's an object. + $retval = $fromThis->$indexName; + } + return($retval); + }//end get_data_segment() + //====================================================================================== + + + + //====================================================================================== + /** + * Pre-pends the internal $this->prefix onto the given path. + * + * @param $path <str> path to append $this->prefix onto. + * + * @return <str> PASS: this is the path with our prefix added. + */ + private function fix_path($path) { + if(is_null($path) && is_null($this->prefix)) { + //all data is null. don't bother changing it. + $retval = NULL; + } + else { + //remove slashes at the beginning or end of the path. + $path = preg_replace('/\/$/', '', $path); + + if(preg_match('/\/$/', $this->prefix)) { + //remove the trailing slash. + $this->prefix = preg_replace('/$\//', '', $this->prefix); + } + if(preg_match('/^\//', $this->prefix)) { + $this->prefix = preg_replace('/^\//', '', $this->prefix); + } + $path = preg_replace('/\/$/', '', $path); + + //should we add our prefix? + if(preg_match('/^\//', $path)) { + $retval = $path; + } + else { + $retval = $this->prefix ."/". $path; + } + + //remove a trailing slash, if present, before returning. + $retval = preg_replace('/\/$/', '', $retval); + } + + return($retval); + + }//end fix_path() + //====================================================================================== + + + + //====================================================================================== + /** + * Sets data into the given path, with options to override our internal prefix, and to + * force-overwrite data if it's not an array. + * + * @param $path <str> path to set the data into. + * @param $data <mixed> what to set into the given path. + * + * @return 0 FAIL: old data doesn't match new data. + * @return 1 PASS: everything lines-up. + */ + public function set_data($path, $data) { + //get the list of indices in the session that we have to traverse. + $myIndexList = $this->explode_path($path); + + $retval = 0; + //Use an internal iterator to go through the little bits of the session & set the + // data where it's supposed to be. + if($path === '/' || count($myIndexList) == 0) { + //setting the data. + $this->data = $data; + $retval = 1; + } + elseif(count($myIndexList) == 1) { + //that should be simple: set the index to be $data. + $this->data[$myIndexList[0]] = $data; + $retval = 1; + } + elseif(count($myIndexList) > 1) { + $this->internal_iterator($this->data, $path, $data); + $retval = 1; + } + + return($retval); + }//end set_data() + //====================================================================================== + + + //====================================================================================== + /** + * Iterates through the session to create the values for set_data(). This method passes + * AND returns the $array argument by reference. + * + * @param &$array (array) iterate through this. + * @param $path (array) numbered array of keys, representing a path through the + * internal data to go through to set $data. + * @param $data (mixed) data to set into the path referenced in $indexList. + * + * @return <void> + */ + protected function &internal_iterator(&$array, $path, $data) { + //make sure it doesn't call itself to death. ;) + $this->iteration++; + + if($this->iteration > 1000) { + throw new exception("arrayToPath{}: too many iterations, path=($path)"); + } + + $retval = 0; + $indexList = $this->explode_path($path); + $myIndex = array_shift($indexList); + $path = $this->string_from_array($indexList); + + if(is_array($array) && !strlen($path)) { + if(isset($myIndex)) { + //set the final piece of the array. + $array[$myIndex] = $data; + } + else { + //something is broken. + throw new exception("arrayToPath{}->internal_iterator(): no index ($myIndex) to follow at the end of the path."); + } + } + elseif(is_array($array) && strlen($path)) { + if((count($indexList) == 0) || (is_array($indexList) && count($indexList) > 1)) { + if(!is_array($array[$myIndex])) { + $array[$myIndex] = array(); + } + $array = &$array[$myIndex]; + $newPath = $this->string_from_array($indexList); + + $this->internal_iterator($array, $path, $data); + } + elseif(is_array($indexList) && count($indexList) == 1) { + if(!is_array($array[$myIndex])) { + $array[$myIndex] = array(); + } + $array = &$array[$myIndex]; + $this->internal_iterator($array, $indexList[0], $data); + } + else { + //not sure what to do but throw an exception. + throw new exception("arrayToPath{}->internal_iterator(): unknown error ('not sure what to do'): ($array)"); + } + } + elseif(is_object($array)) { + //can't handle objects...? + throw new exception("arrayToPath{}->internal_iterator(): can't handle objects...?"); + } + else { + //something is... er... broken. + throw new exception("arrayToPath{}->internal_iterator(): found unknown data type in path ($array)"); + } + + //decrement the iteration, so methods using it can call it multiple times without worrying about accidentally hitting the limit. + $this->iteration--; + }//end internal_iterator() + //====================================================================================== + + + + + //====================================================================================== + /** + * Will unset the final index in the $path var. I.E. to unset $this->array['x']['y'], + * call unset_data('/x/y') + * + * @param $path (str) path to unset data; The last item in the path will be removed. + */ + public function unset_data($path) { + //explode the path. + $pathArr = $this->explode_path($path); + $removeThis = array_pop($pathArr); + $path = $this->string_from_array($pathArr); + + //retrieve the data... + $myData = $this->get_data($path); + + if(is_array($myData)) { + //now remove the bit of data as requested. + unset($myData[$removeThis]); + //update the path with our new data. + $retval = $this->set_data($path, $myData); + } + else { + //throw a terrible error. + throw new exception("unset_data(): data ($myData) wasn't an array! ($path)"); + } + + return($retval); + }//end unset_data() + //====================================================================================== + + + + //====================================================================================== + /** + * Performs all the work of exploding the path and fixing it. + * + * @param $path <string> Path to work with. + * @return <array> PASS: array contains exploded path. + */ + public function explode_path($path) { + $path = preg_replace('/\/\//', '/', $path); + $path = $this->fix_path($path); + $retval = explode('/', $path); + + //if the initial index is blank, just remove it. + if($retval[0] == '' || strlen($retval[0]) < 1) { + //it was blank! KILL IT! + $checkItOut = array_shift($retval); + } + + return($retval); + }//end explode_path() + //====================================================================================== + + + + //====================================================================================== + public function reload_data($array) { + //call the constructor on it, and pass along the CURRENT prefix, so it doesn't get reset. + $this->__construct($array, $this->prefix); + }//end reload_data() + //====================================================================================== + + + + //====================================================================================== + private function string_from_array(array $array) { + $retval = ""; + foreach($array as $index) { + if(strlen($retval)) { + $retval .= "/". $index; + } + else { + $retval = $index; + } + } + return($retval); + }//end string_from_array() + //====================================================================================== + +}//end arrayToPath{} + +?> Added: releases/1.2/lib/cs-arrayToPath/cs_versionAbstract.class.php =================================================================== --- releases/1.2/lib/cs-arrayToPath/cs_versionAbstract.class.php (rev 0) +++ releases/1.2/lib/cs-arrayToPath/cs_versionAbstract.class.php 2008-08-28 03:59:39 UTC (rev 910) @@ -0,0 +1,86 @@ +<?php +/* + * Created on Sept. 12, 2007 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author: crazedsanity $ + * Current Revision:::: $Revision: 153 $ + * Repository Location: $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/cs_versionAbstract.class.php $ + * Last Updated:::::::: $Date: 2007-09-12 13:33:15 -0500 (Wed, 12 Sep 2007) $ + */ + +abstract class cs_a2p_versionAbstract { + + public $isTest=FALSE; + + abstract public function __construct(); + + + + //========================================================================= + /** + * Retrieve our version string from the VERSION file. + */ + final public function get_version() { + $retval = NULL; + $versionFileLocation = dirname(__FILE__) .'/VERSION'; + if(file_exists($versionFileLocation)) { + $myData = file($versionFileLocation); + + //set the logical line number that the version string is on, and + // drop by one to get the corresponding array index. + $lineOfVersion = 3; + $arrayIndex = $lineOfVersion -1; + + $myVersionString = trim($myData[$arrayIndex]); + + if(preg_match('/^VERSION: /', $myVersionString)) { + $retval = preg_replace('/^VERSION: /', '', $myVersionString); + } + else { + throw new exception(__METHOD__ .": failed to retrieve version string"); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve version information"); + } + + return($retval); + }//end get_version() + //========================================================================= + + + + //========================================================================= + final public function get_project() { + $retval = NULL; + $versionFileLocation = dirname(__FILE__) .'/VERSION'; + if(file_exists($versionFileLocation)) { + $myData = file($versionFileLocation); + + //set the logical line number that the version string is on, and + // drop by one to get the corresponding array index. + $lineOfProject = 4; + $arrayIndex = $lineOfProject -1; + + $myProject = trim($myData[$arrayIndex]); + + if(preg_match('/^PROJECT: /', $myProject)) { + $retval = preg_replace('/^PROJECT: /', '', $myProject); + } + else { + throw new exception(__METHOD__ .": failed to retrieve project string"); + } + } + else { + throw new exception(__METHOD__ .": failed to retrieve project information"); + } + + return($retval); + }//end get_project() + //========================================================================= + + +} +?> \ No newline at end of file Property changes on: releases/1.2/lib/cs-arrayToPath/cs_versionAbstract.class.php ___________________________________________________________________ Added: svn:executable + * Added: releases/1.2/lib/cs-content/LICENSE =================================================================== --- releases/1.2/lib/cs-content/LICENSE (rev 0) +++ releases/1.2/lib/cs-content/LICENSE 2008-08-28 03:59:39 UTC (rev 910) @@ -0,0 +1,291 @@ +NOTE: a full HTML version of this license can be found at: +http://www.opensource.org/licenses/gpl-license.php + +It has been reproduced below without any HTML. +========================================================================== + +The GNU General Public License (GPL) + +Version 2, June 1991 + + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS Added: releases/1.2/lib/cs-content/README.txt =================================================================== --- releases/1.2/lib/cs-content/README.txt (rev 0) +++ releases/1.2/lib/cs-content/README.txt 2008-08-28 03:59:39 UTC (rev 910) @@ -0,0 +1,5 @@ +Documentation is now located at: +[https://cs-content.svn.sourceforge.net/svnroot/cs-content/documentation]. It +has been moved to avoid unnecessarily large downloads. + +$Id: README.txt 267 2008-04-29 15:27:28Z crazedsanity $ \ No newline at end of file Added: releases/1.2/lib/cs-content/VERSION =================================================================== --- releases/1.2/lib/cs-content/VERSION (rev 0) +++ releases/1.2/lib/cs-content/VERSION 2008-08-28 03:59:39 UTC (rev 910) @@ -0,0 +1,5 @@ +## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. + +VERSION: 0.10.12 +PROJECT: cs-content +$HeadURL:https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/VERSION $ \ No newline at end of file Added: releases/1.2/lib/cs-content/contentSystemClass.php =================================================================== --- releases/1.2/lib/cs-content/contentSystemClass.php (rev 0) +++ releases/1.2/lib/cs-content/contentSystemClass.php 2008-08-28 03:59:39 UTC (rev 910) @@ -0,0 +1,858 @@ +<?php +/* + * FILE INFORMATION: + * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/0.10/contentSystemClass.php $ + * $Id: contentSystemClass.php 288 2008-06-04 18:20:26Z crazedsanity $ + * $LastChangedDate: 2008-06-04 13:20:26 -0500 (Wed, 04 Jun 2008) $ + * $LastChangedRevision: 288 $ + * $LastChangedBy: crazedsanity $ + * + * HOW THE SYSTEM WORKS::: + * TEMPLATE FILES: + * Automatically loads templates based on the URL, and optionally includes scripts in the includes directory. + * + * MAIN SECTION: + * For the main section, i.e. "/content", it requires a template in a directory of that name beneath + * /templates, with a file called "index.content.tmpl"... i.e. /templatee/content/index.content.tmpl. + * SUB SECTIONS: + * For any subsection to be valid, i.e. "/content/members", it must have an associated template, i.e. + * "/templates/content/members.content.tmpl". If a subdirectory with an index.content.tmpl file exists, it will + * be used instead of the file in the sub directory (i.e. "/templates/content/members/index.content.tmpl"). + * SUB SECTION TEMPLATE INHERITANCE: + * All pages load the base set of "shared" templates, which are in the form "<section>.shared.tmpl" in + * the root of the templates directory. + * + * Shared files within each directory, in the form "<section>.shared.tmpl", will be loaded for ANY subsection. + * + * For any subsection, it inherits a previous section's templates in the following manner (any "content" + * templates are ignored for inheritance, as they're require for page load). + * /content ---> /templates/content/index.*.tmpl + * + * /content/members |--> /templates/content/index.*.tmpl + * `--> /templates/content/members.*.tmpl + * + * /content/members/test |--> /templates/content/index.*.tmpl + * |--> /templates/content/members.*.tmpl + * |--> /templates/content/members/index.*.tmpl + * `--> /templates/content/members/test.*.tmpl + * AUTOMATIC INCLUDES: + * Much in the same way templates are included, so are scripts, from the /includes directory, though the logic + * is decidedly simpler: all scripts must have the extension of ".inc", and must have either the section's name + * as the first part of the filename, or "shared". Shared scripts will be loaded for ALL subsections. + * + * INCLUDES INHERITANCE: + * The template inheritance scheme is as laid-out below. The content system will go as far into the + * includes directory as it can for the given section, regardless of if any intermediate files are missing. + * + * It is important to note that the content system will NOT regard a section as valid if there are include + * scripts but no templates. + * + * /content |--> /includes/shared.inc + * `--> /includes/content.inc + * + * /content/members |--> /includes/shared.inc + * |--> /includes/content.inc + * |--> /includes/content/shared.inc + * `--> /includes/content/members.inc + * + * /content/members/test |--> /includes/shared.inc + * |--> /includes/content.inc + * |--> /includes/content/shared.inc + * |--> /includes/content/members.inc + * |--> /includes/content/members/shared.inc + * |--> /includes/content/members/test.inc + */ + +//TODO: remove this terrible little hack. +if(!isset($GLOBALS['SITE_ROOT'])) { + //define where our scripts are located. + $GLOBALS['SITE_ROOT'] = $_SERVER['DOCUMENT_ROOT']; + $GLOBALS['SITE_ROOT'] = str_replace("/public_html", "", $GLOBALS['SITE_ROOT']); +} + +require_once(dirname(__FILE__) ."/cs_globalFunctions.php"); +require_once(dirname(__FILE__) ."/cs_fileSystemClass.php"); +require_once(dirname(__FILE__) ."/cs_sessionClass.php"); +require_once(dirname(__FILE__) ."/cs_genericPageClass.php"); +require_once(dirname(__FILE__) ."/cs_tabsClass.php"); +require_once(dirname(__FILE__) ."/cs_versionAbstract.class.php"); + +class contentSystem extends cs_versionAbstract { + + protected $baseDir = NULL; //base directory for templates & includes. + protected $section = NULL; //section string, derived from the URL. + protected $sectionArr = array(); //array of items, for figuring out where templates & includes are. + protected $fileSystemObj = NULL; //the object used to access the filesystem. + protected $ignoredList = array( //array of files & folders that are implicitely ignored. + 'file' => array('.htaccess'), + 'dir' => array('.svn','CVS' + ) + ); + protected $templateList = array(); + protected $includesList = array(); + public $templateObj = NULL; + protected $gfObj = NULL; + protected $tabs = NULL; + + protected $finalSection; + + private $isValid=FALSE; + private $reason=NULL; + + //------------------------------------------------------------------------ + /** + * The CONSTRUCTOR. Duh. + */ + public function __construct($testOnly=FALSE) { + if($testOnly === 'unit_test') { + //It's just a test, don't do anything we might regret later. + $this->isTest = TRUE; + } + else { + $this->get_version(); + $this->get_project(); + //make a cs_globalFunctions{} object. + $this->gfObj = new cs_globalFunctions(); + + //setup the section stuff... + $repArr = array($_SERVER['SCRIPT_NAME'], "/"); + $_SERVER['REQUEST_URI'] = ereg_replace('^/', "", $_SERVER['REQUEST_URI']); + + //figure out the section & subsection stuff. + $this->section = $this->clean_url($_SERVER['REQUEST_URI']); + + $this->initialize_locals(); + } + }//end __construct() + //------------------------------------------------------------------------ + + + + //------------------------------------------------------------------------ + /** + * Creates internal objects & prepares for later usage. + */ + private function initialize_locals() { + //build the templating engine: this may cause an immediate redirect, if they need to be logged-in. + //TODO: find a way to define this on a per-page basis. Possibly have templateObj->check_login() + // run during the "finish" stage... probably using GenericPage{}->check_login(). + $this->templateObj = new cs_genericPage(FALSE, "main.shared.tmpl"); + + //setup some default template vars. + $this->templateObj->add_template_var('date', date('m-d-Y')); + $this->templateObj->add_template_var('time', date('H:i:s')); + + $myUrl = '/'; + if(strlen($this->section) && $this->section !== 0) { + $myUrl = '/'. $this->section; + } + $this->templateObj->add_template_var('CURRENT_URL', $myUrl); + + //create a fileSystem object. + $this->fileSystemObj = new cs_fileSystemClass(); + + //create a tabs object, in case they want to load tabs on the page. + $this->tabs = new cs_tabs($this->templateObj); + + //check versions, make sure they're all the same. + $myVersion = $this->get_version(); + if($this->templateObj->get_version() !== $myVersion) { + throw new exception(__METHOD__ .": ". get_class($this->templateObj) ." has mismatched version (". $this->templateObj->get_version() ." does not equal ". $myVersion .")"); + } + if($this->fileSystemObj->get_version() !== $myVersion) { + throw new exception(__METHOD__ .": ". get_cl... [truncated message content] |
From: <cra...@us...> - 2009-02-06 20:51:49
|
Revision: 943 http://cs-project.svn.sourceforge.net/cs-project/?rev=943&view=rev Author: crazedsanity Date: 2009-02-06 20:51:48 +0000 (Fri, 06 Feb 2009) Log Message: ----------- remove cs-content & cs-phpxml to make way for new versions. Removed Paths: ------------- releases/1.2/lib/cs-content/ releases/1.2/lib/cs-phpxml/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cra...@us...> - 2009-02-06 20:57:27
|
Revision: 944 http://cs-project.svn.sourceforge.net/cs-project/?rev=944&view=rev Author: crazedsanity Date: 2009-02-06 20:57:19 +0000 (Fri, 06 Feb 2009) Log Message: ----------- New versions of libraries for version 1.2.0-ALPHA9 Added Paths: ----------- releases/1.2/lib/cs-arrayToPath/ releases/1.2/lib/cs-arrayToPath/CREDITS releases/1.2/lib/cs-arrayToPath/LICENSE releases/1.2/lib/cs-arrayToPath/VERSION releases/1.2/lib/cs-arrayToPath/cs_arrayToPath.class.php releases/1.2/lib/cs-arrayToPath/tests/ releases/1.2/lib/cs-arrayToPath/tests/example_test.php releases/1.2/lib/cs-arrayToPath/tests/testOfA2P.php releases/1.2/lib/cs-content/ releases/1.2/lib/cs-content/CREDITS releases/1.2/lib/cs-content/LICENSE releases/1.2/lib/cs-content/README.txt releases/1.2/lib/cs-content/VERSION releases/1.2/lib/cs-content/abstract/ releases/1.2/lib/cs-content/abstract/cs_content.abstract.class.php releases/1.2/lib/cs-content/abstract/cs_phpDB.abstract.class.php releases/1.2/lib/cs-content/contentSystem.class.php releases/1.2/lib/cs-content/cs_bbCodeParser.class.php releases/1.2/lib/cs-content/cs_fileSystem.class.php releases/1.2/lib/cs-content/cs_genericPage.class.php releases/1.2/lib/cs-content/cs_globalFunctions.class.php releases/1.2/lib/cs-content/cs_phpDB.class.php releases/1.2/lib/cs-content/cs_session.class.php releases/1.2/lib/cs-content/cs_siteConfig.class.php releases/1.2/lib/cs-content/cs_tabs.class.php releases/1.2/lib/cs-content/db_types/ releases/1.2/lib/cs-content/db_types/cs_phpDB__mysql.class.php releases/1.2/lib/cs-content/db_types/cs_phpDB__pgsql.class.php releases/1.2/lib/cs-content/db_types/cs_phpDB__sqlite.class.php releases/1.2/lib/cs-content/required/ releases/1.2/lib/cs-content/required/template.inc releases/1.2/lib/cs-content/sample_files/ releases/1.2/lib/cs-content/sample_files/public_html/ releases/1.2/lib/cs-content/sample_files/public_html/.htaccess releases/1.2/lib/cs-content/sample_files/public_html/content releases/1.2/lib/cs-content/sample_files/public_html/index.php releases/1.2/lib/cs-content/sample_files/templates/ releases/1.2/lib/cs-content/sample_files/templates/content/ releases/1.2/lib/cs-content/sample_files/templates/content/index.content.tmpl releases/1.2/lib/cs-content/sample_files/templates/footer.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/header.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/infobar.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/main.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/menu.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/ releases/1.2/lib/cs-content/sample_files/templates/system/404.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/construction.content.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/db_error.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/message_box.tmpl releases/1.2/lib/cs-content/tests/ releases/1.2/lib/cs-content/tests/example_test.php releases/1.2/lib/cs-content/tests/files/ releases/1.2/lib/cs-content/tests/files/gptest_all-together.txt releases/1.2/lib/cs-content/tests/files/sampleConfig.xml releases/1.2/lib/cs-content/tests/files/templates/ releases/1.2/lib/cs-content/tests/files/templates/content.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/footer.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/infobar.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/main.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/menubar.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/title.shared.tmpl releases/1.2/lib/cs-content/tests/testOfCSContent.php releases/1.2/lib/cs-phpxml/ releases/1.2/lib/cs-phpxml/CREDITS releases/1.2/lib/cs-phpxml/LICENSE releases/1.2/lib/cs-phpxml/README.txt releases/1.2/lib/cs-phpxml/VERSION releases/1.2/lib/cs-phpxml/cs_phpxml.abstract.class.php releases/1.2/lib/cs-phpxml/cs_phpxmlBuilder.class.php releases/1.2/lib/cs-phpxml/cs_phpxmlCreator.class.php releases/1.2/lib/cs-phpxml/cs_phpxmlParser.class.php releases/1.2/lib/cs-phpxml/tests/ releases/1.2/lib/cs-phpxml/tests/example_test.php releases/1.2/lib/cs-phpxml/tests/files/ releases/1.2/lib/cs-phpxml/tests/files/test1.xml releases/1.2/lib/cs-phpxml/tests/testOfCSPHPXML.php releases/1.2/lib/cs-versionparse/ releases/1.2/lib/cs-versionparse/CREDITS releases/1.2/lib/cs-versionparse/LICENSE releases/1.2/lib/cs-versionparse/VERSION releases/1.2/lib/cs-versionparse/cs_version.abstract.class.php releases/1.2/lib/cs-versionparse/tests/ releases/1.2/lib/cs-versionparse/tests/example_test.php releases/1.2/lib/cs-versionparse/tests/files/ releases/1.2/lib/cs-versionparse/tests/files/version1 releases/1.2/lib/cs-versionparse/tests/files/version2 releases/1.2/lib/cs-versionparse/tests/files/version3 releases/1.2/lib/cs-versionparse/tests/testOfCSVersionParse.php Added: releases/1.2/lib/cs-arrayToPath/CREDITS =================================================================== --- releases/1.2/lib/cs-arrayToPath/CREDITS (rev 0) +++ releases/1.2/lib/cs-arrayToPath/CREDITS 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,3 @@ + +Lead Developer: Dan Falconer (cra...@us...) + Added: releases/1.2/lib/cs-arrayToPath/LICENSE =================================================================== --- releases/1.2/lib/cs-arrayToPath/LICENSE (rev 0) +++ releases/1.2/lib/cs-arrayToPath/LICENSE 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,291 @@ +NOTE: a full HTML version of this license can be found at: +http://www.opensource.org/licenses/gpl-license.php + +It has been reproduced below without any HTML. +========================================================================== + +The GNU General Public License (GPL) + +Version 2, June 1991 + + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS Added: releases/1.2/lib/cs-arrayToPath/VERSION =================================================================== --- releases/1.2/lib/cs-arrayToPath/VERSION (rev 0) +++ releases/1.2/lib/cs-arrayToPath/VERSION 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,5 @@ +## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. + +VERSION: 1.0 +PROJECT: cs-arrayToPath +$HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/VERSION $ \ No newline at end of file Added: releases/1.2/lib/cs-arrayToPath/cs_arrayToPath.class.php =================================================================== --- releases/1.2/lib/cs-arrayToPath/cs_arrayToPath.class.php (rev 0) +++ releases/1.2/lib/cs-arrayToPath/cs_arrayToPath.class.php 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,385 @@ +<?php +/* + * Created on Nov 20, 2006 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author: crazedsanity $ + * Current Revision:::: $Revision: 25 $ + * Repository Location: $HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/cs_arrayToPath.class.php $ + * Last Updated:::::::: $Date: 2009-01-25 17:17:49 -0600 (Sun, 25 Jan 2009) $ + * + * + * Basically traverses an array as though it were a filesystem. In the given example, it looks + * more complex than necessary, but the "NEW WAY" is very programatic, whereas the "OLD WAY" is + * just that: OLD. Also, the new way is very extensible, and is handy when performing a LOT of + * complex operations on an array. + * Example: + * OLD WAY: + * $my_data = $array['path']['to']['your']['hidden']['data']; + * $my_vault = $array['path']['to']['your']['hidden']['vault']; + * $my_other = $array['path']['to']['your']['hidden']['other']; + * + * $array['path']['to']['my'] = array(); + * $array['path']['to']['my']['data'] = array(); + * $array['path']['to']['my']['data']['is'] = "here"; + * NEW WAY: + * $arrayToPath = new arrayToPath($array); + * $my_data = $arrayToPath('/path/to/your/hidden/data'); + * $my_vault = $arrayToPath('/path/to/your/hidden/vault'); + * $my_other = $arrayToPath('/path/to/your/hidden/other'); + * + * $arrayToPath->set_data('/path/to/my/data/is', 'here'); + */ + + +require_once(dirname(__FILE__) .'/../cs-versionparse/cs_version.abstract.class.php'); + +class cs_arrayToPath extends cs_versionAbstract { + + private $prefix = NULL; //the first directory to use. + private $data; + private $iteration = 0; + + //====================================================================================== + /** + * The constructor. + * + * @param $array (array) The data that will be used when + * + * TODO::: there is a strange recursion issue when $prefix is non-null: prefix is presently hardwired as NULL for now... + */ + public function __construct($array) { + $this->set_version_file_location(dirname(__FILE__) . '/VERSION'); + if($array === 'unit_test') { + //it's a unit test. + $this->isTest = TRUE; + } + else { + $this->get_version(); + if(!is_array($array)) { + //I don't deal with non-arrays. Idiot. + exit('arrayToPath{}->__construct(): got an invalid datatype.'); + } + //create a reference to the data, so if it changes, the class doesn't have to be re-initialized. + $this->data = $array; + } + }//end __construct() + //====================================================================================== + + + //====================================================================================== + /** + * Takes a path & returns the appropriate index in the session. + * + * @param $path <str> path to the appropriate section in the session. + * + * @return <NULL> FAIL: unable to find requested index. + * @return <mixed> PASS: this is the value of the index. + */ + public function get_data($path=NULL) { + $myIndexList = array(); + $path = $this->fix_path($path); + + if(is_null($path) || (strlen($path) < 1)) { + //they just want ALL THE DATA. + $retval = $this->data; + } + else { + //get the list of indices in our data that we have to traverse. + $myIndexList = $this->explode_path($path); + + //set an initial retval. + $retval = $this->get_data_segment($this->data, $myIndexList[0]); + unset($myIndexList[0]); + + if(count($myIndexList) > 0) { + foreach($myIndexList as $indexName) { + $retval = $this->get_data_segment($retval, $indexName); + if(is_null($retval)) { + //hmm... well, if it's null, it's nothing which can have a sub-index. Stop here. + break; + } + } + } + } + + return($retval); + + }//end get_data() + //====================================================================================== + + + + //====================================================================================== + /** + * Returns a given index from a piece of data, used by get_data(). + */ + private function get_data_segment($fromThis, $indexName) { + if(is_array($fromThis)) { + //it's an array. + $retval = $fromThis[$indexName]; + } + elseif(is_object($fromThis)) { + //it's an object. + $retval = $fromThis->$indexName; + } + return($retval); + }//end get_data_segment() + //====================================================================================== + + + + //====================================================================================== + /** + * Fixes issues with extra slashes and such. + * + * @param $path <str> path to fix + * + * @return <str> PASS: this is the fixed path + */ + private function fix_path($path) { + $retval = $path; + if(!is_null($path) && strlen($path)) { + + $retval = preg_replace('/[\/]{2,}/', '/', $retval); + if(strlen($retval) && preg_match('/\./', $retval)) { + + $pieces = explode('/', $retval); + + $finalPieces = array(); + for($i=0; $i < count($pieces); $i++) { + $dirName = $pieces[$i]; + if($dirName == '.') { + //do nothing; don't bother appending. + } + elseif($dirName == '..') { + $rippedIndex = array_pop($finalPieces); + } + else { + $finalPieces[] = $dirName; + } + } + + #$retval = $this->gf->string_from_array($finalPieces, NULL, '/'); + $retval = ""; + foreach($finalPieces as $bit) { + if(strlen($retval)) { + $retval .= '/'. $bit; + } + else { + $retval = '/'. $bit; + } + } + } + + //remove slashes at the beginning or end of the path. + $retval = preg_replace('/\/$/', '', $retval); + + //remove a trailing slash, if present, before returning. + $retval = preg_replace('/\/$/', '', $retval); + } + + return($retval); + + }//end fix_path() + //====================================================================================== + + + + //====================================================================================== + /** + * Sets data into the given path, with options to override our internal prefix, and to + * force-overwrite data if it's not an array. + * + * @param $path <str> path to set the data into. + * @param $data <mixed> what to set into the given path. + * + * @return 0 FAIL: old data doesn't match new data. + * @return 1 PASS: everything lines-up. + */ + public function set_data($path, $data) { + //get the list of indices in the session that we have to traverse. + $myIndexList = $this->explode_path($path); + + $retval = 0; + //Use an internal iterator to go through the little bits of the session & set the + // data where it's supposed to be. + if($path === '/' || count($myIndexList) == 0) { + //setting the data. + $this->data = $data; + $retval = 1; + } + elseif(count($myIndexList) == 1) { + //that should be simple: set the index to be $data. + $this->data[$myIndexList[0]] = $data; + $retval = 1; + } + elseif(count($myIndexList) > 1) { + $this->internal_iterator($this->data, $path, $data); + $retval = 1; + } + + return($retval); + }//end set_data() + //====================================================================================== + + + //====================================================================================== + /** + * Iterates through the session to create the values for set_data(). This method passes + * AND returns the $array argument by reference. + * + * @param &$array (array) iterate through this. + * @param $path (array) numbered array of keys, representing a path through the + * internal data to go through to set $data. + * @param $data (mixed) data to set into the path referenced in $indexList. + * + * @return <void> + */ + protected function &internal_iterator(&$array, $path, $data) { + //make sure it doesn't call itself to death. ;) + $this->iteration++; + + if($this->iteration > 1000) { + throw new exception("arrayToPath{}: too many iterations, path=($path)"); + } + + $retval = 0; + $indexList = $this->explode_path($path); + $myIndex = array_shift($indexList); + $path = $this->string_from_array($indexList); + + if(is_array($array) && !strlen($path)) { + if(isset($myIndex)) { + //set the final piece of the array. + $array[$myIndex] = $data; + } + else { + //something is broken. + throw new exception("arrayToPath{}->internal_iterator(): no index ($myIndex) to follow at the end of the path."); + } + } + elseif(is_array($array) && strlen($path)) { + if((count($indexList) == 0) || (is_array($indexList) && count($indexList) > 1)) { + if(!is_array($array[$myIndex])) { + $array[$myIndex] = array(); + } + $array = &$array[$myIndex]; + $newPath = $this->string_from_array($indexList); + + $this->internal_iterator($array, $path, $data); + } + elseif(is_array($indexList) && count($indexList) == 1) { + if(!is_array($array[$myIndex])) { + $array[$myIndex] = array(); + } + $array = &$array[$myIndex]; + $this->internal_iterator($array, $indexList[0], $data); + } + else { + //not sure what to do but throw an exception. + throw new exception("arrayToPath{}->internal_iterator(): unknown error ('not sure what to do'): ($array)"); + } + } + elseif(is_object($array)) { + //can't handle objects...? + throw new exception("arrayToPath{}->internal_iterator(): can't handle objects...?"); + } + else { + //something is... er... broken. + throw new exception("arrayToPath{}->internal_iterator(): found unknown data type in path ($array)"); + } + + //decrement the iteration, so methods using it can call it multiple times without worrying about accidentally hitting the limit. + $this->iteration--; + }//end internal_iterator() + //====================================================================================== + + + + + //====================================================================================== + /** + * Will unset the final index in the $path var. I.E. to unset $this->array['x']['y'], + * call unset_data('/x/y') + * + * @param $path (str) path to unset data; The last item in the path will be removed. + */ + public function unset_data($path) { + //explode the path. + $pathArr = $this->explode_path($path); + $removeThis = array_pop($pathArr); + $path = $this->string_from_array($pathArr); + + //retrieve the data... + $myData = $this->get_data($path); + + if(is_array($myData)) { + //now remove the bit of data as requested. + unset($myData[$removeThis]); + //update the path with our new data. + $retval = $this->set_data($path, $myData); + } + else { + //throw a terrible error. + throw new exception("unset_data(): data ($myData) wasn't an array! ($path)"); + } + + return($retval); + }//end unset_data() + //====================================================================================== + + + + //====================================================================================== + /** + * Performs all the work of exploding the path and fixing it. + * + * @param $path <string> Path to work with. + * @return <array> PASS: array contains exploded path. + */ + public function explode_path($path) { + $path = preg_replace('/\/\//', '/', $path); + $path = $this->fix_path($path); + $retval = explode('/', $path); + + //if the initial index is blank, just remove it. + if($retval[0] == '' || strlen($retval[0]) < 1) { + //it was blank! KILL IT! + $checkItOut = array_shift($retval); + } + + return($retval); + }//end explode_path() + //====================================================================================== + + + + //====================================================================================== + public function reload_data($array) { + //call the constructor on it, and pass along the CURRENT prefix, so it doesn't get reset. + $this->__construct($array); + }//end reload_data() + //====================================================================================== + + + + //====================================================================================== + private function string_from_array(array $array) { + $retval = ""; + foreach($array as $index) { + if(strlen($retval)) { + $retval .= "/". $index; + } + else { + $retval = $index; + } + } + return($retval); + }//end string_from_array() + //====================================================================================== + +}//end arrayToPath{} + +?> Added: releases/1.2/lib/cs-arrayToPath/tests/example_test.php =================================================================== --- releases/1.2/lib/cs-arrayToPath/tests/example_test.php (rev 0) +++ releases/1.2/lib/cs-arrayToPath/tests/example_test.php 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,19 @@ +<?php +/* + * Created on Jan 25, 2009 + * + * FILE INFORMATION: + * + * $HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/tests/example_test.php $ + * $Id: example_test.php 23 2009-01-25 21:25:10Z crazedsanity $ + * $LastChangedDate: 2009-01-25 15:25:10 -0600 (Sun, 25 Jan 2009) $ + * $LastChangedBy: crazedsanity $ + * $LastChangedRevision: 23 $ + */ + + +require_once(dirname(__FILE__) .'/testOfA2P.php'); + +$test = &new TestOfA2P(); +$test->run(new HtmlReporter()) +?> Added: releases/1.2/lib/cs-arrayToPath/tests/testOfA2P.php =================================================================== --- releases/1.2/lib/cs-arrayToPath/tests/testOfA2P.php (rev 0) +++ releases/1.2/lib/cs-arrayToPath/tests/testOfA2P.php 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,75 @@ +<?php +/* + * Created on Jan 25, 2009 + * + * FILE INFORMATION: + * + * $HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/tests/testOfA2P.php $ + * $Id: testOfA2P.php 25 2009-01-25 23:17:49Z crazedsanity $ + * $LastChangedDate: 2009-01-25 17:17:49 -0600 (Sun, 25 Jan 2009) $ + * $LastChangedBy: crazedsanity $ + * $LastChangedRevision: 25 $ + */ + +require_once(dirname(__FILE__) .'/../cs_arrayToPath.class.php'); + +class testOfA2P extends UnitTestCase { + + //------------------------------------------------------------------------- + function setUp() { + $this->a2p = new cs_arrayToPath(array()); + $this->gfObj = new cs_globalFunctions; + }//end setUp() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + function tearDown() { + }//end tearDown() + //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + function test_basics() { + //make sure nothing is in the object initialially. + $this->assertEqual(array(), $this->a2p->get_data()); + + $newData = array( + 'look at me' => '23dasdvcv3q3qeedasd' + ); + $this->a2p->reload_data($newData); + $this->assertNotEqual(array(), $this->a2p->get_data()); + + + //load a complex array & test to ensure the returned value is the same. + $newData = array( + 'x' => array( + 'y' => array( + 'z' => array( + 'fiNal' => 'asdfadsfadfadsfasdf' + ) + ), + '_y_' => null, + '-' => null + ), + 'a nother path2 Stuff -+=~!@#$' + ); + $this->a2p->reload_data($newData); + $this->assertEqual($newData, $this->a2p->get_data()); + $this->assertEqual($newData['x']['y']['z']['fiNal'], $this->a2p->get_data('/x/y/z/fiNal')); + + $this->a2p->set_data('/x/y/z/fiNal', null); + $this->assertNotEqual($this->a2p->get_data('/x/y/z/fiNal'), $newData['x']['y']['z']['fiNal']); + + //ensure paths with dots are ok. + $this->assertEqual($this->a2p->get_data('/x/y/z/fiNal'), $this->a2p->get_data('/x/y/z/g/q/x/../../../fiNal')); + + //make sure extra slashes are okay. + $this->assertEqual($this->a2p->get_data('/x/y/z/fiNal'), $this->a2p->get_data('/x/y//z///fiNal//')); + }//end test_basics() + //------------------------------------------------------------------------- + +}//end testOfA2P{} +?> Added: releases/1.2/lib/cs-content/CREDITS =================================================================== --- releases/1.2/lib/cs-content/CREDITS (rev 0) +++ releases/1.2/lib/cs-content/CREDITS 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,3 @@ + +Lead Developer: Dan Falconer (cra...@us...) + Added: releases/1.2/lib/cs-content/LICENSE =================================================================== --- releases/1.2/lib/cs-content/LICENSE (rev 0) +++ releases/1.2/lib/cs-content/LICENSE 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,291 @@ +NOTE: a full HTML version of this license can be found at: +http://www.opensource.org/licenses/gpl-license.php + +It has been reproduced below without any HTML. +========================================================================== + +The GNU General Public License (GPL) + +Version 2, June 1991 + + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS Added: releases/1.2/lib/cs-content/README.txt =================================================================== --- releases/1.2/lib/cs-content/README.txt (rev 0) +++ releases/1.2/lib/cs-content/README.txt 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,5 @@ +Documentation is now located at: +[https://cs-content.svn.sourceforge.net/svnroot/cs-content/documentation]. It +has been moved to avoid unnecessarily large downloads. + +$Id: README.txt 267 2008-04-29 15:27:28Z crazedsanity $ \ No newline at end of file Added: releases/1.2/lib/cs-content/VERSION =================================================================== --- releases/1.2/lib/cs-content/VERSION (rev 0) +++ releases/1.2/lib/cs-content/VERSION 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,5 @@ +## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. + +VERSION: 1.0-ALPHA7 +PROJECT: cs-content +$HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/1.0/VERSION $ \ No newline at end of file Added: releases/1.2/lib/cs-content/abstract/cs_content.abstract.class.php =================================================================== --- releases/1.2/lib/cs-content/abstract/cs_content.abstract.class.php (rev 0) +++ releases/1.2/lib/cs-content/abstract/cs_content.abstract.class.php 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,36 @@ +<?php +/* + * Created on Jan 29, 2009 + * + * FILE INFORMATION: + * + * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/1.0/abstract/cs_content.abstract.class.php $ + * $Id: cs_content.abstract.class.php 335 2009-01-29 21:25:58Z crazedsanity $ + * $LastChangedDate: 2009-01-29 15:25:58 -0600 (Thu, 29 Jan 2009) $ + * $LastChangedBy: crazedsanity $ + * $LastChangedRevision: 335 $ + */ + +require_once(dirname(__FILE__) ."/../../cs-versionparse/cs_version.abstract.class.php"); + + +abstract class cs_contentAbstract extends cs_versionAbstract { + + //------------------------------------------------------------------------- + function __construct($makeGfObj=true) { + $this->set_version_file_location(dirname(__FILE__) . '/../VERSION'); + $this->get_version(); + $this->get_project(); + + if($makeGfObj === true) { + //make a cs_globalFunctions{} object. + require_once(dirname(__FILE__) ."/../cs_globalFunctions.class.php"); + $this->gfObj = new cs_globalFunctions(); + } + }//end __construct() + //------------------------------------------------------------------------- + + + +} +?> \ No newline at end of file Added: releases/1.2/lib/cs-content/abstract/cs_phpDB.abstract.class.php =================================================================== --- releases/1.2/lib/cs-content/abstract/cs_phpDB.abstract.class.php (rev 0) +++ releases/1.2/lib/cs-content/abstract/cs_phpDB.abstract.class.php 2009-02-06 20:57:19 UTC (rev 944) @@ -0,0 +1,166 @@ +<?php +/* + * Created on Jan 29, 2009 + * + * FILE INFORMATION: + * + * $HeadURL: https://cs-content.svn.sourceforge.net/svnroot/cs-content/trunk/1.0/abstract/cs_phpDB.abstract.class.php $ + * $Id: cs_phpDB.abstract.class.php 330 2009-01-29 19:44:01Z crazedsanity $ + * $LastChangedDate: 2009-01-29 13:44:01 -0600 (Thu, 29 Jan 2009) $ + * $LastChangedBy: crazedsanity $ + * $LastChangedRevision: 330 $ + */ + +abstract class cs_phpDBAbstract { + + /** Internal result set pointer. */ + protected $result = NULL; + + /** Internal error code. */ + protected $errorCode = 0; + + /** Status of the current transaction. */ + protected $transStatus = NULL; + + /** Whether there is a transaction in progress or not. */ + protected $inTrans = FALSE; + + /** Holds the last query performed. */ + protected $lastQuery = NULL; + + /** List of queries that have been run */ + protected $queryList=array(); + + /** How many seconds to wait for a query before cancelling it. */ + protected $timeOutSeconds = NULL; + + /** Internal check to determine if a connection has been established. */ + protected $isConnected=FALSE; + + /** Internal check to determine if the parameters have been set. */ + protected $paramsAreSet=FALSE; + + /** Resource handle. */ + protected $connectionID = -1; + + /** Hostname or IP to connect to */ + protected $host; + + /** Port to connect to (default for Postgres is 5432) */ + protected $port; + + /** Name of the database */ + protected $dbname; + + /** Username to connect to the database */ + protected $user; + + /** password to connect to the database */ + protected $password; + + /** Row counter for looping through records */ + protected $row = -1; + + /** cs_globalFunctions object, for string stuff. */ + protected $gfObj; + + /** Internal check to ensure the object has been properly created. */ + protected $isInitialized=FALSE; + + /** List of prepared statements, indexed off the name, with the sub-array being fieldname=>dataType. */ + protected $preparedStatements = array(); + + /** Set to TRUE to save all queries into an array. */ + protected $useQueryList=FALSE; + + /** array that essentially remembers how many times beginTrans() was called. */ + protected $transactionTree = NULL; + + + + //Define some abstract methods so they MUST be provided in order for things to work. + abstract public function set_db_info(array $params); + abstract public function close(); + abstract public function connect(array $dbParams=NULL, $forceNewConnection=FALSE); + abstract public function exec($query); + abstract public function errorMsg($setMessage=null, $logError=null); + abstract public function fobject(); + abstract public function farray(); + abstract public function farray_fieldnames($index=null, $numbered=null,$unsetIndex=1); + abstr... [truncated message content] |
From: <cra...@us...> - 2009-02-06 21:06:35
|
Revision: 945 http://cs-project.svn.sourceforge.net/cs-project/?rev=945&view=rev Author: crazedsanity Date: 2009-02-06 21:06:25 +0000 (Fri, 06 Feb 2009) Log Message: ----------- REVERSE-MERGE of last commits; 1.2.0-ALPHA9 has unexpected fatal errors. SVN COMMANDS::: merge --depth=infinity -r944:941 https://cs-project.svn.sourceforge.net/svnroot/cs-project/releases/1.2 Added Paths: ----------- releases/1.2/lib/cs-arrayToPath/ releases/1.2/lib/cs-arrayToPath/LICENSE releases/1.2/lib/cs-arrayToPath/VERSION releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php releases/1.2/lib/cs-arrayToPath/cs_versionAbstract.class.php releases/1.2/lib/cs-content/ releases/1.2/lib/cs-content/LICENSE releases/1.2/lib/cs-content/README.txt releases/1.2/lib/cs-content/VERSION releases/1.2/lib/cs-content/contentSystemClass.php releases/1.2/lib/cs-content/cs_bbCodeParser.class.php releases/1.2/lib/cs-content/cs_fileSystemClass.php releases/1.2/lib/cs-content/cs_genericPageClass.php releases/1.2/lib/cs-content/cs_globalFunctions.php releases/1.2/lib/cs-content/cs_phpDB.php releases/1.2/lib/cs-content/cs_sessionClass.php releases/1.2/lib/cs-content/cs_tabsClass.php releases/1.2/lib/cs-content/cs_versionAbstract.class.php releases/1.2/lib/cs-content/db_types/ releases/1.2/lib/cs-content/db_types/cs_phpDB__mysql.class.php releases/1.2/lib/cs-content/db_types/cs_phpDB__pgsql.class.php releases/1.2/lib/cs-content/db_types/cs_phpDB__sqlite.class.php releases/1.2/lib/cs-content/sample_files/ releases/1.2/lib/cs-content/sample_files/public_html/ releases/1.2/lib/cs-content/sample_files/public_html/.htaccess releases/1.2/lib/cs-content/sample_files/public_html/content releases/1.2/lib/cs-content/sample_files/public_html/index.php releases/1.2/lib/cs-content/sample_files/templates/ releases/1.2/lib/cs-content/sample_files/templates/content/ releases/1.2/lib/cs-content/sample_files/templates/content/index.content.tmpl releases/1.2/lib/cs-content/sample_files/templates/footer.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/header.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/infobar.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/main.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/menu.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/ releases/1.2/lib/cs-content/sample_files/templates/system/404.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/construction.content.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/db_error.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/message_box.tmpl releases/1.2/lib/cs-content/template.inc releases/1.2/lib/cs-phpxml/ releases/1.2/lib/cs-phpxml/LICENSE releases/1.2/lib/cs-phpxml/README.txt releases/1.2/lib/cs-phpxml/VERSION releases/1.2/lib/cs-phpxml/xmlAbstract.class.php releases/1.2/lib/cs-phpxml/xmlBuilderClass.php releases/1.2/lib/cs-phpxml/xmlCreatorClass.php releases/1.2/lib/cs-phpxml/xmlParserClass.php Removed Paths: ------------- releases/1.2/lib/cs-arrayToPath/ releases/1.2/lib/cs-arrayToPath/LICENSE releases/1.2/lib/cs-arrayToPath/VERSION releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php releases/1.2/lib/cs-arrayToPath/cs_versionAbstract.class.php releases/1.2/lib/cs-content/ releases/1.2/lib/cs-content/LICENSE releases/1.2/lib/cs-content/README.txt releases/1.2/lib/cs-content/VERSION releases/1.2/lib/cs-content/contentSystemClass.php releases/1.2/lib/cs-content/cs_bbCodeParser.class.php releases/1.2/lib/cs-content/cs_fileSystemClass.php releases/1.2/lib/cs-content/cs_genericPageClass.php releases/1.2/lib/cs-content/cs_globalFunctions.php releases/1.2/lib/cs-content/cs_phpDB.php releases/1.2/lib/cs-content/cs_sessionClass.php releases/1.2/lib/cs-content/cs_tabsClass.php releases/1.2/lib/cs-content/cs_versionAbstract.class.php releases/1.2/lib/cs-content/db_types/ releases/1.2/lib/cs-content/db_types/cs_phpDB__mysql.class.php releases/1.2/lib/cs-content/db_types/cs_phpDB__pgsql.class.php releases/1.2/lib/cs-content/db_types/cs_phpDB__sqlite.class.php releases/1.2/lib/cs-content/sample_files/ releases/1.2/lib/cs-content/sample_files/public_html/ releases/1.2/lib/cs-content/sample_files/public_html/.htaccess releases/1.2/lib/cs-content/sample_files/public_html/content releases/1.2/lib/cs-content/sample_files/public_html/index.php releases/1.2/lib/cs-content/sample_files/templates/ releases/1.2/lib/cs-content/sample_files/templates/content/ releases/1.2/lib/cs-content/sample_files/templates/content/index.content.tmpl releases/1.2/lib/cs-content/sample_files/templates/footer.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/header.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/infobar.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/main.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/menu.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/ releases/1.2/lib/cs-content/sample_files/templates/system/404.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/construction.content.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/db_error.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/message_box.tmpl releases/1.2/lib/cs-content/template.inc releases/1.2/lib/cs-phpxml/ releases/1.2/lib/cs-phpxml/LICENSE releases/1.2/lib/cs-phpxml/README.txt releases/1.2/lib/cs-phpxml/VERSION releases/1.2/lib/cs-phpxml/xmlAbstract.class.php releases/1.2/lib/cs-phpxml/xmlBuilderClass.php releases/1.2/lib/cs-phpxml/xmlCreatorClass.php releases/1.2/lib/cs-phpxml/xmlParserClass.php releases/1.2/lib/cs-versionparse/ Deleted: releases/1.2/lib/cs-arrayToPath/LICENSE =================================================================== --- releases/1.2/lib/cs-arrayToPath/LICENSE 2009-02-06 20:47:43 UTC (rev 941) +++ releases/1.2/lib/cs-arrayToPath/LICENSE 2009-02-06 21:06:25 UTC (rev 945) @@ -1,291 +0,0 @@ -NOTE: a full HTML version of this license can be found at: -http://www.opensource.org/licenses/gpl-license.php - -It has been reproduced below without any HTML. -========================================================================== - -The GNU General Public License (GPL) - -Version 2, June 1991 - - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS Copied: releases/1.2/lib/cs-arrayToPath/LICENSE (from rev 941, releases/1.2/lib/cs-arrayToPath/LICENSE) =================================================================== --- releases/1.2/lib/cs-arrayToPath/LICENSE (rev 0) +++ releases/1.2/lib/cs-arrayToPath/LICENSE 2009-02-06 21:06:25 UTC (rev 945) @@ -0,0 +1,291 @@ +NOTE: a full HTML version of this license can be found at: +http://www.opensource.org/licenses/gpl-license.php + +It has been reproduced below without any HTML. +========================================================================== + +The GNU General Public License (GPL) + +Version 2, June 1991 + + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS Deleted: releases/1.2/lib/cs-arrayToPath/VERSION =================================================================== --- releases/1.2/lib/cs-arrayToPath/VERSION 2009-02-06 20:47:43 UTC (rev 941) +++ releases/1.2/lib/cs-arrayToPath/VERSION 2009-02-06 21:06:25 UTC (rev 945) @@ -1,5 +0,0 @@ -## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. - -VERSION: 0.2.2 -PROJECT: cs-arrayToPath -$HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/VERSION $ \ No newline at end of file Copied: releases/1.2/lib/cs-arrayToPath/VERSION (from rev 941, releases/1.2/lib/cs-arrayToPath/VERSION) =================================================================== --- releases/1.2/lib/cs-arrayToPath/VERSION (rev 0) +++ releases/1.2/lib/cs-arrayToPath/VERSION 2009-02-06 21:06:25 UTC (rev 945) @@ -0,0 +1,5 @@ +## Stores the current version of the cs-content system, and it's source. Please do NOT modify this file. + +VERSION: 0.2.2 +PROJECT: cs-arrayToPath +$HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/VERSION $ \ No newline at end of file Deleted: releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php =================================================================== --- releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php 2009-02-06 20:47:43 UTC (rev 941) +++ releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php 2009-02-06 21:06:25 UTC (rev 945) @@ -1,379 +0,0 @@ -<?php -/* - * Created on Nov 20, 2006 - * - * SVN INFORMATION::: - * ------------------- - * Last Author::::::::: $Author: crazedsanity $ - * Current Revision:::: $Revision: 17 $ - * Repository Location: $HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/arrayToPathClass.php $ - * Last Updated:::::::: $Date: 2007-09-12 14:24:46 -0500 (Wed, 12 Sep 2007) $ - * - * - * Basically traverses an array as though it were a filesystem. In the given example, it looks - * more complex than necessary, but the "NEW WAY" is very programatic, whereas the "OLD WAY" is - * just that: OLD. Also, the new way is very extensible, and is handy when performing a LOT of - * complex operations on an array. - * Example: - * OLD WAY: - * $my_data = $array['path']['to']['your']['hidden']['data']; - * $my_vault = $array['path']['to']['your']['hidden']['vault']; - * $my_other = $array['path']['to']['your']['hidden']['other']; - * - * $array['path']['to']['my'] = array(); - * $array['path']['to']['my']['data'] = array(); - * $array['path']['to']['my']['data']['is'] = "here"; - * NEW WAY: - * $arrayToPath = new arrayToPath($array); - * $my_data = $arrayToPath('/path/to/your/hidden/data'); - * $my_vault = $arrayToPath('/path/to/your/hidden/vault'); - * $my_other = $arrayToPath('/path/to/your/hidden/other'); - * - * $arrayToPath->set_data('/path/to/my/data/is', 'here'); - */ - - -require_once(dirname(__FILE__) .'/cs_versionAbstract.class.php'); - -class arrayToPath extends cs_a2p_versionAbstract { - - private $prefix = NULL; //the first directory to use. - private $data; - private $iteration = 0; - - //====================================================================================== - /** - * The constructor. - * - * @param $array (array) The data that will be used when - * - * TODO::: there is a strange recursion issue when $prefix is non-null: prefix is presently hardwired as NULL for now... - */ - public function __construct($array, $prefix=NULL) { - if($array === 'unit_test') { - //it's a unit test. - $this->isTest = TRUE; - } - else { - $this->get_version(); - $prefix=NULL; - if(!is_array($array)) { - //I don't deal with non-arrays. Idiot. - exit('arrayToPath{}->__construct(): got an invalid datatype.'); - } - //create a reference to the data, so if it changes, the class doesn't have to be re-initialized. - $this->data = $array; - - //now set the prefix ONLY if the prefix is valid. - if(!is_null($prefix) && strlen($prefix)) { - //got a good prefix, so use it. - $this->prefix = $prefix; - } - } - }//end __construct() - //====================================================================================== - - - //====================================================================================== - /** - * Takes a path & returns the appropriate index in the session. - * - * @param $path <str> path to the appropriate section in the session. - * - * @return <NULL> FAIL: unable to find requested index. - * @return <mixed> PASS: this is the value of the index. - */ - public function get_data($path=NULL) { - $myIndexList = array(); - $path = $this->fix_path($path); - - if(is_null($path) || (strlen($path) < 1)) { - //they just want ALL THE DATA. - $retval = $this->data; - } - else { - //get the list of indices in our data that we have to traverse. - $myIndexList = $this->explode_path($path); - - //set an initial retval. - $retval = $this->get_data_segment($this->data, $myIndexList[0]); - unset($myIndexList[0]); - - if(count($myIndexList) > 0) { - foreach($myIndexList as $indexName) { - $retval = $this->get_data_segment($retval, $indexName); - if(is_null($retval)) { - //hmm... well, if it's null, it's nothing which can have a sub-index. Stop here. - break; - } - } - } - } - - return($retval); - - }//end get_data() - //====================================================================================== - - - - //====================================================================================== - /** - * Returns a given index from a piece of data, used by get_data(). - */ - private function get_data_segment($fromThis, $indexName) { - if(is_array($fromThis)) { - //it's an array. - $retval = $fromThis[$indexName]; - } - elseif(is_object($fromThis)) { - //it's an object. - $retval = $fromThis->$indexName; - } - return($retval); - }//end get_data_segment() - //====================================================================================== - - - - //====================================================================================== - /** - * Pre-pends the internal $this->prefix onto the given path. - * - * @param $path <str> path to append $this->prefix onto. - * - * @return <str> PASS: this is the path with our prefix added. - */ - private function fix_path($path) { - if(is_null($path) && is_null($this->prefix)) { - //all data is null. don't bother changing it. - $retval = NULL; - } - else { - //remove slashes at the beginning or end of the path. - $path = preg_replace('/\/$/', '', $path); - - if(preg_match('/\/$/', $this->prefix)) { - //remove the trailing slash. - $this->prefix = preg_replace('/$\//', '', $this->prefix); - } - if(preg_match('/^\//', $this->prefix)) { - $this->prefix = preg_replace('/^\//', '', $this->prefix); - } - $path = preg_replace('/\/$/', '', $path); - - //should we add our prefix? - if(preg_match('/^\//', $path)) { - $retval = $path; - } - else { - $retval = $this->prefix ."/". $path; - } - - //remove a trailing slash, if present, before returning. - $retval = preg_replace('/\/$/', '', $retval); - } - - return($retval); - - }//end fix_path() - //====================================================================================== - - - - //====================================================================================== - /** - * Sets data into the given path, with options to override our internal prefix, and to - * force-overwrite data if it's not an array. - * - * @param $path <str> path to set the data into. - * @param $data <mixed> what to set into the given path. - * - * @return 0 FAIL: old data doesn't match new data. - * @return 1 PASS: everything lines-up. - */ - public function set_data($path, $data) { - //get the list of indices in the session that we have to traverse. - $myIndexList = $this->explode_path($path); - - $retval = 0; - //Use an internal iterator to go through the little bits of the session & set the - // data where it's supposed to be. - if($path === '/' || count($myIndexList) == 0) { - //setting the data. - $this->data = $data; - $retval = 1; - } - elseif(count($myIndexList) == 1) { - //that should be simple: set the index to be $data. - $this->data[$myIndexList[0]] = $data; - $retval = 1; - } - elseif(count($myIndexList) > 1) { - $this->internal_iterator($this->data, $path, $data); - $retval = 1; - } - - return($retval); - }//end set_data() - //====================================================================================== - - - //====================================================================================== - /** - * Iterates through the session to create the values for set_data(). This method passes - * AND returns the $array argument by reference. - * - * @param &$array (array) iterate through this. - * @param $path (array) numbered array of keys, representing a path through the - * internal data to go through to set $data. - * @param $data (mixed) data to set into the path referenced in $indexList. - * - * @return <void> - */ - protected function &internal_iterator(&$array, $path, $data) { - //make sure it doesn't call itself to death. ;) - $this->iteration++; - - if($this->iteration > 1000) { - throw new exception("arrayToPath{}: too many iterations, path=($path)"); - } - - $retval = 0; - $indexList = $this->explode_path($path); - $myIndex = array_shift($indexList); - $path = $this->string_from_array($indexList); - - if(is_array($array) && !strlen($path)) { - if(isset($myIndex)) { - //set the final piece of the array. - $array[$myIndex] = $data; - } - else { - //something is broken. - throw new exception("arrayToPath{}->internal_iterator(): no index ($myIndex) to follow at the end of the path."); - } - } - elseif(is_array($array) && strlen($path)) { - if((count($indexList) == 0) || (is_array($indexList) && count($indexList) > 1)) { - if(!is_array($array[$myIndex])) { - $array[$myIndex] = array(); - } - $array = &$array[$myIndex]; - $newPath = $this->string_from_array($indexList); - - $this->internal_iterator($array, $path, $data); - } - elseif(is_array($indexList) && count($indexList) == 1) { - if(!is_array($array[$myIndex])) { - $array[$myIndex] = array(); - } - $array = &$array[$myIndex]; - $this->internal_iterator($array, $indexList[0], $data); - } - else { - //not sure what to do but throw an exception. - throw new exception("arrayToPath{}->internal_iterator(): unknown error ('not sure what to do'): ($array)"); - } - } - elseif(is_object($array)) { - //can't handle objects...? - throw new exception("arrayToPath{}->internal_iterator(): can't handle objects...?"); - } - else { - //something is... er... broken. - throw new exception("arrayToPath{}->internal_iterator(): found unknown data type in path ($array)"); - } - - //decrement the iteration, so methods using it can call it multiple times without worrying about accidentally hitting the limit. - $this->iteration--; - }//end internal_iterator() - //====================================================================================== - - - - - //====================================================================================== - /** - * Will unset the final index in the $path var. I.E. to unset $this->array['x']['y'], - * call unset_data('/x/y') - * - * @param $path (str) path to unset data; The last item in the path will be removed. - */ - public function unset_data($path) { - //explode the path. - $pathArr = $this->explode_path($path); - $removeThis = array_pop($pathArr); - $path = $this->string_from_array($pathArr); - - //retrieve the data... - $myData = $this->get_data($path); - - if(is_array($myData)) { - //now remove the bit of data as requested. - unset($myData[$removeThis]); - //update the path with our new data. - $retval = $this->set_data($path, $myData); - } - else { - //throw a terrible error. - throw new exception("unset_data(): data ($myData) wasn't an array! ($path)"); - } - - return($retval); - }//end unset_data() - //====================================================================================== - - - - //====================================================================================== - /** - * Performs all the work of exploding the path and fixing it. - * - * @param $path <string> Path to work with. - * @return <array> PASS: array contains exploded path. - */ - public function explode_path($path) { - $path = preg_replace('/\/\//', '/', $path); - $path = $this->fix_path($path); - $retval = explode('/', $path); - - //if the initial index is blank, just remove it. - if($retval[0] == '' || strlen($retval[0]) < 1) { - //it was blank! KILL IT! - $checkItOut = array_shift($retval); - } - - return($retval); - }//end explode_path() - //====================================================================================== - - - - //====================================================================================== - public function reload_data($array) { - //call the constructor on it, and pass along the CURRENT prefix, so it doesn't get reset. - $this->__construct($array, $this->prefix); - }//end reload_data() - //====================================================================================== - - - - //====================================================================================== - private function string_from_array(array $array) { - $retval = ""; - foreach($array as $index) { - if(strlen($retval)) { - $retval .= "/". $index; - } - else { - $retval = $index; - } - } - return($retval); - }//end string_from_array() - //====================================================================================== - -}//end arrayToPath{} - -?> Copied: releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php (from rev 941, releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php) =================================================================== --- releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php (rev 0) +++ releases/1.2/lib/cs-arrayToPath/arrayToPathClass.php 2009-02-06 21:06:25 UTC (rev 945) @@ -0,0 +1,379 @@ +<?php +/* + * Created on Nov 20, 2006 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author: crazedsanity $ + * Current Revision:::: $Revision: 17 $ + * Repository Location: $HeadURL: https://cs-arraytopath.svn.sourceforge.net/svnroot/cs-arraytopath/trunk/arrayToPathClass.php $ + * Last Updated:::::::: $Date: 2007-09-12 14:24:46 -0500 (Wed, 12 Sep 2007) $ + * + * + * Basically traverses an array as though it were a filesystem. In the given example, it looks + * more complex than necessary, but the "NEW WAY" is very programatic, whereas the "OLD WAY" is + * just that: OLD. Also, the new way is very extensible, and is handy when performing a LOT of + * complex operations on an array. + * Example: + * OLD WAY: + * $my_data = $array['path']['to']['your']['hidden']['data']; + * $my_vault = $array['path']['to']['your']['hidden']['vault']; + * $my_other = $array['path']['to']['your']['hidden']['other']; + * + * $array['path']['to']['my'] = array(); + * $array['path']['to']['my']['data'] = array(); + * $array['path']['to']['my']['data']['is'] = "here"; + * NEW WAY: + * $arrayToPath = new arrayToPath($array); + * $my_data = $arrayToPath('/path/to/your/hidden/data'); + * $my_vault = $arrayToPath('/path/to/your/hidden/vault'); + * $my_other = $arrayToPath('/path/to/your/hidden/other'); + * + * $arrayToPath->set_data('/path/to/my/data/is', 'here'); + */ + + +require_once(dirname(__FILE__) .'/cs_versionAbstract.class.php'); + +class arrayToPath extends cs_a2p_versionAbstract { + + private $prefix = NULL; //the first directory to use. + private $data; + private $iteration = 0; + + //====================================================================================== + /** + * The constructor. + * + * @param $array (array) The data that will be used when + * + * TODO::: there is a strange recursion issue when $prefix is non-null: prefix is presently hardwired as NULL for now... + */ + public function __construct($array, $prefix=NULL) { + if($array === 'unit_test') { + //it's a unit test. + $this->isTest = TRUE; + } + else { + $this->get_version(); + $prefix=NULL; + if(!is_array($array)) { + //I don't deal with non-arrays. Idiot. + exit('arrayToPath{}->__construct(): got an invalid datatype.'); + } + //create a reference to the data, so if it changes, the class doesn't have to be re-initialized. + $this->data = $array; + + //now set the prefix ONLY if the prefix is valid. + if(!is_null($prefix) && strlen($prefix)) { + //got a good prefix, so use it. + $this->prefix = $prefix; + } + } + }//end __construct() + //====================================================================================== + + + //====================================================================================== + /** + * Takes a path & returns the appropriate index in the session. + * + * @param $path <str> path to the appropriate section in the session. + * + * @return <NULL> FAIL: unable to find requested index. + * @return <mixed> PASS: this is the value of the index. + */ + public function get_data($path=NULL) { + $myIndexList = array(); + $path = $this->fix_path($path); + + if(is_null($path) || (strlen($path) < 1)) { + //they just want ALL THE DATA. + $retval = $this->data; + } + else { + //get the list of indices in our data that we have to traverse. + $myIndexList = $this->explode_path($path); + + //set an initial retval. + $retval = $this->get_data_segment($this->data, $myIndexList[0]); + unset($myIndexList[0]); + + if(count($myIndexList) > 0) { + foreach($myIndexList as $indexName) { + $retval = $this->get_data_segment($retval, $indexName); + if(is_null($retval)) { + //hmm... well, if it's null, it's nothing which can have a sub-index. Stop here. + break; + } + } + } + } + + return($retval); + + }//end get_data() + //====================================================================================== + + + + //====================================================================================== + /** + * Returns a given index from a piece of data, used by get_data(). + */ + private function get_data_segment($fromThis, $indexName) { + if(is_array($fromThis)) { + //it's an array. + $retval = $fromThis[$indexName]; + } + elseif(is_object($fromThis)) { + //it's an object. + $retval = $fromThis->$indexName; + } + return($retval); + }//end get_data_segment() + //====================================================================================== + + + + //====================================================================================== + /** + * Pre-pends the internal $this->prefix onto the given path. + * + * @param $path <str> path to append $this->prefix onto. + * + * @return <str> PASS: this is the path with our prefix added. + */ + private function fix_path($path) { + if(is_null($path) && is_null($this->prefix)) { + //all data is null. don't bother changing it. + $retval = NULL; + } + else { + //remove slashes at the beginning or end of the path. + $path = preg_replace('/\/$/', '', $path); + + if(preg_match('/\/$/', $this->prefix)) { + //remove the trailing slash. + $this->prefix = preg_replace('/$\//', '', $this->prefix); + } + if(preg_match('/^\//', $this->prefix)) { + $this->prefix = preg_replace('/^\//', '', $this->prefix); + } + $path = preg_replace('/\/$/', '', $path); + + //should we add our prefix? + if(preg_match('/^\//', $path)) { + $retval = $path; + } + else { + $retval = $this->prefix ."/". $path; + } + + //remove a trailing slash, if present, before returning. + $retval = preg_replace('/\/$/', '', $retval); + } + + return($retval); + + }//end fix_path() + //====================================================================================== + + + + //====================================================================================== + /** + * Sets data into the given path, with options to override our internal prefix, and to + * force-overwrite data if it's not an array. + * + * @param $path <str> path to set the data into. + * @param $data <mixed> what to set into the given path. + * + * @return 0 FAIL: old data doesn't match new data. + * @return 1 PASS: everything lines-up. + */ + public function set_data($path, $data) { + //get the list of indices in the session that we have to traverse. + $myIndexList = $this->explode_path($path); + + $retval = 0; + //Use an internal iterator to go through the little bits of the session & set the + // data where it's supposed to be. + if($path === '/' || count($myIndexList) == 0) { + //setting the data. + $this->data = $data; + $retval = 1; + } + elseif(count($myIndexList) == 1) { + //that should be simple: set the index to be $data. + $this->data[$myIndexList[0]] = $data; + $retval = 1; + } + elseif(count($myIndexList) > 1) { + $this->internal_iterator($this->data, $path, $data); + $retval = 1; + } + + return($retval); + }//end set_data() + //====================================================================================== + + + //====================================================================================== + /** + * Iterates through the session to create the values for set_data(). This method passes + * AND returns the $array argument by reference. + * + * @param &$array (array) iterate through this. + * @param $path (array) numbered array of keys, representing a path through the + * internal data to go through to set $data. + * @param $data (mixed) data to set into the path referenced in $indexList. + * + * @return <void> + */ + protected function &internal_iterator(&$array, $path, $data) { + //make sure it doesn't call itself to death. ;) + $this->iteration++; + + if($this->iteration > 1000) { + throw new exception("arrayToPath{}: too many iterations, path=($path)"); + } + + $retval = 0; + $indexList = $this->explode_path($path); + $myIndex = array_shift($indexList); + $path = $this->string_from_array($indexList); + + if(is_array($a... [truncated message content] |
From: <cra...@us...> - 2009-10-26 03:15:22
|
Revision: 996 http://cs-project.svn.sourceforge.net/cs-project/?rev=996&view=rev Author: crazedsanity Date: 2009-10-26 03:15:10 +0000 (Mon, 26 Oct 2009) Log Message: ----------- v1.2.0-ALPHA13 part 2. Modified Paths: -------------- releases/1.2/lib/_unitTests_/cs-content_tests.php releases/1.2/lib/abstractClasses/dbAbstract.class.php releases/1.2/lib/bbCodeParser.class.php releases/1.2/lib/config.class.php releases/1.2/lib/cs-content/VERSION releases/1.2/lib/cs-content/abstract/cs_content.abstract.class.php releases/1.2/lib/cs-content/contentSystem.class.php releases/1.2/lib/cs-content/cs_fileSystem.class.php releases/1.2/lib/cs-content/cs_genericPage.class.php releases/1.2/lib/cs-content/cs_globalFunctions.class.php releases/1.2/lib/cs-content/cs_session.class.php releases/1.2/lib/cs-content/sample_files/public_html/content releases/1.2/lib/cs-content/sample_files/templates/system/404.shared.tmpl releases/1.2/lib/cs-content/sample_files/templates/system/message_box.tmpl releases/1.2/lib/cs-content/tests/files/gptest_all-together.txt releases/1.2/lib/cs-content/tests/files/templates/content.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/footer.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/infobar.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/main.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/menubar.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/title.shared.tmpl releases/1.2/lib/cs-content/tests/testOfCSContent.php releases/1.2/lib/cs-phpxml/README.txt releases/1.2/lib/cs-phpxml/VERSION releases/1.2/lib/cs-phpxml/cs_phpxml.abstract.class.php releases/1.2/lib/cs-phpxml/cs_phpxmlBuilder.class.php releases/1.2/lib/cs-phpxml/cs_phpxmlCreator.class.php releases/1.2/lib/cs-phpxml/cs_phpxmlParser.class.php releases/1.2/lib/cs-phpxml/tests/example_test.php releases/1.2/lib/cs-phpxml/tests/testOfCSPHPXML.php releases/1.2/lib/globalFunctions.php releases/1.2/lib/helpdeskClass.php releases/1.2/lib/mainRecordClass.php releases/1.2/lib/session_class.php releases/1.2/lib/site_config.php Added Paths: ----------- releases/1.2/lib/_setup/ releases/1.2/lib/_setup/MyDisplay.class.php releases/1.2/lib/_setup/__finalStep.class.php releases/1.2/lib/_setup/__setupDefaultValues.class.php releases/1.2/lib/_setup/__tmpSetupClass.class.php releases/1.2/lib/_setup/_setupUpgrade.class.php releases/1.2/lib/_setup/unitTest.class.php releases/1.2/lib/cs-content/__autoload.php releases/1.2/lib/cs-content/abstract/cs_version.abstract.class.php releases/1.2/lib/cs-content/sample_files/public_html/images/ releases/1.2/lib/cs-content/sample_files/public_html/images/clear.gif releases/1.2/lib/cs-content/sample_files/public_html/images/frame/ releases/1.2/lib/cs-content/sample_files/public_html/images/frame/crn-white-bl.gif releases/1.2/lib/cs-content/sample_files/public_html/images/frame/crn-white-br.gif releases/1.2/lib/cs-content/sample_files/public_html/images/frame/crn-white-tl.gif releases/1.2/lib/cs-content/sample_files/public_html/images/frame/crn-white-tr.gif releases/1.2/lib/cs-content/tests/files/gptest_blockrows.txt releases/1.2/lib/cs-content/tests/files/gptest_blockrows2.txt releases/1.2/lib/cs-content/tests/files/includes/ releases/1.2/lib/cs-content/tests/files/includes/shared.inc releases/1.2/lib/cs-content/tests/files/templates/system/ releases/1.2/lib/cs-content/tests/files/templates/system/404.shared.tmpl releases/1.2/lib/cs-content/tests/files/templates/system/message_box.tmpl releases/1.2/lib/cs-content/tests/files/version1 releases/1.2/lib/cs-content/tests/files/version2 releases/1.2/lib/cs-content/tests/files/version3 releases/1.2/lib/cs-content/tests/testOfCSFileSystem.php releases/1.2/lib/cs-content/tests/testOfCSGlobalFunctions.php releases/1.2/lib/cs-content/tests/testOfCSVersionAbstract.php releases/1.2/lib/cs-content.tmp releases/1.2/lib/cs-phpxml/cs_arrayToPath.class.php releases/1.2/lib/cs-phpxml/tests/files/test2-issue267.xml releases/1.2/lib/cs-phpxml/tests/testOfA2P.php releases/1.2/lib/cs-webapplibs/ releases/1.2/lib/cs-webapplibs/VERSION releases/1.2/lib/cs-webapplibs/abstract/ releases/1.2/lib/cs-webapplibs/abstract/cs_phpDB.abstract.class.php releases/1.2/lib/cs-webapplibs/abstract/cs_webapplibs.abstract.class.php releases/1.2/lib/cs-webapplibs/cs_authToken.class.php releases/1.2/lib/cs-webapplibs/cs_bbCodeParser.class.php releases/1.2/lib/cs-webapplibs/cs_phpDB.class.php releases/1.2/lib/cs-webapplibs/cs_sessionDB.class.php releases/1.2/lib/cs-webapplibs/cs_siteConfig.class.php releases/1.2/lib/cs-webapplibs/cs_tabs.class.php releases/1.2/lib/cs-webapplibs/cs_webdblogger.class.php releases/1.2/lib/cs-webapplibs/cs_webdbupgrade.class.php releases/1.2/lib/cs-webapplibs/db_types/ releases/1.2/lib/cs-webapplibs/db_types/cs_phpDB__mysql.class.php releases/1.2/lib/cs-webapplibs/db_types/cs_phpDB__pgsql.class.php releases/1.2/lib/cs-webapplibs/db_types/cs_phpDB__sqlite.class.php releases/1.2/lib/cs-webapplibs/docs/ releases/1.2/lib/cs-webapplibs/docs/CREDITS releases/1.2/lib/cs-webapplibs/docs/LICENSE releases/1.2/lib/cs-webapplibs/docs/README.txt releases/1.2/lib/cs-webapplibs/docs/SETUP.txt releases/1.2/lib/cs-webapplibs/setup/ releases/1.2/lib/cs-webapplibs/setup/schema.mysql.sql releases/1.2/lib/cs-webapplibs/setup/schema.pgsql.sql releases/1.2/lib/cs-webapplibs/tests/ releases/1.2/lib/cs-webapplibs/tests/example_test.php releases/1.2/lib/cs-webapplibs/tests/files/ releases/1.2/lib/cs-webapplibs/tests/testOfCSPHPDB.php releases/1.2/lib/cs-webapplibs/tests/testOfCSWebAppLibs.php releases/1.2/lib/cs-webapplibs/upgrades/ releases/1.2/lib/cs-webapplibs/upgrades/upgrade.xml releases/1.2/lib/recaptchalib.php Removed Paths: ------------- releases/1.2/lib/_setup/MyDisplay.class.php releases/1.2/lib/_setup/__finalStep.class.php releases/1.2/lib/_setup/__setupDefaultValues.class.php releases/1.2/lib/_setup/__tmpSetupClass.class.php releases/1.2/lib/_setup/_setupUpgrade.class.php releases/1.2/lib/_setup/unitTest.class.php releases/1.2/lib/_unitTests_/cs-arrayToPath_tests.php releases/1.2/lib/_unitTests_/cs-phpxml_tests.php releases/1.2/lib/cs-arrayToPath/ releases/1.2/lib/cs-versionparse/ releases/1.2/lib/upgradeClass.php Deleted: releases/1.2/lib/_setup/MyDisplay.class.php =================================================================== --- trunk/1.2/lib/_setup/MyDisplay.class.php 2009-10-25 18:37:02 UTC (rev 992) +++ releases/1.2/lib/_setup/MyDisplay.class.php 2009-10-26 03:15:10 UTC (rev 996) @@ -1,46 +0,0 @@ -<?php -/* - * Created on Aug 23, 2007 - * - * SVN INFORMATION::: - * ------------------- - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ - */ - - - - -//####################################################################################### -/** - * Built to avoid always printing-out the results (so we can retrieve result data separately. - */ -class MyDisplay extends SimpleReporter { - - function paintHeader($test_name) { - } - - function paintFooter($test_name) { - } - - function paintStart($test_name, $size) { - parent::paintStart($test_name, $size); - } - - function paintEnd($test_name, $size) { - parent::paintEnd($test_name, $size); - } - - function paintPass($message) { - parent::paintPass($message); - } - - function paintFail($message) { - parent::paintFail($message); - } -} -//####################################################################################### - -?> Copied: releases/1.2/lib/_setup/MyDisplay.class.php (from rev 992, trunk/1.2/lib/_setup/MyDisplay.class.php) =================================================================== --- releases/1.2/lib/_setup/MyDisplay.class.php (rev 0) +++ releases/1.2/lib/_setup/MyDisplay.class.php 2009-10-26 03:15:10 UTC (rev 996) @@ -0,0 +1,46 @@ +<?php +/* + * Created on Aug 23, 2007 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + + + + +//####################################################################################### +/** + * Built to avoid always printing-out the results (so we can retrieve result data separately. + */ +class MyDisplay extends SimpleReporter { + + function paintHeader($test_name) { + } + + function paintFooter($test_name) { + } + + function paintStart($test_name, $size) { + parent::paintStart($test_name, $size); + } + + function paintEnd($test_name, $size) { + parent::paintEnd($test_name, $size); + } + + function paintPass($message) { + parent::paintPass($message); + } + + function paintFail($message) { + parent::paintFail($message); + } +} +//####################################################################################### + +?> Deleted: releases/1.2/lib/_setup/__finalStep.class.php =================================================================== --- trunk/1.2/lib/_setup/__finalStep.class.php 2009-10-25 18:37:02 UTC (rev 992) +++ releases/1.2/lib/_setup/__finalStep.class.php 2009-10-26 03:15:10 UTC (rev 996) @@ -1,142 +0,0 @@ -<?php -/* - * Created on Aug 23, 2007 - * - * SVN INFORMATION::: - * ------------------- - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ - */ - - - -class __finalStep { - - - private $page; - private $gfObj; - - - //========================================================================= - public function __construct(cs_genericPage $page, array $stepData) { - $this->page = $page; - $this->stepData = $stepData; - unset($this->stepData[5]); - - $this->gfObj = new cs_globalFunctions; - $this->fsObj = new cs_fileSystem(dirname(__FILE__) ."/../../". CONFIG_DIRECTORY); - }//end __construct() - //========================================================================= - - - - //========================================================================= - function write_config() { - if($this->fsObj->is_writable(NULL)) { - $lsData = $this->fsObj->ls(); - if(!is_array($lsData[CONFIG_FILENAME])) { - $myData = array(); - foreach($this->stepData as $stepNum=>$garbage) { - $tempStepData = get_setup_data($stepNum, 'data'); - if(is_array($tempStepData)) { - $myData = array_merge($tempStepData, $myData); - } - else { - throw new exception(__METHOD__ .": step #". $stepNum ." has no valid data... ". $this->gfObj->debug_print($tempStepData,0)); - } - } - - //now that we've built the array successfully, now let's turn it into XML. - $xmlCreator = new cs_phpxmlCreator('config'); - $tagPath = "/config/main"; - $xmlCreator->add_tag($tagPath); - $xmlCreator->add_attribute($tagPath, array('fix'=>"sanitizeDirs")); - $xmlCreator->set_tag_as_multiple($tagPath); - - //Special values (including vars that cs_siteConfig{} handles) - $specialValues = array( - 'site_root' => '{_DIRNAMEOFFILE_}/..', - 'document_root' => '{MAIN/SITE_ROOT}', - 'libdir' => '{MAIN/SITE_ROOT}/lib', - 'tmpldir' => '{MAIN/SITE_ROOT}/templates', - 'seq_helpdesk' => 'special__helpdesk_public_id_seq', - 'seq_project' => 'special__project_public_id_seq', - 'seq_main' => 'record_table_record_id_seq', - 'table_todocomment' => 'task_comment_table', - 'rwdir' => '{MAIN/SITE_ROOT}/rw', - 'format_wordwrap' => '90' - ); - $defineAsGlobal=array('site_root', 'libdir', 'tmpldir'); - foreach($specialValues as $index=>$value) { - $xmlCreator->add_tag($tagPath .'/'. $index, $value); - $attributes = array('setconstant'=>1); - if(array_search($index, $defineAsGlobal)) { - $attributes['setglobal']=1; - } - $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); - } - - $skipSetConstant = array('version_string', 'workingonit'); - foreach($myData as $index=>$value) { - $xmlCreator->add_tag($tagPath ."/". $index, $value); - $attributes=array(); - if(!strlen(array_search($index, $skipSetConstant))) { - $attributes['setconstant']=1; - } - $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); - } - $extraAttributes = array( - 'generated' => date('Y-m-d H:m:s'), - 'version' => $myData['version_string'], - 'usecssiteconfig' => 1 - ); - $xmlCreator->add_attribute('/config', $extraAttributes); - - //add values for other libs... - $tagPath = '/config/cs-webapplibs'; - $xmlCreator->add_tag($tagPath); - $attributes = array('setconstant'=>1, 'setconstantprefix'=>"cs_webapplibs"); - - //TODO: set this dynamically if other databases are supported. - $xmlCreator->add_tag($tagPath .'/DBTYPE', 'pgsql', array('setconstant'=>1)); - $xmlCreator->add_tag($tagPath .'/DB_CONNECT_HOST', '{MAIN/DATABASE__HOST}', $attributes); - $xmlCreator->add_tag($tagPath .'/DB_CONNECT_DBNAME', '{MAIN/DATABASE__DBNAME}', $attributes); - $xmlCreator->add_tag($tagPath .'/DB_CONNECT_USER', '{MAIN/DATABASE__USER}', $attributes); - $xmlCreator->add_tag($tagPath .'/DB_CONNECT_PASSWORD', '{MAIN/DATABASE__PASSWORD}', $attributes); - $xmlCreator->add_tag($tagPath .'/DB_CONNECT_PORT', '{MAIN/DATABASE__PORT}', $attributes); - - //now, create an XML string... - $xmlString = $xmlCreator->create_xml_string(); - - $this->fsObj->create_file(CONFIG_FILENAME, TRUE); - $writeRes = $this->fsObj->write($xmlString, CONFIG_FILENAME); - - if($writeRes > 0) { - $retval = "Successfully created the XML config file"; - store_setup_data(5, 1, 'result'); - store_setup_data(5, $retval, 'text'); - } - else { - throw new exception(__METHOD__ .": failed to write any data to the config file"); - } - } - else { - throw new exception(__METHOD__ .": ". CONFIG_FILE_LOCATION ." already exists!"); - } - } - else { - throw new exception(__METHOD__ .": the config directory is not writable!"); - } - - $configObj = new config(CONFIG_FILE_LOCATION); - $configObj->remove_setup_config(); - - return($retval); - }//end write_config() - //========================================================================= -} - - -?> Copied: releases/1.2/lib/_setup/__finalStep.class.php (from rev 992, trunk/1.2/lib/_setup/__finalStep.class.php) =================================================================== --- releases/1.2/lib/_setup/__finalStep.class.php (rev 0) +++ releases/1.2/lib/_setup/__finalStep.class.php 2009-10-26 03:15:10 UTC (rev 996) @@ -0,0 +1,144 @@ +<?php +/* + * Created on Aug 23, 2007 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + + + +class __finalStep { + + + private $page; + private $gfObj; + + + //========================================================================= + public function __construct(cs_genericPage $page, array $stepData) { + $this->page = $page; + $this->stepData = $stepData; + unset($this->stepData[5]); + + $this->gfObj = new cs_globalFunctions; + $this->fsObj = new cs_fileSystem(dirname(__FILE__) ."/../../". CONFIG_DIRECTORY); + }//end __construct() + //========================================================================= + + + + //========================================================================= + function write_config() { + if($this->fsObj->is_writable(NULL)) { + $lsData = $this->fsObj->ls(); + if(!is_array($lsData[CONFIG_FILENAME])) { + $myData = array(); + foreach($this->stepData as $stepNum=>$garbage) { + $tempStepData = get_setup_data($stepNum, 'data'); + if(is_array($tempStepData)) { + $myData = array_merge($tempStepData, $myData); + } + else { + throw new exception(__METHOD__ .": step #". $stepNum ." has no valid data... ". $this->gfObj->debug_print($tempStepData,0)); + } + } + + //now that we've built the array successfully, now let's turn it into XML. + $xmlCreator = new cs_phpxmlCreator('config'); + $tagPath = "/config/main"; + $xmlCreator->add_tag($tagPath); + $xmlCreator->add_attribute($tagPath, array('fix'=>"sanitizeDirs")); + $xmlCreator->set_tag_as_multiple($tagPath); + + //Special values (including vars that cs_siteConfig{} handles) + $specialValues = array( + 'site_root' => '{_DIRNAMEOFFILE_}/..', + 'document_root' => '{MAIN/SITE_ROOT}', + 'libdir' => '{MAIN/SITE_ROOT}/lib', + 'tmpldir' => '{MAIN/SITE_ROOT}/templates', + 'seq_helpdesk' => 'special__helpdesk_public_id_seq', + 'seq_project' => 'special__project_public_id_seq', + 'seq_main' => 'record_table_record_id_seq', + 'table_todocomment' => 'task_comment_table', + 'rwdir' => '{MAIN/SITE_ROOT}/rw', + 'format_wordwrap' => '90', + 'recaptcha_publickey' => '6Ld27ggAAAAAADHN-jYSdY0cJjfM10pjRgbWS02B', + 'recaptcha_privatekey' => '6Ld27ggAAAAAAErK12LU6sCeYF8m-whCJn4azM2B' + ); + $defineAsGlobal=array('site_root', 'libdir', 'tmpldir'); + foreach($specialValues as $index=>$value) { + $xmlCreator->add_tag($tagPath .'/'. $index, $value); + $attributes = array('setconstant'=>1); + if(array_search($index, $defineAsGlobal)) { + $attributes['setglobal']=1; + } + $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); + } + + $skipSetConstant = array('version_string', 'workingonit'); + foreach($myData as $index=>$value) { + $xmlCreator->add_tag($tagPath ."/". $index, $value); + $attributes=array(); + if(!strlen(array_search($index, $skipSetConstant))) { + $attributes['setconstant']=1; + } + $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); + } + $extraAttributes = array( + 'generated' => date('Y-m-d H:m:s'), + 'version' => $myData['version_string'], + 'usecssiteconfig' => 1 + ); + $xmlCreator->add_attribute('/config', $extraAttributes); + + //add values for other libs... + $tagPath = '/config/cs-webapplibs'; + $xmlCreator->add_tag($tagPath); + $attributes = array('setconstant'=>1, 'setconstantprefix'=>"cs_webapplibs"); + + //TODO: set this dynamically if other databases are supported. + $xmlCreator->add_tag($tagPath .'/DBTYPE', 'pgsql', array('setconstant'=>1)); + $xmlCreator->add_tag($tagPath .'/DB_CONNECT_HOST', '{MAIN/DATABASE__HOST}', $attributes); + $xmlCreator->add_tag($tagPath .'/DB_CONNECT_DBNAME', '{MAIN/DATABASE__DBNAME}', $attributes); + $xmlCreator->add_tag($tagPath .'/DB_CONNECT_USER', '{MAIN/DATABASE__USER}', $attributes); + $xmlCreator->add_tag($tagPath .'/DB_CONNECT_PASSWORD', '{MAIN/DATABASE__PASSWORD}', $attributes); + $xmlCreator->add_tag($tagPath .'/DB_CONNECT_PORT', '{MAIN/DATABASE__PORT}', $attributes); + + //now, create an XML string... + $xmlString = $xmlCreator->create_xml_string(); + + $this->fsObj->create_file(CONFIG_FILENAME, TRUE); + $writeRes = $this->fsObj->write($xmlString, CONFIG_FILENAME); + + if($writeRes > 0) { + $retval = "Successfully created the XML config file"; + store_setup_data(5, 1, 'result'); + store_setup_data(5, $retval, 'text'); + } + else { + throw new exception(__METHOD__ .": failed to write any data to the config file"); + } + } + else { + throw new exception(__METHOD__ .": ". CONFIG_FILE_LOCATION ." already exists!"); + } + } + else { + throw new exception(__METHOD__ .": the config directory is not writable!"); + } + + $configObj = new config(CONFIG_FILE_LOCATION); + $configObj->remove_setup_config(); + + return($retval); + }//end write_config() + //========================================================================= +} + + +?> Deleted: releases/1.2/lib/_setup/__setupDefaultValues.class.php =================================================================== --- trunk/1.2/lib/_setup/__setupDefaultValues.class.php 2009-10-25 18:37:02 UTC (rev 992) +++ releases/1.2/lib/_setup/__setupDefaultValues.class.php 2009-10-26 03:15:10 UTC (rev 996) @@ -1,974 +0,0 @@ -<?php -/* - * Created on Aug 23, 2007 - * - * SVN INFORMATION::: - * ------------------- - * Last Author::::::::: $Author$ - * Current Revision:::: $Revision$ - * Repository Location: $HeadURL$ - * Last Updated:::::::: $Date$ - */ - -class __setupDefaultValues extends cs_webdbupgrade { - - - protected $db; - private $totalRecords=0; - - private $data=array(); - - private $lastNumrows=NULL; - private $lastDberror=NULL; - - //========================================================================= - public function __construct() { - $this->db = new cs_phpDB; - $this->gfObj = new cs_globalFunctions; - }//end __construct() - //========================================================================= - - - - //========================================================================= - public function go() { - store_setup_data(3, 0, 'result'); - try { - $params = get_db_params(); - $this->db->connect($params); - $this->db->beginTrans(__METHOD__); - $retval = "Connected successfully to the database."; - - //now that we've connected, start doing stuff. - $retval = $this->set_version(); - $retval .= "<BR>\n". $this->create_log_categories_and_classes(); - $retval .= "<BR>\n". $this->create_attributes(); - $retval .= "<BR>\n". $this->create_anonymous_contact_data(); - $retval .= "<BR>\n". $this->create_status_records(); - $retval .= "<BR>\n". $this->create_tag_names(); - $retval .= "<BR>\n". $this->build_preferences(); - $retval .= "<BR>\n". $this->create_users(); - $retval .= "<BR>\n". $this->create_user_group_records(); - - $commitRes = $this->db->commitTrans(); - if($commitRes == 1) { - $retval .= "<BR>\n ----------- Created (". $this->totalRecords ."), result of commit: (". $commitRes .")."; - store_setup_data(3, 1, 'result'); - store_setup_data(4, 1, 'accessible'); - } - else { - $this->db->rollbackTrans(); - store_setup_data(3, 0, 'result'); - throw new exception(__METHOD__ .": failed to commit the transaction (". $commitRes .")"); - } - - } - catch(exception $e) { - //TODO: rollback the transaction - $retval = "An error occurred: ". $e->getMessage(); - } - - return($retval); - - }//end go() - //========================================================================= - - - - //========================================================================= - /** - * Set version information into the database for future upgradeability. - */ - private function set_version() { - //get the version string. - $fullVersionString = read_version_file(); - - $suffixData = explode('-', $fullVersionString); - if(count($suffixData) == 2 && preg_match('/\./', $suffixData[0]) && !preg_match('/\./', $suffixData[1])) { - //there's a suffix, and it doesn't contain periods (i.e. "1.0.0-ALPHA1") - $suffix = $suffixData[1]; - } - elseif(count($suffixData) == 1) { - //no suffix. - $suffix = ""; - } - else { - //there's a dash in the name, but it's invalid or contains periods (i.e. "BETA-1.0.0" or "1.0.0-ALPHA1.0") - throw new exception(__METHOD__ .": version string is invalid (". $fullVersionString ."), suffix contains dashes, or there is a prefix"); - } - - //remove the suffix & parse it. - $versionString = $suffixData[0]; - $versionData = $this->parse_version_string($fullVersionString); - $sqlData = $versionData; - - - #$sqlData = array( - # 'version_string' => $fullVersionString, - # 'version_major' => $versionData[0], - # 'version_minor' => $versionData[1], - # 'version_maintenance' => $versionData[2], - # 'version_suffix' => $suffix - #); - - $retval = 0; - foreach($sqlData as $name => $value) { - $sql = "SELECT internal_data_set_value('". $name ."', '". $value ."')"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to set (". $name .") as (". $value .")::: ". $dberror); - } - } - - if($retval == count($sqlData)) { - //okay, the final test: run a query that straps everything together, to ensure it all has the same version. - $sql = "SELECT internal_data_get_value('version_major') || '.' || internal_data_get_value('version_minor') " . - " || '.' || internal_data_get_value('version_maintenance') as text, " . - "internal_data_get_value('version_suffix') as version_suffix;"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $data = $this->db->farray(); - $dbVersionString = $data['text']; - if(strlen($data['version_suffix'])) { - $dbVersionString .= "-". $data['version_suffix']; - } - - if($dbVersionString === $fullVersionString) { - //okay, one final test: check that the "version_string" in the database matches ours. - $sql = "SELECT internal_data_get_value('version_string')"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $data = $this->db->farray(); - $dbVersionString = $data[0]; - - if($dbVersionString === $fullVersionString) { - $this->data['version_string'] = $fullVersionString; - $retval = "Successfully set version string"; - } - else { - throw new exception(__METHOD__ .": derived database version string (". $dbVersionString .") doesn't match our version (". $fullVersionString .")"); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve full version_string from database::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": derived database version string (". $dbVersionString .") doesn't match our version (". $fullVersionString .")"); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve derived database version string::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - //it's cryptic, but what should it really say??? - throw new exception(__METHOD__ .": internal error, checksum didn't match"); - } - - return($retval); - - }//end set_version() - //========================================================================= - - - - //========================================================================= - private function create_log_categories_and_classes() { - - $counter = 0; - - $classes = array( - 1 => 'Error', - 2 => 'Information', - 3 => 'Create', - 4 => 'Update', - 5 => 'Delete', - 6 => 'REPORT', - 7 => 'DEBUG' - ); - - - foreach($classes as $num=>$name) { - $insertArr = array( - 'log_class_id' => $num, - 'name' => $name - ); - $sql = "INSERT INTO log_class_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good. - $counter++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to create class record for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - - //Reset sequence, so new records can be created. - $sql = "SELECT setval('log_class_table_log_class_id_seq', (SELECT max(log_class_id) FROM log_class_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $categories = array( - 1 => 'Database', - 2 => 'Authentication', - 3 => 'Users', - 4 => 'General', - 5 => 'Project', - 6 => 'Helpdesk', - 7 => 'Task', - 8 => 'Tags', - 9 => 'Estimates', - 10 => 'Navigation', - 11 => 'Preferences' - ); - - - foreach($categories as $num=>$name) { - $insertArr = array( - 'log_category_id' => $num, - 'name' => $name - ); - $sql = "INSERT INTO log_category_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good. - $counter++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to create category record for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - //Reset sequence, so new records can be created. - $sql = "SELECT setval('log_category_table_log_category_id_seq', (SELECT max(log_category_id) FROM log_category_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - - //format (primary index is log_event_id): log_class_id, log_category_id, description - $logEvents = array( - // * log_event_id | log_class_id | log_category_id | description - 1 => array(3, 5, 'Project: created record'), - 2 => array(5, 5, 'Project: deleted record'), - 3 => array(4, 5, 'Project: updated record'), - 4 => array(1, 5, 'Project: ERROR'), - 5 => array(3, 6, 'Helpdesk: Created record'), - 6 => array(4, 6, 'Helpdesk: Updated record'), - 7 => array(2, 6, 'Helpdesk: Information'), - 8 => array(1, 6, 'Helpdesk: ERROR'), - 9 => array(6, 6, 'Helpdesk: Report'), - 10 => array(3, 7, 'Task: created record'), - 11 => array(5, 7, 'Task: deleted record'), - 12 => array(4, 7, 'Task: updated record'), - 13 => array(1, 1, 'Database Error'), - 14 => array(6, 5, 'Project: Activity Report'), - 15 => array(6, 7, 'Task: Activity Report'), - 16 => array(3, 2, 'User logged-in'), - 17 => array(5, 2, 'User logged-out'), - 18 => array(6, 2, 'Login/Logout Report'), - 19 => array(3, 8, 'Tags: created record'), - 20 => array(5, 8, 'Tags: deleted record'), - 21 => array(4, 8, 'Tags: updated record'), - 22 => array(6, 8, 'Tags: Activity Report'), - 23 => array(1, 2, 'Authentication: ERROR'), - 24 => array(2, 10, 'Navigation: Viewed page'), - 25 => array(4, 9, 'Update: Estimates'), - 26 => array(1, 9, 'Error: Estimates'), - 27 => array(2, 5, 'Information: Project'), - 28 => array(4, 3, 'Update: Users'), - 29 => array(1, 7, 'Error: Task'), - 30 => array(3, 3, 'Create: Users') - ); - - foreach($logEvents as $logEventId => $subArr) { - $insertArr = array( - 'log_event_id' => $logEventId, - 'log_class_id' => $subArr[0], - 'log_category_id' => $subArr[1], - 'description' => $subArr[2] - ); - $sql = "INSERT INTO log_event_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $counter++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to create log_event_id #". $insertArr['log_event_id'] - .", description: ". $insertArr['description'] ."<BR>\nERROR::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - //FINAL SANITY CHECKS!!! - if($counter == (count($classes) + count($categories) + count($logEvents))) { - - //reset the sequence. - $sql = "SELECT setval('log_event_table_log_event_id_seq', (SELECT max(log_event_id) FROM log_event_table))"; - if($this->run_sql($sql) === TRUE) { - $retval = "Successfully created all category, class, and log event records (". $counter .")"; - } - else { - throw new exception(__METHOD__ .": failed to reset sequence for log_event table::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": Internal error, failed to create all category and class records"); - } - } - else { - throw new exception(__METHOD__ .": failed to reset sequence for log_category_table::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": failed to reset sequence for log_class_table::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - - return($retval); - - }//end create_log_categories_and_classes() - //========================================================================= - - - - //========================================================================= - private function create_attributes() { - $attributes = array( - 3 => array('phone', 'phone', 'Phone'), - 4 => array('fax', 'phone', 'Fax'), - 5 => array('cell', 'phone', 'Cell'), - 6 => array('im_yahoo', 'alphanumeric', 'IM: Yahoo'), - 7 => array('im_skype', 'alphanumeric', 'IM: Skype'), - 8 => array('im_aol', 'alphanumeric', 'IM: AOL'), - 9 => array('im_msn', 'alphanumeric', 'IM: MSN'), - 10 => array('im_icq', 'alphanumeric', 'IM: ICQ'), - 11 => array('address', 'sql', 'Address'), - 12 => array('city', 'alphanumeric', 'City'), - 13 => array('state', 'alphanumeric', 'State'), - 14 => array('zip', 'alphanumeric', 'Zip') - ); - - $retval = 0; - foreach($attributes as $attributeId => $subData) { - $insertArr = array( - 'attribute_id' => $attributeId, - 'name' => $subData[0], - 'clean_as' => $subData[1], - 'display_name' => $subData[2] - ); - $sql = "INSERT INTO attribute_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to insert data for attribute (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == count($attributes)) { - $sql = "SELECT setval('attribute_table_attribute_id_seq'::text, (SELECT max(attribute_id) FROM attribute_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval = "Successfully created all attributes (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check failed)"); - } - - return($retval); - }//end create_attributes() - //========================================================================= - - - - //========================================================================= - /** - * Create the anonymous user. This includes their contact data and the - * default group. - * - * TODO: change "short_name" into "display_name". - */ - private function create_anonymous_contact_data() { - $allRecords = array( - 'disabled group' => array( - 'name' => 'group_table', - 'data' => array( - 'group_id' => 0, - 'name' => 'disabled', - 'short_name' => 'DISABLED', - 'leader_uid' => 0 - ), - ), - 'anonymous record in user table' => array( - 'name' => 'user_table', - 'data' => array( - 'uid' => 0, - 'username' => 'Anonymous', - 'password' => 'disabled', //this is PURPOSELY an invalid password (passwords should be 32-char md5's - 'is_admin' => 'f', - 'is_active' => 'f', - 'group_id' => 0, - 'contact_id' => 0 - ), - ), - 'default group' => array( - 'name' => 'group_table', - 'data' => array( - 'group_id' => 1, - 'name' => 'default', - 'short_name' => '-DEFAULT-', - 'leader_uid' => 0 - ), - ), - 'anonymous contact record' => array( - 'name' => 'contact_table', - 'data' => array( - 'contact_id' => 0, - 'company' => '', - 'fname' => 'Anonymous', - 'lname' => '', - 'contact_email_id' => '-1' - ) - ), - 'anonymous email record' => array( - 'name' => 'contact_email_table', - 'data' => array( - 'contact_id' => 0, - 'email' => 'ano...@nu...' - ) - ) - ); - - $retval = 0; - foreach($allRecords as $operationName => $subData) { - $tableName = $subData['name']; - $insertArr = $subData['data']; - - $sql = "INSERT INTO ". $tableName ." ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $this->totalRecords++; - $retval++; - } else { - throw new exception(__METHOD__. ": failed perform operation (". $operationName .") for table (". $tableName .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - $sql = "SELECT currval('contact_email_table_contact_email_id_seq'::text)"; - if($this->run_sql($sql)) { - $data = $this->db->farray(); - $sql = "UPDATE contact_table SET contact_email_id=". $data[0] ." WHERE contact_id=0"; - if($this->run_sql($sql)) { - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to set contact_email_id for anonymous"); - } - } - else { - throw new exception(__METHOD__ .": failed to get sequence for contact_email_table"); - } - - if($retval == count($allRecords)) { - //reset the sequence for the group table... - $sql = "SELECT setval('group_table_group_id_seq'::text, (SELECT max(group_id) FROM group_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good to go. - $retval = "Successfully created anonymous user, anonymous contact record, and the two default groups (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset group sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (failed sanity check)"); - } - - return($retval); - }//end create_anonymous_contact_data() - //========================================================================= - - - //========================================================================= - private function create_status_records() { - //format: {status_id} => array({name}, {description}) - $statuses = array( - 0 => array('New/Offered', 'New record'), - 1 => array('Pending', 'Not new: pending review, or nearly complete.'), - 2 => array('Running/Accepted', 'Work is underway'), - 3 => array('Stalled', 'Unable to complete, or dependent on other things.'), - 4 => array('Ended/Solved', 'Work is complete!'), - 5 => array('Rejected', 'Denied.'), - 6 => array('Re-opened', 'Was solved, but is once again open.'), - ); - - $retval = 0; - foreach($statuses as $statusId => $subData) { - $insertArr = array( - 'status_id' => $statusId, - 'name' => $subData[0], - 'description' => $subData[1] - ); - $sql = "INSERT INTO status_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to create status (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == count($statuses)) { - //reset the status_table.status_id sequence... - $sql = "SELECT setval('status_table_status_id_seq'::text, (SELECT max(status_id) FROM status_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good to go. - $retval = "Successfully created all status records (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset status sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (failed sanity check)"); - } - - return($retval); - - }//end create_status_records() - //========================================================================= - - - - //========================================================================= - private function create_tag_names() { - $tags = array( - 1 => 'bug', - 2 => 'feature request', - 3 => 'information', - 4 => 'network related', - 5 => 'critical', - 6 => 'exception' - ); - - $retval = 0; - foreach($tags as $id=>$name) { - $insertArr = array( - 'tag_name_id' => $id, - 'name' => $name - ); - $sql = "INSERT INTO tag_name_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to insert data for (". $name .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == count($tags)) { - //reset sequence for tag_name_table.tag_name_id - $sql = "SELECT setval('tag_name_table_tag_name_id_seq'::text, (SELECT max(tag_name_id) FROM tag_name_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - //good to go. - $retval = "Successfully created all tags (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset tag_name sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check failed)"); - } - - return($retval); - }//end create_tag_names() - //========================================================================= - - - - //========================================================================= - private function build_preferences() { - //format: {pref_type_id} => array({name}, {default_value}, {display_name}, {description}) - $prefTypes = array( - 1 => array('startModule', 'helpdesk', 'Starting on Module', 'Defines which section will be loaded upon login if nothing was selected.'), - 5 => array('sorting_helpdesk', 'public_id|DESC', 'Helpdesk Sorting', 'Define the type of sorting for the helpdesk page.'), - 6 => array('sorting_project', 'priority|ASC', 'Project Sorting', 'Define the type of sorting for the helpdesk page.'), - 7 => array('projectDetails_taskDisplayOnlyMine', 'all', 'Project Details: Task display', 'Define what tasks are displayed on a project\\\'s details page.'), - 8 => array('projectDetails_showCompletedIssues', '1', 'Project Details: Display completed issues', 'Should completed issues display in the details of a project?') - ); - - $retval = 0; - foreach($prefTypes as $prefTypeId => $subData) { - $insertArr = array( - 'pref_type_id' => $prefTypeId, - 'name' => $subData[0], - 'default_value' => $subData[1], - 'display_name' => $subData[2], - 'description' => $subData[3] - ); - - $sql = "INSERT INTO pref_type_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql_insert'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to insert data for (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == count($prefTypes)) { - //format: {pref_option_id} => array({pref_type_id}, {name}, {effective_value}) - $prefOptions = array( - 1 =>array(1, 'Helpdesk', 'helpdesk'), - 2 =>array(1, 'Projects', 'project'), - 3 =>array(1, 'Summary ', 'summary'), - 8 =>array(5, 'ID - Descending', 'public_id|DESC'), - 9 =>array(5, 'ID - Ascending', 'public_id|ASC'), - 10 =>array(5, 'Priority - Descending', 'priority|DESC'), - 11 =>array(5, 'Priority - Ascending', 'priority|ASC'), - 12 =>array(5, 'Submit - Descending', 'start_date|DESC'), - 13 =>array(5, 'Submit - Ascending', 'start_date|ASC'), - 14 =>array(5, 'Title - Descending', 'name|DESC'), - 15 =>array(5, 'Title - Ascending', 'name|DESC'), - 16 =>array(5, 'Status ID - Descending', 'status_id|DESC'), - 17 =>array(5, 'Status ID - Ascending', 'status_id|DESC'), - 18 =>array(5, 'Assigned - Descending', 'assigned|DESC'), - 19 =>array(5, 'Assigned - Ascending', 'assigned|DESC'), - 20 =>array(6, 'Priority - Ascending', 'priority|ASC'), - 21 =>array(6, 'Priority - Descending', 'priority|DESC'), - 22 =>array(6, 'Name of Project - Ascending', 'name|ASC'), - 23 =>array(6, 'Name of Project - Descending', 'name|DESC'), - 24 =>array(6, 'Begin - Ascending', 'start_date|ASC'), - 25 =>array(6, 'Begin - Descending', 'start_date|DESC'), - 26 =>array(6, 'End - Ascending', 'end|ASC'), - 27 =>array(6, 'End - Descending', 'end|DESC'), - 28 =>array(6, 'Status ID - Ascending', 'status_id|ASC'), - 29 =>array(6, 'Status ID - Descending', 'status_id|DESC'), - 30 =>array(6, 'Progress - Ascending', 'progress|ASC'), - 31 =>array(6, 'Progress - Descending', 'progress|DESC'), - 32 =>array(6, 'Leader - Ascending', 'leader_contact_id|ASC'), - 33 =>array(6, 'Leader - Descending', 'leader_contact_id|DESC'), - 34 =>array(7, 'Show everything', 'all'), - 35 =>array(7, 'All of mine (created & assigned)', 'mine'), - 36 =>array(7, 'Only my assigned items', 'assigned'), - 37 =>array(8, 'Yes', '1'), - 38 =>array(8, 'No', '0'), - ); - - foreach($prefOptions as $prefOptionId => $subData) { - $insertArr = array( - 'pref_option_id' => $prefOptionId, - 'pref_type_id' => $subData[0], - 'name' => $subData[1], - 'effective_value' => $subData[2] - ); - $sql = "INSERT INTO pref_option_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval++; - $this->totalRecords++; - } - else { - throw new exception(__METHOD__ .": failed to insert data for pref option (". $insertArr['name'] .")::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($retval == (count($prefTypes) + count($prefOptions))) { - //reset the pref_type_table.pref_type_id sequence. - $sql = "SELECT setval('pref_type_table_pref_type_id_seq'::text, (SELECT max(pref_type_id) FROM pref_type_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - if($retval == (count($prefTypes) + count($prefOptions))) { - //reset the pref_option_table.pref_option_id sequence. - $sql = "SELECT setval('pref_option_table_pref_option_id_seq'::text, (SELECT max(pref_option_id) FROM pref_option_table))"; - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $retval = "Successfully created all preferences and options (". $retval .")!"; - } - else { - throw new exception(__METHOD__ .": failed to reset the pref_option sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check #2 failed)"); - } - } - else { - throw new exception(__METHOD__ .": failed to reset pref_type sequence::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check #2 failed): (". $retval ." != ". (count($prefTypes) + count($prefOptions)) .")"); - } - } - else { - throw new exception(__METHOD__ .": internal error (sanity check #1 failed)"); - } - - return($retval); - - }//end build_preferences() - //========================================================================= - - - - //========================================================================= - private function create_users() { - - //retrieve the user information. - $userData = get_setup_data(3, 'post_info'); - if(!is_array($userData) || count($userData) != 2) { - throw new exception(__METHOD__ .": no user data...?". $this->gfObj->debug_print($userData,0)); - } - - $counter = 0; - $retval = "Successfully created records for::: "; - foreach($userData as $num => $subData) { - - //split their name up, based upon spaces. - $nameData = explode(' ', $subData['name']); - $insertArr = array(); - if(count($nameData) == 1) { - $insertArr['fname'] = $nameData[0]; - $insertArr['lname'] = ""; - } - elseif(count($nameData) == 2) { - $insertArr['fname'] = $nameData[0]; - $insertArr['lname'] = $nameData[1]; - } - else { - $insertArr['fname'] = $nameData[0]; - $insertArr['lname'] = preg_replace('/^'. $insertArr['fname'] .' /', '', $subData['name']); - } - $insertArr['contact_email_id'] = '-1'; - - //create their contact record. - $sql = "INSERT INTO contact_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - - if(!strlen($dberror) && $numrows == 1) { - $sql = "SELECT currval('contact_table_contact_id_seq'::text)"; - if($this->run_sql($sql, 1) === TRUE) { - $this->totalRecords++; - - $data = $this->db->farray(); - $contactId = $data[0]; - - //now create the user. - $xUser = $subData['username']; - $insertArr = array( - 'username' => $subData['username'], - 'password' => md5($subData['password'] .'_'. $contactId), - 'is_admin' => interpret_bool($subData['is_admin'], array('f', 't')), - 'contact_id' => $contactId - ); - $sql = "INSERT INTO user_table ". $this->gfObj->string_from_array($insertArr, 'insert', NULL, 'sql'); - - if($this->run_sql($sql, 1) === TRUE) { - $sql = "SELECT currval('user_table_uid_seq'::text)"; - if($this->run_sql($sql,1) === TRUE) { - $data = $this->db->farray(); - $lastUid = $data[0]; - - //create an email address for them. - $sql = "INSERT INTO contact_email_table (contact_id, email) VALUES (". $contactId .", '". strtolower($subData['email']) ."')"; - if($this->run_sql($sql,1) === TRUE) { - $counter++; - //get the newly inserted id, so we can update the contact table. - if($this->run_sql("SELECT currval('contact_email_table_contact_email_id_seq'::text)")) { - $data = $this->db->farray(); - $contactEmailId = $data[0]; - - $sql = "UPDATE contact_table SET contact_email_id=". $contactEmailId ." WHERE contact_id=". $contactId; - if($this->run_sql($sql)) { - $retval = $this->gfObj->create_list($retval, " --- Created record for ". $subData['username'] ." (". $lastUid .")", "<BR>\n"); - } - else { - throw new exception(__METHOD__ .": unable to update contact table with new contact_email_id..."); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve contact_email_id"); - } - } - else { - throw new exception(__METHOD__ .": failed to create email for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": failed to retrieve uid for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": failed to create user record for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": unable to retrieve contact_id for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": failed to create contact record for ". $subData['username'] ."::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - - if($counter == 2) { - $retval = $this->gfObj->create_list($retval, " --->>> done, created (". $counter .") records", "<BR>\n"); - } - else { - throw new exception(__METHOD__ .": failed to create users (". $counter .")::: ". $this->gfObj->debug_print($userData,0)); - } - - return($retval); - }//end create_users() - //========================================================================= - - - - //========================================================================= - public function finish(cs_genericPage &$page) { - - $stepRes = get_setup_data(3, 'result'); - if($stepRes == 1) { - $page->set_message_wrapper(array( - 'title' => "Successfully Setup Data", - 'message' => "All default data was stored in the new database successfully!", - 'type' => "status" - )); - store_setup_data(3, $this->data, 'data'); - $page->conditional_header("/setup/4", TRUE); - } - else { - $page->set_message_wrapper(array( - 'title' => "Step Failed", - 'message' => "Please review the errors below and proceed accordingly.", - 'type' => "error" - )); - $page->conditional_header("/setup/3", TRUE); - } - - }//end finish() - //========================================================================= - - - - //========================================================================= - protected function run_sql($sql, $expectedNumrows=NULL) { - if(strlen($sql)) { - $numrows = $this->db->exec($sql); - $dberror = $this->db->errorMsg(); - $this->lastNumrows = $numrows; - $this->lastDberror = $dberror; - - if(!strlen($dberror) && $numrows >= 0) { - if(is_numeric($expectedNumrows)) { - if($expectedNumrows == $numrows) { - $retval = TRUE; - } - else { - $retval = FALSE; - } - } - else { - //don't care if it's numeric. - $retval = TRUE; - } - } - else { - throw new exception(__METHOD__ .": failed to run SQL, got numrows=(". $numrows ."), dberror::: ". $dberror ."<BR>\nSQL::: ". $sql); - } - } - else { - throw new exception(__METHOD__ .": no SQL to run..."); - } - - return($retval); - }//end run_sql() - //========================================================================= - - - - //========================================================================= - private function create_user_group_records() { - $sql = "INSERT INTO user_group_table (uid, group_id) SELECT uid, group_id FROM user_table"; - if($this->run_sql($sql, 3) === TRUE) { - $retval = "Successfully created user_group linkage."; - } - else { - throw new exception(__METHOD__ .": unable to create user group records::: ". $this->lastDberror ."<BR>\nSQL::: ". $sql); - } - return($retval); - }//end create_user_group_records() - //========================================================================= - - -}//end __setupDefaultValues{} - - - -?> Copied: releases/1.2/lib/_setup/__setupDefaultValues.class.php (from rev 992, trunk/1.2/lib/_setup/__setupDefaultValues.class.php) =================================================================== --- releases/1.2/lib/_setup/__setupDefaultValues.class.php (rev 0) +++ releases/1.2/lib/_setup/__setupDefaultValues.class.php 2009-10-26 03:15:10 UTC (rev 996) @@ -0,0 +1,974 @@ +<?php +/* + * Created on Aug 23, 2007 + * + * SVN INFORMATION::: + * ------------------- + * Last Author::::::::: $Author$ + * Current Revision:::: $Revision$ + * Repository Location: $HeadURL$ + * Last Updated:::::::: $Date$ + */ + +class __setupDefaultValues extends cs_webdbupgrade { + + + protected $db; + private $totalRecords=0; + + private $data=array(); + + private $lastNumrows=NULL; + private $lastDberror=NULL; + + //========================================================================= + public function __construct() { + $this->db = new cs_phpDB; + $this->gfObj = new cs_globalFunctions; + }//end __construct() + //========================================================================= + + + + //========================================================================= + public function go() { + store_setup_data(3, 0, 'result'); + try { + $params = get_db_params(); + $this->db->connect($params); + $this->db->beginTrans(__METHOD__); + $retval = "Connected successfully to the database."; + + //now that we've connected, start doing stuff. + $retval = $this->set_version(); + $retval .= "<BR>\n". $this->create_log_categories_and_classes(); + $retval .= "<BR>\n". $this->create_attributes(); + $retval .= "<BR>\n". $this->create_anonymous_contact_data(); + $retval .= "<BR>\n". $this->create_status_records(); + $retval .= "<BR>\n". $this->create_tag_names(); + $retval .= "<BR>\n". $this->build_preferences(); + $retval .= "<BR>\n". $this->create_users(); + $retval .= "<BR>\n". $this->create_user_group_records(); + + $commitRes = $this->db->commitTrans(); + if($commitRes == 1) { + $retval .= "<BR>\n ----------- Created (". $this->totalRecords ."), result of commit: (". $commitRes .")."; + store_setup_data(3, 1, 'result'); + store_setup_data(4, 1, 'accessible'); + } + else { + $this->db->rollbackTrans(); + store_setup_data(3, 0, 'result'); + throw new exception(__METHOD__ .": failed to commit the transaction (". $commitRes .")"); + } + + } + catch(exception $e) { + //TODO: rollback the transaction + $retval = "An error occurred: ". $e->getMessage(); + } + + return($retval); + + }//end go() + //========================================================================= + + + + //========================================================================= + /** + * Set version information into the database for future upgradeability. + */ + private function set_version() { + //get the version string. + $fullVersionString = read_version_file(); + + $suffixData = explode('-', $fullVersionString); + if(count($suffixData) == 2 && preg_match('/\./', $suffixData[0]) && !preg_match('/\./', $suffixData[1])) { + //there's a suffix, and it doesn't contain periods (i.e. "1.0.0-ALPHA1") + $suffix = $suffixData[1]; + } + elseif(count($suffixData) == 1) { + //no suffix. + $suffix = ""; + } + else { + //there's a dash in the name, but it's invalid or contains periods (i.e. "BETA-1.0.0" or "1.0.0-ALPHA1.0") + throw new exception(__METHOD__ .": version string is invalid (". $fullVersionString ."), suffix contains dashes, or there is a prefix"); + } + + //remove the suffix & parse it. + $versionString = $suffixData[0]; + $versionData = $this->parse_version_string($fullVersionString); + $sqlData = $versionData; + + + #$sqlData = array( + # 'version_string' => $fullVersionString, + # 'version_major' => $versionData[0], + # 'version_minor' => $versionData[1], + # 'version_maintenance' => $versionData[2], + # 'version_suffix' => $suffix + #); + + $retval = 0; + foreach($sqlData as $name => $value) { + $sql = "SELECT internal_data_set_value('". $name ."', '". $value ."')"; + $numrows = $this->db->exec($sql); + $dberror = $this->db->errorMsg(); + + if(!strlen($dberror) && $numrows == 1) { + $retval++; + $this->totalRecords++; + } + else { + throw new exception(__METHOD__ .": failed to set (". $name .") as (". $value .")::: ". $dberror); + } + } + + if($retval == count($sqlData)) { + //okay, the final test: run a query that straps everything together, to ensure it all has the same version. + $sql = "SELECT internal_data_get_value('version_major') || '.' || internal_data_get_value('version_minor') " . + " || '.' || internal_data_get_value('version_maintenance') as text, " . + "internal_data_get_value('... [truncated message content] |