コード例 #1
0
 public function actionDelete($id)
 {
     $contact = (new Contact())->findById((int) $id)[0];
     $deleted = false;
     if ($contact->user_id == App::getComponent('user')->getId()) {
         $deleted = (bool) $contact->delete();
     }
     if (App::getComponent('request')->isAjax()) {
         return $deleted;
     }
     $this->redirect('contacts');
 }
コード例 #2
0
ファイル: Html.php プロジェクト: tonci/phonebook
 public static function endForm()
 {
     return App::getComponent('view')->render(__DIR__ . '/views/endForm.php');
 }
コード例 #3
0
ファイル: ErrorController.php プロジェクト: tonci/phonebook
 public function action404()
 {
     $params['home_url'] = App::getComponent('request')->getBaseUrl();
     return $this->renderPartial('404', $params);
 }
コード例 #4
0
ファイル: UserController.php プロジェクト: tonci/phonebook
 public function actionLogout()
 {
     App::getComponent('user')->logout();
     $this->redirect('user', 'login');
 }
コード例 #5
0
ファイル: LoginForm.php プロジェクト: tonci/phonebook
 public function login()
 {
     if ($this->validate()) {
         return App::getComponent('user')->login($this->getUser());
     }
 }
コード例 #6
0
ファイル: DataGrid.php プロジェクト: tonci/phonebook
 public function getUrl($params = [], $escaped = true)
 {
     $search = [];
     if (!empty($_REQUEST[$this->search])) {
         $search[$this->search] = array_filter($_REQUEST[$this->search], function ($value) {
             return !empty($value);
         });
     }
     $query = array_merge($_GET, $search, $params);
     if (isset($query[$this->page]) && $query[$this->page] > $this->getAvailablePages()) {
         $query[$this->page] = $this->getAvailablePages();
     }
     if (isset($query[$this->page]) && $query[$this->page] < 1) {
         $query[$this->page] = 1;
     }
     $query = http_build_query($query);
     if ($escaped) {
         $query = htmlspecialchars($query);
     }
     return App::getComponent('request')->getBaseUrl() . '?' . $query;
 }