search videos by username, add incomplete video upload handler on each page request (will not yet delete the failed video from db - only shows the error), added variable stypesheet option by passing &xslt= , deleted everything but user settings from settings.pl

git-svn-id: http://yolanda.mister-muffin.de/svn@210 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2007-12-18 12:39:27 +00:00
parent 1d9629200f
commit 3b99d00bcc
4 changed files with 50 additions and 83 deletions

View file

@ -26,17 +26,34 @@ sub get_page_array
#get parameters
my (@userinfo) = @_;
$page->{'username'} = $userinfo->{'username'};
#if user is logged in, use his locale setting
if($userinfo->{'locale'})
#if user is logged in, use his locale setting and check for new upload status
if($userinfo->{'username'})
{
$page->{'locale'} = $userinfo->{'locale'};
#prepare query
my $sth = $dbh->prepare(qq{select id, title, status from uploaded where userid = ? and status != 0}) or die $dbh->errstr;
#execute it
$sth->execute($userinfo->{'id'}) or die $dbh->errstr;
while(my ($id, $title, $status) = $sth->fetchrow_array())
{
$page->{'message'}->{'type'} = "error";
$page->{'message'}->{'text'} = "error_202c";
#TODO: delete from uploaded where id = $id
}
#finish query
$sth->finish() or die $dbh->errstr;
}
#else get the locale from the http server variable
else
{
($page->{'locale'}) = $query->http('HTTP_ACCEPT_LANGUAGE') =~ /^([^,]+),.*$/;
}
$page->{'username'} = $userinfo->{'username'};
$page->{'stylesheet'} = $stylesheet;
$page->{'xmlns:dc'} = $xmlns_dc;
$page->{'xmlns:cc'} = $xmlns_cc;
@ -45,7 +62,7 @@ sub get_page_array
# called by video.pl (display ambiguous videos),
# search.pl (display search results)
# and account.pl (display own videos)
# and upload.pl (display similar videos)
sub fill_results
{
#prepare query
@ -141,7 +158,20 @@ sub output_page
my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file("$root/xsl/xhtml.xsl"));
#let the xslt param choose other stylesheets or default to xhtml.xsl
my $param_xslt = $query->param('xslt');
$param_xslt =~ s/[^a-z]//gi;
if( -f "$root/xsl/$param_xslt.xsl")
{
$xsltpath = "$root/xsl/$param_xslt.xsl"
}
else
{
$xsltpath = "$root/xsl/xhtml.xsl";
}
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file($xsltpath));
#TODO: this usage of libxsl omits the xsl:output definition (no ident of html) but outputs in UTF8
#TODO: later versions of XML::LibXSLT (>= 1.62) define output_as_bytes - this is what we want to use
@ -151,7 +181,6 @@ sub output_page
XMLout(
$page,
KeyAttr => {},
XMLDecl => $XMLDecl,
RootName => 'page',
AttrIndent => '1'
)

View file

@ -20,7 +20,6 @@ $dbuser = 'root';
$dbpass = '';
$domain = 'http://localhost';
$session_name = 'sid';
$XMLDecl = qq{<?xml version="1.0" encoding="UTF-8" ?><?xml-stylesheet type="text/xsl" href="/xsl/xhtml.xsl" ?>};
$locale = "en-US";
$stylesheet = "/style/default.css";
$xmlns_dc = "http://purl.org/dc/elements/1.1/";

View file

@ -24,10 +24,9 @@ if($query->param('query') or $query->param('orderby'))
my @args = ();
$strquery = $query->param('query');
push @tags, $strquery =~ /tag:"([^"]+)"/gi;
push @tags, $strquery =~ /tag:(\w+)/gi;
$strquery =~ s/(tag|title):"[^"]+"//gi;
$strquery =~ s/(tag|title):\w+//gi;
(@tags) = $strquery =~ /tag:(\w+)/gi;
($username) = $strquery =~ /user:(\w+)/i;
$strquery =~ s/(tag|title|user):\w+//gi;
$strquery =~ s/^\s*(.*?)\s*$/$1/;
#build mysql query
@ -54,6 +53,12 @@ if($query->param('query') or $query->param('orderby'))
push @args, "@tags";
}
if($username)
{
$dbquery .= " and match(u.username) against (? in boolean mode)";
push @args, "$username";
}
if($query->param('orderby'))
{
if($query->param('orderby') eq 'filesize')

View file

@ -9,7 +9,7 @@ $session = new CGI::Session;
if($userinfo->{'username'})
{
if($query->param('show') eq 'settings' and $query->param('submit'))
if($query->param('submit'))
{
$dbh->do(qq{update users set locale = ?, pagesize = ?, cortado = ? where id = ?}, undef, $query->param('locale'), $query->param('pagesize'), $query->param('cortado'), $userinfo->{'id'} ) or die $dbh->errstr;
}
@ -21,76 +21,10 @@ if($userinfo->{'username'})
if($userinfo->{'username'})
{
if($query->param('show') eq 'settings')
{
$page->{'account'}->{'show'} = 'settings';
$page->{'account'}->{'locale'} = $userinfo->{'locale'};
$page->{'account'}->{'pagesize'} = $userinfo->{'pagesize'};
$page->{'account'}->{'cortado'} = $userinfo->{'cortado'}
}
elsif($query->param('show') eq 'bookmarks')
{
$page->{'account'}->{'show'} = 'bookmarks';
}
elsif($query->param('show') eq 'uploads')
{
$page->{'account'}->{'show'} = 'uploads';
$page->{'results'}->{'scriptname'} = 'account.pl';
$page->{'results'}->{'argument'} = 'show';
$page->{'results'}->{'value'} = 'uploads';
$page->{'results'}->{'orderby'} = $query->param('orderby');
$page->{'results'}->{'sort'} = $query->param('sort');
#build mysql query
$dbquery = "(select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ) as timestamp,
v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights,
v.license, filesize, duration, width, height, fps, viewcount, downloadcount, 1
from videos as v, users as u where v.userid = u.id and u.sid = ?)
union
(select v.id, v.title, '', u.username, from_unixtime( v.timestamp ) as timestamp,
v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights,
v.license, 0, 0, 0, 0, 0, 0, 0, v.status
from uploaded as v, users as u where v.userid = u.id and u.sid = ?)";
if($query->param('orderby'))
{
if($query->param('orderby') eq 'filesize')
{
$dbquery .= " order by filesize";
}
elsif($query->param('orderby') eq 'duration')
{
$dbquery .= " order by duration";
}
elsif($query->param('orderby') eq 'viewcount')
{
$dbquery .= " order by viewcount";
}
elsif($query->param('orderby') eq 'timestamp')
{
$dbquery .= " order by timestamp";
}
else
{
$dbquery .= " order by id";
}
if($query->param('sort') eq "asc")
{
$dbquery .= " asc"
}
else
{
$dbquery .= " desc"
}
}
fill_results($session->id, $session->id);
}
else
{
$page->{'account'} = [''];
}
$page->{'account'}->{'show'} = 'settings';
$page->{'account'}->{'locale'} = $userinfo->{'locale'};
$page->{'account'}->{'pagesize'} = $userinfo->{'pagesize'};
$page->{'account'}->{'cortado'} = $userinfo->{'cortado'}
}
else
{