ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

graph_data_algorithms.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
26 class graph_data_algorithms_1_0_0{
27
38 var $GraphDataAccess = false;
39 var $Security = false;
40 var $SecurityParser = false;
41
52 function __construct()
53 {
54 try
55 {
56 $this->GraphDataAccess = get_package( 'graph::graph_data::graph_data_access' , 'last' , __FILE__ );
57 $this->Security = get_package( 'security' , 'last' , __FILE__ );
58 $this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
59 }
60 catch( Exception $e )
61 {
62 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
63 }
64 }
65
92 function get_abscissa_range( $UserId , $GraphType )
93 {
94 try
95 {
96 $UserId = $this->Security->get( $UserId , 'integer' );
97 $GraphType = $this->Security->get( $GraphType , 'integer' );
98
99 $Records = $this->GraphDataAccess->unsafe_select(
100 "author = $UserId AND graph_type = $GraphType" ,
101 "MIN( abscissa ) AS `from` , MAX( abscissa ) AS `to`"
102 );
103
104 if( isset( $Records[ 0 ] ) === false || get_field( $Records[ 0 ] , 'from' ) == null )
105 {
106 return( false );
107 }
108
109 return(
110 array( 'from' => get_field( $Records[ 0 ] , 'from' ) , 'to' => get_field( $Records[ 0 ] , 'to' ) )
111 );
112 }
113 catch( Exception $e )
114 {
115 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
116 }
117 }
118
153 function get_data_for_range( $UserId , $GraphType , $AbscissaFrom , $AbscissaTo )
154 {
155 try
156 {
157 $UserId = $this->Security->get( $UserId , 'integer' );
158 $GraphType = $this->Security->get( $GraphType , 'integer' );
159 $AbscissaFrom = $this->Security->get( $AbscissaFrom , 'integer' );
160 $AbscissaTo = $this->Security->get( $AbscissaTo , 'integer' );
161
162 $Records = $this->GraphDataAccess->unsafe_select(
163 "author = $UserId AND graph_type = $GraphType ".
164 "AND abscissa >= $AbscissaFrom AND abscissa <= $AbscissaTo ORDER BY abscissa ASC"
165 );
166
167 return( $Records );
168 }
169 catch( Exception $e )
170 {
171 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
172 }
173 }
174
205 function get_abscissa_for_ordinatus( $DataX ,$DataY , $Ordinatus )
206 {
207 try
208 {
209 foreach( $DataY as $i => $Y )
210 {
211 if( $Y == $Ordinatus )
212 {
213 return( $DataX[ $i ] );
214 }
215 }
216
217 throw( new Exception( 'Abscissa was not found' ) );
218 }
219 catch( Exception $e )
220 {
221 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
222 }
223 }
224 }
225
226 ?>