Esempio n. 1
0
 /**
  * Handle upload.
  */
 protected function handle_upload()
 {
     $upload = $this->request->file($this->form_name);
     if ($upload['name'] != 'none' && trim($upload['name'])) {
         // Try uploading the file.
         $this->upload_file();
         // Store for easier access
         $this->errors = array_merge($this->errors, $this->filedata['error']);
         // If we had no problems we can submit the data to the database.
         if (empty($this->filedata['error'])) {
             $order_id = $this->set_custom_order ? $this->operator->get_max_custom_index() + 1 : 0;
             $data = array('attachment_id' => 0, 'physical_filename' => $this->filedata['physical_filename'], 'attachment_directory' => $this->filedata['attachment_directory'], 'real_filename' => $this->filedata['real_filename'], 'extension' => $this->filedata['extension'], 'mimetype' => $this->filedata['mimetype'], 'filesize' => $this->filedata['filesize'], 'filetime' => $this->filedata['filetime'], 'hash' => $this->filedata['md5_checksum'], 'attachment_order' => $order_id, 'attachment_comment' => $this->request->variable('filecomment', '', true), 'object_type' => $this->object_type, 'object_id' => $this->object_id);
             $attachment = $this->operator->get_new_entity($data);
             // Create thumbnail
             $has_thumbnail = $is_preview = false;
             if ($this->filedata['is_image']) {
                 $has_thumbnail = $attachment->create_thumbnail($this->max_thumbnail_width, $this->max_thumbnail_width === false ? false : 0);
                 // set first screenshot as preview image when it is uploaded
                 $is_preview = !$this->operator->get_count();
             }
             $attachment->__set_array(array('thumbnail' => $has_thumbnail, 'is_preview' => $is_preview));
             $attachment->submit();
             // Store in operator
             $this->operator->set($attachment);
             $this->uploaded = $attachment->get_id();
         }
     }
     // We do not want to upload it again if this function is called again.
     $this->request->overwrite($this->form_name, null, request_interface::FILES);
 }
Esempio n. 2
0
 public function display($tpl_block = 'revisions', $show_queue = false, $all_versions = false)
 {
     $ordered_phpbb_versions = versions::order_phpbb_version_list_from_db($this->cache, $this->phpbb_versions, $all_versions);
     // Get rid of the day of the week if it exists in the dateformat
     $old_date_format = phpbb::$user->date_format;
     phpbb::$user->date_format = str_replace('D ', '', phpbb::$user->date_format);
     $install_time = false;
     if ($this->install_time > 0) {
         if ($this->install_time < 60) {
             $install_time = phpbb::$user->lang['INSTALL_LESS_THAN_1_MINUTE'];
         } else {
             $install_time = phpbb::$user->lang('INSTALL_MINUTES', (int) ($this->install_time / 60));
         }
     }
     // ColorizeIt stuff
     $url_colorizeit = '';
     if ($this->revision_status == TITANIA_REVISION_APPROVED && strlen(titania::$config->colorizeit) && $this->contrib && $this->contrib->has_colorizeit()) {
         $url_colorizeit = 'http://' . titania::$config->colorizeit_url . '/custom/' . titania::$config->colorizeit . '.html?id=' . $this->attachment_id . '&amp;sample=' . $this->contrib->clr_sample->get_id();
     }
     phpbb::$template->assign_block_vars($tpl_block, array('REVISION_ID' => $this->revision_id, 'CREATED' => phpbb::$user->format_date($this->revision_time), 'NAME' => $this->revision_name ? censor_text($this->revision_name) : ($this->contrib ? $this->contrib->contrib_name . ' ' . $this->revision_version : ''), 'VERSION' => $this->revision_version, 'VALIDATED_DATE' => $this->validation_date ? phpbb::$user->format_date($this->validation_date) : phpbb::$user->lang['NOT_VALIDATED'], 'REVISION_QUEUE' => $show_queue && $this->revision_queue_id ? $this->controller_helper->route('phpbb.titania.queue.item', array('id' => $this->revision_queue_id)) : '', 'PHPBB_VERSION' => sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : '', 'REVISION_LICENSE' => $this->revision_license ? censor_text($this->revision_license) : ($this->contrib && sizeof($this->contrib->type->license_options) ? phpbb::$user->lang['UNKNOWN'] : ''), 'INSTALL_TIME' => $install_time, 'BBC_HTML_REPLACEMENT' => $this->revision_bbc_html_replace, 'BBC_BBCODE_USAGE' => $this->revision_bbc_bbcode_usage, 'BBC_HELPLINE' => $this->revision_bbc_help_line, 'BBC_DEMO' => $this->revision_bbc_demo, 'INSTALL_LEVEL' => $this->install_level > 0 ? phpbb::$user->lang['INSTALL_LEVEL_' . $this->install_level] : '', 'DOWNLOADS' => isset($this->download_count) ? $this->download_count : 0, 'U_DOWNLOAD' => $this->get_url(), 'U_COLORIZEIT' => $url_colorizeit, 'U_EDIT' => $this->contrib && ($this->contrib->is_author || $this->contrib->is_active_coauthor || $this->contrib->type->acl_get('moderate')) ? $this->contrib->get_url('revision', array('page' => 'edit', 'id' => $this->revision_id)) : '', 'S_USE_QUEUE' => titania::$config->use_queue && $this->contrib->type->use_queue ? true : false, 'S_NEW' => $this->revision_status == TITANIA_REVISION_NEW ? true : false, 'S_APPROVED' => $this->revision_status == TITANIA_REVISION_APPROVED ? true : false, 'S_DENIED' => $this->revision_status == TITANIA_REVISION_DENIED ? true : false, 'S_PULLED_SECURITY' => $this->revision_status == TITANIA_REVISION_PULLED_SECURITY ? true : false, 'S_PULLED_OTHER' => $this->revision_status == TITANIA_REVISION_PULLED_OTHER ? true : false, 'S_REPACKED' => $this->revision_status == TITANIA_REVISION_REPACKED ? true : false, 'S_RESUBMITTED' => $this->revision_status == TITANIA_REVISION_RESUBMITTED ? true : false));
     phpbb::$user->date_format = $old_date_format;
     // Output phpBB versions
     foreach ($ordered_phpbb_versions as $version) {
         phpbb::$template->assign_block_vars($tpl_block . '.phpbb_versions', array('VERSION' => $version));
     }
     // Output translations
     if ($this->translations->get_count()) {
         $message = false;
         $this->translations->parse_attachments($message, false, false, $tpl_block . '.translations', '');
     }
     // Hooks
     titania::$hook->call_hook(array(__CLASS__, __FUNCTION__), $this, $tpl_block);
 }
Esempio n. 3
0
 /**
  * Passes details to the template
  *
  * @param bool $simple True to output a simpler version (on the non-main pages)
  */
 public function assign_details($simple = false, $return = false)
 {
     $vars = array('CONTRIB_NAME' => $this->contrib_name, 'CONTRIB_DESC' => $this->generate_text_for_display(), 'CONTRIB_VIEWS' => $this->contrib_views, 'CONTRIB_UPDATE_DATE' => $this->contrib_last_update ? phpbb::$user->format_date($this->contrib_last_update) : '', 'CONTRIB_STATUS' => $this->contrib_status, 'CONTRIB_LIMITED_SUPPORT' => $this->contrib_limited_support, 'CONTRIB_LOCAL_NAME' => $this->contrib_local_name, 'CONTRIB_ISO_CODE' => $this->contrib_iso_code, 'CONTRIB_RATING' => $this->contrib_rating, 'CONTRIB_RATING_COUNT' => $this->contrib_rating_count, 'CONTRIB_RATING_STRING' => $this->rating ? $this->rating->get_rating_string($this->get_url('rate')) : '', 'L_ANNOUNCEMENT_TOPIC' => titania::$config->support_in_titania ? phpbb::$user->lang['ANNOUNCEMENT_TOPIC'] : phpbb::$user->lang['ANNOUNCEMENT_TOPIC_SUPPORT'], 'U_VIEW_DEMO' => $this->contrib_demo, 'S_INTEGRATE_DEMO' => $this->options['demo']);
     // Ignore some stuff before it is submitted else we can cause an error
     if ($this->contrib_id) {
         foreach ($this->type->get_allowed_branches(true, false) as $branch => $name) {
             $release_topic_id = $this->get_release_topic_id($branch);
             if ($release_topic_id) {
                 phpbb::$template->assign_block_vars('announce_topic', array('URL' => phpbb::append_sid('viewtopic', 't=' . $release_topic_id), 'BRANCH' => $name));
             }
         }
         if (!empty($this->download)) {
             $this->assign_download_details();
             $vars = array_merge($vars, array('CONTRIB_DOWNLOADS' => $this->contrib_downloads));
         }
         if ($this->contrib_type == TITANIA_TYPE_BBCODE && !empty($this->download)) {
             $download = reset($this->download);
             $demo_output = $download['revision_bbc_demo'];
             $demo_rendered = false;
             if ($download['revision_status'] == TITANIA_REVISION_APPROVED && !empty($demo_output)) {
                 $demo = $this->type->get_demo()->configure($this->contrib_id, $download['revision_bbc_bbcode_usage'], $download['revision_bbc_html_replace']);
                 $demo_output = $demo->get_demo($demo_output);
                 unset($demo);
                 $demo_rendered = true;
             }
             $vars = array_merge($vars, array('CONTRIB_BBC_HTML_REPLACEMENT' => isset($download['revision_bbc_html_replace']) ? $download['revision_bbc_html_replace'] : '', 'CONTRIB_BBC_BBCODE_USAGE' => isset($download['revision_bbc_bbcode_usage']) ? $download['revision_bbc_bbcode_usage'] : '', 'CONTRIB_BBC_HELPLINE' => isset($download['revision_bbc_help_line']) ? $download['revision_bbc_help_line'] : '', 'CONTRIB_BBC_DEMO' => $demo_output, 'S_CONTRIB_BBC_DEMO_RENDERED' => $demo_rendered));
         }
         $use_queue = titania::$config->use_queue && $this->type->use_queue;
         $u_view_reports = $u_manage = $u_new_revision = $u_queue_discussion = false;
         if ($this->type->acl_get('moderate')) {
             $u_view_reports = $this->controller_helper->route('phpbb.titania.manage.attention.redirect', array('type' => TITANIA_CONTRIB, 'id' => $this->contrib_id));
         }
         if ($this->is_manageable()) {
             $u_manage = $this->get_url('manage');
             if (phpbb::$auth->acl_get('u_titania_contrib_submit')) {
                 $u_new_revision = $this->get_url('revision');
             }
         }
         if ($use_queue && $this->is_manageable('queue_discussion')) {
             $u_queue_discussion = $this->get_url('queue_discussion');
         }
         $vars = array_merge($vars, array('CONTRIB_TYPE' => $this->type->lang, 'CONTRIB_TYPE_ID' => $this->contrib_type, 'CONTRIB_TYPE_CLEAN' => $this->type->url, 'U_CONTRIB_MANAGE' => $u_manage, 'U_NEW_REVISION' => $u_new_revision, 'U_QUEUE_DISCUSSION' => $u_queue_discussion, 'U_VIEW_CONTRIB' => $this->get_url(), 'U_REPORT' => phpbb::$user->data['is_registered'] ? $this->get_url('report') : '', 'U_VIEW_REPORTS' => $u_view_reports, 'S_CONTRIB_NEW' => $this->contrib_status == TITANIA_CONTRIB_NEW ? true : false, 'S_CONTRIB_VALIDATED' => $this->contrib_status == TITANIA_CONTRIB_APPROVED ? true : false, 'S_CONTRIB_CLEANED' => $this->contrib_status == TITANIA_CONTRIB_CLEANED ? true : false, 'S_CONTRIB_DOWNLOAD_DISABLED' => $this->contrib_status == TITANIA_CONTRIB_DOWNLOAD_DISABLED ? true : false, 'S_CONTRIB_HIDDEN' => $this->contrib_status == TITANIA_CONTRIB_HIDDEN ? true : false, 'S_CONTRIB_DISABLED' => $this->contrib_status == TITANIA_CONTRIB_DISABLED ? true : false, 'JS_CONTRIB_TRANSLATION' => !empty($this->contrib_iso_code) ? 'true' : 'false'));
     }
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $vars, $this);
     // Display real author
     if ($return) {
         $vars['AUTHOR_NAME_FULL'] = $this->author->get_username_string();
     } else {
         $this->author->assign_details();
     }
     if (!$simple && !$return) {
         $active_coauthors = $past_coauthors = array();
         $author_sort = function ($a, $b) {
             return strcmp($a['AUTHOR_NAME'], $b['AUTHOR_NAME']);
         };
         // Display Co-authors
         foreach ($this->coauthors as $user_id => $row) {
             if ($row['active']) {
                 $active_coauthors[] = $this->author->assign_details(true, $row);
             } else {
                 $past_coauthors[] = $this->author->assign_details(true, $row);
             }
         }
         usort($active_coauthors, $author_sort);
         usort($past_coauthors, $author_sort);
         phpbb::$template->assign_block_vars_array('coauthors', $active_coauthors);
         phpbb::$template->assign_block_vars_array('past_coauthors', $past_coauthors);
         // Display Revisions and phpBB versions
         if (sizeof($this->revisions)) {
             $revision = new titania_revision($this);
             $revision->contrib = $this;
             $phpbb_versions = array();
             foreach ($this->revisions as $revision_id => $row) {
                 $revision->__set_array($row);
                 $revision->phpbb_versions = isset($row['phpbb_versions']) ? $row['phpbb_versions'] : array();
                 $revision->translations = isset($row['translations']) ? $revision->set_translations($row['translations']) : array();
                 $revision->display('revisions', $this->type->acl_get('view'), $this->options['all_versions']);
                 $phpbb_versions = array_merge($phpbb_versions, $revision->phpbb_versions);
             }
             unset($revision);
             $ordered_phpbb_versions = versions::order_phpbb_version_list_from_db($this->cache, $phpbb_versions, $this->options['all_versions']);
             if (sizeof($ordered_phpbb_versions) == 1) {
                 phpbb::$template->assign_vars(array('PHPBB_VERSION' => $ordered_phpbb_versions[0]));
             } else {
                 foreach ($ordered_phpbb_versions as $version_row) {
                     phpbb::$template->assign_block_vars('phpbb_versions', array('NAME' => $version_row));
                 }
             }
         }
         // Display Screenshots
         if ($this->screenshots->get_count()) {
             $message = false;
             $this->screenshots->parse_attachments($message, false, false, 'screenshots', true);
         }
         // Display categories
         $category = new titania_category();
         foreach ($this->category_data as $category_row) {
             $category->__set_array($category_row);
             phpbb::$template->assign_block_vars('categories', $category->assign_display(true));
         }
     }
     if ($return) {
         return $vars;
     }
     phpbb::$template->assign_vars($vars);
 }