/** * Edit revision action. * * @param string $contrib_type Contrib type URL identifier * @param string $contrib Contrib name clean * @param int $id Revision id * * @return \Symfony\Component\HttpFoundation\Response|JsonResponse */ public function edit($contrib_type, $contrib, $id) { $this->setup($contrib_type, $contrib); if (!$this->check_auth()) { return $this->helper->needs_auth(); } $this->load_revision($id); $this->vendor_versions = $this->cache->get_phpbb_versions(); $this->handle_revision_delete(); // Translations $this->translations->configure(TITANIA_TRANSLATION, $this->id, true); if ($this->contrib->type->extra_upload) { $this->translations->get_operator()->load(); $this->translations->handle_form_action(); $this->handle_translation_delete(); if ($this->translations->plupload_active()) { return new JsonResponse($this->translations->get_plupload_response_data()); } } $settings = $this->get_settings(); $error = array(); // Submit the revision if ($this->request->is_set_post('submit')) { $error = array_merge($this->validate_settings($settings), $this->translations->get_errors()); // If no errors, submit if (empty($error)) { $this->submit_settings($settings); redirect($this->contrib->get_url()); } } $this->assign_vars($settings, $error); add_form_key('postform'); return $this->helper->render('contributions/contribution_revision_edit.html', $this->contrib->contrib_name . ' - ' . $this->user->lang['EDIT_REVISION']); }
/** * Common handler for initial setup tasks * * @param string $contrib_type Contrib type URL identifier. * @param string $contrib Contrib name clean. * @return null */ protected function setup($contrib_type, $contrib) { $this->load_contrib($contrib_type, $contrib); $this->revision = new \titania_revision($this->contrib); $this->uploader->configure(TITANIA_CONTRIB, $this->contrib->contrib_id, true); $this->package = new \phpbb\titania\entity\package(); $this->revisions_in_queue = $this->repackable_branches = array(); $this->is_moderator = $this->contrib->type->acl_get('moderate'); $this->use_queue = $this->ext_config->use_queue && $this->contrib->type->use_queue; $this->require_upload = $this->contrib->type->require_upload; }
/** * Load ColorizeIt handler. * * @return null */ protected function load_colorizeit() { $this->colorizeit_sample->configure(TITANIA_CLR_SCREENSHOT, $this->contrib->contrib_id)->get_operator()->load(); $this->colorizeit_sample->handle_form_action(); if ($this->colorizeit_sample->uploaded) { $uploaded = $this->colorizeit_sample->get_operator()->get_all_ids(); // If multiple files are uploaded, then one is being replaced. if (sizeof($uploaded) > 1) { $this->colorizeit_sample->get_operator()->delete(array_diff($uploaded, array($this->colorizeit_sample->uploaded))); } } }
/** * Setup the attachments * Unfortunately there is not much of a good way of doing this besides * requiring extra calls to the message class (which I do not want to do) */ protected function setup_attachments() { // We set it up already... if ($this->uploader->get_object_type() !== null) { return; } $for_edit = $this->post_object->generate_text_for_edit(); if ($this->auth['attachments'] && isset($for_edit['object_type'])) { $this->posting_panels['attach-panel'] = 'ATTACHMENTS'; $this->uploader->configure($for_edit['object_type'], $for_edit['object_id'], true)->get_operator()->load(); $this->uploader->handle_form_action(); $this->error = array_merge($this->error, $this->uploader->get_errors()); $this->uploader->clear_errors(); // Empty the error array to prevent showing duplicates } }