protected function _pre_update($data) { //插入權限檢查 //$this->auth->allow(1); if (FALSE === isset($data['title']) or is_null($data['title'])) { $host = $this->get_field('host'); $title = retrieve_title($host); if (NULL != $title) { $data['title'] = $title; $this->set_field('title', $title); } } return $data; }
function test() { $this->load->library('unit_test'); //$test = 1 + 1; //$expected_result = 2; //$test_name = 'Adds one plus one'; //$this->unit->run($test, $expected_result, $test_name); $this->load->helper('kals'); $this->unit->run(get_referer_url(), 'http://localhost/CodeIgniter_1.7.2/unit_test', '取得參考的網址!' . get_referer_url()); $this->unit->run(parse_host(get_referer_url()), $this->host, '取得參考的HOST!' . parse_host()); $this->unit->run(parse_uri('http://localhost/CodeIgniter_1.7.2/index.php/ut_misc/ut_kals_helper/test'), '/CodeIgniter_1.7.2/index.php/ut_misc/ut_kals_helper/test', '取得參考的URI!' . parse_uri()); $this->unit->run(url_is_link('http://images.plurk.com/1422855_79bdc93f1317c2a7b8c9f0c5d51586c9.jpg'), TRUE, '確認是否是連結'); $this->unit->run(url_is_image('http://images.plurk.com/1422855_79bdc93f1317c2a7b8c9f0c5d51586c9.jpg'), TRUE, '確認是否是圖片'); $this->unit->run(url_is_link('http://www.plurk.com/p/5u89gi#response-1629050986'), TRUE, '確認是否是連結'); $this->unit->run(url_is_image('http://www.plurk.com/p/5u89gi#response-1629050986'), FALSE, '確認是否是圖片'); $this->unit->run(parse_email_name('*****@*****.**'), 'puddingchen.35', '取出email的名字'); $this->unit->run(retrieve_title('http://www.plurk.com/p/5uuz7o#response-1632175301'), 'JS布丁 正在 [CODING D2] http://www.youtube.com/watch?v=c8I_WPonFHE 進度:2/182 - #5uuz7o', '取得網頁的title'); $data = array('title' => get_class($this), 'unit' => $this->unit); $this->load->view('misc/unit_test', $data); }
protected function _pre_update($data) { //插入權限檢查 //$this->auth->allow(2); // 過濾url if (isset($data['url'])) { $data['url'] = url_strip_index($data['url']); } if (FALSE === isset($data['title']) or is_null($data['title'])) { $title = retrieve_title($this->get_url()); if (NULL != $title) { $data['title'] = $title; $this->set_field('title', $title); } } return $data; }