De GirinoWiki
SpecialPageListSubBlogs.php/SpecialPagesListAllBlogs.php
- Adds Blog functionality to MediaWiki
Copyright (C) 2005 Shannon McNaught
SpecialPageListSubBlogsRSS.php
- Adds RSS functionality to SpecialPageListSubBlogs.php
Copyright (C) 2007 Girino Vey!
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<?php
$wgExtensionFunctions[] = "loadSpecialListSubBlogs";
require_once("includes/SpecialPage.php");
class SpecialListSubBlogs extends SpecialPage {
function SpecialListSubBlogs() {
SpecialPage::SpecialPage('ListSubBlogs', '', false);
$this->includable(true);
}
function execute( $parent = null ) {
global $wgRequest, $wgOut, $wgUser;
$wgOut->setArticleRelated( false );
$fname = 'listsubpages';
// Handle Errors
$target = $this->including() ? $wgRequest->getVal( 'title' ) :
(isset( $parent ) ? $parent : $wgRequest->getVal( 'target' ));
if (is_null($target)) {
// $wgOut->errorpage( 'notargettitle', 'notargettext' );
// return;
} else {
$target = Title::newFromURL( $target );
if( !$target ) {
$wgOut->errorpage( 'notargettitle', 'notargettext' );
return;
}
// RSS feeds
$wgOut->addLink( array( 'title'=>'RSS 2.0', 'rel'=>'alternate', 'type'=>'application/rss+xml', 'href'=>'/girinowiki/Special:ListSubBlogsRSS/User:'.$target->getDBKey().'?feed=atom' ) );
$wgOut->addLink( array( 'title'=>'Atom 1.0', 'rel'=>'alternate', 'type'=>'application/atom+xml', 'href'=>'/girinowiki/Special:ListSubBlogsRSS/User:'.$target->getDBKey().'?feed=atom' ) );
}
$skin = $wgUser->getSkin();
// Do query
list($limit, $offset) = $wgRequest->getLimitOffset(10, 'bloglimit');
$dbr =& wfGetDB( DB_READ );
$use_slash = '/';
if ( $target and preg_match('/\//', $target->getDbKey()) ) {
$use_slash = '';
}
if ($target) {
$result = $dbr->select( 'page' ,
array( 'page_namespace', 'page_title' ),
array( 'page_namespace' => $target->getNamespace(),
"page_title LIKE " . $dbr->addQuotes($target->getDbKey() . $use_slash . '%') ),
$fname,
array( 'ORDER BY'=>'page_id DESC','LIMIT' => $limit, 'OFFSET' => $offset ) );
} else {
$result = $dbr->select( 'page' ,
array( 'page_namespace', 'page_title', 'page_touched' ),
array( 'page_namespace' => '2',
"page_title LIKE '%BlogEntry%'"),
$fname,
array( 'ORDER BY'=>'page_id DESC', 'LIMIT' => $limit + 1, 'OFFSET' => $offset ) );
}
// Output results
if ($target) {
$blogname = $target->getDbKey();
if ( preg_match('/^([^\/]*)\//', $blogname, $matches) ) {
$blogname = $matches[1];
$myblog = 'Special:ListSubBlogs/User:' . $blogname;
$wgOut->addWikiText("< [[$myblog|Retorna ao Blog do $blogname]]<br />\n");
}
$pagetitle = 'Blog do ' . $blogname;
} else {
$pagetitle = 'Todos os blogs';
}
$wgOut->setPagetitle( $pagetitle );
if ( 0 == $dbr->numRows( $result ) ) {
$d = date( 'Y F d H:i:s T' );
if ($wgUser->getName() == $target->getDbKey()) {
$wgOut->addWikiText('[[User:' . $wgUser->getName() . '/BlogEntry: ' . $d . ' | Add New Blog Entry]]');
}
$wgOut->addWikiText("Currently No Blog Entries.");
return;
}
$specialTitle = $this->getTitle();
if ($target) {
$prevnext = wfViewPrevNext( $offset, $limit, $specialTitle,
'target=' . urlencode( $target->getPrefixedDbKey() ),
($dbr->numRows( $result ) < $limit) );
$wgOut->addHTML( $prevnext );
} else {
$prevnext = wfViewPrevNext( $offset, $limit, $specialTitle, '',
($dbr->numRows( $result ) < $limit) );
$wgOut->addHTML( $prevnext );
}
$rows = array();
$d = date( 'Y F d H:i:s T' );
if ($target and $wgUser->getName() == $target->getDbKey()) {
$wgOut->addWikiText('[[User:' . $wgUser->getName() . '/BlogEntry: ' . $d . ' | Add New Blog Entry]]');
}
// add CSS Styles.
$wgOut->addHTML('' .
'<style type="text/css">
.title {
width: 100%;
border: 1px solid rgb(224, 224, 224);
cellpadding: 5px;
cellspacing: 0;
-moz-border-radius: 10px;
}
.blogentry {
border: 1px solid rgb(169, 169, 224);
background-color: rgb(242, 245, 253);
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 100%;
text-align: left;
padding-left: 7px;
width: 100%;
-moz-border-radius: 10px;
}
.entrycontent {
margin: 3px 0 3px 0;
padding: 3px 1em 3px 1em;
background-color: transparent;
border: solid 1px rgb(224, 224, 224);
-moz-border-radius: 10px;
}
.comments {
padding-left: 1em;
padding-right: 1em;
margin: 1em 1em 0 1em;
background-color: #f8f8f8;
border: solid 1px #e0e0e0;
font-size: 75%;
-moz-border-radius: 10px;
}
.commenttitle {
background-color: rgb(255, 255, 244);
width: 70%;
padding-left: 3px;
padding-right: 3px;
border: solid 1px rgb(224, 224, 192);
-moz-border-radius: 10px;
}
.commentlink {
font-size: 75%;
text-align: right;
/*float: right;*/
margin-right: 1em;
}
</style>');
while ($row = $dbr->fetchObject($result)) {
if (ereg("BlogEntry",$row->page_title)) {
$link = Title::makeTitle( $row->page_namespace, $row->page_title);
list($user1,$date1) = explode("/BlogEntry:_",$row->page_title,2);
$date1 = preg_replace('/_/', ' ', $date1);
// make borders
$wgOut->addHTML("<a name=\"". $row->page_title . "\" ></a>");
$wgOut->addHTML("<table class=\"title\" ><tr><td>");
$wgOut->addHTML("<table class=\"blogentry\">");
$wgOut->addHTML("<tr><td align=left>");
// blog image
$wgOut->addWikiText("<div style=\"float: left;\">{{blogimage}}</div>");
// post title
$wgOut->addHTML("<font size=4><a href=\"" .
$this->getTitle()->escapeFullUrl() .
"/User:". $row->page_title .
"\">$date1</a></font>");
if ($wgUser->getName() == $user1) {
$wgOut->addHTML("<small><a href=\"" .
$link->escapeLocalURL( 'action=edit' ) .
"\">editar</a></small>");
}
$userTitle = Title::makeTitle( NS_USER, $user1 );
$wgOut->addHTML("<br>Posted By: <a href=\"" .
$userTitle->escapeLocalURL() .
"\">$user1</a>");
// BlogBlogs ping gadget
if ($wgUser->getName() == $user1) {
$wgOut->addHTML("<br /><a href='http://blogblogs.com.br" .
"/my/gadgets/ping?url=http://www.girino.org/blog/' " .
"title='Pingar o BlogBlogs' " .
"rel='alternate'>" .
"<img " .
"src='http://assets3.blogblogs.com.br" .
"/public/bb/images/gadgets/bbgad_ping_1.gif' " .
"alt='Pingar o BlogBlogs'></a>");
}
$wgOut->addHTML("</td>");
// links at the right side
$wgOut->addHTML("<td valign=top align=right>" .
"<a href=\"" . $this->getTitle()->escapeFullUrl() .
"/User:$user1\">$user1's Blog</a>");
# permalink
$wgOut->addHTML("<br>" .
"<a href=\"" .
$this->getTitle()->escapeFullUrl() .
"/User:".$row->page_title .
"\">" .
"Permalink" .
"</a>");
$wgOut->addHTML("<br>");
# adding stumbleupon link
$wgOut->addHTML(//"<br>" .
"<a href=\"".
"http://www.stumbleupon.com/submit?" .
"url=" .
$wgOut->parse("{{urlencode:{{fullurl:Special:ListSubBlogs/User:" .
$row->page_title .
"}}}}", false) .
"\" title=\"Adicionar este post no StumbleUpon\">" .
//"Stumble it! " .
'<img border="0" ' .
'src="http://www.stumbleupon.com' .
'/images/stumbleit.gif" ' .
'alt="Adicionar este post no StumbleUpon">' .
"</a>");
$wgOut->addHTML(" ");
# linkk
$wgOut->addHTML(//"<br>" .
"<a href=\"" .
"http://www.linkk.com.br/submit.php?url=" .
$wgOut->parse("{{urlencode:{{fullurl:Special:ListSubBlogs/User:" .
$row->page_title .
"}}}}", false) .
"\" title=\"Adicionar este post no Linkk\" >" .
//"Linkk " .
"<img src=\"http://www.linkk.com.br/img/linkk.gif\"" .
"alt=\"Adicionar este post no Linkk\" />" .
"</a>");
$wgOut->addHTML("</td></tr></table>");
// header end
// rankings
// Rec6
global $rec6widget;
if ($rec6widget) {
$wgOut->addHTML("<div style=\"float: right; padding: 0.8em;\">");
$wgOut->addHTML("<script language=\"JavaScript\" " .
"src=\"http://rec6.via6.com/link.php?action=widget&" .
"url=" .
$wgOut->parse("{{urlencode:{{fullurl:Special:" .
"ListSubBlogs/User:" .
$row->page_title .
"}}}}", false) .
"\" type=\"text/javascript\"></script>");
$wgOut->addHTML("</div>");
}
// LinkTo
global $linktowidget;
if ($linktowidget) {
$wgOut->addHTML("<div style=\"float: right; padding: 0.8em;\">");
$wgOut->addHTML(
"<script type=\"text/javascript\">".
" widgetLinkTo_goTo = \"doLink\";".
" widgetLinkTo_actionDo = \"votosPadrao\";".
" widgetLinkTo_Pim = ".
" \"aa799f96803d212601c1d8729be410a8e6e59b9f-f9c2\";\n".
" widgetLinkTo_Url = \"".
$this->getTitle()->escapeFullUrl().
"/User:". $row->page_title .
"\";\n".
" ".
" widgetLinkTo_C_Borda = \"FFFFFF\";".
" widgetLinkTo_C_Fundo = \"FF0000\";".
" widgetLinkTo_C_Link = \"FFFFFF\";".
" widgetLinkTo_C_Texto = \"FFFFFF\";".
" ".
" widgetLinkTo_Largura = 50;".
" widgetLinkTo_Altura = 60;".
" </script>".
" <script type=\"text/javascript\" ".
" src=\"http://www.linkto.com.br/_js_/monta_widget.js\">".
" </script>");
$wgOut->addHTML("</div>");
}
// end rankings
// contents
$tempvalue = "<div class=\"entrycontent\">\n{{:User:" . $row->page_title . "}}\n</div>";
$wgOut->addWikiText($tempvalue);
// comments/talk page
$comments = "<div class=\"commenttitle\">\n";
$comments .= "{{#ifexist:User Talk:". $row->page_title ."|";
$comments .= ";Comentários:\n";
$comments .= "<div class=\"comments\">\n";
$comments .= "{{:User Talk:" . $row->page_title . "}}\n";
$comments .= "</div>";
$comments .= "<div class=\"commentlink\"><span class=\"plainlinks\">" .
"[{{fullurl:Usu%C3%A1rio_Discuss%C3%A3o:".
$row->page_title .
"|action=edit§ion=new}} Comentar]" .
"</span></div>\n";
$comments .= "|";
$comments .= ";<span class=\"plainlinks\">" .
"[{{fullurl:Usu%C3%A1rio_Discuss%C3%A3o:".
$row->page_title .
"|action=edit§ion=new}} Seja o primeiro a comentar]" .
"</span>\n";
$comments .= "}}";
$comments .= "</div>";
$wgOut->addWikiText($comments);
// footer
$wgOut->addHTML("</td></tr></table><p>");
}
}
$wgOut->addHTML($prevnext);
$dbr->freeResult($result);
#$wgOut->addHTML("<span style=\"display: none;\"><a href='http://blogblogs.com.br/api/claim/-779449365/155804/23791' rel='me'> BlogBlogs.Com.Br </a></span>");
}
}
function loadSpecialListSubBlogs()
{
SpecialPage::addPage(new SpecialListSubBlogs);
}
?>