コード例 #1
0
ファイル: Template.php プロジェクト: sttt/phery-kohana
 /**
  * Assigns the template [View] as the request response.
  */
 public function after()
 {
     if (Phery::is_ajax(true)) {
         $this->auto_render = false;
     }
     parent::after();
     if ($this->auto_render === TRUE) {
         $this->response->body($this->template->render());
     }
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: sttt/phery-kohana
 public function after()
 {
     $this->ajax->config(array_replace($this->ajax_config, $this->ajax(), array('exit_allowed' => false, 'return' => true)));
     parent::after();
     if (Phery::is_ajax(true)) {
         try {
             if (($response = $this->ajax->process()) !== false) {
                 $this->response->headers(array('Content-Type' => 'application/json'))->body($response);
             }
         } catch (PheryException $exc) {
             Kohana::$log->add(Log::ERROR, $exc->getMessage());
             $answer = PheryResponse::factory();
             if ($exc->getCode() === Phery::ERROR_CSRF) {
                 $answer->renew_csrf($this->ajax);
             }
             $this->response->headers(array('Content-Type' => 'application/json'))->body($answer);
         }
     }
 }
コード例 #3
0
ファイル: demo.php プロジェクト: cbsistem/phery
/**
 * Callback that executes before calling the remote ajax function
 * This is usually useful when dealing with repetitive tasks or to
 * centralize all the common tasks to one big callback
 */
function pre_callback($data, $callback_specific_data_as_array)
{
    // Dont mess with data that is submited without ajax
    if (Phery::is_ajax()) {
        ob_start();
        unset($callback_specific_data_as_array['phery']);
        var_export(array(array('$data' => $data), array('$callback_specific_data_as_array' => $callback_specific_data_as_array)));
        $dump = ob_get_clean();
        $data['new-onthefly-var'] = $dump;
    }
    if (is_array($data)) {
        foreach ($data as &$d) {
            if (is_string($d)) {
                $d = strtoupper($d);
            }
        }
    }
    return $data;
    // Must return the data, or false if you want to stop further processing
}