Esempio n. 1
0
 /**
  * Passes details to the template
  *
  * @param bool $return True if you want the data prepared for output and returned as an array, false to output to the template
  */
 public function assign_details($return = false, $row = false, $revert = true)
 {
     // Set special data to display
     if ($row !== false) {
         if ($revert) {
             $backup = $this->object_data;
         }
         $this->__set_array($row);
     }
     $vars = array('AUTHOR_NAME_FULL' => $this->get_username_string(), 'AUTHOR_REALNAME' => $this->author_realname, 'AUTHOR_WEBSITE' => $this->get_website_url(), 'AUTHOR_WEBSITE_LINK' => '<a href="' . $this->get_website_url() . '">' . $this->get_website_url() . '</a>', 'AUTHOR_RATING' => $this->author_id ? $this->author_rating : '', 'AUTHOR_RATING_STRING' => $this->author_id && isset($this->rating) ? $this->rating->get_rating_string() : '', 'AUTHOR_RATING_COUNT' => $this->author_id ? $this->author_rating_count : '', 'AUTHOR_CONTRIBS' => $this->author_contribs, 'AUTHOR_DESC' => $this->generate_text_for_display(), 'U_AUTHOR_PROFILE' => $this->get_url(), 'U_AUTHOR_PROFILE_PHPBB' => $this->get_phpbb_profile_url(), 'U_AUTHOR_PROFILE_PHPBB_COM' => $this->get_phpbb_com_profile_url(), 'U_AUTHOR_CONTRIBUTIONS' => $this->get_url('contributions'));
     // Add to it the common user details
     if (isset(users_overlord::$users[$this->user_id])) {
         $vars = array_merge(users_overlord::assign_details($this->user_id), $vars);
     }
     // Output the count for different types
     $type_list = array();
     foreach (titania_types::$types as $type) {
         if (!isset($type->author_count)) {
             // Figure out the counts some other way
             $sql_ary = array('SELECT' => 'COUNT(*) AS contrib_cnt, cat.category_name, cat.category_name_clean', 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIB_COAUTHORS_TABLE => 'ca'), 'ON' => 'ca.contrib_id = c.contrib_id'), array('FROM' => array(TITANIA_CATEGORIES_TABLE => 'cat'), 'ON' => 'cat.category_type = c.contrib_type')), 'WHERE' => "c.contrib_visible = 1 AND c.contrib_type = {$type->id} AND (c.contrib_user_id = {$this->user_id}\n\t\t\t\t\t\t\t\t\tOR ca.user_id = {$this->user_id})");
             $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
             $result = phpbb::$db->sql_query($sql);
             $type_row = phpbb::$db->sql_fetchrow($result);
             phpbb::$db->sql_freeresult($result);
             $contrib_cnt = (int) $type_row['contrib_cnt'];
             $cat_name = $type_row['category_name'];
             $cat_name_clean = $type_row['category_name_clean'];
             if ($contrib_cnt > 0) {
                 if ($contrib_cnt == 1) {
                     $type_list[] = isset(phpbb::$user->langs['AUTHOR_' . strtoupper($cat_name_clean) . '_ONE']) ? phpbb::$user->lang['AUTHOR_' . strtoupper($cat_name_clean) . '_ONE'] : '1 ' . $cat_name;
                 } else {
                     $type_list[] = isset(phpbb::$user->lang['AUTHOR_' . strtoupper($cat_name_clean)]) ? sprintf(phpbb::$user->lang['AUTHOR_' . strtoupper($cat_name_clean)], $contrib_cnt) : $contrib_cnt . ' ' . $cat_name;
                 }
             }
             continue;
         }
         if ($this->{$type->author_count} > 0) {
             if ($this->{$type->author_count} == 1) {
                 $type_list[] = isset(phpbb::$user->lang[strtoupper($type->author_count) . '_ONE']) ? phpbb::$user->lang[strtoupper($type->author_count) . '_ONE'] : '{' . strtoupper($type->author_count) . '_ONE}';
             } else {
                 $type_list[] = isset(phpbb::$user->lang[strtoupper($type->author_count)]) ? sprintf(phpbb::$user->lang[strtoupper($type->author_count)], $this->{$type->author_count}) : '{' . strtoupper($type->author_count) . '}';
             }
         }
     }
     $vars['AUTHOR_CONTRIB_LIST'] = implode($type_list, ', ');
     /* @todo: automatically display the common author data too...
     		if (isset($this->sql_data))
     		{
     			$vars = array_merge($vars, assign_user_details($this->sql_data));
     		}*/
     // Revert data
     if ($revert && $row !== false) {
         $this->__set_array($backup);
         unset($backup);
     }
     if ($return) {
         return $vars;
     }
     phpbb::$template->assign_vars($vars);
 }
Esempio n. 2
0
 /**
  * Passes details to the template
  *
  * @param bool $return True if you want the data prepared for output and returned as an array, false to output to the template
  */
 public function assign_details($return = false, $row = false, $revert = true)
 {
     // Set special data to display
     if ($row !== false) {
         if ($revert) {
             $backup = $this->object_data;
         }
         $this->__set_array($row);
     }
     $vars = array('AUTHOR_NAME_FULL' => $this->get_username_string(), 'AUTHOR_REALNAME' => $this->author_realname, 'AUTHOR_WEBSITE' => $this->get_website_url(), 'AUTHOR_WEBSITE_LINK' => '<a href="' . $this->get_website_url() . '">' . $this->get_website_url() . '</a>', 'AUTHOR_RATING' => $this->author_id ? $this->author_rating : '', 'AUTHOR_RATING_STRING' => $this->author_id && isset($this->rating) ? $this->rating->get_rating_string() : '', 'AUTHOR_RATING_COUNT' => $this->author_id ? $this->author_rating_count : '', 'AUTHOR_CONTRIBS' => $this->author_contribs, 'AUTHOR_DESC' => $this->generate_text_for_display(), 'U_AUTHOR_PROFILE' => $this->get_url(), 'U_AUTHOR_PROFILE_PHPBB' => $this->get_phpbb_profile_url(), 'U_AUTHOR_PROFILE_PHPBB_COM' => $this->get_phpbb_com_profile_url(), 'U_AUTHOR_CONTRIBUTIONS' => $this->get_url('contributions'));
     // Add to it the common user details
     if (isset(users_overlord::$users[$this->user_id])) {
         $vars = array_merge(users_overlord::assign_details($this->user_id), $vars);
     }
     // Output the count for different types
     $type_list = array();
     foreach (titania_types::$types as $type) {
         if (!isset($type->author_count)) {
             continue;
         }
         if ($this->{$type->author_count} == 1) {
             $type_list[] = isset(phpbb::$user->lang[strtoupper($type->author_count) . '_ONE']) ? phpbb::$user->lang[strtoupper($type->author_count) . '_ONE'] : '{' . strtoupper($type->author_count) . '_ONE}';
         } else {
             $type_list[] = isset(phpbb::$user->lang[strtoupper($type->author_count)]) ? sprintf(phpbb::$user->lang[strtoupper($type->author_count)], $this->{$type->author_count}) : '{' . strtoupper($type->author_count) . '}';
         }
     }
     $vars['AUTHOR_CONTRIB_LIST'] = implode($type_list, ', ');
     /* @todo: automatically display the common author data too...
     		if (isset($this->sql_data))
     		{
     			$vars = array_merge($vars, assign_user_details($this->sql_data));
     		}*/
     // Revert data
     if ($revert && $row !== false) {
         $this->__set_array($backup);
         unset($backup);
     }
     if ($return) {
         return $vars;
     }
     phpbb::$template->assign_vars($vars);
 }