liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file data.object.php

Documentation is available at data.object.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7. // +----------------------------------------------------------------------+
  8. // | Copyright (c) 2004, bitweaver.org
  9. // +----------------------------------------------------------------------+
  10. // | All Rights Reserved. See below for details and a complete list of authors.
  11. // | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
  12. // |
  13. // | For comments, please use phpdocu.sourceforge.net documentation standards!!!
  14. // | -> see http://phpdocu.sourceforge.net/
  15. // +----------------------------------------------------------------------+
  16. // | Author (TikiWiki): Damian Parker <damosoft@users.sourceforge.net>
  17. // | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
  18. // | by: StarRider <starrrider@users.sourceforge.net>
  19. // | Rewrote data function so plugin can cover more types of objects than just Flash
  20. // | by: Jasp (Jared Woodbridge) <jaspp@users.sourceforge.net>
  21. // +----------------------------------------------------------------------+
  22. // $Id$
  23.  
  24. /**
  25.  * definitions
  26.  */
  27. global $gBitSystem;
  28. if$gBitSystem->isPackageActive'wiki' ) ) // Do not include this Plugin if the Package is not active
  29.  
  30. define'PLUGIN_GUID_DATAOBJECT''dataobject' );
  31. global $gLibertySystem;
  32. $pluginParams array (
  33.     'tag' => 'OBJECT',
  34.     'auto_activate' => FALSE,
  35.     'requires_pair' => FALSE,
  36.     'load_function' => 'data_object',
  37.     'title' => 'Object',
  38.     'help_page' => 'DataPluginObject',
  39.     'description' => tra("This plugin displays a Flash, Tcl or Java applet/object."),
  40.     'help_function' => 'data_object_help',
  41.     'syntax' => "{OBJECT type= src= width= height=}",
  42.     'plugin_type' => DATA_PLUGIN
  43. );
  44. $gLibertySystem->registerPluginPLUGIN_GUID_DATAOBJECT$pluginParams );
  45. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATAOBJECT );
  46.  
  47.  
  48. function data_object_help({
  49.     $help =
  50.         '<table class="data help">'
  51.             .'<tr>'
  52.                 .'<th>' tra"Key" '</th>'
  53.                 .'<th>' tra"Type" '</th>'
  54.                 .'<th>' tra"Comments" '</th>'
  55.             .'</tr>'
  56.             .'<tr class="odd">'
  57.                 .'<td>type</td>'
  58.                 .'<td>' tra"key-word" '<br />' tra"(manditory)" '</td>'
  59.                 .'<td>' tra"The type of object being displayed. Possible values are:"' <strong>tcl, flash, java</strong>.' '</td>'
  60.             .'</tr>'
  61.             .'<tr class="even">'
  62.                 .'<td>src</td>'
  63.                 .'<td>' tra"string" '<br />' tra"(manditory)" '</td>'
  64.                 .'<td>' tra"The location of the file used for the object. This can be any URL or a site value. See Examples."'</td>'
  65.             .'</tr>'
  66.             .'<tr class="odd">'
  67.                 .'<td>param_<i>name</i></td>'
  68.                 .'<td>' tra"string" '<br />' tra"(optional)" '</td>'
  69.                 .'<td>' tra"Can be used to specify custom object parameters. Currently only available for Tcl applets. Replace \"<i>name</i>\" with the name of the parameter."'</td>'
  70.             .'</tr>'
  71.             .'<tr class="even">'
  72.                 .'<td>width</td>'
  73.                 .'<td>' tra"number or percentage" '<br />' tra"(optional)" '</td>'
  74.                 .'<td>' tra"The width of the object. This value can be given in pixels or as a percentage of available area. A pixel value is assumed so only a numeric value is needed. To specify a percentage - the character <strong>% MUST</strong> follow the value."'</td>'
  75.             .'</tr>'
  76.             .'<tr class="odd">'
  77.                 .'<td>height</td>'
  78.                 .'<td>' tra"number or percentage" '<br />' tra"(optional)" '</td>'
  79.                 .'<td>' tra"The height of the object. This value can be given in pixels or as a percentage. A pixel value is assumed so only a numeric value is needed. To specify a percentage - the character <strong>% MUST</strong> follow the value."'</td>'
  80.             .'</tr>'
  81.             .'<tr class="even">'
  82.                 .'<td>float</td>'
  83.                 .'<td>' tra"key-words" '<br />' tra"(optional)" '</td>'
  84.                 .'<td>' tra"Specifies how the object is to float on the page. Floating elements are positioned on the side specified, with content flowing around. Possible values are:"' <strong>left, right, none</strong>. '
  85.                 . tra("(Default = "'<strong>' tra'none - object is shown inline' '</strong>)</td>'
  86.             .'</tr>'
  87.             .'<tr class="odd">'
  88.                 .'<td>clear</td>'
  89.                 .'<td>' tra"key-words" '<br />' tra"(optional)" '</td>'
  90.                 .'<td>' tra"Specifies which horizontal sides of the object can not have other content flowing around. Possible values are:"' <strong>left, right, both, none</strong>. '
  91.                 . tra("(Default = "'<strong>' tra'none - content is allowed to flow around object' '</strong>)</td>'
  92.             .'</tr>'
  93.         .'</table>'
  94.  
  95.         .'<table class="data help">'
  96.             .'<caption>' tra"Flash specific parameters" '</caption>'
  97.             .'<tr>'
  98.                 .'<th>' tra"Key" '</th>'
  99.                 .'<th>' tra"Type" '</th>'
  100.                 .'<th>' tra"Comments" '</th>'
  101.             .'</tr>'
  102.             .'<tr class="odd">'
  103.                 .'<td>quality</td>'
  104.                 .'<td>' tra"key-word" '<br />' tra"(optional)" '</td>'
  105.                 .'<td>' tra"The quality at which to display a Flash applet. Possible values are unknown - except:"' <strong>high</strong> ' tra("and probably"' <strong>low</strong>.</td>'
  106.             .'</tr>'
  107.         .'</table>'
  108.  
  109.         .'<table class="data help">'
  110.             .'<caption>' tra"Java specific parameters" '</caption>'
  111.             .'<tr>'
  112.                 .'<th>' tra"Key" '</th>'
  113.                 .'<th>' tra"Type" '</th>'
  114.                 .'<th>' tra"Comments" '</th>'
  115.             .'</tr>'
  116.             .'<tr class="odd">'
  117.                 .'<td>vmversion</td>'
  118.                 .'<td>' tra"version number" '<br />' tra"(optional)" '</td>'
  119.                 .'<td>' tra"The version of Java required for the applet. Should be in the form of <strong>X.x</strong>, eg: <strong>1.3</strong>." '</td>'
  120.             .'</tr>'
  121.             .'<tr class="even">'
  122.                 .'<td>pagescript</td>'
  123.                 .'<td>' tra"boolean" '<br />' tra"(optional)" '</td>'
  124.                 .'<td>' tra"Specifies if the applet can access Javascript features on the web page. Possible values are:"' <strong>true, false</strong>.</td>'
  125.             .'</tr>'
  126.             .'<tr class="odd">'
  127.                 .'<td>appletscript</td>'
  128.                 .'<td>' tra"boolean" '<br />' tra"(optional)" '</td>'
  129.                 .'<td>' tra"Specifies whether the applet is scriptable from the web page using JavaScript or VBScript. Possible values are:"' <strong>true, false</strong>.</td>'
  130.             .'</tr>'
  131.             .'<tr class="even">'
  132.                 .'<td>srcbase</td>'
  133.                 .'<td>' tra"string" '<br />' tra"(optional)" '</td>'
  134.                 .'<td>' tra"The base location of the Java applet." '</td>'
  135.             .'</tr>'
  136.             .'<tr class="odd">'
  137.                 .'<td>archive</td>'
  138.                 .'<td>' tra"string" '<br />' tra"(optional)" '</td>'
  139.                 .'<td>' tra"Specifies the name of the Java archive." '</td>'
  140.             .'</tr>'
  141.         .'</table>'
  142.  
  143.         . tra("Example: ""{OBJECT type=flash src=../liberty/icons/Mind-Reader.swf}<br />"
  144.         . tra("Example: ""{OBJECT type=flash src=http://www.bitweaver.org/liberty/icons/Mind-Reader.swf width='100%' height='600' quality='high'}<br />"
  145.         . tra('Both of these examples display "The Flash Mind Reader" by Andy Naughton. The first example is on your site and is not very large. The second example is located on the bitweaver.org site and takes the width of the center column with an appropriate height.');
  146.     return $help;
  147. }
  148.  
  149.  
  150. function data_object ($data$params{
  151.     // Need these plugin parameters
  152.     foreach (array("type""src"as $parameter{
  153.         if (!array_key_exists($parameter$params))
  154.             return '<span class="warning">'.tra('When using <strong>{object}</strong>, a <strong>type</strong> and <strong>src</strong> parameter is required.').'</span>';
  155.     }
  156.  
  157.     $objectParams array();
  158.  
  159.     switch ($params["type"]{
  160.         case "tcl":
  161.             // This loop scans for and sets param_ custom object parmeters. Note that in the future, it may be used for object types other than Tcl, so don't go making this part of the tcl clause below.
  162.             foreach (array_keys($paramsas $parameter{
  163.                 if (ereg("param_*"$parameter))
  164.                     $objectParams[substr($parameter6)$params[$parameter];
  165.             }
  166.  
  167.         case "tcl":
  168.             // Tcl Plugin applet
  169.             $classid "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
  170.             $objectParams["type""application/x-tcl";
  171.             $objectParams["pluginspage""http://www.tcl.tk/software/plugin/";
  172.             $objectParams["src"$params["src"];
  173.             break;
  174.  
  175.         case "flash":
  176.             // Macromedia Flash movie
  177.             $classid "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
  178.             $objectParams["movie"$params["src"];
  179.             if (array_key_exists("quality"$params))
  180.                 $objectParams["quality"$params["quality"];
  181.             break;
  182.  
  183.         case "java":
  184.             // Java applet
  185.             $classid "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
  186.             $objectParams["code"$params["src"];
  187.             $objectParams["type""application/x-java-applet";
  188.             if (array_key_exists("vmversion"$params))
  189.                 $objectParams["type".= ';version='.$params["vmversion"];
  190.             if (array_key_exists("pagescript"$params))
  191.                 $objectParams["mayscript"$params["pagescript"];
  192.             if (array_key_exists("appletscript"$params))
  193.                 $objectParams["scriptable"$params["appletscript"];
  194.             if (array_key_exists("srcbase"$params))
  195.                 $objectParams["codebase"$params["srcbase"];
  196.             if (array_key_exists("archive"$params))
  197.                 $objectParams["archive"$params["archive"];
  198.             break;
  199.  
  200.         default:
  201.             // Unrecognized object type
  202.             return '<span class="warning">'.tra('The <strong>type</strong> parameter of <strong>{object}</strong> must either be <strong>tcl</strong>, <strong>flash</strong> or <strong>java</strong>.').'</span>';
  203.     }
  204.  
  205.     // Build the <object> HTML code
  206.     $result  '<object classid="'.$classid.'" style="';
  207.     $result .= (array_key_exists("float",  $params)) ' float: ' .$params["float"]';' '';
  208.     $result .= (array_key_exists("clear",  $params)) ' clear: ' .$params["clear"]';' '';
  209.     $result .= '"';
  210.     $result .= (array_key_exists("width",  $params)) ' width="' .$params["width"]'"' '';
  211.     $result .= (array_key_exists("height"$params)) ' height="'.$params["height"].'"' '';
  212.     $result .= '>';
  213.     foreach (array_keys($objectParamsas $parameter)
  214.         $result .= '<param name="'.$parameter.'" value="'.$objectParams[$parameter].'"/>';
  215.     $result .= '</object>';
  216.  
  217.     // ...and we're done
  218.     return $result;
  219. }
  220.  
  221. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:20 +0000 by phpDocumentor 1.5.0-lsces