$this->_afterAdd($item);
$url = @$request->POST['ipf_referrer'];
if ($url=='')
- $url = IPF_HTTP_URL_urlForView('IPF_Admin_Views_ListItems', array($lapp, $lmodel));
+ $url = IPF_HTTP_URL::urlForView('IPF_Admin_Views_ListItems', array($lapp, $lmodel));
return new IPF_HTTP_Response_Redirect($url);
}
}
$o->delete();
$url = @$request->POST['ipf_referrer'];
if ($url=='')
- $url = IPF_HTTP_URL_urlForView('IPF_Admin_Views_ListItems', array($lapp, $lmodel));
+ $url = IPF_HTTP_URL::urlForView('IPF_Admin_Views_ListItems', array($lapp, $lmodel));
return new IPF_HTTP_Response_Redirect($url);
}
$context = array(
$this->_afterEdit($item);
$url = @$request->POST['ipf_referrer'];
if ($url=='')
- $url = IPF_HTTP_URL_urlForView('IPF_Admin_Views_ListItems', array($lapp, $lmodel));
+ $url = IPF_HTTP_URL::urlForView('IPF_Admin_Views_ListItems', array($lapp, $lmodel));
return new IPF_HTTP_Response_Redirect($url);
}
}
const CHANGE = 2;
const DELETION = 3;
- public static function logAction($request, $object, $action_flag, $message=''){
+ public static function logAction($request, $object, $action_flag, $message='')
+ {
$log = new AdminLog();
$log->username = $request->user->username;
$log->user_id = $request->user->id;
$log->save();
}
- public function is_addition(){
+ public function is_addition()
+ {
if ($this->action_flag==AdminLog::ADDITION)
return true;
return false;
}
- public function is_change(){
+ public function is_change()
+ {
if ($this->action_flag==AdminLog::CHANGE)
return true;
return false;
}
- public function is_deletion(){
+ public function is_deletion()
+ {
if ($this->action_flag==AdminLog::DELETION)
return true;
return false;
}
- public function GetAdminUrl(){
- return IPF_HTTP_URL_urlForView('IPF_Admin_Views_Index').IPF_Utils::appLabelByModel($this->object_class).'/'.strtolower($this->object_class).'/'.$this->object_id.'/';
+ public function GetAdminUrl()
+ {
+ return IPF_HTTP_URL::urlForView('IPF_Admin_Views_Index').IPF_Utils::appLabelByModel($this->object_class).'/'.strtolower($this->object_class).'/'.$this->object_id.'/';
}
-
}
}
return '/';
}
-}
-function IPF_HTTP_URL_urlForView($view, $params=array(), $by_name=false,
- $get_params=array(), $encoded=true)
-{
- $action = IPF_HTTP_URL_reverse($view, $params, $by_name);
- return IPF_HTTP_URL::generate($action, $get_params, $encoded);
-}
+ public static function urlForView($view, $params=array(), $by_name=false,
+ $get_params=array(), $encoded=true)
+ {
+ $action = self::reverse($view, $params, $by_name);
+ return self::generate($action, $get_params, $encoded);
+ }
-function IPF_HTTP_URL_reverse($view, $params=array(), $by_name=false)
-{
- $regex = null;
-
- foreach (IPF::get('urls') as $url) {
- $prefix = $url['prefix'];
- foreach ($url['urls'] as $suburl){
- if ($suburl['func']==$view){
- $regex = $prefix.$suburl['regex'];
- break;
+ public static function reverse($view, $params=array(), $by_name=false)
+ {
+ $regex = null;
+
+ foreach (IPF::get('urls') as $url) {
+ $prefix = $url['prefix'];
+ foreach ($url['urls'] as $suburl){
+ if ($suburl['func']==$view){
+ $regex = $prefix.$suburl['regex'];
+ break;
+ }
}
+ if ($regex!==null)
+ break;
}
- if ($regex!==null)
- break;
- }
- if ($regex === null) {
- throw new IPF_Exception('Error, the view: '.$view.' has not been found.');
+ if ($regex === null) {
+ throw new IPF_Exception('Error, the view: '.$view.' has not been found.');
+ }
+ $url = self::buildReverseUrl($regex, $params);
+ return IPF::get('app_base').$url;
}
- $url = IPF_HTTP_URL_buildReverseUrl($regex, $params);
- return IPF::get('app_base').$url;
-}
-function IPF_HTTP_URL_buildReverseUrl($url_regex, $params=array())
-{
- $url_regex = str_replace('\\.', '.', $url_regex);
- $url_regex = str_replace('\\-', '-', $url_regex);
- $url = $url_regex;
- $groups = '#\(([^)]+)\)#';
- $matches = array();
- preg_match_all($groups, $url_regex, $matches);
- reset($params);
- if (count($matches[0]) && count($matches[0]) == count($params)) {
- // Test the params against the pattern
- foreach ($matches[0] as $pattern) {
- $in = current($params);
- if (0 === preg_match('#'.$pattern.'#', $in)) {
- throw new IPF_Exception('Error, param: '.$in.' is not matching the pattern: '.$pattern);
+ public static function buildReverseUrl($url_regex, $params=array())
+ {
+ $url_regex = str_replace('\\.', '.', $url_regex);
+ $url_regex = str_replace('\\-', '-', $url_regex);
+ $url = $url_regex;
+ $groups = '#\(([^)]+)\)#';
+ $matches = array();
+ preg_match_all($groups, $url_regex, $matches);
+ reset($params);
+ if (count($matches[0]) && count($matches[0]) == count($params)) {
+ // Test the params against the pattern
+ foreach ($matches[0] as $pattern) {
+ $in = current($params);
+ if (0 === preg_match('#'.$pattern.'#', $in)) {
+ throw new IPF_Exception('Error, param: '.$in.' is not matching the pattern: '.$pattern);
+ }
+ next($params);
}
- next($params);
+ $func = create_function('$matches',
+ 'static $p = '.var_export($params, true).'; '.
+ '$a = current($p); '.
+ 'next($p); '.
+ 'return $a;');
+ $url = preg_replace_callback($groups, $func, $url_regex);
}
- $func = create_function('$matches',
- 'static $p = '.var_export($params, true).'; '.
- '$a = current($p); '.
- 'next($p); '.
- 'return $a;');
- $url = preg_replace_callback($groups, $func, $url_regex);
- }
- $url = substr(substr($url, 2), 0, -2);
- if (substr($url, -1) !== '$') {
- return $url;
+ $url = substr(substr($url, 2), 0, -2);
+ if (substr($url, -1) !== '$') {
+ return $url;
+ }
+ return substr($url, 0, -1);
}
- return substr($url, 0, -1);
}
+