예제 #1
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_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() : '', 'CONTRIB_ANNOUNCEMENT_TOPIC' => $this->contrib_release_topic_id ? sprintf(phpbb::$user->lang['ANNOUNCEMENT_TOPIC_VIEW'], '<a href="' . phpbb::append_sid('viewtopic', 't=' . $this->contrib_release_topic_id) . '">', '</a>') : false, 'L_ANNOUNCEMENT_TOPIC' => titania::$config->support_in_titania ? phpbb::$user->lang['ANNOUNCEMENT_TOPIC'] : phpbb::$user->lang['ANNOUNCEMENT_TOPIC_SUPPORT'], 'CONTRIB_DOWNLOADS' => $this->contrib_downloads, 'DOWNLOAD_SIZE' => isset($this->download['filesize']) ? get_formatted_filesize($this->download['filesize']) : '', 'DOWNLOAD_CHECKSUM' => isset($this->download['hash']) ? $this->download['hash'] : '', 'DOWNLOAD_NAME' => isset($this->download['revision_name']) ? censor_text($this->download['revision_name']) : '', 'DOWNLOAD_VERSION' => isset($this->download['revision_version']) ? censor_text($this->download['revision_version']) : '', 'DOWNLOAD_LICENSE' => isset($this->download['revision_license']) ? censor_text($this->download['revision_license']) : '', 'U_VIEW_DEMO' => $this->contrib_demo);
     // Ignore some stuff before it is submitted else we can cause an error
     if ($this->contrib_id) {
         $vars = array_merge($vars, array('CONTRIB_TYPE' => titania_types::$types[$this->contrib_type]->lang, 'CONTRIB_TYPE_ID' => $this->contrib_type, 'U_CONTRIB_MANAGE' => ($this->is_author || $this->is_active_coauthor) && !in_array($this->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)) || titania_types::$types[$this->contrib_type]->acl_get('moderate') ? $this->get_url('manage') : '', 'U_DOWNLOAD' => isset($this->download['attachment_id']) ? titania_url::build_url('download', array('id' => $this->download['attachment_id'])) : '', 'U_NEW_REVISION' => ($this->is_author || $this->is_active_coauthor) && !in_array($this->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)) || titania_types::$types[$this->contrib_type]->acl_get('moderate') ? $this->get_url('revision') : '', 'U_QUEUE_DISCUSSION' => titania::$config->use_queue && titania_types::$types[$this->contrib_type]->use_queue && (($this->is_author || $this->is_active_coauthor) && !in_array($this->contrib_status, array(TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_DISABLED)) || titania_types::$types[$this->contrib_type]->acl_get('queue_discussion')) ? $this->get_url('queue_discussion') : '', 'U_VIEW_CONTRIB' => $this->get_url(), 'U_REPORT' => phpbb::$user->data['is_registered'] ? $this->get_url('report') : '', 'U_INFO' => titania_types::$types[$this->contrib_type]->acl_get('moderate') ? titania_url::build_url('manage/attention', array('type' => TITANIA_CONTRIB, 'id' => $this->contrib_id)) : '', 'S_CONTRIB_NEW' => titania_types::$types[$this->contrib_type]->use_queue && titania::$config->use_queue && $this->contrib_status == TITANIA_CONTRIB_NEW ? true : false, 'S_CONTRIB_VALIDATED' => !titania_types::$types[$this->contrib_type]->use_queue || !titania::$config->use_queue || $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 = array_merge($vars, $this->author->assign_details(true));
     } else {
         $this->author->assign_details();
     }
     if (!$simple) {
         if (!$return) {
             // Display Co-authors
             foreach ($this->coauthors as $user_id => $row) {
                 if ($row['author_visible']) {
                     phpbb::$template->assign_block_vars('coauthors', $this->author->assign_details(true, $row));
                 }
             }
             // Display Revisions and phpBB versions
             if (sizeof($this->revisions)) {
                 $revision = new titania_revision($this);
                 $revision->contrib = $this;
                 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']) ? $row['translations'] : array();
                     $revision->display('revisions', titania_types::$types[$this->contrib_type]->acl_get('view'));
                     $phpbb_versions[] = $revision->phpbb_versions[0];
                 }
                 unset($revision);
                 $ordered_phpbb_versions = order_phpbb_version_list_from_db($phpbb_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) {
                 $this->screenshots->parse_attachments($message = false, false, false, 'screenshots');
             }
         }
     }
     if ($return) {
         return $vars;
     }
     phpbb::$template->assign_vars($vars);
 }
예제 #2
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);
 }