{"action":"created","comment":{"url":"https://api.github.com/repos/codex-team/codex.edu/pulls/comments/48382276","id":48382276,"diff_hunk":"@@ -2,31 +2,186 @@\n \r\n class Controller_Pages extends Controller_Base_preDispatch\r\n {\r\n-    const TYPE_PAGE = 1;\r\n-    const TYPE_NEWS = 2;\r\n-    const TYPE_BLOG = 3;\r\n+    const TYPE_SITE_PAGE = 1;\r\n+    const TYPE_SITE_NEWS = 2;\r\n+    const TYPE_USER_PAGE = 3;\r\n \r\n-    public function action_page()\r\n+\r\n+    public function action_page_show()\r\n     {\r\n+\r\n         $id = $this->request->param('id');\r\n         $uri = $this->request->param('uri');\r\n \r\n-        $page = $this->methods->getPage( $id , $uri );\r\n+        $page = $this->methods->getPage($id, $uri);\r\n+\r\n+        if ($page['title']) {\r\n+\r\n+            if (!$uri)\r\n+            {\r\n+                $this->redirect('/page/' . $page['id'] . '/' . $page['uri']);\r\n+            }\r\n+\r\n+            $page['parent'] = 0;\r\n+            if ($page['id_parent']) {\r\n+                $page['parent'] = $this->methods->getPage($page['id_parent']);\r\n+            }\r\n+\r\n+            $page['childrens']  = $this->methods->getChildrenPagesByParent($page['id']);\r\n+\r\n+            $this->view['page'] = $page;\r\n+            $this->view['files'] = $this->methods->getPageFiles($page['id']);\r\n+            $this->template->content = View::factory('templates/page', $this->view);\r\n+\r\n+        }\r\n+    }\r\n+\r\n+    public function action_news_add()\r\n+    {\r\n+        if (!$this->user->isAdmin()) {\r\n+            $this->redirect('/');\r\n+        }\r\n+\r\n+        $page['type'] = Controller_Pages::TYPE_SITE_NEWS;\r\n+\r\n+        $page['parent'] = '0';\r\n \r\n-        if ( $page ) {\r\n+        if (Security::check(Arr::get($_POST, 'csrf'))) {\r\n+            self::save_form();\r\n+        }\r\n+\r\n+        $this->view['page']     = $page;\r\n+        $this->template->content = View::factory('templates/page_form', $this->view);\r\n \r\n-            $this->view['page']  = $page;\r\n-            $this->view['files'] = $this->methods->getPageFiles( $page['id'] );\r\n+    }\r\n \r\n-            $this->view['page']['childrens'] = $this->methods->getChildrenPagesByParent( $page['id'] );\r\n-            \r\n-            $this->template->content = View::factory('templates/page',  $this->view);\r\n-        \r\n-        } else{\r\n+    public function action_page_add()\r\n+    {\r\n+        if (!$this->user->isTeacher()) {\r\n             $this->redirect('/');\r\n         }\r\n \r\n+        $page['type'] = Controller_Pages::TYPE_USER_PAGE;\r\n \r\n+        $page['parent'] = '0';\r\n+\r\n+        if (Security::check(Arr::get($_POST, 'csrf'))) {\r\n+            self::save_form();\r\n+        }\r\n+\r\n+        $this->view['page']     = $page;\r\n+        $this->template->content = View::factory('templates/page_form', $this->view);\r\n     }\r\n \r\n+    public function action_subpage_add()\r\n+    {\r\n+        if (!$this->user->isTeacher()) {\r\n+            $this->redirect('/');\r\n+        }\r\n+\r\n+        $parent_id = $this->request->param('id');\r\n+        $page['id_parent'] = $parent_id;\r\n+        if ($page['id_parent']) {\r\n+            $page['parent'] = $this->methods->getPage($page['id_parent']);\r\n+\r\n+            switch ($page['parent']['type'])\r\n+            {\r\n+                case Controller_Pages::TYPE_USER_PAGE :\r\n+                            $page_type = Controller_Pages::TYPE_USER_PAGE; break;\r\n+                default :   $page_type = Controller_Pages::TYPE_SITE_PAGE;\r\n+            }\r\n+            $page['type'] = $page_type;\r\n+        }\r\n+\r\n+        if (Security::check(Arr::get($_POST, 'csrf'))) {\r\n+            self::save_form();\r\n+        }\r\n+\r\n+        $this->view['page']     = $page;\r\n+        $this->template->content = View::factory('templates/page_form', $this->view);\r\n+    }\r\n+\r\n+    public function action_page_edit()\r","path":"application/classes/Controller/Pages.php","position":116,"original_position":116,"commit_id":"1088814e1f09c1011a05493f5ac355796f9d67b9","original_commit_id":"1088814e1f09c1011a05493f5ac355796f9d67b9","user":{"login":"neSpecc","id":3684889,"avatar_url":"https://avatars.githubusercontent.com/u/3684889?v=3","gravatar_id":"","url":"https://api.github.com/users/neSpecc","html_url":"https://github.com/neSpecc","followers_url":"https://api.github.com/users/neSpecc/followers","following_url":"https://api.github.com/users/neSpecc/following{/other_user}","gists_url":"https://api.github.com/users/neSpecc/gists{/gist_id}","starred_url":"https://api.github.com/users/neSpecc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neSpecc/subscriptions","organizations_url":"https://api.github.com/users/neSpecc/orgs","repos_url":"https://api.github.com/users/neSpecc/repos","events_url":"https://api.github.com/users/neSpecc/events{/privacy}","received_events_url":"https://api.github.com/users/neSpecc/received_events","type":"User","site_admin":false},"body":"edit_page или просто edit","created_at":"2015-12-23T21:54:06Z","updated_at":"2015-12-23T21:54:06Z","html_url":"https://github.com/codex-team/codex.edu/pull/24#discussion_r48382276","pull_request_url":"https://api.github.com/repos/codex-team/codex.edu/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/codex-team/codex.edu/pulls/comments/48382276"},"html":{"href":"https://github.com/codex-team/codex.edu/pull/24#discussion_r48382276"},"pull_request":{"href":"https://api.github.com/repos/codex-team/codex.edu/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/codex-team/codex.edu/pulls/24","id":54370571,"html_url":"https://github.com/codex-team/codex.edu/pull/24","diff_url":"https://github.com/codex-team/codex.edu/pull/24.diff","patch_url":"https://github.com/codex-team/codex.edu/pull/24.patch","issue_url":"https://api.github.com/repos/codex-team/codex.edu/issues/24","number":24,"state":"open","locked":false,"title":"Form for pages","user":{"login":"illiiiillllilii","id":15259299,"avatar_url":"https://avatars.githubusercontent.com/u/15259299?v=3","gravatar_id":"","url":"https://api.github.com/users/illiiiillllilii","html_url":"https://github.com/illiiiillllilii","followers_url":"https://api.github.com/users/illiiiillllilii/followers","following_url":"https://api.github.com/users/illiiiillllilii/following{/other_user}","gists_url":"https://api.github.com/users/illiiiillllilii/gists{/gist_id}","starred_url":"https://api.github.com/users/illiiiillllilii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/illiiiillllilii/subscriptions","organizations_url":"https://api.github.com/users/illiiiillllilii/orgs","repos_url":"https://api.github.com/users/illiiiillllilii/repos","events_url":"https://api.github.com/users/illiiiillllilii/events{/privacy}","received_events_url":"https://api.github.com/users/illiiiillllilii/received_events","type":"User","site_admin":false},"body":"issue #22\r\n\r\nРевьюверы\r\n- [ ] @neSpecc \r\n- [ ] @eliseealex \r\n- [ ] @ivanszhuravlev ","created_at":"2015-12-22T13:41:45Z","updated_at":"2015-12-23T21:54:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"115e9af8fcb8dba371eb9256f894391308eeec36","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codex-team/codex.edu/pulls/24/commits","review_comments_url":"https://api.github.com/repos/codex-team/codex.edu/pulls/24/comments","review_comment_url":"https://api.github.com/repos/codex-team/codex.edu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codex-team/codex.edu/issues/24/comments","statuses_url":"https://api.github.com/repos/codex-team/codex.edu/statuses/1088814e1f09c1011a05493f5ac355796f9d67b9","head":{"label":"codex-team:form_for_pages","ref":"form_for_pages","sha":"1088814e1f09c1011a05493f5ac355796f9d67b9","user":{"login":"codex-team","id":16060815,"avatar_url":"https://avatars.githubusercontent.com/u/16060815?v=3","gravatar_id":"","url":"https://api.github.com/users/codex-team","html_url":"https://github.com/codex-team","followers_url":"https://api.github.com/users/codex-team/followers","following_url":"https://api.github.com/users/codex-team/following{/other_user}","gists_url":"https://api.github.com/users/codex-team/gists{/gist_id}","starred_url":"https://api.github.com/users/codex-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codex-team/subscriptions","organizations_url":"https://api.github.com/users/codex-team/orgs","repos_url":"https://api.github.com/users/codex-team/repos","events_url":"https://api.github.com/users/codex-team/events{/privacy}","received_events_url":"https://api.github.com/users/codex-team/received_events","type":"Organization","site_admin":false},"repo":{"id":46662693,"name":"codex.edu","full_name":"codex-team/codex.edu","owner":{"login":"codex-team","id":16060815,"avatar_url":"https://avatars.githubusercontent.com/u/16060815?v=3","gravatar_id":"","url":"https://api.github.com/users/codex-team","html_url":"https://github.com/codex-team","followers_url":"https://api.github.com/users/codex-team/followers","following_url":"https://api.github.com/users/codex-team/following{/other_user}","gists_url":"https://api.github.com/users/codex-team/gists{/gist_id}","starred_url":"https://api.github.com/users/codex-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codex-team/subscriptions","organizations_url":"https://api.github.com/users/codex-team/orgs","repos_url":"https://api.github.com/users/codex-team/repos","events_url":"https://api.github.com/users/codex-team/events{/privacy}","received_events_url":"https://api.github.com/users/codex-team/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codex-team/codex.edu","description":"Project «Codex Education»","fork":false,"url":"https://api.github.com/repos/codex-team/codex.edu","forks_url":"https://api.github.com/repos/codex-team/codex.edu/forks","keys_url":"https://api.github.com/repos/codex-team/codex.edu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codex-team/codex.edu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codex-team/codex.edu/teams","hooks_url":"https://api.github.com/repos/codex-team/codex.edu/hooks","issue_events_url":"https://api.github.com/repos/codex-team/codex.edu/issues/events{/number}","events_url":"https://api.github.com/repos/codex-team/codex.edu/events","assignees_url":"https://api.github.com/repos/codex-team/codex.edu/assignees{/user}","branches_url":"https://api.github.com/repos/codex-team/codex.edu/branches{/branch}","tags_url":"https://api.github.com/repos/codex-team/codex.edu/tags","blobs_url":"https://api.github.com/repos/codex-team/codex.edu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codex-team/codex.edu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codex-team/codex.edu/git/refs{/sha}","trees_url":"https://api.github.com/repos/codex-team/codex.edu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codex-team/codex.edu/statuses/{sha}","languages_url":"https://api.github.com/repos/codex-team/codex.edu/languages","stargazers_url":"https://api.github.com/repos/codex-team/codex.edu/stargazers","contributors_url":"https://api.github.com/repos/codex-team/codex.edu/contributors","subscribers_url":"https://api.github.com/repos/codex-team/codex.edu/subscribers","subscription_url":"https://api.github.com/repos/codex-team/codex.edu/subscription","commits_url":"https://api.github.com/repos/codex-team/codex.edu/commits{/sha}","git_commits_url":"https://api.github.com/repos/codex-team/codex.edu/git/commits{/sha}","comments_url":"https://api.github.com/repos/codex-team/codex.edu/comments{/number}","issue_comment_url":"https://api.github.com/repos/codex-team/codex.edu/issues/comments{/number}","contents_url":"https://api.github.com/repos/codex-team/codex.edu/contents/{+path}","compare_url":"https://api.github.com/repos/codex-team/codex.edu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codex-team/codex.edu/merges","archive_url":"https://api.github.com/repos/codex-team/codex.edu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codex-team/codex.edu/downloads","issues_url":"https://api.github.com/repos/codex-team/codex.edu/issues{/number}","pulls_url":"https://api.github.com/repos/codex-team/codex.edu/pulls{/number}","milestones_url":"https://api.github.com/repos/codex-team/codex.edu/milestones{/number}","notifications_url":"https://api.github.com/repos/codex-team/codex.edu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codex-team/codex.edu/labels{/name}","releases_url":"https://api.github.com/repos/codex-team/codex.edu/releases{/id}","created_at":"2015-11-22T13:51:50Z","updated_at":"2015-12-19T23:42:34Z","pushed_at":"2015-12-23T21:29:04Z","git_url":"git://github.com/codex-team/codex.edu.git","ssh_url":"git@github.com:codex-team/codex.edu.git","clone_url":"https://github.com/codex-team/codex.edu.git","svn_url":"https://github.com/codex-team/codex.edu","homepage":null,"size":5033,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":1,"default_branch":"master"}},"base":{"label":"codex-team:master","ref":"master","sha":"0a1ca7dbae2175d84b7eec001ab890443a9827ad","user":{"login":"codex-team","id":16060815,"avatar_url":"https://avatars.githubusercontent.com/u/16060815?v=3","gravatar_id":"","url":"https://api.github.com/users/codex-team","html_url":"https://github.com/codex-team","followers_url":"https://api.github.com/users/codex-team/followers","following_url":"https://api.github.com/users/codex-team/following{/other_user}","gists_url":"https://api.github.com/users/codex-team/gists{/gist_id}","starred_url":"https://api.github.com/users/codex-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codex-team/subscriptions","organizations_url":"https://api.github.com/users/codex-team/orgs","repos_url":"https://api.github.com/users/codex-team/repos","events_url":"https://api.github.com/users/codex-team/events{/privacy}","received_events_url":"https://api.github.com/users/codex-team/received_events","type":"Organization","site_admin":false},"repo":{"id":46662693,"name":"codex.edu","full_name":"codex-team/codex.edu","owner":{"login":"codex-team","id":16060815,"avatar_url":"https://avatars.githubusercontent.com/u/16060815?v=3","gravatar_id":"","url":"https://api.github.com/users/codex-team","html_url":"https://github.com/codex-team","followers_url":"https://api.github.com/users/codex-team/followers","following_url":"https://api.github.com/users/codex-team/following{/other_user}","gists_url":"https://api.github.com/users/codex-team/gists{/gist_id}","starred_url":"https://api.github.com/users/codex-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codex-team/subscriptions","organizations_url":"https://api.github.com/users/codex-team/orgs","repos_url":"https://api.github.com/users/codex-team/repos","events_url":"https://api.github.com/users/codex-team/events{/privacy}","received_events_url":"https://api.github.com/users/codex-team/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codex-team/codex.edu","description":"Project «Codex Education»","fork":false,"url":"https://api.github.com/repos/codex-team/codex.edu","forks_url":"https://api.github.com/repos/codex-team/codex.edu/forks","keys_url":"https://api.github.com/repos/codex-team/codex.edu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codex-team/codex.edu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codex-team/codex.edu/teams","hooks_url":"https://api.github.com/repos/codex-team/codex.edu/hooks","issue_events_url":"https://api.github.com/repos/codex-team/codex.edu/issues/events{/number}","events_url":"https://api.github.com/repos/codex-team/codex.edu/events","assignees_url":"https://api.github.com/repos/codex-team/codex.edu/assignees{/user}","branches_url":"https://api.github.com/repos/codex-team/codex.edu/branches{/branch}","tags_url":"https://api.github.com/repos/codex-team/codex.edu/tags","blobs_url":"https://api.github.com/repos/codex-team/codex.edu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codex-team/codex.edu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codex-team/codex.edu/git/refs{/sha}","trees_url":"https://api.github.com/repos/codex-team/codex.edu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codex-team/codex.edu/statuses/{sha}","languages_url":"https://api.github.com/repos/codex-team/codex.edu/languages","stargazers_url":"https://api.github.com/repos/codex-team/codex.edu/stargazers","contributors_url":"https://api.github.com/repos/codex-team/codex.edu/contributors","subscribers_url":"https://api.github.com/repos/codex-team/codex.edu/subscribers","subscription_url":"https://api.github.com/repos/codex-team/codex.edu/subscription","commits_url":"https://api.github.com/repos/codex-team/codex.edu/commits{/sha}","git_commits_url":"https://api.github.com/repos/codex-team/codex.edu/git/commits{/sha}","comments_url":"https://api.github.com/repos/codex-team/codex.edu/comments{/number}","issue_comment_url":"https://api.github.com/repos/codex-team/codex.edu/issues/comments{/number}","contents_url":"https://api.github.com/repos/codex-team/codex.edu/contents/{+path}","compare_url":"https://api.github.com/repos/codex-team/codex.edu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codex-team/codex.edu/merges","archive_url":"https://api.github.com/repos/codex-team/codex.edu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codex-team/codex.edu/downloads","issues_url":"https://api.github.com/repos/codex-team/codex.edu/issues{/number}","pulls_url":"https://api.github.com/repos/codex-team/codex.edu/pulls{/number}","milestones_url":"https://api.github.com/repos/codex-team/codex.edu/milestones{/number}","notifications_url":"https://api.github.com/repos/codex-team/codex.edu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codex-team/codex.edu/labels{/name}","releases_url":"https://api.github.com/repos/codex-team/codex.edu/releases{/id}","created_at":"2015-11-22T13:51:50Z","updated_at":"2015-12-19T23:42:34Z","pushed_at":"2015-12-23T21:29:04Z","git_url":"git://github.com/codex-team/codex.edu.git","ssh_url":"git@github.com:codex-team/codex.edu.git","clone_url":"https://github.com/codex-team/codex.edu.git","svn_url":"https://github.com/codex-team/codex.edu","homepage":null,"size":5033,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codex-team/codex.edu/pulls/24"},"html":{"href":"https://github.com/codex-team/codex.edu/pull/24"},"issue":{"href":"https://api.github.com/repos/codex-team/codex.edu/issues/24"},"comments":{"href":"https://api.github.com/repos/codex-team/codex.edu/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/codex-team/codex.edu/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/codex-team/codex.edu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codex-team/codex.edu/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/codex-team/codex.edu/statuses/1088814e1f09c1011a05493f5ac355796f9d67b9"}}}}