view->controller->Ajaxthis->initThis($ajaxCall,$ajaxAction,$ajaxParams); if(!isset($params)){ return null; } else{ return $params; } } /** *Public : Returning path to dummy ajax method with given params + the name of element to render and requested params **/ function ajaxThis($ajaxCall = null,$ajaxAction = null,$ajaxViews = null,$ajaxParams = array()){ if(!empty($ajaxAction)){ return array( 'url' => '/'.$this->view->controller->params['controller'].'/ajaxThis/'.base64_encode($ajaxCall).'/'.base64_encode($ajaxAction).'/'.$this->_encodeAjaxViews($ajaxViews).'/'.base64_encode(http_build_query($ajaxParams, '', '&')), 'update' => $this->_filterAjaxViews($ajaxViews) ); } else{ return array( 'url' => '/'.$this->view->controller->params['controller'].'/ajaxThis/'.base64_encode($ajaxCall).'/'.$this->_encodeAjaxViews($ajaxViews).'/'.base64_encode(http_build_query($ajaxParams, '', '&')), 'update' => $this->_filterAjaxViews($ajaxViews) ); } } /** *Private : Encoding ajaxViews array **/ function _encodeAjaxViews($ajaxViews){ $ajaxViews = $this->_setAjaxViews($ajaxViews); if(!empty($ajaxViews)){ return base64_encode($ajaxViews); } else{ return $ajaxViews; } } /** *Private : Filter ajaxViews array **/ function _filterAjaxViews($ajaxViews){ $ajaxViews = $this->_setAjaxViews($ajaxViews); if(strpos($ajaxViews , '&')===false){ if(!(strpos($ajaxViews,'\\')===false)){ return stripslashes($ajaxViews); } else{ return $ajaxViews; } } else{ $ajaxViews = explode('&' , $ajaxViews); foreach($ajaxViews as &$view){ $view = stripslashes($view); if(!(strpos($view,'\\')===false)){ $view = stripslashes($view); //$view=substr($view,strpos($view,'\\')+1,strlen($view)); } } return $ajaxViews; } } /** *Private : set corresponding ajaxViews **/ function _setAjaxViews($ajaxViews,$separator = '&'){ if (!empty($ajaxViews)){ if(!is_array($ajaxViews)){ return $ajaxViews; } else{ $commonViews = ''; $specificViews = ''; foreach($ajaxViews as $key => $view){ if($key == 'common'){ if(!is_array($view)){ $commonViews .= $view.$separator; } else{ foreach($view as $commonView){ $commonViews .= $commonView.$separator; } } } else{ if(strtolower($key) == strtolower($this->view->controller->params['controller'])){ if(!is_array($view)){ $specificViews .= $view.$separator; } else{ foreach($view as $action => $specificView){ if(strtolower($action) == strtolower($this->view->controller->params['action'])){ if(!is_array($specificView)){ $specificViews .= $specificView.$separator; } else{ foreach($specificView as $subview){ $specificViews .= $subview.$separator; } } } } } } } } if($commonViews!=''){ if($specificViews!=''){ return substr($commonViews.$specificViews,0,strlen($commonViews.$specificViews)-1); } else{ return substr($commonViews,0,strlen($commonViews)-1); } } else{ if($specificViews!=''){ return substr($specificViews,0,strlen($specificViews)-1); } else{ return null; } } } } else{ return null; } } } ?>