Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezhttppersistence.php
Go to the documentation of this file.
1 <?php
20 class eZHTTPPersistence
21 {
25 public function __construct()
26 {
27 }
28
42 static function fetch( $base_name, array $def, $objects, eZHTTPTool $http, $is_array, $indexField = false )
43 {
44 if ( $is_array )
45 {
46 for ( $i = 0, $iMax = count( $objects ); $i < $iMax; ++$i )
47 {
48 $object = $objects[$i];
49 $index = is_string( $indexField ) ? $indexField : $i;
50 eZHTTPPersistence::fetchElement( $base_name, $def, $object, $http, $index );
51 }
52 }
53 else
54 {
55 eZHTTPPersistence::fetchElement( $base_name, $def, $objects, $http, false );
56 }
57 }
58
72 static function fetchElement( $base_name, array $def, $object, eZHTTPTool $http, $index )
73 {
74 $fields = $def["fields"];
75 $keys = $def["keys"];
76 foreach ( $fields as $field_name => $field_member )
77 {
78 if ( !in_array( $field_name, $keys ) )
79 {
80 $post_var = $base_name . "_" . $field_name;
81 if ( $http->hasPostVariable( $post_var ) )
82 {
83 $post_value = $http->postVariable( $post_var );
84 if ( $index === false )
85 {
86 if ( $post_value !== null &&
87 $field_member['datatype'] === 'string' &&
88 array_key_exists( 'max_length', $field_member ) &&
89 $field_member['max_length'] > 0 &&
90 strlen( $post_value ) > $field_member['max_length'] )
91 {
92 $post_value = substr( $post_value, 0, $field_member['max_length'] );
93 eZDebug::writeDebug( $post_value, "truncation of $field_name to max_length=". $field_member['max_length'] );
94 }
95 $object->setAttribute( $field_name, $post_value );
96 }
97 else if ( is_string( $index ) )
98 {
99 $object->setAttribute( $field_name, $post_value[$object->attribute( $index )] );
100 }
101 else
102 {
103 $object->setAttribute( $field_name, $post_value[$index] );
104 }
105 }
106 }
107 }
108 }
109
125 static function splitSelected( $base_name, $objects, eZHTTPTool $http, $cond, &$keepers, &$rejects )
126 {
127 $keepers = array();
128 $rejects = array();
129 $post_var = $base_name . "_" . $cond . "_checked";
130 if ( $http->hasPostVariable( $post_var ) )
131 {
132 $checks = $http->postVariable( $post_var );
133 }
134 else
135 {
136 return false;
137 }
138 foreach( $objects as $object )
139 {
140 if ( $object->hasAttribute( $cond ) )
141 {
142 $val = $object->attribute( $cond );
143 if ( in_array( $val, $checks ) )
144 {
145 $rejects[] = $object;
146 }
147 else
148 {
149 $keepers[] = $object;
150 }
151 }
152 else
153 {
154 $keepers[] = $object;
155 }
156 }
157 return true;
158 }
159 }
160 ?>
eZDebug\writeDebug
static writeDebug( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:588
eZHTTPPersistence
Definition: ezhttppersistence.php:21
eZHTTPPersistence\__construct
__construct()
Definition: ezhttppersistence.php:25
eZHTTPPersistence\fetch
static fetch( $base_name, array $def, $objects, eZHTTPTool $http, $is_array, $indexField=false)
Definition: ezhttppersistence.php:42
eZHTTPPersistence\fetchElement
static fetchElement( $base_name, array $def, $object, eZHTTPTool $http, $index)
Definition: ezhttppersistence.php:72
eZHTTPPersistence\splitSelected
static splitSelected( $base_name, $objects, eZHTTPTool $http, $cond, &$keepers, &$rejects)
Definition: ezhttppersistence.php:125
eZHTTPTool
Provides access to HTTP post,get and session variables.
Definition: ezhttptool.php:24
eZHTTPTool\postVariable
postVariable( $var, $fallbackValue=null)
Definition: ezhttptool.php:50
eZHTTPTool\hasPostVariable
hasPostVariable( $var)
Definition: ezhttptool.php:69
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.