function do_trackbacks() { global $db, $globals; echo '<div id="trackback">'; echo '<h2><a href="' . get_trackback($globals['link_id']) . '" title="' . _('URI para trackbacks') . '">trackbacks</a></h2>'; $id = $globals['link_id']; $trackbacks = $db->get_col("SELECT trackback_id FROM trackbacks WHERE trackback_link_id={$id} AND trackback_type='in' ORDER BY trackback_date DESC"); echo '<ul>'; if ($trackbacks) { require_once mnminclude . 'trackback.php'; $trackback = new Trackback(); foreach ($trackbacks as $trackback_id) { $trackback->id = $trackback_id; $trackback->read(); echo '<li><a href="' . $trackback->url . '" title="' . $trackback->content . '">' . $trackback->title . '</a></li>'; } } else { echo '<li>' . _('(sin trackbacks)') . '</li>'; } echo '<li><img src="img/favicons/technorati.png" alt="' . _('enlaces technorati') . '" width="16" height="16"/> <a href="http://technorati.com/search/' . urlencode(get_permalink($globals['link_id'])) . '">' . _('según Technorati') . '</a></li>'; echo "</ul>\n"; echo '</div><!--html1:do_trackbacks-->'; }
function fill_smarty($smarty, $type = 'full') { static $link_index = 0; global $current_user, $globals, $the_template, $db, $ranklist; if (!$ranklist) { $users = $db->get_results("SELECT user_karma, COUNT(*) FROM " . table_users . " WHERE user_level NOT IN ('Spammer') AND user_karma>0 GROUP BY user_karma ORDER BY user_karma DESC", ARRAY_N); $ranklist = array(); $rank = 1; if ($users) { foreach ($users as $dbuser) { $ranklist[$dbuser[0]] = $rank; $rank += $dbuser[1]; } } } // DB 08/04/08 if (!is_numeric($this->id)) { return false; } ///// $smarty->assign('link_id', $this->id); if (!$this->read) { return $smarty; } $url = str_replace('&', '&', htmlspecialchars($this->url)); $url_short = txt_shorter($url); if ($this->url == "http://" || $this->url == '') { $url_short = "http://"; } else { $parsed = parse_url($this->url); if (isset($parsed['scheme'])) { $url_short = $parsed['scheme'] . "://" . $parsed['host']; } } echo $parsed['scheme']; $title_short = htmlspecialchars(utf8_wordwrap($this->title, 30, " ", 1)); $smarty->assign('viewtype', $type); $smarty->assign('URL_tagcloud', getmyurl("tagcloud")); $smarty->assign('URL_global_statistics', getmyurl("global_statistics")); $smarty->assign('No_URL_Name', No_URL_Name); if (track_outgoing == true && $url_short != "http://") { if (track_outgoing_method == "id") { $smarty->assign('url', getmyurl("out", $this->id)); } if (track_outgoing_method == "title") { $smarty->assign('url', getmyurl("outtitle", urlencode($this->title_url))); } if (track_outgoing_method == "url") { $smarty->assign('url', getmyurl("outurl", $url)); } } else { $smarty->assign('url', $url); } // DB 11/12/08 if ($url_short == "http://" || $url_short == "://") { $smarty->assign('enc_url', urlencode(my_base_url . $this->get_internal_url())); } else { $smarty->assign('enc_url', urlencode($url)); } ///// $smarty->assign('url_short', $url_short); $smarty->assign('title_short', $title_short); //$smarty->assign('title_url', urlencode($this->title_url)); $smarty->assign('enc_title_short', urlencode($title_short)); $smarty->assign('story_url', $this->get_internal_url()); $smarty->assign('story_edit_url', getmyurl("editlink", $this->id)); $smarty->assign('story_admin_url', getmyurl("admin_modify", $this->id)); $smarty->assign('story_comment_count', $this->comments()); $smarty->assign('story_status', $this->status); //$smarty->assign('story_karma', $this->karma); if ($type == "summary") { if ($this->link_summary == "") { $smarty->assign('story_content', $this->truncate_content()); } else { $smarty->assign('story_content', $this->link_summary); } } /* $sql = "SELECT link_id FROM " . table_links . " WHERE link_category='$id'"; $links = $db->get_results($sql); foreach($links as $link) { $db->query('UPDATE '.table_comments." SET comment_status='discard' WHERE comment_link_id={$link->link_id}"); $vars = array('link_id' => $link->link_id); check_actions('story_discard', $vars); $db->query('UPDATE '.table_links." SET link_status='discard' WHERE link_id={$link->link_id}"); } */ if ($type == "full") { $smarty->assign('story_content', $this->content); $smarty->assign('story_id', $this->id); } if ($this->get_author_info == true) { $smarty->assign('link_submitter', $this->username()); $smarty->assign('submitter_profile_url', getmyurl('user', $this->username)); $smarty->assign('submitter_rank', $ranklist[$this->userkarma]); } $smarty->assign('link_submit_time', $this->date); $smarty->assign('link_submit_timeago', txt_time_diff($this->date)); $smarty->assign('link_submit_date', date('F, d Y g:i A', $this->date)); $smarty->assign('link_published_time', $this->published_date); $smarty->assign('link_published_timeago', txt_time_diff($this->published_date)); $smarty->assign('link_category', $this->category_name()); if (Multiple_Categories) { $cats = array(); foreach ($this->additional_cats as $cat) { $url = $this->category_safe_name($cat); if ($this->status == "published") { $url = getmyurl("maincategory", $url); } if ($this->status == "queued") { $url = getmyurl("queuedcategory", $url); } if ($this->status == "discard") { $url = getmyurl("discardedcategory", $url); } $cats[$url] = $this->category_name($cat); } $smarty->assign('link_additional_cats', $cats); } //assign category id to smarty, so we can use it in the templates. Needed for category colors! $smarty->assign('category_id', $this->category); global $URLMethod; $catvar = $this->category_safe_name(); $smarty->assign('Voting_Method', Voting_Method); $this->votecount = $this->countvotes(); if (Voting_Method == 2) { if (!$this->rating) { $this->rating = $this->rating($this->id) / 2; } $smarty->assign('link_rating', $this->rating); $smarty->assign('link_rating_width', $this->rating * 25); $current_user_id = $current_user->user_id; $jsLink = "vote({$current_user_id}, {$this->id}, {$link_index}, '" . md5($current_user_id . $this->randkey) . "', "; for ($stars = 1; $stars <= 5; $stars++) { $smarty->assign("link_shakebox_javascript_vote_{$stars}star", $jsLink . $stars * 2 . ')'); } $smarty->assign('vote_count', $this->votecount); if ($this->votes($current_user_id) > 0) { $smarty->assign('star_class', "-noh"); } else { $smarty->assign('star_class', ""); } } $smarty->assign('get_group_membered', $this->get_group_membered()); if ($this->status == "published") { $smarty->assign('category_url', getmyurl("maincategory", $catvar)); } if ($this->status == "queued") { $smarty->assign('category_url', getmyurl("queuedcategory", $catvar)); } if ($this->status == "discard") { $smarty->assign('category_url', getmyurl("discardedcategory", $catvar)); } $smarty->assign('trackback_url', get_trackback($this->id)); $smarty->assign('user_logged_in', $current_user->user_login); $smarty->assign('randmd5', md5($current_user->user_id . $this->randkey)); $smarty->assign('user_id', $this->author); $smarty->assign('current_user_id', $current_user_id); if (Enable_Extra_Fields) { $main_smarty = $smarty; include mnminclude . 'extra_fields_smarty.php'; $smarty = $main_smarty; $smarty->assign('link_field1', $this->link_field1); $smarty->assign('link_field2', $this->link_field2); $smarty->assign('link_field3', $this->link_field3); $smarty->assign('link_field4', $this->link_field4); $smarty->assign('link_field5', $this->link_field5); $smarty->assign('link_field6', $this->link_field6); $smarty->assign('link_field7', $this->link_field7); $smarty->assign('link_field8', $this->link_field8); $smarty->assign('link_field9', $this->link_field9); $smarty->assign('link_field10', $this->link_field10); $smarty->assign('link_field11', $this->link_field11); $smarty->assign('link_field12', $this->link_field12); $smarty->assign('link_field13', $this->link_field13); $smarty->assign('link_field14', $this->link_field14); $smarty->assign('link_field15', $this->link_field15); } $smarty->assign('link_group_id', $this->link_group_id); $smarty->assign('Enable_Recommend', Enable_Recommend); $smarty->assign('instpath', my_base_url . my_pligg_base . "/"); $smarty->assign('UseAvatars', do_we_use_avatars()); $smarty->assign('Avatar_ImgSrc', get_avatar('large', "", "", "", $this->userid)); $smarty->assign('Avatar_ImgSrcs', get_avatar('small', "", "", "", $this->userid)); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); $canIhaveAccess = $canIhaveAccess + checklevel('admin'); if ($canIhaveAccess == 1) { $smarty->assign('isadmin', 'yes'); } if ($this->check_friends == true) { // For Friends // include_once mnminclude . 'friend.php'; $friend = new Friend(); // make sure we're logged in and we didnt submit the link. if ($current_user->user_id > 0 && $current_user->user_login != $this->username()) { $friend_md5 = friend_MD5($current_user->user_login, $this->username()); $smarty->assign('FriendMD5', $friend_md5); $isfriend = $friend->get_friend_status($this->author); if (!$isfriend) { $friend_text = 'add to'; $friend_url = 'addfriend'; } else { $friend_text = 'remove from'; $friend_url = 'removefriend'; } $smarty->assign('Friend_Text', $friend_text); $smarty->assign('user_add_remove', getmyurl('user_add_remove', $this->username(), $friend_url)); } $smarty->assign('Allow_Friends', Allow_Friends); // --- // } if ($current_user->user_id != '') { $vars = array('author_id' => $this->author, 'link_id' => $this->id); check_actions('friends_activity_function', $vars); if ($vars['value'] == true) { $smarty->assign('friendvoted', 1); } } /* //for friends voting activity include_once(mnminclude.'friend.php'); $friend = new Friend; $sql = 'SELECT ' . table_votes . '.*, ' . table_users . '.user_id FROM ' . table_votes . ' INNER JOIN ' . table_users . ' ON ' . table_votes . '.vote_user_id = ' . table_users . '.user_id WHERE (((' . table_votes . '.vote_value)>0) AND ((' . table_votes . '.vote_link_id)='.$this->id.') AND (' . table_votes . '.vote_type= "links"));'; $voters = $db->get_results($sql); $voters = object_2_array($voters); foreach($voters as $key => $val) { $voteduserid = $val['user_id']; if($voteduserid == $friend->get_friend_status($this->author)) { $friendvoted = 1; } $smarty->assign('friendvoted', $friendvoted); }*/ if ($this->check_saved == true) { global $cached_saved_links; if (isset($cached_saved_links[$this->id])) { $smarty->assign('link_mine', $cached_saved_links[$this->id]); } else { $smarty->assign('link_mine', $db->get_row("SELECT * FROM " . table_saved_links . " WHERE saved_user_id={$current_user->user_id} AND saved_link_id={$this->id} LIMIT 1;")); } } $smarty->assign('user_url_saved', getmyurl('user2', $current_user->user_login, 'saved')); $smarty->assign('user_add_links_private', getmyurl('user_add_links_private', $this->id)); $smarty->assign('user_add_links_public', getmyurl('user_add_links_public', $this->id)); $smarty->assign('group_story_links_publish', getmyurl('group_story_links_publish', $this->id)); $smarty->assign('group_story_links_queued', getmyurl('group_story_links_queued', $this->id)); $smarty->assign('group_story_links_discard', getmyurl('group_story_links_discard', $this->id)); $smarty->assign('user_url_add_links', getmyurl('user_add_links', $this->id)); $smarty->assign('user_url_remove_links', getmyurl('user_remove_links', $this->id)); $smarty->assign('enable_tags', Enable_Tags); $smarty->assign('link_shakebox_index', $link_index); $smarty->assign('link_shakebox_votes', $this->votes); $smarty->assign('link_shakebox_showbury', $this->reports); $this->get_current_user_votes($current_user->user_id); $smarty->assign('link_shakebox_currentuser_votes', $this->current_user_votes); $smarty->assign('link_shakebox_currentuser_reports', $this->current_user_reports); if ($this->reports == -1) { // reporting was added to the svn and some people started using it // so in upgrade if someone already has the reports field, we set it to // -1. Then when we read() we check if -1. if it still is, update the count // from the votes table and store it into the link_reports field so we // don't have to look at the votes table again. $this->reports = $this->count_all_votes("<0"); $this->store_basic(); $smarty->assign('link_shakebox_reports', $this->reports); } $jslink = "vote({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',10)"; $jsreportlink = "vote({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',-10)"; $smarty->assign('link_shakebox_javascript_vote', $jslink); $jsunvote = "unvote({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',10)"; $smarty->assign('link_shakebox_javascript_unvote', $jsunvote); $smarty->assign('link_shakebox_javascript_report', $jsreportlink); if (!defined('alltagtext')) { // for pages like index, this ->display was being called for each story // which was sometimes 15+ times per page. this way it's just called once $smarty->display('blank.tpl'); //this is just to load the lang file so we can pull from it in php define('alltagtext', $smarty->get_config_vars('PLIGG_Visual_Tags_All_Tags')); } $alltagtext = alltagtext; if (Enable_Tags) { $smarty->assign('tags', $this->tags); if (!empty($this->tags)) { $tags_words = str_replace(", ", ",", $this->tags); $tags_count = substr_count($tags_words, ','); if ($tags_count > 1) { $tags_words = $tags_words; } $tag_array = explode(",", $tags_words); $c = count($tag_array); $tag_array[$c] = $this->tags; $c++; for ($i = 0; $i <= $c; $i++) { if (isset($tag_array[$i])) { if ($URLMethod == 1) { $tags_url_array[$i] = my_pligg_base . "/search.php?search=" . urlencode(trim($tag_array[$i])) . "&tag=true"; } elseif ($URLMethod == 2) { $tags_url_array[$i] = my_pligg_base . "/tag/" . urlencode(trim($tag_array[$i])); } } } $tag_array[$c - 1] = $alltagtext; $smarty->assign('tag_array', $tag_array); $smarty->assign('tags_url_array', $tags_url_array); $tags_url = urlencode($this->tags); $smarty->assign('tags_count', $tags_count); $smarty->assign('tags_words', $tags_words); $smarty->assign('tags_url', $tags_url); } } $smarty->assign('enable_group', enable_group); $smarty->assign('pagename', pagename); $smarty->assign('my_base_url', my_base_url); $smarty->assign('my_pligg_base', my_pligg_base); $smarty->assign('Default_Gravatar_Large', Default_Gravatar_Large); $link_index++; $vars['smarty'] = $smarty; check_actions('lib_link_summary_fill_smarty', $vars); return $smarty; }
function fill_smarty($smarty, $type = 'full') { static $link_index = 0; global $current_user, $globals, $the_template; $smarty->assign('link_id', $this->id); $smarty->display('blank.tpl'); //this is just to load the lang file so we can pull from it in php if (!$this->read) { return; } $url = str_replace('&', '&', htmlspecialchars($this->url)); $url_short = txt_shorter($url); if ($this->url == "http://") { $url_short = "http://"; } else { $parsed = parse_url($this->url); $url_short = $parsed['scheme'] . "://" . $parsed['host']; } $title_short = htmlspecialchars(utf8_wordwrap($this->title, 30, " ", 1)); $smarty->assign('viewtype', $type); $smarty->assign('URL_tagcloud', getmyurl("tagcloud")); $smarty->assign('No_URL_Name', No_URL_Name); if (track_outgoing == true) { if (track_outgoing_method == "id") { $smarty->assign('url', getmyurl("out", $this->id)); } if (track_outgoing_method == "title") { $smarty->assign('url', getmyurl("outtitle", $this->title_url)); } if (track_outgoing_method == "url") { $smarty->assign('url', getmyurl("outurl", $url)); } } else { $smarty->assign('url', $url); } $smarty->assign('enc_url', urlencode($url)); $smarty->assign('url_short', $url_short); $smarty->assign('title_short', $title_short); $smarty->assign('title_url', urlencode($this->title_url)); $smarty->assign('enc_title_short', urlencode($title_short)); if ($this->title_url == "") { $smarty->assign('story_url', getmyurl("story", $this->id)); // internal link to the comments page } else { $smarty->assign('story_url', getmyurl("storyURL", $this->category_safe_name(), urlencode($this->title_url), $this->id)); // internal link to the comments page } $smarty->assign('story_edit_url', getmyurl("editlink", $this->id)); $smarty->assign('story_admin_url', getmyurl("admin_modify", $this->id)); $smarty->assign('story_comment_count', $this->comments()); $smarty->assign('story_status', $this->status); if ($type == "summary") { if ($this->link_summary == "") { $smarty->assign('story_content', $this->truncate_content()); } else { $smarty->assign('story_content', $this->link_summary); } } if ($type == "full") { $smarty->assign('story_content', $this->content); } $smarty->assign('link_submitter', $this->username()); $smarty->assign('submitter_profile_url', getmyurl('user', $this->username())); $smarty->assign('link_submit_time', $this->date); $smarty->assign('link_submit_timeago', txt_time_diff($this->date)); $smarty->assign('link_published_time', $this->published_date); $smarty->assign('link_published_timeago', txt_time_diff($this->published_date)); $smarty->assign('link_category', $this->category_name()); //assign category id to smarty, so we can use it in the templates. Needed for category colors! $smarty->assign('category_id', $this->category); global $URLMethod; $catvar = $this->category_safe_name(); $smarty->assign('Voting_Method', Voting_Method); if (Voting_Method == 2) { $this->rating = $this->rating($this->id) / 2; $smarty->assign('link_rating', $this->rating); $smarty->assign('link_rating_width', $this->rating * 25); $js5link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 10)"; $smarty->assign('link_shakebox_javascript_vote_5star', $js5link); $js4link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 8)"; $smarty->assign('link_shakebox_javascript_vote_4star', $js4link); $js3link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 6)"; $smarty->assign('link_shakebox_javascript_vote_3star', $js3link); $js2link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 4)"; $smarty->assign('link_shakebox_javascript_vote_2star', $js2link); $js1link = "menealo({$current_user->user_id}, {$this->id}, {$link_index}, " . "'" . md5($current_user->user_id . $this->randkey) . "', 2)"; $smarty->assign('link_shakebox_javascript_vote_1star', $js1link); $this->votecount = $this->countvotes(); $smarty->assign('vote_count', $this->votecount); if ($this->votes($current_user->user_id) > 0) { $smarty->assign('star_class', "-noh"); } else { $smarty->assign('star_class', ""); } } if ($this->status == "published") { $smarty->assign('category_url', getmyurl("maincategory", $catvar)); } if ($this->status == "queued") { $smarty->assign('category_url', getmyurl("queuedcategory", $catvar)); } if ($this->status == "discard") { $smarty->assign('category_url', getmyurl("discardedcategory", $catvar)); } $smarty->assign('trackback_url', get_trackback($this->id)); $smarty->assign('user_logged_in', $current_user->user_login); $smarty->assign('randmd5', md5($current_user->user_id . $this->randkey)); $smarty->assign('user_id', $this->author); $smarty->assign('current_user_id', $current_user->user_id); if (Enable_Extra_Fields) { $main_smarty = $smarty; include mnminclude . 'extra_fields_smarty.php'; $smarty = $main_smarty; $smarty->assign('link_field1', $this->link_field1); $smarty->assign('link_field2', $this->link_field2); $smarty->assign('link_field3', $this->link_field3); $smarty->assign('link_field4', $this->link_field4); $smarty->assign('link_field5', $this->link_field5); $smarty->assign('link_field6', $this->link_field6); $smarty->assign('link_field7', $this->link_field7); $smarty->assign('link_field8', $this->link_field8); $smarty->assign('link_field9', $this->link_field9); $smarty->assign('link_field10', $this->link_field10); $smarty->assign('link_field11', $this->link_field11); $smarty->assign('link_field12', $this->link_field12); $smarty->assign('link_field13', $this->link_field13); $smarty->assign('link_field14', $this->link_field14); $smarty->assign('link_field15', $this->link_field15); } $smarty->assign('Enable_Recommend', Enable_Recommend); $smarty->assign('Recommend_Type', Recommend_Type); $smarty->assign('instpath', my_base_url . my_pligg_base . "/"); $smarty->assign('UseAvatars', do_we_use_avatars()); $smarty->assign('Avatar_ImgSrc', get_avatar('large', "", $this->username(), $this->author_email)); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); $canIhaveAccess = $canIhaveAccess + checklevel('admin'); if ($canIhaveAccess == 1) { $smarty->assign('isadmin', 'yes'); } // For Friends // include_once mnminclude . 'friend.php'; $friend = new Friend(); // make sure we're logged in and we didnt submit the link. if ($current_user->user_id > 0 && $current_user->user_login != $this->username()) { $friend_md5 = friend_MD5($current_user->user_login, $this->username()); $smarty->assign('FriendMD5', $friend_md5); $isfriend = $friend->get_friend_status($this->author); if (!$isfriend) { $friend_text = 'add to'; $friend_url = 'addfriend'; } else { $friend_text = 'remove from'; $friend_url = 'removefriend'; } $smarty->assign('Friend_Text', $friend_text); $smarty->assign('user_add_remove', getmyurl('user_add_remove', $this->username(), $friend_url)); } $smarty->assign('Allow_Friends', Allow_Friends); $smarty->assign('Enable_AddTo', Enable_AddTo); // --- // $smarty->assign('enable_tags', Enable_Tags); $smarty->assign('link_shakebox_index', $link_index); $smarty->assign('link_shakebox_votes', $this->votes); $smarty->assign('link_shakebox_currentuser_votes', $this->votes($current_user->user_id)); $smarty->assign('link_shakebox_currentuser_reports', $this->reports($current_user->user_id)); $jslink = "menealo({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',10)"; $smarty->assign('link_shakebox_javascript_vote', $jslink); $jslink_negative = "menealo({$current_user->user_id},{$this->id},{$link_index}," . "'" . md5($current_user->user_id . $this->randkey) . "',-10)"; $smarty->assign('link_shakebox_javascript_vote_negative', $jslink_negative); $alltagtext = $smarty->get_config_vars('PLIGG_Visual_Tags_All_Tags'); if (Enable_Tags) { $smarty->assign('tags', $this->tags); if (!empty($this->tags)) { $tags_words = str_replace(",", ", ", $this->tags); $tags_count = substr_count($tags_words, ','); if ($tags_count > 1) { $tags_words = $tags_words; } $tag_array = explode(",", $tags_words); $c = count($tag_array); $tag_array[$c] = $this->tags; $c++; for ($i = 0; $i <= $c; $i++) { if ($URLMethod == 1) { $tags_url_array[$i] = my_pligg_base . "/search.php?search=" . urlencode(trim($tag_array[$i])) . "&tag=true"; } elseif ($URLMethod == 2) { $tags_url_array[$i] = my_pligg_base . "/tag/" . urlencode(trim($tag_array[$i])); } } $tag_array[$c - 1] = $alltagtext; $smarty->assign('tag_array', $tag_array); $smarty->assign('tags_url_array', $tags_url_array); $tags_url = urlencode($this->tags); $smarty->assign('tags_count', $tags_count); $smarty->assign('tags_words', $tags_words); $smarty->assign('tags_url', $tags_url); } } $smarty->assign('pagename', pagename); $smarty->assign('my_base_url', my_base_url); $smarty->assign('my_pligg_base', my_pligg_base); $smarty->assign('Default_Gravatar_Large', Default_Gravatar_Large); $smarty->assign('enable_categorycolors', enable_categorycolors); //read enable or disable category colors in config.php $link_index++; check_actions('lib_link_summary_fill_smarty'); return $smarty; }