Modules | |
Zigmoyd Define System. | |
This file is part of Zigmoyd PHP Framework. | |
Error handler Module. | |
This file is part of Zigmoyd PHP Framework. | |
Common Database Essentials | |
This file is part of Zigmoyd PHP Framework. | |
Functions | |
strchr_occurrences ($str, $chr) | |
url_segment () | |
Returns the different segments of an url. | |
getUrlRoot () | |
Return the Url Root [Similer to zigController::getUrlRoot()]. | |
getCurrentUrl ($bindGet=false) | |
Returns the Current Url e.g. | |
array_fix ($key, $val) | |
zero_fill ($str) | |
Fills a number with Zeros and returns it as a string. | |
Variables | |
if(!defined('ZIG_URL_SEGMENT_PATH')) define('ZIG_URL_SEGMENT_PATH' | true |
if(!defined('ZIG_URL_SEGMENT_ALL')) define('ZIG_URL_SEGMENT_ALL' | false |
Copyright (C) 2008 Neel Basu (Sunanda Bose)
Zigmoyd PHP Framework is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Zigmoyd PHP Framework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with Zigmoyd PHP Framework. If not, see <http://www.gnu.org/licenses/>.
array_fix | ( | $ | key, | |
$ | val | |||
) |
Zigmoyd's Internal method.
For internal use only.
$key | unknown | |
$val | unknown |
Definition at line 172 of file usr/include/czr.php.
References $val, and perror().
00172 { 00173 if(count($key) != count($val)){ 00174 perror('invalid arguments sent to array_fix(array, array)<br />Length of 2 inputed arrays (key, value), must be same<br /> 00175 $key array is of length '.count($key).'<br />and contains<pre>'.print_r($key, true). 00176 '</pre>and<br />$val array is of length '.count($val).'<br />and contains<pre>'.print_r($val, true).'</pre>'); 00177 return false; 00178 }else{ 00179 for($i=0;$i<count($key);$i++){ 00180 $ret[$key[$i]] = $val[$i]; 00181 } 00182 } 00183 return $ret; 00184 }
getCurrentUrl | ( | $ | bindGet = false |
) |
Returns the Current Url e.g.
http://example.com/controller/method/args if true is supplied as an argument also includes the Get query in the returned Url
$bindGet | boolean if set to true also includes the Get query in the returned Url |
Definition at line 151 of file usr/include/czr.php.
References $val, getUrlRoot(), and url_segment().
Referenced by form::start(), and form::startMultipart().
00151 { 00152 if(!$bindGet) 00153 return getUrlRoot().'/'.implode('/', url_segment(ZIG_URL_SEGMENT_PATH)); 00154 else{ 00155 $base = getUrlRoot().'/'.implode('/', url_segment(ZIG_URL_SEGMENT_PATH)); 00156 if(is_array($this->request->get->items) && count($this->request->get->items) >= 1){ 00157 $base .= "?"; 00158 foreach($this->request->get->items as $key => $val){ 00159 $base .= "$key=$val"; 00160 } 00161 } 00162 return $base; 00163 } 00164 }
getUrlRoot | ( | ) |
Return the Url Root [Similer to zigController::getUrlRoot()].
Definition at line 140 of file usr/include/czr.php.
Referenced by getCurrentUrl().
strchr_occurrences | ( | $ | str, | |
$ | chr | |||
) |
Definition at line 27 of file usr/include/czr.php.
Referenced by zigController::retViewPath().
00027 { 00028 $i=0; 00029 while(($rest = strstr($str, $chr)) !== false){ 00030 $str = substr($rest, 1); 00031 $i++; 00032 } 00033 return $i; 00034 }
url_segment | ( | ) |
Returns the different segments of an url.
A very Handy and must use tool for analyzing Urls e.g. url_segment('http://username:password/path/to/file?arg=valueanchor', 'host') If no url is given it takes the current url as the requested url would return separate segment of the url according to given argument For example
scheme => http host => hostname user => username pass => password path => /path query => arg=value fragment => anchorIf you use url_segment(0) or url_segment(1) It will return firstPart and secondPart /firstPart/secondPart.
$url | string | |
$segment | mixed |
Definition at line 55 of file usr/include/czr.php.
References perror().
Referenced by rewriteMapParser::currentUrlPath(), zigController::forward(), zigController::getCurrentUrl(), getCurrentUrl(), and zHttpAuth::sendHeaders().
00055 { 00056 $list_args = func_get_args(); 00057 switch(func_num_args()){ 00058 case 2: 00059 $url = $list_args[0]; 00060 $segment = $list_args[1]; 00061 break; 00062 case 1: 00063 if(isset($_SERVER['SCRIPT_URI'])){ 00064 $url = $_SERVER['SCRIPT_URI'].'?'.$_SERVER['QUERY_STRING']; 00065 }else{ 00066 //{ Build the uri Manually 00067 //{{ Set the Protocol 00068 if(preg_match('/HTTP\/(.+)/', $_SERVER['SERVER_PROTOCOL'])){ 00069 $protocol = 'http'; 00070 }else{ 00071 $protocol = 'https'; 00072 } 00073 //}} 00074 if($_SERVER['SERVER_PORT'] != 80)$url = $protocol.'://'.$_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].'/'.$_SERVER['REQUEST_URI']; 00075 else $url = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 00076 //} 00077 } 00078 $segment = $list_args[0]; 00079 break; 00080 case 0: 00081 if(isset($_SERVER['SCRIPT_URI'])){ 00082 $url = $_SERVER['SCRIPT_URI'].'?'.$_SERVER['QUERY_STRING']; 00083 }else{ 00084 //{ Build the uri Manually 00085 //{{ Set the Protocol 00086 if(preg_match('/HTTP\/(.+)/', $_SERVER['SERVER_PROTOCOL'])){ 00087 $protocol = 'http'; 00088 }else{ 00089 $protocol = 'https'; 00090 } 00091 //}} 00092 if($_SERVER['SERVER_PORT'] != 80)$url = $protocol.'://'.$_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].'/'.$_SERVER['REQUEST_URI']; 00093 else $url = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 00094 //} 00095 } 00096 $segment = true; 00097 break; 00098 default: 00099 perror("url_segment Takes only 1 or 2 arguments ".count($list_args).' Given'); 00100 return false; 00101 } 00102 if(is_string($segment) && $segment == 'url')return $url; 00103 $url = parse_url($url); 00104 if(isset($url['path']))$url['path'] = '/'.ltrim($url['path'], '/'); 00105 switch(gettype($segment)){ 00106 case 'string': 00107 if(!isset($url[$segment]) || @strlen($segment)<=0){return false;} 00108 else{ 00109 return $url[$segment]; 00110 } 00111 break; 00112 case 'integer': 00113 $path_segment = explode('/', trim(@$_SERVER['PATH_INFO'], '/')); 00114 if(!isset($path_segment[$segment])){return false;} 00115 else{ 00116 return $path_segment[$segment]; 00117 } 00118 break; 00119 case 'boolean': 00120 switch($segment){ 00121 case true: 00122 $path_segment = explode('/', trim(@$_SERVER['PATH_INFO'], '/')); 00123 return $path_segment; 00124 break; 00125 case false: 00126 return $url; 00127 break; 00128 } 00129 break; 00130 default: 00131 perror('The segment must be a String or an integer '.gettype($segment).' provided'); 00132 return false; 00133 } 00134 }
zero_fill | ( | $ | str | ) |
Fills a number with Zeros and returns it as a string.
For internal use only.
$str | int |
Definition at line 192 of file usr/include/czr.php.
00192 { 00193 $str = (string)$str; 00194 if(strlen($str)>4){return $str;} 00195 while(strlen($str) < 4){ 00196 $str = '0'.$str; 00197 } 00198 return $str; 00199 } 00200 if(!function_exists('class_exists')){ 00201 function class_exists($className){ 00202 return in_array($className, get_declared_classes()); 00203 } 00204 }
Definition at line 26 of file usr/include/czr.php.
Definition at line 25 of file usr/include/czr.php.