added first xforms upload page
git-svn-id: http://yolanda.mister-muffin.de/svn@328 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
07f6ffc2c2
commit
f7419101c3
2 changed files with 234 additions and 157 deletions
210
trunk/upload.pl
210
trunk/upload.pl
|
@ -7,163 +7,71 @@ $session = new CGI::Session;
|
||||||
|
|
||||||
@userinfo = get_userinfo_from_sid($session->id);
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
@page = get_page_array(@userinfo);
|
my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );
|
||||||
|
|
||||||
if($userinfo->{'username'})
|
my $page = get_page_array(@userinfo);
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'DC.Title'} = $query->param('DC.Title');
|
|
||||||
$page->{'uploadform'}->{'DC.Subject'} = $query->param('DC.Subject');
|
|
||||||
$page->{'uploadform'}->{'DC.Description'} = $query->param('DC.Description');
|
|
||||||
$page->{'uploadform'}->{'DC.Creator'} = $query->param('DC.Creator');
|
|
||||||
$page->{'uploadform'}->{'DC.Source'} = $query->param('DC.Source');
|
|
||||||
$page->{'uploadform'}->{'DC.Language'} = $query->param('DC.Language');
|
|
||||||
$page->{'uploadform'}->{'DC.Coverage'} = $query->param('DC.Coverage');
|
|
||||||
$page->{'uploadform'}->{'DC.Rights'} = $query->param('DC.Rights');
|
|
||||||
$page->{'uploadform'}->{'DC.License'} = $query->param('DC.License');
|
|
||||||
|
|
||||||
if($query->param('2'))
|
$page->setNamespace("http://www.w3.org/2002/xforms", "xforms", 0);
|
||||||
{
|
$page->setNamespace("http://www.w3.org/2001/XMLSchema", "xsd", 0);
|
||||||
#remove duplicates from tags
|
$page->setNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi", 0);
|
||||||
@subject = split(' ', $query->param('DC.Subject'));
|
|
||||||
@unique{ @subject } = ();
|
|
||||||
foreach $tag (keys %unique)
|
|
||||||
{
|
|
||||||
if(length($tag) >= $config->{"page_tag_lenght_min"})
|
|
||||||
{
|
|
||||||
$subject.=$tag." ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$subject =~ s/\s*$//;
|
|
||||||
$page->{'uploadform'}->{'DC.Subject'} = $subject;
|
|
||||||
|
|
||||||
if($query->param('DC.Title')&&$subject&&$query->param('DC.Description'))
|
my $instance = XML::LibXML::Element->new( "instance" );
|
||||||
{
|
$instance->setNamespace("http://www.w3.org/2002/xforms", "xforms");
|
||||||
$page->{'results-listing'} = [''];
|
|
||||||
|
|
||||||
my @args = ();
|
my $video = XML::LibXML::Element->new( "video" );
|
||||||
|
|
||||||
#build mysql query
|
my $node = XML::LibXML::Element->new( "Title" );
|
||||||
my $dbquery = "select v.id, v.title, v.description, u.username,
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
from_unixtime( v.timestamp ), v.creator, v.subject,
|
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
|
||||||
v.source, v.language, v.coverage, v.rights,
|
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
|
||||||
v.license, filesize, duration, width, height, fps, viewcount,
|
$video->appendChild($node);
|
||||||
downloadcount,
|
|
||||||
match(v.title, v.description, v.subject)
|
|
||||||
against( ? in boolean mode) as relevance
|
|
||||||
from videos as v, users as u where u.id = v.userid
|
|
||||||
and match(v.title, v.description, v.subject)
|
|
||||||
against( ? in boolean mode)";
|
|
||||||
push @args, $query->param('DC.Title'), $query->param('DC.Title');
|
|
||||||
|
|
||||||
fill_results($dbquery, @args);
|
$node = XML::LibXML::Element->new( "Subject" );
|
||||||
$page->{'uploadform'}->{'page'} = '2';
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
}
|
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
|
||||||
else
|
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
|
||||||
{
|
$video->appendChild($node);
|
||||||
if(!$query->param('DC.Title'))
|
|
||||||
{
|
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_missing_DC.Title";
|
|
||||||
}
|
|
||||||
elsif(!$query->param('DC.Subject'))
|
|
||||||
{
|
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_missing_DC.Subject";
|
|
||||||
}
|
|
||||||
elsif(!$query->param('DC.Description'))
|
|
||||||
{
|
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_missing_DC.Description";
|
|
||||||
}
|
|
||||||
$page->{'uploadform'}->{'page'} = '1';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif($query->param('3'))
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'page'} = '3';
|
|
||||||
}
|
|
||||||
elsif($query->param('4'))
|
|
||||||
{
|
|
||||||
if($query->param('DC.License') eq 'cc-by')
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'remix'} = 'true';
|
|
||||||
}
|
|
||||||
elsif($query->param('DC.License') eq 'cc-by-sa')
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'sharealike'} = 'true';
|
|
||||||
}
|
|
||||||
elsif($query->param('DC.License') eq 'cc-by-nd')
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'noderivatives'} = 'true';
|
|
||||||
}
|
|
||||||
elsif($query->param('DC.License') eq 'cc-by-nc')
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'remix'} = 'true';
|
|
||||||
$page->{'uploadform'}->{'noncommercial'} = 'true';
|
|
||||||
}
|
|
||||||
elsif($query->param('DC.License') eq 'cc-by-nc-sa')
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'sharealike'} = 'true';
|
|
||||||
$page->{'uploadform'}->{'noncommercial'} = 'true';
|
|
||||||
}
|
|
||||||
elsif($query->param('DC.License') eq 'cc-by-nc-nd')
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'noderivatives'} = 'true';
|
|
||||||
$page->{'uploadform'}->{'noncommercial'} = 'true';
|
|
||||||
}
|
|
||||||
|
|
||||||
$page->{'uploadform'}->{'page'} = '4';
|
$node = XML::LibXML::Element->new( "Description" );
|
||||||
}
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
elsif($query->param('5'))
|
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
|
||||||
{
|
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:string" );
|
||||||
if($query->param('modification') and not $query->param('DC.License'))
|
$video->appendChild($node);
|
||||||
{
|
|
||||||
if($query->param('modification') eq 'remix')
|
|
||||||
{
|
|
||||||
if($query->param('noncommercial'))
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'DC.License'} = 'cc-by-nc';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'DC.License'} = 'cc-by';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif($query->param('modification') eq 'sharealike')
|
|
||||||
{
|
|
||||||
if($query->param('noncommercial'))
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'DC.License'} = 'cc-by-nc-sa';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'DC.License'} = 'cc-by-sa';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif($query->param('modification') eq 'noderivatives')
|
|
||||||
{
|
|
||||||
if($query->param('noncommercial'))
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'DC.License'} = 'cc-by-nc-nd';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$page->{'uploadform'}->{'DC.License'} = 'cc-by-nd';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$page->{'uploadform'}->{'page'} = '5';
|
$node = XML::LibXML::Element->new( "Coverage.day" );
|
||||||
}
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
else
|
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
|
||||||
{
|
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:gDay" );
|
||||||
$page->{'uploadform'}->{'page'} = '1';
|
$video->appendChild($node);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$page->{'message'}->{'type'} = "error";
|
|
||||||
$page->{'message'}->{'text'} = "error_202c";
|
|
||||||
}
|
|
||||||
|
|
||||||
print output_page();
|
$node = XML::LibXML::Element->new( "Coverage.month" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
|
||||||
|
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:gMonth" );
|
||||||
|
$video->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "Coverage.year" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
|
||||||
|
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:gYear" );
|
||||||
|
$video->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "Coverage.placeName" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
|
||||||
|
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:normalizedString" );
|
||||||
|
$video->appendChild($node);
|
||||||
|
|
||||||
|
$node = XML::LibXML::Element->new( "Language" );
|
||||||
|
$node->setNamespace( "http://purl.org/dc/elements/1.1/", "dc" );
|
||||||
|
$node->setNamespace( "http://www.w3.org/2001/XMLSchema-instance", "xsi", 0 );
|
||||||
|
$node->setAttributeNS( "http://www.w3.org/2001/XMLSchema-instance", "type", "xsd:language" );
|
||||||
|
$video->appendChild($node);
|
||||||
|
|
||||||
|
$instance->appendChild($video);
|
||||||
|
|
||||||
|
$page->appendChild($instance);
|
||||||
|
|
||||||
|
$doc->setDocumentElement($page);
|
||||||
|
|
||||||
|
output_page($doc);
|
||||||
|
|
169
trunk/upload.pl.bak
Normal file
169
trunk/upload.pl.bak
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
require "functions.pl";
|
||||||
|
|
||||||
|
#create or resume session
|
||||||
|
CGI::Session->name($config->{"page_cookie_name"});
|
||||||
|
$query = new CGI;
|
||||||
|
$session = new CGI::Session;
|
||||||
|
|
||||||
|
@userinfo = get_userinfo_from_sid($session->id);
|
||||||
|
|
||||||
|
@page = get_page_array(@userinfo);
|
||||||
|
|
||||||
|
if($userinfo->{'username'})
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'DC.Title'} = $query->param('DC.Title');
|
||||||
|
$page->{'uploadform'}->{'DC.Subject'} = $query->param('DC.Subject');
|
||||||
|
$page->{'uploadform'}->{'DC.Description'} = $query->param('DC.Description');
|
||||||
|
$page->{'uploadform'}->{'DC.Creator'} = $query->param('DC.Creator');
|
||||||
|
$page->{'uploadform'}->{'DC.Source'} = $query->param('DC.Source');
|
||||||
|
$page->{'uploadform'}->{'DC.Language'} = $query->param('DC.Language');
|
||||||
|
$page->{'uploadform'}->{'DC.Coverage'} = $query->param('DC.Coverage');
|
||||||
|
$page->{'uploadform'}->{'DC.Rights'} = $query->param('DC.Rights');
|
||||||
|
$page->{'uploadform'}->{'DC.License'} = $query->param('DC.License');
|
||||||
|
|
||||||
|
if($query->param('2'))
|
||||||
|
{
|
||||||
|
#remove duplicates from tags
|
||||||
|
@subject = split(' ', $query->param('DC.Subject'));
|
||||||
|
@unique{ @subject } = ();
|
||||||
|
foreach $tag (keys %unique)
|
||||||
|
{
|
||||||
|
if(length($tag) >= $config->{"page_tag_lenght_min"})
|
||||||
|
{
|
||||||
|
$subject.=$tag." ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$subject =~ s/\s*$//;
|
||||||
|
$page->{'uploadform'}->{'DC.Subject'} = $subject;
|
||||||
|
|
||||||
|
if($query->param('DC.Title')&&$subject&&$query->param('DC.Description'))
|
||||||
|
{
|
||||||
|
$page->{'results-listing'} = [''];
|
||||||
|
|
||||||
|
my @args = ();
|
||||||
|
|
||||||
|
#build mysql query
|
||||||
|
my $dbquery = "select v.id, v.title, v.description, u.username,
|
||||||
|
from_unixtime( v.timestamp ), v.creator, v.subject,
|
||||||
|
v.source, v.language, v.coverage, v.rights,
|
||||||
|
v.license, filesize, duration, width, height, fps, viewcount,
|
||||||
|
downloadcount,
|
||||||
|
match(v.title, v.description, v.subject)
|
||||||
|
against( ? in boolean mode) as relevance
|
||||||
|
from videos as v, users as u where u.id = v.userid
|
||||||
|
and match(v.title, v.description, v.subject)
|
||||||
|
against( ? in boolean mode)";
|
||||||
|
push @args, $query->param('DC.Title'), $query->param('DC.Title');
|
||||||
|
|
||||||
|
fill_results($dbquery, @args);
|
||||||
|
$page->{'uploadform'}->{'page'} = '2';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!$query->param('DC.Title'))
|
||||||
|
{
|
||||||
|
$page->{'message'}->{'type'} = "error";
|
||||||
|
$page->{'message'}->{'text'} = "error_missing_DC.Title";
|
||||||
|
}
|
||||||
|
elsif(!$query->param('DC.Subject'))
|
||||||
|
{
|
||||||
|
$page->{'message'}->{'type'} = "error";
|
||||||
|
$page->{'message'}->{'text'} = "error_missing_DC.Subject";
|
||||||
|
}
|
||||||
|
elsif(!$query->param('DC.Description'))
|
||||||
|
{
|
||||||
|
$page->{'message'}->{'type'} = "error";
|
||||||
|
$page->{'message'}->{'text'} = "error_missing_DC.Description";
|
||||||
|
}
|
||||||
|
$page->{'uploadform'}->{'page'} = '1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($query->param('3'))
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'page'} = '3';
|
||||||
|
}
|
||||||
|
elsif($query->param('4'))
|
||||||
|
{
|
||||||
|
if($query->param('DC.License') eq 'cc-by')
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'remix'} = 'true';
|
||||||
|
}
|
||||||
|
elsif($query->param('DC.License') eq 'cc-by-sa')
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'sharealike'} = 'true';
|
||||||
|
}
|
||||||
|
elsif($query->param('DC.License') eq 'cc-by-nd')
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'noderivatives'} = 'true';
|
||||||
|
}
|
||||||
|
elsif($query->param('DC.License') eq 'cc-by-nc')
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'remix'} = 'true';
|
||||||
|
$page->{'uploadform'}->{'noncommercial'} = 'true';
|
||||||
|
}
|
||||||
|
elsif($query->param('DC.License') eq 'cc-by-nc-sa')
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'sharealike'} = 'true';
|
||||||
|
$page->{'uploadform'}->{'noncommercial'} = 'true';
|
||||||
|
}
|
||||||
|
elsif($query->param('DC.License') eq 'cc-by-nc-nd')
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'noderivatives'} = 'true';
|
||||||
|
$page->{'uploadform'}->{'noncommercial'} = 'true';
|
||||||
|
}
|
||||||
|
|
||||||
|
$page->{'uploadform'}->{'page'} = '4';
|
||||||
|
}
|
||||||
|
elsif($query->param('5'))
|
||||||
|
{
|
||||||
|
if($query->param('modification') and not $query->param('DC.License'))
|
||||||
|
{
|
||||||
|
if($query->param('modification') eq 'remix')
|
||||||
|
{
|
||||||
|
if($query->param('noncommercial'))
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'DC.License'} = 'cc-by-nc';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'DC.License'} = 'cc-by';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($query->param('modification') eq 'sharealike')
|
||||||
|
{
|
||||||
|
if($query->param('noncommercial'))
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'DC.License'} = 'cc-by-nc-sa';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'DC.License'} = 'cc-by-sa';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($query->param('modification') eq 'noderivatives')
|
||||||
|
{
|
||||||
|
if($query->param('noncommercial'))
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'DC.License'} = 'cc-by-nc-nd';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'DC.License'} = 'cc-by-nd';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$page->{'uploadform'}->{'page'} = '5';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page->{'uploadform'}->{'page'} = '1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page->{'message'}->{'type'} = "error";
|
||||||
|
$page->{'message'}->{'text'} = "error_202c";
|
||||||
|
}
|
||||||
|
|
||||||
|
print output_page();
|
Loading…
Reference in a new issue