/** * Load view file * * @param string $file Name of the view file * @param array $data Array of data to be bind on the view * * @throws \SilverWp\Exception * @return String The result view * @access public */ public function load($file, $data = array(), $extension = 'php') { $view_file = $file . '.' . $extension; if (!file_exists($view_file)) { throw new Exception("View file not found: {$view_file}"); } \extract($data); // fix bug when data is form Ajaxt request if (AjaxAbstract::isAjax()) { return include $view_file; } else { \ob_start(); include $view_file; $content = \ob_get_clean(); return $content; } }
/** * * Generate JSON response * * @param int $already 0/1 user vote or not * @param int $post_like_count * * @return string * @access private */ private function response($already, $post_like_count) { $data = array('already' => $already, 'count' => $post_like_count); parent::responseJson($data); }