GitHub PullRequestReviewCommentEvent at 2014-04-18 08:28:45
Repository: forkcms
Actor: turanct
Payload: {"comment":{"url":"https://api.github.com/repos/sumocoders/forkcms/pulls/comments/11766766","id":11766766,"diff_hunk":"@@ -0,0 +1,131 @@\n+<?php\n+\n+/*\n+ * This file is part of Fork CMS.\n+ *\n+ * For the full copyright and license information, please view the license\n+ * file that was distributed with this source code.\n+ */\n+\n+/**\n+ * This action will load a form with the item data and save the changes.\n+ *\n+ * @author Jelmer <jelmer@sumocoders.be>\n+ */\n+class BackendPartnersEditPartner extends BackendBaseActionEdit\n+{\n+    /**\n+     * @var int widgetId the id of the widge\n+     */\n+    private $widgetId;\n+\n+    /**\n+     * Execute the action\n+     */\n+    public function execute()\n+    {\n+        $this->id = $this->getParameter('id', 'int');\n+\n+        // does the item exists\n+        if ($this->id !== null && BackendPartnersModel::partnerExists($this->id)) {\n+            parent::execute();\n+            $this->getData();\n+\n+            $this->loadForm();\n+            $this->validateForm();\n+\n+            $this->parse();\n+            $this->display();\n+        } else {\n+            $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');\n+        }\n+    }\n+\n+    /**\n+     * Get the data\n+     */\n+    private function getData()\n+    {\n+        $this->record = (array) BackendPartnersModel::getPartner($this->id);\n+\n+        // no item found, redirect to index\n+        if (empty($this->record)) {\n+            $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');\n+        }\n+    }\n+\n+    /**\n+     * Load the form\n+     */\n+    private function loadForm()\n+    {\n+        $this->frm = new BackendForm('edit');\n+        $this->frm->addText('name', $this->record['name'], 255, 'inputText name', 'inputTextError name')->setAttribute(\n+            'required'\n+        );\n+        $this->frm->addImage('img', 'inputImage img', 'inputImageError img')->setAttribute('required');\n+        $this->frm->addText('url', $this->record['url'], 255, 'inputText url', 'inputTextError url')->setAttributes(\n+            array('type' => 'url', 'required')\n+        );\n+    }\n+\n+    /**\n+     * Parse the form\n+     */\n+    protected function parse()\n+    {\n+        parent::parse();\n+\n+        // assign this variable so it can be used in the template\n+        $this->tpl->assign('item', $this->record);\n+    }\n+\n+    /**\n+     * Validate the form\n+     */\n+    private function validateForm()\n+    {\n+        if ($this->frm->isSubmitted()) {\n+            $this->frm->cleanupFields();\n+\n+            // validation\n+            $this->frm->getField('name')->isFilled(BL::err('NameIsRequired'));\n+            if ($this->frm->getField('img')->isFilled()) {\n+                // image has the jpg/png extension\n+                $this->frm->getField('img')->isAllowedExtension(\n+                    array('jpg', 'png', 'gif'),\n+                    BL::err('JPGGIFAndPNGOnly')\n+                );\n+            }\n+\n+            $this->frm->getField('url')->isFilled(BL::err('FieldIsRequired'));\n+            // no errors?\n+            if ($this->frm->isCorrect()) {\n+                $item['id'] = $this->record['id'];\n+                $item['name'] = $this->frm->getField('name')->getValue();\n+                $item['url'] = $this->frm->getField('url')->getValue();\n+                if ($this->frm->getField('img')->isFilled()) {\n+                    SpoonFile::delete(\n+                        FRONTEND_FILES_PATH . '/' . FrontendPartnersModel::IMAGE_PATH . $this->record['widget']  . '/source/' . $this->record['img']","path":"backend/modules/partners/actions/edit_partner.php","position":null,"original_position":109,"commit_id":"dd0893c1156eb83cb566133b355630e24317d37b","original_commit_id":"ef17a0f3a2b4bb81d9e0d94d2030f409dda22651","user":{"login":"turanct","id":1728360,"avatar_url":"https://avatars.githubusercontent.com/u/1728360?","gravatar_id":"e18c5cba78277eb42c8473e0861262ef","url":"https://api.github.com/users/turanct","html_url":"https://github.com/turanct","followers_url":"https://api.github.com/users/turanct/followers","following_url":"https://api.github.com/users/turanct/following{/other_user}","gists_url":"https://api.github.com/users/turanct/gists{/gist_id}","starred_url":"https://api.github.com/users/turanct/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turanct/subscriptions","organizations_url":"https://api.github.com/users/turanct/orgs","repos_url":"https://api.github.com/users/turanct/repos","events_url":"https://api.github.com/users/turanct/events{/privacy}","received_events_url":"https://api.github.com/users/turanct/received_events","type":"User","site_admin":false},"body":"See comment about frontend image url + more than 120 cols","created_at":"2014-04-18T08:28:45Z","updated_at":"2014-04-18T08:28:45Z","html_url":"https://github.com/sumocoders/forkcms/pull/12#discussion_r11766766","pull_request_url":"https://api.github.com/repos/sumocoders/forkcms/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/sumocoders/forkcms/pulls/comments/11766766"},"html":{"href":"https://github.com/sumocoders/forkcms/pull/12#discussion_r11766766"},"pull_request":{"href":"https://api.github.com/repos/sumocoders/forkcms/pulls/12"}}}}