ultimix
settings_utilities.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
27 
50  function transform_settings( $Settings , $Separator )
51  {
52  try
53  {
54  $Settings = str_replace(
55  array( "\r" , "\n" , $Separator.$Separator ) ,
56  array( $Separator , $Separator , $Separator ) ,
57  $Settings
58  );
59 
60  return( explode( $Separator , $Settings ) );
61  }
62  catch( Exception $e )
63  {
64  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
65  }
66  }
67 
86  function load_settings( $Settings )
87  {
88  try
89  {
90  $SettingsList = array();
91  foreach( $Settings as $s )
92  {
93  $Tmp = explode( '=' , $s );
94  if( isset( $Tmp[ 1 ] ) === true )
95  {
96  $SettingsList[ $Tmp[ 0 ] ] = $Tmp[ 1 ];
97  }
98  elseif( isset( $Tmp[ 0 ] ) === true && isset( $Tmp[ 1 ] ) === false )
99  {
100  $SettingsList[ $Tmp[ 0 ] ] = true;
101  }
102  elseif( isset( $Tmp[ 0 ] ) === false )
103  {
104  $Settings = serialize( $Settings );
105  $s = serialize( $s );
106  $Tmp = serialize( $Tmp );
107  throw_exception( "Settings : $Settings s : $s Tmp : $Tmp Illegal settings string" );
108  }
109  }
110  return( $SettingsList );
111  }
112  catch( Exception $e )
113  {
114  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
115  }
116  }
117  }
118 
119 ?>