From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>Konstrukt::Plugin::wiki::backend::file</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
<link rel="stylesheet" title="cpan" type="text/css" href="../../../../cpan.css" media="all" >
</head>
<body class='pod'>
<!--
generated by Pod::Simple::CustomHTML v,
using Pod::Simple::PullParser v2.02,
under Perl v5.008008 at Tue Sep 26 20:07:32 2006 GMT.
If you want to change this HTML document, you probably shouldn't do that
by changing it directly. Instead, see about changing the calling options
to Pod::Simple::CustomHTML, and/or subclassing Pod::Simple::CustomHTML,
then reconverting this document from the Pod source.
When in doubt, email the author of Pod::Simple::CustomHTML for advice.
See 'perldoc Pod::Simple::CustomHTML' for more info.
-->
<!-- start doc -->
<p class="backlinktop"><b><a name="___top" href="../../../../index.html" accesskey="1" title="All Documents">&lt;&lt;</a></b></p>
<div class='indexgroup'>
<ul class='indexList indexList1'>
<li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
<li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
<li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
<li class='indexItem indexItem1'><a href='#METHODS'>METHODS</a>
<ul class='indexList indexList2'>
<li class='indexItem indexItem2'><a href='#init'>init</a>
<li class='indexItem indexItem2'><a href='#install'>install</a>
<li class='indexItem indexItem2'><a href='#actions'>actions</a>
<li class='indexItem indexItem2'><a href='#prepare'>prepare</a>
<li class='indexItem indexItem2'><a href='#execute'>execute</a>
<li class='indexItem indexItem2'><a href='#file_show'>file_show</a>
<li class='indexItem indexItem2'><a href='#file_edit_show'>file_edit_show</a>
<li class='indexItem indexItem2'><a href='#file_edit'>file_edit</a>
<li class='indexItem indexItem2'><a href='#file_revision_list'>file_revision_list</a>
<li class='indexItem indexItem2'><a href='#file_restore'>file_restore</a>
<li class='indexItem indexItem2'><a href='#exists'>exists</a>
<li class='indexItem indexItem2'><a href='#revision'>revision</a>
<li class='indexItem indexItem2'><a href='#revisions'>revisions</a>
<li class='indexItem indexItem2'><a href='#get_info'>get_info</a>
<li class='indexItem indexItem2'><a href='#get_content'>get_content</a>
<li class='indexItem indexItem2'><a href='#store'>store</a>
<li class='indexItem indexItem2'><a href='#restore'>restore</a>
</ul>
<li class='indexItem indexItem1'><a href='#AUTHOR'>AUTHOR</a>
<li class='indexItem indexItem1'><a href='#SEE_ALSO'>SEE ALSO</a>
</ul>
</div>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>
<p>Konstrukt::Plugin::wiki::backend::file - Base class for file backends</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>
<pre> use base &#39;Konstrukt::Plugin::wiki::backend::file&#39;;
#overwrite the methods
#note that you can use $self-&#62;backend_method() in the action methods as
#only an instance of the backend class will be created and it will inherit your methods.</pre>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>
<p>Base class for a backend class that implements the backend functionality (store, retrieve, ...) for files (*.zip, *.pdf, *.*).</p>
<p>Includes the control/display code for managing files as it won&#39;t change with different backend types (DBI, file, ...). So the implementing backend class will inherit this code but must overwrite the data retrieval and update code.</p>
<p>Although currently only DBI-backends exist, it should be easy to develop other backends (e.g. file based).</p>
<p>Note that the name of the files will be normalized. All characters but letters, numbers, hyphens, parenthesis, brackets and dots will be replaced by underscores. Internally files are case insensitive. So <code>SomeFile.zip</code> will point to the same page as <code>somefile.zip</code>.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS</a></h1>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="init"
>init</a></h2>
<p>Initialization for this plugin.</p>
<p>If you overwrite this one in your implementation, make sure to call <code>$self-</code>SUPER::init(@_);&#62; to let the base class (this class) also do its init work.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="install"
>install</a></h2>
<p>Installs the templates.</p>
<p><b>Parameters:</b></p>
<p>none</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="actions"
>actions</a></h2>
<p>See <a href="../../../../Konstrukt/Plugin/wiki/backend.html#actions" class="podlinkpod"
>&#34;actions&#34; in Konstrukt::Plugin::wiki::backend</a> for a description of this one.</p>
<p>Responsible for the actions to show manage files.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="prepare"
>prepare</a></h2>
<p>The served file content will of course be dynamic. Don&#39;t do anything here.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="execute"
>execute</a></h2>
<p>This one will be called, when a file&#39;s content will be downloaded. It will retrieve the content from the backend and return it to the browser.</p>
<p><b>Parameters</b>:</p>
<ul>
<li>$tag - Reference to the tag (and its children) that shall be handled.</li>
</ul>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="file_show"
>file_show</a></h2>
<p>Will handle the action to show an information page for a file.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="file_edit_show"
>file_edit_show</a></h2>
<p>Will handle the action to show the form to edit/upload a file.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="file_edit"
>file_edit</a></h2>
<p>Will handle the action to update a file.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="file_revision_list"
>file_revision_list</a></h2>
<p>Will handle the action to show the revision history of a file.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="file_restore"
>file_restore</a></h2>
<p>Will handle the action to restore a file&#39;s content and/or description.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="exists"
>exists</a></h2>
<p>This method will return true, if a specified file exists. It will return undef otherwise.</p>
<p>Must be overwritten by the implementing class.</p>
<p><b>Parameters</b>:</p>
<ul>
<li>$title - The title of the file</li>
<li>$revision - Optional: A specific revision of a file</li>
</ul>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="revision"
>revision</a></h2>
<p>This method will return the latest revision number/number of revisions of a specified file. It will return undef if the specified file does not exist.</p>
<p>Must be overwritten by the implementing class.</p>
<p><b>Parameters</b>:</p>
<ul>
<li>$title - The title of the file</li>
</ul>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="revisions"
>revisions</a></h2>
<p>This method will return all revisions of the specified file as an array of hash references ordered by ascending revision numbers:</p>
<pre> [
{ revision =&#62; 1, description =&#62; &#39;foo&#39;, description_revision =&#62; 3, content_revision =&#62; 4, content =&#62; 1, author =&#62; &#39;bar&#39;, host =&#62; &#39;123.123.123.123&#39;, year =&#62; 2005, month =&#62; 1, day =&#62; 1, hour =&#62; 0, =&#62; minute =&#62; 0 },
{ revision =&#62; 2, ...},
...
]</pre>
<p>Will return undef, if the file doesn&#39;t exist.</p>
<p>Note that the description_revision and content_revision may also be 0 if no content has been saved yet.</p>
<p>Must be overwritten by the implementing class.</p>
<p><b>Parameters</b>:</p>
<ul>
<li>$title - The title of the file</li>
</ul>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="get_info"
>get_info</a></h2>
<p>This method will return the file info as a hashref:</p>
<pre> { title =&#62; &#39;foo&#39;, revision =&#62; 7, description =&#62; &#39;some text&#39;, description_revision =&#62; 3, content_revision =&#62; 4, author =&#62; &#39;foo&#39;, host =&#62; &#39;123.123.123.123&#39;, year =&#62; 2005, month =&#62; 1, day =&#62; 1, hour =&#62; 0, =&#62; minute =&#62; 0 },</pre>
<p>Will return undef, if the requested file doesn&#39;t exist.</p>
<p>Note that the description_revision and content_revision may also be 0 if no content has been saved yet.</p>
<p>Must be overwritten by the implementing class.</p>
<p><b>Parameters</b>:</p>
<ul>
<li>$title - The title of the file</li>
<li>$revision - Optional: A specific revision of a file. When not specified, the latest revision will be returned.</li>
</ul>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="get_content"
>get_content</a></h2>
<p>This method will return the file content as a hashref:</p>
<pre> { content =&#62; &#39;binarydata&#39;, mimetype =&#62; &#39;application/foobar&#39;, filename =&#62; &#39;somefile.ext&#39; }</pre>
<p>Will return undef, if the requested file doesn&#39;t exist or there is no content yet.</p>
<p>Must be overwritten by the implementing class.</p>
<p><b>Parameters</b>:</p>
<ul>
<li>$title - The title of the file</li>
<li>$revision - Optional: A specific revision of a file. When not specified, the latest revision will be returned.</li>
</ul>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="store"
>store</a></h2>
<p>This method will add a new file (or new revision if the file already exists) to the store.</p>
<p>If the file already exists, you may also just add a new description or a new content for the file. Pass undef for the value, you don&#39;t want to change.</p>
<p>Will return -1 if no change has been made (which is the case, when no new content and no new description has been passed and the file already exists in the database). Will return true on successful update and undef on error.</p>
<p><b>Parameters</b>:</p>
<ul>
<li>$title - The title of the file</li>
<li>$store_description - True, if a new description should be stored. False, if the old one should be left.</li>
<li>$description - A description of this file. May be undef to reset (delete) the description for the new revision.</li>
<li>$store_content - True, if a new content should be stored. False, if the old one should be left.</li>
<li>$content - The (binary) content that should be stored. May be undef to reset (delete) the content for the new revision.</li>
<li>$mimetype - The MIME type of the file</li>
<li>$filename - The filename of the uploaded file. Will be used as the filename for the download</li>
<li>$author - User id of the creator</li>
<li>$host - Internet address of the creator</li>
</ul>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="restore"
>restore</a></h2>
<p>This method will restore a description and/or a content from a given file revision.</p>
<p>Will return -1 if no change has been made (which is the case, when the current data and the data, which should be restored, are the same). Will return true on successful update and undef on error.</p>
<p><b>Parameters</b>:</p>
<ul>
<li>$title - The title of the file</li>
<li>$revision - The revision from which the description will be restored.</li>
<li>$restore_description - True, when the description should be restored</li>
<li>$restore_content - True, when the content should be restored</li>
<li>$author - User id of the modifier</li>
<li>$host - Internet address of the modifier</li>
</ul>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="AUTHOR"
>AUTHOR</a></h1>
<p>Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.</p>
<p>This document is free software. It is distributed under the same terms as Perl itself.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SEE_ALSO"
>SEE ALSO</a></h1>
<p><a href="../../../../Konstrukt/Plugin.html" class="podlinkpod"
>Konstrukt::Plugin</a>, <a href="../../../../Konstrukt/Plugin.html" class="podlinkpod"
>Konstrukt::Plugin</a>, <a href="../../../../Konstrukt.html" class="podlinkpod"
>Konstrukt</a></p>
<p class="backlinkbottom"><b><a name="___bottom" href="../../../../index.html" title="All Documents">&lt;&lt;</a></b></p>
<!-- end doc -->
</body></html>