Location: PHPKode > projects > Aukyla Document Management System > doc/html/a00213.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>Aukyla PHP Framework</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="StyleSheet" href="auton.css" type="text/css" media="screen">
  </head>

  <body>
    <div id="mainmenu">
      <a href="http://www.auton.nl/" class="home">Home</a>
    </div>
    <div id="submenu">
      <a class="logo" href="http://www.auton.nl/"></a>

      <div class="head">Ads</div>
      <a href="http://sourceforge.net/"><img src="http://sourceforge.net/sflogo.php?group_id=116358&amp;type=1" alt="SourceForge.net Logo" style="padding: 2px 4px; width: 88px; height: 31px; border: 0px"></a>
      <a href="http://getfirefox.com/" title="Get Firefox - The Browser, Reloaded."><img src="http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png" alt="Get Firefox" style="width: 110px; height: 32px; border: 0px"></a>
    </div>
    <div id="main">
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">base</a></div>
<h1>Document.php</h1><div class="fragment"><pre class="fragment">00001 &lt;?php
00002 <span class="comment">/*</span>
00003 <span class="comment">     Document.php, functions for working with documents, like viewing, editing,</span>
00004 <span class="comment">                   saving and indexing.</span>
00005 <span class="comment">     Copyright (C) 2003-2004 Arend van Beelen, Auton Rijnsburg</span>
00006 <span class="comment"></span>
00007 <span class="comment">     This program is free software; you can redistribute it and/or modify it</span>
00008 <span class="comment">     under the terms of the GNU General Public License as published by the Free</span>
00009 <span class="comment">     Software Foundation; either version 2 of the License, or (at your option)</span>
00010 <span class="comment">     any later version.</span>
00011 <span class="comment"></span>
00012 <span class="comment">     This program is distributed in the hope that it will be useful, but WITHOUT</span>
00013 <span class="comment">     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span>
00014 <span class="comment">     FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for</span>
00015 <span class="comment">     more details.</span>
00016 <span class="comment"></span>
00017 <span class="comment">     You should have received a copy of the GNU General Public License along</span>
00018 <span class="comment">     with this program; if not, write to the Free Software Foundation, Inc.,</span>
00019 <span class="comment">     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
00020 <span class="comment"></span>
00021 <span class="comment">     For any questions, comments or whatever, you may mail me at: hide@address.com</span>
00022 <span class="comment">*/</span>
00023 
00024 require_once('<a class="code" href="a00092.html">Config</a>.php');
00025 require_once('Constants.php');
00026 require_once('Forms.php');
00027 require_once('GUI.php');
00028 require_once('<a class="code" href="a00115.html">JavaScript</a>.php');
00029 require_once('MIME.php');
00030 require_once('<a class="code" href="a00119.html">Locale</a>.php');
00031 require_once('<a class="code" href="a00153.html">String</a>.php');
00032 
<a name="l00043"></a><a class="code" href="a00100.html">00043</a> <span class="keyword">class </span><a class="code" href="a00100.html">Document</a>
00044 {
<a name="l00052"></a><a class="code" href="a00100.html#e0">00052</a>         <span class="keyword">public</span> <span class="keyword">static</span> function hasViewer($mimetype)
00053         {
00054                 <span class="keywordflow">if</span>(self::loadHandler($mimetype) == <span class="keyword">false</span>)
00055                 {
00056                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
00057                 }
00058 
00059                 $className = self::handlerName($mimetype);
00060                 <span class="keywordflow">return</span> call_user_func(array($className, 'supportsViewing'));
00061         }
00062 
<a name="l00070"></a><a class="code" href="a00100.html#e1">00070</a>         <span class="keyword">public</span> <span class="keyword">static</span> function hasEditor($mimetype)
00071         {
00072                 <span class="keywordflow">if</span>(self::loadHandler($mimetype) == <span class="keyword">false</span>)
00073                 {
00074                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
00075                 }
00076 
00077                 $className = self::handlerName($mimetype);
00078                 <span class="keywordflow">return</span> call_user_func(array($className, 'supportsEditing'));
00079         }
00080 
<a name="l00089"></a><a class="code" href="a00100.html#e2">00089</a>         <span class="keyword">public</span> <span class="keyword">static</span> function save($<span class="keywordtype">id</span>, $uri, $mimetype)
00090         {
00091                 <span class="keywordflow">if</span>(self::loadHandler($mimetype) == <span class="keyword">false</span>)
00092                 {
00093                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
00094                 }
00095 
00096                 $className = self::handlerName($mimetype);
00097                 $result = call_user_func(array($className, 'save'), $<span class="keywordtype">id</span>, $uri);
00098                 <span class="keywordflow">return</span> $result;
00099         }
00100 
<a name="l00118"></a><a class="code" href="a00100.html#e3">00118</a>         <span class="keyword">public</span> <span class="keyword">static</span> function hasIndexer($mimetype)
00119         {
00120                 <span class="keywordflow">if</span>(self::loadHandler($mimetype) == <span class="keyword">false</span>)
00121                 {
00122                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
00123                 }
00124 
00125                 $className = self::handlerName($mimetype);
00126                 <span class="keywordflow">return</span> call_user_func(array($className, 'supportsIndexing'));
00127         }
00128 
<a name="l00142"></a><a class="code" href="a00100.html#e4">00142</a>         <span class="keyword">public</span> <span class="keyword">static</span> function index($documentId, $uri)
00143         {
00144                 $mimetype = MIME::type($uri);
00145 
00146                 <span class="keywordflow">if</span>(self::loadHandler($mimetype) == <span class="keyword">false</span>)
00147                 {
00148                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
00149                 }
00150 
00151                 $className = self::handlerName($mimetype);
00152                 call_user_func(array($className, 'index'), $documentId, $uri);
00153         }
00154 
00165         <span class="keyword">public</span> <span class="keyword">static</span> function loadHandler($mimetype)
00166         {
00167                 $className = self::handlerName($mimetype);
00168                 <span class="keywordflow">if</span>(class_exists($className) == <span class="keyword">false</span>)
00169                 {
00170                         <span class="keywordflow">if</span>(file_exists(AUKYLA_DIR.<span class="stringliteral">"/plugins/DocumentHandlers/$className.php"</span>) == <span class="keyword">false</span>)
00171                         {
00172                                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00173                         }
00174                         $include = include_once(<span class="stringliteral">"DocumentHandlers/$className.php"</span>);
00175                         <span class="keywordflow">if</span>($include == <span class="keyword">false</span> ||
00176                            class_exists($className) == <span class="keyword">false</span>)
00177                         {
00178                                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00179                         }
00180                 }
00181                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00182         }
00183 
00193         <span class="keyword">public</span> <span class="keyword">static</span> function handlerName($mimetype)
00194         {
00195                 <span class="keywordflow">return</span> str_replace(array(<span class="charliteral">'/'</span>, <span class="charliteral">'-'</span>, <span class="charliteral">'.'</span>), <span class="charliteral">'_'</span>, $mimetype).'_DocumentHandler';
00196         }
00197 }
00198 
<a name="l00202"></a><a class="code" href="a00103.html">00202</a> <span class="keyword">class </span><a class="code" href="a00103.html">DocumentViewer</a> <span class="keyword">extends</span> <a class="code" href="a00096.html">Container</a>
00203 {
<a name="l00214"></a><a class="code" href="a00103.html#a0">00214</a>         <span class="keyword">public</span> function <a class="code" href="a00103.html#a0">__construct</a>(<a class="code" href="a00096.html">Container</a> $parent, $uri, $mimetype = '', $name = '')
00215         {
00216                 parent::__construct($parent);
00217 
00218                 <span class="keywordflow">if</span>($mimetype == '')
00219                 {
00220                         $mimetype == MIME::type($uri);
00221                 }
00222 
00223                 $className = Document::handlerName($mimetype);
00224 
00225                 <span class="keywordflow">if</span>(Document::loadHandler($mimetype) == <span class="keyword">false</span> ||
00226                    call_user_func(array($className, 'supportsViewing')) == <span class="keyword">false</span>)
00227                 {
00228                         $name = <a class="code" href="a00153.html#e4">String::stripSpecialChars</a>($name == '' ? basename($uri) : $name).
00229                                 MIME::extension($mimetype);
00230                         $downloadUrl = <a class="code" href="a00092.html#e0">Config::globals</a>('downloadURL');
00231                         <span class="keywordflow">if</span>($downloadUrl != '')
00232                         {
00233                                 $url = <span class="stringliteral">"$downloadUrl?file={$uri}&amp;amp;name=$name"</span>;
00234                                 $javaScriptUrl = <span class="stringliteral">"$downloadUrl?file={$uri}&amp;name=$name"</span>;
00235                                 <span class="keyword">new</span> <a class="code" href="a00136.html">Paragraph</a>($<span class="keyword">this</span>, i18n('The document will be downloaded. If nothing happens, please click the following link:'));
00236                                 <span class="keyword">new</span> <a class="code" href="a00118.html">Link</a>($<span class="keyword">this</span>, $url, $name);
00237                                 <span class="keyword">new</span> <a class="code" href="a00115.html">JavaScript</a>($<span class="keyword">this</span>, <span class="stringliteral">"setTimeout('window.location=\"$javaScriptUrl\";', 250);"</span>);
00238                         }
00239                         <span class="keywordflow">else</span>
00240                         {
00241                                 <span class="keyword">new</span> <a class="code" href="a00136.html">Paragraph</a>($<span class="keyword">this</span>, i18n('Sorry, no viewer could be found <span class="keywordflow">for</span> the document type (%1).',
00242                                                           MIME::description($mimetype, Locale::language())));
00243                         }
00244                 }
00245                 <span class="keywordflow">else</span>
00246                 {
00247                         $className = Document::handlerName($mimetype);
00248                         <span class="keywordflow">return</span> call_user_func(array($className, 'view'), $parent, $uri);
00249                 }
00250         }
00251 }
00252 
<a name="l00256"></a><a class="code" href="a00101.html">00256</a> <span class="keyword">class </span><a class="code" href="a00101.html">DocumentEditor</a> <span class="keyword">extends</span> <a class="code" href="a00114.html">Input</a>
00257 {
<a name="l00267"></a><a class="code" href="a00101.html#a0">00267</a>         <span class="keyword">public</span> function <a class="code" href="a00101.html#a0">__construct</a>(<a class="code" href="a00096.html">Container</a> $parent, $<span class="keywordtype">id</span>, $uri, $mimetype)
00268         {
00269                 parent::__construct($parent, $<span class="keywordtype">id</span>);
00270 
00271                 $className = Document::handlerName($mimetype);
00272 
00273                 <span class="keywordflow">if</span>(Document::loadHandler($mimetype) == <span class="keyword">false</span> ||
00274                    call_user_func(array($className, 'supportsEditing')) == <span class="keyword">false</span>)
00275                 {
00276                         <span class="keyword">new</span> <a class="code" href="a00136.html">Paragraph</a>($<span class="keyword">this</span>, i18n('Sorry, no editer could be found <span class="keywordflow">for</span> the document type (%1).',
00277                                                   MIME::description($this-&gt;mimetype, Locale::language())));
00278                 }
00279                 <span class="keywordflow">else</span>
00280                 {
00281                         $className = Document::handlerName($mimetype);
00282                         <span class="keywordflow">return</span> call_user_func(array($className, 'edit'), $parent, $<span class="keywordtype">id</span>, $uri);
00283                 }
00284         }
00285 }
00286 
00287 ?&gt;
</pre></div>    </div>
  </body>
</html>
Return current item: Aukyla Document Management System