summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e207d91)
raw | patch | inline | side by side (parent: e207d91)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 9 Jan 2008 16:02:24 +0000 (16:02 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 9 Jan 2008 16:02:24 +0000 (16:02 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8267 594d385d-05f5-0310-b6e9-bd551577e9d8
53 files changed:
index c0d1c0900962d6e2409a5357c671dccceee5c080..889bf74fefab06251b039d1983c44ceafedc7459 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-require_once "../include/php_writeexcel/class.writeexcel_workbook.inc.php";
-require_once "../include/php_writeexcel/class.writeexcel_worksheet.inc.php";
+require_once "../include/utils/excel/class.writeexcel_workbook.inc.php";
+require_once "../include/utils/excel/class.writeexcel_worksheet.inc.php";
function dump_ldap ($mode= 0)
{
diff --git a/gosa-core/include/TreeMenu.inc b/gosa-core/include/TreeMenu.inc
+++ /dev/null
@@ -1,822 +0,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Copyright (c) 2002-2005, Richard Heyes, Harald Radi |
-// | All rights reserved. |
-// | |
-// | Redistribution and use in source and binary forms, with or without |
-// | modification, are permitted provided that the following conditions |
-// | are met: |
-// | |
-// | o Redistributions of source code must retain the above copyright |
-// | notice, this list of conditions and the following disclaimer. |
-// | o Redistributions in binary form must reproduce the above copyright |
-// | notice, this list of conditions and the following disclaimer in the |
-// | documentation and/or other materials provided with the distribution.|
-// | o The names of the authors may not be used to endorse or promote |
-// | products derived from this software without specific prior written |
-// | permission. |
-// | |
-// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
-// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
-// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
-// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
-// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
-// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
-// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
-// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
-// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
-// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
-// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// | |
-// +-----------------------------------------------------------------------+
-// | Author: Richard Heyes <http://www.phpguru.org/> |
-// | Harald Radi <harald.radi@nme.at> |
-// +-----------------------------------------------------------------------+
-//
-// $Id: TreeMenu.php,v 1.21 2005/03/02 02:24:26 richard Exp $
-
-/**
-* HTML_TreeMenu Class
-*
-* A simple couple of PHP classes and some not so simple
-* Jabbascript which produces a tree menu. In IE this menu
-* is dynamic, with branches being collapsable. In IE5+ the
-* status of the collapsed/open branches persists across page
-* refreshes.In any other browser the tree is static. Code is
-* based on work of Harald Radi.
-*
-* Usage.
-*
-* After installing the package, copy the example php script to
-* your servers document root. Also place the TreeMenu.js and the
-* images folder in the same place. Running the script should
-* then produce the tree.
-*
-* Thanks go to Chip Chapin (http://www.chipchapin.com) for many
-* excellent ideas and improvements.
-*
-* @author Richard Heyes <richard@php.net>
-* @author Harald Radi <harald.radi@nme.at>
-* @access public
-* @package HTML_TreeMenu
-*/
-
-class HTML_TreeMenu
-{
- /**
- * Indexed array of subnodes
- * @var array
- */
- var $items;
-
- /**
- * Constructor
- *
- * @access public
- */
- function HTML_TreeMenu()
- {
- // Not much to do here :(
- }
-
- /**
- * This function adds an item to the the tree.
- *
- * @access public
- * @param object $node The node to add. This object should be
- * a HTML_TreeNode object.
- * @return object Returns a reference to the new node inside
- * the tree.
- */
- function addItem(&$node)
- {
- $this->items[] = &$node;
- return $this->items[count($this->items) - 1];
- }
-
- /**
- * Import method for creating HTML_TreeMenu objects/structures
- * out of existing tree objects/structures. Currently supported
- * are Wolfram Kriesings' PEAR Tree class, and Richard Heyes' (me!)
- * Tree class (available here: http://www.phpguru.org/). This
- * method is intended to be used statically, eg:
- * $treeMenu = &HTML_TreeMenu::createFromStructure($myTreeStructureObj);
- *
- * @param array $params An array of parameters that determine
- * how the import happens. This can consist of:
- * structure => The tree structure
- * type => The type of the structure, currently
- * can be either 'heyes' or 'kriesing'
- * nodeOptions => Default options for each node
- *
- * @return object The resulting HTML_TreeMenu object
- */
- function createFromStructure($params)
- {
- if (!isset($params['nodeOptions'])) {
- $params['nodeOptions'] = array();
- }
-
- switch (@$params['type']) {
-
- /**
- * Wolfram Kriesings' PEAR Tree class
- */
- case 'kriesing':
- $className = strtolower(get_class($params['structure']->dataSourceClass));
- $isXMLStruct = strpos($className,'_xml') !== false ? true : false;
-
- // Get the entire tree, the $nodes are sorted like in the tree view
- // from top to bottom, so we can easily put them in the nodes
- $nodes = $params['structure']->getNode();
-
- // Make a new menu and fill it with the values from the tree
- $treeMenu = new HTML_TreeMenu();
- $curNode[0] = &$treeMenu; // we need the current node as the reference to the
-
- foreach ( $nodes as $aNode ) {
- $events = array();
- $data = array();
-
- // In an XML, all the attributes are saved in an array, but since they might be
- // used as the parameters, we simply extract them here if we handle an XML-structure
- if ( $isXMLStruct && sizeof($aNode['attributes']) ){
- foreach ( $aNode['attributes'] as $key=>$val ) {
- if ( !$aNode[$key] ) { // dont overwrite existing values
- $aNode[$key] = $val;
- }
- }
- }
-
- // Process all the data that are saved in $aNode and put them in the data and/or events array
- foreach ( $aNode as $key=>$val ) {
- if ( !is_array($val) ) {
- // Dont get the recursive data in here! they are always arrays
- if ( substr($key,0,2) == 'on' ){ // get the events
- $events[$key] = $val;
- }
-
- // I put it in data too, so in case an options starts with 'on' its also passed to the node ... not too cool i know
- $data[$key] = $val;
- }
- }
-
- // Normally the text is in 'name' in the Tree class, so we check both but 'text' is used if found
- $data['text'] = $aNode['text'] ? $aNode['text'] : $aNode['name'];
-
- // Add the item to the proper node
- $thisNode = &$curNode[$aNode['level']]->addItem( new HTML_TreeNode( $data , $events ) );
- $curNode[$aNode['level']+1] = &$thisNode;
- }
- break;
-
- /**
- * Richard Heyes' (me!) second (array based) Tree class
- */
- case 'heyes_array':
- // Need to create a HTML_TreeMenu object ?
- if (!isset($params['treeMenu'])) {
- $treeMenu = new HTML_TreeMenu();
- $parentID = 0;
- } else {
- $treeMenu = &$params['treeMenu'];
- $parentID = $params['parentID'];
- }
-
- // Loop thru the trees nodes
- foreach ($params['structure']->getChildren($parentID) as $nodeID) {
- $data = $params['structure']->getData($nodeID);
- $parentNode = &$treeMenu->addItem(new HTML_TreeNode(array_merge($params['nodeOptions'], $data)));
-
- // Recurse ?
- if ($params['structure']->hasChildren($nodeID)) {
- $recurseParams['type'] = 'heyes_array';
- $recurseParams['parentID'] = $nodeID;
- $recurseParams['nodeOptions'] = $params['nodeOptions'];
- $recurseParams['structure'] = &$params['structure'];
- $recurseParams['treeMenu'] = &$parentNode;
- HTML_TreeMenu::createFromStructure($recurseParams);
- }
- }
-
- break;
-
- /**
- * Richard Heyes' (me!) original OO based Tree class
- */
- case 'heyes':
- default:
- // Need to create a HTML_TreeMenu object ?
- if (!isset($params['treeMenu'])) {
- $treeMenu = new HTML_TreeMenu();
- } else {
- $treeMenu = &$params['treeMenu'];
- }
-
- // Loop thru the trees nodes
- foreach ($params['structure']->nodes->nodes as $node) {
- $tag = $node->getTag();
- $parentNode = &$treeMenu->addItem(new HTML_TreeNode(array_merge($params['nodeOptions'], $tag)));
-
- // Recurse ?
- if (!empty($node->nodes->nodes)) {
- $recurseParams['structure'] = $node;
- $recurseParams['nodeOptions'] = $params['nodeOptions'];
- $recurseParams['treeMenu'] = &$parentNode;
- HTML_TreeMenu::createFromStructure($recurseParams);
- }
- }
- break;
-
- }
-
- return $treeMenu;
- }
-
- /**
- * Creates a treeMenu from XML. The structure of your XML should be
- * like so:
- *
- * <treemenu>
- * <node text="First node" icon="folder.gif" expandedIcon="folder-expanded.gif" />
- * <node text="Second node" icon="folder.gif" expandedIcon="folder-expanded.gif">
- * <node text="Sub node" icon="folder.gif" expandedIcon="folder-expanded.gif" />
- * </node>
- * <node text="Third node" icon="folder.gif" expandedIcon="folder-expanded.gif">
- * </treemenu>
- *
- * Any of the options you can supply to the HTML_TreeNode constructor can be supplied as
- * attributes to the <node> tag. If there are no subnodes for a particular node, you can
- * use the XML shortcut <node ... /> instead of <node ... ></node>. The $xml argument can
- * be either the XML as a string, or an pre-created XML_Tree object. Also, this method
- * REQUIRES my own Tree class to work (http://phpguru.org/tree.html). If this has not
- * been include()ed or require()ed this method will die().
- *
- * @param mixed $xml This can be either a string containing the XML, or an XML_Tree object
- * (the PEAR::XML_Tree package).
- * @return object The HTML_TreeMenu object
- */
- function createFromXML($xml)
- {
- if (!class_exists('Tree')) {
- die('Could not find Tree class');
- }
-
- // Supplied $xml is a string
- if (is_string($xml)) {
- require_once('XML/Tree.php');
- $xmlTree = new XML_Tree();
- $xmlTree->getTreeFromString($xml);
-
- // Supplied $xml is an XML_Tree object
- } else {
- $xmlTree = $xml;
- }
-
- // Now process the XML_Tree object, setting the XML attributes
- // to be the tag data (with out the XML tag name or contents).
- $treeStructure = Tree::createFromXMLTree($xmlTree, true);
- $treeStructure->nodes->traverse(create_function('&$node', '$tagData = $node->getTag(); $node->setTag($tagData["attributes"]);'));
-
-
- return HTML_TreeMenu::createFromStructure(array('structure' => $treeStructure));
- }
-} // HTML_TreeMenu
-
-
-/**
-* HTML_TreeNode class
-*
-* This class is supplementary to the above and provides a way to
-* add nodes to the tree. A node can have other nodes added to it.
-*
-* @author Richard Heyes <richard@php.net>
-* @author Harald Radi <harald.radi@nme.at>
-* @access public
-* @package HTML_TreeMenu
-*/
-class HTML_TreeNode
-{
- /**
- * The text for this node.
- * @var string
- */
- var $text;
-
- /**
- * The link for this node.
- * @var string
- */
- var $link;
-
- /**
- * The icon for this node.
- * @var string
- */
- var $icon;
-
- /**
- * The icon to show when expanded for this node.
- * @var string
- */
- var $expandedIcon;
-
- /**
- * The css class for this node
- * @var string
- */
- var $cssClass;
-
- /**
- * The link target for this node
- * @var string
- */
- var $linkTarget;
-
- /**
- * Indexed array of subnodes
- * @var array
- */
- var $items;
-
- /**
- * Whether this node is expanded or not
- * @var bool
- */
- var $expanded;
-
- /**
- * Whether this node is dynamic or not
- * @var bool
- */
- var $isDynamic;
-
- /**
- * Should this node be made visible?
- * @var bool
- */
- var $ensureVisible;
-
- /**
- * The parent node. Null if top level
- * @var object
- */
- var $parent;
-
- /**
- * Javascript event handlers;
- * @var array
- */
- var $events;
-
- /**
- * Constructor
- *
- * @access public
- * @param array $options An array of options which you can pass to change
- * the way this node looks/acts. This can consist of:
- * o text The title of the node, defaults to blank
- * o link The link for the node, defaults to blank
- * o icon The icon for the node, defaults to blank
- * o expandedIcon The icon to show when the node is expanded
- * o cssClass The CSS class for this node, defaults to blank
- * o expanded The default expanded status of this node, defaults to false
- * This doesn't affect non dynamic presentation types
- * o linkTarget Target for the links. Defaults to linkTarget of the
- * HTML_TreeMenu_Presentation.
- * o isDynamic If this node is dynamic or not. Only affects
- * certain presentation types.
- * o ensureVisible If true this node will be made visible despite the expanded
- * settings, and client side persistence. Will not affect
- * some presentation styles, such as Listbox. Default is false
- * @param array $events An array of javascript events and the corresponding event handlers.
- * Additionally to the standard javascript events you can specify handlers
- * for the 'onexpand', 'oncollapse' and 'ontoggle' events which will be fired
- * whenever a node is collapsed and/or expanded.
- */
- function HTML_TreeNode($options = array(), $events = array())
- {
- $this->text = '';
- $this->link = '';
- $this->icon = '';
- $this->expandedIcon = '';
- $this->cssClass = '';
- $this->expanded = false;
- $this->isDynamic = true;
- $this->ensureVisible = false;
- $this->linkTarget = null;
-
- $this->parent = null;
- $this->events = $events;
-
- foreach ($options as $option => $value) {
- $this->$option = $value;
- }
- }
-
- /**
- * Allows setting of various parameters after the initial
- * constructor call. Possible options you can set are:
- * o text
- * o link
- * o icon
- * o cssClass
- * o expanded
- * o isDynamic
- * o ensureVisible
- * ie The same options as in the constructor
- *
- * @access public
- * @param string $option Option to set
- * @param string $value Value to set the option to
- */
- function setOption($option, $value)
- {
- $this->$option = $value;
- }
-
- /**
- * Adds a new subnode to this node.
- *
- * @access public
- * @param object $node The new node
- */
- function &addItem(&$node)
- {
- $node->parent = &$this;
- $this->items[] = &$node;
-
- /**
- * If the subnode has ensureVisible set it needs
- * to be handled, and all parents set accordingly.
- */
- if ($node->ensureVisible) {
- $this->_ensureVisible();
- }
-
- return $this->items[count($this->items) - 1];
- }
-
- /**
- * Private function to handle ensureVisible stuff
- *
- * @access private
- */
- function _ensureVisible()
- {
- $this->ensureVisible = true;
- $this->expanded = true;
-
- if (!is_null($this->parent)) {
- $this->parent->_ensureVisible();
- }
- }
-} // HTML_TreeNode
-
-
-/**
-* HTML_TreeMenu_Presentation class
-*
-* Base class for other presentation classes to
-* inherit from.
-*/
-class HTML_TreeMenu_Presentation
-{
- /**
- * The TreeMenu structure
- * @var object
- */
- var $menu;
-
- /**
- * Base constructor simply sets the menu object
- *
- * @param object $structure The menu structure
- */
- function HTML_TreeMenu_Presentation(&$structure)
- {
- $this->menu = &$structure;
- }
-
- /**
- * Prints the HTML generated by the toHTML() method.
- * toHTML() must therefore be defined by the derived
- * class.
- *
- * @access public
- * @param array Options to set. Any options taken by
- * the presentation class can be specified
- * here.
- */
- function printMenu($options = array())
- {
- foreach ($options as $option => $value) {
- $this->$option = $value;
- }
-
- echo $this->toHTML();
- }
-}
-
-
-/**
-* HTML_TreeMenu_DHTML class
-*
-* This class is a presentation class for the tree structure
-* created using the TreeMenu/TreeNode. It presents the
-* traditional tree, static for browsers that can't handle
-* the DHTML.
-*/
-class HTML_TreeMenu_DHTML extends HTML_TreeMenu_Presentation
-{
- /**
- * Dynamic status of the treemenu. If true (default) this has no effect. If
- * false it will override all dynamic status vars and set the menu to be
- * fully expanded an non-dynamic.
- */
- var $isDynamic;
-
- /**
- * Path to the images
- * @var string
- */
- var $images;
-
- /**
- * Target for the links generated
- * @var string
- */
- var $linkTarget;
-
- /**
- * Whether to use clientside persistence or not
- * @var bool
- */
- var $usePersistence;
-
- /**
- * The default CSS class for the nodes
- */
- var $defaultClass;
-
- /**
- * Whether to skip first level branch images
- * @var bool
- */
- var $noTopLevelImages;
-
- /**
- * Name of Jabbascript object to use
- * @var string
- */
- var $jsObjectName;
-
- /**
- * Constructor, takes the tree structure as
- * an argument and an array of options which
- * can consist of:
- * o images - The path to the images folder. Defaults to "images"
- * o linkTarget - The target for the link. Defaults to "_self"
- * o defaultClass - The default CSS class to apply to a node. Default is none.
- * o usePersistence - Whether to use clientside persistence. This persistence
- * is achieved using cookies. Default is true.
- * o noTopLevelImages - Whether to skip displaying the first level of images if
- * there is multiple top level branches.
- * o maxDepth - The maximum depth of indentation. Useful for ensuring
- * deeply nested trees don't go way off to the right of your
- * page etc. Defaults to no limit.
- * o jsObjectName - Name to use for jabbascript object. Set this if you have
- * different menus that should maintain their persistence
- * information separately.
- *
- * And also a boolean for whether the entire tree is dynamic or not.
- * This overrides any perNode dynamic settings.
- *
- * @param object $structure The menu structure
- * @param array $options Array of options
- * @param bool $isDynamic Whether the tree is dynamic or not
- */
- function HTML_TreeMenu_DHTML(&$structure, $options = array(), $isDynamic = true)
- {
- $this->HTML_TreeMenu_Presentation($structure);
- $this->isDynamic = $isDynamic;
-
- // Defaults
- $this->images = 'images';
- $this->maxDepth = 0; // No limit
- $this->linkTarget = '_self';
- $this->jsObjectName = 'objTreeMenu';
- $this->defaultClass = '';
- $this->usePersistence = true;
- $this->noTopLevelImages = false;
-
- foreach ($options as $option => $value) {
- $this->$option = $value;
- }
- }
-
- /**
- * Returns the HTML for the menu. This method can be
- * used instead of printMenu() to use the menu system
- * with a template system.
- *
- * @access public
- * @return string The HTML for the menu
- */
- function toHTML()
- {
- static $count = 0;
- $menuObj = $this->jsObjectName . '_' . ++$count;
-
- $html = "\n";
- $html .= '<script language="javascript" type="text/javascript">' . "\n//<![CDATA[\n\t";
- $html .= sprintf('%s = new TreeMenu("%s", "%s", "%s", "%s", %s, %s);',
- $menuObj,
- $this->images,
- $menuObj,
- $this->linkTarget,
- $this->defaultClass,
- $this->usePersistence ? 'true' : 'false',
- $this->noTopLevelImages ? 'true' : 'false');
-
- $html .= "\n";
-
- /**
- * Loop through subnodes
- */
- if (isset($this->menu->items)) {
- for ($i=0; $i<count($this->menu->items); $i++) {
- $html .= $this->_nodeToHTML($this->menu->items[$i], $menuObj);
- }
- }
-
- $html .= sprintf("\n\t%s.drawMenu();", $menuObj);
- $html .= sprintf("\n\t%s.writeOutput();", $menuObj);
-
- if ($this->usePersistence && $this->isDynamic) {
- $html .= sprintf("\n\t%s.resetBranches();", $menuObj);
- }
- $html .= "\n// ]]>\n</script>";
-
- return $html;
- }
-
- /**
- * Prints a node of the menu
- *
- * @access private
- */
- function _nodeToHTML($nodeObj, $prefix, $return = 'newNode', $currentDepth = 0, $maxDepthPrefix = null)
- {
- $prefix = empty($maxDepthPrefix) ? $prefix : $maxDepthPrefix;
-
- $expanded = $this->isDynamic ? ($nodeObj->expanded ? 'true' : 'false') : 'true';
- $isDynamic = $this->isDynamic ? ($nodeObj->isDynamic ? 'true' : 'false') : 'false';
- $html = sprintf("\t %s = %s.addItem(new TreeNode('%s', %s, %s, %s, %s, '%s', '%s', %s));\n",
- $return,
- $prefix,
- str_replace("'", "\\'", $nodeObj->text),
- !empty($nodeObj->icon) ? "'" . $nodeObj->icon . "'" : 'null',
- !empty($nodeObj->link) ? "'" . $nodeObj->link . "'" : 'null',
- $expanded,
- $isDynamic,
- $nodeObj->cssClass,
- $nodeObj->linkTarget,
- !empty($nodeObj->expandedIcon) ? "'" . $nodeObj->expandedIcon . "'" : 'null');
-
- foreach ($nodeObj->events as $event => $handler) {
- $html .= sprintf("\t %s.setEvent('%s', '%s');\n",
- $return,
- $event,
- str_replace(array("\r", "\n", "'"), array('\r', '\n', "\'"), $handler));
- }
-
- if ($this->maxDepth > 0 AND $currentDepth == $this->maxDepth) {
- $maxDepthPrefix = $prefix;
- }
-
- /**
- * Loop through subnodes
- */
- if (!empty($nodeObj->items)) {
- for ($i=0; $i<count($nodeObj->items); $i++) {
- $html .= $this->_nodeToHTML($nodeObj->items[$i], $return, $return . '_' . ($i + 1), $currentDepth + 1, $maxDepthPrefix);
- }
- }
-
- return $html;
- }
-} // End class HTML_TreeMenu_DHTML
-
-
-/**
-* HTML_TreeMenu_Listbox class
-*
-* This class presents the menu as a listbox
-*/
-class HTML_TreeMenu_Listbox extends HTML_TreeMenu_Presentation
-{
- /**
- * The text that is displayed in the first option
- * @var string
- */
- var $promoText;
-
- /**
- * The character used for indentation
- * @var string
- */
- var $indentChar;
-
- /**
- * How many of the indent chars to use
- * per indentation level
- * @var integer
- */
- var $indentNum;
-
- /**
- * Target for the links generated
- * @var string
- */
- var $linkTarget;
-
- /**
- * Constructor
- *
- * @param object $structure The menu structure
- * @param array $options Options whic affect the display of the listbox.
- * These can consist of:
- * o promoText The text that appears at the the top of the listbox
- * Defaults to "Select..."
- * o indentChar The character to use for indenting the nodes
- * Defaults to " "
- * o indentNum How many of the indentChars to use per indentation level
- * Defaults to 2
- * o linkTarget Target for the links. Defaults to "_self"
- * o submitText Text for the submit button. Defaults to "Go"
- */
- function HTML_TreeMenu_Listbox($structure, $options = array())
- {
- $this->HTML_TreeMenu_Presentation($structure);
-
- $this->promoText = 'Select...';
- $this->indentChar = ' ';
- $this->indentNum = 2;
- $this->linkTarget = '_self';
- $this->submitText = 'Go';
-
- foreach ($options as $option => $value) {
- $this->$option = $value;
- }
- }
-
- /**
- * Returns the HTML generated
- */
- function toHTML()
- {
- static $count = 0;
- $nodeHTML = '';
-
- /**
- * Loop through subnodes
- */
- if (isset($this->menu->items)) {
- for ($i=0; $i<count($this->menu->items); $i++) {
- $nodeHTML .= $this->_nodeToHTML($this->menu->items[$i]);
- }
- }
-
- return sprintf('<form target="%s" action="" onsubmit="var link = this.%s.options[this.%s.selectedIndex].value; if (link) {this.action = link; return true} else return false"><select name="%s"><option value="">%s</option>%s</select> <input type="submit" value="%s" /></form>',
- $this->linkTarget,
- 'HTML_TreeMenu_Listbox_' . ++$count,
- 'HTML_TreeMenu_Listbox_' . $count,
- 'HTML_TreeMenu_Listbox_' . $count,
- $this->promoText,
- $nodeHTML,
- $this->submitText);
- }
-
- /**
- * Returns HTML for a single node
- *
- * @access private
- */
- function _nodeToHTML($node, $prefix = '')
- {
- $html = sprintf('<option value="%s">%s%s</option>', $node->link, $prefix, $node->text);
-
- /**
- * Loop through subnodes
- */
- if (isset($node->items)) {
- for ($i=0; $i<count($node->items); $i++) {
- $html .= $this->_nodeToHTML($node->items[$i], $prefix . str_repeat($this->indentChar, $this->indentNum));
- }
- }
-
- return $html;
- }
-} // End class HTML_TreeMenu_Listbox
-?>
diff --git a/gosa-core/include/class_MultiSelectWindow.inc b/gosa-core/include/class_MultiSelectWindow.inc
index a93ad5f3e439694709eda299f0ef9e83fc18a338..8295cb3002d7c8f486bc74137659401f97fd2943 100644 (file)
$mid = new LayersMenu(6, 7, 2, 1);
$mid->setImgwww("./images/");
$mid->setIcondir("./images/");
- $mid->setDirroot("../include/php_layers_menu/");
+ $mid->setDirroot("../include/layer-menu/");
$mid->setHorizontalMenuTpl("../ihtml/".get_template_path("",FALSE).'GOsa_MultiSelectHeader.ihtml');
$mid->setSubMenuTpl("../ihtml/".get_template_path("",FALSE).'GOsa_MultiSelectHeaderSubEntry.ihtml');
$mid->setMenuStructureString($this->string_ListDropDown);
index 155ccb19fc1db405bd47a7638347f70bdb4dd811..7996d313c9b5d17597d46b5aac18461af5d0ffcf 100644 (file)
"CopyPasteHandler" => "include/class_CopyPasteHandler.inc",
"plugin" => "include/class_plugin.inc",
"glpiDB" => "include/class_glpi.inc",
- "Template_PHPLIB" => "include/php_layers_menu/lib/PHPLIB.php",
- "PHPTreeMenu" => "include/php_layers_menu/lib/phptreemenu.inc.php",
- "ProcessLayersMenu" => "include/php_layers_menu/lib/layersmenu-process.inc.php",
- "TreeMenu" => "include/php_layers_menu/lib/treemenu.inc.php",
- "LayersMenu" => "include/php_layers_menu/lib/layersmenu.inc.php",
- "LayersMenuCommon" => "include/php_layers_menu/lib/layersmenu-common.inc.php",
- "PlainMenu" => "include/php_layers_menu/lib/plainmenu.inc.php",
"acl" => "include/class_acl.inc",
"pluglist" => "include/class_pluglist.inc",
"HTML_TreeMenu" => "html/TreeMenu.php",
"sieve_discard" => "include/sieve/class_sieveElement_Discard.inc",
"My_Scanner" => "include/sieve/class_My_Scanner.inc",
"ogw" => "include/class_opengw.inc",
+ "Template_PHPLIB" => "include/layer-menu/lib/PHPLIB.php",
+ "PHPTreeMenu" => "include/layer-menu/lib/phptreemenu.inc.php",
+ "ProcessLayersMenu" => "include/layer-menu/lib/layersmenu-process.inc.php",
+ "TreeMenu" => "include/layer-menu/lib/treemenu.inc.php",
+ "LayersMenu" => "include/layer-menu/lib/layersmenu.inc.php",
+ "LayersMenuCommon" => "include/layer-menu/lib/layersmenu-common.inc.php",
+ "PlainMenu" => "include/layer-menu/lib/plainmenu.inc.php",
"gosa_cache" => "include/class_cache_handler.inc",
"Socket_Client" => "include/class_socketClient.inc",
"log" => "include/class_log.inc",
diff --git a/gosa-core/include/layer-menu/COPYING b/gosa-core/include/layer-menu/COPYING
--- /dev/null
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+\f
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+\f
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/gosa-core/include/layer-menu/lib/PHPLIB.php b/gosa-core/include/layer-menu/lib/PHPLIB.php
--- /dev/null
@@ -0,0 +1,567 @@
+<?php
+// vim: set expandtab tabstop=4 shiftwidth=4:
+// This code that was derived from the original PHPLIB Template class
+// is copyright by Kristian Koehntopp, NetUSE AG and was released
+// under the LGPL.
+//
+// Authors: Kristian Koehntopp <kris@koehntopp.de> (original from PHPLIB)
+// Bjoern Schotte <bjoern@rent-a-phpwizard.de> (PEARification)
+// Martin Jansen <mj@php.net> (PEAR conformance)
+//
+// $Id: PHPLIB.php,v 1.14 2003/06/11 06:03:32 bjoern Exp $
+//
+
+//require_once "PEAR.php";
+
+/**
+ * Converted PHPLIB Template class
+ *
+ * For those who want to use PHPLIB's fine template class,
+ * here's a PEAR conforming class with the original PHPLIB
+ * template code from phplib-stable CVS. Original author
+ * was Kristian Koehntopp <kris@koehntopp.de>
+ *
+ * @author Bjoern Schotte <bjoern@rent-a-phpwizard.de>
+ * @author Martin Jansen <mj@php.net> (PEAR conformance)
+ * @version 1.0
+ */
+class Template_PHPLIB
+{
+ /**
+ * If set, echo assignments
+ * @var bool
+ */
+ var $debug = false;
+
+ /**
+ * $file[handle] = "filename";
+ * @var array
+ */
+ var $file = array();
+
+ /**
+ * fallback paths that should be defined in a child class
+ * @var array
+ */
+ var $file_fallbacks = array();
+
+ /**
+ * Relative filenames are relative to this pathname
+ * @var string
+ */
+ var $root = "";
+
+ /*
+ * $_varKeys[key] = "key"
+ * @var array
+ */
+ var $_varKeys = array();
+
+ /**
+ * $_varVals[key] = "value";
+ * @var array
+ */
+ var $_varVals = array();
+
+ /**
+ * "remove" => remove undefined variables
+ * "comment" => replace undefined variables with comments
+ * "keep" => keep undefined variables
+ * @var string
+ */
+ var $unknowns = "remove";
+
+ /**
+ * "yes" => halt, "report" => report error, continue, "no" => ignore error quietly
+ * @var string
+ */
+ var $haltOnError = "report";
+
+ /**
+ * The last error message is retained here
+ * @var string
+ * @see halt
+ */
+ var $_lastError = "";
+
+
+ /**
+ * Constructor
+ *
+ * @access public
+ * @param string template root directory
+ * @param string how to handle unknown variables
+ * @param array fallback paths
+ */
+ function Template_PHPLIB($root = ".", $unknowns = "remove", $fallback="")
+ {
+ $this->setRoot($root);
+ $this->setUnknowns($unknowns);
+ if (is_array($fallback)) $this->file_fallbacks = $fallback;
+ }
+
+ /**
+ * Sets the template directory
+ *
+ * @access public
+ * @param string new template directory
+ * @return bool
+ */
+ function setRoot($root)
+ {
+ if (!is_dir($root)) {
+ $this->halt("setRoot: $root is not a directory.");
+ return false;
+ }
+
+ $this->root = $root;
+
+ return true;
+ }
+
+ /**
+ * What to do with unknown variables
+ *
+ * three possible values:
+ *
+ * - "remove" will remove unknown variables
+ * (don't use this if you define CSS in your page)
+ * - "comment" will replace undefined variables with comments
+ * - "keep" will keep undefined variables as-is
+ *
+ * @access public
+ * @param string unknowns
+ */
+ function setUnknowns($unknowns = "keep")
+ {
+ $this->unknowns = $unknowns;
+ }
+
+ /**
+ * Set appropriate template files
+ *
+ * With this method you set the template files you want to use.
+ * Either you supply an associative array with key/value pairs
+ * where the key is the handle for the filname and the value
+ * is the filename itself, or you define $handle as the file name
+ * handle and $filename as the filename if you want to define only
+ * one template.
+ *
+ * @access public
+ * @param mixed handle for a filename or array with handle/name value pairs
+ * @param string name of template file
+ * @return bool
+ */
+ function setFile($handle, $filename = "")
+ {
+ if (!is_array($handle)) {
+
+ if ($filename == "") {
+ $this->halt("setFile: For handle $handle filename is empty.");
+ return false;
+ }
+
+ $this->file[$handle] = $this->_filename($filename);
+
+ } else {
+
+ reset($handle);
+ while (list($h, $f) = each($handle)) {
+ $this->file[$h] = $this->_filename($f);
+ }
+ }
+ }
+
+ /**
+ * Set a block in the appropriate template handle
+ *
+ * By setting a block like that:
+ *
+ * <!-- BEGIN blockname -->
+ * html code
+ * <!-- END blockname -->
+ *
+ * you can easily do repeating HTML code, i.e. output
+ * database data nice formatted into a HTML table where
+ * each DB row is placed into a HTML table row which is
+ * defined in this block.
+ * It extracts the template $handle from $parent and places
+ * variable {$name} instead.
+ *
+ * @access public
+ * @param string parent handle
+ * @param string block name handle
+ * @param string variable substitution name
+ */
+ function setBlock($parent, $handle, $name = "")
+ {
+ if (!$this->_loadFile($parent)) {
+ $this->halt("setBlock: unable to load $parent.");
+ return false;
+ }
+
+ if ($name == "") {
+ $name = $handle;
+ }
+
+ $str = $this->getVar($parent);
+ $reg = "/[ \t]*<!--\s+BEGIN $handle\s+-->\s*?\n?(\s*.*?\n?)\s*<!--\s+END $handle\s+-->\s*?\n?/sm";
+ preg_match_all($reg, $str, $m);
+ $str = preg_replace($reg, "{" . "$name}", $str);
+
+ if (isset($m[1][0])) $this->setVar($handle, $m[1][0]);
+ $this->setVar($parent, $str);
+ }
+
+ /**
+ * Set corresponding substitutions for placeholders
+ *
+ * @access public
+ * @param string name of a variable that is to be defined or an array of variables with value substitution as key/value pairs
+ * @param string value of that variable
+ * @param boolean if true, the value is appended to the variable's existing value
+ */
+ function setVar($varname, $value = "", $append = false)
+ {
+ if (!is_array($varname)) {
+
+ if (!empty($varname))
+ if ($this->debug) print "scalar: set *$varname* to *$value*<br>\n";
+
+ $this->_varKeys[$varname] = $this->_varname($varname);
+ ($append) ? $this->_varVals[$varname] .= $value : $this->_varVals[$varname] = $value;
+
+ } else {
+ reset($varname);
+
+ while (list($k, $v) = each($varname)) {
+ if (!empty($k))
+ if ($this->debug) print "array: set *$k* to *$v*<br>\n";
+
+ $this->_varKeys[$k] = $this->_varname($k);
+ ($append) ? $this->_varVals[$k] .= $v : $this->_varVals[$k] = $v;
+ }
+ }
+ }
+
+ /**
+ * Substitute variables in handle $handle
+ *
+ * @access public
+ * @param string name of handle
+ * @return mixed string substituted content of handle
+ */
+ function subst($handle)
+ {
+ if (!$this->_loadFile($handle)) {
+ $this->halt("subst: unable to load $handle.");
+ return false;
+ }
+
+ return @str_replace($this->_varKeys, $this->_varVals, $this->getVar($handle));
+ }
+
+ /**
+ * Same as subst but printing the result
+ *
+ * @access public
+ * @brother subst
+ * @param string handle of template
+ * @return bool always false
+ */
+ function pSubst($handle)
+ {
+ print $this->subst($handle);
+ return false;
+ }
+
+ /**
+ * Parse handle into target
+ *
+ * Parses handle $handle into $target, eventually
+ * appending handle at $target if $append is defined
+ * as TRUE.
+ *
+ * @access public
+ * @param string target handle to parse into
+ * @param string which handle should be parsed
+ * @param boolean append it to $target or not?
+ * @return string parsed handle
+ */
+ function parse($target, $handle, $append = false)
+ {
+ if (!is_array($handle)) {
+ $str = $this->subst($handle);
+
+ ($append) ? $this->setVar($target, $this->getVar($target) . $str) : $this->setVar($target, $str);
+ } else {
+ reset($handle);
+
+ while (list(, $h) = each($handle)) {
+ $str = $this->subst($h);
+ $this->setVar($target, $str);
+ }
+ }
+
+ return $str;
+ }
+
+ /**
+ * Same as parse, but printing it.
+ *
+ * @access public
+ * @brother parse
+ * @param string target to parse into
+ * @param string handle which should be parsed
+ * @param should $handle be appended to $target?
+ * @return bool
+ */
+ function pParse($target, $handle, $append = false)
+ {
+ print $this->finish($this->parse($target, $handle, $append));
+ return false;
+ }
+
+ /**
+ * Return all defined variables and their values
+ *
+ * @access public
+ * @return array with all defined variables and their values
+ */
+ function getVars()
+ {
+ reset($this->_varKeys);
+
+ while (list($k, ) = each($this->_varKeys)) {
+ $result[$k] = $this->getVar($k);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Return one or more specific variable(s) with their values.
+ *
+ * @access public
+ * @param mixed array with variable names or one variable name as a string
+ * @return mixed array of variable names with their values or value of one specific variable
+ */
+ function getVar($varname)
+ {
+ if (!is_array($varname)) {
+ if (isset($this->_varVals[$varname])) {
+ return $this->_varVals[$varname];
+ } else {
+ return "";
+ }
+ } else {
+ reset($varname);
+
+ while (list($k, ) = each($varname)) {
+ $result[$k] = (isset($this->_varVals[$k])) ? $this->_varVals[$k] : "";
+ }
+
+ return $result;
+ }
+ }
+
+ /**
+ * Get undefined values of a handle
+ *
+ * @access public
+ * @param string handle name
+ * @return mixed false if an error occured or the undefined values
+ */
+ function getUndefined($handle)
+ {
+ if (!$this->_loadFile($handle)) {
+ $this->halt("getUndefined: unable to load $handle.");
+ return false;
+ }
+
+ preg_match_all("/{([^ \t\r\n}]+)}/", $this->getVar($handle), $m);
+ $m = $m[1];
+ if (!is_array($m)) {
+ return false;
+ }
+
+ reset($m);
+ while (list(, $v) = each($m)) {
+ if (!isset($this->_varKeys[$v])) {
+ $result[$v] = $v;
+ }
+ }
+
+ if (isset($result) && count($result)) {
+ return $result;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Finish string
+ *
+ * @access public
+ * @param string string to finish
+ * @return finished, i.e. substituted string
+ */
+ function finish($str)
+ {
+ switch ($this->unknowns) {
+ case "remove":
+ $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
+ break;
+
+ case "comment":
+ $str = preg_replace('/{([^ \t\r\n}]+)}/', "<!-- Template $handle: Variable \\1 undefined -->", $str);
+ break;
+ }
+
+ return $str;
+ }
+
+ /**
+ * Print variable to the browser
+ *
+ * @access public
+ * @param string name of variable to print
+ */
+ function p($varname)
+ {
+ print $this->finish($this->getVar($varname));
+ }
+
+ /**
+ * Get finished variable
+ *
+ * @access public public
+ * @param string variable to get
+ * @return string string with finished variable
+ */
+ function get($varname)
+ {
+ return $this->finish($this->getVar($varname));
+ }
+
+ /**
+ * Complete filename
+ *
+ * Complete filename, i.e. testing it for slashes
+ *
+ * @access private
+ * @param string filename to be completed
+ * @return string completed filename
+ */
+ function _filename($filename)
+ {
+// if (substr($filename, 0, 1) != "/") {
+// $filename = $this->root."/".$filename;
+// }
+
+ if (file_exists($filename)) return $filename;
+ if (is_array($this->file_fallbacks) && count($this->file_fallbacks) > 0) {
+ reset($this->file_fallbacks);
+ while (list(,$v) = each($this->file_fallbacks)) {
+ if (file_exists($v.basename($filename))) return $v.basename($filename);
+ }
+ $this->halt(sprintf("filename: file %s does not exist in the fallback paths %s.",$filename,implode(",",$this->file_fallbacks)));
+ return false;
+ } else {
+ $this->halt(sprintf("filename: file %s does not exist.",$filename));
+ return false;
+ }
+
+ return $filename;
+ }
+
+ /**
+ * Protect a replacement variable
+ *
+ * @access private
+ * @param string name of replacement variable
+ * @return string replaced variable
+ */
+ function _varname($varname)
+ {
+ return "{".$varname."}";
+ }
+
+ /**
+ * load file defined by handle if it is not loaded yet
+ *
+ * @access private
+ * @param string handle
+ * @return bool FALSE if error, true if all is ok
+ */
+ function _loadFile($handle)
+ {
+ if (isset($this->_varKeys[$handle]) and !empty($this->_varVals[$handle])) {
+ return true;
+ }
+
+ if (!isset($this->file[$handle])) {
+ $this->halt("loadfile: $handle is not a valid handle.");
+ return false;
+ }
+
+ $filename = $this->file[$handle];
+ if (function_exists("file_get_contents")) {
+ $str = file_get_contents($filename);
+ } else {
+ if (!$fp = @fopen($filename,"r")) {
+ $this->halt("loadfile: couldn't open $filename");
+ return false;
+ }
+
+ $str = fread($fp,filesize($filename));
+ fclose($fp);
+ }
+
+ if ($str=='') {
+ $this->halt("loadfile: While loading $handle, $filename does not exist or is empty.");
+ return false;
+ }
+
+ $this->setVar($handle, $str);
+
+ return true;
+ }
+
+ /**
+ * Error function. Halt template system with message to show
+ *
+ * @access public
+ * @param string message to show
+ * @return bool
+ */
+ function halt($msg)
+ {
+ $this->_lastError = $msg;
+
+ if ($this->haltOnError != "no") {
+// return $this->haltMsg($msg);
+ $this->haltMsg($msg);
+ }
+
+ if ($this->haltOnError == "yes") {
+ die("<b>Halted.</b>");
+ }
+
+ return false;
+ }
+
+ /**
+ * printf error message to show
+ *
+ * @access public
+ * @param string message to show
+ * @return object PEAR error object
+ */
+ function haltMsg($msg)
+ {
+// PEAR::raiseError(sprintf("<b>Template Error:</b> %s<br>\n", $msg));
+ printf("<b>Template Error:</b> %s<br>\n", $msg);
+ }
+}
+?>
diff --git a/gosa-core/include/layer-menu/lib/layersmenu-browser_detection.php b/gosa-core/include/layer-menu/lib/layersmenu-browser_detection.php
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+
+function inAgent($string)
+{
+ if (isset($_SERVER['HTTP_USER_AGENT'])) {
+ $http_user_agent = $_SERVER['HTTP_USER_AGENT'];
+ } else {
+ $http_user_agent = '';
+ }
+ return !(strpos($http_user_agent, $string) === false);
+}
+
+if (inAgent('Gecko')) {
+ $browser = 'Mozilla';
+} elseif (
+ inAgent('Lynx') || inAgent('lynx')
+ || inAgent('Links') || inAgent('links')
+ || inAgent('w3m')
+ ) {
+ $browser = 'TEXT';
+// I detect Konqueror and Opera before than the others,
+// as they often qualify themselves as Mozilla/Netscape/MSIE
+} elseif (inAgent('Konqueror')) {
+ if (inAgent('Konqueror 1') || inAgent('Konqueror/1')) {
+ $browser = 'Konqueror1';
+ // On KDE 1.1.2, kfm qualifies itself as "Konqueror/1.1.2"
+ // (tested on Red Hat Linux 6.2)
+ } elseif (inAgent('Konqueror 2.0') || inAgent('Konqueror/2.0')
+ || inAgent('Konqueror 2;') || inAgent('Konqueror/2;')
+ || inAgent('Konqueror 2)') || inAgent('Konqueror/2)')
+ ) {
+ $browser = 'Konqueror20';
+ } elseif (inAgent('Konqueror 2.1') || inAgent('Konqueror/2.1')) {
+ $browser = 'Konqueror21';
+ } else {
+ $browser = 'Konqueror';
+ }
+} elseif (inAgent('Opera')) {
+ if (inAgent('Opera 4') || inAgent('Opera/4')) {
+ $browser = 'Opera4';
+ // I hope that Opera 4 users can be satisfied by the Plain menu version;
+ // sorry, but I have never used Opera 4 and I do not have a copy of it
+ // to perform tests. If you are using Opera < 4, it's your problem :-P
+ } elseif ((inAgent('Opera 6') || inAgent('Opera/6')) && inAgent('Linux')) {
+ $browser = 'Opera6forLinux';
+ } elseif (
+ inAgent('Opera 5') || inAgent('Opera/5')
+ || inAgent('Opera 6') || inAgent('Opera/6')
+ ) {
+ $browser = 'Opera56';
+ } else {
+ $browser = 'Opera';
+ }
+} elseif (inAgent('Safari')) {
+ $browser = 'Safari';
+} elseif (inAgent('MSIE 4') || inAgent('MSIE/4')) {
+ $browser = 'IE4';
+} elseif (inAgent('MSIE')) {
+ $browser = 'IE5';
+ // msie != 4 is handled like msie 5+; if you are using msie 3-, it's your problem :-P
+} elseif (inAgent('Mozilla 4') || inAgent('Mozilla/4')) {
+ $browser = 'NS4';
+} else {
+ $browser = 'Unknown';
+}
+
+if (
+ $browser == 'TEXT'
+ || $browser == 'Konqueror1' || $browser == 'Konqueror20' || $browser == 'Konqueror21'
+ // IMO, on Konqueror 2.1, the Plain version is more usable than the "OLD" one
+ || $browser == 'Opera4'
+) {
+ $menuType = 'PLAIN';
+} elseif ($browser == 'NS4' || $browser == 'Opera56' || $browser == 'IE4') {
+ $menuType = 'OLD';
+} else {
+ $menuType = 'DOM';
+}
+
+?>
diff --git a/gosa-core/include/layer-menu/lib/layersmenu-common.inc.php b/gosa-core/include/layer-menu/lib/layersmenu-common.inc.php
--- /dev/null
@@ -0,0 +1,955 @@
+<?php
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+/**
+* This file contains the code of the LayersMenuCommon class.
+* @package PHPLayersMenu
+*/
+
+/**
+* This is the "common" class of the PHP Layers Menu library.
+*
+* You need to include PEAR.php and DB.php if (and only if) you want to use the DB support provided by ths class.
+*
+* @version 3.2.0-rc
+* @package PHPLayersMenu
+*/
+class LayersMenuCommon
+{
+
+/**
+* The name of the package
+* @access private
+* @var string
+*/
+var $_packageName;
+/**
+* The version of the package
+* @access private
+* @var string
+*/
+var $version;
+/**
+* The copyright of the package
+* @access private
+* @var string
+*/
+var $copyright;
+/**
+* The author of the package
+* @access private
+* @var string
+*/
+var $author;
+
+/**
+* URL to be prepended to the menu hrefs
+* @access private
+* @var string
+*/
+var $prependedUrl = '';
+/**
+* Do you want that code execution halts on error?
+* @access private
+* @var string
+*/
+var $haltOnError = 'yes';
+
+/**
+* The base directory where the package is installed
+* @access private
+* @var string
+*/
+var $dirroot;
+/**
+* The "libjs" directory of the package
+* @access private
+* @var string
+*/
+var $libjsdir;
+/**
+* The directory where images related to the menu can be found
+* @access private
+* @var string
+*/
+var $imgdir;
+/**
+* The http path corresponding to imgdir
+* @access private
+* @var string
+*/
+var $imgwww;
+/**
+* The directory where icons of menu items can be found
+* @access private
+* @var string
+*/
+var $icondir;
+/**
+* The http path corresponding to icondir
+* @access private
+* @var string
+*/
+var $iconwww;
+/**
+* This array may contain width and height of all icons
+* @access private
+* @var integer
+*/
+var $iconsize = array();
+/**
+* If this var is false, width and height of icons have to be detected; if this var is true, width and height of icons are not detected and are retrieved from the iconsize array
+* @access private
+* @var boolean
+*/
+var $issetIconsize = false;
+/**
+* The directory where templates can be found
+* @access private
+* @var string
+*/
+var $tpldir;
+/**
+* The string containing the menu structure
+* @access private
+* @var string
+*/
+var $menuStructure;
+
+/**
+* It counts nodes for all menus
+* @access private
+* @var integer
+*/
+var $_nodesCount;
+/**
+* A multi-dimensional array to store informations for each menu entry
+* @access private
+* @var array
+*/
+var $tree;
+/**
+* A multi-dimensional array used only with the DB support; for each $menu_name, it stores the $cnt associated to each item id
+*
+* This array is needed for selection of the current item
+* through the corresponding id (see the DB table structure)
+* as, internally, items are stored, sorted and addressed in terms of $cnt
+*
+* @access private
+* @var array
+*/
+var $treecnt;
+/**
+* The maximum hierarchical level of menu items
+* @access private
+* @var integer
+*/
+var $_maxLevel;
+/**
+* An array that counts the number of first level items for each menu
+* @access private
+* @var array
+*/
+var $_firstLevelCnt;
+/**
+* An array containing the number identifying the first item of each menu
+* @access private
+* @var array
+*/
+var $_firstItem;
+/**
+* An array containing the number identifying the last item of each menu
+* @access private
+* @var array
+*/
+var $_lastItem;
+
+/**
+* Data Source Name: the connection string for PEAR DB
+* @access private
+* @var string
+*/
+var $dsn = 'pgsql://dbuser:dbpass@dbhost/dbname';
+/**
+* DB connections are either persistent or not persistent
+* @access private
+* @var boolean
+*/
+var $persistent = false;
+/**
+* Name of the table storing data describing the menu
+* @access private
+* @var string
+*/
+var $tableName = 'phplayersmenu';
+/**
+* Name of the i18n table corresponding to $tableName
+* @access private
+* @var string
+*/
+var $tableName_i18n = 'phplayersmenu_i18n';
+/**
+* Names of fields of the table storing data describing the menu
+*
+* default field names correspond to the same field names foreseen
+* by the menu structure format
+*
+* @access private
+* @var array
+*/
+var $tableFields = array(
+ 'id' => 'id',
+ 'parent_id' => 'parent_id',
+ 'text' => 'text',
+ 'href' => 'href',
+ 'title' => 'title',
+ 'icon' => 'icon',
+ 'target' => 'target',
+ 'orderfield' => 'orderfield',
+ 'expanded' => 'expanded'
+);
+/**
+* Names of fields of the i18n table corresponding to $tableName
+* @access private
+* @var array
+*/
+var $tableFields_i18n = array(
+ 'language' => 'language',
+ 'id' => 'id',
+ 'text' => 'text',
+ 'title' => 'title'
+);
+/**
+* A temporary array to store data retrieved from the DB and to perform the depth-first search
+* @access private
+* @var array
+*/
+var $_tmpArray = array();
+
+/**
+* The constructor method; it initializates the menu system
+* @return void
+*/
+function LayersMenuCommon()
+{
+ $this->_packageName = 'PHP Layers Menu';
+ $this->version = '3.2.0-rc';
+ $this->copyright = '(C) 2001-2004';
+ $this->author = 'Marco Pratesi - http://www.marcopratesi.it/';
+
+ $this->prependedUrl = '';
+
+ $this->dirroot = './';
+ $this->libjsdir = './libjs/';
+ $this->imgdir = './menuimages/';
+ $this->imgwww = 'menuimages/';
+ $this->icondir = './menuicons/';
+ $this->iconwww = 'menuicons/';
+ $this->tpldir = './templates/';
+ $this->menuStructure = '';
+ $this->separator = '|';
+
+ $this->_nodesCount = 0;
+ $this->tree = array();
+ $this->treecnt = array();
+ $this->_maxLevel = array();
+ $this->_firstLevelCnt = array();
+ $this->_firstItem = array();
+ $this->_lastItem = array();
+}
+
+/**
+* The method to set the prepended URL
+* @access public
+* @return boolean
+*/
+function setPrependedUrl($prependedUrl)
+{
+ // We do not perform any check
+ $this->prependedUrl = $prependedUrl;
+ return true;
+}
+
+/**
+* The method to set the dirroot directory
+* @access public
+* @return boolean
+*/
+function setDirrootCommon($dirroot)
+{
+ if (!is_dir($dirroot)) {
+ $this->error("setDirroot: $dirroot is not a directory.");
+ return false;
+ }
+ if (substr($dirroot, -1) != '/') {
+ $dirroot .= '/';
+ }
+ $oldlength = strlen($this->dirroot);
+ $foobar = strpos($this->libjsdir, $this->dirroot);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->libjsdir = $dirroot . substr($this->libjsdir, $oldlength);
+ }
+ $foobar = strpos($this->imgdir, $this->dirroot);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->imgdir = $dirroot . substr($this->imgdir, $oldlength);
+ }
+ $foobar = strpos($this->icondir, $this->dirroot);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->icondir = $dirroot . substr($this->icondir, $oldlength);
+ }
+ $foobar = strpos($this->tpldir, $this->dirroot);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->tpldir = $dirroot . substr($this->tpldir, $oldlength);
+ }
+ $this->dirroot = $dirroot;
+ return true;
+}
+
+/**
+* The method to set the libjsdir directory
+* @access public
+* @return boolean
+*/
+function setLibjsdir($libjsdir)
+{
+ if ($libjsdir != '' && substr($libjsdir, -1) != '/') {
+ $libjsdir .= '/';
+ }
+ if ($libjsdir == '' || substr($libjsdir, 0, 1) != '/') {
+ $foobar = strpos($libjsdir, $this->dirroot);
+ if ($foobar === false || $foobar != 0) {
+ $libjsdir = $this->dirroot . $libjsdir;
+ }
+ }
+ if (!is_dir($libjsdir)) {
+ $this->error("setLibjsdir: $libjsdir is not a directory.");
+ return false;
+ }
+ $this->libjsdir = $libjsdir;
+ return true;
+}
+
+/**
+* The method to set the imgdir directory
+* @access public
+* @return boolean
+*/
+function setImgdir($imgdir)
+{
+ if ($imgdir != '' && substr($imgdir, -1) != '/') {
+ $imgdir .= '/';
+ }
+ if ($imgdir == '' || substr($imgdir, 0, 1) != '/') {
+ $foobar = strpos($imgdir, $this->dirroot);
+ if ($foobar === false || $foobar != 0) {
+ $imgdir = $this->dirroot . $imgdir;
+ }
+ }
+ if (!is_dir($imgdir)) {
+ $this->error("setImgdir: $imgdir is not a directory.");
+ return false;
+ }
+ $this->imgdir = $imgdir;
+ return true;
+}
+
+/**
+* The method to set imgwww
+* @access public
+* @return void
+*/
+function setImgwww($imgwww)
+{
+ if ($imgwww != '' && substr($imgwww, -1) != '/') {
+ $imgwww .= '/';
+ }
+ $this->imgwww = $imgwww;
+}
+
+/**
+* The method to set the icondir directory
+* @access public
+* @return boolean
+*/
+function setIcondir($icondir)
+{
+ if ($icondir != '' && substr($icondir, -1) != '/') {
+ $icondir .= '/';
+ }
+ if ($icondir == '' || substr($icondir, 0, 1) != '/') {
+ $foobar = strpos($icondir, $this->dirroot);
+ if ($foobar === false || $foobar != 0) {
+ $icondir = $this->dirroot . $icondir;
+ }
+ }
+ if (!is_dir($icondir)) {
+ $this->error("setIcondir: $icondir is not a directory.");
+ return false;
+ }
+ $this->icondir = $icondir;
+ return true;
+}
+
+/**
+* The method to set iconwww
+* @access public
+* @return void
+*/
+function setIconwww($iconwww)
+{
+ if ($iconwww != '' && substr($iconwww, -1) != '/') {
+ $iconwww .= '/';
+ }
+ $this->iconwww = $iconwww;
+}
+
+/**
+* The method to set the iconsize array
+* @access public
+* @return void
+*/
+function setIconsize($width, $height)
+{
+ $this->iconsize['width'] = ($width == (int) $width) ? $width : 0;
+ $this->iconsize['height'] = ($height == (int) $height) ? $height : 0;
+ $this->issetIconsize = true;
+}
+
+/**
+* The method to unset the iconsize array
+* @access public
+* @return void
+*/
+function unsetIconsize()
+{
+ unset($this->iconsize['width']);
+ unset($this->iconsize['height']);
+ $this->issetIconsize = false;
+}
+
+/**
+* The method to set the tpldir directory
+* @access public
+* @return boolean
+*/
+function setTpldirCommon($tpldir)
+{
+ if ($tpldir != '' && substr($tpldir, -1) != '/') {
+ $tpldir .= '/';
+ }
+ if ($tpldir == '' || substr($tpldir, 0, 1) != '/') {
+ $foobar = strpos($tpldir, $this->dirroot);
+ if ($foobar === false || $foobar != 0) {
+ $tpldir = $this->dirroot . $tpldir;
+ }
+ }
+ if (!is_dir($tpldir)) {
+ $this->error("setTpldir: $tpldir is not a directory.");
+ return false;
+ }
+ $this->tpldir = $tpldir;
+ return true;
+}
+
+/**
+* The method to read the menu structure from a file
+* @access public
+* @param string $tree_file the menu structure file
+* @return boolean
+*/
+function setMenuStructureFile($tree_file)
+{
+ if (!($fd = fopen($tree_file, 'r'))) {
+ $this->error("setMenuStructureFile: unable to open file $tree_file.");
+ return false;
+ }
+ $this->menuStructure = '';
+ while ($buffer = fgets($fd, 4096)) {
+ $buffer = ereg_replace(chr(13), '', $buffer); // Microsoft Stupidity Suppression
+ $this->menuStructure .= $buffer;
+ }
+ fclose($fd);
+ if ($this->menuStructure == '') {
+ $this->error("setMenuStructureFile: $tree_file is empty.");
+ return false;
+ }
+ return true;
+}
+
+/**
+* The method to set the menu structure passing it through a string
+* @access public
+* @param string $tree_string the menu structure string
+* @return boolean
+*/
+function setMenuStructureString($tree_string)
+{
+ $this->menuStructure = ereg_replace(chr(13), '', $tree_string); // Microsoft Stupidity Suppression
+ if ($this->menuStructure == '') {
+ $this->error('setMenuStructureString: empty string.');
+ return false;
+ }
+ return true;
+}
+
+/**
+* The method to set the value of separator
+* @access public
+* @return void
+*/
+function setSeparator($separator)
+{
+ $this->separator = $separator;
+}
+
+/**
+* The method to set parameters for the DB connection
+* @access public
+* @param string $dns Data Source Name: the connection string for PEAR DB
+* @param bool $persistent DB connections are either persistent or not persistent
+* @return boolean
+*/
+function setDBConnParms($dsn, $persistent=false)
+{
+ if (!is_string($dsn)) {
+ $this->error('initdb: $dsn is not an string.');
+ return false;
+ }
+ if (!is_bool($persistent)) {
+ $this->error('initdb: $persistent is not a boolean.');
+ return false;
+ }
+ $this->dsn = $dsn;
+ $this->persistent = $persistent;
+ return true;
+}
+
+/**
+* The method to set the name of the table storing data describing the menu
+* @access public
+* @param string
+* @return boolean
+*/
+function setTableName($tableName)
+{
+ if (!is_string($tableName)) {
+ $this->error('setTableName: $tableName is not a string.');
+ return false;
+ }
+ $this->tableName = $tableName;
+ return true;
+}
+
+/**
+* The method to set the name of the i18n table corresponding to $tableName
+* @access public
+* @param string
+* @return boolean
+*/
+function setTableName_i18n($tableName_i18n)
+{
+ if (!is_string($tableName_i18n)) {
+ $this->error('setTableName_i18n: $tableName_i18n is not a string.');
+ return false;
+ }
+ $this->tableName_i18n = $tableName_i18n;
+ return true;
+}
+
+/**
+* The method to set names of fields of the table storing data describing the menu
+* @access public
+* @param array
+* @return boolean
+*/
+function setTableFields($tableFields)
+{
+ if (!is_array($tableFields)) {
+ $this->error('setTableFields: $tableFields is not an array.');
+ return false;
+ }
+ if (count($tableFields) == 0) {
+ $this->error('setTableFields: $tableFields is a zero-length array.');
+ return false;
+ }
+ reset ($tableFields);
+ while (list($key, $value) = each($tableFields)) {
+ $this->tableFields[$key] = ($value == '') ? "''" : $value;
+ }
+ return true;
+}
+
+/**
+* The method to set names of fields of the i18n table corresponding to $tableName
+* @access public
+* @param array
+* @return boolean
+*/
+function setTableFields_i18n($tableFields_i18n)
+{
+ if (!is_array($tableFields_i18n)) {
+ $this->error('setTableFields_i18n: $tableFields_i18n is not an array.');
+ return false;
+ }
+ if (count($tableFields_i18n) == 0) {
+ $this->error('setTableFields_i18n: $tableFields_i18n is a zero-length array.');
+ return false;
+ }
+ reset ($tableFields_i18n);
+ while (list($key, $value) = each($tableFields_i18n)) {
+ $this->tableFields_i18n[$key] = ($value == '') ? "''" : $value;
+ }
+ return true;
+}
+
+/**
+* The method to parse the current menu structure and correspondingly update related variables
+* @access public
+* @param string $menu_name the name to be attributed to the menu
+* whose structure has to be parsed
+* @return void
+*/
+function parseStructureForMenu(
+ $menu_name = '' // non consistent default...
+ )
+{
+ $this->_maxLevel[$menu_name] = 0;
+ $this->_firstLevelCnt[$menu_name] = 0;
+ $this->_firstItem[$menu_name] = $this->_nodesCount + 1;
+ $cnt = $this->_firstItem[$menu_name];
+ $menuStructure = $this->menuStructure;
+
+ /* *********************************************** */
+ /* Partially based on a piece of code taken from */
+ /* TreeMenu 1.1 - Bjorge Dijkstra (bjorge@gmx.net) */
+ /* *********************************************** */
+
+ while ($menuStructure != '') {
+ $before_cr = strcspn($menuStructure, "\n");
+ $buffer = substr($menuStructure, 0, $before_cr);
+ $menuStructure = substr($menuStructure, $before_cr+1);
+ if (substr($buffer, 0, 1) == '#') {
+ continue; // commented item line...
+ }
+ $tmp = rtrim($buffer);
+ $node = explode($this->separator, $tmp);
+ for ($i=count($node); $i<=6; $i++) {
+ $node[$i] = '';
+ }
+ $this->tree[$cnt]['level'] = strlen($node[0]);
+ $this->tree[$cnt]['text'] = $node[1];
+ $this->tree[$cnt]['href'] = $node[2];
+ $this->tree[$cnt]['title'] = $node[3];
+ $this->tree[$cnt]['icon'] = $node[4];
+ $this->tree[$cnt]['target'] = $node[5];
+ $this->tree[$cnt]['expanded'] = $node[6];
+ $cnt++;
+ }
+
+ /* *********************************************** */
+
+ $this->_lastItem[$menu_name] = count($this->tree);
+ $this->_nodesCount = $this->_lastItem[$menu_name];
+ $this->tree[$this->_lastItem[$menu_name]+1]['level'] = 0;
+ $this->_postParse($menu_name);
+}
+
+/**
+* The method to parse the current menu table and correspondingly update related variables
+* @access public
+* @param string $menu_name the name to be attributed to the menu
+* whose structure has to be parsed
+* @param string $language i18n language; either omit it or pass
+* an empty string ('') if you do not want to use any i18n table
+* @return void
+*/
+function scanTableForMenu(
+ $menu_name = '', // non consistent default...
+ $language = ''
+ )
+{
+ $this->_maxLevel[$menu_name] = 0;
+ $this->_firstLevelCnt[$menu_name] = 0;
+ unset($this->tree[$this->_nodesCount+1]);
+ $this->_firstItem[$menu_name] = $this->_nodesCount + 1;
+/* BEGIN BENCHMARK CODE
+$time_start = $this->_getmicrotime();
+/* END BENCHMARK CODE */
+ $db = DB::connect($this->dsn, $this->persistent);
+ if (DB::isError($db)) {
+ $this->error('scanTableForMenu: ' . $db->getMessage());
+ }
+ $dbresult = $db->query('
+ SELECT ' .
+ $this->tableFields['id'] . ' AS id, ' .
+ $this->tableFields['parent_id'] . ' AS parent_id, ' .
+ $this->tableFields['text'] . ' AS text, ' .
+ $this->tableFields['href'] . ' AS href, ' .
+ $this->tableFields['title'] . ' AS title, ' .
+ $this->tableFields['icon'] . ' AS icon, ' .
+ $this->tableFields['target'] . ' AS target, ' .
+ $this->tableFields['expanded'] . ' AS expanded
+ FROM ' . $this->tableName . '
+ WHERE ' . $this->tableFields['id'] . ' <> 1
+ ORDER BY ' . $this->tableFields['orderfield'] . ', ' . $this->tableFields['text'] . ' ASC
+ ');
+ $this->_tmpArray = array();
+ while ($dbresult->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+ $this->_tmpArray[$row['id']]['parent_id'] = $row['parent_id'];
+ $this->_tmpArray[$row['id']]['text'] = $row['text'];
+ $this->_tmpArray[$row['id']]['href'] = $row['href'];
+ $this->_tmpArray[$row['id']]['title'] = $row['title'];
+ $this->_tmpArray[$row['id']]['icon'] = $row['icon'];
+ $this->_tmpArray[$row['id']]['target'] = $row['target'];
+ $this->_tmpArray[$row['id']]['expanded'] = $row['expanded'];
+ }
+ if ($language != '') {
+ $dbresult = $db->query('
+ SELECT ' .
+ $this->tableFields_i18n['id'] . ' AS id, ' .
+ $this->tableFields_i18n['text'] . ' AS text, ' .
+ $this->tableFields_i18n['title'] . ' AS title
+ FROM ' . $this->tableName_i18n . '
+ WHERE ' . $this->tableFields_i18n['id'] . ' <> 1
+ AND ' . $this->tableFields_i18n['language'] . ' = ' . "'$language'" . '
+ ');
+ while ($dbresult->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+ if (isset($this->_tmpArray[$row['id']])) {
+ $this->_tmpArray[$row['id']]['text'] = $row['text'];
+ $this->_tmpArray[$row['id']]['title'] = $row['title'];
+ }
+ }
+ }
+ unset($dbresult);
+ unset($row);
+ $this->_depthFirstSearch($menu_name, $this->_tmpArray, 1, 1);
+/* BEGIN BENCHMARK CODE
+$time_end = $this->_getmicrotime();
+$time = $time_end - $time_start;
+print "TIME ELAPSED = $time\n<br>";
+/* END BENCHMARK CODE */
+ $this->_lastItem[$menu_name] = count($this->tree);
+ $this->_nodesCount = $this->_lastItem[$menu_name];
+ $this->tree[$this->_lastItem[$menu_name]+1]['level'] = 0;
+ $this->_postParse($menu_name);
+}
+
+function _getmicrotime()
+{
+ list($usec, $sec) = explode(' ', microtime());
+ return ((float) $usec + (float) $sec);
+}
+
+/**
+* Recursive method to perform the depth-first search of the tree data taken from the current menu table
+* @access private
+* @param string $menu_name the name to be attributed to the menu
+* whose structure has to be parsed
+* @param array $tmpArray the temporary array that stores data to perform
+* the depth-first search
+* @param integer $parent_id id of the item whose children have
+* to be searched for
+* @param integer $level the hierarchical level of children to be searched for
+* @return void
+*/
+function _depthFirstSearch($menu_name, $tmpArray, $parent_id=1, $level=1)
+{
+ reset ($tmpArray);
+ while (list($id, $foobar) = each($tmpArray)) {
+ if ($foobar['parent_id'] == $parent_id) {
+ unset($tmpArray[$id]);
+ unset($this->_tmpArray[$id]);
+ $cnt = count($this->tree) + 1;
+ $this->tree[$cnt]['level'] = $level;
+ $this->tree[$cnt]['text'] = $foobar['text'];
+ $this->tree[$cnt]['href'] = $foobar['href'];
+ $this->tree[$cnt]['title'] = $foobar['title'];
+ $this->tree[$cnt]['icon'] = $foobar['icon'];
+ $this->tree[$cnt]['target'] = $foobar['target'];
+ $this->tree[$cnt]['expanded'] = $foobar['expanded'];
+ $this->treecnt[$menu_name][$id] = $cnt;
+ unset($foobar);
+ if ($id != $parent_id) {
+ $this->_depthFirstSearch($menu_name, $this->_tmpArray, $id, $level+1);
+ }
+ }
+ }
+}
+
+/**
+* A method providing parsing needed after both file/string parsing and DB table parsing
+* @access private
+* @param string $menu_name the name of the menu for which the parsing
+* has to be performed
+* @return void
+*/
+function _postParse(
+ $menu_name = '' // non consistent default...
+ )
+{
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
+ $this->tree[$cnt]['child_of_root_node'] = ($this->tree[$cnt]['level'] == 1);
+ $this->tree[$cnt]['parsed_text'] = stripslashes($this->tree[$cnt]['text']);
+ $this->tree[$cnt]['parsed_href'] = (ereg_replace(' ', '', $this->tree[$cnt]['href']) == '') ? '#' : $this->prependedUrl . $this->tree[$cnt]['href'];
+ $this->tree[$cnt]['parsed_title'] = ($this->tree[$cnt]['title'] == '') ? '' : ' title="' . stripslashes($this->tree[$cnt]['title']) . '"';
+ $fooimg = $this->icondir . $this->tree[$cnt]['icon'];
+ if ($this->tree[$cnt]['icon'] != '' && (substr($this->tree[$cnt]['icon'], 0, 7) == 'http://' || substr($this->tree[$cnt]['icon'], 0, 8) == 'https://')) {
+ $this->tree[$cnt]['parsed_icon'] = $this->tree[$cnt]['icon'];
+ if ($this->issetIconsize) {
+ $this->tree[$cnt]['iconwidth'] = $this->iconsize['width'];
+ $this->tree[$cnt]['iconheight'] = $this->iconsize['height'];
+ } else {
+ $foobar = getimagesize($this->tree[$cnt]['icon']);
+ $this->tree[$cnt]['iconwidth'] = $foobar[0];
+ $this->tree[$cnt]['iconheight'] = $foobar[1];
+ }
+ } elseif ($this->tree[$cnt]['icon'] != '' && file_exists($fooimg)) {
+ $this->tree[$cnt]['parsed_icon'] = $this->iconwww . $this->tree[$cnt]['icon'];
+ if ($this->issetIconsize) {
+ $this->tree[$cnt]['iconwidth'] = $this->iconsize['width'];
+ $this->tree[$cnt]['iconheight'] = $this->iconsize['height'];
+ } else {
+ $foobar = getimagesize($fooimg);
+ $this->tree[$cnt]['iconwidth'] = $foobar[0];
+ $this->tree[$cnt]['iconheight'] = $foobar[1];
+ }
+ } else {
+ $this->tree[$cnt]['parsed_icon'] = '';
+ }
+ $this->tree[$cnt]['parsed_target'] = ($this->tree[$cnt]['target'] == '') ? '' : ' target="' . $this->tree[$cnt]['target'] . '"';
+// $this->tree[$cnt]['expanded'] = ($this->tree[$cnt]['expanded'] == '') ? 0 : $this->tree[$cnt]['expanded'];
+ $this->_maxLevel[$menu_name] = max($this->_maxLevel[$menu_name], $this->tree[$cnt]['level']);
+ if ($this->tree[$cnt]['level'] == 1) {
+ $this->_firstLevelCnt[$menu_name]++;
+ }
+ }
+}
+
+/**
+* A method to replace strings in all URLs (hrefs) of a menu
+* @access public
+* @param string $menu_name the name of the menu for which the replacement
+* has to be performed
+* @param string $string the string to be replaced
+* @param string $value the replacement string
+* @return void
+*/
+function replaceStringInUrls($menu_name, $string, $value)
+{
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
+ $this->tree[$cnt]['parsed_href'] = str_replace($string, $value, $this->tree[$cnt]['parsed_href']);
+ }
+}
+
+/**
+* A method to set the same target for all links of a menu
+* @access public
+* @param string $menu_name the name of the menu for which the targets
+* have to be set
+* @param string $target the target to be set for all links
+* of the $menu_name menu
+* @return void
+*/
+function setLinksTargets($menu_name, $target)
+{
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
+ $this->tree[$cnt]['parsed_target'] = ' target="' . $target . '"';
+ }
+}
+
+/**
+* A method to select the current item of $menu_name in terms of $cnt, i.e., very likely, in terms of its line number in the corresponding menu structure file (excluding from the count commented out lines, if any)
+* @access public
+* @param string $menu_name the name of the menu for which the current item
+* has to be selected
+* @param integer $count the line number of the current item
+* in the corresponding menu structure file
+* (excluding from the count commented out lines, if any)
+* @return void
+*/
+function setSelectedItemByCount($menu_name, $count)
+{
+ if ($count < 1) {
+ $this->error("setSelectedItemByCount: the \$count argument is $count, but \$count can not be lower than 1");
+ return;
+ }
+ if ($count > $this->_lastItem[$menu_name] - $this->_firstItem[$menu_name] + 1) {
+ $this->error("setSelectedItemByCount: the \$count argument is $count and is larger than the number of items of the '$menu_name' menu");
+ return;
+ }
+ $cnt = $this->_firstItem[$menu_name] + $count - 1;
+ $this->tree[$cnt]['selected'] = true;
+}
+
+/**
+* A method to select the current item of $menu_name in terms of the corresponding id (see the DB table structure); obviously, this method can be used only together with the DB support
+* @access public
+* @param string $menu_name the name of the menu for which the current item
+* has to be selected
+* @param integer $id the id of the current item in the corresponding DB table
+* @return void
+*/
+function setSelectedItemById($menu_name, $id)
+{
+ if (!isset($this->treecnt[$menu_name][$id])) {
+ $this->error("setSelectedItemById: there is not any item with \$id = $id in the '$menu_name' menu");
+ return;
+ }
+ $cnt = $this->treecnt[$menu_name][$id];
+ $this->tree[$cnt]['selected'] = true;
+}
+
+/**
+* A method to select the current item of $menu_name specifying a string that occurs in the current URL
+* @access public
+* @param string $menu_name the name of the menu for which the current item
+* has to be selected
+* @param string $url a string that occurs in the current URL
+* @return void
+*/
+function setSelectedItemByUrl($menu_name, $url)
+{
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
+ if (!(strpos($this->tree[$cnt]['parsed_href'], $url) === false)) {
+ $this->tree[$cnt]['selected'] = true;
+ break;
+ }
+ }
+}
+
+/**
+* A method to select the current item of $menu_name specifying a regular expression that matches (a substring of) the current URL; just the same as the setSelectedItemByUrl() method, but using eregi() instead of strpos()
+* @access public
+* @param string $menu_name the name of the menu for which the current item
+* has to be selected
+* @param string $url_eregi the regular expression that matches
+* (a substring of) the current URL
+* @return void
+*/
+function setSelectedItemByUrlEregi($menu_name, $url_eregi)
+{
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
+ if (eregi($url_eregi, $this->tree[$cnt]['parsed_href'])) {
+ $this->tree[$cnt]['selected'] = true;
+ break;
+ }
+ }
+}
+
+/**
+* Method to handle errors
+* @access private
+* @param string $errormsg the error message
+* @return void
+*/
+function error($errormsg)
+{
+ print "<b>LayersMenu Error:</b> $errormsg<br />\n";
+ if ($this->haltOnError == 'yes') {
+ die("<b>Halted.</b><br />\n");
+ }
+}
+
+} /* END OF CLASS */
+
+?>
diff --git a/gosa-core/include/layer-menu/lib/layersmenu-process.inc.php b/gosa-core/include/layer-menu/lib/layersmenu-process.inc.php
--- /dev/null
@@ -0,0 +1,158 @@
+<?php
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+/**
+* This file contains the code of the ProcessLayersMenu class.
+* @package PHPLayersMenu
+*/
+
+/**
+* This is an extension of the "common" class of the PHP Layers Menu library.
+*
+* It provides methods useful to process/convert menus data, e.g. to output a menu structure and a DB SQL dump corresponding to already parsed data and hence also to convert a menu structure file to a DB SQL dump and viceversa
+*
+* @version 3.2.0-rc
+* @package PHPLayersMenu
+*/
+class ProcessLayersMenu extends LayersMenuCommon
+{
+
+/**
+* The constructor method
+* @return void
+*/
+function ProcessLayersMenu()
+{
+ $this->LayersMenuCommon();
+}
+
+/**
+* The method to set the dirroot directory
+* @access public
+* @return boolean
+*/
+function setDirroot($dirroot)
+{
+ return $this->setDirrootCommon($dirroot);
+}
+
+/**
+* Method to output a menu structure corresponding to items of a menu
+* @access public
+* @param string $menu_name the name of the menu for which a menu structure
+* has to be returned
+* @param string $separator the character used in the menu structure format
+* to separate fields of each item
+* @return string
+*/
+function getMenuStructure(
+ $menu_name = '', // non consistent default...
+ $separator = '|'
+ )
+{
+ $menuStructure = '';
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the menu
+ $menuStructure .= str_repeat('.', $this->tree[$cnt]['level']);
+ $menuStructure .= $separator;
+ $menuStructure .= $this->tree[$cnt]['text'];
+ $menuStructure .= $separator;
+ $menuStructure .= $this->tree[$cnt]['href'];
+ $menuStructure .= $separator;
+ $menuStructure .= $this->tree[$cnt]['title'];
+ $menuStructure .= $separator;
+ $menuStructure .= $this->tree[$cnt]['icon'];
+ $menuStructure .= $separator;
+ $menuStructure .= $this->tree[$cnt]['target'];
+ $menuStructure .= $separator;
+ $menuStructure .= $this->tree[$cnt]['expanded'];
+ $menuStructure .= "\n";
+ }
+ return $menuStructure;
+}
+
+/**
+* Method to output a DB SQL dump corresponding to items of a menu
+* @access public
+* @param string $menu_name the name of the menu for which a DB SQL dump
+* has to be returned
+* @param string $db_type the type of DB to dump for;
+* leave it either empty or not specified if you are using PHP < 5,
+* as sqlite_escape_string() has been added in PHP 5;
+* it has to be specified and set to 'sqlite' only if the dump
+* has to be prepared for SQLite; it is not significant if != 'sqlite'
+* @return string
+*/
+function getSQLDump(
+ $menu_name = '', // non consistent default...
+ $db_type = ''
+ )
+{
+ $SQLDump = '';
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the menu
+ $current_node[$this->tree[$cnt]['level']] = $cnt;
+ if (!$this->tree[$cnt]['child_of_root_node']) {
+ $this->tree[$cnt]['father_node'] = $current_node[$this->tree[$cnt]['level']-1];
+ }
+ $VALUES = '';
+ $SQLDump .= 'INSERT INTO ';
+ $SQLDump .= $this->tableName;
+ $SQLDump .= ' (';
+ $SQLDump .= $this->tableFields['id'] . ', ';
+ $VALUES .= "'" . 10*$cnt . "', ";
+ $SQLDump .= $this->tableFields['parent_id'] . ', ';
+ if (isset($this->tree[$cnt]['father_node']) && $this->tree[$cnt]['father_node'] != 0) {
+ $VALUES .= "'" . 10*$this->tree[$cnt]['father_node'] . "', ";
+ } else {
+ $VALUES .= "'1', ";
+ }
+ $SQLDump .= $this->tableFields['text'] . ', ';
+ $foobar = $this->tree[$cnt]['text'];
+ if ($foobar != '') {
+ if ($db_type != 'sqlite') {
+ $foobar = addslashes($foobar);
+ } else {
+ $foobar = sqlite_escape_string($foobar);
+ }
+ }
+ $VALUES .= "'$foobar', ";
+ $SQLDump .= $this->tableFields['href'] . ', ';
+ $VALUES .= "'" . $this->tree[$cnt]['href'] . "', ";
+ if ($this->tableFields['title'] != "''") {
+ $SQLDump .= $this->tableFields['title'] . ', ';
+ $foobar = $this->tree[$cnt]['title'];
+ if ($foobar != '') {
+ if ($db_type != 'sqlite') {
+ $foobar = addslashes($foobar);
+ } else {
+ $foobar = sqlite_escape_string($foobar);
+ }
+ }
+ $VALUES .= "'$foobar', ";
+ }
+ if ($this->tableFields['icon'] != "''") {
+ $SQLDump .= $this->tableFields['icon'] . ', ';
+ $VALUES .= "'" . $this->tree[$cnt]['icon'] . "', ";
+ }
+ if ($this->tableFields['target'] != "''") {
+ $SQLDump .= $this->tableFields['target'] . ', ';
+ $VALUES .= "'" . $this->tree[$cnt]['target'] . "', ";
+ }
+ if ($this->tableFields['orderfield'] != "''") {
+ $SQLDump .= $this->tableFields['orderfield'] . ', ';
+ $VALUES .= "'" . 10*$cnt . "', ";
+ }
+ if ($this->tableFields['expanded'] != "''") {
+ $SQLDump .= $this->tableFields['expanded'] . ', ';
+ $this->tree[$cnt]['expanded'] = (int) $this->tree[$cnt]['expanded'];
+ $VALUES .= "'" . $this->tree[$cnt]['expanded'] . "', ";
+ }
+ $SQLDump = substr($SQLDump, 0, -2);
+ $VALUES = substr($VALUES, 0, -2);
+ $SQLDump .= ") VALUES ($VALUES);\n";
+ }
+ return $SQLDump;
+}
+
+} /* END OF CLASS */
+
+?>
diff --git a/gosa-core/include/layer-menu/lib/layersmenu.inc.php b/gosa-core/include/layer-menu/lib/layersmenu.inc.php
--- /dev/null
@@ -0,0 +1,942 @@
+<?php
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+/**
+* This file contains the code of the LayersMenu class.
+* @package PHPLayersMenu
+*/
+
+/**
+* This is the LayersMenu class of the PHP Layers Menu library.
+*
+* This class depends on the LayersMenuCommon class and on the PEAR conforming version of the PHPLib Template class, i.e. on HTML_Template_PHPLIB
+*
+* @version 3.2.0-rc
+* @package PHPLayersMenu
+*/
+class LayersMenu extends LayersMenuCommon
+{
+
+/**
+* The template to be used for the first level menu of a horizontal menu.
+*
+* The value of this variable is significant only when preparing
+* a horizontal menu.
+*
+* @access private
+* @var string
+*/
+var $horizontalMenuTpl;
+/**
+* The template to be used for the first level menu of a vertical menu.
+*
+* The value of this variable is significant only when preparing
+* a vertical menu.
+*
+* @access private
+* @var string
+*/
+var $verticalMenuTpl;
+/**
+* The template to be used for submenu layers
+* @access private
+* @var string
+*/
+var $subMenuTpl;
+
+/**
+* A string containing the header needed to use the menu(s) in the page
+* @access private
+* @var string
+*/
+var $header;
+/**
+* This var tells if the header has been made or not
+* @access private
+* @var boolean
+*/
+var $_headerHasBeenMade = false;
+/**
+* The JS vector to list layers
+* @access private
+* @var string
+*/
+var $listl;
+/**
+* The JS vector of keys to know the father of each layer
+* @access private
+* @var string
+*/
+var $father_keys;
+/**
+* The JS vector of vals to know the father of each layer
+* @access private
+* @var string
+*/
+var $father_vals;
+/**
+* The JS function to set initial positions of all layers
+* @access private
+* @var string
+*/
+var $moveLayers;
+/**
+* An array containing the code related to the first level menu of each menu
+* @access private
+* @var array
+*/
+var $_firstLevelMenu;
+/**
+* A string containing the footer needed to use the menu(s) in the page
+* @access private
+* @var string
+*/
+var $footer;
+/**
+* This var tells if the footer has been made or not
+* @access private
+* @var boolean
+*/
+var $_footerHasBeenMade = false;
+
+/**
+* The image used for forward arrows.
+* @access private
+* @var string
+*/
+var $forwardArrowImg;
+/**
+* The image used for down arrows.
+* @access private
+* @var string
+*/
+var $downArrowImg;
+/**
+* A 1x1 transparent icon.
+* @access private
+* @var string
+*/
+var $transparentIcon;
+/**
+* An array to keep trace of layers containing / not containing icons
+* @access private
+* @var array
+*/
+var $_hasIcons;
+/**
+* Top offset for positioning of sub menu layers
+* @access private
+* @var integer
+*/
+var $menuTopShift;
+/**
+* Right offset for positioning of sub menu layers
+* @access private
+* @var integer
+*/
+var $menuRightShift;
+/**
+* Left offset for positioning of sub menu layers
+* @access private
+* @var integer
+*/
+var $menuLeftShift;
+/**
+* Threshold for vertical repositioning of a layer
+* @access private
+* @var integer
+*/
+var $thresholdY;
+/**
+* Step for the left boundaries of layers
+* @access private
+* @var integer
+*/
+var $abscissaStep;
+
+/**
+* The constructor method; it initializates the menu system
+* @return void
+*/
+function LayersMenu(
+ $menuTopShift = 6, // Gtk2-like
+ $menuRightShift = 7, // Gtk2-like
+ $menuLeftShift = 2, // Gtk2-like
+ $thresholdY = 5,
+ $abscissaStep = 140
+ )
+{
+ $this->LayersMenuCommon();
+
+ $this->horizontalMenuTpl = $this->tpldir . 'layersmenu-horizontal_menu.ihtml';
+ $this->verticalMenuTpl = $this->tpldir . 'layersmenu-vertical_menu.ihtml';
+ $this->subMenuTpl = $this->tpldir . 'layersmenu-sub_menu.ihtml';
+
+ $this->header = '';
+ $this->listl = '';
+ $this->father_keys = '';
+ $this->father_vals = '';
+ $this->moveLayers = '';
+ $this->_firstLevelMenu = array();
+ $this->footer = '';
+
+ $this->transparentIcon = 'transparent.png';
+ $this->_hasIcons = array();
+ $this->forwardArrowImg['src'] = 'forward-arrow.png';
+ $this->forwardArrowImg['width'] = 4;
+ $this->forwardArrowImg['height'] = 7;
+ $this->downArrowImg['src'] = 'down-arrow.png';
+ $this->downArrowImg['width'] = 9;
+ $this->downArrowImg['height'] = 5;
+ $this->menuTopShift = $menuTopShift;
+ $this->menuRightShift = $menuRightShift;
+ $this->menuLeftShift = $menuLeftShift;
+ $this->thresholdY = $thresholdY;
+ $this->abscissaStep = $abscissaStep;
+}
+
+/**
+* The method to set the value of menuTopShift
+* @access public
+* @return void
+*/
+function setMenuTopShift($menuTopShift)
+{
+ $this->menuTopShift = $menuTopShift;
+}
+
+/**
+* The method to set the value of menuRightShift
+* @access public
+* @return void
+*/
+function setMenuRightShift($menuRightShift)
+{
+ $this->menuRightShift = $menuRightShift;
+}
+
+/**
+* The method to set the value of menuLeftShift
+* @access public
+* @return void
+*/
+function setMenuLeftShift($menuLeftShift)
+{
+ $this->menuLeftShift = $menuLeftShift;
+}
+
+/**
+* The method to set the value of thresholdY
+* @access public
+* @return void
+*/
+function setThresholdY($thresholdY)
+{
+ $this->thresholdY = $thresholdY;
+}
+
+/**
+* The method to set the value of abscissaStep
+* @access public
+* @return void
+*/
+function setAbscissaStep($abscissaStep)
+{
+ $this->abscissaStep = $abscissaStep;
+}
+
+/**
+* The method to set the dirroot directory
+* @access public
+* @return boolean
+*/
+function setDirroot($dirroot)
+{
+ $oldtpldir = $this->tpldir;
+ if ($foobar = $this->setDirrootCommon($dirroot)) {
+ $this->updateTpldir($oldtpldir);
+ }
+ return $foobar;
+}
+
+/**
+* The method to set the tpldir directory
+* @access public
+* @return boolean
+*/
+function setTpldir($tpldir)
+{
+ $oldtpldir = $this->tpldir;
+ if ($foobar = $this->setTpldirCommon($tpldir)) {
+ $this->updateTpldir($oldtpldir);
+ }
+ return $foobar;
+}
+
+/**
+* The method to update the templates directory path to the new tpldir
+* @access private
+* @return void
+*/
+function updateTpldir($oldtpldir)
+{
+ $oldlength = strlen($oldtpldir);
+ $foobar = strpos($this->horizontalMenuTpl, $oldtpldir);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->horizontalMenuTpl = $this->tpldir . substr($this->horizontalMenuTpl, $oldlength);
+ }
+ $foobar = strpos($this->verticalMenuTpl, $oldtpldir);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->verticalMenuTpl = $this->tpldir . substr($this->verticalMenuTpl, $oldlength);
+ }
+ $foobar = strpos($this->subMenuTpl, $oldtpldir);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->subMenuTpl = $this->tpldir . substr($this->subMenuTpl, $oldlength);
+ }
+}
+
+/**
+* The method to set horizontalMenuTpl
+* @access public
+* @return boolean
+*/
+function setHorizontalMenuTpl($horizontalMenuTpl)
+{
+ if (str_replace('/', '', $horizontalMenuTpl) == $horizontalMenuTpl) {
+ $horizontalMenuTpl = $this->tpldir . $horizontalMenuTpl;
+ }
+ if (!file_exists($horizontalMenuTpl)) {
+ $this->error("setHorizontalMenuTpl: file $horizontalMenuTpl does not exist.");
+ return false;
+ }
+ $this->horizontalMenuTpl = $horizontalMenuTpl;
+ return true;
+}
+
+/**
+* The method to set verticalMenuTpl
+* @access public
+* @return boolean
+*/
+function setVerticalMenuTpl($verticalMenuTpl)
+{
+ if (str_replace('/', '', $verticalMenuTpl) == $verticalMenuTpl) {
+ $verticalMenuTpl = $this->tpldir . $verticalMenuTpl;
+ }
+ if (!file_exists($verticalMenuTpl)) {
+ $this->error("setVerticalMenuTpl: file $verticalMenuTpl does not exist.");
+ return false;
+ }
+ $this->verticalMenuTpl = $verticalMenuTpl;
+ return true;
+}
+
+/**
+* The method to set subMenuTpl
+* @access public
+* @return boolean
+*/
+function setSubMenuTpl($subMenuTpl)
+{
+ if (str_replace('/', '', $subMenuTpl) == $subMenuTpl) {
+ $subMenuTpl = $this->tpldir . $subMenuTpl;
+ }
+ if (!file_exists($subMenuTpl)) {
+ $this->error("setSubMenuTpl: file $subMenuTpl does not exist.");
+ return false;
+ }
+ $this->subMenuTpl = $subMenuTpl;
+ return true;
+}
+
+/**
+* A method to set transparentIcon
+* @access public
+* @param string $transparentIcon a transparentIcon filename (without the path)
+* @return void
+*/
+function setTransparentIcon($transparentIcon)
+{
+ $this->transparentIcon = $transparentIcon;
+}
+
+/**
+* The method to set an image to be used for the forward arrow
+* @access public
+* @param string $forwardArrowImg the forward arrow image filename
+* @return boolean
+*/
+function setForwardArrowImg($forwardArrowImg)
+{
+ if (!file_exists($this->imgdir . $forwardArrowImg)) {
+ $this->error('setForwardArrowImg: file ' . $this->imgdir . $forwardArrowImg . ' does not exist.');
+ return false;
+ }
+ $foobar = getimagesize($this->imgdir . $forwardArrowImg);
+ $this->forwardArrowImg['src'] = $forwardArrowImg;
+ $this->forwardArrowImg['width'] = $foobar[0];
+ $this->forwardArrowImg['height'] = $foobar[1];
+ return true;
+}
+
+/**
+* The method to set an image to be used for the down arrow
+* @access public
+* @param string $downArrowImg the down arrow image filename
+* @return boolean
+*/
+function setDownArrowImg($downArrowImg)
+{
+ if (!file_exists($this->imgdir . $downArrowImg)) {
+ $this->error('setDownArrowImg: file ' . $this->imgdir . $downArrowImg . ' does not exist.');
+ return false;
+ }
+ $foobar = getimagesize($this->imgdir . $downArrowImg);
+ $this->downArrowImg['src'] = $downArrowImg;
+ $this->downArrowImg['width'] = $foobar[0];
+ $this->downArrowImg['height'] = $foobar[1];
+ return true;
+}
+
+/**
+* A method providing parsing needed both for horizontal and vertical menus; it can be useful also with the ProcessLayersMenu extended class
+* @access public
+* @param string $menu_name the name of the menu for which the parsing
+* has to be performed
+* @return void
+*/
+function parseCommon(
+ $menu_name = '' // non consistent default...
+ )
+{
+ $this->_hasIcons[$menu_name] = false;
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
+ $this->_hasIcons[$cnt] = false;
+ $this->tree[$cnt]['layer_label'] = "L$cnt";
+ $current_node[$this->tree[$cnt]['level']] = $cnt;
+ if (!$this->tree[$cnt]['child_of_root_node']) {
+ $this->tree[$cnt]['father_node'] = $current_node[$this->tree[$cnt]['level']-1];
+ $this->father_keys .= ",'L$cnt'";
+ $this->father_vals .= ",'" . $this->tree[$this->tree[$cnt]['father_node']]['layer_label'] . "'";
+ }
+ $this->tree[$cnt]['not_a_leaf'] = ($this->tree[$cnt+1]['level']>$this->tree[$cnt]['level'] && $cnt<$this->_lastItem[$menu_name]);
+ // if the above condition is true, the node is not a leaf,
+ // hence it has at least a child; if it is false, the node is a leaf
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ // initialize the corresponding layer content trought a void string
+ $this->tree[$cnt]['layer_content'] = '';
+ // the new layer is accounted for in the layers list
+ $this->listl .= ",'" . $this->tree[$cnt]['layer_label'] . "'";
+ }
+/*
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $this->tree[$cnt]['parsed_href'] = '#';
+ }
+*/
+ if ($this->tree[$cnt]['parsed_icon'] == '') {
+ $this->tree[$cnt]['iconsrc'] = $this->imgwww . $this->transparentIcon;
+ $this->tree[$cnt]['iconwidth'] = 16;
+ $this->tree[$cnt]['iconheight'] = 16;
+ $this->tree[$cnt]['iconalt'] = ' ';
+ } else {
+ if ($this->tree[$cnt]['level'] > 1) {
+ $this->_hasIcons[$this->tree[$cnt]['father_node']] = true;
+ } else {
+ $this->_hasIcons[$menu_name] = true;
+ }
+ $this->tree[$cnt]['iconsrc'] = $this->tree[$cnt]['parsed_icon'];
+ $this->tree[$cnt]['iconalt'] = 'O';
+ }
+ }
+}
+
+/**
+* A method needed to update the footer both for horizontal and vertical menus
+* @access private
+* @param string $menu_name the name of the menu for which the updating
+* has to be performed
+* @return void
+*/
+function _updateFooter(
+ $menu_name = '' // non consistent default...
+ )
+{
+ $t = new Template_PHPLIB();
+ $t->setFile('tplfile', $this->subMenuTpl);
+ $t->setBlock('tplfile', 'template', 'template_blck');
+ $t->setBlock('template', 'sub_menu_cell', 'sub_menu_cell_blck');
+ $t->setVar('sub_menu_cell_blck', '');
+ $t->setBlock('template', 'separator', 'separator_blck');
+ $t->setVar('separator_blck', '');
+ $t->setVar('abscissaStep', $this->abscissaStep);
+
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $t->setVar(array(
+ 'layer_label' => $this->tree[$cnt]['layer_label'],
+ 'layer_title' => $this->tree[$cnt]['text'],
+ 'sub_menu_cell_blck' => $this->tree[$cnt]['layer_content']
+ ));
+ $this->footer .= $t->parse('template_blck', 'template');
+ }
+ }
+}
+
+/**
+* Method to preparare a horizontal menu.
+*
+* This method processes items of a menu to prepare the corresponding
+* horizontal menu code updating many variables; it returns the code
+* of the corresponding _firstLevelMenu
+*
+* @access public
+* @param string $menu_name the name of the menu whose items have to be processed
+* @return string
+*/
+function newHorizontalMenu(
+ $menu_name = '' // non consistent default...
+ )
+{
+ if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) {
+ $this->error("newHorizontalMenu: the first/last item of the menu '$menu_name' is not defined; please check if you have parsed its menu data.");
+ return 0;
+ }
+
+ $this->parseCommon($menu_name);
+
+ $t = new Template_PHPLIB();
+ $t->setFile('tplfile', $this->horizontalMenuTpl);
+ $t->setBlock('tplfile', 'template', 'template_blck');
+ $t->setBlock('template', 'horizontal_menu_cell', 'horizontal_menu_cell_blck');
+ $t->setVar('horizontal_menu_cell_blck', '');
+ $t->setBlock('horizontal_menu_cell', 'cell_link', 'cell_link_blck');
+ $t->setVar('cell_link_blck', '');
+ $t->setBlock('cell_link', 'cell_icon', 'cell_icon_blck');
+ $t->setVar('cell_icon_blck', '');
+ $t->setBlock('cell_link', 'cell_arrow', 'cell_arrow_blck');
+ $t->setVar('cell_arrow_blck', '');
+
+ $t_sub = new Template_PHPLIB();
+ $t_sub->setFile('tplfile', $this->subMenuTpl);
+ $t_sub->setBlock('tplfile', 'sub_menu_cell', 'sub_menu_cell_blck');
+ $t_sub->setVar('sub_menu_cell_blck', '');
+ $t_sub->setBlock('sub_menu_cell', 'cell_icon', 'cell_icon_blck');
+ $t_sub->setVar('cell_icon_blck', '');
+ $t_sub->setBlock('sub_menu_cell', 'cell_arrow', 'cell_arrow_blck');
+ $t_sub->setVar('cell_arrow_blck', '');
+ $t_sub->setBlock('tplfile', 'separator', 'separator_blck');
+ $t_sub->setVar('separator_blck', '');
+
+ $this->_firstLevelMenu[$menu_name] = '';
+
+ $foobar = $this->_firstItem[$menu_name];
+ $this->moveLayers .= "\tvar " . $menu_name . "TOP = getOffsetTop('" . $menu_name . "L" . $foobar . "');\n";
+ $this->moveLayers .= "\tvar " . $menu_name . "HEIGHT = getOffsetHeight('" . $menu_name . "L" . $foobar . "');\n";
+
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ // geometrical parameters are assigned to the new layer, related to the above mentioned children
+ if ($this->tree[$cnt]['child_of_root_node']) {
+ $this->moveLayers .= "\tsetTop('" . $this->tree[$cnt]['layer_label'] . "', " . $menu_name . "TOP + " . $menu_name . "HEIGHT);\n";
+ $this->moveLayers .= "\tmoveLayerX1('" . $this->tree[$cnt]['layer_label'] . "', '" . $menu_name . "');\n";
+ }
+ }
+
+ if ($this->tree[$cnt]['child_of_root_node']) {
+ if ($this->tree[$cnt]['text'] == '---') {
+ continue;
+ }
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $this->tree[$cnt]['onmouseover'] = ' onmouseover="moveLayerX1(' . "'" . $this->tree[$cnt]['layer_label'] . "', '" . $menu_name . "') ; LMPopUp('" . $this->tree[$cnt]['layer_label'] . "'" . ', false);"';
+ } else {
+ $this->tree[$cnt]['onmouseover'] = ' onmouseover="shutdown();"';
+ }
+ $t->setVar(array(
+ 'menu_layer_label' => $menu_name . $this->tree[$cnt]['layer_label'],
+ 'imgwww' => $this->imgwww,
+ 'transparent' => $this->transparentIcon,
+ 'href' => $this->tree[$cnt]['parsed_href'],
+ 'onmouseover' => $this->tree[$cnt]['onmouseover'],
+ 'title' => $this->tree[$cnt]['parsed_title'],
+ 'target' => $this->tree[$cnt]['parsed_target'],
+ 'text' => $this->tree[$cnt]['text'],
+ 'downsrc' => $this->downArrowImg['src'],
+ 'downwidth' => $this->downArrowImg['width'],
+ 'downheight' => $this->downArrowImg['height']
+ ));
+ if ($this->tree[$cnt]['parsed_icon'] != '') {
+ $t->setVar(array(
+ 'iconsrc' => $this->tree[$cnt]['iconsrc'],
+ 'iconwidth' => $this->tree[$cnt]['iconwidth'],
+ 'iconheight' => $this->tree[$cnt]['iconheight'],
+ 'iconalt' => $this->tree[$cnt]['iconalt'],
+ ));
+ $t->parse('cell_icon_blck', 'cell_icon');
+ } else {
+ $t->setVar('cell_icon_blck', '');
+ }
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $t->parse('cell_arrow_blck', 'cell_arrow');
+ } else {
+ $t->setVar('cell_arrow_blck', '');
+ }
+ $foobar = $t->parse('cell_link_blck', 'cell_link');
+ $t->setVar(array(
+ 'cellwidth' => $this->abscissaStep,
+ 'cell_link_blck' => $foobar
+ ));
+ $t->parse('horizontal_menu_cell_blck', 'horizontal_menu_cell', true);
+ } else {
+ if ($this->tree[$cnt]['text'] == '---') {
+ $this->tree[$this->tree[$cnt]['father_node']]['layer_content'] .= $t_sub->parse('separator_blck', 'separator');
+ continue;
+ }
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $this->tree[$cnt]['onmouseover'] = ' onmouseover="moveLayerX(' . "'" . $this->tree[$cnt]['layer_label'] . "') ; moveLayerY('" . $this->tree[$cnt]['layer_label'] . "') ; LMPopUp('" . $this->tree[$cnt]['layer_label'] . "'". ', false);"';
+ } else {
+ $this->tree[$cnt]['onmouseover'] = ' onmouseover="LMPopUp(' . "'" . $this->tree[$this->tree[$cnt]['father_node']]['layer_label'] . "'" . ', true);"';
+ }
+ $t_sub->setVar(array(
+ 'imgwww' => $this->imgwww,
+ 'transparent' => $this->transparentIcon,
+ 'href' => $this->tree[$cnt]['parsed_href'],
+ 'refid' => 'ref' . $this->tree[$cnt]['layer_label'],
+ 'onmouseover' => $this->tree[$cnt]['onmouseover'],
+ 'title' => $this->tree[$cnt]['parsed_title'],
+ 'target' => $this->tree[$cnt]['parsed_target'],
+ 'text' => $this->tree[$cnt]['text'],
+ 'arrowsrc' => $this->forwardArrowImg['src'],
+ 'arrowwidth' => $this->forwardArrowImg['width'],
+ 'arrowheight' => $this->forwardArrowImg['height']
+ ));
+ if ($this->_hasIcons[$this->tree[$cnt]['father_node']]) {
+ $t_sub->setVar(array(
+ 'iconsrc' => $this->tree[$cnt]['iconsrc'],
+ 'iconwidth' => $this->tree[$cnt]['iconwidth'],
+ 'iconheight' => $this->tree[$cnt]['iconheight'],
+ 'iconalt' => $this->tree[$cnt]['iconalt']
+ ));
+ $t_sub->parse('cell_icon_blck', 'cell_icon');
+ } else {
+ $t_sub->setVar('cell_icon_blck', '');
+ }
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $t_sub->parse('cell_arrow_blck', 'cell_arrow');
+ } else {
+ $t_sub->setVar('cell_arrow_blck', '');
+ }
+ $this->tree[$this->tree[$cnt]['father_node']]['layer_content'] .= $t_sub->parse('sub_menu_cell_blck', 'sub_menu_cell');
+ }
+ } // end of the "for" cycle scanning all nodes
+
+ $foobar = $this->_firstLevelCnt[$menu_name] * $this->abscissaStep;
+ $t->setVar('menuwidth', $foobar);
+ $t->setVar(array(
+ 'layer_label' => $menu_name,
+ 'menubody' => $this->_firstLevelMenu[$menu_name]
+ ));
+ $this->_firstLevelMenu[$menu_name] = $t->parse('template_blck', 'template');
+
+ $this->_updateFooter($menu_name);
+
+ return $this->_firstLevelMenu[$menu_name];
+}
+
+/**
+* Method to preparare a vertical menu.
+*
+* This method processes items of a menu to prepare the corresponding
+* vertical menu code updating many variables; it returns the code
+* of the corresponding _firstLevelMenu
+*
+* @access public
+* @param string $menu_name the name of the menu whose items have to be processed
+* @return string
+*/
+function newVerticalMenu(
+ $menu_name = '' // non consistent default...
+ )
+{
+ if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) {
+ $this->error("newVerticalMenu: the first/last item of the menu '$menu_name' is not defined; please check if you have parsed its menu data.");
+ return 0;
+ }
+
+ $this->parseCommon($menu_name);
+
+ $t = new Template_PHPLIB();
+ $t->setFile('tplfile', $this->verticalMenuTpl);
+ $t->setBlock('tplfile', 'template', 'template_blck');
+ $t->setBlock('template', 'vertical_menu_box', 'vertical_menu_box_blck');
+ $t->setVar('vertical_menu_box_blck', '');
+ $t->setBlock('vertical_menu_box', 'vertical_menu_cell', 'vertical_menu_cell_blck');
+ $t->setVar('vertical_menu_cell_blck', '');
+ $t->setBlock('vertical_menu_cell', 'cell_icon', 'cell_icon_blck');
+ $t->setVar('cell_icon_blck', '');
+ $t->setBlock('vertical_menu_cell', 'cell_arrow', 'cell_arrow_blck');
+ $t->setVar('cell_arrow_blck', '');
+ $t->setBlock('vertical_menu_box', 'separator', 'separator_blck');
+ $t->setVar('separator_blck', '');
+
+ $t_sub = new Template_PHPLIB();
+ $t_sub->setFile('tplfile', $this->subMenuTpl);
+ $t_sub->setBlock('tplfile', 'sub_menu_cell', 'sub_menu_cell_blck');
+ $t_sub->setVar('sub_menu_cell_blck', '');
+ $t_sub->setBlock('sub_menu_cell', 'cell_icon', 'cell_icon_blck');
+ $t_sub->setVar('cell_icon_blck', '');
+ $t_sub->setBlock('sub_menu_cell', 'cell_arrow', 'cell_arrow_blck');
+ $t_sub->setVar('cell_arrow_blck', '');
+ $t_sub->setBlock('tplfile', 'separator', 'separator_blck');
+ $t_sub->setVar('separator_blck', '');
+
+ $this->_firstLevelMenu[$menu_name] = '';
+
+ $this->moveLayers .= "\tvar " . $menu_name . "TOP = getOffsetTop('" . $menu_name . "');\n";
+ $this->moveLayers .= "\tvar " . $menu_name . "LEFT = getOffsetLeft('" . $menu_name . "');\n";
+ $this->moveLayers .= "\tvar " . $menu_name . "WIDTH = getOffsetWidth('" . $menu_name . "');\n";
+
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ // geometrical parameters are assigned to the new layer, related to the above mentioned children
+ if ($this->tree[$cnt]['child_of_root_node']) {
+ $this->moveLayers .= "\tsetLeft('" . $this->tree[$cnt]['layer_label'] . "', " . $menu_name . "LEFT + " . $menu_name . "WIDTH - menuRightShift);\n";
+ }
+ }
+
+ if ($this->tree[$cnt]['child_of_root_node']) {
+ if ($this->tree[$cnt]['text'] == '---') {
+ $this->_firstLevelMenu[$menu_name] .= $t->parse('separator_blck', 'separator');
+ continue;
+ }
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $this->tree[$cnt]['onmouseover'] = ' onmouseover="moveLayerX(' . "'" . $this->tree[$cnt]['layer_label'] . "') ; moveLayerY('" . $this->tree[$cnt]['layer_label'] . "') ; LMPopUp('" . $this->tree[$cnt]['layer_label'] . "'" . ', false);"';
+ } else {
+ $this->tree[$cnt]['onmouseover'] = ' onmouseover="shutdown();"';
+ }
+ $t->setVar(array(
+ 'imgwww' => $this->imgwww,
+ 'transparent' => $this->transparentIcon,
+ 'href' => $this->tree[$cnt]['parsed_href'],
+ 'refid' => 'ref' . $this->tree[$cnt]['layer_label'],
+ 'onmouseover' => $this->tree[$cnt]['onmouseover'],
+ 'title' => $this->tree[$cnt]['parsed_title'],
+ 'target' => $this->tree[$cnt]['parsed_target'],
+ 'text' => $this->tree[$cnt]['text'],
+ 'arrowsrc' => $this->forwardArrowImg['src'],
+ 'arrowwidth' => $this->forwardArrowImg['width'],
+ 'arrowheight' => $this->forwardArrowImg['height']
+ ));
+ if ($this->_hasIcons[$menu_name]) {
+ $t->setVar(array(
+ 'iconsrc' => $this->tree[$cnt]['iconsrc'],
+ 'iconwidth' => $this->tree[$cnt]['iconwidth'],
+ 'iconheight' => $this->tree[$cnt]['iconheight'],
+ 'iconalt' => $this->tree[$cnt]['iconalt']
+ ));
+ $t->parse('cell_icon_blck', 'cell_icon');
+ } else {
+ $t->setVar('cell_icon_blck', '');
+ }
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $t->parse('cell_arrow_blck', 'cell_arrow');
+ } else {
+ $t->setVar('cell_arrow_blck', '');
+ }
+ $this->_firstLevelMenu[$menu_name] .= $t->parse('vertical_menu_cell_blck', 'vertical_menu_cell');
+ } else {
+ if ($this->tree[$cnt]['text'] == '---') {
+ $this->tree[$this->tree[$cnt]['father_node']]['layer_content'] .= $t_sub->parse('separator_blck', 'separator');
+ continue;
+ }
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $this->tree[$cnt]['onmouseover'] = ' onmouseover="moveLayerX(' . "'" . $this->tree[$cnt]['layer_label'] . "') ; moveLayerY('" . $this->tree[$cnt]['layer_label'] . "') ; LMPopUp('" . $this->tree[$cnt]['layer_label'] . "'" . ', false);"';
+ } else {
+ $this->tree[$cnt]['onmouseover'] = ' onmouseover="LMPopUp(' . "'" . $this->tree[$this->tree[$cnt]['father_node']]['layer_label'] . "'" . ', true);"';
+ }
+ $t_sub->setVar(array(
+ 'imgwww' => $this->imgwww,
+ 'transparent' => $this->transparentIcon,
+ 'href' => $this->tree[$cnt]['parsed_href'],
+ 'refid' => 'ref' . $this->tree[$cnt]['layer_label'],
+ 'onmouseover' => $this->tree[$cnt]['onmouseover'],
+ 'title' => $this->tree[$cnt]['parsed_title'],
+ 'target' => $this->tree[$cnt]['parsed_target'],
+ 'text' => $this->tree[$cnt]['text'],
+ 'arrowsrc' => $this->forwardArrowImg['src'],
+ 'arrowwidth' => $this->forwardArrowImg['width'],
+ 'arrowheight' => $this->forwardArrowImg['height']
+ ));
+ if ($this->_hasIcons[$this->tree[$cnt]['father_node']]) {
+ $t_sub->setVar(array(
+ 'iconsrc' => $this->tree[$cnt]['iconsrc'],
+ 'iconwidth' => $this->tree[$cnt]['iconwidth'],
+ 'iconheight' => $this->tree[$cnt]['iconheight'],
+ 'iconalt' => $this->tree[$cnt]['iconalt']
+ ));
+ $t_sub->parse('cell_icon_blck', 'cell_icon');
+ } else {
+ $t_sub->setVar('cell_icon_blck', '');
+ }
+ if ($this->tree[$cnt]['not_a_leaf']) {
+ $t_sub->parse('cell_arrow_blck', 'cell_arrow');
+ } else {
+ $t_sub->setVar('cell_arrow_blck', '');
+ }
+ $this->tree[$this->tree[$cnt]['father_node']]['layer_content'] .= $t_sub->parse('sub_menu_cell_blck', 'sub_menu_cell');
+ }
+ } // end of the "for" cycle scanning all nodes
+
+ $t->setVar(array(
+ 'menu_name' => $menu_name,
+ 'vertical_menu_cell_blck' => $this->_firstLevelMenu[$menu_name],
+ 'separator_blck' => ''
+ ));
+ $this->_firstLevelMenu[$menu_name] = $t->parse('vertical_menu_box_blck', 'vertical_menu_box');
+ $t->setVar('abscissaStep', $this->abscissaStep);
+ $t->setVar(array(
+ 'layer_label' => $menu_name,
+ 'vertical_menu_box_blck' => $this->_firstLevelMenu[$menu_name]
+ ));
+ $this->_firstLevelMenu[$menu_name] = $t->parse('template_blck', 'template');
+
+ $this->_updateFooter($menu_name);
+
+ return $this->_firstLevelMenu[$menu_name];
+}
+
+/**
+* Method to prepare the header.
+*
+* This method obtains the header using collected informations
+* and the suited JavaScript template; it returns the code of the header
+*
+* @access public
+* @return string
+*/
+function makeHeader()
+{
+ $t = new Template_PHPLIB();
+ $this->listl = 'listl = [' . substr($this->listl, 1) . '];';
+ $this->father_keys = 'father_keys = [' . substr($this->father_keys, 1) . '];';
+ $this->father_vals = 'father_vals = [' . substr($this->father_vals, 1) . '];';
+ $t->setFile('tplfile', $this->libjsdir . 'layersmenu-header.ijs');
+ $t->setVar(array(
+ 'packageName' => $this->_packageName,
+ 'version' => $this->version,
+ 'copyright' => $this->copyright,
+ 'author' => $this->author,
+ 'menuTopShift' => $this->menuTopShift,
+ 'menuRightShift'=> $this->menuRightShift,
+ 'menuLeftShift' => $this->menuLeftShift,
+ 'thresholdY' => $this->thresholdY,
+ 'abscissaStep' => $this->abscissaStep,
+ 'listl' => $this->listl,
+ 'nodesCount' => $this->_nodesCount,
+ 'father_keys' => $this->father_keys,
+ 'father_vals' => $this->father_vals,
+ 'moveLayers' => $this->moveLayers
+ ));
+ $this->header = $t->parse('out', 'tplfile');
+ $this->_headerHasBeenMade = true;
+ return $this->header;
+}
+
+/**
+* Method that returns the code of the header
+* @access public
+* @return string
+*/
+function getHeader()
+{
+ if (!$this->_headerHasBeenMade) {
+ $this->makeHeader();
+ }
+ return $this->header;
+}
+
+/**
+* Method that prints the code of the header
+* @access public
+* @return void
+*/
+function printHeader()
+{
+ print $this->getHeader();
+}
+
+/**
+* Method that returns the code of the requested _firstLevelMenu
+* @access public
+* @param string $menu_name the name of the menu whose _firstLevelMenu
+* has to be returned
+* @return string
+*/
+function getMenu($menu_name)
+{
+ return $this->_firstLevelMenu[$menu_name];
+}
+
+/**
+* Method that prints the code of the requested _firstLevelMenu
+* @access public
+* @param string $menu_name the name of the menu whose _firstLevelMenu
+* has to be printed
+* @return void
+*/
+function printMenu($menu_name)
+{
+ print $this->_firstLevelMenu[$menu_name];
+}
+
+/**
+* Method to prepare the footer.
+*
+* This method obtains the footer using collected informations
+* and the suited JavaScript template; it returns the code of the footer
+*
+* @access public
+* @return string
+*/
+function makeFooter()
+{
+ $t = new Template_PHPLIB();
+ $t->setFile('tplfile', $this->libjsdir . 'layersmenu-footer.ijs');
+ $t->setVar(array(
+ 'packageName' => $this->_packageName,
+ 'version' => $this->version,
+ 'copyright' => $this->copyright,
+ 'author' => $this->author,
+ 'footer' => $this->footer
+
+ ));
+ $this->footer = $t->parse('out', 'tplfile');
+ $this->_footerHasBeenMade = true;
+ return $this->footer;
+}
+
+/**
+* Method that returns the code of the footer
+* @access public
+* @return string
+*/
+function getFooter()
+{
+ if (!$this->_footerHasBeenMade) {
+ $this->makeFooter();
+ }
+ return $this->footer;
+}
+
+/**
+* Method that prints the code of the footer
+* @access public
+* @return void
+*/
+function printFooter()
+{
+ print $this->getFooter();
+}
+
+} /* END OF CLASS */
+
+?>
diff --git a/gosa-core/include/layer-menu/lib/phptreemenu.inc.php b/gosa-core/include/layer-menu/lib/phptreemenu.inc.php
--- /dev/null
@@ -0,0 +1,448 @@
+<?php
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+/**
+* This file contains the code of the PHPTreeMenu class.
+* @package PHPLayersMenu
+*/
+
+/**
+* This is the PHPTreeMenu class of the PHP Layers Menu library.
+*
+* This class depends on the LayersMenuCommon class. It provides "server-side" (PHP-based) tree menus, that to do not require JavaScript to work.
+*
+* @version 3.2.0-rc
+* @package PHPLayersMenu
+*/
+class PHPTreeMenu extends LayersMenuCommon
+{
+
+/**
+* The character used for the PHP Tree Menu in the query string to separate items ids
+* @access private
+* @var string
+*/
+var $phpTreeMenuSeparator;
+/**
+* The default value of the expansion string for the PHP Tree Menu
+* @access private
+* @var string
+*/
+var $phpTreeMenuDefaultExpansion;
+/**
+* Type of images used for the Tree Menu
+* @access private
+* @var string
+*/
+var $phpTreeMenuImagesType;
+/**
+* Prefix for filenames of images of a theme
+* @access private
+* @var string
+*/
+var $phpTreeMenuTheme;
+/**
+* An array where we store the PHP Tree Menu code for each menu
+* @access private
+* @var array
+*/
+var $_phpTreeMenu;
+
+/**
+* The constructor method; it initializates some variables
+* @return void
+*/
+function PHPTreeMenu()
+{
+ $this->LayersMenuCommon();
+
+ $this->phpTreeMenuSeparator = '|';
+ $this->phpTreeMenuDefaultExpansion = '';
+ $this->phpTreeMenuImagesType = 'png';
+ $this->phpTreeMenuTheme = '';
+ $this->_phpTreeMenu = array();
+}
+
+/**
+* The method to set the dirroot directory
+* @access public
+* @return boolean
+*/
+function setDirroot($dirroot)
+{
+ return $this->setDirrootCommon($dirroot);
+}
+
+/**
+* The method to set the value of separator for the Tree Menu query string
+* @access public
+* @return void
+*/
+function setPHPTreeMenuSeparator($phpTreeMenuSeparator)
+{
+ $this->phpTreeMenuSeparator = $phpTreeMenuSeparator;
+}
+
+/**
+* The method to set the default value of the expansion string for the PHP Tree Menu
+* @access public
+* @return void
+*/
+function setPHPTreeMenuDefaultExpansion($phpTreeMenuDefaultExpansion)
+{
+ $this->phpTreeMenuDefaultExpansion = $phpTreeMenuDefaultExpansion;
+}
+
+/**
+* The method to set the type of images used for the Tree Menu
+* @access public
+* @return void
+*/
+function setPHPTreeMenuImagesType($phpTreeMenuImagesType)
+{
+ $this->phpTreeMenuImagesType = $phpTreeMenuImagesType;
+}
+
+/**
+* The method to set the prefix for filenames of images of a theme
+* @access public
+* @return void
+*/
+function setPHPTreeMenuTheme($phpTreeMenuTheme)
+{
+ $this->phpTreeMenuTheme = $phpTreeMenuTheme;
+}
+
+/**
+* Method to prepare a new PHP Tree Menu.
+*
+* This method processes items of a menu and parameters submitted
+* through GET (i.e. nodes to be expanded) to prepare and return
+* the corresponding Tree Menu code.
+*
+* @access public
+* @param string $menu_name the name of the menu whose items have to be processed
+* @return string
+*/
+function newPHPTreeMenu(
+ $menu_name = '' // non consistent default...
+ )
+{
+ $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
+ $this_host = (isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
+ if (isset($_SERVER['SCRIPT_NAME'])) {
+ $me = $_SERVER['SCRIPT_NAME'];
+ } elseif (isset($_SERVER['REQUEST_URI'])) {
+ $me = $_SERVER['REQUEST_URI'];
+ } elseif (isset($_SERVER['PHP_SELF'])) {
+ $me = $_SERVER['PHP_SELF'];
+ } elseif (isset($_SERVER['PATH_INFO'])) {
+ $me = $_SERVER['PATH_INFO'];
+ }
+ $url = $protocol . $this_host . $me;
+ $query = '';
+ reset($_GET);
+ while (list($key, $value) = each($_GET)) {
+ if ($key != 'p' && $value != '') {
+ $query .= '&' . $key . '=' . $value;
+ }
+ }
+ if ($query != '') {
+ $query = '?' . substr($query, 5) . '&p=';
+ } else {
+ $query = '?p=';
+ }
+ $p = (isset($_GET['p'])) ? $_GET['p'] : $this->phpTreeMenuDefaultExpansion;
+
+/* ********************************************************* */
+/* Based on TreeMenu 1.1 by Bjorge Dijkstra (bjorge@gmx.net) */
+/* ********************************************************* */
+ $this->_phpTreeMenu[$menu_name] = '';
+
+ $img_collapse = $this->imgwww . $this->phpTreeMenuTheme . 'tree_collapse.' . $this->phpTreeMenuImagesType;
+ $alt_collapse = '--';
+ $img_collapse_corner = $this->imgwww . $this->phpTreeMenuTheme . 'tree_collapse_corner.' . $this->phpTreeMenuImagesType;
+ $alt_collapse_corner = '--';
+ $img_collapse_corner_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_collapse_corner_first.' . $this->phpTreeMenuImagesType;
+ $alt_collapse_corner_first = '--';
+ $img_collapse_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_collapse_first.' . $this->phpTreeMenuImagesType;
+ $alt_collapse_first = '--';
+ $img_corner = $this->imgwww . $this->phpTreeMenuTheme . 'tree_corner.' . $this->phpTreeMenuImagesType;
+ $alt_corner = '`-';
+ $img_expand = $this->imgwww . $this->phpTreeMenuTheme . 'tree_expand.' . $this->phpTreeMenuImagesType;
+ $alt_expand = '+-';
+ $img_expand_corner = $this->imgwww . $this->phpTreeMenuTheme . 'tree_expand_corner.' . $this->phpTreeMenuImagesType;
+ $alt_expand_corner = '+-';
+ $img_expand_corner_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_expand_corner_first.' . $this->phpTreeMenuImagesType;
+ $alt_expand_corner_first = '+-';
+ $img_expand_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_expand_first.' . $this->phpTreeMenuImagesType;
+ $alt_expand_first = '+-';
+ $img_folder_closed = $this->imgwww . $this->phpTreeMenuTheme . 'tree_folder_closed.' . $this->phpTreeMenuImagesType;
+ $alt_folder_closed = '->';
+ $img_folder_open = $this->imgwww . $this->phpTreeMenuTheme . 'tree_folder_open.' . $this->phpTreeMenuImagesType;
+ $alt_folder_open = '->';
+ $img_leaf = $this->imgwww . $this->phpTreeMenuTheme . 'tree_leaf.' . $this->phpTreeMenuImagesType;
+ $alt_leaf = '->';
+ $img_space = $this->imgwww . $this->phpTreeMenuTheme . 'tree_space.' . $this->phpTreeMenuImagesType;
+ $alt_space = ' ';
+ $img_split = $this->imgwww . $this->phpTreeMenuTheme . 'tree_split.' . $this->phpTreeMenuImagesType;
+ $alt_split = '|-';
+ $img_split_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_split_first.' . $this->phpTreeMenuImagesType;
+ $alt_split_first = '|-';
+ $img_vertline = $this->imgwww . $this->phpTreeMenuTheme . 'tree_vertline.' . $this->phpTreeMenuImagesType;
+ $alt_vertline = '| ';
+
+ for ($i=$this->_firstItem[$menu_name]; $i<=$this->_lastItem[$menu_name]; $i++) {
+ $expand[$i] = 0;
+ $visible[$i] = 0;
+ $this->tree[$i]['last_item'] = 0;
+ }
+ for ($i=0; $i<=$this->_maxLevel[$menu_name]; $i++) {
+ $levels[$i] = 0;
+ }
+
+ // Get numbers of nodes to be expanded
+ if ($p != '') {
+ $explevels = explode($this->phpTreeMenuSeparator, $p);
+ $explevels_count = count($explevels);
+ for ($i=0; $i<$explevels_count; $i++) {
+ $expand[$explevels[$i]] = 1;
+ }
+ }
+
+ // Find last nodes of subtrees
+ $last_level = $this->_maxLevel[$menu_name];
+ for ($i=$this->_lastItem[$menu_name]; $i>=$this->_firstItem[$menu_name]; $i--) {
+ if ($this->tree[$i]['level'] < $last_level) {
+ for ($j=$this->tree[$i]['level']+1; $j<=$this->_maxLevel[$menu_name]; $j++) {
+ $levels[$j] = 0;
+ }
+ }
+ if ($levels[$this->tree[$i]['level']] == 0) {
+ $levels[$this->tree[$i]['level']] = 1;
+ $this->tree[$i]['last_item'] = 1;
+ } else {
+ $this->tree[$i]['last_item'] = 0;
+ }
+ $last_level = $this->tree[$i]['level'];
+ }
+
+ // Determine visible nodes
+ // all root nodes are always visible
+ for ($i=$this->_firstItem[$menu_name]; $i<=$this->_lastItem[$menu_name]; $i++) {
+ if ($this->tree[$i]['level'] == 1) {
+ $visible[$i] = 1;
+ }
+ }
+ if (isset($explevels)) {
+ for ($i=0; $i<$explevels_count; $i++) {
+ $n = $explevels[$i];
+ if ($n >= $this->_firstItem[$menu_name] && $n <= $this->_lastItem[$menu_name] && $visible[$n] == 1 && $expand[$n] == 1) {
+ $j = $n + 1;
+ while ($j<=$this->_lastItem[$menu_name] && $this->tree[$j]['level']>$this->tree[$n]['level']) {
+ if ($this->tree[$j]['level'] == $this->tree[$n]['level']+1) {
+ $visible[$j] = 1;
+ }
+ $j++;
+ }
+ }
+ }
+ }
+
+ // Output nicely formatted tree
+ for ($i=0; $i<$this->_maxLevel[$menu_name]; $i++) {
+ $levels[$i] = 1;
+ }
+ $max_visible_level = 0;
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
+ if ($visible[$cnt]) {
+ $max_visible_level = max($max_visible_level, $this->tree[$cnt]['level']);
+ }
+ }
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
+ if ($this->tree[$cnt]['text'] == '---') {
+ continue; // separators are significant only for layers-based menus
+ }
+
+ if (isset($this->tree[$cnt]['selected']) && $this->tree[$cnt]['selected']) {
+ $linkstyle = 'phplmselected';
+ } else {
+ $linkstyle = 'phplm';
+ }
+
+ if ($visible[$cnt]) {
+ $this->_phpTreeMenu[$menu_name] .= '<div class="treemenudiv">' . "\n";
+
+ // vertical lines from higher levels
+ for ($i=0; $i<$this->tree[$cnt]['level']-1; $i++) {
+ if ($levels[$i] == 1) {
+ $img = $img_vertline;
+ $alt = $alt_vertline;
+ } else {
+ $img = $img_space;
+ $alt = $alt_space;
+ }
+ $this->_phpTreeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />';
+ }
+
+ $not_a_leaf = $cnt<$this->_lastItem[$menu_name] && $this->tree[$cnt+1]['level']>$this->tree[$cnt]['level'];
+
+ if ($not_a_leaf) {
+ // Create expand/collapse parameters
+ $params = '';
+ for ($i=$this->_firstItem[$menu_name]; $i<=$this->_lastItem[$menu_name]; $i++) {
+ if ($expand[$i] == 1 && $cnt!= $i || ($expand[$i] == 0 && $cnt == $i)) {
+ $params .= $this->phpTreeMenuSeparator . $i;
+ }
+ }
+ if ($params != '') {
+ $params = substr($params, 1);
+ }
+ }
+
+ if ($this->tree[$cnt]['last_item'] == 1) {
+ // corner at end of subtree or t-split
+ if ($not_a_leaf) {
+ if ($expand[$cnt] == 0) {
+ if ($cnt == $this->_firstItem[$menu_name]) {
+ $img = $img_expand_corner_first;
+ $alt = $alt_expand_corner_first;
+ } else {
+ $img = $img_expand_corner;
+ $alt = $alt_expand_corner;
+ }
+ } else {
+ if ($cnt == $this->_firstItem[$menu_name]) {
+ $img = $img_collapse_corner_first;
+ $alt = $alt_collapse_corner_first;
+ } else {
+ $img = $img_collapse_corner;
+ $alt = $alt_collapse_corner;
+ }
+ }
+ $this->_phpTreeMenu[$menu_name] .= '<a name="' . $cnt . '" class="' . $linkstyle . '" href="' . $url . $query . $params . '#' . $cnt . '"><img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" /></a>';
+ } else {
+ $this->_phpTreeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img_corner . '" alt="' . $alt_corner . '" />';
+ }
+ $levels[$this->tree[$cnt]['level']-1] = 0;
+ } else {
+ if ($not_a_leaf) {
+ if ($expand[$cnt] == 0) {
+ if ($cnt == $this->_firstItem[$menu_name]) {
+ $img = $img_expand_first;
+ $alt = $alt_expand_first;
+ } else {
+ $img = $img_expand;
+ $alt = $alt_expand;
+ }
+ } else {
+ if ($cnt == $this->_firstItem[$menu_name]) {
+ $img = $img_collapse_first;
+ $alt = $alt_collapse_first;
+ } else {
+ $img = $img_collapse;
+ $alt = $alt_collapse;
+ }
+ }
+ $this->_phpTreeMenu[$menu_name] .= '<a name="' . $cnt . '" class="' . $linkstyle . '" href="' . $url . $query . $params . '#' . $cnt . '"><img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" /></a>';
+ } else {
+ if ($cnt == $this->_firstItem[$menu_name]) {
+ $img = $img_split_first;
+ $alt = $alt_split_first;
+ } else {
+ $img = $img_split;
+ $alt = $alt_split;
+ }
+ $this->_phpTreeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />';
+ }
+ $levels[$this->tree[$cnt]['level']-1] = 1;
+ }
+
+ if ($this->tree[$cnt]['parsed_href'] == '' || $this->tree[$cnt]['parsed_href'] == '#') {
+ $a_href_open_img = '';
+ $a_href_close_img = '';
+ $a_href_open = '<a class="phplmnormal">';
+ $a_href_close = '</a>';
+ } else {
+ $a_href_open_img = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . '>';
+ $a_href_close_img = '</a>';
+ $a_href_open = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . ' class="' . $linkstyle . '">';
+ $a_href_close = '</a>';
+ }
+
+ if ($not_a_leaf) {
+ if ($expand[$cnt] == 1) {
+ $img = $img_folder_open;
+ $alt = $alt_folder_open;
+ } else {
+ $img = $img_folder_closed;
+ $alt = $alt_folder_closed;
+ }
+ $this->_phpTreeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />' . $a_href_close_img;
+ } else {
+ if ($this->tree[$cnt]['parsed_icon'] != '') {
+ $this->_phpTreeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" src="' . $this->tree[$cnt]['parsed_icon'] . '" width="' . $this->tree[$cnt]['iconwidth'] . '" height="' . $this->tree[$cnt]['iconheight'] . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
+ } else {
+ $this->_phpTreeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" src="' . $img_leaf . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
+ }
+ }
+
+ // output item text
+ $foobar = $max_visible_level - $this->tree[$cnt]['level'] + 1;
+ if ($foobar > 1) {
+ $colspan = ' colspan="' . $foobar . '"';
+ } else {
+ $colspan = '';
+ }
+ $this->_phpTreeMenu[$menu_name] .= ' ' . $a_href_open . $this->tree[$cnt]['parsed_text'] . $a_href_close . "\n";
+ $this->_phpTreeMenu[$menu_name] .= '</div>' . "\n";
+ }
+ }
+/* ********************************************************* */
+
+/*
+ $this->_phpTreeMenu[$menu_name] =
+ '<div class="phplmnormal">' . "\n" .
+ $this->_phpTreeMenu[$menu_name] .
+ '</div>' . "\n";
+*/
+ // Some (old) browsers do not support the "white-space: nowrap;" CSS property...
+ $this->_phpTreeMenu[$menu_name] =
+ '<table cellspacing="0" cellpadding="0" border="0">' . "\n" .
+ '<tr>' . "\n" .
+ '<td class="phplmnormal" nowrap="nowrap">' . "\n" .
+ $this->_phpTreeMenu[$menu_name] .
+ '</td>' . "\n" .
+ '</tr>' . "\n" .
+ '</table>' . "\n";
+
+ return $this->_phpTreeMenu[$menu_name];
+}
+
+/**
+* Method that returns the code of the requested PHP Tree Menu
+* @access public
+* @param string $menu_name the name of the menu whose PHP Tree Menu code
+* has to be returned
+* @return string
+*/
+function getPHPTreeMenu($menu_name)
+{
+ return $this->_phpTreeMenu[$menu_name];
+}
+
+/**
+* Method that prints the code of the requested PHP Tree Menu
+* @access public
+* @param string $menu_name the name of the menu whose PHP Tree Menu code
+* has to be printed
+* @return void
+*/
+function printPHPTreeMenu($menu_name)
+{
+ print $this->_phpTreeMenu[$menu_name];
+}
+
+} /* END OF CLASS */
+
+?>
diff --git a/gosa-core/include/layer-menu/lib/plainmenu.inc.php b/gosa-core/include/layer-menu/lib/plainmenu.inc.php
--- /dev/null
@@ -0,0 +1,281 @@
+<?php
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+/**
+* This file contains the code of the PlainMenu class.
+* @package PHPLayersMenu
+*/
+
+/**
+* This is the PlainMenu class of the PHP Layers Menu library.
+*
+* This class depends on the LayersMenuCommon class and on the PEAR conforming version of the PHPLib Template class, i.e. on HTML_Template_PHPLIB. It provides plain menus, that to do not require JavaScript to work.
+*
+* @version 3.2.0-rc
+* @package PHPLayersMenu
+*/
+class PlainMenu extends LayersMenuCommon
+{
+
+/**
+* The template to be used for the Plain Menu
+*/
+var $plainMenuTpl;
+/**
+* An array where we store the Plain Menu code for each menu
+* @access private
+* @var array
+*/
+var $_plainMenu;
+
+/**
+* The template to be used for the Horizontal Plain Menu
+*/
+var $horizontalPlainMenuTpl;
+/**
+* An array where we store the Horizontal Plain Menu code for each menu
+* @access private
+* @var array
+*/
+var $_horizontalPlainMenu;
+
+/**
+* The constructor method; it initializates some variables
+* @return void
+*/
+function PlainMenu()
+{
+ $this->LayersMenuCommon();
+
+ $this->plainMenuTpl = $this->tpldir . 'layersmenu-plain_menu.ihtml';
+ $this->_plainMenu = array();
+
+ $this->horizontalPlainMenuTpl = $this->tpldir . 'layersmenu-horizontal_plain_menu.ihtml';
+ $this->_horizontalPlainMenu = array();
+}
+
+/**
+* The method to set the dirroot directory
+* @access public
+* @return boolean
+*/
+function setDirroot($dirroot)
+{
+ $oldtpldir = $this->tpldir;
+ if ($foobar = $this->setDirrootCommon($dirroot)) {
+ $this->updateTpldir($oldtpldir);
+ }
+ return $foobar;
+}
+
+/**
+* The method to set the tpldir directory
+* @access public
+* @return boolean
+*/
+function setTpldir($tpldir)
+{
+ $oldtpldir = $this->tpldir;
+ if ($foobar = $this->setTpldirCommon($tpldir)) {
+ $this->updateTpldir($oldtpldir);
+ }
+ return $foobar;
+}
+
+/**
+* The method to update the templates directory path to the new tpldir
+* @access private
+* @return void
+*/
+function updateTpldir($oldtpldir)
+{
+ $oldlength = strlen($oldtpldir);
+ $foobar = strpos($this->plainMenuTpl, $oldtpldir);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->plainMenuTpl = $this->tpldir . substr($this->plainMenuTpl, $oldlength);
+ }
+ $foobar = strpos($this->horizontalPlainMenuTpl, $oldtpldir);
+ if (!($foobar === false || $foobar != 0)) {
+ $this->horizontalPlainMenuTpl = $this->tpldir . substr($this->horizontalPlainMenuTpl, $oldlength);
+ }
+}
+
+/**
+* The method to set plainMenuTpl
+* @access public
+* @return boolean
+*/
+function setPlainMenuTpl($plainMenuTpl)
+{
+ if (str_replace('/', '', $plainMenuTpl) == $plainMenuTpl) {
+ $plainMenuTpl = $this->tpldir . $plainMenuTpl;
+ }
+ if (!file_exists($plainMenuTpl)) {
+ $this->error("setPlainMenuTpl: file $plainMenuTpl does not exist.");
+ return false;
+ }
+ $this->plainMenuTpl = $plainMenuTpl;
+ return true;
+}
+
+/**
+* Method to prepare a new Plain Menu.
+*
+* This method processes items of a menu to prepare and return
+* the corresponding Plain Menu code.
+*
+* @access public
+* @param string $menu_name the name of the menu whose items have to be processed
+* @return string
+*/
+function newPlainMenu(
+ $menu_name = '' // non consistent default...
+ )
+{
+ $plain_menu_blck = '';
+ $t = new Template_PHPLIB();
+ $t->setFile('tplfile', $this->plainMenuTpl);
+ $t->setBlock('tplfile', 'template', 'template_blck');
+ $t->setBlock('template', 'plain_menu_cell', 'plain_menu_cell_blck');
+ $t->setVar('plain_menu_cell_blck', '');
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
+ if ($this->tree[$cnt]['text'] == '---') {
+ continue; // separators are significant only for layers-based menus
+ }
+ $nbsp = '';
+ for ($i=1; $i<$this->tree[$cnt]['level']; $i++) {
+ $nbsp .= ' ';
+ }
+ $t->setVar(array(
+ 'nbsp' => $nbsp,
+ 'href' => $this->tree[$cnt]['parsed_href'],
+ 'title' => $this->tree[$cnt]['parsed_title'],
+ 'target' => $this->tree[$cnt]['parsed_target'],
+ 'text' => $this->tree[$cnt]['parsed_text']
+ ));
+ $plain_menu_blck .= $t->parse('plain_menu_cell_blck', 'plain_menu_cell', false);
+ }
+ $t->setVar('plain_menu_cell_blck', $plain_menu_blck);
+ $this->_plainMenu[$menu_name] = $t->parse('template_blck', 'template');
+
+ return $this->_plainMenu[$menu_name];
+}
+
+/**
+* Method that returns the code of the requested Plain Menu
+* @access public
+* @param string $menu_name the name of the menu whose Plain Menu code
+* has to be returned
+* @return string
+*/
+function getPlainMenu($menu_name)
+{
+ return $this->_plainMenu[$menu_name];
+}
+
+/**
+* Method that prints the code of the requested Plain Menu
+* @access public
+* @param string $menu_name the name of the menu whose Plain Menu code
+* has to be printed
+* @return void
+*/
+function printPlainMenu($menu_name)
+{
+ print $this->_plainMenu[$menu_name];
+}
+
+/**
+* The method to set horizontalPlainMenuTpl
+* @access public
+* @return boolean
+*/
+function setHorizontalPlainMenuTpl($horizontalPlainMenuTpl)
+{
+ if (str_replace('/', '', $horizontalPlainMenuTpl) == $horizontalPlainMenuTpl) {
+ $horizontalPlainMenuTpl = $this->tpldir . $horizontalPlainMenuTpl;
+ }
+ if (!file_exists($horizontalPlainMenuTpl)) {
+ $this->error("setHorizontalPlainMenuTpl: file $horizontalPlainMenuTpl does not exist.");
+ return false;
+ }
+ $this->horizontalPlainMenuTpl = $horizontalPlainMenuTpl;
+ return true;
+}
+
+/**
+* Method to prepare a new Horizontal Plain Menu.
+*
+* This method processes items of a menu to prepare and return
+* the corresponding Horizontal Plain Menu code.
+*
+* @access public
+* @param string $menu_name the name of the menu whose items have to be processed
+* @return string
+*/
+function newHorizontalPlainMenu(
+ $menu_name = '' // non consistent default...
+ )
+{
+ $horizontal_plain_menu_blck = '';
+ $t = new Template_PHPLIB();
+ $t->setFile('tplfile', $this->horizontalPlainMenuTpl);
+ $t->setBlock('tplfile', 'template', 'template_blck');
+ $t->setBlock('template', 'horizontal_plain_menu_cell', 'horizontal_plain_menu_cell_blck');
+ $t->setVar('horizontal_plain_menu_cell_blck', '');
+ $t->setBlock('horizontal_plain_menu_cell', 'plain_menu_cell', 'plain_menu_cell_blck');
+ $t->setVar('plain_menu_cell_blck', '');
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
+ if ($this->tree[$cnt]['text'] == '---') {
+ continue; // separators are significant only for layers-based menus
+ }
+ if ($this->tree[$cnt]['level'] == 1 && $cnt > $this->_firstItem[$menu_name]) {
+ $t->parse('horizontal_plain_menu_cell_blck', 'horizontal_plain_menu_cell', true);
+ $t->setVar('plain_menu_cell_blck', '');
+ }
+ $nbsp = '';
+ for ($i=1; $i<$this->tree[$cnt]['level']; $i++) {
+ $nbsp .= ' ';
+ }
+ $t->setVar(array(
+ 'nbsp' => $nbsp,
+ 'href' => $this->tree[$cnt]['parsed_href'],
+ 'title' => $this->tree[$cnt]['parsed_title'],
+ 'target' => $this->tree[$cnt]['parsed_target'],
+ 'text' => $this->tree[$cnt]['parsed_text']
+ ));
+ $t->parse('plain_menu_cell_blck', 'plain_menu_cell', true);
+ }
+ $t->parse('horizontal_plain_menu_cell_blck', 'horizontal_plain_menu_cell', true);
+ $this->_horizontalPlainMenu[$menu_name] = $t->parse('template_blck', 'template');
+
+ return $this->_horizontalPlainMenu[$menu_name];
+}
+
+/**
+* Method that returns the code of the requested Horizontal Plain Menu
+* @access public
+* @param string $menu_name the name of the menu whose Horizontal Plain Menu code
+* has to be returned
+* @return string
+*/
+function getHorizontalPlainMenu($menu_name)
+{
+ return $this->_horizontalPlainMenu[$menu_name];
+}
+
+/**
+* Method that prints the code of the requested Horizontal Plain Menu
+* @access public
+* @param string $menu_name the name of the menu whose Horizontal Plain Menu code
+* has to be printed
+* @return void
+*/
+function printHorizontalPlainMenu($menu_name)
+{
+ print $this->_horizontalPlainMenu[$menu_name];
+}
+
+} /* END OF CLASS */
+
+?>
diff --git a/gosa-core/include/layer-menu/lib/treemenu.inc.php b/gosa-core/include/layer-menu/lib/treemenu.inc.php
--- /dev/null
@@ -0,0 +1,352 @@
+<?php
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+/**
+* This file contains the code of the TreeMenu class.
+* @package PHPLayersMenu
+*/
+
+/**
+* This is the TreeMenu class of the PHP Layers Menu library.
+*
+* This class depends on the LayersMenuCommon class and on the PEAR conforming version of the PHPLib Template class, i.e. on HTML_Template_PHPLIB
+*
+* @version 3.2.0-rc
+* @package PHPLayersMenu
+*/
+class TreeMenu extends LayersMenuCommon
+{
+
+/**
+* Type of images used for the Tree Menu
+* @access private
+* @var string
+*/
+var $treeMenuImagesType;
+/**
+* Prefix for filenames of images of a theme
+* @access private
+* @var string
+*/
+var $treeMenuTheme;
+/**
+* An array where we store the Tree Menu code for each menu
+* @access private
+* @var array
+*/
+var $_treeMenu;
+
+/**
+* The constructor method; it initializates the menu system
+* @return void
+*/
+function TreeMenu()
+{
+ $this->LayersMenuCommon();
+
+ $this->treeMenuImagesType = 'png';
+ $this->treeMenuTheme = '';
+ $this->_treeMenu = array();
+
+ $this->_nodesCount = 0;
+ $this->tree = array();
+ $this->_maxLevel = array();
+ $this->_firstLevelCnt = array();
+ $this->_firstItem = array();
+ $this->_lastItem = array();
+}
+
+/**
+* The method to set the dirroot directory
+* @access public
+* @return boolean
+*/
+function setDirroot($dirroot)
+{
+ return $this->setDirrootCommon($dirroot);
+}
+
+/**
+* The method to set the type of images used for the Tree Menu
+* @access public
+* @return void
+*/
+function setTreeMenuImagesType($treeMenuImagesType)
+{
+ $this->treeMenuImagesType = $treeMenuImagesType;
+}
+
+/**
+* The method to set the prefix for filenames of images of a theme
+* @access public
+* @return void
+*/
+function setTreeMenuTheme($treeMenuTheme)
+{
+ $this->treeMenuTheme = $treeMenuTheme;
+}
+
+/**
+* Method to prepare a new Tree Menu.
+*
+* This method processes items of a menu to prepare and return
+* the corresponding Tree Menu code.
+*
+* @access public
+* @param string $menu_name the name of the menu whose items have to be processed
+* @return string
+*/
+function newTreeMenu(
+ $menu_name = '' // non consistent default...
+ )
+{
+ if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) {
+ $this->error("newTreeMenu: the first/last item of the menu '$menu_name' is not defined; please check if you have parsed its menu data.");
+ return 0;
+ }
+
+ $this->_treeMenu[$menu_name] = '';
+
+ $img_collapse = $this->imgwww . $this->treeMenuTheme . 'tree_collapse.' . $this->treeMenuImagesType;
+ $alt_collapse = '--';
+ $img_collapse_corner = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_corner.' . $this->treeMenuImagesType;
+ $alt_collapse_corner = '--';
+ $img_collapse_corner_first = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_corner_first.' . $this->treeMenuImagesType;
+ $alt_collapse_corner_first = '--';
+ $img_collapse_first = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_first.' . $this->treeMenuImagesType;
+ $alt_collapse_first = '--';
+ $img_corner = $this->imgwww . $this->treeMenuTheme . 'tree_corner.' . $this->treeMenuImagesType;
+ $alt_corner = '`-';
+ $img_expand = $this->imgwww . $this->treeMenuTheme . 'tree_expand.' . $this->treeMenuImagesType;
+ $alt_expand = '+-';
+ $img_expand_corner = $this->imgwww . $this->treeMenuTheme . 'tree_expand_corner.' . $this->treeMenuImagesType;
+ $alt_expand_corner = '+-';
+ $img_expand_corner_first = $this->imgwww . $this->treeMenuTheme . 'tree_expand_corner_first.' . $this->treeMenuImagesType;
+ $alt_expand_corner_first = '+-';
+ $img_expand_first = $this->imgwww . $this->treeMenuTheme . 'tree_expand_first.' . $this->treeMenuImagesType;
+ $alt_expand_first = '+-';
+ $img_folder_closed = $this->imgwww . $this->treeMenuTheme . 'tree_folder_closed.' . $this->treeMenuImagesType;
+ $alt_folder_closed = '->';
+ $img_folder_open = $this->imgwww . $this->treeMenuTheme . 'tree_folder_open.' . $this->treeMenuImagesType;
+ $alt_folder_open = '->';
+ $img_leaf = $this->imgwww . $this->treeMenuTheme . 'tree_leaf.' . $this->treeMenuImagesType;
+ $alt_leaf = '->';
+ $img_space = $this->imgwww . $this->treeMenuTheme . 'tree_space.' . $this->treeMenuImagesType;
+ $alt_space = ' ';
+ $img_split = $this->imgwww . $this->treeMenuTheme . 'tree_split.' . $this->treeMenuImagesType;
+ $alt_split = '|-';
+ $img_split_first = $this->imgwww . $this->treeMenuTheme . 'tree_split_first.' . $this->treeMenuImagesType;
+ $alt_split_first = '|-';
+ $img_vertline = $this->imgwww . $this->treeMenuTheme . 'tree_vertline.' . $this->treeMenuImagesType;
+ $alt_vertline = '| ';
+
+ for ($i=0; $i<=$this->_maxLevel[$menu_name]; $i++) {
+ $levels[$i] = 0;
+ }
+
+ // Find last nodes of subtrees
+ $last_level = $this->_maxLevel[$menu_name];
+ for ($i=$this->_lastItem[$menu_name]; $i>=$this->_firstItem[$menu_name]; $i--) {
+ if ($this->tree[$i]['level'] < $last_level) {
+ for ($j=$this->tree[$i]['level']+1; $j<=$this->_maxLevel[$menu_name]; $j++) {
+ $levels[$j] = 0;
+ }
+ }
+ if ($levels[$this->tree[$i]['level']] == 0) {
+ $levels[$this->tree[$i]['level']] = 1;
+ $this->tree[$i]['last_item'] = 1;
+ } else {
+ $this->tree[$i]['last_item'] = 0;
+ }
+ $last_level = $this->tree[$i]['level'];
+ }
+
+ $toggle = '';
+ $toggle_function_name = 'toggle' . $menu_name;
+
+ for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
+ if ($this->tree[$cnt]['text'] == '---') {
+ continue; // separators are significant only for layers-based menus
+ }
+
+ if (isset($this->tree[$cnt]['selected']) && $this->tree[$cnt]['selected']) {
+ $linkstyle = 'phplmselected';
+ } else {
+ $linkstyle = 'phplm';
+ }
+
+ $this->_treeMenu[$menu_name] .= '<div id="jt' . $cnt . '" class="treemenudiv">' . "\n";
+
+ // vertical lines from higher levels
+ for ($i=0; $i<$this->tree[$cnt]['level']-1; $i++) {
+ if ($levels[$i] == 1) {
+ $img = $img_vertline;
+ $alt = $alt_vertline;
+ } else {
+ $img = $img_space;
+ $alt = $alt_space;
+ }
+ $this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />';
+ }
+
+ $not_a_leaf = $cnt<$this->_lastItem[$menu_name] && $this->tree[$cnt+1]['level']>$this->tree[$cnt]['level'];
+
+ if ($this->tree[$cnt]['last_item'] == 1) {
+ // corner at end of subtree or t-split
+ if ($not_a_leaf) {
+ if ($cnt == $this->_firstItem[$menu_name]) {
+ $img = $img_collapse_corner_first;
+ $alt = $alt_collapse_corner_first;
+ } else {
+ $img = $img_collapse_corner;
+ $alt = $alt_collapse_corner;
+ }
+ $this->_treeMenu[$menu_name] .= '<a onmousedown="' . $toggle_function_name . "('" . $cnt . "')" . '"><img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" /></a>';
+ } else {
+ $this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img_corner . '" alt="' . $alt_corner . '" />';
+ }
+ $levels[$this->tree[$cnt]['level']-1] = 0;
+ } else {
+ if ($not_a_leaf) {
+ if ($cnt == $this->_firstItem[$menu_name]) {
+ $img = $img_collapse_first;
+ $alt = $alt_collapse_first;
+ } else {
+ $img = $img_collapse;
+ $alt = $alt_collapse;
+ }
+ $this->_treeMenu[$menu_name] .= '<a onmousedown="' . $toggle_function_name . "('" . $cnt . "');" . '"><img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" /></a>';
+ } else {
+ if ($cnt == $this->_firstItem[$menu_name]) {
+ $img = $img_split_first;
+ $alt = $alt_split_first;
+ } else {
+ $img = $img_split;
+ $alt = $alt_split;
+ }
+ $this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" />';
+ }
+ $levels[$this->tree[$cnt]['level']-1] = 1;
+ }
+
+ if ($this->tree[$cnt]['parsed_href'] == '' || $this->tree[$cnt]['parsed_href'] == '#') {
+ $a_href_open_img = '';
+ $a_href_close_img = '';
+ $a_href_open = '<a class="phplmnormal">';
+ $a_href_close = '</a>';
+ } else {
+ $a_href_open_img = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . '>';
+ $a_href_close_img = '</a>';
+ $a_href_open = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . ' class="' . $linkstyle . '">';
+ $a_href_close = '</a>';
+ }
+
+ if ($not_a_leaf) {
+ $this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" id="jt' . $cnt . 'folder" src="' . $img_folder_open . '" alt="' . $alt_folder_open . '" />' . $a_href_close_img;
+ } else {
+ if ($this->tree[$cnt]['parsed_icon'] != '') {
+ $this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" src="' . $this->tree[$cnt]['parsed_icon'] . '" width="' . $this->tree[$cnt]['iconwidth'] . '" height="' . $this->tree[$cnt]['iconheight'] . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
+ } else {
+ $this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" src="' . $img_leaf . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
+ }
+ }
+ $this->_treeMenu[$menu_name] .= ' ' . $a_href_open . $this->tree[$cnt]['text'] . $a_href_close . "\n";
+ $this->_treeMenu[$menu_name] .= '</div>' . "\n";
+
+ if ($cnt<$this->_lastItem[$menu_name] && $this->tree[$cnt]['level']<$this->tree[$cnt+1]['level']) {
+ $this->_treeMenu[$menu_name] .= '<div id="jt' . $cnt . 'son" class="treemenudiv">' . "\n";
+ if ($this->tree[$cnt]['expanded'] != 1) {
+ $toggle .= 'if (phplm_expand[' . $cnt . '] != 1) ' . $toggle_function_name . "('" . $cnt . "');\n";
+ } else {
+ $toggle .= 'if (phplm_collapse[' . $cnt . '] == 1) ' . $toggle_function_name . "('" . $cnt . "');\n";
+ }
+ }
+
+ if ($cnt>$this->_firstItem[$menu_name] && $this->tree[$cnt]['level']>$this->tree[$cnt+1]['level']) {
+ for ($i=max(1, $this->tree[$cnt+1]['level']); $i<$this->tree[$cnt]['level']; $i++) {
+ $this->_treeMenu[$menu_name] .= '</div>' . "\n";
+ }
+ }
+ }
+
+/*
+ $this->_treeMenu[$menu_name] =
+ '<div class="phplmnormal">' . "\n" .
+ $this->_treeMenu[$menu_name] .
+ '</div>' . "\n";
+*/
+ // Some (old) browsers do not support the "white-space: nowrap;" CSS property...
+ $this->_treeMenu[$menu_name] =
+ '<table cellspacing="0" cellpadding="0" border="0">' . "\n" .
+ '<tr>' . "\n" .
+ '<td class="phplmnormal" nowrap="nowrap">' . "\n" .
+ $this->_treeMenu[$menu_name] .
+ '</td>' . "\n" .
+ '</tr>' . "\n" .
+ '</table>' . "\n";
+
+ $t = new Template_PHPLIB();
+ $t->setFile('tplfile', $this->libjsdir . 'layerstreemenu.ijs');
+ $t->setVar(array(
+ 'toggle_function_name' => $toggle_function_name,
+ 'img_collapse' => $img_collapse,
+ 'img_collapse_corner' => $img_collapse_corner,
+ 'img_collapse_corner_first' => $img_collapse_corner_first,
+ 'img_collapse_first' => $img_collapse_first,
+ 'img_expand' => $img_expand,
+ 'img_expand_corner' => $img_expand_corner,
+ 'img_expand_corner_first' => $img_expand_corner_first,
+ 'img_expand_first' => $img_expand_first,
+ 'img_folder_closed' => $img_folder_closed,
+ 'img_folder_open' => $img_folder_open
+ ));
+ $toggle_function = $t->parse('out', 'tplfile');
+ $toggle_function =
+ '<script language="JavaScript" type="text/javascript">' . "\n" .
+ '<!--' . "\n" .
+ $toggle_function .
+ '// -->' . "\n" .
+ '</script>' . "\n";
+
+ $toggle =
+ '<script language="JavaScript" type="text/javascript">' . "\n" .
+ '<!--' . "\n" .
+ 'if ((DOM && !Opera56 && !Konqueror22) || IE4) {' . "\n" .
+ $toggle .
+ '}' . "\n" .
+ 'if (NS4) alert("Only the accessibility is provided to Netscape 4 on the JavaScript Tree Menu.\nWe *strongly* suggest you to upgrade your browser.");' . "\n" .
+ '// -->' . "\n" .
+ '</script>' . "\n";
+
+ $this->_treeMenu[$menu_name] = $toggle_function . "\n" . $this->_treeMenu[$menu_name] . "\n" . $toggle;
+
+ return $this->_treeMenu[$menu_name];
+}
+
+/**
+* Method that returns the code of the requested Tree Menu
+* @access public
+* @param string $menu_name the name of the menu whose Tree Menu code
+* has to be returned
+* @return string
+*/
+function getTreeMenu($menu_name)
+{
+ return $this->_treeMenu[$menu_name];
+}
+
+/**
+* Method that prints the code of the requested Tree Menu
+* @access public
+* @param string $menu_name the name of the menu whose Tree Menu code
+* has to be printed
+* @return void
+*/
+function printTreeMenu($menu_name)
+{
+ print $this->_treeMenu[$menu_name];
+}
+
+} /* END OF CLASS */
+
+?>
diff --git a/gosa-core/include/layer-menu/libjs/layersmenu-browser_detection.js b/gosa-core/include/layer-menu/libjs/layersmenu-browser_detection.js
--- /dev/null
@@ -0,0 +1,33 @@
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+DOM = (document.getElementById) ? 1 : 0;
+NS4 = (document.layers) ? 1 : 0;
+// We need to explicitly detect Konqueror
+// because Konqueror 3 sets IE = 1 ... AAAAAAAAAARGHHH!!!
+Konqueror = (navigator.userAgent.indexOf('Konqueror') > -1) ? 1 : 0;
+// We need to detect Konqueror 2.2 as it does not handle the window.onresize event
+Konqueror22 = (navigator.userAgent.indexOf('Konqueror 2.2') > -1 || navigator.userAgent.indexOf('Konqueror/2.2') > -1) ? 1 : 0;
+Konqueror30 =
+ (
+ navigator.userAgent.indexOf('Konqueror 3.0') > -1
+ || navigator.userAgent.indexOf('Konqueror/3.0') > -1
+ || navigator.userAgent.indexOf('Konqueror 3;') > -1
+ || navigator.userAgent.indexOf('Konqueror/3;') > -1
+ || navigator.userAgent.indexOf('Konqueror 3)') > -1
+ || navigator.userAgent.indexOf('Konqueror/3)') > -1
+ )
+ ? 1 : 0;
+Konqueror31 = (navigator.userAgent.indexOf('Konqueror 3.1') > -1 || navigator.userAgent.indexOf('Konqueror/3.1') > -1) ? 1 : 0;
+// We need to detect Konqueror 3.2 and 3.3 as they are affected by the see-through effect only for 2 form elements
+Konqueror32 = (navigator.userAgent.indexOf('Konqueror 3.2') > -1 || navigator.userAgent.indexOf('Konqueror/3.2') > -1) ? 1 : 0;
+Konqueror33 = (navigator.userAgent.indexOf('Konqueror 3.3') > -1 || navigator.userAgent.indexOf('Konqueror/3.3') > -1) ? 1 : 0;
+Opera = (navigator.userAgent.indexOf('Opera') > -1) ? 1 : 0;
+Opera5 = (navigator.userAgent.indexOf('Opera 5') > -1 || navigator.userAgent.indexOf('Opera/5') > -1) ? 1 : 0;
+Opera6 = (navigator.userAgent.indexOf('Opera 6') > -1 || navigator.userAgent.indexOf('Opera/6') > -1) ? 1 : 0;
+Opera56 = Opera5 || Opera6;
+IE = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
+IE = IE && !Opera;
+IE5 = IE && DOM;
+IE4 = (document.all) ? 1 : 0;
+IE4 = IE4 && IE && !DOM;
+
diff --git a/gosa-core/include/layer-menu/libjs/layersmenu-footer.ijs b/gosa-core/include/layer-menu/libjs/layersmenu-footer.ijs
--- /dev/null
@@ -0,0 +1,11 @@
+<!-- beginning of menu footer - {packageName} {version} {copyright} {author} -->
+
+{footer}
+
+<script language="JavaScript" type="text/javascript">
+<!--
+loaded = 1;
+// -->
+</script>
+
+<!-- end of menu footer - {packageName} {version} {copyright} {author} -->
diff --git a/gosa-core/include/layer-menu/libjs/layersmenu-header.ijs b/gosa-core/include/layer-menu/libjs/layersmenu-header.ijs
--- /dev/null
@@ -0,0 +1,57 @@
+<!-- beginning of menu header - {packageName} {version} {copyright} {author} -->
+
+<script language="JavaScript" type="text/javascript">
+<!--
+
+menuTopShift = {menuTopShift};
+menuRightShift = {menuRightShift};
+menuLeftShift = {menuLeftShift};
+
+var thresholdY = {thresholdY};
+var abscissaStep = {abscissaStep};
+
+toBeHidden = new Array();
+toBeHiddenLeft = new Array();
+toBeHiddenTop = new Array();
+
+{listl}
+var numl = listl.length;
+
+father = new Array();
+for (i=1; i<={nodesCount}; i++) {
+ father['L' + i] = '';
+}
+{father_keys}
+{father_vals}
+for (i=0; i<father_keys.length; i++) {
+ father[father_keys[i]] = father_vals[i];
+}
+
+lwidth = new Array();
+var lwidthDetected = 0;
+
+function moveLayers()
+{
+ if (!lwidthDetected) {
+ for (i=0; i<numl; i++) {
+ lwidth[listl[i]] = getOffsetWidth(listl[i]);
+ }
+ lwidthDetected = 1;
+ }
+ if (IE4) {
+ for (i=0; i<numl; i++) {
+ setWidth(listl[i], abscissaStep);
+ }
+ }
+{moveLayers}
+}
+
+back = new Array();
+for (i=1; i<={nodesCount}; i++) {
+ back['L' + i] = 0;
+}
+
+// -->
+</script>
+
+<!-- end of menu header - {packageName} {version} {copyright} {author} -->
diff --git a/gosa-core/include/layer-menu/libjs/layersmenu-library.js b/gosa-core/include/layer-menu/libjs/layersmenu-library.js
--- /dev/null
@@ -0,0 +1,248 @@
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+layerLeft = new Array();
+layerTop = new Array();
+
+function setVisibility(layer, on)
+{
+ if (on) {
+ if (DOM) {
+ document.getElementById(layer).style.visibility = 'visible';
+ } else if (NS4) {
+ document.layers[layer].visibility = 'show';
+ } else {
+ document.all[layer].style.visibility = 'visible';
+ }
+ } else {
+ if (DOM) {
+ document.getElementById(layer).style.visibility = 'hidden';
+ } else if (NS4) {
+ document.layers[layer].visibility = 'hide';
+ } else {
+ document.all[layer].style.visibility = 'hidden';
+ }
+ }
+}
+
+function isVisible(layer)
+{
+ if (DOM) {
+ return (document.getElementById(layer).style.visibility == 'visible');
+ } else if (NS4) {
+ return (document.layers[layer].visibility == 'show');
+ } else {
+ return (document.all[layer].style.visibility == 'visible');
+ }
+}
+
+function setLeft(layer, x)
+{
+layerLeft[layer] = x;
+ if (DOM && !Opera5) {
+ document.getElementById(layer).style.left = x + 'px';
+ } else if (Opera5) {
+ document.getElementById(layer).style.left = x;
+ } else if (NS4) {
+ document.layers[layer].left = x;
+ } else {
+ document.all[layer].style.pixelLeft = x;
+ }
+}
+
+function getOffsetLeft(layer)
+{
+ var value = 0;
+ if (DOM) { // Mozilla, Konqueror >= 2.2, Opera >= 5, IE
+ object = document.getElementById(layer);
+ value = object.offsetLeft;
+//alert (object.tagName + ' --- ' + object.offsetLeft);
+ while (object.tagName != 'BODY' && object.offsetParent) {
+ object = object.offsetParent;
+//alert (object.tagName + ' --- ' + object.offsetLeft);
+ value += object.offsetLeft;
+ }
+ } else if (NS4) {
+ value = document.layers[layer].pageX;
+ } else { // IE4 IS SIMPLY A BASTARD !!!
+ if (document.all['IE4' + layer]) {
+ layer = 'IE4' + layer;
+ }
+ object = document.all[layer];
+ value = object.offsetLeft;
+ while (object.tagName != 'BODY') {
+ object = object.offsetParent;
+ value += object.offsetLeft;
+ }
+ }
+ return (value);
+}
+
+function setTop(layer, y)
+{
+layerTop[layer] = y;
+ if (DOM && !Opera5) {
+ document.getElementById(layer).style.top = y + 'px';
+ } else if (Opera5) {
+ document.getElementById(layer).style.top = y;
+ } else if (NS4) {
+ document.layers[layer].top = y;
+ } else {
+ document.all[layer].style.pixelTop = y;
+ }
+}
+
+function getOffsetTop(layer)
+{
+// IE 5.5 and 6.0 behaviour with this function is really strange:
+// in some cases, they return a really too large value...
+// ... after all, IE is buggy, nothing new
+ var value = 0;
+ if (DOM) {
+ object = document.getElementById(layer);
+ value = object.offsetTop;
+ while (object.tagName != 'BODY' && object.offsetParent) {
+ object = object.offsetParent;
+ value += object.offsetTop;
+ }
+ } else if (NS4) {
+ value = document.layers[layer].pageY;
+ } else { // IE4 IS SIMPLY A BASTARD !!!
+ if (document.all['IE4' + layer]) {
+ layer = 'IE4' + layer;
+ }
+ object = document.all[layer];
+ value = object.offsetTop;
+ while (object.tagName != 'BODY') {
+ object = object.offsetParent;
+ value += object.offsetTop;
+ }
+ }
+ return (value);
+}
+
+function setWidth(layer, w)
+{
+ if (DOM) {
+ document.getElementById(layer).style.width = w;
+ } else if (NS4) {
+// document.layers[layer].width = w;
+ } else {
+ document.all[layer].style.pixelWidth = w;
+ }
+}
+
+function getOffsetWidth(layer)
+{
+ var value = 0;
+ if (DOM && !Opera56) {
+ value = document.getElementById(layer).offsetWidth;
+ } else if (NS4) {
+ value = document.layers[layer].document.width;
+ } else if (Opera56) {
+ value = document.getElementById(layer).style.pixelWidth;
+ } else { // IE4 IS SIMPLY A BASTARD !!!
+ if (document.all['IE4' + layer]) {
+ layer = 'IE4' + layer;
+ }
+ value = document.all[layer].offsetWidth;
+ }
+ return (value);
+}
+
+function setHeight(layer, h) // unused, not tested
+{
+ if (DOM) {
+ document.getElementById(layer).style.height = h;
+ } else if (NS4) {
+// document.layers[layer].height = h;
+ } else {
+ document.all[layer].style.pixelHeight = h;
+ }
+}
+
+function getOffsetHeight(layer)
+{
+ var value = 0;
+ if (DOM && !Opera56) {
+ value = document.getElementById(layer).offsetHeight;
+ } else if (NS4) {
+ value = document.layers[layer].document.height;
+ } else if (Opera56) {
+ value = document.getElementById(layer).style.pixelHeight;
+ } else { // IE4 IS SIMPLY A BASTARD !!!
+ if (document.all['IE4' + layer]) {
+ layer = 'IE4' + layer;
+ }
+ value = document.all[layer].offsetHeight;
+ }
+ return (value);
+}
+
+function getWindowWidth()
+{
+ var value = 0;
+ if ((DOM && !IE) || NS4 || Konqueror || Opera) {
+ value = window.innerWidth;
+// } else if (NS4) {
+// value = document.width;
+ } else { // IE
+ if (document.documentElement && document.documentElement.clientWidth) {
+ value = document.documentElement.clientWidth;
+ } else if (document.body) {
+ value = document.body.clientWidth;
+ }
+ }
+ if (isNaN(value)) {
+ value = window.innerWidth;
+ }
+ return (value);
+}
+
+function getWindowXOffset()
+{
+ var value = 0;
+ if ((DOM && !IE) || NS4 || Konqueror || Opera) {
+ value = window.pageXOffset;
+ } else { // IE
+ if (document.documentElement && document.documentElement.scrollLeft) {
+ value = document.documentElement.scrollLeft;
+ } else if (document.body) {
+ value = document.body.scrollLeft;
+ }
+ }
+ return (value);
+}
+
+function getWindowHeight()
+{
+ var value = 0;
+ if ((DOM && !IE) || NS4 || Konqueror || Opera) {
+ value = window.innerHeight;
+ } else { // IE
+ if (document.documentElement && document.documentElement.clientHeight) {
+ value = document.documentElement.clientHeight;
+ } else if (document.body) {
+ value = document.body.clientHeight;
+ }
+ }
+ if (isNaN(value)) {
+ value = window.innerHeight;
+ }
+ return (value);
+}
+
+function getWindowYOffset()
+{
+ var value = 0;
+ if ((DOM && !IE) || NS4 || Konqueror || Opera) {
+ value = window.pageYOffset;
+ } else { // IE
+ if (document.documentElement && document.documentElement.scrollTop) {
+ value = document.documentElement.scrollTop;
+ } else if (document.body) {
+ value = document.body.scrollTop;
+ }
+ }
+ return (value);
+}
+
diff --git a/gosa-core/include/layer-menu/libjs/layersmenu-see-through.js b/gosa-core/include/layer-menu/libjs/layersmenu-see-through.js
--- /dev/null
@@ -0,0 +1,65 @@
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+function scanChildren(element)
+{
+ var counter = element.childNodes.length;
+ for (var i=0; i<counter; i++) {
+ foobar = element.childNodes.item(i);
+ if ( ( (Konqueror22 || Konqueror30 || Konqueror31) &&
+ ( foobar.nodeName == 'INPUT' || foobar.nodeName == 'input'
+ || foobar.nodeName == 'SELECT' || foobar.nodeName == 'select'
+ || foobar.nodeName == 'TEXTAREA' || foobar.nodeName == 'textarea'
+ )
+ )
+ ||
+// Konqueror 3.2 and 3.3 need hiding only for the following two form elements, but, alas,
+// at the time of this writing (Konqueror 3.2.3 and 3.3.0-rc2), hiding of such two form elements
+// on Konqueror 3.2 and 3.3 does not work, it is affected by the following bug: http://bugs.kde.org/72885
+ ( (Konqueror32 || Konqueror33) &&
+ ( ((foobar.nodeName == 'SELECT' || foobar.nodeName == 'select') && foobar.size > 1)
+ || foobar.nodeName == 'TEXTAREA' || foobar.nodeName == 'textarea'
+ )
+ )
+ ||
+ ( IE &&
+ ( foobar.nodeName == 'SELECT' || foobar.nodeName == 'select' )
+ )
+ ) {
+ toBeHidden[toBeHidden.length] = foobar;
+ }
+ if (foobar.childNodes.length > 0) {
+ scanChildren(foobar);
+ }
+ }
+}
+
+function seeThroughCoordinatesDetection()
+{
+ if (!((Konqueror && !Konqueror22) || IE5)) {
+ return;
+ }
+ for (i=0; i<toBeHidden.length; i++) {
+ object = toBeHidden[i];
+ toBeHiddenLeft[i] = object.offsetLeft;
+ while (object.tagName != 'BODY' && object.offsetParent) {
+ object = object.offsetParent;
+ toBeHiddenLeft[i] += object.offsetLeft;
+ }
+ object = toBeHidden[i];
+ toBeHiddenTop[i] = object.offsetTop;
+ while (object.tagName != 'BODY' && object.offsetParent) {
+ object = object.offsetParent;
+ toBeHiddenTop[i] += object.offsetTop;
+ }
+ }
+}
+
+//document.write("<br />\nSCANNING STARTED<br />\n");
+//scanChildren(document.getElementsByTagName('BODY').item(0));
+if ((Konqueror || IE5) && document.getElementById('phplmseethrough')) {
+ scanChildren(document.getElementById('phplmseethrough'));
+}
+//document.write("<br />\nSCANNING COMPLETED<br />\n");
+
+seeThroughCoordinatesDetection();
+
diff --git a/gosa-core/include/layer-menu/libjs/layersmenu.js b/gosa-core/include/layer-menu/libjs/layersmenu.js
--- /dev/null
@@ -0,0 +1,316 @@
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+useTimeouts = 1;
+timeoutLength = 1000; // time in ms; not significant if useTimeouts = 0;
+shutdownOnClick = 0;
+
+loaded = 0;
+layersMoved = 0;
+layerPoppedUp = '';
+
+timeoutFlag = 0;
+if (Opera56 || IE4) {
+ useTimeouts = 0;
+}
+if (NS4 || Opera56 || IE4) {
+ shutdownOnClick = 1;
+}
+
+currentY = 0;
+function grabMouse(e) // for NS4
+{
+ currentY = e.pageY;
+}
+if (NS4) {
+ document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
+ document.onmousemove = grabMouse;
+}
+
+function seeThroughElements(show)
+{
+ if (show) {
+ foobar = 'visible';
+ } else {
+ foobar = 'hidden';
+ }
+ for (i=0; i<toBeHidden.length; i++) {
+ toBeHidden[i].style.visibility = foobar;
+ }
+}
+
+function shutdown()
+{
+ for (i=0; i<numl; i++) {
+ LMPopUpL(listl[i], false);
+ }
+ layerPoppedUp = '';
+ if (Konqueror || IE5) {
+ seeThroughElements(true);
+ }
+}
+if (shutdownOnClick) {
+ if (NS4) {
+ document.onmousedown = shutdown;
+ } else {
+ document.onclick = shutdown;
+ }
+}
+
+function setLMTO()
+{
+ if (useTimeouts) {
+ timeoutFlag = setTimeout('shutdown()', timeoutLength);
+ }
+}
+
+function clearLMTO()
+{
+ if (useTimeouts) {
+ clearTimeout(timeoutFlag);
+ }
+}
+
+function moveLayerX(menuName)
+{
+ if (!loaded || (isVisible(menuName) && menuName != layerPoppedUp)) {
+ return;
+ }
+ if (father[menuName] != '') {
+ if (!Opera5 && !IE4) {
+ width0 = lwidth[father[menuName]];
+ width1 = lwidth[menuName];
+ } else if (Opera5) {
+ // Opera 5 stupidly and exaggeratedly overestimates layers widths
+ // hence we consider a default value equal to $abscissaStep
+ width0 = abscissaStep;
+ width1 = abscissaStep;
+ } else if (IE4) {
+ width0 = getOffsetWidth(father[menuName]);
+ width1 = getOffsetWidth(menuName);
+ }
+ onLeft = getOffsetLeft(father[menuName]) - width1 + menuLeftShift;
+ onRight = getOffsetLeft(father[menuName]) + width0 - menuRightShift;
+ windowWidth = getWindowWidth();
+ windowXOffset = getWindowXOffset();
+// if (NS4 && !DOM) {
+// windowXOffset = 0;
+// }
+ if (onLeft < windowXOffset && onRight + width1 > windowWidth + windowXOffset) {
+ if (onRight + width1 - windowWidth - windowXOffset > windowXOffset - onLeft) {
+ onLeft = windowXOffset;
+ } else {
+ onRight = windowWidth + windowXOffset - width1;
+ }
+ }
+ if (back[father[menuName]]) {
+ if (onLeft < windowXOffset) {
+ back[menuName] = 0;
+ } else {
+ back[menuName] = 1;
+ }
+ } else {
+//alert(onRight + ' - ' + width1 + ' - ' + windowWidth + ' - ' + windowXOffset);
+ if (onRight + width1 > windowWidth + windowXOffset) {
+ back[menuName] = 1;
+ } else {
+ back[menuName] = 0;
+ }
+ }
+ if (back[menuName]) {
+ setLeft(menuName, onLeft);
+ } else {
+ setLeft(menuName, onRight);
+ }
+ }
+ moveLayerY(menuName); // workaround needed for Mozilla < 1.4 for MS Windows
+}
+
+function moveLayerY(menuName)
+{
+ if (!loaded || (isVisible(menuName) && menuName != layerPoppedUp)) {
+ return;
+ }
+ if (!layersMoved) {
+ moveLayers();
+ layersMoved = 1;
+ }
+ if (!NS4) {
+ newY = getOffsetTop('ref' + menuName);
+ } else {
+ newY = currentY;
+ }
+ newY += menuTopShift;
+ layerHeight = getOffsetHeight(menuName);
+ windowHeight = getWindowHeight();
+ windowYOffset = getWindowYOffset();
+ if (newY + layerHeight > windowHeight + windowYOffset) {
+ if (layerHeight > windowHeight) {
+ newY = windowYOffset;
+ } else {
+ newY = windowHeight + windowYOffset - layerHeight;
+ }
+ }
+ if (Math.abs(getOffsetTop(menuName) - newY) > thresholdY) {
+ setTop(menuName, newY);
+ }
+}
+
+function moveLayerX1(menuName, father)
+{
+ if (!lwidthDetected) {
+ return;
+ }
+ if (!Opera5 && !IE4) {
+ width1 = lwidth[menuName];
+ } else if (Opera5) {
+ // Opera 5 stupidly and exaggeratedly overestimates layers widths
+ // hence we consider a default value equal to $abscissaStep
+ width1 = abscissaStep;
+ }
+ foobar = getOffsetLeft(father + menuName);
+if (!IE4) {
+ windowWidth = getWindowWidth();
+ windowXOffset = getWindowXOffset();
+ if (foobar + width1 > windowWidth + windowXOffset) {
+ foobar = windowWidth + windowXOffset - width1;
+ }
+ if (foobar < windowXOffset) {
+ foobar = windowXOffset;
+ }
+}
+ setLeft(menuName, foobar);
+}
+
+function layersOverlap(layer, i)
+{
+ if (Konqueror22) {
+ return true;
+ }
+
+// xa1 = getOffsetLeft(layer);
+//setLeft(layer, xa1);
+ xa1 = layerLeft[layer];
+ xa2 = xa1 + getOffsetWidth(layer);
+//setWidth(layer, xa2-xa1);
+// ya1 = getOffsetTop(layer);
+//setTop(layer, ya1);
+ ya1 = layerTop[layer];
+ ya2 = ya1 + getOffsetHeight(layer);
+//setHeight(layer, ya2-ya1);
+//alert(':' + xa1 + ':' + xa2 + ':' + ya1 + ':' + ya2 + ':');
+
+ xb1 = toBeHiddenLeft[i];
+ xb2 = xb1 + toBeHidden[i].offsetWidth;
+ yb1 = toBeHiddenTop[i];
+ yb2 = yb1 + toBeHidden[i].offsetHeight;
+//alert(':' + xb1 + ':' + xb2 + ':' + yb1 + ':' + yb2 + ':');
+
+ if(xb1>xa1) xa1=xb1; if(xb2<xa2) xa2=xb2;
+ if(yb1>ya1) ya1=yb1; if(yb2<ya2) ya2=yb2;
+
+ return (xa2>xa1 && ya2>ya1);
+}
+
+function seeThroughWorkaround(menuName, on)
+{
+ for (i=0; i<toBeHidden.length; i++) {
+ if (layersOverlap(menuName, i)) {
+ if (on) {
+ toBeHidden[i].style.visibility = 'hidden';
+ } else {
+ toBeHidden[i].style.visibility = 'visible';
+ }
+ }
+ }
+}
+
+function LMPopUpL(menuName, on)
+{
+ if (!loaded) {
+ return;
+ }
+ if (!layersMoved) {
+ moveLayers();
+ layersMoved = 1;
+ }
+ setVisibility(menuName, on);
+}
+
+function LMPopUp(menuName, isCurrent)
+{
+ if (!loaded || menuName == layerPoppedUp || (isVisible(menuName) && !isCurrent)) {
+ return;
+ }
+ if (menuName == father[layerPoppedUp]) {
+ LMPopUpL(layerPoppedUp, false);
+// seeThroughWorkaround(menuName, false);
+ } else if (father[menuName] == layerPoppedUp) {
+ LMPopUpL(menuName, true);
+ seeThroughWorkaround(menuName, true);
+ } else {
+ shutdown();
+ foobar = menuName;
+ do {
+ LMPopUpL(foobar, true);
+ seeThroughWorkaround(foobar, true);
+ foobar = father[foobar];
+ } while (foobar != '')
+ }
+/*
+ if (layerPoppedUp == '') {
+ seeThroughElements(false);
+ }
+*/
+ layerPoppedUp = menuName;
+}
+
+function resizeHandler()
+{
+ if (NS4) {
+ window.location.reload();
+ }
+ shutdown();
+ for (i=0; i<numl; i++) {
+ setLeft(listl[i], 0);
+ setTop(listl[i], 0);
+ }
+ if (toBeHidden != null && toBeHidden.length > 0) {
+ seeThroughCoordinatesDetection();
+ }
+// moveLayers();
+ layersMoved = 0;
+}
+window.onresize = resizeHandler;
+
+function yaresizeHandler()
+{
+ if (window.innerWidth != origWidth || window.innerHeight != origHeight) {
+ if (Konqueror22 || Opera5) {
+ window.location.reload(); // Opera 5 often fails this
+ }
+ origWidth = window.innerWidth;
+ origHeight = window.innerHeight;
+ resizeHandler();
+ }
+ setTimeout('yaresizeHandler()', 500);
+}
+function loadHandler()
+{
+ if (Konqueror22 || Opera56) {
+ origWidth = window.innerWidth;
+ origHeight = window.innerHeight;
+ yaresizeHandler();
+ }
+}
+window.onload = loadHandler;
+
+function fixieflm(menuName)
+{
+ if (DOM) {
+ setWidth(menuName, '100%');
+ } else { // IE4 IS SIMPLY A BASTARD !!!
+ document.write('</div>');
+ document.write('<div id="IE4' + menuName + '" style="position: relative; width: 100%; visibility: visible;">');
+ }
+}
+
diff --git a/gosa-core/include/layer-menu/libjs/layerstreemenu-cookies.js b/gosa-core/include/layer-menu/libjs/layerstreemenu-cookies.js
--- /dev/null
@@ -0,0 +1,70 @@
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+function setLMCookie(name, value)
+{
+ document.cookie = name + '=' + value + ';path=/';
+}
+
+function getLMCookie(name)
+{
+ foobar = document.cookie.split(name + '=');
+ if (foobar.length < 2) {
+ return null;
+ }
+ tempString = foobar[1];
+ if (tempString.indexOf(';') == -1) {
+ return tempString;
+ }
+ yafoobar = tempString.split(';');
+ return yafoobar[0];
+}
+
+function parseExpandString()
+{
+ expandString = getLMCookie('phplm_expand');
+ phplm_expand = new Array();
+ if (expandString) {
+ expanded = expandString.split('|');
+ for (i=0; i<expanded.length-1; i++) {
+ phplm_expand[expanded[i]] = 1;
+ }
+ }
+}
+
+function parseCollapseString()
+{
+ collapseString = getLMCookie('phplm_collapse');
+ phplm_collapse = new Array();
+ if (collapseString) {
+ collapsed = collapseString.split('|');
+ for (i=0; i<collapsed.length-1; i++) {
+ phplm_collapse[collapsed[i]] = 1;
+ }
+ }
+}
+
+parseExpandString();
+parseCollapseString();
+
+function saveExpandString()
+{
+ expandString = '';
+ for (i=0; i<phplm_expand.length; i++) {
+ if (phplm_expand[i] == 1) {
+ expandString += i + '|';
+ }
+ }
+ setLMCookie('phplm_expand', expandString);
+}
+
+function saveCollapseString()
+{
+ collapseString = '';
+ for (i=0; i<phplm_collapse.length; i++) {
+ if (phplm_collapse[i] == 1) {
+ collapseString += i + '|';
+ }
+ }
+ setLMCookie('phplm_collapse', collapseString);
+}
+
diff --git a/gosa-core/include/layer-menu/libjs/layerstreemenu.ijs b/gosa-core/include/layer-menu/libjs/layerstreemenu.ijs
--- /dev/null
@@ -0,0 +1,52 @@
+// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
+
+function {toggle_function_name}(nodeid)
+{
+ if ((!DOM || Opera56 || Konqueror22) && !IE4) {
+ return;
+ }
+ layersMoved = 0;
+ parseExpandString();
+ parseCollapseString();
+ if (!IE4) {
+ sonLayer = document.getElementById('jt' + nodeid + 'son');
+ nodeLayer = document.getElementById('jt' + nodeid + 'node');
+ folderLayer = document.getElementById('jt' + nodeid + 'folder');
+ } else {
+ sonLayer = document.all('jt' + nodeid + 'son');
+ nodeLayer = document.all('jt' + nodeid + 'node');
+ folderLayer = document.all('jt' + nodeid + 'folder');
+ }
+ if (sonLayer.style.display == 'none') {
+ sonLayer.style.display = 'block';
+ if (nodeLayer.src.indexOf('{img_expand}') > -1) {
+ nodeLayer.src = '{img_collapse}';
+ } else if (nodeLayer.src.indexOf('{img_expand_first}') > -1) {
+ nodeLayer.src = '{img_collapse_first}';
+ } else if (nodeLayer.src.indexOf('{img_expand_corner}') > -1) {
+ nodeLayer.src = '{img_collapse_corner}';
+ } else {
+ nodeLayer.src = '{img_collapse_corner_first}';
+ }
+ folderLayer.src = '{img_folder_open}';
+ phplm_expand[nodeid] = 1;
+ phplm_collapse[nodeid] = 0;
+ } else {
+ sonLayer.style.display = 'none';
+ if (nodeLayer.src.indexOf('{img_collapse}') > -1) {
+ nodeLayer.src = '{img_expand}';
+ } else if (nodeLayer.src.indexOf('{img_collapse_first}') > -1) {
+ nodeLayer.src = '{img_expand_first}';
+ } else if (nodeLayer.src.indexOf('{img_collapse_corner}') > -1) {
+ nodeLayer.src = '{img_expand_corner}';
+ } else {
+ nodeLayer.src = '{img_expand_corner_first}';
+ }
+ folderLayer.src = '{img_folder_closed}';
+ phplm_expand[nodeid] = 0;
+ phplm_collapse[nodeid] = 1;
+ }
+ saveExpandString();
+ saveCollapseString();
+}
+
diff --git a/gosa-core/include/php_layers_menu/COPYING b/gosa-core/include/php_layers_menu/COPYING
+++ /dev/null
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-\f
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-\f
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/gosa-core/include/php_layers_menu/lib/PHPLIB.php b/gosa-core/include/php_layers_menu/lib/PHPLIB.php
+++ /dev/null
@@ -1,567 +0,0 @@
-<?php
-// vim: set expandtab tabstop=4 shiftwidth=4:
-// This code that was derived from the original PHPLIB Template class
-// is copyright by Kristian Koehntopp, NetUSE AG and was released
-// under the LGPL.
-//
-// Authors: Kristian Koehntopp <kris@koehntopp.de> (original from PHPLIB)
-// Bjoern Schotte <bjoern@rent-a-phpwizard.de> (PEARification)
-// Martin Jansen <mj@php.net> (PEAR conformance)
-//
-// $Id: PHPLIB.php,v 1.14 2003/06/11 06:03:32 bjoern Exp $
-//
-
-//require_once "PEAR.php";
-
-/**
- * Converted PHPLIB Template class
- *
- * For those who want to use PHPLIB's fine template class,
- * here's a PEAR conforming class with the original PHPLIB
- * template code from phplib-stable CVS. Original author
- * was Kristian Koehntopp <kris@koehntopp.de>
- *
- * @author Bjoern Schotte <bjoern@rent-a-phpwizard.de>
- * @author Martin Jansen <mj@php.net> (PEAR conformance)
- * @version 1.0
- */
-class Template_PHPLIB
-{
- /**
- * If set, echo assignments
- * @var bool
- */
- var $debug = false;
-
- /**
- * $file[handle] = "filename";
- * @var array
- */
- var $file = array();
-
- /**
- * fallback paths that should be defined in a child class
- * @var array
- */
- var $file_fallbacks = array();
-
- /**
- * Relative filenames are relative to this pathname
- * @var string
- */
- var $root = "";
-
- /*
- * $_varKeys[key] = "key"
- * @var array
- */
- var $_varKeys = array();
-
- /**
- * $_varVals[key] = "value";
- * @var array
- */
- var $_varVals = array();
-
- /**
- * "remove" => remove undefined variables
- * "comment" => replace undefined variables with comments
- * "keep" => keep undefined variables
- * @var string
- */
- var $unknowns = "remove";
-
- /**
- * "yes" => halt, "report" => report error, continue, "no" => ignore error quietly
- * @var string
- */
- var $haltOnError = "report";
-
- /**
- * The last error message is retained here
- * @var string
- * @see halt
- */
- var $_lastError = "";
-
-
- /**
- * Constructor
- *
- * @access public
- * @param string template root directory
- * @param string how to handle unknown variables
- * @param array fallback paths
- */
- function Template_PHPLIB($root = ".", $unknowns = "remove", $fallback="")
- {
- $this->setRoot($root);
- $this->setUnknowns($unknowns);
- if (is_array($fallback)) $this->file_fallbacks = $fallback;
- }
-
- /**
- * Sets the template directory
- *
- * @access public
- * @param string new template directory
- * @return bool
- */
- function setRoot($root)
- {
- if (!is_dir($root)) {
- $this->halt("setRoot: $root is not a directory.");
- return false;
- }
-
- $this->root = $root;
-
- return true;
- }
-
- /**
- * What to do with unknown variables
- *
- * three possible values:
- *
- * - "remove" will remove unknown variables
- * (don't use this if you define CSS in your page)
- * - "comment" will replace undefined variables with comments
- * - "keep" will keep undefined variables as-is
- *
- * @access public
- * @param string unknowns
- */
- function setUnknowns($unknowns = "keep")
- {
- $this->unknowns = $unknowns;
- }
-
- /**
- * Set appropriate template files
- *
- * With this method you set the template files you want to use.
- * Either you supply an associative array with key/value pairs
- * where the key is the handle for the filname and the value
- * is the filename itself, or you define $handle as the file name
- * handle and $filename as the filename if you want to define only
- * one template.
- *
- * @access public
- * @param mixed handle for a filename or array with handle/name value pairs
- * @param string name of template file
- * @return bool
- */
- function setFile($handle, $filename = "")
- {
- if (!is_array($handle)) {
-
- if ($filename == "") {
- $this->halt("setFile: For handle $handle filename is empty.");
- return false;
- }
-
- $this->file[$handle] = $this->_filename($filename);
-
- } else {
-
- reset($handle);
- while (list($h, $f) = each($handle)) {
- $this->file[$h] = $this->_filename($f);
- }
- }
- }
-
- /**
- * Set a block in the appropriate template handle
- *
- * By setting a block like that:
- *
- * <!-- BEGIN blockname -->
- * html code
- * <!-- END blockname -->
- *
- * you can easily do repeating HTML code, i.e. output
- * database data nice formatted into a HTML table where
- * each DB row is placed into a HTML table row which is
- * defined in this block.
- * It extracts the template $handle from $parent and places
- * variable {$name} instead.
- *
- * @access public
- * @param string parent handle
- * @param string block name handle
- * @param string variable substitution name
- */
- function setBlock($parent, $handle, $name = "")
- {
- if (!$this->_loadFile($parent)) {
- $this->halt("setBlock: unable to load $parent.");
- return false;
- }
-
- if ($name == "") {
- $name = $handle;
- }
-
- $str = $this->getVar($parent);
- $reg = "/[ \t]*<!--\s+BEGIN $handle\s+-->\s*?\n?(\s*.*?\n?)\s*<!--\s+END $handle\s+-->\s*?\n?/sm";
- preg_match_all($reg, $str, $m);
- $str = preg_replace($reg, "{" . "$name}", $str);
-
- if (isset($m[1][0])) $this->setVar($handle, $m[1][0]);
- $this->setVar($parent, $str);
- }
-
- /**
- * Set corresponding substitutions for placeholders
- *
- * @access public
- * @param string name of a variable that is to be defined or an array of variables with value substitution as key/value pairs
- * @param string value of that variable
- * @param boolean if true, the value is appended to the variable's existing value
- */
- function setVar($varname, $value = "", $append = false)
- {
- if (!is_array($varname)) {
-
- if (!empty($varname))
- if ($this->debug) print "scalar: set *$varname* to *$value*<br>\n";
-
- $this->_varKeys[$varname] = $this->_varname($varname);
- ($append) ? $this->_varVals[$varname] .= $value : $this->_varVals[$varname] = $value;
-
- } else {
- reset($varname);
-
- while (list($k, $v) = each($varname)) {
- if (!empty($k))
- if ($this->debug) print "array: set *$k* to *$v*<br>\n";
-
- $this->_varKeys[$k] = $this->_varname($k);
- ($append) ? $this->_varVals[$k] .= $v : $this->_varVals[$k] = $v;
- }
- }
- }
-
- /**
- * Substitute variables in handle $handle
- *
- * @access public
- * @param string name of handle
- * @return mixed string substituted content of handle
- */
- function subst($handle)
- {
- if (!$this->_loadFile($handle)) {
- $this->halt("subst: unable to load $handle.");
- return false;
- }
-
- return @str_replace($this->_varKeys, $this->_varVals, $this->getVar($handle));
- }
-
- /**
- * Same as subst but printing the result
- *
- * @access public
- * @brother subst
- * @param string handle of template
- * @return bool always false
- */
- function pSubst($handle)
- {
- print $this->subst($handle);
- return false;
- }
-
- /**
- * Parse handle into target
- *
- * Parses handle $handle into $target, eventually
- * appending handle at $target if $append is defined
- * as TRUE.
- *
- * @access public
- * @param string target handle to parse into
- * @param string which handle should be parsed
- * @param boolean append it to $target or not?
- * @return string parsed handle
- */
- function parse($target, $handle, $append = false)
- {
- if (!is_array($handle)) {
- $str = $this->subst($handle);
-
- ($append) ? $this->setVar($target, $this->getVar($target) . $str) : $this->setVar($target, $str);
- } else {
- reset($handle);
-
- while (list(, $h) = each($handle)) {
- $str = $this->subst($h);
- $this->setVar($target, $str);
- }
- }
-
- return $str;
- }
-
- /**
- * Same as parse, but printing it.
- *
- * @access public
- * @brother parse
- * @param string target to parse into
- * @param string handle which should be parsed
- * @param should $handle be appended to $target?
- * @return bool
- */
- function pParse($target, $handle, $append = false)
- {
- print $this->finish($this->parse($target, $handle, $append));
- return false;
- }
-
- /**
- * Return all defined variables and their values
- *
- * @access public
- * @return array with all defined variables and their values
- */
- function getVars()
- {
- reset($this->_varKeys);
-
- while (list($k, ) = each($this->_varKeys)) {
- $result[$k] = $this->getVar($k);
- }
-
- return $result;
- }
-
- /**
- * Return one or more specific variable(s) with their values.
- *
- * @access public
- * @param mixed array with variable names or one variable name as a string
- * @return mixed array of variable names with their values or value of one specific variable
- */
- function getVar($varname)
- {
- if (!is_array($varname)) {
- if (isset($this->_varVals[$varname])) {
- return $this->_varVals[$varname];
- } else {
- return "";
- }
- } else {
- reset($varname);
-
- while (list($k, ) = each($varname)) {
- $result[$k] = (isset($this->_varVals[$k])) ? $this->_varVals[$k] : "";
- }
-
- return $result;
- }
- }
-
- /**
- * Get undefined values of a handle
- *
- * @access public
- * @param string handle name
- * @return mixed false if an error occured or the undefined values
- */
- function getUndefined($handle)
- {
- if (!$this->_loadFile($handle)) {
- $this->halt("getUndefined: unable to load $handle.");
- return false;
- }
-
- preg_match_all("/{([^ \t\r\n}]+)}/", $this->getVar($handle), $m);
- $m = $m[1];
- if (!is_array($m)) {
- return false;
- }
-
- reset($m);
- while (list(, $v) = each($m)) {
- if (!isset($this->_varKeys[$v])) {
- $result[$v] = $v;
- }
- }
-
- if (isset($result) && count($result)) {
- return $result;
- } else {
- return false;
- }
- }
-
- /**
- * Finish string
- *
- * @access public
- * @param string string to finish
- * @return finished, i.e. substituted string
- */
- function finish($str)
- {
- switch ($this->unknowns) {
- case "remove":
- $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
- break;
-
- case "comment":
- $str = preg_replace('/{([^ \t\r\n}]+)}/', "<!-- Template $handle: Variable \\1 undefined -->", $str);
- break;
- }
-
- return $str;
- }
-
- /**
- * Print variable to the browser
- *
- * @access public
- * @param string name of variable to print
- */
- function p($varname)
- {
- print $this->finish($this->getVar($varname));
- }
-
- /**
- * Get finished variable
- *
- * @access public public
- * @param string variable to get
- * @return string string with finished variable
- */
- function get($varname)
- {
- return $this->finish($this->getVar($varname));
- }
-
- /**
- * Complete filename
- *
- * Complete filename, i.e. testing it for slashes
- *
- * @access private
- * @param string filename to be completed
- * @return string completed filename
- */
- function _filename($filename)
- {
-// if (substr($filename, 0, 1) != "/") {
-// $filename = $this->root."/".$filename;
-// }
-
- if (file_exists($filename)) return $filename;
- if (is_array($this->file_fallbacks) && count($this->file_fallbacks) > 0) {
- reset($this->file_fallbacks);
- while (list(,$v) = each($this->file_fallbacks)) {
- if (file_exists($v.basename($filename))) return $v.basename($filename);
- }
- $this->halt(sprintf("filename: file %s does not exist in the fallback paths %s.",$filename,implode(",",$this->file_fallbacks)));
- return false;
- } else {
- $this->halt(sprintf("filename: file %s does not exist.",$filename));
- return false;
- }
-
- return $filename;
- }
-
- /**
- * Protect a replacement variable
- *
- * @access private
- * @param string name of replacement variable
- * @return string replaced variable
- */
- function _varname($varname)
- {
- return "{".$varname."}";
- }
-
- /**
- * load file defined by handle if it is not loaded yet
- *
- * @access private
- * @param string handle
- * @return bool FALSE if error, true if all is ok
- */
- function _loadFile($handle)
- {
- if (isset($this->_varKeys[$handle]) and !empty($this->_varVals[$handle])) {
- return true;
- }
-
- if (!isset($this->file[$handle])) {
- $this->halt("loadfile: $handle is not a valid handle.");
- return false;
- }
-
- $filename = $this->file[$handle];
- if (function_exists("file_get_contents")) {
- $str = file_get_contents($filename);
- } else {
- if (!$fp = @fopen($filename,"r")) {
- $this->halt("loadfile: couldn't open $filename");
- return false;
- }
-
- $str = fread($fp,filesize($filename));
- fclose($fp);
- }
-
- if ($str=='') {
- $this->halt("loadfile: While loading $handle, $filename does not exist or is empty.");
- return false;
- }
-
- $this->setVar($handle, $str);
-
- return true;
- }
-
- /**
- * Error function. Halt template system with message to show
- *
- * @access public
- * @param string message to show
- * @return bool
- */
- function halt($msg)
- {
- $this->_lastError = $msg;
-
- if ($this->haltOnError != "no") {
-// return $this->haltMsg($msg);
- $this->haltMsg($msg);
- }
-
- if ($this->haltOnError == "yes") {
- die("<b>Halted.</b>");
- }
-
- return false;
- }
-
- /**
- * printf error message to show
- *
- * @access public
- * @param string message to show
- * @return object PEAR error object
- */
- function haltMsg($msg)
- {
-// PEAR::raiseError(sprintf("<b>Template Error:</b> %s<br>\n", $msg));
- printf("<b>Template Error:</b> %s<br>\n", $msg);
- }
-}
-?>
diff --git a/gosa-core/include/php_layers_menu/lib/layersmenu-browser_detection.php b/gosa-core/include/php_layers_menu/lib/layersmenu-browser_detection.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-function inAgent($string)
-{
- if (isset($_SERVER['HTTP_USER_AGENT'])) {
- $http_user_agent = $_SERVER['HTTP_USER_AGENT'];
- } else {
- $http_user_agent = '';
- }
- return !(strpos($http_user_agent, $string) === false);
-}
-
-if (inAgent('Gecko')) {
- $browser = 'Mozilla';
-} elseif (
- inAgent('Lynx') || inAgent('lynx')
- || inAgent('Links') || inAgent('links')
- || inAgent('w3m')
- ) {
- $browser = 'TEXT';
-// I detect Konqueror and Opera before than the others,
-// as they often qualify themselves as Mozilla/Netscape/MSIE
-} elseif (inAgent('Konqueror')) {
- if (inAgent('Konqueror 1') || inAgent('Konqueror/1')) {
- $browser = 'Konqueror1';
- // On KDE 1.1.2, kfm qualifies itself as "Konqueror/1.1.2"
- // (tested on Red Hat Linux 6.2)
- } elseif (inAgent('Konqueror 2.0') || inAgent('Konqueror/2.0')
- || inAgent('Konqueror 2;') || inAgent('Konqueror/2;')
- || inAgent('Konqueror 2)') || inAgent('Konqueror/2)')
- ) {
- $browser = 'Konqueror20';
- } elseif (inAgent('Konqueror 2.1') || inAgent('Konqueror/2.1')) {
- $browser = 'Konqueror21';
- } else {
- $browser = 'Konqueror';
- }
-} elseif (inAgent('Opera')) {
- if (inAgent('Opera 4') || inAgent('Opera/4')) {
- $browser = 'Opera4';
- // I hope that Opera 4 users can be satisfied by the Plain menu version;
- // sorry, but I have never used Opera 4 and I do not have a copy of it
- // to perform tests. If you are using Opera < 4, it's your problem :-P
- } elseif ((inAgent('Opera 6') || inAgent('Opera/6')) && inAgent('Linux')) {
- $browser = 'Opera6forLinux';
- } elseif (
- inAgent('Opera 5') || inAgent('Opera/5')
- || inAgent('Opera 6') || inAgent('Opera/6')
- ) {
- $browser = 'Opera56';
- } else {
- $browser = 'Opera';
- }
-} elseif (inAgent('Safari')) {
- $browser = 'Safari';
-} elseif (inAgent('MSIE 4') || inAgent('MSIE/4')) {
- $browser = 'IE4';
-} elseif (inAgent('MSIE')) {
- $browser = 'IE5';
- // msie != 4 is handled like msie 5+; if you are using msie 3-, it's your problem :-P
-} elseif (inAgent('Mozilla 4') || inAgent('Mozilla/4')) {
- $browser = 'NS4';
-} else {
- $browser = 'Unknown';
-}
-
-if (
- $browser == 'TEXT'
- || $browser == 'Konqueror1' || $browser == 'Konqueror20' || $browser == 'Konqueror21'
- // IMO, on Konqueror 2.1, the Plain version is more usable than the "OLD" one
- || $browser == 'Opera4'
-) {
- $menuType = 'PLAIN';
-} elseif ($browser == 'NS4' || $browser == 'Opera56' || $browser == 'IE4') {
- $menuType = 'OLD';
-} else {
- $menuType = 'DOM';
-}
-
-?>
diff --git a/gosa-core/include/php_layers_menu/lib/layersmenu-common.inc.php b/gosa-core/include/php_layers_menu/lib/layersmenu-common.inc.php
+++ /dev/null
@@ -1,955 +0,0 @@
-<?php
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-/**
-* This file contains the code of the LayersMenuCommon class.
-* @package PHPLayersMenu
-*/
-
-/**
-* This is the "common" class of the PHP Layers Menu library.
-*
-* You need to include PEAR.php and DB.php if (and only if) you want to use the DB support provided by ths class.
-*
-* @version 3.2.0-rc
-* @package PHPLayersMenu
-*/
-class LayersMenuCommon
-{
-
-/**
-* The name of the package
-* @access private
-* @var string
-*/
-var $_packageName;
-/**
-* The version of the package
-* @access private
-* @var string
-*/
-var $version;
-/**
-* The copyright of the package
-* @access private
-* @var string
-*/
-var $copyright;
-/**
-* The author of the package
-* @access private
-* @var string
-*/
-var $author;
-
-/**
-* URL to be prepended to the menu hrefs
-* @access private
-* @var string
-*/
-var $prependedUrl = '';
-/**
-* Do you want that code execution halts on error?
-* @access private
-* @var string
-*/
-var $haltOnError = 'yes';
-
-/**
-* The base directory where the package is installed
-* @access private
-* @var string
-*/
-var $dirroot;
-/**
-* The "libjs" directory of the package
-* @access private
-* @var string
-*/
-var $libjsdir;
-/**
-* The directory where images related to the menu can be found
-* @access private
-* @var string
-*/
-var $imgdir;
-/**
-* The http path corresponding to imgdir
-* @access private
-* @var string
-*/
-var $imgwww;
-/**
-* The directory where icons of menu items can be found
-* @access private
-* @var string
-*/
-var $icondir;
-/**
-* The http path corresponding to icondir
-* @access private
-* @var string
-*/
-var $iconwww;
-/**
-* This array may contain width and height of all icons
-* @access private
-* @var integer
-*/
-var $iconsize = array();
-/**
-* If this var is false, width and height of icons have to be detected; if this var is true, width and height of icons are not detected and are retrieved from the iconsize array
-* @access private
-* @var boolean
-*/
-var $issetIconsize = false;
-/**
-* The directory where templates can be found
-* @access private
-* @var string
-*/
-var $tpldir;
-/**
-* The string containing the menu structure
-* @access private
-* @var string
-*/
-var $menuStructure;
-
-/**
-* It counts nodes for all menus
-* @access private
-* @var integer
-*/
-var $_nodesCount;
-/**
-* A multi-dimensional array to store informations for each menu entry
-* @access private
-* @var array
-*/
-var $tree;
-/**
-* A multi-dimensional array used only with the DB support; for each $menu_name, it stores the $cnt associated to each item id
-*
-* This array is needed for selection of the current item
-* through the corresponding id (see the DB table structure)
-* as, internally, items are stored, sorted and addressed in terms of $cnt
-*
-* @access private
-* @var array
-*/
-var $treecnt;
-/**
-* The maximum hierarchical level of menu items
-* @access private
-* @var integer
-*/
-var $_maxLevel;
-/**
-* An array that counts the number of first level items for each menu
-* @access private
-* @var array
-*/
-var $_firstLevelCnt;
-/**
-* An array containing the number identifying the first item of each menu
-* @access private
-* @var array
-*/
-var $_firstItem;
-/**
-* An array containing the number identifying the last item of each menu
-* @access private
-* @var array
-*/
-var $_lastItem;
-
-/**
-* Data Source Name: the connection string for PEAR DB
-* @access private
-* @var string
-*/
-var $dsn = 'pgsql://dbuser:dbpass@dbhost/dbname';
-/**
-* DB connections are either persistent or not persistent
-* @access private
-* @var boolean
-*/
-var $persistent = false;
-/**
-* Name of the table storing data describing the menu
-* @access private
-* @var string
-*/
-var $tableName = 'phplayersmenu';
-/**
-* Name of the i18n table corresponding to $tableName
-* @access private
-* @var string
-*/
-var $tableName_i18n = 'phplayersmenu_i18n';
-/**
-* Names of fields of the table storing data describing the menu
-*
-* default field names correspond to the same field names foreseen
-* by the menu structure format
-*
-* @access private
-* @var array
-*/
-var $tableFields = array(
- 'id' => 'id',
- 'parent_id' => 'parent_id',
- 'text' => 'text',
- 'href' => 'href',
- 'title' => 'title',
- 'icon' => 'icon',
- 'target' => 'target',
- 'orderfield' => 'orderfield',
- 'expanded' => 'expanded'
-);
-/**
-* Names of fields of the i18n table corresponding to $tableName
-* @access private
-* @var array
-*/
-var $tableFields_i18n = array(
- 'language' => 'language',
- 'id' => 'id',
- 'text' => 'text',
- 'title' => 'title'
-);
-/**
-* A temporary array to store data retrieved from the DB and to perform the depth-first search
-* @access private
-* @var array
-*/
-var $_tmpArray = array();
-
-/**
-* The constructor method; it initializates the menu system
-* @return void
-*/
-function LayersMenuCommon()
-{
- $this->_packageName = 'PHP Layers Menu';
- $this->version = '3.2.0-rc';
- $this->copyright = '(C) 2001-2004';
- $this->author = 'Marco Pratesi - http://www.marcopratesi.it/';
-
- $this->prependedUrl = '';
-
- $this->dirroot = './';
- $this->libjsdir = './libjs/';
- $this->imgdir = './menuimages/';
- $this->imgwww = 'menuimages/';
- $this->icondir = './menuicons/';
- $this->iconwww = 'menuicons/';
- $this->tpldir = './templates/';
- $this->menuStructure = '';
- $this->separator = '|';
-
- $this->_nodesCount = 0;
- $this->tree = array();
- $this->treecnt = array();
- $this->_maxLevel = array();
- $this->_firstLevelCnt = array();
- $this->_firstItem = array();
- $this->_lastItem = array();
-}
-
-/**
-* The method to set the prepended URL
-* @access public
-* @return boolean
-*/
-function setPrependedUrl($prependedUrl)
-{
- // We do not perform any check
- $this->prependedUrl = $prependedUrl;
- return true;
-}
-
-/**
-* The method to set the dirroot directory
-* @access public
-* @return boolean
-*/
-function setDirrootCommon($dirroot)
-{
- if (!is_dir($dirroot)) {
- $this->error("setDirroot: $dirroot is not a directory.");
- return false;
- }
- if (substr($dirroot, -1) != '/') {
- $dirroot .= '/';
- }
- $oldlength = strlen($this->dirroot);
- $foobar = strpos($this->libjsdir, $this->dirroot);
- if (!($foobar === false || $foobar != 0)) {
- $this->libjsdir = $dirroot . substr($this->libjsdir, $oldlength);
- }
- $foobar = strpos($this->imgdir, $this->dirroot);
- if (!($foobar === false || $foobar != 0)) {
- $this->imgdir = $dirroot . substr($this->imgdir, $oldlength);
- }
- $foobar = strpos($this->icondir, $this->dirroot);
- if (!($foobar === false || $foobar != 0)) {
- $this->icondir = $dirroot . substr($this->icondir, $oldlength);
- }
- $foobar = strpos($this->tpldir, $this->dirroot);
- if (!($foobar === false || $foobar != 0)) {
- $this->tpldir = $dirroot . substr($this->tpldir, $oldlength);
- }
- $this->dirroot = $dirroot;
- return true;
-}
-
-/**
-* The method to set the libjsdir directory
-* @access public
-* @return boolean
-*/
-function setLibjsdir($libjsdir)
-{
- if ($libjsdir != '' && substr($libjsdir, -1) != '/') {
- $libjsdir .= '/';
- }
- if ($libjsdir == '' || substr($libjsdir, 0, 1) != '/') {
- $foobar = strpos($libjsdir, $this->dirroot);
- if ($foobar === false || $foobar != 0) {
- $libjsdir = $this->dirroot . $libjsdir;
- }
- }
- if (!is_dir($libjsdir)) {
- $this->error("setLibjsdir: $libjsdir is not a directory.");
- return false;
- }
- $this->libjsdir = $libjsdir;
- return true;
-}
-
-/**
-* The method to set the imgdir directory
-* @access public
-* @return boolean
-*/
-function setImgdir($imgdir)
-{
- if ($imgdir != '' && substr($imgdir, -1) != '/') {
- $imgdir .= '/';
- }
- if ($imgdir == '' || substr($imgdir, 0, 1) != '/') {
- $foobar = strpos($imgdir, $this->dirroot);
- if ($foobar === false || $foobar != 0) {
- $imgdir = $this->dirroot . $imgdir;
- }
- }
- if (!is_dir($imgdir)) {
- $this->error("setImgdir: $imgdir is not a directory.");
- return false;
- }
- $this->imgdir = $imgdir;
- return true;
-}
-
-/**
-* The method to set imgwww
-* @access public
-* @return void
-*/
-function setImgwww($imgwww)
-{
- if ($imgwww != '' && substr($imgwww, -1) != '/') {
- $imgwww .= '/';
- }
- $this->imgwww = $imgwww;
-}
-
-/**
-* The method to set the icondir directory
-* @access public
-* @return boolean
-*/
-function setIcondir($icondir)
-{
- if ($icondir != '' && substr($icondir, -1) != '/') {
- $icondir .= '/';
- }
- if ($icondir == '' || substr($icondir, 0, 1) != '/') {
- $foobar = strpos($icondir, $this->dirroot);
- if ($foobar === false || $foobar != 0) {
- $icondir = $this->dirroot . $icondir;
- }
- }
- if (!is_dir($icondir)) {
- $this->error("setIcondir: $icondir is not a directory.");
- return false;
- }
- $this->icondir = $icondir;
- return true;
-}
-
-/**
-* The method to set iconwww
-* @access public
-* @return void
-*/
-function setIconwww($iconwww)
-{
- if ($iconwww != '' && substr($iconwww, -1) != '/') {
- $iconwww .= '/';
- }
- $this->iconwww = $iconwww;
-}
-
-/**
-* The method to set the iconsize array
-* @access public
-* @return void
-*/
-function setIconsize($width, $height)
-{
- $this->iconsize['width'] = ($width == (int) $width) ? $width : 0;
- $this->iconsize['height'] = ($height == (int) $height) ? $height : 0;
- $this->issetIconsize = true;
-}
-
-/**
-* The method to unset the iconsize array
-* @access public
-* @return void
-*/
-function unsetIconsize()
-{
- unset($this->iconsize['width']);
- unset($this->iconsize['height']);
- $this->issetIconsize = false;
-}
-
-/**
-* The method to set the tpldir directory
-* @access public
-* @return boolean
-*/
-function setTpldirCommon($tpldir)
-{
- if ($tpldir != '' && substr($tpldir, -1) != '/') {
- $tpldir .= '/';
- }
- if ($tpldir == '' || substr($tpldir, 0, 1) != '/') {
- $foobar = strpos($tpldir, $this->dirroot);
- if ($foobar === false || $foobar != 0) {
- $tpldir = $this->dirroot . $tpldir;
- }
- }
- if (!is_dir($tpldir)) {
- $this->error("setTpldir: $tpldir is not a directory.");
- return false;
- }
- $this->tpldir = $tpldir;
- return true;
-}
-
-/**
-* The method to read the menu structure from a file
-* @access public
-* @param string $tree_file the menu structure file
-* @return boolean
-*/
-function setMenuStructureFile($tree_file)
-{
- if (!($fd = fopen($tree_file, 'r'))) {
- $this->error("setMenuStructureFile: unable to open file $tree_file.");
- return false;
- }
- $this->menuStructure = '';
- while ($buffer = fgets($fd, 4096)) {
- $buffer = ereg_replace(chr(13), '', $buffer); // Microsoft Stupidity Suppression
- $this->menuStructure .= $buffer;
- }
- fclose($fd);
- if ($this->menuStructure == '') {
- $this->error("setMenuStructureFile: $tree_file is empty.");
- return false;
- }
- return true;
-}
-
-/**
-* The method to set the menu structure passing it through a string
-* @access public
-* @param string $tree_string the menu structure string
-* @return boolean
-*/
-function setMenuStructureString($tree_string)
-{
- $this->menuStructure = ereg_replace(chr(13), '', $tree_string); // Microsoft Stupidity Suppression
- if ($this->menuStructure == '') {
- $this->error('setMenuStructureString: empty string.');
- return false;
- }
- return true;
-}
-
-/**
-* The method to set the value of separator
-* @access public
-* @return void
-*/
-function setSeparator($separator)
-{
- $this->separator = $separator;
-}
-
-/**
-* The method to set parameters for the DB connection
-* @access public
-* @param string $dns Data Source Name: the connection string for PEAR DB
-* @param bool $persistent DB connections are either persistent or not persistent
-* @return boolean
-*/
-function setDBConnParms($dsn, $persistent=false)
-{
- if (!is_string($dsn)) {
- $this->error('initdb: $dsn is not an string.');
- return false;
- }
- if (!is_bool($persistent)) {
- $this->error('initdb: $persistent is not a boolean.');
- return false;
- }
- $this->dsn = $dsn;
- $this->persistent = $persistent;
- return true;
-}
-
-/**
-* The method to set the name of the table storing data describing the menu
-* @access public
-* @param string
-* @return boolean
-*/
-function setTableName($tableName)
-{
- if (!is_string($tableName)) {
- $this->error('setTableName: $tableName is not a string.');
- return false;
- }
- $this->tableName = $tableName;
- return true;
-}
-
-/**
-* The method to set the name of the i18n table corresponding to $tableName
-* @access public
-* @param string
-* @return boolean
-*/
-function setTableName_i18n($tableName_i18n)
-{
- if (!is_string($tableName_i18n)) {
- $this->error('setTableName_i18n: $tableName_i18n is not a string.');
- return false;
- }
- $this->tableName_i18n = $tableName_i18n;
- return true;
-}
-
-/**
-* The method to set names of fields of the table storing data describing the menu
-* @access public
-* @param array
-* @return boolean
-*/
-function setTableFields($tableFields)
-{
- if (!is_array($tableFields)) {
- $this->error('setTableFields: $tableFields is not an array.');
- return false;
- }
- if (count($tableFields) == 0) {
- $this->error('setTableFields: $tableFields is a zero-length array.');
- return false;
- }
- reset ($tableFields);
- while (list($key, $value) = each($tableFields)) {
- $this->tableFields[$key] = ($value == '') ? "''" : $value;
- }
- return true;
-}
-
-/**
-* The method to set names of fields of the i18n table corresponding to $tableName
-* @access public
-* @param array
-* @return boolean
-*/
-function setTableFields_i18n($tableFields_i18n)
-{
- if (!is_array($tableFields_i18n)) {
- $this->error('setTableFields_i18n: $tableFields_i18n is not an array.');
- return false;
- }
- if (count($tableFields_i18n) == 0) {
- $this->error('setTableFields_i18n: $tableFields_i18n is a zero-length array.');
- return false;
- }
- reset ($tableFields_i18n);
- while (list($key, $value) = each($tableFields_i18n)) {
- $this->tableFields_i18n[$key] = ($value == '') ? "''" : $value;
- }
- return true;
-}
-
-/**
-* The method to parse the current menu structure and correspondingly update related variables
-* @access public
-* @param string $menu_name the name to be attributed to the menu
-* whose structure has to be parsed
-* @return void
-*/
-function parseStructureForMenu(
- $menu_name = '' // non consistent default...
- )
-{
- $this->_maxLevel[$menu_name] = 0;
- $this->_firstLevelCnt[$menu_name] = 0;
- $this->_firstItem[$menu_name] = $this->_nodesCount + 1;
- $cnt = $this->_firstItem[$menu_name];
- $menuStructure = $this->menuStructure;
-
- /* *********************************************** */
- /* Partially based on a piece of code taken from */
- /* TreeMenu 1.1 - Bjorge Dijkstra (bjorge@gmx.net) */
- /* *********************************************** */
-
- while ($menuStructure != '') {
- $before_cr = strcspn($menuStructure, "\n");
- $buffer = substr($menuStructure, 0, $before_cr);
- $menuStructure = substr($menuStructure, $before_cr+1);
- if (substr($buffer, 0, 1) == '#') {
- continue; // commented item line...
- }
- $tmp = rtrim($buffer);
- $node = explode($this->separator, $tmp);
- for ($i=count($node); $i<=6; $i++) {
- $node[$i] = '';
- }
- $this->tree[$cnt]['level'] = strlen($node[0]);
- $this->tree[$cnt]['text'] = $node[1];
- $this->tree[$cnt]['href'] = $node[2];
- $this->tree[$cnt]['title'] = $node[3];
- $this->tree[$cnt]['icon'] = $node[4];
- $this->tree[$cnt]['target'] = $node[5];
- $this->tree[$cnt]['expanded'] = $node[6];
- $cnt++;
- }
-
- /* *********************************************** */
-
- $this->_lastItem[$menu_name] = count($this->tree);
- $this->_nodesCount = $this->_lastItem[$menu_name];
- $this->tree[$this->_lastItem[$menu_name]+1]['level'] = 0;
- $this->_postParse($menu_name);
-}
-
-/**
-* The method to parse the current menu table and correspondingly update related variables
-* @access public
-* @param string $menu_name the name to be attributed to the menu
-* whose structure has to be parsed
-* @param string $language i18n language; either omit it or pass
-* an empty string ('') if you do not want to use any i18n table
-* @return void
-*/
-function scanTableForMenu(
- $menu_name = '', // non consistent default...
- $language = ''
- )
-{
- $this->_maxLevel[$menu_name] = 0;
- $this->_firstLevelCnt[$menu_name] = 0;
- unset($this->tree[$this->_nodesCount+1]);
- $this->_firstItem[$menu_name] = $this->_nodesCount + 1;
-/* BEGIN BENCHMARK CODE
-$time_start = $this->_getmicrotime();
-/* END BENCHMARK CODE */
- $db = DB::connect($this->dsn, $this->persistent);
- if (DB::isError($db)) {
- $this->error('scanTableForMenu: ' . $db->getMessage());
- }
- $dbresult = $db->query('
- SELECT ' .
- $this->tableFields['id'] . ' AS id, ' .
- $this->tableFields['parent_id'] . ' AS parent_id, ' .
- $this->tableFields['text'] . ' AS text, ' .
- $this->tableFields['href'] . ' AS href, ' .
- $this->tableFields['title'] . ' AS title, ' .
- $this->tableFields['icon'] . ' AS icon, ' .
- $this->tableFields['target'] . ' AS target, ' .
- $this->tableFields['expanded'] . ' AS expanded
- FROM ' . $this->tableName . '
- WHERE ' . $this->tableFields['id'] . ' <> 1
- ORDER BY ' . $this->tableFields['orderfield'] . ', ' . $this->tableFields['text'] . ' ASC
- ');
- $this->_tmpArray = array();
- while ($dbresult->fetchInto($row, DB_FETCHMODE_ASSOC)) {
- $this->_tmpArray[$row['id']]['parent_id'] = $row['parent_id'];
- $this->_tmpArray[$row['id']]['text'] = $row['text'];
- $this->_tmpArray[$row['id']]['href'] = $row['href'];
- $this->_tmpArray[$row['id']]['title'] = $row['title'];
- $this->_tmpArray[$row['id']]['icon'] = $row['icon'];
- $this->_tmpArray[$row['id']]['target'] = $row['target'];
- $this->_tmpArray[$row['id']]['expanded'] = $row['expanded'];
- }
- if ($language != '') {
- $dbresult = $db->query('
- SELECT ' .
- $this->tableFields_i18n['id'] . ' AS id, ' .
- $this->tableFields_i18n['text'] . ' AS text, ' .
- $this->tableFields_i18n['title'] . ' AS title
- FROM ' . $this->tableName_i18n . '
- WHERE ' . $this->tableFields_i18n['id'] . ' <> 1
- AND ' . $this->tableFields_i18n['language'] . ' = ' . "'$language'" . '
- ');
- while ($dbresult->fetchInto($row, DB_FETCHMODE_ASSOC)) {
- if (isset($this->_tmpArray[$row['id']])) {
- $this->_tmpArray[$row['id']]['text'] = $row['text'];
- $this->_tmpArray[$row['id']]['title'] = $row['title'];
- }
- }
- }
- unset($dbresult);
- unset($row);
- $this->_depthFirstSearch($menu_name, $this->_tmpArray, 1, 1);
-/* BEGIN BENCHMARK CODE
-$time_end = $this->_getmicrotime();
-$time = $time_end - $time_start;
-print "TIME ELAPSED = $time\n<br>";
-/* END BENCHMARK CODE */
- $this->_lastItem[$menu_name] = count($this->tree);
- $this->_nodesCount = $this->_lastItem[$menu_name];
- $this->tree[$this->_lastItem[$menu_name]+1]['level'] = 0;
- $this->_postParse($menu_name);
-}
-
-function _getmicrotime()
-{
- list($usec, $sec) = explode(' ', microtime());
- return ((float) $usec + (float) $sec);
-}
-
-/**
-* Recursive method to perform the depth-first search of the tree data taken from the current menu table
-* @access private
-* @param string $menu_name the name to be attributed to the menu
-* whose structure has to be parsed
-* @param array $tmpArray the temporary array that stores data to perform
-* the depth-first search
-* @param integer $parent_id id of the item whose children have
-* to be searched for
-* @param integer $level the hierarchical level of children to be searched for
-* @return void
-*/
-function _depthFirstSearch($menu_name, $tmpArray, $parent_id=1, $level=1)
-{
- reset ($tmpArray);
- while (list($id, $foobar) = each($tmpArray)) {
- if ($foobar['parent_id'] == $parent_id) {
- unset($tmpArray[$id]);
- unset($this->_tmpArray[$id]);
- $cnt = count($this->tree) + 1;
- $this->tree[$cnt]['level'] = $level;
- $this->tree[$cnt]['text'] = $foobar['text'];
- $this->tree[$cnt]['href'] = $foobar['href'];
- $this->tree[$cnt]['title'] = $foobar['title'];
- $this->tree[$cnt]['icon'] = $foobar['icon'];
- $this->tree[$cnt]['target'] = $foobar['target'];
- $this->tree[$cnt]['expanded'] = $foobar['expanded'];
- $this->treecnt[$menu_name][$id] = $cnt;
- unset($foobar);
- if ($id != $parent_id) {
- $this->_depthFirstSearch($menu_name, $this->_tmpArray, $id, $level+1);
- }
- }
- }
-}
-
-/**
-* A method providing parsing needed after both file/string parsing and DB table parsing
-* @access private
-* @param string $menu_name the name of the menu for which the parsing
-* has to be performed
-* @return void
-*/
-function _postParse(
- $menu_name = '' // non consistent default...
- )
-{
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
- $this->tree[$cnt]['child_of_root_node'] = ($this->tree[$cnt]['level'] == 1);
- $this->tree[$cnt]['parsed_text'] = stripslashes($this->tree[$cnt]['text']);
- $this->tree[$cnt]['parsed_href'] = (ereg_replace(' ', '', $this->tree[$cnt]['href']) == '') ? '#' : $this->prependedUrl . $this->tree[$cnt]['href'];
- $this->tree[$cnt]['parsed_title'] = ($this->tree[$cnt]['title'] == '') ? '' : ' title="' . stripslashes($this->tree[$cnt]['title']) . '"';
- $fooimg = $this->icondir . $this->tree[$cnt]['icon'];
- if ($this->tree[$cnt]['icon'] != '' && (substr($this->tree[$cnt]['icon'], 0, 7) == 'http://' || substr($this->tree[$cnt]['icon'], 0, 8) == 'https://')) {
- $this->tree[$cnt]['parsed_icon'] = $this->tree[$cnt]['icon'];
- if ($this->issetIconsize) {
- $this->tree[$cnt]['iconwidth'] = $this->iconsize['width'];
- $this->tree[$cnt]['iconheight'] = $this->iconsize['height'];
- } else {
- $foobar = getimagesize($this->tree[$cnt]['icon']);
- $this->tree[$cnt]['iconwidth'] = $foobar[0];
- $this->tree[$cnt]['iconheight'] = $foobar[1];
- }
- } elseif ($this->tree[$cnt]['icon'] != '' && file_exists($fooimg)) {
- $this->tree[$cnt]['parsed_icon'] = $this->iconwww . $this->tree[$cnt]['icon'];
- if ($this->issetIconsize) {
- $this->tree[$cnt]['iconwidth'] = $this->iconsize['width'];
- $this->tree[$cnt]['iconheight'] = $this->iconsize['height'];
- } else {
- $foobar = getimagesize($fooimg);
- $this->tree[$cnt]['iconwidth'] = $foobar[0];
- $this->tree[$cnt]['iconheight'] = $foobar[1];
- }
- } else {
- $this->tree[$cnt]['parsed_icon'] = '';
- }
- $this->tree[$cnt]['parsed_target'] = ($this->tree[$cnt]['target'] == '') ? '' : ' target="' . $this->tree[$cnt]['target'] . '"';
-// $this->tree[$cnt]['expanded'] = ($this->tree[$cnt]['expanded'] == '') ? 0 : $this->tree[$cnt]['expanded'];
- $this->_maxLevel[$menu_name] = max($this->_maxLevel[$menu_name], $this->tree[$cnt]['level']);
- if ($this->tree[$cnt]['level'] == 1) {
- $this->_firstLevelCnt[$menu_name]++;
- }
- }
-}
-
-/**
-* A method to replace strings in all URLs (hrefs) of a menu
-* @access public
-* @param string $menu_name the name of the menu for which the replacement
-* has to be performed
-* @param string $string the string to be replaced
-* @param string $value the replacement string
-* @return void
-*/
-function replaceStringInUrls($menu_name, $string, $value)
-{
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
- $this->tree[$cnt]['parsed_href'] = str_replace($string, $value, $this->tree[$cnt]['parsed_href']);
- }
-}
-
-/**
-* A method to set the same target for all links of a menu
-* @access public
-* @param string $menu_name the name of the menu for which the targets
-* have to be set
-* @param string $target the target to be set for all links
-* of the $menu_name menu
-* @return void
-*/
-function setLinksTargets($menu_name, $target)
-{
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
- $this->tree[$cnt]['parsed_target'] = ' target="' . $target . '"';
- }
-}
-
-/**
-* A method to select the current item of $menu_name in terms of $cnt, i.e., very likely, in terms of its line number in the corresponding menu structure file (excluding from the count commented out lines, if any)
-* @access public
-* @param string $menu_name the name of the menu for which the current item
-* has to be selected
-* @param integer $count the line number of the current item
-* in the corresponding menu structure file
-* (excluding from the count commented out lines, if any)
-* @return void
-*/
-function setSelectedItemByCount($menu_name, $count)
-{
- if ($count < 1) {
- $this->error("setSelectedItemByCount: the \$count argument is $count, but \$count can not be lower than 1");
- return;
- }
- if ($count > $this->_lastItem[$menu_name] - $this->_firstItem[$menu_name] + 1) {
- $this->error("setSelectedItemByCount: the \$count argument is $count and is larger than the number of items of the '$menu_name' menu");
- return;
- }
- $cnt = $this->_firstItem[$menu_name] + $count - 1;
- $this->tree[$cnt]['selected'] = true;
-}
-
-/**
-* A method to select the current item of $menu_name in terms of the corresponding id (see the DB table structure); obviously, this method can be used only together with the DB support
-* @access public
-* @param string $menu_name the name of the menu for which the current item
-* has to be selected
-* @param integer $id the id of the current item in the corresponding DB table
-* @return void
-*/
-function setSelectedItemById($menu_name, $id)
-{
- if (!isset($this->treecnt[$menu_name][$id])) {
- $this->error("setSelectedItemById: there is not any item with \$id = $id in the '$menu_name' menu");
- return;
- }
- $cnt = $this->treecnt[$menu_name][$id];
- $this->tree[$cnt]['selected'] = true;
-}
-
-/**
-* A method to select the current item of $menu_name specifying a string that occurs in the current URL
-* @access public
-* @param string $menu_name the name of the menu for which the current item
-* has to be selected
-* @param string $url a string that occurs in the current URL
-* @return void
-*/
-function setSelectedItemByUrl($menu_name, $url)
-{
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
- if (!(strpos($this->tree[$cnt]['parsed_href'], $url) === false)) {
- $this->tree[$cnt]['selected'] = true;
- break;
- }
- }
-}
-
-/**
-* A method to select the current item of $menu_name specifying a regular expression that matches (a substring of) the current URL; just the same as the setSelectedItemByUrl() method, but using eregi() instead of strpos()
-* @access public
-* @param string $menu_name the name of the menu for which the current item
-* has to be selected
-* @param string $url_eregi the regular expression that matches
-* (a substring of) the current URL
-* @return void
-*/
-function setSelectedItemByUrlEregi($menu_name, $url_eregi)
-{
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
- if (eregi($url_eregi, $this->tree[$cnt]['parsed_href'])) {
- $this->tree[$cnt]['selected'] = true;
- break;
- }
- }
-}
-
-/**
-* Method to handle errors
-* @access private
-* @param string $errormsg the error message
-* @return void
-*/
-function error($errormsg)
-{
- print "<b>LayersMenu Error:</b> $errormsg<br />\n";
- if ($this->haltOnError == 'yes') {
- die("<b>Halted.</b><br />\n");
- }
-}
-
-} /* END OF CLASS */
-
-?>
diff --git a/gosa-core/include/php_layers_menu/lib/layersmenu-process.inc.php b/gosa-core/include/php_layers_menu/lib/layersmenu-process.inc.php
+++ /dev/null
@@ -1,158 +0,0 @@
-<?php
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-/**
-* This file contains the code of the ProcessLayersMenu class.
-* @package PHPLayersMenu
-*/
-
-/**
-* This is an extension of the "common" class of the PHP Layers Menu library.
-*
-* It provides methods useful to process/convert menus data, e.g. to output a menu structure and a DB SQL dump corresponding to already parsed data and hence also to convert a menu structure file to a DB SQL dump and viceversa
-*
-* @version 3.2.0-rc
-* @package PHPLayersMenu
-*/
-class ProcessLayersMenu extends LayersMenuCommon
-{
-
-/**
-* The constructor method
-* @return void
-*/
-function ProcessLayersMenu()
-{
- $this->LayersMenuCommon();
-}
-
-/**
-* The method to set the dirroot directory
-* @access public
-* @return boolean
-*/
-function setDirroot($dirroot)
-{
- return $this->setDirrootCommon($dirroot);
-}
-
-/**
-* Method to output a menu structure corresponding to items of a menu
-* @access public
-* @param string $menu_name the name of the menu for which a menu structure
-* has to be returned
-* @param string $separator the character used in the menu structure format
-* to separate fields of each item
-* @return string
-*/
-function getMenuStructure(
- $menu_name = '', // non consistent default...
- $separator = '|'
- )
-{
- $menuStructure = '';
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the menu
- $menuStructure .= str_repeat('.', $this->tree[$cnt]['level']);
- $menuStructure .= $separator;
- $menuStructure .= $this->tree[$cnt]['text'];
- $menuStructure .= $separator;
- $menuStructure .= $this->tree[$cnt]['href'];
- $menuStructure .= $separator;
- $menuStructure .= $this->tree[$cnt]['title'];
- $menuStructure .= $separator;
- $menuStructure .= $this->tree[$cnt]['icon'];
- $menuStructure .= $separator;
- $menuStructure .= $this->tree[$cnt]['target'];
- $menuStructure .= $separator;
- $menuStructure .= $this->tree[$cnt]['expanded'];
- $menuStructure .= "\n";
- }
- return $menuStructure;
-}
-
-/**
-* Method to output a DB SQL dump corresponding to items of a menu
-* @access public
-* @param string $menu_name the name of the menu for which a DB SQL dump
-* has to be returned
-* @param string $db_type the type of DB to dump for;
-* leave it either empty or not specified if you are using PHP < 5,
-* as sqlite_escape_string() has been added in PHP 5;
-* it has to be specified and set to 'sqlite' only if the dump
-* has to be prepared for SQLite; it is not significant if != 'sqlite'
-* @return string
-*/
-function getSQLDump(
- $menu_name = '', // non consistent default...
- $db_type = ''
- )
-{
- $SQLDump = '';
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the menu
- $current_node[$this->tree[$cnt]['level']] = $cnt;
- if (!$this->tree[$cnt]['child_of_root_node']) {
- $this->tree[$cnt]['father_node'] = $current_node[$this->tree[$cnt]['level']-1];
- }
- $VALUES = '';
- $SQLDump .= 'INSERT INTO ';
- $SQLDump .= $this->tableName;
- $SQLDump .= ' (';
- $SQLDump .= $this->tableFields['id'] . ', ';
- $VALUES .= "'" . 10*$cnt . "', ";
- $SQLDump .= $this->tableFields['parent_id'] . ', ';
- if (isset($this->tree[$cnt]['father_node']) && $this->tree[$cnt]['father_node'] != 0) {
- $VALUES .= "'" . 10*$this->tree[$cnt]['father_node'] . "', ";
- } else {
- $VALUES .= "'1', ";
- }
- $SQLDump .= $this->tableFields['text'] . ', ';
- $foobar = $this->tree[$cnt]['text'];
- if ($foobar != '') {
- if ($db_type != 'sqlite') {
- $foobar = addslashes($foobar);
- } else {
- $foobar = sqlite_escape_string($foobar);
- }
- }
- $VALUES .= "'$foobar', ";
- $SQLDump .= $this->tableFields['href'] . ', ';
- $VALUES .= "'" . $this->tree[$cnt]['href'] . "', ";
- if ($this->tableFields['title'] != "''") {
- $SQLDump .= $this->tableFields['title'] . ', ';
- $foobar = $this->tree[$cnt]['title'];
- if ($foobar != '') {
- if ($db_type != 'sqlite') {
- $foobar = addslashes($foobar);
- } else {
- $foobar = sqlite_escape_string($foobar);
- }
- }
- $VALUES .= "'$foobar', ";
- }
- if ($this->tableFields['icon'] != "''") {
- $SQLDump .= $this->tableFields['icon'] . ', ';
- $VALUES .= "'" . $this->tree[$cnt]['icon'] . "', ";
- }
- if ($this->tableFields['target'] != "''") {
- $SQLDump .= $this->tableFields['target'] . ', ';
- $VALUES .= "'" . $this->tree[$cnt]['target'] . "', ";
- }
- if ($this->tableFields['orderfield'] != "''") {
- $SQLDump .= $this->tableFields['orderfield'] . ', ';
- $VALUES .= "'" . 10*$cnt . "', ";
- }
- if ($this->tableFields['expanded'] != "''") {
- $SQLDump .= $this->tableFields['expanded'] . ', ';
- $this->tree[$cnt]['expanded'] = (int) $this->tree[$cnt]['expanded'];
- $VALUES .= "'" . $this->tree[$cnt]['expanded'] . "', ";
- }
- $SQLDump = substr($SQLDump, 0, -2);
- $VALUES = substr($VALUES, 0, -2);
- $SQLDump .= ") VALUES ($VALUES);\n";
- }
- return $SQLDump;
-}
-
-} /* END OF CLASS */
-
-?>
diff --git a/gosa-core/include/php_layers_menu/lib/layersmenu.inc.php b/gosa-core/include/php_layers_menu/lib/layersmenu.inc.php
+++ /dev/null
@@ -1,942 +0,0 @@
-<?php
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-/**
-* This file contains the code of the LayersMenu class.
-* @package PHPLayersMenu
-*/
-
-/**
-* This is the LayersMenu class of the PHP Layers Menu library.
-*
-* This class depends on the LayersMenuCommon class and on the PEAR conforming version of the PHPLib Template class, i.e. on HTML_Template_PHPLIB
-*
-* @version 3.2.0-rc
-* @package PHPLayersMenu
-*/
-class LayersMenu extends LayersMenuCommon
-{
-
-/**
-* The template to be used for the first level menu of a horizontal menu.
-*
-* The value of this variable is significant only when preparing
-* a horizontal menu.
-*
-* @access private
-* @var string
-*/
-var $horizontalMenuTpl;
-/**
-* The template to be used for the first level menu of a vertical menu.
-*
-* The value of this variable is significant only when preparing
-* a vertical menu.
-*
-* @access private
-* @var string
-*/
-var $verticalMenuTpl;
-/**
-* The template to be used for submenu layers
-* @access private
-* @var string
-*/
-var $subMenuTpl;
-
-/**
-* A string containing the header needed to use the menu(s) in the page
-* @access private
-* @var string
-*/
-var $header;
-/**
-* This var tells if the header has been made or not
-* @access private
-* @var boolean
-*/
-var $_headerHasBeenMade = false;
-/**
-* The JS vector to list layers
-* @access private
-* @var string
-*/
-var $listl;
-/**
-* The JS vector of keys to know the father of each layer
-* @access private
-* @var string
-*/
-var $father_keys;
-/**
-* The JS vector of vals to know the father of each layer
-* @access private
-* @var string
-*/
-var $father_vals;
-/**
-* The JS function to set initial positions of all layers
-* @access private
-* @var string
-*/
-var $moveLayers;
-/**
-* An array containing the code related to the first level menu of each menu
-* @access private
-* @var array
-*/
-var $_firstLevelMenu;
-/**
-* A string containing the footer needed to use the menu(s) in the page
-* @access private
-* @var string
-*/
-var $footer;
-/**
-* This var tells if the footer has been made or not
-* @access private
-* @var boolean
-*/
-var $_footerHasBeenMade = false;
-
-/**
-* The image used for forward arrows.
-* @access private
-* @var string
-*/
-var $forwardArrowImg;
-/**
-* The image used for down arrows.
-* @access private
-* @var string
-*/
-var $downArrowImg;
-/**
-* A 1x1 transparent icon.
-* @access private
-* @var string
-*/
-var $transparentIcon;
-/**
-* An array to keep trace of layers containing / not containing icons
-* @access private
-* @var array
-*/
-var $_hasIcons;
-/**
-* Top offset for positioning of sub menu layers
-* @access private
-* @var integer
-*/
-var $menuTopShift;
-/**
-* Right offset for positioning of sub menu layers
-* @access private
-* @var integer
-*/
-var $menuRightShift;
-/**
-* Left offset for positioning of sub menu layers
-* @access private
-* @var integer
-*/
-var $menuLeftShift;
-/**
-* Threshold for vertical repositioning of a layer
-* @access private
-* @var integer
-*/
-var $thresholdY;
-/**
-* Step for the left boundaries of layers
-* @access private
-* @var integer
-*/
-var $abscissaStep;
-
-/**
-* The constructor method; it initializates the menu system
-* @return void
-*/
-function LayersMenu(
- $menuTopShift = 6, // Gtk2-like
- $menuRightShift = 7, // Gtk2-like
- $menuLeftShift = 2, // Gtk2-like
- $thresholdY = 5,
- $abscissaStep = 140
- )
-{
- $this->LayersMenuCommon();
-
- $this->horizontalMenuTpl = $this->tpldir . 'layersmenu-horizontal_menu.ihtml';
- $this->verticalMenuTpl = $this->tpldir . 'layersmenu-vertical_menu.ihtml';
- $this->subMenuTpl = $this->tpldir . 'layersmenu-sub_menu.ihtml';
-
- $this->header = '';
- $this->listl = '';
- $this->father_keys = '';
- $this->father_vals = '';
- $this->moveLayers = '';
- $this->_firstLevelMenu = array();
- $this->footer = '';
-
- $this->transparentIcon = 'transparent.png';
- $this->_hasIcons = array();
- $this->forwardArrowImg['src'] = 'forward-arrow.png';
- $this->forwardArrowImg['width'] = 4;
- $this->forwardArrowImg['height'] = 7;
- $this->downArrowImg['src'] = 'down-arrow.png';
- $this->downArrowImg['width'] = 9;
- $this->downArrowImg['height'] = 5;
- $this->menuTopShift = $menuTopShift;
- $this->menuRightShift = $menuRightShift;
- $this->menuLeftShift = $menuLeftShift;
- $this->thresholdY = $thresholdY;
- $this->abscissaStep = $abscissaStep;
-}
-
-/**
-* The method to set the value of menuTopShift
-* @access public
-* @return void
-*/
-function setMenuTopShift($menuTopShift)
-{
- $this->menuTopShift = $menuTopShift;
-}
-
-/**
-* The method to set the value of menuRightShift
-* @access public
-* @return void
-*/
-function setMenuRightShift($menuRightShift)
-{
- $this->menuRightShift = $menuRightShift;
-}
-
-/**
-* The method to set the value of menuLeftShift
-* @access public
-* @return void
-*/
-function setMenuLeftShift($menuLeftShift)
-{
- $this->menuLeftShift = $menuLeftShift;
-}
-
-/**
-* The method to set the value of thresholdY
-* @access public
-* @return void
-*/
-function setThresholdY($thresholdY)
-{
- $this->thresholdY = $thresholdY;
-}
-
-/**
-* The method to set the value of abscissaStep
-* @access public
-* @return void
-*/
-function setAbscissaStep($abscissaStep)
-{
- $this->abscissaStep = $abscissaStep;
-}
-
-/**
-* The method to set the dirroot directory
-* @access public
-* @return boolean
-*/
-function setDirroot($dirroot)
-{
- $oldtpldir = $this->tpldir;
- if ($foobar = $this->setDirrootCommon($dirroot)) {
- $this->updateTpldir($oldtpldir);
- }
- return $foobar;
-}
-
-/**
-* The method to set the tpldir directory
-* @access public
-* @return boolean
-*/
-function setTpldir($tpldir)
-{
- $oldtpldir = $this->tpldir;
- if ($foobar = $this->setTpldirCommon($tpldir)) {
- $this->updateTpldir($oldtpldir);
- }
- return $foobar;
-}
-
-/**
-* The method to update the templates directory path to the new tpldir
-* @access private
-* @return void
-*/
-function updateTpldir($oldtpldir)
-{
- $oldlength = strlen($oldtpldir);
- $foobar = strpos($this->horizontalMenuTpl, $oldtpldir);
- if (!($foobar === false || $foobar != 0)) {
- $this->horizontalMenuTpl = $this->tpldir . substr($this->horizontalMenuTpl, $oldlength);
- }
- $foobar = strpos($this->verticalMenuTpl, $oldtpldir);
- if (!($foobar === false || $foobar != 0)) {
- $this->verticalMenuTpl = $this->tpldir . substr($this->verticalMenuTpl, $oldlength);
- }
- $foobar = strpos($this->subMenuTpl, $oldtpldir);
- if (!($foobar === false || $foobar != 0)) {
- $this->subMenuTpl = $this->tpldir . substr($this->subMenuTpl, $oldlength);
- }
-}
-
-/**
-* The method to set horizontalMenuTpl
-* @access public
-* @return boolean
-*/
-function setHorizontalMenuTpl($horizontalMenuTpl)
-{
- if (str_replace('/', '', $horizontalMenuTpl) == $horizontalMenuTpl) {
- $horizontalMenuTpl = $this->tpldir . $horizontalMenuTpl;
- }
- if (!file_exists($horizontalMenuTpl)) {
- $this->error("setHorizontalMenuTpl: file $horizontalMenuTpl does not exist.");
- return false;
- }
- $this->horizontalMenuTpl = $horizontalMenuTpl;
- return true;
-}
-
-/**
-* The method to set verticalMenuTpl
-* @access public
-* @return boolean
-*/
-function setVerticalMenuTpl($verticalMenuTpl)
-{
- if (str_replace('/', '', $verticalMenuTpl) == $verticalMenuTpl) {
- $verticalMenuTpl = $this->tpldir . $verticalMenuTpl;
- }
- if (!file_exists($verticalMenuTpl)) {
- $this->error("setVerticalMenuTpl: file $verticalMenuTpl does not exist.");
- return false;
- }
- $this->verticalMenuTpl = $verticalMenuTpl;
- return true;
-}
-
-/**
-* The method to set subMenuTpl
-* @access public
-* @return boolean
-*/
-function setSubMenuTpl($subMenuTpl)
-{
- if (str_replace('/', '', $subMenuTpl) == $subMenuTpl) {
- $subMenuTpl = $this->tpldir . $subMenuTpl;
- }
- if (!file_exists($subMenuTpl)) {
- $this->error("setSubMenuTpl: file $subMenuTpl does not exist.");
- return false;
- }
- $this->subMenuTpl = $subMenuTpl;
- return true;
-}
-
-/**
-* A method to set transparentIcon
-* @access public
-* @param string $transparentIcon a transparentIcon filename (without the path)
-* @return void
-*/
-function setTransparentIcon($transparentIcon)
-{
- $this->transparentIcon = $transparentIcon;
-}
-
-/**
-* The method to set an image to be used for the forward arrow
-* @access public
-* @param string $forwardArrowImg the forward arrow image filename
-* @return boolean
-*/
-function setForwardArrowImg($forwardArrowImg)
-{
- if (!file_exists($this->imgdir . $forwardArrowImg)) {
- $this->error('setForwardArrowImg: file ' . $this->imgdir . $forwardArrowImg . ' does not exist.');
- return false;
- }
- $foobar = getimagesize($this->imgdir . $forwardArrowImg);
- $this->forwardArrowImg['src'] = $forwardArrowImg;
- $this->forwardArrowImg['width'] = $foobar[0];
- $this->forwardArrowImg['height'] = $foobar[1];
- return true;
-}
-
-/**
-* The method to set an image to be used for the down arrow
-* @access public
-* @param string $downArrowImg the down arrow image filename
-* @return boolean
-*/
-function setDownArrowImg($downArrowImg)
-{
- if (!file_exists($this->imgdir . $downArrowImg)) {
- $this->error('setDownArrowImg: file ' . $this->imgdir . $downArrowImg . ' does not exist.');
- return false;
- }
- $foobar = getimagesize($this->imgdir . $downArrowImg);
- $this->downArrowImg['src'] = $downArrowImg;
- $this->downArrowImg['width'] = $foobar[0];
- $this->downArrowImg['height'] = $foobar[1];
- return true;
-}
-
-/**
-* A method providing parsing needed both for horizontal and vertical menus; it can be useful also with the ProcessLayersMenu extended class
-* @access public
-* @param string $menu_name the name of the menu for which the parsing
-* has to be performed
-* @return void
-*/
-function parseCommon(
- $menu_name = '' // non consistent default...
- )
-{
- $this->_hasIcons[$menu_name] = false;
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
- $this->_hasIcons[$cnt] = false;
- $this->tree[$cnt]['layer_label'] = "L$cnt";
- $current_node[$this->tree[$cnt]['level']] = $cnt;
- if (!$this->tree[$cnt]['child_of_root_node']) {
- $this->tree[$cnt]['father_node'] = $current_node[$this->tree[$cnt]['level']-1];
- $this->father_keys .= ",'L$cnt'";
- $this->father_vals .= ",'" . $this->tree[$this->tree[$cnt]['father_node']]['layer_label'] . "'";
- }
- $this->tree[$cnt]['not_a_leaf'] = ($this->tree[$cnt+1]['level']>$this->tree[$cnt]['level'] && $cnt<$this->_lastItem[$menu_name]);
- // if the above condition is true, the node is not a leaf,
- // hence it has at least a child; if it is false, the node is a leaf
- if ($this->tree[$cnt]['not_a_leaf']) {
- // initialize the corresponding layer content trought a void string
- $this->tree[$cnt]['layer_content'] = '';
- // the new layer is accounted for in the layers list
- $this->listl .= ",'" . $this->tree[$cnt]['layer_label'] . "'";
- }
-/*
- if ($this->tree[$cnt]['not_a_leaf']) {
- $this->tree[$cnt]['parsed_href'] = '#';
- }
-*/
- if ($this->tree[$cnt]['parsed_icon'] == '') {
- $this->tree[$cnt]['iconsrc'] = $this->imgwww . $this->transparentIcon;
- $this->tree[$cnt]['iconwidth'] = 16;
- $this->tree[$cnt]['iconheight'] = 16;
- $this->tree[$cnt]['iconalt'] = ' ';
- } else {
- if ($this->tree[$cnt]['level'] > 1) {
- $this->_hasIcons[$this->tree[$cnt]['father_node']] = true;
- } else {
- $this->_hasIcons[$menu_name] = true;
- }
- $this->tree[$cnt]['iconsrc'] = $this->tree[$cnt]['parsed_icon'];
- $this->tree[$cnt]['iconalt'] = 'O';
- }
- }
-}
-
-/**
-* A method needed to update the footer both for horizontal and vertical menus
-* @access private
-* @param string $menu_name the name of the menu for which the updating
-* has to be performed
-* @return void
-*/
-function _updateFooter(
- $menu_name = '' // non consistent default...
- )
-{
- $t = new Template_PHPLIB();
- $t->setFile('tplfile', $this->subMenuTpl);
- $t->setBlock('tplfile', 'template', 'template_blck');
- $t->setBlock('template', 'sub_menu_cell', 'sub_menu_cell_blck');
- $t->setVar('sub_menu_cell_blck', '');
- $t->setBlock('template', 'separator', 'separator_blck');
- $t->setVar('separator_blck', '');
- $t->setVar('abscissaStep', $this->abscissaStep);
-
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
- if ($this->tree[$cnt]['not_a_leaf']) {
- $t->setVar(array(
- 'layer_label' => $this->tree[$cnt]['layer_label'],
- 'layer_title' => $this->tree[$cnt]['text'],
- 'sub_menu_cell_blck' => $this->tree[$cnt]['layer_content']
- ));
- $this->footer .= $t->parse('template_blck', 'template');
- }
- }
-}
-
-/**
-* Method to preparare a horizontal menu.
-*
-* This method processes items of a menu to prepare the corresponding
-* horizontal menu code updating many variables; it returns the code
-* of the corresponding _firstLevelMenu
-*
-* @access public
-* @param string $menu_name the name of the menu whose items have to be processed
-* @return string
-*/
-function newHorizontalMenu(
- $menu_name = '' // non consistent default...
- )
-{
- if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) {
- $this->error("newHorizontalMenu: the first/last item of the menu '$menu_name' is not defined; please check if you have parsed its menu data.");
- return 0;
- }
-
- $this->parseCommon($menu_name);
-
- $t = new Template_PHPLIB();
- $t->setFile('tplfile', $this->horizontalMenuTpl);
- $t->setBlock('tplfile', 'template', 'template_blck');
- $t->setBlock('template', 'horizontal_menu_cell', 'horizontal_menu_cell_blck');
- $t->setVar('horizontal_menu_cell_blck', '');
- $t->setBlock('horizontal_menu_cell', 'cell_link', 'cell_link_blck');
- $t->setVar('cell_link_blck', '');
- $t->setBlock('cell_link', 'cell_icon', 'cell_icon_blck');
- $t->setVar('cell_icon_blck', '');
- $t->setBlock('cell_link', 'cell_arrow', 'cell_arrow_blck');
- $t->setVar('cell_arrow_blck', '');
-
- $t_sub = new Template_PHPLIB();
- $t_sub->setFile('tplfile', $this->subMenuTpl);
- $t_sub->setBlock('tplfile', 'sub_menu_cell', 'sub_menu_cell_blck');
- $t_sub->setVar('sub_menu_cell_blck', '');
- $t_sub->setBlock('sub_menu_cell', 'cell_icon', 'cell_icon_blck');
- $t_sub->setVar('cell_icon_blck', '');
- $t_sub->setBlock('sub_menu_cell', 'cell_arrow', 'cell_arrow_blck');
- $t_sub->setVar('cell_arrow_blck', '');
- $t_sub->setBlock('tplfile', 'separator', 'separator_blck');
- $t_sub->setVar('separator_blck', '');
-
- $this->_firstLevelMenu[$menu_name] = '';
-
- $foobar = $this->_firstItem[$menu_name];
- $this->moveLayers .= "\tvar " . $menu_name . "TOP = getOffsetTop('" . $menu_name . "L" . $foobar . "');\n";
- $this->moveLayers .= "\tvar " . $menu_name . "HEIGHT = getOffsetHeight('" . $menu_name . "L" . $foobar . "');\n";
-
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
- if ($this->tree[$cnt]['not_a_leaf']) {
- // geometrical parameters are assigned to the new layer, related to the above mentioned children
- if ($this->tree[$cnt]['child_of_root_node']) {
- $this->moveLayers .= "\tsetTop('" . $this->tree[$cnt]['layer_label'] . "', " . $menu_name . "TOP + " . $menu_name . "HEIGHT);\n";
- $this->moveLayers .= "\tmoveLayerX1('" . $this->tree[$cnt]['layer_label'] . "', '" . $menu_name . "');\n";
- }
- }
-
- if ($this->tree[$cnt]['child_of_root_node']) {
- if ($this->tree[$cnt]['text'] == '---') {
- continue;
- }
- if ($this->tree[$cnt]['not_a_leaf']) {
- $this->tree[$cnt]['onmouseover'] = ' onmouseover="moveLayerX1(' . "'" . $this->tree[$cnt]['layer_label'] . "', '" . $menu_name . "') ; LMPopUp('" . $this->tree[$cnt]['layer_label'] . "'" . ', false);"';
- } else {
- $this->tree[$cnt]['onmouseover'] = ' onmouseover="shutdown();"';
- }
- $t->setVar(array(
- 'menu_layer_label' => $menu_name . $this->tree[$cnt]['layer_label'],
- 'imgwww' => $this->imgwww,
- 'transparent' => $this->transparentIcon,
- 'href' => $this->tree[$cnt]['parsed_href'],
- 'onmouseover' => $this->tree[$cnt]['onmouseover'],
- 'title' => $this->tree[$cnt]['parsed_title'],
- 'target' => $this->tree[$cnt]['parsed_target'],
- 'text' => $this->tree[$cnt]['text'],
- 'downsrc' => $this->downArrowImg['src'],
- 'downwidth' => $this->downArrowImg['width'],
- 'downheight' => $this->downArrowImg['height']
- ));
- if ($this->tree[$cnt]['parsed_icon'] != '') {
- $t->setVar(array(
- 'iconsrc' => $this->tree[$cnt]['iconsrc'],
- 'iconwidth' => $this->tree[$cnt]['iconwidth'],
- 'iconheight' => $this->tree[$cnt]['iconheight'],
- 'iconalt' => $this->tree[$cnt]['iconalt'],
- ));
- $t->parse('cell_icon_blck', 'cell_icon');
- } else {
- $t->setVar('cell_icon_blck', '');
- }
- if ($this->tree[$cnt]['not_a_leaf']) {
- $t->parse('cell_arrow_blck', 'cell_arrow');
- } else {
- $t->setVar('cell_arrow_blck', '');
- }
- $foobar = $t->parse('cell_link_blck', 'cell_link');
- $t->setVar(array(
- 'cellwidth' => $this->abscissaStep,
- 'cell_link_blck' => $foobar
- ));
- $t->parse('horizontal_menu_cell_blck', 'horizontal_menu_cell', true);
- } else {
- if ($this->tree[$cnt]['text'] == '---') {
- $this->tree[$this->tree[$cnt]['father_node']]['layer_content'] .= $t_sub->parse('separator_blck', 'separator');
- continue;
- }
- if ($this->tree[$cnt]['not_a_leaf']) {
- $this->tree[$cnt]['onmouseover'] = ' onmouseover="moveLayerX(' . "'" . $this->tree[$cnt]['layer_label'] . "') ; moveLayerY('" . $this->tree[$cnt]['layer_label'] . "') ; LMPopUp('" . $this->tree[$cnt]['layer_label'] . "'". ', false);"';
- } else {
- $this->tree[$cnt]['onmouseover'] = ' onmouseover="LMPopUp(' . "'" . $this->tree[$this->tree[$cnt]['father_node']]['layer_label'] . "'" . ', true);"';
- }
- $t_sub->setVar(array(
- 'imgwww' => $this->imgwww,
- 'transparent' => $this->transparentIcon,
- 'href' => $this->tree[$cnt]['parsed_href'],
- 'refid' => 'ref' . $this->tree[$cnt]['layer_label'],
- 'onmouseover' => $this->tree[$cnt]['onmouseover'],
- 'title' => $this->tree[$cnt]['parsed_title'],
- 'target' => $this->tree[$cnt]['parsed_target'],
- 'text' => $this->tree[$cnt]['text'],
- 'arrowsrc' => $this->forwardArrowImg['src'],
- 'arrowwidth' => $this->forwardArrowImg['width'],
- 'arrowheight' => $this->forwardArrowImg['height']
- ));
- if ($this->_hasIcons[$this->tree[$cnt]['father_node']]) {
- $t_sub->setVar(array(
- 'iconsrc' => $this->tree[$cnt]['iconsrc'],
- 'iconwidth' => $this->tree[$cnt]['iconwidth'],
- 'iconheight' => $this->tree[$cnt]['iconheight'],
- 'iconalt' => $this->tree[$cnt]['iconalt']
- ));
- $t_sub->parse('cell_icon_blck', 'cell_icon');
- } else {
- $t_sub->setVar('cell_icon_blck', '');
- }
- if ($this->tree[$cnt]['not_a_leaf']) {
- $t_sub->parse('cell_arrow_blck', 'cell_arrow');
- } else {
- $t_sub->setVar('cell_arrow_blck', '');
- }
- $this->tree[$this->tree[$cnt]['father_node']]['layer_content'] .= $t_sub->parse('sub_menu_cell_blck', 'sub_menu_cell');
- }
- } // end of the "for" cycle scanning all nodes
-
- $foobar = $this->_firstLevelCnt[$menu_name] * $this->abscissaStep;
- $t->setVar('menuwidth', $foobar);
- $t->setVar(array(
- 'layer_label' => $menu_name,
- 'menubody' => $this->_firstLevelMenu[$menu_name]
- ));
- $this->_firstLevelMenu[$menu_name] = $t->parse('template_blck', 'template');
-
- $this->_updateFooter($menu_name);
-
- return $this->_firstLevelMenu[$menu_name];
-}
-
-/**
-* Method to preparare a vertical menu.
-*
-* This method processes items of a menu to prepare the corresponding
-* vertical menu code updating many variables; it returns the code
-* of the corresponding _firstLevelMenu
-*
-* @access public
-* @param string $menu_name the name of the menu whose items have to be processed
-* @return string
-*/
-function newVerticalMenu(
- $menu_name = '' // non consistent default...
- )
-{
- if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) {
- $this->error("newVerticalMenu: the first/last item of the menu '$menu_name' is not defined; please check if you have parsed its menu data.");
- return 0;
- }
-
- $this->parseCommon($menu_name);
-
- $t = new Template_PHPLIB();
- $t->setFile('tplfile', $this->verticalMenuTpl);
- $t->setBlock('tplfile', 'template', 'template_blck');
- $t->setBlock('template', 'vertical_menu_box', 'vertical_menu_box_blck');
- $t->setVar('vertical_menu_box_blck', '');
- $t->setBlock('vertical_menu_box', 'vertical_menu_cell', 'vertical_menu_cell_blck');
- $t->setVar('vertical_menu_cell_blck', '');
- $t->setBlock('vertical_menu_cell', 'cell_icon', 'cell_icon_blck');
- $t->setVar('cell_icon_blck', '');
- $t->setBlock('vertical_menu_cell', 'cell_arrow', 'cell_arrow_blck');
- $t->setVar('cell_arrow_blck', '');
- $t->setBlock('vertical_menu_box', 'separator', 'separator_blck');
- $t->setVar('separator_blck', '');
-
- $t_sub = new Template_PHPLIB();
- $t_sub->setFile('tplfile', $this->subMenuTpl);
- $t_sub->setBlock('tplfile', 'sub_menu_cell', 'sub_menu_cell_blck');
- $t_sub->setVar('sub_menu_cell_blck', '');
- $t_sub->setBlock('sub_menu_cell', 'cell_icon', 'cell_icon_blck');
- $t_sub->setVar('cell_icon_blck', '');
- $t_sub->setBlock('sub_menu_cell', 'cell_arrow', 'cell_arrow_blck');
- $t_sub->setVar('cell_arrow_blck', '');
- $t_sub->setBlock('tplfile', 'separator', 'separator_blck');
- $t_sub->setVar('separator_blck', '');
-
- $this->_firstLevelMenu[$menu_name] = '';
-
- $this->moveLayers .= "\tvar " . $menu_name . "TOP = getOffsetTop('" . $menu_name . "');\n";
- $this->moveLayers .= "\tvar " . $menu_name . "LEFT = getOffsetLeft('" . $menu_name . "');\n";
- $this->moveLayers .= "\tvar " . $menu_name . "WIDTH = getOffsetWidth('" . $menu_name . "');\n";
-
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
- if ($this->tree[$cnt]['not_a_leaf']) {
- // geometrical parameters are assigned to the new layer, related to the above mentioned children
- if ($this->tree[$cnt]['child_of_root_node']) {
- $this->moveLayers .= "\tsetLeft('" . $this->tree[$cnt]['layer_label'] . "', " . $menu_name . "LEFT + " . $menu_name . "WIDTH - menuRightShift);\n";
- }
- }
-
- if ($this->tree[$cnt]['child_of_root_node']) {
- if ($this->tree[$cnt]['text'] == '---') {
- $this->_firstLevelMenu[$menu_name] .= $t->parse('separator_blck', 'separator');
- continue;
- }
- if ($this->tree[$cnt]['not_a_leaf']) {
- $this->tree[$cnt]['onmouseover'] = ' onmouseover="moveLayerX(' . "'" . $this->tree[$cnt]['layer_label'] . "') ; moveLayerY('" . $this->tree[$cnt]['layer_label'] . "') ; LMPopUp('" . $this->tree[$cnt]['layer_label'] . "'" . ', false);"';
- } else {
- $this->tree[$cnt]['onmouseover'] = ' onmouseover="shutdown();"';
- }
- $t->setVar(array(
- 'imgwww' => $this->imgwww,
- 'transparent' => $this->transparentIcon,
- 'href' => $this->tree[$cnt]['parsed_href'],
- 'refid' => 'ref' . $this->tree[$cnt]['layer_label'],
- 'onmouseover' => $this->tree[$cnt]['onmouseover'],
- 'title' => $this->tree[$cnt]['parsed_title'],
- 'target' => $this->tree[$cnt]['parsed_target'],
- 'text' => $this->tree[$cnt]['text'],
- 'arrowsrc' => $this->forwardArrowImg['src'],
- 'arrowwidth' => $this->forwardArrowImg['width'],
- 'arrowheight' => $this->forwardArrowImg['height']
- ));
- if ($this->_hasIcons[$menu_name]) {
- $t->setVar(array(
- 'iconsrc' => $this->tree[$cnt]['iconsrc'],
- 'iconwidth' => $this->tree[$cnt]['iconwidth'],
- 'iconheight' => $this->tree[$cnt]['iconheight'],
- 'iconalt' => $this->tree[$cnt]['iconalt']
- ));
- $t->parse('cell_icon_blck', 'cell_icon');
- } else {
- $t->setVar('cell_icon_blck', '');
- }
- if ($this->tree[$cnt]['not_a_leaf']) {
- $t->parse('cell_arrow_blck', 'cell_arrow');
- } else {
- $t->setVar('cell_arrow_blck', '');
- }
- $this->_firstLevelMenu[$menu_name] .= $t->parse('vertical_menu_cell_blck', 'vertical_menu_cell');
- } else {
- if ($this->tree[$cnt]['text'] == '---') {
- $this->tree[$this->tree[$cnt]['father_node']]['layer_content'] .= $t_sub->parse('separator_blck', 'separator');
- continue;
- }
- if ($this->tree[$cnt]['not_a_leaf']) {
- $this->tree[$cnt]['onmouseover'] = ' onmouseover="moveLayerX(' . "'" . $this->tree[$cnt]['layer_label'] . "') ; moveLayerY('" . $this->tree[$cnt]['layer_label'] . "') ; LMPopUp('" . $this->tree[$cnt]['layer_label'] . "'" . ', false);"';
- } else {
- $this->tree[$cnt]['onmouseover'] = ' onmouseover="LMPopUp(' . "'" . $this->tree[$this->tree[$cnt]['father_node']]['layer_label'] . "'" . ', true);"';
- }
- $t_sub->setVar(array(
- 'imgwww' => $this->imgwww,
- 'transparent' => $this->transparentIcon,
- 'href' => $this->tree[$cnt]['parsed_href'],
- 'refid' => 'ref' . $this->tree[$cnt]['layer_label'],
- 'onmouseover' => $this->tree[$cnt]['onmouseover'],
- 'title' => $this->tree[$cnt]['parsed_title'],
- 'target' => $this->tree[$cnt]['parsed_target'],
- 'text' => $this->tree[$cnt]['text'],
- 'arrowsrc' => $this->forwardArrowImg['src'],
- 'arrowwidth' => $this->forwardArrowImg['width'],
- 'arrowheight' => $this->forwardArrowImg['height']
- ));
- if ($this->_hasIcons[$this->tree[$cnt]['father_node']]) {
- $t_sub->setVar(array(
- 'iconsrc' => $this->tree[$cnt]['iconsrc'],
- 'iconwidth' => $this->tree[$cnt]['iconwidth'],
- 'iconheight' => $this->tree[$cnt]['iconheight'],
- 'iconalt' => $this->tree[$cnt]['iconalt']
- ));
- $t_sub->parse('cell_icon_blck', 'cell_icon');
- } else {
- $t_sub->setVar('cell_icon_blck', '');
- }
- if ($this->tree[$cnt]['not_a_leaf']) {
- $t_sub->parse('cell_arrow_blck', 'cell_arrow');
- } else {
- $t_sub->setVar('cell_arrow_blck', '');
- }
- $this->tree[$this->tree[$cnt]['father_node']]['layer_content'] .= $t_sub->parse('sub_menu_cell_blck', 'sub_menu_cell');
- }
- } // end of the "for" cycle scanning all nodes
-
- $t->setVar(array(
- 'menu_name' => $menu_name,
- 'vertical_menu_cell_blck' => $this->_firstLevelMenu[$menu_name],
- 'separator_blck' => ''
- ));
- $this->_firstLevelMenu[$menu_name] = $t->parse('vertical_menu_box_blck', 'vertical_menu_box');
- $t->setVar('abscissaStep', $this->abscissaStep);
- $t->setVar(array(
- 'layer_label' => $menu_name,
- 'vertical_menu_box_blck' => $this->_firstLevelMenu[$menu_name]
- ));
- $this->_firstLevelMenu[$menu_name] = $t->parse('template_blck', 'template');
-
- $this->_updateFooter($menu_name);
-
- return $this->_firstLevelMenu[$menu_name];
-}
-
-/**
-* Method to prepare the header.
-*
-* This method obtains the header using collected informations
-* and the suited JavaScript template; it returns the code of the header
-*
-* @access public
-* @return string
-*/
-function makeHeader()
-{
- $t = new Template_PHPLIB();
- $this->listl = 'listl = [' . substr($this->listl, 1) . '];';
- $this->father_keys = 'father_keys = [' . substr($this->father_keys, 1) . '];';
- $this->father_vals = 'father_vals = [' . substr($this->father_vals, 1) . '];';
- $t->setFile('tplfile', $this->libjsdir . 'layersmenu-header.ijs');
- $t->setVar(array(
- 'packageName' => $this->_packageName,
- 'version' => $this->version,
- 'copyright' => $this->copyright,
- 'author' => $this->author,
- 'menuTopShift' => $this->menuTopShift,
- 'menuRightShift'=> $this->menuRightShift,
- 'menuLeftShift' => $this->menuLeftShift,
- 'thresholdY' => $this->thresholdY,
- 'abscissaStep' => $this->abscissaStep,
- 'listl' => $this->listl,
- 'nodesCount' => $this->_nodesCount,
- 'father_keys' => $this->father_keys,
- 'father_vals' => $this->father_vals,
- 'moveLayers' => $this->moveLayers
- ));
- $this->header = $t->parse('out', 'tplfile');
- $this->_headerHasBeenMade = true;
- return $this->header;
-}
-
-/**
-* Method that returns the code of the header
-* @access public
-* @return string
-*/
-function getHeader()
-{
- if (!$this->_headerHasBeenMade) {
- $this->makeHeader();
- }
- return $this->header;
-}
-
-/**
-* Method that prints the code of the header
-* @access public
-* @return void
-*/
-function printHeader()
-{
- print $this->getHeader();
-}
-
-/**
-* Method that returns the code of the requested _firstLevelMenu
-* @access public
-* @param string $menu_name the name of the menu whose _firstLevelMenu
-* has to be returned
-* @return string
-*/
-function getMenu($menu_name)
-{
- return $this->_firstLevelMenu[$menu_name];
-}
-
-/**
-* Method that prints the code of the requested _firstLevelMenu
-* @access public
-* @param string $menu_name the name of the menu whose _firstLevelMenu
-* has to be printed
-* @return void
-*/
-function printMenu($menu_name)
-{
- print $this->_firstLevelMenu[$menu_name];
-}
-
-/**
-* Method to prepare the footer.
-*
-* This method obtains the footer using collected informations
-* and the suited JavaScript template; it returns the code of the footer
-*
-* @access public
-* @return string
-*/
-function makeFooter()
-{
- $t = new Template_PHPLIB();
- $t->setFile('tplfile', $this->libjsdir . 'layersmenu-footer.ijs');
- $t->setVar(array(
- 'packageName' => $this->_packageName,
- 'version' => $this->version,
- 'copyright' => $this->copyright,
- 'author' => $this->author,
- 'footer' => $this->footer
-
- ));
- $this->footer = $t->parse('out', 'tplfile');
- $this->_footerHasBeenMade = true;
- return $this->footer;
-}
-
-/**
-* Method that returns the code of the footer
-* @access public
-* @return string
-*/
-function getFooter()
-{
- if (!$this->_footerHasBeenMade) {
- $this->makeFooter();
- }
- return $this->footer;
-}
-
-/**
-* Method that prints the code of the footer
-* @access public
-* @return void
-*/
-function printFooter()
-{
- print $this->getFooter();
-}
-
-} /* END OF CLASS */
-
-?>
diff --git a/gosa-core/include/php_layers_menu/lib/phptreemenu.inc.php b/gosa-core/include/php_layers_menu/lib/phptreemenu.inc.php
+++ /dev/null
@@ -1,448 +0,0 @@
-<?php
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-/**
-* This file contains the code of the PHPTreeMenu class.
-* @package PHPLayersMenu
-*/
-
-/**
-* This is the PHPTreeMenu class of the PHP Layers Menu library.
-*
-* This class depends on the LayersMenuCommon class. It provides "server-side" (PHP-based) tree menus, that to do not require JavaScript to work.
-*
-* @version 3.2.0-rc
-* @package PHPLayersMenu
-*/
-class PHPTreeMenu extends LayersMenuCommon
-{
-
-/**
-* The character used for the PHP Tree Menu in the query string to separate items ids
-* @access private
-* @var string
-*/
-var $phpTreeMenuSeparator;
-/**
-* The default value of the expansion string for the PHP Tree Menu
-* @access private
-* @var string
-*/
-var $phpTreeMenuDefaultExpansion;
-/**
-* Type of images used for the Tree Menu
-* @access private
-* @var string
-*/
-var $phpTreeMenuImagesType;
-/**
-* Prefix for filenames of images of a theme
-* @access private
-* @var string
-*/
-var $phpTreeMenuTheme;
-/**
-* An array where we store the PHP Tree Menu code for each menu
-* @access private
-* @var array
-*/
-var $_phpTreeMenu;
-
-/**
-* The constructor method; it initializates some variables
-* @return void
-*/
-function PHPTreeMenu()
-{
- $this->LayersMenuCommon();
-
- $this->phpTreeMenuSeparator = '|';
- $this->phpTreeMenuDefaultExpansion = '';
- $this->phpTreeMenuImagesType = 'png';
- $this->phpTreeMenuTheme = '';
- $this->_phpTreeMenu = array();
-}
-
-/**
-* The method to set the dirroot directory
-* @access public
-* @return boolean
-*/
-function setDirroot($dirroot)
-{
- return $this->setDirrootCommon($dirroot);
-}
-
-/**
-* The method to set the value of separator for the Tree Menu query string
-* @access public
-* @return void
-*/
-function setPHPTreeMenuSeparator($phpTreeMenuSeparator)
-{
- $this->phpTreeMenuSeparator = $phpTreeMenuSeparator;
-}
-
-/**
-* The method to set the default value of the expansion string for the PHP Tree Menu
-* @access public
-* @return void
-*/
-function setPHPTreeMenuDefaultExpansion($phpTreeMenuDefaultExpansion)
-{
- $this->phpTreeMenuDefaultExpansion = $phpTreeMenuDefaultExpansion;
-}
-
-/**
-* The method to set the type of images used for the Tree Menu
-* @access public
-* @return void
-*/
-function setPHPTreeMenuImagesType($phpTreeMenuImagesType)
-{
- $this->phpTreeMenuImagesType = $phpTreeMenuImagesType;
-}
-
-/**
-* The method to set the prefix for filenames of images of a theme
-* @access public
-* @return void
-*/
-function setPHPTreeMenuTheme($phpTreeMenuTheme)
-{
- $this->phpTreeMenuTheme = $phpTreeMenuTheme;
-}
-
-/**
-* Method to prepare a new PHP Tree Menu.
-*
-* This method processes items of a menu and parameters submitted
-* through GET (i.e. nodes to be expanded) to prepare and return
-* the corresponding Tree Menu code.
-*
-* @access public
-* @param string $menu_name the name of the menu whose items have to be processed
-* @return string
-*/
-function newPHPTreeMenu(
- $menu_name = '' // non consistent default...
- )
-{
- $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
- $this_host = (isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
- if (isset($_SERVER['SCRIPT_NAME'])) {
- $me = $_SERVER['SCRIPT_NAME'];
- } elseif (isset($_SERVER['REQUEST_URI'])) {
- $me = $_SERVER['REQUEST_URI'];
- } elseif (isset($_SERVER['PHP_SELF'])) {
- $me = $_SERVER['PHP_SELF'];
- } elseif (isset($_SERVER['PATH_INFO'])) {
- $me = $_SERVER['PATH_INFO'];
- }
- $url = $protocol . $this_host . $me;
- $query = '';
- reset($_GET);
- while (list($key, $value) = each($_GET)) {
- if ($key != 'p' && $value != '') {
- $query .= '&' . $key . '=' . $value;
- }
- }
- if ($query != '') {
- $query = '?' . substr($query, 5) . '&p=';
- } else {
- $query = '?p=';
- }
- $p = (isset($_GET['p'])) ? $_GET['p'] : $this->phpTreeMenuDefaultExpansion;
-
-/* ********************************************************* */
-/* Based on TreeMenu 1.1 by Bjorge Dijkstra (bjorge@gmx.net) */
-/* ********************************************************* */
- $this->_phpTreeMenu[$menu_name] = '';
-
- $img_collapse = $this->imgwww . $this->phpTreeMenuTheme . 'tree_collapse.' . $this->phpTreeMenuImagesType;
- $alt_collapse = '--';
- $img_collapse_corner = $this->imgwww . $this->phpTreeMenuTheme . 'tree_collapse_corner.' . $this->phpTreeMenuImagesType;
- $alt_collapse_corner = '--';
- $img_collapse_corner_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_collapse_corner_first.' . $this->phpTreeMenuImagesType;
- $alt_collapse_corner_first = '--';
- $img_collapse_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_collapse_first.' . $this->phpTreeMenuImagesType;
- $alt_collapse_first = '--';
- $img_corner = $this->imgwww . $this->phpTreeMenuTheme . 'tree_corner.' . $this->phpTreeMenuImagesType;
- $alt_corner = '`-';
- $img_expand = $this->imgwww . $this->phpTreeMenuTheme . 'tree_expand.' . $this->phpTreeMenuImagesType;
- $alt_expand = '+-';
- $img_expand_corner = $this->imgwww . $this->phpTreeMenuTheme . 'tree_expand_corner.' . $this->phpTreeMenuImagesType;
- $alt_expand_corner = '+-';
- $img_expand_corner_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_expand_corner_first.' . $this->phpTreeMenuImagesType;
- $alt_expand_corner_first = '+-';
- $img_expand_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_expand_first.' . $this->phpTreeMenuImagesType;
- $alt_expand_first = '+-';
- $img_folder_closed = $this->imgwww . $this->phpTreeMenuTheme . 'tree_folder_closed.' . $this->phpTreeMenuImagesType;
- $alt_folder_closed = '->';
- $img_folder_open = $this->imgwww . $this->phpTreeMenuTheme . 'tree_folder_open.' . $this->phpTreeMenuImagesType;
- $alt_folder_open = '->';
- $img_leaf = $this->imgwww . $this->phpTreeMenuTheme . 'tree_leaf.' . $this->phpTreeMenuImagesType;
- $alt_leaf = '->';
- $img_space = $this->imgwww . $this->phpTreeMenuTheme . 'tree_space.' . $this->phpTreeMenuImagesType;
- $alt_space = ' ';
- $img_split = $this->imgwww . $this->phpTreeMenuTheme . 'tree_split.' . $this->phpTreeMenuImagesType;
- $alt_split = '|-';
- $img_split_first = $this->imgwww . $this->phpTreeMenuTheme . 'tree_split_first.' . $this->phpTreeMenuImagesType;
- $alt_split_first = '|-';
- $img_vertline = $this->imgwww . $this->phpTreeMenuTheme . 'tree_vertline.' . $this->phpTreeMenuImagesType;
- $alt_vertline = '| ';
-
- for ($i=$this->_firstItem[$menu_name]; $i<=$this->_lastItem[$menu_name]; $i++) {
- $expand[$i] = 0;
- $visible[$i] = 0;
- $this->tree[$i]['last_item'] = 0;
- }
- for ($i=0; $i<=$this->_maxLevel[$menu_name]; $i++) {
- $levels[$i] = 0;
- }
-
- // Get numbers of nodes to be expanded
- if ($p != '') {
- $explevels = explode($this->phpTreeMenuSeparator, $p);
- $explevels_count = count($explevels);
- for ($i=0; $i<$explevels_count; $i++) {
- $expand[$explevels[$i]] = 1;
- }
- }
-
- // Find last nodes of subtrees
- $last_level = $this->_maxLevel[$menu_name];
- for ($i=$this->_lastItem[$menu_name]; $i>=$this->_firstItem[$menu_name]; $i--) {
- if ($this->tree[$i]['level'] < $last_level) {
- for ($j=$this->tree[$i]['level']+1; $j<=$this->_maxLevel[$menu_name]; $j++) {
- $levels[$j] = 0;
- }
- }
- if ($levels[$this->tree[$i]['level']] == 0) {
- $levels[$this->tree[$i]['level']] = 1;
- $this->tree[$i]['last_item'] = 1;
- } else {
- $this->tree[$i]['last_item'] = 0;
- }
- $last_level = $this->tree[$i]['level'];
- }
-
- // Determine visible nodes
- // all root nodes are always visible
- for ($i=$this->_firstItem[$menu_name]; $i<=$this->_lastItem[$menu_name]; $i++) {
- if ($this->tree[$i]['level'] == 1) {
- $visible[$i] = 1;
- }
- }
- if (isset($explevels)) {
- for ($i=0; $i<$explevels_count; $i++) {
- $n = $explevels[$i];
- if ($n >= $this->_firstItem[$menu_name] && $n <= $this->_lastItem[$menu_name] && $visible[$n] == 1 && $expand[$n] == 1) {
- $j = $n + 1;
- while ($j<=$this->_lastItem[$menu_name] && $this->tree[$j]['level']>$this->tree[$n]['level']) {
- if ($this->tree[$j]['level'] == $this->tree[$n]['level']+1) {
- $visible[$j] = 1;
- }
- $j++;
- }
- }
- }
- }
-
- // Output nicely formatted tree
- for ($i=0; $i<$this->_maxLevel[$menu_name]; $i++) {
- $levels[$i] = 1;
- }
- $max_visible_level = 0;
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
- if ($visible[$cnt]) {
- $max_visible_level = max($max_visible_level, $this->tree[$cnt]['level']);
- }
- }
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
- if ($this->tree[$cnt]['text'] == '---') {
- continue; // separators are significant only for layers-based menus
- }
-
- if (isset($this->tree[$cnt]['selected']) && $this->tree[$cnt]['selected']) {
- $linkstyle = 'phplmselected';
- } else {
- $linkstyle = 'phplm';
- }
-
- if ($visible[$cnt]) {
- $this->_phpTreeMenu[$menu_name] .= '<div class="treemenudiv">' . "\n";
-
- // vertical lines from higher levels
- for ($i=0; $i<$this->tree[$cnt]['level']-1; $i++) {
- if ($levels[$i] == 1) {
- $img = $img_vertline;
- $alt = $alt_vertline;
- } else {
- $img = $img_space;
- $alt = $alt_space;
- }
- $this->_phpTreeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />';
- }
-
- $not_a_leaf = $cnt<$this->_lastItem[$menu_name] && $this->tree[$cnt+1]['level']>$this->tree[$cnt]['level'];
-
- if ($not_a_leaf) {
- // Create expand/collapse parameters
- $params = '';
- for ($i=$this->_firstItem[$menu_name]; $i<=$this->_lastItem[$menu_name]; $i++) {
- if ($expand[$i] == 1 && $cnt!= $i || ($expand[$i] == 0 && $cnt == $i)) {
- $params .= $this->phpTreeMenuSeparator . $i;
- }
- }
- if ($params != '') {
- $params = substr($params, 1);
- }
- }
-
- if ($this->tree[$cnt]['last_item'] == 1) {
- // corner at end of subtree or t-split
- if ($not_a_leaf) {
- if ($expand[$cnt] == 0) {
- if ($cnt == $this->_firstItem[$menu_name]) {
- $img = $img_expand_corner_first;
- $alt = $alt_expand_corner_first;
- } else {
- $img = $img_expand_corner;
- $alt = $alt_expand_corner;
- }
- } else {
- if ($cnt == $this->_firstItem[$menu_name]) {
- $img = $img_collapse_corner_first;
- $alt = $alt_collapse_corner_first;
- } else {
- $img = $img_collapse_corner;
- $alt = $alt_collapse_corner;
- }
- }
- $this->_phpTreeMenu[$menu_name] .= '<a name="' . $cnt . '" class="' . $linkstyle . '" href="' . $url . $query . $params . '#' . $cnt . '"><img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" /></a>';
- } else {
- $this->_phpTreeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img_corner . '" alt="' . $alt_corner . '" />';
- }
- $levels[$this->tree[$cnt]['level']-1] = 0;
- } else {
- if ($not_a_leaf) {
- if ($expand[$cnt] == 0) {
- if ($cnt == $this->_firstItem[$menu_name]) {
- $img = $img_expand_first;
- $alt = $alt_expand_first;
- } else {
- $img = $img_expand;
- $alt = $alt_expand;
- }
- } else {
- if ($cnt == $this->_firstItem[$menu_name]) {
- $img = $img_collapse_first;
- $alt = $alt_collapse_first;
- } else {
- $img = $img_collapse;
- $alt = $alt_collapse;
- }
- }
- $this->_phpTreeMenu[$menu_name] .= '<a name="' . $cnt . '" class="' . $linkstyle . '" href="' . $url . $query . $params . '#' . $cnt . '"><img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" /></a>';
- } else {
- if ($cnt == $this->_firstItem[$menu_name]) {
- $img = $img_split_first;
- $alt = $alt_split_first;
- } else {
- $img = $img_split;
- $alt = $alt_split;
- }
- $this->_phpTreeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />';
- }
- $levels[$this->tree[$cnt]['level']-1] = 1;
- }
-
- if ($this->tree[$cnt]['parsed_href'] == '' || $this->tree[$cnt]['parsed_href'] == '#') {
- $a_href_open_img = '';
- $a_href_close_img = '';
- $a_href_open = '<a class="phplmnormal">';
- $a_href_close = '</a>';
- } else {
- $a_href_open_img = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . '>';
- $a_href_close_img = '</a>';
- $a_href_open = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . ' class="' . $linkstyle . '">';
- $a_href_close = '</a>';
- }
-
- if ($not_a_leaf) {
- if ($expand[$cnt] == 1) {
- $img = $img_folder_open;
- $alt = $alt_folder_open;
- } else {
- $img = $img_folder_closed;
- $alt = $alt_folder_closed;
- }
- $this->_phpTreeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />' . $a_href_close_img;
- } else {
- if ($this->tree[$cnt]['parsed_icon'] != '') {
- $this->_phpTreeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" src="' . $this->tree[$cnt]['parsed_icon'] . '" width="' . $this->tree[$cnt]['iconwidth'] . '" height="' . $this->tree[$cnt]['iconheight'] . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
- } else {
- $this->_phpTreeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" src="' . $img_leaf . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
- }
- }
-
- // output item text
- $foobar = $max_visible_level - $this->tree[$cnt]['level'] + 1;
- if ($foobar > 1) {
- $colspan = ' colspan="' . $foobar . '"';
- } else {
- $colspan = '';
- }
- $this->_phpTreeMenu[$menu_name] .= ' ' . $a_href_open . $this->tree[$cnt]['parsed_text'] . $a_href_close . "\n";
- $this->_phpTreeMenu[$menu_name] .= '</div>' . "\n";
- }
- }
-/* ********************************************************* */
-
-/*
- $this->_phpTreeMenu[$menu_name] =
- '<div class="phplmnormal">' . "\n" .
- $this->_phpTreeMenu[$menu_name] .
- '</div>' . "\n";
-*/
- // Some (old) browsers do not support the "white-space: nowrap;" CSS property...
- $this->_phpTreeMenu[$menu_name] =
- '<table cellspacing="0" cellpadding="0" border="0">' . "\n" .
- '<tr>' . "\n" .
- '<td class="phplmnormal" nowrap="nowrap">' . "\n" .
- $this->_phpTreeMenu[$menu_name] .
- '</td>' . "\n" .
- '</tr>' . "\n" .
- '</table>' . "\n";
-
- return $this->_phpTreeMenu[$menu_name];
-}
-
-/**
-* Method that returns the code of the requested PHP Tree Menu
-* @access public
-* @param string $menu_name the name of the menu whose PHP Tree Menu code
-* has to be returned
-* @return string
-*/
-function getPHPTreeMenu($menu_name)
-{
- return $this->_phpTreeMenu[$menu_name];
-}
-
-/**
-* Method that prints the code of the requested PHP Tree Menu
-* @access public
-* @param string $menu_name the name of the menu whose PHP Tree Menu code
-* has to be printed
-* @return void
-*/
-function printPHPTreeMenu($menu_name)
-{
- print $this->_phpTreeMenu[$menu_name];
-}
-
-} /* END OF CLASS */
-
-?>
diff --git a/gosa-core/include/php_layers_menu/lib/plainmenu.inc.php b/gosa-core/include/php_layers_menu/lib/plainmenu.inc.php
+++ /dev/null
@@ -1,281 +0,0 @@
-<?php
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-/**
-* This file contains the code of the PlainMenu class.
-* @package PHPLayersMenu
-*/
-
-/**
-* This is the PlainMenu class of the PHP Layers Menu library.
-*
-* This class depends on the LayersMenuCommon class and on the PEAR conforming version of the PHPLib Template class, i.e. on HTML_Template_PHPLIB. It provides plain menus, that to do not require JavaScript to work.
-*
-* @version 3.2.0-rc
-* @package PHPLayersMenu
-*/
-class PlainMenu extends LayersMenuCommon
-{
-
-/**
-* The template to be used for the Plain Menu
-*/
-var $plainMenuTpl;
-/**
-* An array where we store the Plain Menu code for each menu
-* @access private
-* @var array
-*/
-var $_plainMenu;
-
-/**
-* The template to be used for the Horizontal Plain Menu
-*/
-var $horizontalPlainMenuTpl;
-/**
-* An array where we store the Horizontal Plain Menu code for each menu
-* @access private
-* @var array
-*/
-var $_horizontalPlainMenu;
-
-/**
-* The constructor method; it initializates some variables
-* @return void
-*/
-function PlainMenu()
-{
- $this->LayersMenuCommon();
-
- $this->plainMenuTpl = $this->tpldir . 'layersmenu-plain_menu.ihtml';
- $this->_plainMenu = array();
-
- $this->horizontalPlainMenuTpl = $this->tpldir . 'layersmenu-horizontal_plain_menu.ihtml';
- $this->_horizontalPlainMenu = array();
-}
-
-/**
-* The method to set the dirroot directory
-* @access public
-* @return boolean
-*/
-function setDirroot($dirroot)
-{
- $oldtpldir = $this->tpldir;
- if ($foobar = $this->setDirrootCommon($dirroot)) {
- $this->updateTpldir($oldtpldir);
- }
- return $foobar;
-}
-
-/**
-* The method to set the tpldir directory
-* @access public
-* @return boolean
-*/
-function setTpldir($tpldir)
-{
- $oldtpldir = $this->tpldir;
- if ($foobar = $this->setTpldirCommon($tpldir)) {
- $this->updateTpldir($oldtpldir);
- }
- return $foobar;
-}
-
-/**
-* The method to update the templates directory path to the new tpldir
-* @access private
-* @return void
-*/
-function updateTpldir($oldtpldir)
-{
- $oldlength = strlen($oldtpldir);
- $foobar = strpos($this->plainMenuTpl, $oldtpldir);
- if (!($foobar === false || $foobar != 0)) {
- $this->plainMenuTpl = $this->tpldir . substr($this->plainMenuTpl, $oldlength);
- }
- $foobar = strpos($this->horizontalPlainMenuTpl, $oldtpldir);
- if (!($foobar === false || $foobar != 0)) {
- $this->horizontalPlainMenuTpl = $this->tpldir . substr($this->horizontalPlainMenuTpl, $oldlength);
- }
-}
-
-/**
-* The method to set plainMenuTpl
-* @access public
-* @return boolean
-*/
-function setPlainMenuTpl($plainMenuTpl)
-{
- if (str_replace('/', '', $plainMenuTpl) == $plainMenuTpl) {
- $plainMenuTpl = $this->tpldir . $plainMenuTpl;
- }
- if (!file_exists($plainMenuTpl)) {
- $this->error("setPlainMenuTpl: file $plainMenuTpl does not exist.");
- return false;
- }
- $this->plainMenuTpl = $plainMenuTpl;
- return true;
-}
-
-/**
-* Method to prepare a new Plain Menu.
-*
-* This method processes items of a menu to prepare and return
-* the corresponding Plain Menu code.
-*
-* @access public
-* @param string $menu_name the name of the menu whose items have to be processed
-* @return string
-*/
-function newPlainMenu(
- $menu_name = '' // non consistent default...
- )
-{
- $plain_menu_blck = '';
- $t = new Template_PHPLIB();
- $t->setFile('tplfile', $this->plainMenuTpl);
- $t->setBlock('tplfile', 'template', 'template_blck');
- $t->setBlock('template', 'plain_menu_cell', 'plain_menu_cell_blck');
- $t->setVar('plain_menu_cell_blck', '');
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
- if ($this->tree[$cnt]['text'] == '---') {
- continue; // separators are significant only for layers-based menus
- }
- $nbsp = '';
- for ($i=1; $i<$this->tree[$cnt]['level']; $i++) {
- $nbsp .= ' ';
- }
- $t->setVar(array(
- 'nbsp' => $nbsp,
- 'href' => $this->tree[$cnt]['parsed_href'],
- 'title' => $this->tree[$cnt]['parsed_title'],
- 'target' => $this->tree[$cnt]['parsed_target'],
- 'text' => $this->tree[$cnt]['parsed_text']
- ));
- $plain_menu_blck .= $t->parse('plain_menu_cell_blck', 'plain_menu_cell', false);
- }
- $t->setVar('plain_menu_cell_blck', $plain_menu_blck);
- $this->_plainMenu[$menu_name] = $t->parse('template_blck', 'template');
-
- return $this->_plainMenu[$menu_name];
-}
-
-/**
-* Method that returns the code of the requested Plain Menu
-* @access public
-* @param string $menu_name the name of the menu whose Plain Menu code
-* has to be returned
-* @return string
-*/
-function getPlainMenu($menu_name)
-{
- return $this->_plainMenu[$menu_name];
-}
-
-/**
-* Method that prints the code of the requested Plain Menu
-* @access public
-* @param string $menu_name the name of the menu whose Plain Menu code
-* has to be printed
-* @return void
-*/
-function printPlainMenu($menu_name)
-{
- print $this->_plainMenu[$menu_name];
-}
-
-/**
-* The method to set horizontalPlainMenuTpl
-* @access public
-* @return boolean
-*/
-function setHorizontalPlainMenuTpl($horizontalPlainMenuTpl)
-{
- if (str_replace('/', '', $horizontalPlainMenuTpl) == $horizontalPlainMenuTpl) {
- $horizontalPlainMenuTpl = $this->tpldir . $horizontalPlainMenuTpl;
- }
- if (!file_exists($horizontalPlainMenuTpl)) {
- $this->error("setHorizontalPlainMenuTpl: file $horizontalPlainMenuTpl does not exist.");
- return false;
- }
- $this->horizontalPlainMenuTpl = $horizontalPlainMenuTpl;
- return true;
-}
-
-/**
-* Method to prepare a new Horizontal Plain Menu.
-*
-* This method processes items of a menu to prepare and return
-* the corresponding Horizontal Plain Menu code.
-*
-* @access public
-* @param string $menu_name the name of the menu whose items have to be processed
-* @return string
-*/
-function newHorizontalPlainMenu(
- $menu_name = '' // non consistent default...
- )
-{
- $horizontal_plain_menu_blck = '';
- $t = new Template_PHPLIB();
- $t->setFile('tplfile', $this->horizontalPlainMenuTpl);
- $t->setBlock('tplfile', 'template', 'template_blck');
- $t->setBlock('template', 'horizontal_plain_menu_cell', 'horizontal_plain_menu_cell_blck');
- $t->setVar('horizontal_plain_menu_cell_blck', '');
- $t->setBlock('horizontal_plain_menu_cell', 'plain_menu_cell', 'plain_menu_cell_blck');
- $t->setVar('plain_menu_cell_blck', '');
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
- if ($this->tree[$cnt]['text'] == '---') {
- continue; // separators are significant only for layers-based menus
- }
- if ($this->tree[$cnt]['level'] == 1 && $cnt > $this->_firstItem[$menu_name]) {
- $t->parse('horizontal_plain_menu_cell_blck', 'horizontal_plain_menu_cell', true);
- $t->setVar('plain_menu_cell_blck', '');
- }
- $nbsp = '';
- for ($i=1; $i<$this->tree[$cnt]['level']; $i++) {
- $nbsp .= ' ';
- }
- $t->setVar(array(
- 'nbsp' => $nbsp,
- 'href' => $this->tree[$cnt]['parsed_href'],
- 'title' => $this->tree[$cnt]['parsed_title'],
- 'target' => $this->tree[$cnt]['parsed_target'],
- 'text' => $this->tree[$cnt]['parsed_text']
- ));
- $t->parse('plain_menu_cell_blck', 'plain_menu_cell', true);
- }
- $t->parse('horizontal_plain_menu_cell_blck', 'horizontal_plain_menu_cell', true);
- $this->_horizontalPlainMenu[$menu_name] = $t->parse('template_blck', 'template');
-
- return $this->_horizontalPlainMenu[$menu_name];
-}
-
-/**
-* Method that returns the code of the requested Horizontal Plain Menu
-* @access public
-* @param string $menu_name the name of the menu whose Horizontal Plain Menu code
-* has to be returned
-* @return string
-*/
-function getHorizontalPlainMenu($menu_name)
-{
- return $this->_horizontalPlainMenu[$menu_name];
-}
-
-/**
-* Method that prints the code of the requested Horizontal Plain Menu
-* @access public
-* @param string $menu_name the name of the menu whose Horizontal Plain Menu code
-* has to be printed
-* @return void
-*/
-function printHorizontalPlainMenu($menu_name)
-{
- print $this->_horizontalPlainMenu[$menu_name];
-}
-
-} /* END OF CLASS */
-
-?>
diff --git a/gosa-core/include/php_layers_menu/lib/treemenu.inc.php b/gosa-core/include/php_layers_menu/lib/treemenu.inc.php
+++ /dev/null
@@ -1,352 +0,0 @@
-<?php
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-/**
-* This file contains the code of the TreeMenu class.
-* @package PHPLayersMenu
-*/
-
-/**
-* This is the TreeMenu class of the PHP Layers Menu library.
-*
-* This class depends on the LayersMenuCommon class and on the PEAR conforming version of the PHPLib Template class, i.e. on HTML_Template_PHPLIB
-*
-* @version 3.2.0-rc
-* @package PHPLayersMenu
-*/
-class TreeMenu extends LayersMenuCommon
-{
-
-/**
-* Type of images used for the Tree Menu
-* @access private
-* @var string
-*/
-var $treeMenuImagesType;
-/**
-* Prefix for filenames of images of a theme
-* @access private
-* @var string
-*/
-var $treeMenuTheme;
-/**
-* An array where we store the Tree Menu code for each menu
-* @access private
-* @var array
-*/
-var $_treeMenu;
-
-/**
-* The constructor method; it initializates the menu system
-* @return void
-*/
-function TreeMenu()
-{
- $this->LayersMenuCommon();
-
- $this->treeMenuImagesType = 'png';
- $this->treeMenuTheme = '';
- $this->_treeMenu = array();
-
- $this->_nodesCount = 0;
- $this->tree = array();
- $this->_maxLevel = array();
- $this->_firstLevelCnt = array();
- $this->_firstItem = array();
- $this->_lastItem = array();
-}
-
-/**
-* The method to set the dirroot directory
-* @access public
-* @return boolean
-*/
-function setDirroot($dirroot)
-{
- return $this->setDirrootCommon($dirroot);
-}
-
-/**
-* The method to set the type of images used for the Tree Menu
-* @access public
-* @return void
-*/
-function setTreeMenuImagesType($treeMenuImagesType)
-{
- $this->treeMenuImagesType = $treeMenuImagesType;
-}
-
-/**
-* The method to set the prefix for filenames of images of a theme
-* @access public
-* @return void
-*/
-function setTreeMenuTheme($treeMenuTheme)
-{
- $this->treeMenuTheme = $treeMenuTheme;
-}
-
-/**
-* Method to prepare a new Tree Menu.
-*
-* This method processes items of a menu to prepare and return
-* the corresponding Tree Menu code.
-*
-* @access public
-* @param string $menu_name the name of the menu whose items have to be processed
-* @return string
-*/
-function newTreeMenu(
- $menu_name = '' // non consistent default...
- )
-{
- if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) {
- $this->error("newTreeMenu: the first/last item of the menu '$menu_name' is not defined; please check if you have parsed its menu data.");
- return 0;
- }
-
- $this->_treeMenu[$menu_name] = '';
-
- $img_collapse = $this->imgwww . $this->treeMenuTheme . 'tree_collapse.' . $this->treeMenuImagesType;
- $alt_collapse = '--';
- $img_collapse_corner = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_corner.' . $this->treeMenuImagesType;
- $alt_collapse_corner = '--';
- $img_collapse_corner_first = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_corner_first.' . $this->treeMenuImagesType;
- $alt_collapse_corner_first = '--';
- $img_collapse_first = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_first.' . $this->treeMenuImagesType;
- $alt_collapse_first = '--';
- $img_corner = $this->imgwww . $this->treeMenuTheme . 'tree_corner.' . $this->treeMenuImagesType;
- $alt_corner = '`-';
- $img_expand = $this->imgwww . $this->treeMenuTheme . 'tree_expand.' . $this->treeMenuImagesType;
- $alt_expand = '+-';
- $img_expand_corner = $this->imgwww . $this->treeMenuTheme . 'tree_expand_corner.' . $this->treeMenuImagesType;
- $alt_expand_corner = '+-';
- $img_expand_corner_first = $this->imgwww . $this->treeMenuTheme . 'tree_expand_corner_first.' . $this->treeMenuImagesType;
- $alt_expand_corner_first = '+-';
- $img_expand_first = $this->imgwww . $this->treeMenuTheme . 'tree_expand_first.' . $this->treeMenuImagesType;
- $alt_expand_first = '+-';
- $img_folder_closed = $this->imgwww . $this->treeMenuTheme . 'tree_folder_closed.' . $this->treeMenuImagesType;
- $alt_folder_closed = '->';
- $img_folder_open = $this->imgwww . $this->treeMenuTheme . 'tree_folder_open.' . $this->treeMenuImagesType;
- $alt_folder_open = '->';
- $img_leaf = $this->imgwww . $this->treeMenuTheme . 'tree_leaf.' . $this->treeMenuImagesType;
- $alt_leaf = '->';
- $img_space = $this->imgwww . $this->treeMenuTheme . 'tree_space.' . $this->treeMenuImagesType;
- $alt_space = ' ';
- $img_split = $this->imgwww . $this->treeMenuTheme . 'tree_split.' . $this->treeMenuImagesType;
- $alt_split = '|-';
- $img_split_first = $this->imgwww . $this->treeMenuTheme . 'tree_split_first.' . $this->treeMenuImagesType;
- $alt_split_first = '|-';
- $img_vertline = $this->imgwww . $this->treeMenuTheme . 'tree_vertline.' . $this->treeMenuImagesType;
- $alt_vertline = '| ';
-
- for ($i=0; $i<=$this->_maxLevel[$menu_name]; $i++) {
- $levels[$i] = 0;
- }
-
- // Find last nodes of subtrees
- $last_level = $this->_maxLevel[$menu_name];
- for ($i=$this->_lastItem[$menu_name]; $i>=$this->_firstItem[$menu_name]; $i--) {
- if ($this->tree[$i]['level'] < $last_level) {
- for ($j=$this->tree[$i]['level']+1; $j<=$this->_maxLevel[$menu_name]; $j++) {
- $levels[$j] = 0;
- }
- }
- if ($levels[$this->tree[$i]['level']] == 0) {
- $levels[$this->tree[$i]['level']] = 1;
- $this->tree[$i]['last_item'] = 1;
- } else {
- $this->tree[$i]['last_item'] = 0;
- }
- $last_level = $this->tree[$i]['level'];
- }
-
- $toggle = '';
- $toggle_function_name = 'toggle' . $menu_name;
-
- for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
- if ($this->tree[$cnt]['text'] == '---') {
- continue; // separators are significant only for layers-based menus
- }
-
- if (isset($this->tree[$cnt]['selected']) && $this->tree[$cnt]['selected']) {
- $linkstyle = 'phplmselected';
- } else {
- $linkstyle = 'phplm';
- }
-
- $this->_treeMenu[$menu_name] .= '<div id="jt' . $cnt . '" class="treemenudiv">' . "\n";
-
- // vertical lines from higher levels
- for ($i=0; $i<$this->tree[$cnt]['level']-1; $i++) {
- if ($levels[$i] == 1) {
- $img = $img_vertline;
- $alt = $alt_vertline;
- } else {
- $img = $img_space;
- $alt = $alt_space;
- }
- $this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />';
- }
-
- $not_a_leaf = $cnt<$this->_lastItem[$menu_name] && $this->tree[$cnt+1]['level']>$this->tree[$cnt]['level'];
-
- if ($this->tree[$cnt]['last_item'] == 1) {
- // corner at end of subtree or t-split
- if ($not_a_leaf) {
- if ($cnt == $this->_firstItem[$menu_name]) {
- $img = $img_collapse_corner_first;
- $alt = $alt_collapse_corner_first;
- } else {
- $img = $img_collapse_corner;
- $alt = $alt_collapse_corner;
- }
- $this->_treeMenu[$menu_name] .= '<a onmousedown="' . $toggle_function_name . "('" . $cnt . "')" . '"><img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" /></a>';
- } else {
- $this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img_corner . '" alt="' . $alt_corner . '" />';
- }
- $levels[$this->tree[$cnt]['level']-1] = 0;
- } else {
- if ($not_a_leaf) {
- if ($cnt == $this->_firstItem[$menu_name]) {
- $img = $img_collapse_first;
- $alt = $alt_collapse_first;
- } else {
- $img = $img_collapse;
- $alt = $alt_collapse;
- }
- $this->_treeMenu[$menu_name] .= '<a onmousedown="' . $toggle_function_name . "('" . $cnt . "');" . '"><img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" /></a>';
- } else {
- if ($cnt == $this->_firstItem[$menu_name]) {
- $img = $img_split_first;
- $alt = $alt_split_first;
- } else {
- $img = $img_split;
- $alt = $alt_split;
- }
- $this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" />';
- }
- $levels[$this->tree[$cnt]['level']-1] = 1;
- }
-
- if ($this->tree[$cnt]['parsed_href'] == '' || $this->tree[$cnt]['parsed_href'] == '#') {
- $a_href_open_img = '';
- $a_href_close_img = '';
- $a_href_open = '<a class="phplmnormal">';
- $a_href_close = '</a>';
- } else {
- $a_href_open_img = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . '>';
- $a_href_close_img = '</a>';
- $a_href_open = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . ' class="' . $linkstyle . '">';
- $a_href_close = '</a>';
- }
-
- if ($not_a_leaf) {
- $this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" id="jt' . $cnt . 'folder" src="' . $img_folder_open . '" alt="' . $alt_folder_open . '" />' . $a_href_close_img;
- } else {
- if ($this->tree[$cnt]['parsed_icon'] != '') {
- $this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" src="' . $this->tree[$cnt]['parsed_icon'] . '" width="' . $this->tree[$cnt]['iconwidth'] . '" height="' . $this->tree[$cnt]['iconheight'] . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
- } else {
- $this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" src="' . $img_leaf . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
- }
- }
- $this->_treeMenu[$menu_name] .= ' ' . $a_href_open . $this->tree[$cnt]['text'] . $a_href_close . "\n";
- $this->_treeMenu[$menu_name] .= '</div>' . "\n";
-
- if ($cnt<$this->_lastItem[$menu_name] && $this->tree[$cnt]['level']<$this->tree[$cnt+1]['level']) {
- $this->_treeMenu[$menu_name] .= '<div id="jt' . $cnt . 'son" class="treemenudiv">' . "\n";
- if ($this->tree[$cnt]['expanded'] != 1) {
- $toggle .= 'if (phplm_expand[' . $cnt . '] != 1) ' . $toggle_function_name . "('" . $cnt . "');\n";
- } else {
- $toggle .= 'if (phplm_collapse[' . $cnt . '] == 1) ' . $toggle_function_name . "('" . $cnt . "');\n";
- }
- }
-
- if ($cnt>$this->_firstItem[$menu_name] && $this->tree[$cnt]['level']>$this->tree[$cnt+1]['level']) {
- for ($i=max(1, $this->tree[$cnt+1]['level']); $i<$this->tree[$cnt]['level']; $i++) {
- $this->_treeMenu[$menu_name] .= '</div>' . "\n";
- }
- }
- }
-
-/*
- $this->_treeMenu[$menu_name] =
- '<div class="phplmnormal">' . "\n" .
- $this->_treeMenu[$menu_name] .
- '</div>' . "\n";
-*/
- // Some (old) browsers do not support the "white-space: nowrap;" CSS property...
- $this->_treeMenu[$menu_name] =
- '<table cellspacing="0" cellpadding="0" border="0">' . "\n" .
- '<tr>' . "\n" .
- '<td class="phplmnormal" nowrap="nowrap">' . "\n" .
- $this->_treeMenu[$menu_name] .
- '</td>' . "\n" .
- '</tr>' . "\n" .
- '</table>' . "\n";
-
- $t = new Template_PHPLIB();
- $t->setFile('tplfile', $this->libjsdir . 'layerstreemenu.ijs');
- $t->setVar(array(
- 'toggle_function_name' => $toggle_function_name,
- 'img_collapse' => $img_collapse,
- 'img_collapse_corner' => $img_collapse_corner,
- 'img_collapse_corner_first' => $img_collapse_corner_first,
- 'img_collapse_first' => $img_collapse_first,
- 'img_expand' => $img_expand,
- 'img_expand_corner' => $img_expand_corner,
- 'img_expand_corner_first' => $img_expand_corner_first,
- 'img_expand_first' => $img_expand_first,
- 'img_folder_closed' => $img_folder_closed,
- 'img_folder_open' => $img_folder_open
- ));
- $toggle_function = $t->parse('out', 'tplfile');
- $toggle_function =
- '<script language="JavaScript" type="text/javascript">' . "\n" .
- '<!--' . "\n" .
- $toggle_function .
- '// -->' . "\n" .
- '</script>' . "\n";
-
- $toggle =
- '<script language="JavaScript" type="text/javascript">' . "\n" .
- '<!--' . "\n" .
- 'if ((DOM && !Opera56 && !Konqueror22) || IE4) {' . "\n" .
- $toggle .
- '}' . "\n" .
- 'if (NS4) alert("Only the accessibility is provided to Netscape 4 on the JavaScript Tree Menu.\nWe *strongly* suggest you to upgrade your browser.");' . "\n" .
- '// -->' . "\n" .
- '</script>' . "\n";
-
- $this->_treeMenu[$menu_name] = $toggle_function . "\n" . $this->_treeMenu[$menu_name] . "\n" . $toggle;
-
- return $this->_treeMenu[$menu_name];
-}
-
-/**
-* Method that returns the code of the requested Tree Menu
-* @access public
-* @param string $menu_name the name of the menu whose Tree Menu code
-* has to be returned
-* @return string
-*/
-function getTreeMenu($menu_name)
-{
- return $this->_treeMenu[$menu_name];
-}
-
-/**
-* Method that prints the code of the requested Tree Menu
-* @access public
-* @param string $menu_name the name of the menu whose Tree Menu code
-* has to be printed
-* @return void
-*/
-function printTreeMenu($menu_name)
-{
- print $this->_treeMenu[$menu_name];
-}
-
-} /* END OF CLASS */
-
-?>
diff --git a/gosa-core/include/php_layers_menu/libjs/layersmenu-browser_detection.js b/gosa-core/include/php_layers_menu/libjs/layersmenu-browser_detection.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-DOM = (document.getElementById) ? 1 : 0;
-NS4 = (document.layers) ? 1 : 0;
-// We need to explicitly detect Konqueror
-// because Konqueror 3 sets IE = 1 ... AAAAAAAAAARGHHH!!!
-Konqueror = (navigator.userAgent.indexOf('Konqueror') > -1) ? 1 : 0;
-// We need to detect Konqueror 2.2 as it does not handle the window.onresize event
-Konqueror22 = (navigator.userAgent.indexOf('Konqueror 2.2') > -1 || navigator.userAgent.indexOf('Konqueror/2.2') > -1) ? 1 : 0;
-Konqueror30 =
- (
- navigator.userAgent.indexOf('Konqueror 3.0') > -1
- || navigator.userAgent.indexOf('Konqueror/3.0') > -1
- || navigator.userAgent.indexOf('Konqueror 3;') > -1
- || navigator.userAgent.indexOf('Konqueror/3;') > -1
- || navigator.userAgent.indexOf('Konqueror 3)') > -1
- || navigator.userAgent.indexOf('Konqueror/3)') > -1
- )
- ? 1 : 0;
-Konqueror31 = (navigator.userAgent.indexOf('Konqueror 3.1') > -1 || navigator.userAgent.indexOf('Konqueror/3.1') > -1) ? 1 : 0;
-// We need to detect Konqueror 3.2 and 3.3 as they are affected by the see-through effect only for 2 form elements
-Konqueror32 = (navigator.userAgent.indexOf('Konqueror 3.2') > -1 || navigator.userAgent.indexOf('Konqueror/3.2') > -1) ? 1 : 0;
-Konqueror33 = (navigator.userAgent.indexOf('Konqueror 3.3') > -1 || navigator.userAgent.indexOf('Konqueror/3.3') > -1) ? 1 : 0;
-Opera = (navigator.userAgent.indexOf('Opera') > -1) ? 1 : 0;
-Opera5 = (navigator.userAgent.indexOf('Opera 5') > -1 || navigator.userAgent.indexOf('Opera/5') > -1) ? 1 : 0;
-Opera6 = (navigator.userAgent.indexOf('Opera 6') > -1 || navigator.userAgent.indexOf('Opera/6') > -1) ? 1 : 0;
-Opera56 = Opera5 || Opera6;
-IE = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
-IE = IE && !Opera;
-IE5 = IE && DOM;
-IE4 = (document.all) ? 1 : 0;
-IE4 = IE4 && IE && !DOM;
-
diff --git a/gosa-core/include/php_layers_menu/libjs/layersmenu-footer.ijs b/gosa-core/include/php_layers_menu/libjs/layersmenu-footer.ijs
+++ /dev/null
@@ -1,11 +0,0 @@
-<!-- beginning of menu footer - {packageName} {version} {copyright} {author} -->
-
-{footer}
-
-<script language="JavaScript" type="text/javascript">
-<!--
-loaded = 1;
-// -->
-</script>
-
-<!-- end of menu footer - {packageName} {version} {copyright} {author} -->
diff --git a/gosa-core/include/php_layers_menu/libjs/layersmenu-header.ijs b/gosa-core/include/php_layers_menu/libjs/layersmenu-header.ijs
+++ /dev/null
@@ -1,57 +0,0 @@
-<!-- beginning of menu header - {packageName} {version} {copyright} {author} -->
-
-<script language="JavaScript" type="text/javascript">
-<!--
-
-menuTopShift = {menuTopShift};
-menuRightShift = {menuRightShift};
-menuLeftShift = {menuLeftShift};
-
-var thresholdY = {thresholdY};
-var abscissaStep = {abscissaStep};
-
-toBeHidden = new Array();
-toBeHiddenLeft = new Array();
-toBeHiddenTop = new Array();
-
-{listl}
-var numl = listl.length;
-
-father = new Array();
-for (i=1; i<={nodesCount}; i++) {
- father['L' + i] = '';
-}
-{father_keys}
-{father_vals}
-for (i=0; i<father_keys.length; i++) {
- father[father_keys[i]] = father_vals[i];
-}
-
-lwidth = new Array();
-var lwidthDetected = 0;
-
-function moveLayers()
-{
- if (!lwidthDetected) {
- for (i=0; i<numl; i++) {
- lwidth[listl[i]] = getOffsetWidth(listl[i]);
- }
- lwidthDetected = 1;
- }
- if (IE4) {
- for (i=0; i<numl; i++) {
- setWidth(listl[i], abscissaStep);
- }
- }
-{moveLayers}
-}
-
-back = new Array();
-for (i=1; i<={nodesCount}; i++) {
- back['L' + i] = 0;
-}
-
-// -->
-</script>
-
-<!-- end of menu header - {packageName} {version} {copyright} {author} -->
diff --git a/gosa-core/include/php_layers_menu/libjs/layersmenu-library.js b/gosa-core/include/php_layers_menu/libjs/layersmenu-library.js
+++ /dev/null
@@ -1,248 +0,0 @@
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-layerLeft = new Array();
-layerTop = new Array();
-
-function setVisibility(layer, on)
-{
- if (on) {
- if (DOM) {
- document.getElementById(layer).style.visibility = 'visible';
- } else if (NS4) {
- document.layers[layer].visibility = 'show';
- } else {
- document.all[layer].style.visibility = 'visible';
- }
- } else {
- if (DOM) {
- document.getElementById(layer).style.visibility = 'hidden';
- } else if (NS4) {
- document.layers[layer].visibility = 'hide';
- } else {
- document.all[layer].style.visibility = 'hidden';
- }
- }
-}
-
-function isVisible(layer)
-{
- if (DOM) {
- return (document.getElementById(layer).style.visibility == 'visible');
- } else if (NS4) {
- return (document.layers[layer].visibility == 'show');
- } else {
- return (document.all[layer].style.visibility == 'visible');
- }
-}
-
-function setLeft(layer, x)
-{
-layerLeft[layer] = x;
- if (DOM && !Opera5) {
- document.getElementById(layer).style.left = x + 'px';
- } else if (Opera5) {
- document.getElementById(layer).style.left = x;
- } else if (NS4) {
- document.layers[layer].left = x;
- } else {
- document.all[layer].style.pixelLeft = x;
- }
-}
-
-function getOffsetLeft(layer)
-{
- var value = 0;
- if (DOM) { // Mozilla, Konqueror >= 2.2, Opera >= 5, IE
- object = document.getElementById(layer);
- value = object.offsetLeft;
-//alert (object.tagName + ' --- ' + object.offsetLeft);
- while (object.tagName != 'BODY' && object.offsetParent) {
- object = object.offsetParent;
-//alert (object.tagName + ' --- ' + object.offsetLeft);
- value += object.offsetLeft;
- }
- } else if (NS4) {
- value = document.layers[layer].pageX;
- } else { // IE4 IS SIMPLY A BASTARD !!!
- if (document.all['IE4' + layer]) {
- layer = 'IE4' + layer;
- }
- object = document.all[layer];
- value = object.offsetLeft;
- while (object.tagName != 'BODY') {
- object = object.offsetParent;
- value += object.offsetLeft;
- }
- }
- return (value);
-}
-
-function setTop(layer, y)
-{
-layerTop[layer] = y;
- if (DOM && !Opera5) {
- document.getElementById(layer).style.top = y + 'px';
- } else if (Opera5) {
- document.getElementById(layer).style.top = y;
- } else if (NS4) {
- document.layers[layer].top = y;
- } else {
- document.all[layer].style.pixelTop = y;
- }
-}
-
-function getOffsetTop(layer)
-{
-// IE 5.5 and 6.0 behaviour with this function is really strange:
-// in some cases, they return a really too large value...
-// ... after all, IE is buggy, nothing new
- var value = 0;
- if (DOM) {
- object = document.getElementById(layer);
- value = object.offsetTop;
- while (object.tagName != 'BODY' && object.offsetParent) {
- object = object.offsetParent;
- value += object.offsetTop;
- }
- } else if (NS4) {
- value = document.layers[layer].pageY;
- } else { // IE4 IS SIMPLY A BASTARD !!!
- if (document.all['IE4' + layer]) {
- layer = 'IE4' + layer;
- }
- object = document.all[layer];
- value = object.offsetTop;
- while (object.tagName != 'BODY') {
- object = object.offsetParent;
- value += object.offsetTop;
- }
- }
- return (value);
-}
-
-function setWidth(layer, w)
-{
- if (DOM) {
- document.getElementById(layer).style.width = w;
- } else if (NS4) {
-// document.layers[layer].width = w;
- } else {
- document.all[layer].style.pixelWidth = w;
- }
-}
-
-function getOffsetWidth(layer)
-{
- var value = 0;
- if (DOM && !Opera56) {
- value = document.getElementById(layer).offsetWidth;
- } else if (NS4) {
- value = document.layers[layer].document.width;
- } else if (Opera56) {
- value = document.getElementById(layer).style.pixelWidth;
- } else { // IE4 IS SIMPLY A BASTARD !!!
- if (document.all['IE4' + layer]) {
- layer = 'IE4' + layer;
- }
- value = document.all[layer].offsetWidth;
- }
- return (value);
-}
-
-function setHeight(layer, h) // unused, not tested
-{
- if (DOM) {
- document.getElementById(layer).style.height = h;
- } else if (NS4) {
-// document.layers[layer].height = h;
- } else {
- document.all[layer].style.pixelHeight = h;
- }
-}
-
-function getOffsetHeight(layer)
-{
- var value = 0;
- if (DOM && !Opera56) {
- value = document.getElementById(layer).offsetHeight;
- } else if (NS4) {
- value = document.layers[layer].document.height;
- } else if (Opera56) {
- value = document.getElementById(layer).style.pixelHeight;
- } else { // IE4 IS SIMPLY A BASTARD !!!
- if (document.all['IE4' + layer]) {
- layer = 'IE4' + layer;
- }
- value = document.all[layer].offsetHeight;
- }
- return (value);
-}
-
-function getWindowWidth()
-{
- var value = 0;
- if ((DOM && !IE) || NS4 || Konqueror || Opera) {
- value = window.innerWidth;
-// } else if (NS4) {
-// value = document.width;
- } else { // IE
- if (document.documentElement && document.documentElement.clientWidth) {
- value = document.documentElement.clientWidth;
- } else if (document.body) {
- value = document.body.clientWidth;
- }
- }
- if (isNaN(value)) {
- value = window.innerWidth;
- }
- return (value);
-}
-
-function getWindowXOffset()
-{
- var value = 0;
- if ((DOM && !IE) || NS4 || Konqueror || Opera) {
- value = window.pageXOffset;
- } else { // IE
- if (document.documentElement && document.documentElement.scrollLeft) {
- value = document.documentElement.scrollLeft;
- } else if (document.body) {
- value = document.body.scrollLeft;
- }
- }
- return (value);
-}
-
-function getWindowHeight()
-{
- var value = 0;
- if ((DOM && !IE) || NS4 || Konqueror || Opera) {
- value = window.innerHeight;
- } else { // IE
- if (document.documentElement && document.documentElement.clientHeight) {
- value = document.documentElement.clientHeight;
- } else if (document.body) {
- value = document.body.clientHeight;
- }
- }
- if (isNaN(value)) {
- value = window.innerHeight;
- }
- return (value);
-}
-
-function getWindowYOffset()
-{
- var value = 0;
- if ((DOM && !IE) || NS4 || Konqueror || Opera) {
- value = window.pageYOffset;
- } else { // IE
- if (document.documentElement && document.documentElement.scrollTop) {
- value = document.documentElement.scrollTop;
- } else if (document.body) {
- value = document.body.scrollTop;
- }
- }
- return (value);
-}
-
diff --git a/gosa-core/include/php_layers_menu/libjs/layersmenu-see-through.js b/gosa-core/include/php_layers_menu/libjs/layersmenu-see-through.js
+++ /dev/null
@@ -1,65 +0,0 @@
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-function scanChildren(element)
-{
- var counter = element.childNodes.length;
- for (var i=0; i<counter; i++) {
- foobar = element.childNodes.item(i);
- if ( ( (Konqueror22 || Konqueror30 || Konqueror31) &&
- ( foobar.nodeName == 'INPUT' || foobar.nodeName == 'input'
- || foobar.nodeName == 'SELECT' || foobar.nodeName == 'select'
- || foobar.nodeName == 'TEXTAREA' || foobar.nodeName == 'textarea'
- )
- )
- ||
-// Konqueror 3.2 and 3.3 need hiding only for the following two form elements, but, alas,
-// at the time of this writing (Konqueror 3.2.3 and 3.3.0-rc2), hiding of such two form elements
-// on Konqueror 3.2 and 3.3 does not work, it is affected by the following bug: http://bugs.kde.org/72885
- ( (Konqueror32 || Konqueror33) &&
- ( ((foobar.nodeName == 'SELECT' || foobar.nodeName == 'select') && foobar.size > 1)
- || foobar.nodeName == 'TEXTAREA' || foobar.nodeName == 'textarea'
- )
- )
- ||
- ( IE &&
- ( foobar.nodeName == 'SELECT' || foobar.nodeName == 'select' )
- )
- ) {
- toBeHidden[toBeHidden.length] = foobar;
- }
- if (foobar.childNodes.length > 0) {
- scanChildren(foobar);
- }
- }
-}
-
-function seeThroughCoordinatesDetection()
-{
- if (!((Konqueror && !Konqueror22) || IE5)) {
- return;
- }
- for (i=0; i<toBeHidden.length; i++) {
- object = toBeHidden[i];
- toBeHiddenLeft[i] = object.offsetLeft;
- while (object.tagName != 'BODY' && object.offsetParent) {
- object = object.offsetParent;
- toBeHiddenLeft[i] += object.offsetLeft;
- }
- object = toBeHidden[i];
- toBeHiddenTop[i] = object.offsetTop;
- while (object.tagName != 'BODY' && object.offsetParent) {
- object = object.offsetParent;
- toBeHiddenTop[i] += object.offsetTop;
- }
- }
-}
-
-//document.write("<br />\nSCANNING STARTED<br />\n");
-//scanChildren(document.getElementsByTagName('BODY').item(0));
-if ((Konqueror || IE5) && document.getElementById('phplmseethrough')) {
- scanChildren(document.getElementById('phplmseethrough'));
-}
-//document.write("<br />\nSCANNING COMPLETED<br />\n");
-
-seeThroughCoordinatesDetection();
-
diff --git a/gosa-core/include/php_layers_menu/libjs/layersmenu.js b/gosa-core/include/php_layers_menu/libjs/layersmenu.js
+++ /dev/null
@@ -1,316 +0,0 @@
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-useTimeouts = 1;
-timeoutLength = 1000; // time in ms; not significant if useTimeouts = 0;
-shutdownOnClick = 0;
-
-loaded = 0;
-layersMoved = 0;
-layerPoppedUp = '';
-
-timeoutFlag = 0;
-if (Opera56 || IE4) {
- useTimeouts = 0;
-}
-if (NS4 || Opera56 || IE4) {
- shutdownOnClick = 1;
-}
-
-currentY = 0;
-function grabMouse(e) // for NS4
-{
- currentY = e.pageY;
-}
-if (NS4) {
- document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
- document.onmousemove = grabMouse;
-}
-
-function seeThroughElements(show)
-{
- if (show) {
- foobar = 'visible';
- } else {
- foobar = 'hidden';
- }
- for (i=0; i<toBeHidden.length; i++) {
- toBeHidden[i].style.visibility = foobar;
- }
-}
-
-function shutdown()
-{
- for (i=0; i<numl; i++) {
- LMPopUpL(listl[i], false);
- }
- layerPoppedUp = '';
- if (Konqueror || IE5) {
- seeThroughElements(true);
- }
-}
-if (shutdownOnClick) {
- if (NS4) {
- document.onmousedown = shutdown;
- } else {
- document.onclick = shutdown;
- }
-}
-
-function setLMTO()
-{
- if (useTimeouts) {
- timeoutFlag = setTimeout('shutdown()', timeoutLength);
- }
-}
-
-function clearLMTO()
-{
- if (useTimeouts) {
- clearTimeout(timeoutFlag);
- }
-}
-
-function moveLayerX(menuName)
-{
- if (!loaded || (isVisible(menuName) && menuName != layerPoppedUp)) {
- return;
- }
- if (father[menuName] != '') {
- if (!Opera5 && !IE4) {
- width0 = lwidth[father[menuName]];
- width1 = lwidth[menuName];
- } else if (Opera5) {
- // Opera 5 stupidly and exaggeratedly overestimates layers widths
- // hence we consider a default value equal to $abscissaStep
- width0 = abscissaStep;
- width1 = abscissaStep;
- } else if (IE4) {
- width0 = getOffsetWidth(father[menuName]);
- width1 = getOffsetWidth(menuName);
- }
- onLeft = getOffsetLeft(father[menuName]) - width1 + menuLeftShift;
- onRight = getOffsetLeft(father[menuName]) + width0 - menuRightShift;
- windowWidth = getWindowWidth();
- windowXOffset = getWindowXOffset();
-// if (NS4 && !DOM) {
-// windowXOffset = 0;
-// }
- if (onLeft < windowXOffset && onRight + width1 > windowWidth + windowXOffset) {
- if (onRight + width1 - windowWidth - windowXOffset > windowXOffset - onLeft) {
- onLeft = windowXOffset;
- } else {
- onRight = windowWidth + windowXOffset - width1;
- }
- }
- if (back[father[menuName]]) {
- if (onLeft < windowXOffset) {
- back[menuName] = 0;
- } else {
- back[menuName] = 1;
- }
- } else {
-//alert(onRight + ' - ' + width1 + ' - ' + windowWidth + ' - ' + windowXOffset);
- if (onRight + width1 > windowWidth + windowXOffset) {
- back[menuName] = 1;
- } else {
- back[menuName] = 0;
- }
- }
- if (back[menuName]) {
- setLeft(menuName, onLeft);
- } else {
- setLeft(menuName, onRight);
- }
- }
- moveLayerY(menuName); // workaround needed for Mozilla < 1.4 for MS Windows
-}
-
-function moveLayerY(menuName)
-{
- if (!loaded || (isVisible(menuName) && menuName != layerPoppedUp)) {
- return;
- }
- if (!layersMoved) {
- moveLayers();
- layersMoved = 1;
- }
- if (!NS4) {
- newY = getOffsetTop('ref' + menuName);
- } else {
- newY = currentY;
- }
- newY += menuTopShift;
- layerHeight = getOffsetHeight(menuName);
- windowHeight = getWindowHeight();
- windowYOffset = getWindowYOffset();
- if (newY + layerHeight > windowHeight + windowYOffset) {
- if (layerHeight > windowHeight) {
- newY = windowYOffset;
- } else {
- newY = windowHeight + windowYOffset - layerHeight;
- }
- }
- if (Math.abs(getOffsetTop(menuName) - newY) > thresholdY) {
- setTop(menuName, newY);
- }
-}
-
-function moveLayerX1(menuName, father)
-{
- if (!lwidthDetected) {
- return;
- }
- if (!Opera5 && !IE4) {
- width1 = lwidth[menuName];
- } else if (Opera5) {
- // Opera 5 stupidly and exaggeratedly overestimates layers widths
- // hence we consider a default value equal to $abscissaStep
- width1 = abscissaStep;
- }
- foobar = getOffsetLeft(father + menuName);
-if (!IE4) {
- windowWidth = getWindowWidth();
- windowXOffset = getWindowXOffset();
- if (foobar + width1 > windowWidth + windowXOffset) {
- foobar = windowWidth + windowXOffset - width1;
- }
- if (foobar < windowXOffset) {
- foobar = windowXOffset;
- }
-}
- setLeft(menuName, foobar);
-}
-
-function layersOverlap(layer, i)
-{
- if (Konqueror22) {
- return true;
- }
-
-// xa1 = getOffsetLeft(layer);
-//setLeft(layer, xa1);
- xa1 = layerLeft[layer];
- xa2 = xa1 + getOffsetWidth(layer);
-//setWidth(layer, xa2-xa1);
-// ya1 = getOffsetTop(layer);
-//setTop(layer, ya1);
- ya1 = layerTop[layer];
- ya2 = ya1 + getOffsetHeight(layer);
-//setHeight(layer, ya2-ya1);
-//alert(':' + xa1 + ':' + xa2 + ':' + ya1 + ':' + ya2 + ':');
-
- xb1 = toBeHiddenLeft[i];
- xb2 = xb1 + toBeHidden[i].offsetWidth;
- yb1 = toBeHiddenTop[i];
- yb2 = yb1 + toBeHidden[i].offsetHeight;
-//alert(':' + xb1 + ':' + xb2 + ':' + yb1 + ':' + yb2 + ':');
-
- if(xb1>xa1) xa1=xb1; if(xb2<xa2) xa2=xb2;
- if(yb1>ya1) ya1=yb1; if(yb2<ya2) ya2=yb2;
-
- return (xa2>xa1 && ya2>ya1);
-}
-
-function seeThroughWorkaround(menuName, on)
-{
- for (i=0; i<toBeHidden.length; i++) {
- if (layersOverlap(menuName, i)) {
- if (on) {
- toBeHidden[i].style.visibility = 'hidden';
- } else {
- toBeHidden[i].style.visibility = 'visible';
- }
- }
- }
-}
-
-function LMPopUpL(menuName, on)
-{
- if (!loaded) {
- return;
- }
- if (!layersMoved) {
- moveLayers();
- layersMoved = 1;
- }
- setVisibility(menuName, on);
-}
-
-function LMPopUp(menuName, isCurrent)
-{
- if (!loaded || menuName == layerPoppedUp || (isVisible(menuName) && !isCurrent)) {
- return;
- }
- if (menuName == father[layerPoppedUp]) {
- LMPopUpL(layerPoppedUp, false);
-// seeThroughWorkaround(menuName, false);
- } else if (father[menuName] == layerPoppedUp) {
- LMPopUpL(menuName, true);
- seeThroughWorkaround(menuName, true);
- } else {
- shutdown();
- foobar = menuName;
- do {
- LMPopUpL(foobar, true);
- seeThroughWorkaround(foobar, true);
- foobar = father[foobar];
- } while (foobar != '')
- }
-/*
- if (layerPoppedUp == '') {
- seeThroughElements(false);
- }
-*/
- layerPoppedUp = menuName;
-}
-
-function resizeHandler()
-{
- if (NS4) {
- window.location.reload();
- }
- shutdown();
- for (i=0; i<numl; i++) {
- setLeft(listl[i], 0);
- setTop(listl[i], 0);
- }
- if (toBeHidden != null && toBeHidden.length > 0) {
- seeThroughCoordinatesDetection();
- }
-// moveLayers();
- layersMoved = 0;
-}
-window.onresize = resizeHandler;
-
-function yaresizeHandler()
-{
- if (window.innerWidth != origWidth || window.innerHeight != origHeight) {
- if (Konqueror22 || Opera5) {
- window.location.reload(); // Opera 5 often fails this
- }
- origWidth = window.innerWidth;
- origHeight = window.innerHeight;
- resizeHandler();
- }
- setTimeout('yaresizeHandler()', 500);
-}
-function loadHandler()
-{
- if (Konqueror22 || Opera56) {
- origWidth = window.innerWidth;
- origHeight = window.innerHeight;
- yaresizeHandler();
- }
-}
-window.onload = loadHandler;
-
-function fixieflm(menuName)
-{
- if (DOM) {
- setWidth(menuName, '100%');
- } else { // IE4 IS SIMPLY A BASTARD !!!
- document.write('</div>');
- document.write('<div id="IE4' + menuName + '" style="position: relative; width: 100%; visibility: visible;">');
- }
-}
-
diff --git a/gosa-core/include/php_layers_menu/libjs/layerstreemenu-cookies.js b/gosa-core/include/php_layers_menu/libjs/layerstreemenu-cookies.js
+++ /dev/null
@@ -1,70 +0,0 @@
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-function setLMCookie(name, value)
-{
- document.cookie = name + '=' + value + ';path=/';
-}
-
-function getLMCookie(name)
-{
- foobar = document.cookie.split(name + '=');
- if (foobar.length < 2) {
- return null;
- }
- tempString = foobar[1];
- if (tempString.indexOf(';') == -1) {
- return tempString;
- }
- yafoobar = tempString.split(';');
- return yafoobar[0];
-}
-
-function parseExpandString()
-{
- expandString = getLMCookie('phplm_expand');
- phplm_expand = new Array();
- if (expandString) {
- expanded = expandString.split('|');
- for (i=0; i<expanded.length-1; i++) {
- phplm_expand[expanded[i]] = 1;
- }
- }
-}
-
-function parseCollapseString()
-{
- collapseString = getLMCookie('phplm_collapse');
- phplm_collapse = new Array();
- if (collapseString) {
- collapsed = collapseString.split('|');
- for (i=0; i<collapsed.length-1; i++) {
- phplm_collapse[collapsed[i]] = 1;
- }
- }
-}
-
-parseExpandString();
-parseCollapseString();
-
-function saveExpandString()
-{
- expandString = '';
- for (i=0; i<phplm_expand.length; i++) {
- if (phplm_expand[i] == 1) {
- expandString += i + '|';
- }
- }
- setLMCookie('phplm_expand', expandString);
-}
-
-function saveCollapseString()
-{
- collapseString = '';
- for (i=0; i<phplm_collapse.length; i++) {
- if (phplm_collapse[i] == 1) {
- collapseString += i + '|';
- }
- }
- setLMCookie('phplm_collapse', collapseString);
-}
-
diff --git a/gosa-core/include/php_layers_menu/libjs/layerstreemenu.ijs b/gosa-core/include/php_layers_menu/libjs/layerstreemenu.ijs
+++ /dev/null
@@ -1,52 +0,0 @@
-// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
-
-function {toggle_function_name}(nodeid)
-{
- if ((!DOM || Opera56 || Konqueror22) && !IE4) {
- return;
- }
- layersMoved = 0;
- parseExpandString();
- parseCollapseString();
- if (!IE4) {
- sonLayer = document.getElementById('jt' + nodeid + 'son');
- nodeLayer = document.getElementById('jt' + nodeid + 'node');
- folderLayer = document.getElementById('jt' + nodeid + 'folder');
- } else {
- sonLayer = document.all('jt' + nodeid + 'son');
- nodeLayer = document.all('jt' + nodeid + 'node');
- folderLayer = document.all('jt' + nodeid + 'folder');
- }
- if (sonLayer.style.display == 'none') {
- sonLayer.style.display = 'block';
- if (nodeLayer.src.indexOf('{img_expand}') > -1) {
- nodeLayer.src = '{img_collapse}';
- } else if (nodeLayer.src.indexOf('{img_expand_first}') > -1) {
- nodeLayer.src = '{img_collapse_first}';
- } else if (nodeLayer.src.indexOf('{img_expand_corner}') > -1) {
- nodeLayer.src = '{img_collapse_corner}';
- } else {
- nodeLayer.src = '{img_collapse_corner_first}';
- }
- folderLayer.src = '{img_folder_open}';
- phplm_expand[nodeid] = 1;
- phplm_collapse[nodeid] = 0;
- } else {
- sonLayer.style.display = 'none';
- if (nodeLayer.src.indexOf('{img_collapse}') > -1) {
- nodeLayer.src = '{img_expand}';
- } else if (nodeLayer.src.indexOf('{img_collapse_first}') > -1) {
- nodeLayer.src = '{img_expand_first}';
- } else if (nodeLayer.src.indexOf('{img_collapse_corner}') > -1) {
- nodeLayer.src = '{img_expand_corner}';
- } else {
- nodeLayer.src = '{img_expand_corner_first}';
- }
- folderLayer.src = '{img_folder_closed}';
- phplm_expand[nodeid] = 0;
- phplm_collapse[nodeid] = 1;
- }
- saveExpandString();
- saveCollapseString();
-}
-
index f50097ec8c81ca59108e7cd5cc5f747edaf566db..62ffba9bd6f30715b5c3a73dd193c6a3cd7d8c76 100644 (file)
ini_set("track_vars",1);
ini_set("display_errors",1);
ini_set("report_memleaks",1);
-ini_set("include_path",".:$BASE_DIR/include:$BASE_DIR/include/php_writeexcel");
+ini_set("include_path",".:$BASE_DIR/include:$BASE_DIR/include/utils/excel");
/* Do smarty setup */
require("smarty/Smarty.class.php");
diff --git a/gosa-core/include/php_writeexcel/class.writeexcel_biffwriter.inc.php b/gosa-core/include/php_writeexcel/class.writeexcel_biffwriter.inc.php
+++ /dev/null
@@ -1,208 +0,0 @@
-<?php
-
-/*
- * Copyleft 2002 Johann Hanne
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * This is the Spreadsheet::WriteExcel Perl package ported to PHP
- * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
- */
-
-class writeexcel_biffwriter {
- var $byte_order;
- var $BIFF_version;
- var $_byte_order;
- var $_data;
- var $_datasize;
- var $_limit;
-
- /*
- * Constructor
- */
- function writeexcel_biffwriter() {
-
- $this->byte_order = '';
- $this->BIFF_version = 0x0500;
- $this->_byte_order = '';
- $this->_data = false;
- $this->_datasize = 0;
- $this->_limit = 2080;
-
- $this->_set_byte_order();
- }
-
- /*
- * Determine the byte order and store it as class data to avoid
- * recalculating it for each call to new().
- */
- function _set_byte_order() {
- $this->byteorder=0;
- // Check if "pack" gives the required IEEE 64bit float
- $teststr = pack("d", 1.2345);
- $number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
-
- if ($number == $teststr) {
- $this->byte_order = 0; // Little Endian
- } elseif ($number == strrev($teststr)) {
- $this->byte_order = 1; // Big Endian
- } else {
- // Give up
- trigger_error("Required floating point format not supported ".
- "on this platform. See the portability section ".
- "of the documentation.", E_USER_ERROR);
- }
-
- $this->_byte_order = $this->byte_order;
- }
-
- /*
- * General storage function
- */
- function _prepend($data) {
-
- if (func_num_args()>1) {
- trigger_error("writeexcel_biffwriter::_prepend() ".
- "called with more than one argument", E_USER_ERROR);
- }
-
- if ($this->_debug) {
- print "*** writeexcel_biffwriter::_prepend() called:";
- for ($c=0;$c<strlen($data);$c++) {
- if ($c%16==0) {
- print "\n";
- }
- printf("%02X ", ord($data[$c]));
- }
- print "\n";
- }
-
- if (strlen($data) > $this->_limit) {
- $data = $this->_add_continue($data);
- }
-
- $this->_data = $data . $this->_data;
- $this->_datasize += strlen($data);
- }
-
- /*
- * General storage function
- */
- function _append($data) {
-
- if (func_num_args()>1) {
- trigger_error("writeexcel_biffwriter::_append() ".
- "called with more than one argument", E_USER_ERROR);
- }
-
- if ($this->_debug) {
- print "*** writeexcel_biffwriter::_append() called:";
- for ($c=0;$c<strlen($data);$c++) {
- if ($c%16==0) {
- print "\n";
- }
- printf("%02X ", ord($data[$c]));
- }
- print "\n";
- }
-
- if (strlen($data) > $this->_limit) {
- $data = $this->_add_continue($data);
- }
-
- $this->_data = $this->_data . $data;
- $this->_datasize += strlen($data);
- }
-
- /*
- * Writes Excel BOF record to indicate the beginning of a stream or
- * sub-stream in the BIFF file.
- *
- * $type = 0x0005, Workbook
- * $type = 0x0010, Worksheet
- */
- function _store_bof($type) {
-
- $record = 0x0809; // Record identifier
- $length = 0x0008; // Number of bytes to follow
-
- $version = $this->BIFF_version;
-
- // According to the SDK $build and $year should be set to zero.
- // However, this throws a warning in Excel 5. So, use these
- // magic numbers.
- $build = 0x096C;
- $year = 0x07C9;
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvv", $version, $type, $build, $year);
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Writes Excel EOF record to indicate the end of a BIFF stream.
- */
- function _store_eof() {
-
- $record = 0x000A; // Record identifier
- $length = 0x0000; // Number of bytes to follow
-
- $header = pack("vv", $record, $length);
-
- $this->_append($header);
- }
-
- /*
- * Excel limits the size of BIFF records. In Excel 5 the limit is 2084
- * bytes. In Excel 97 the limit is 8228 bytes. Records that are longer
- * than these limits must be split up into CONTINUE blocks.
- *
- * This function take a long BIFF record and inserts CONTINUE records as
- * necessary.
- */
- function _add_continue($data) {
-
- $limit = $this->_limit;
- $record = 0x003C; // Record identifier
-
- // The first 2080/8224 bytes remain intact. However, we have to change
- // the length field of the record.
- $tmp = substr($data, 0, $limit);
- $data = substr($data, $limit);
- $tmp = substr($tmp, 0, 2) . pack ("v", $limit-4) . substr($tmp, 4);
-
- // Strip out chunks of 2080/8224 bytes +4 for the header.
- while (strlen($data) > $limit) {
- $header = pack("vv", $record, $limit);
- $tmp .= $header;
- $tmp .= substr($data, 0, $limit);
- $data = substr($data, $limit);
- }
-
- // Mop up the last of the data
- $header = pack("vv", $record, strlen($data));
- $tmp .= $header;
- $tmp .= $data;
-
- return $tmp;
- }
-
-}
-
-?>
diff --git a/gosa-core/include/php_writeexcel/class.writeexcel_format.inc.php b/gosa-core/include/php_writeexcel/class.writeexcel_format.inc.php
+++ /dev/null
@@ -1,702 +0,0 @@
-<?php
-
-/*
- * Copyleft 2002 Johann Hanne
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * This is the Spreadsheet::WriteExcel Perl package ported to PHP
- * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
- */
-
-class writeexcel_format {
-
- var $_xf_index;
- var $_font_index;
- var $_font;
- var $_size;
- var $_bold;
- var $_italic;
- var $_color;
- var $_underline;
- var $_font_strikeout;
- var $_font_outline;
- var $_font_shadow;
- var $_font_script;
- var $_font_family;
- var $_font_charset;
- var $_num_format;
- var $_hidden;
- var $_locked;
- var $_text_h_align;
- var $_text_wrap;
- var $_text_v_align;
- var $_text_justlast;
- var $_rotation;
- var $_fg_color;
- var $_bg_color;
- var $_pattern;
- var $_bottom;
- var $_top;
- var $_left;
- var $_right;
- var $_bottom_color;
- var $_top_color;
- var $_left_color;
- var $_right_color;
-
- /*
- * Constructor
- */
- function writeexcel_format() {
- $_=func_get_args();
-
- $this->_xf_index = (sizeof($_)>0) ? array_shift($_) : 0;
-
- $this->_font_index = 0;
- $this->_font = 'Arial';
- $this->_size = 10;
- $this->_bold = 0x0190;
- $this->_italic = 0;
- $this->_color = 0x7FFF;
- $this->_underline = 0;
- $this->_font_strikeout = 0;
- $this->_font_outline = 0;
- $this->_font_shadow = 0;
- $this->_font_script = 0;
- $this->_font_family = 0;
- $this->_font_charset = 0;
-
- $this->_num_format = 0;
-
- $this->_hidden = 0;
- $this->_locked = 1;
-
- $this->_text_h_align = 0;
- $this->_text_wrap = 0;
- $this->_text_v_align = 2;
- $this->_text_justlast = 0;
- $this->_rotation = 0;
-
- $this->_fg_color = 0x40;
- $this->_bg_color = 0x41;
-
- $this->_pattern = 0;
-
- $this->_bottom = 0;
- $this->_top = 0;
- $this->_left = 0;
- $this->_right = 0;
-
- $this->_bottom_color = 0x40;
- $this->_top_color = 0x40;
- $this->_left_color = 0x40;
- $this->_right_color = 0x40;
-
- // Set properties passed to writeexcel_workbook::addformat()
- if (sizeof($_)>0) {
- call_user_method_array('set_properties', $this, $_);
- }
- }
-
- /*
- * Copy the attributes of another writeexcel_format object.
- */
- function copy($other) {
- $xf = $this->_xf_index; // Backup XF index
-
- /* A better way to copy member vars, ... won't cause fatal errors in PHP5.
- The only thing i can understand is : For what is this function used,
- it is never used by any object, as I can see in the source code.
- ...
- */
- foreach(get_object_vars($other) as $var => $val){
- $this->$var = $val;
- }
-// $this = $other; // Copy properties
- $this->_xf_index = $xf; // Restore XF index
- }
-
- /*
- * Generate an Excel BIFF XF record.
- */
- function get_xf() {
-
- $_=func_get_args();
-
- // $record Record identifier
- // $length Number of bytes to follow
-
- // $ifnt Index to FONT record
- // $ifmt Index to FORMAT record
- // $style Style and other options
- // $align Alignment
- // $icv fg and bg pattern colors
- // $fill Fill and border line style
- // $border1 Border line style and color
- // $border2 Border color
-
- // Set the type of the XF record and some of the attributes.
- if ($_[0] == "style") {
- $style = 0xFFF5;
- } else {
- $style = $this->_locked;
- $style |= $this->_hidden << 1;
- }
-
- // Flags to indicate if attributes have been set.
- $atr_num = ($this->_num_format != 0) ? 1 : 0;
- $atr_fnt = ($this->_font_index != 0) ? 1 : 0;
- $atr_alc = $this->_text_wrap ? 1 : 0;
- $atr_bdr = ($this->_bottom ||
- $this->_top ||
- $this->_left ||
- $this->_right) ? 1 : 0;
- $atr_pat = ($this->_fg_color != 0x41 ||
- $this->_bg_color != 0x41 ||
- $this->_pattern != 0x00) ? 1 : 0;
- $atr_prot = 0;
-
- // Reset the default colors for the non-font properties
- if ($this->_fg_color == 0x7FFF) $this->_fg_color = 0x40;
- if ($this->_bg_color == 0x7FFF) $this->_bg_color = 0x41;
- if ($this->_bottom_color == 0x7FFF) $this->_bottom_color = 0x41;
- if ($this->_top_color == 0x7FFF) $this->_top_color = 0x41;
- if ($this->_left_color == 0x7FFF) $this->_left_color = 0x41;
- if ($this->_right_color == 0x7FFF) $this->_right_color = 0x41;
-
- // Zero the default border colour if the border has not been set.
- if ($this->_bottom == 0) {
- $this->_bottom_color = 0;
- }
- if ($this->_top == 0) {
- $this->_top_color = 0;
- }
- if ($this->_right == 0) {
- $this->_right_color = 0;
- }
- if ($this->_left == 0) {
- $this->_left_color = 0;
- }
-
- // The following 2 logical statements take care of special cases in
- // relation to cell colors and patterns:
- // 1. For a solid fill (_pattern == 1) Excel reverses the role of
- // foreground and background colors
- // 2. If the user specifies a foreground or background color
- // without a pattern they probably wanted a solid fill, so we
- // fill in the defaults.
- if ($this->_pattern <= 0x01 &&
- $this->_bg_color != 0x41 &&
- $this->_fg_color == 0x40 )
- {
- $this->_fg_color = $this->_bg_color;
- $this->_bg_color = 0x40;
- $this->_pattern = 1;
- }
-
- if ($this->_pattern <= 0x01 &&
- $this->_bg_color == 0x41 &&
- $this->_fg_color != 0x40 )
- {
- $this->_bg_color = 0x40;
- $this->_pattern = 1;
- }
-
- $record = 0x00E0;
- $length = 0x0010;
-
- $ifnt = $this->_font_index;
- $ifmt = $this->_num_format;
-
- $align = $this->_text_h_align;
- $align |= $this->_text_wrap << 3;
- $align |= $this->_text_v_align << 4;
- $align |= $this->_text_justlast << 7;
- $align |= $this->_rotation << 8;
- $align |= $atr_num << 10;
- $align |= $atr_fnt << 11;
- $align |= $atr_alc << 12;
- $align |= $atr_bdr << 13;
- $align |= $atr_pat << 14;
- $align |= $atr_prot << 15;
-
- $icv = $this->_fg_color;
- $icv |= $this->_bg_color << 7;
-
- $fill = $this->_pattern;
- $fill |= $this->_bottom << 6;
- $fill |= $this->_bottom_color << 9;
-
- $border1 = $this->_top;
- $border1 |= $this->_left << 3;
- $border1 |= $this->_right << 6;
- $border1 |= $this->_top_color << 9;
-
- $border2 = $this->_left_color;
- $border2 |= $this->_right_color << 7;
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align,
- $icv, $fill,
- $border1, $border2);
-
- return($header . $data);
- }
-
- /*
- * Generate an Excel BIFF FONT record.
- */
- function get_font() {
-
- // $record Record identifier
- // $length Record length
-
- // $dyHeight Height of font (1/20 of a point)
- // $grbit Font attributes
- // $icv Index to color palette
- // $bls Bold style
- // $sss Superscript/subscript
- // $uls Underline
- // $bFamily Font family
- // $bCharSet Character set
- // $reserved Reserved
- // $cch Length of font name
- // $rgch Font name
-
- $dyHeight = $this->_size * 20;
- $icv = $this->_color;
- $bls = $this->_bold;
- $sss = $this->_font_script;
- $uls = $this->_underline;
- $bFamily = $this->_font_family;
- $bCharSet = $this->_font_charset;
- $rgch = $this->_font;
-
- $cch = strlen($rgch);
- $record = 0x31;
- $length = 0x0F + $cch;
- $reserved = 0x00;
-
- $grbit = 0x00;
-
- if ($this->_italic) {
- $grbit |= 0x02;
- }
-
- if ($this->_font_strikeout) {
- $grbit |= 0x08;
- }
-
- if ($this->_font_outline) {
- $grbit |= 0x10;
- }
-
- if ($this->_font_shadow) {
- $grbit |= 0x20;
- }
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls,
- $sss, $uls, $bFamily,
- $bCharSet, $reserved, $cch);
-
- return($header . $data . $this->_font);
- }
-
- /*
- * Returns a unique hash key for a font.
- * Used by writeexcel_workbook::_store_all_fonts()
- */
- function get_font_key() {
-
- # The following elements are arranged to increase the probability of
- # generating a unique key. Elements that hold a large range of numbers
- # eg. _color are placed between two binary elements such as _italic
- #
- $key = $this->_font.$this->_size.
- $this->_font_script.$this->_underline.
- $this->_font_strikeout.$this->_bold.$this->_font_outline.
- $this->_font_family.$this->_font_charset.
- $this->_font_shadow.$this->_color.$this->_italic;
-
- $key = preg_replace('/ /', '_', $key); # Convert the key to a single word
-
- return $key;
- }
-
- /*
- * Returns the used by Worksheet->_XF()
- */
- function get_xf_index() {
- return $this->_xf_index;
- }
-
- /*
- * Used in conjunction with the set_xxx_color methods to convert a color
- * string into a number. Color range is 0..63 but we will restrict it
- * to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15.
- */
- function _get_color($color=false) {
-
- $colors = array(
- 'aqua' => 0x0F,
- 'cyan' => 0x0F,
- 'black' => 0x08,
- 'blue' => 0x0C,
- 'brown' => 0x10,
- 'magenta' => 0x0E,
- 'fuchsia' => 0x0E,
- 'gray' => 0x17,
- 'grey' => 0x17,
- 'green' => 0x11,
- 'lime' => 0x0B,
- 'navy' => 0x12,
- 'orange' => 0x35,
- 'purple' => 0x14,
- 'red' => 0x0A,
- 'silver' => 0x16,
- 'white' => 0x09,
- 'yellow' => 0x0D
- );
-
- // Return the default color, 0x7FFF, if undef,
- if ($color===false) {
- return 0x7FFF;
- }
-
- // or the color string converted to an integer,
- if (isset($colors[strtolower($color)])) {
- return $colors[strtolower($color)];
- }
-
- // or the default color if string is unrecognised,
- if (preg_match('/\D/', $color)) {
- return 0x7FFF;
- }
-
- // or an index < 8 mapped into the correct range,
- if ($color<8) {
- return $color + 8;
- }
-
- // or the default color if arg is outside range,
- if ($color>63) {
- return 0x7FFF;
- }
-
- // or an integer in the valid range
- return $color;
- }
-
- /*
- * Set cell alignment.
- */
- function set_align($location) {
-
- // Ignore numbers
- if (preg_match('/\d/', $location)) {
- return;
- }
-
- $location = strtolower($location);
-
- switch ($location) {
-
- case 'left':
- $this->set_text_h_align(1);
- break;
-
- case 'centre':
- case 'center':
- $this->set_text_h_align(2);
- break;
-
- case 'right':
- $this->set_text_h_align(3);
- break;
-
- case 'fill':
- $this->set_text_h_align(4);
- break;
-
- case 'justify':
- $this->set_text_h_align(5);
- break;
-
- case 'merge':
- $this->set_text_h_align(6);
- break;
-
- case 'equal_space':
- $this->set_text_h_align(7);
- break;
-
- case 'top':
- $this->set_text_v_align(0);
- break;
-
- case 'vcentre':
- case 'vcenter':
- $this->set_text_v_align(1);
- break;
- break;
-
- case 'bottom':
- $this->set_text_v_align(2);
- break;
-
- case 'vjustify':
- $this->set_text_v_align(3);
- break;
-
- case 'vequal_space':
- $this->set_text_v_align(4);
- break;
- }
- }
-
- /*
- * Set vertical cell alignment. This is required by the set_properties()
- * method to differentiate between the vertical and horizontal properties.
- */
- function set_valign($location) {
- $this->set_align($location);
- }
-
- /*
- * This is an alias for the unintuitive set_align('merge')
- */
- function set_merge() {
- $this->set_text_h_align(6);
- }
-
- /*
- * Bold has a range 0x64..0x3E8.
- * 0x190 is normal. 0x2BC is bold.
- */
- function set_bold($weight=1) {
-
- if ($weight == 1) {
- // Bold text
- $weight = 0x2BC;
- }
-
- if ($weight == 0) {
- // Normal text
- $weight = 0x190;
- }
-
- if ($weight < 0x064) {
- // Lower bound
- $weight = 0x190;
- }
-
- if ($weight > 0x3E8) {
- // Upper bound
- $weight = 0x190;
- }
-
- $this->_bold = $weight;
- }
-
- /*
- * Set all cell borders (bottom, top, left, right) to the same style
- */
- function set_border($style) {
- $this->set_bottom($style);
- $this->set_top($style);
- $this->set_left($style);
- $this->set_right($style);
- }
-
- /*
- * Set all cell borders (bottom, top, left, right) to the same color
- */
- function set_border_color($color) {
- $this->set_bottom_color($color);
- $this->set_top_color($color);
- $this->set_left_color($color);
- $this->set_right_color($color);
- }
-
- /*
- * Convert hashes of properties to method calls.
- */
- function set_properties() {
-
- $_=func_get_args();
-
- $properties=array();
- foreach($_ as $props) {
- if (is_array($props)) {
- $properties=array_merge($properties, $props);
- } else {
- $properties[]=$props;
- }
- }
-
- foreach ($properties as $key=>$value) {
-
- // Strip leading "-" from Tk style properties eg. -color => 'red'.
- $key = preg_replace('/^-/', '', $key);
-
- /* Make sure method names are alphanumeric characters only, in
- case tainted data is passed to the eval(). */
- if (preg_match('/\W/', $key)) {
- trigger_error("Unknown property: $key.",
- E_USER_ERROR);
- }
-
- /* Evaling all $values as a strings gets around the problem of
- some numerical format strings being evaluated as numbers, for
- example "00000" for a zip code. */
- if (is_int($key)) {
- eval("\$this->set_$value();");
- } else {
- eval("\$this->set_$key('$value');");
- }
-
- }
- }
-
- function set_font($font) {
- $this->_font=$font;
- }
-
- function set_size($size) {
- $this->_size=$size;
- }
-
- function set_italic($italic=1) {
- $this->_italic=$italic;
- }
-
- function set_color($color) {
- $this->_color=$this->_get_color($color);
- }
-
- function set_underline($underline=1) {
- $this->_underline=$underline;
- }
-
- function set_font_strikeout($font_strikeout=1) {
- $this->_font_strikeout=$font_strikeout;
- }
-
- function set_font_outline($font_outline=1) {
- $this->_font_outline=$font_outline;
- }
-
- function set_font_shadow($font_shadow=1) {
- $this->_font_shadow=$font_shadow;
- }
-
- function set_font_script($font_script=1) {
- $this->_font_script=$font_script;
- }
-
- /* Undocumented */
- function set_font_family($font_family=1) {
- $this->_font_family=$font_family;
- }
-
- /* Undocumented */
- function set_font_charset($font_charset=1) {
- $this->_font_charset=$font_charset;
- }
-
- function set_num_format($num_format=1) {
- $this->_num_format=$num_format;
- }
-
- function set_hidden($hidden=1) {
- $this->_hidden=$hidden;
- }
-
- function set_locked($locked=1) {
- $this->_locked=$locked;
- }
-
- function set_text_h_align($align) {
- $this->_text_h_align=$align;
- }
-
- function set_text_wrap($wrap=1) {
- $this->_text_wrap=$wrap;
- }
-
- function set_text_v_align($align) {
- $this->_text_v_align=$align;
- }
-
- function set_text_justlast($text_justlast=1) {
- $this->_text_justlast=$text_justlast;
- }
-
- function set_rotation($rotation=1) {
- $this->_rotation=$rotation;
- }
-
- function set_fg_color($color) {
- $this->_fg_color=$this->_get_color($color);
- }
-
- function set_bg_color($color) {
- $this->_bg_color=$this->_get_color($color);
- }
-
- function set_pattern($pattern=1) {
- $this->_pattern=$pattern;
- }
-
- function set_bottom($bottom=1) {
- $this->_bottom=$bottom;
- }
-
- function set_top($top=1) {
- $this->_top=$top;
- }
-
- function set_left($left=1) {
- $this->_left=$left;
- }
-
- function set_right($right=1) {
- $this->_right=$right;
- }
-
- function set_bottom_color($color) {
- $this->_bottom_color=$this->_get_color($color);
- }
-
- function set_top_color($color) {
- $this->_top_color=$this->_get_color($color);
- }
-
- function set_left_color($color) {
- $this->_left_color=$this->_get_color($color);
- }
-
- function set_right_color($color) {
- $this->_right_color=$this->_get_color($color);
- }
-
-}
-
-?>
diff --git a/gosa-core/include/php_writeexcel/class.writeexcel_formula.inc.php b/gosa-core/include/php_writeexcel/class.writeexcel_formula.inc.php
+++ /dev/null
@@ -1,1413 +0,0 @@
-<?php
-
-/*
- * Copyleft 2002 Johann Hanne
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* This file contains source from the PEAR::Spreadsheet class Parser.php file version 0.4 .
- The raiseError was replaced by triggerError function.
- The PEAR::isError was imported to keep compatibility to PEAR::Spreadsheet class
-
- Imported and adapted by Andreas Brodowski 2003 (andreas.brodowski@oscar-gmbh.com).
-
- There should be no license rights in question because the Parser.php from PEAR class is
- published under GNU License the same way like this class.
-
- Changes: 03/08/27 Added SPREADSHEET_EXCEL_WRITER_SCOLON for arg seperation in excel functions
- */
-
-/*
- * This is the Spreadsheet::WriteExcel Perl package ported to PHP
- * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
- */
-
-define('SPREADSHEET_EXCEL_WRITER_ADD',"+");\r // @const SPREADSHEET_EXCEL_WRITER_ADD token identifier for character "+"\r
-define('SPREADSHEET_EXCEL_WRITER_SUB',"-");\r // @const SPREADSHEET_EXCEL_WRITER_SUB token identifier for character "-"\r
-define('SPREADSHEET_EXCEL_WRITER_MUL',"*");\r // @const SPREADSHEET_EXCEL_WRITER_MUL token identifier for character "*"\r
-define('SPREADSHEET_EXCEL_WRITER_DIV',"/");\r // @const SPREADSHEET_EXCEL_WRITER_DIV token identifier for character "/"\r
-define('SPREADSHEET_EXCEL_WRITER_OPEN',"(");\r // @const SPREADSHEET_EXCEL_WRITER_OPEN token identifier for character "("\r
-define('SPREADSHEET_EXCEL_WRITER_CLOSE',")"); \r // @const SPREADSHEET_EXCEL_WRITER_CLOSE token identifier for character ")"\r
-define('SPREADSHEET_EXCEL_WRITER_COMA',",");\r // @const SPREADSHEET_EXCEL_WRITER_COMA token identifier for character ","\r
-define('SPREADSHEET_EXCEL_WRITER_SCOLON',";"); \r// @const SPREADSHEET_EXCEL_WRITER_SCOLON token identifier for character ";"\r
-define('SPREADSHEET_EXCEL_WRITER_GT',">");\r // @const SPREADSHEET_EXCEL_WRITER_GT token identifier for character ">"\r
-define('SPREADSHEET_EXCEL_WRITER_LT',"<");\r // @const SPREADSHEET_EXCEL_WRITER_LT token identifier for character "<"\r
-define('SPREADSHEET_EXCEL_WRITER_LE',"<=");\r // @const SPREADSHEET_EXCEL_WRITER_LE token identifier for character "<="\r
-define('SPREADSHEET_EXCEL_WRITER_GE',">=");\r // @const SPREADSHEET_EXCEL_WRITER_GE token identifier for character ">="\r
-define('SPREADSHEET_EXCEL_WRITER_EQ',"=");\r // @const SPREADSHEET_EXCEL_WRITER_EQ token identifier for character "="\r
-define('SPREADSHEET_EXCEL_WRITER_NE',"<>");\r // @const SPREADSHEET_EXCEL_WRITER_NE token identifier for character "<>"\r
-\r
-
-class writeexcel_formula {
-
-###############################################################################
-#
-# Class data.
-#
-var $parser;
-var $ptg;
-var $_functions;
-var $_current_char;
-var $_current_token;
-var $_lookahead;
-var $_debug;
-var $_byte_order;
-var $_volatile;
-var $_workbook;
-var $_ext_sheets;
-var $_formula;
-
-###############################################################################
-#
-# new()
-#
-# Constructor
-#
-function writeexcel_formula($byte_order) {
-
- $this->parser = false;
- $this->ptg = array();
- $this->_functions = array();
- $this->_debug = 0;
- $this->_byte_order = $byte_order;
- $this->_volatile = 0;
- $this->_workbook = "";
- $this->_ext_sheets = array();
- $this->_current_token = '';
- $this->_lookahead = '';
- $this->_current_char = 0;
- $this->_formula = '';
-}
-
-###############################################################################
-#
-# _init_parser()
-#
-# There is a small overhead involved in generating the parser. Therefore, the
-# initialisation is delayed until a formula is required. TODO: use a pre-
-# compiled header.
-#
-function _init_parser() {
-
- $this->_initializeHashes();
-
-
- if ($this->_debug) {
- print "Init_parser.\n\n";
- }
-}
-
-###############################################################################
-#
-# parse_formula()
-#
-# This is the only public method. It takes a textual description of a formula
-# and returns a RPN encoded byte string.
-#
-function parse_formula() {
-
- $_=func_get_args();
-
- # Initialise the parser if this is the first call
- if ($this->parser===false) {
- $this->_init_parser();
- }
-
- $formula = array_shift($_);
- //$str;
- //$tokens;
-
- if ($this->_debug) {
- print "$formula\n";
- }
-
- # Build the parse tree for the formula
-
- $this->_formula = $formula;
- $this->_current_char = 0;
- $this->_lookahead = $this->_formula{1};
- $this->_advance($formula);
- $parsetree = $this->_condition();
-
- $str = $this->toReversePolish($parsetree);
-
- return $str;
-}
-
-function set_ext_sheet($key, $value) {
-
- $this->_ext_sheets->$key = $value;
-}
-
-function isError($data) {
- return (bool)(is_object($data) &&
- (get_class($data) == 'pear_error' ||
- is_subclass_of($data, 'pear_error')));
-}
-\r
-/**\r
-* Class for parsing Excel formulas\r
-*\r
-* @author Xavier Noguer <xnoguer@rezebra.com>\r
-* @category FileFormats\r
-* @package Spreadsheet_Excel_Writer\r
-*/\r
-\r
- \r
-/**\r
-* Initialize the ptg and function hashes. \r
-*\r
-* @access private\r
-*/\r
-function _initializeHashes()\r {\r
- // The Excel ptg indices\r
- $this->ptg = array(\r
- 'ptgExp' => 0x01,\r 'ptgTbl' => 0x02,\r 'ptgAdd' => 0x03,\r 'ptgSub' => 0x04,\r
- 'ptgMul' => 0x05,\r 'ptgDiv' => 0x06,\r 'ptgPower' => 0x07, 'ptgConcat' => 0x08,\r
- 'ptgLT' => 0x09,\r 'ptgLE' => 0x0A,\r 'ptgEQ' => 0x0B,\r 'ptgGE' => 0x0C,\r
- 'ptgGT' => 0x0D,\r 'ptgNE' => 0x0E,\r 'ptgIsect' => 0x0F,\r 'ptgUnion' => 0x10,\r
- 'ptgRange' => 0x11,\r 'ptgUplus' => 0x12,\r 'ptgUminus' => 0x13,\r 'ptgPercent' => 0x14,\r
- 'ptgParen' => 0x15,\r 'ptgMissArg' => 0x16,\r 'ptgStr' => 0x17,\r 'ptgAttr' => 0x19,\r
- 'ptgSheet' => 0x1A,\r 'ptgEndSheet' => 0x1B,\r 'ptgErr' => 0x1C,\r 'ptgBool' => 0x1D,\r
- 'ptgInt' => 0x1E,\r 'ptgNum' => 0x1F,\r 'ptgArray' => 0x20,\r 'ptgFunc' => 0x21,\r
- 'ptgFuncVar' => 0x22,\r 'ptgName' => 0x23,\r 'ptgRef' => 0x24,\r 'ptgArea' => 0x25,\r
- 'ptgMemArea' => 0x26,\r 'ptgMemErr' => 0x27,\r 'ptgMemNoMem' => 0x28,\r 'ptgMemFunc' => 0x29,\r
- 'ptgRefErr' => 0x2A,\r 'ptgAreaErr' => 0x2B,\r 'ptgRefN' => 0x2C,\r 'ptgAreaN' => 0x2D,\r
- 'ptgMemAreaN' => 0x2E,\r 'ptgMemNoMemN' => 0x2F,\r 'ptgNameX' => 0x39,\r 'ptgRef3d' => 0x3A,
-\r 'ptgArea3d' => 0x3B,\r 'ptgRefErr3d' => 0x3C,\r 'ptgAreaErr3d' => 0x3D,\r 'ptgArrayV' => 0x40,\r
- 'ptgFuncV' => 0x41,\r 'ptgFuncVarV' => 0x42,\r 'ptgNameV' => 0x43,\r 'ptgRefV' => 0x44,\r
- 'ptgAreaV' => 0x45,\r 'ptgMemAreaV' => 0x46,\r 'ptgMemErrV' => 0x47,\r 'ptgMemNoMemV' => 0x48,\r
- 'ptgMemFuncV' => 0x49,\r 'ptgRefErrV' => 0x4A,\r 'ptgAreaErrV' => 0x4B,\r 'ptgRefNV' => 0x4C,\r
- 'ptgAreaNV' => 0x4D,\r 'ptgMemAreaNV' => 0x4E,\r 'ptgMemNoMemN' => 0x4F,\r 'ptgFuncCEV' => 0x58,\r
- 'ptgNameXV' => 0x59,\r 'ptgRef3dV' => 0x5A,\r 'ptgArea3dV' => 0x5B, 'ptgRefErr3dV' => 0x5C,\r
- 'ptgAreaErr3d' => 0x5D,\r 'ptgArrayA' => 0x60,\r 'ptgFuncA' => 0x61,\r 'ptgFuncVarA' => 0x62,\r
- 'ptgNameA' => 0x63, 'ptgRefA' => 0x64,\r 'ptgAreaA' => 0x65,\r 'ptgMemAreaA' => 0x66,\r
- 'ptgMemErrA' => 0x67,\r 'ptgMemNoMemA' => 0x68,\r 'ptgMemFuncA' => 0x69,\r 'ptgRefErrA' => 0x6A,\r
- 'ptgAreaErrA' => 0x6B,\r 'ptgRefNA' => 0x6C,\r 'ptgAreaNA' => 0x6D,\r 'ptgMemAreaNA' => 0x6E,\r
- 'ptgMemNoMemN' => 0x6F,\r 'ptgFuncCEA' => 0x78,\r 'ptgNameXA' => 0x79,\r 'ptgRef3dA' => 0x7A,\r
- 'ptgArea3dA' => 0x7B,\r 'ptgRefErr3dA' => 0x7C,\r 'ptgAreaErr3d' => 0x7D\r
- );\r
- \r
- // Thanks to Michael Meeks and Gnumeric for the initial arg values.\r
- //\r
- // The following hash was generated by "function_locale.pl" in the distro.\r
- // Refer to function_locale.pl for non-English function names.\r
- //\r
- // The array elements are as follow:\r
- // ptg: The Excel function ptg code.\r
- // args: The number of arguments that the function takes:\r
- // >=0 is a fixed number of arguments.\r
- // -1 is a variable number of arguments.\r
- // class: The reference, value or array class of the function args.\r
- // vol: The function is volatile.\r
- //\r
- $this->_functions = array(\r
- // function ptg args class vol\r
- 'COUNT' => array( 0, -1, 0, 0 ),\r
- 'IF' => array( 1, -1, 1, 0 ),\r
- 'ISNA' => array( 2, 1, 1, 0 ),\r
- 'ISERROR' => array( 3, 1, 1, 0 ),\r
- 'SUM' => array( 4, -1, 0, 0 ),\r
- 'AVERAGE' => array( 5, -1, 0, 0 ),\r
- 'MIN' => array( 6, -1, 0, 0 ),\r
- 'MAX' => array( 7, -1, 0, 0 ),\r
- 'ROW' => array( 8, -1, 0, 0 ),\r
- 'COLUMN' => array( 9, -1, 0, 0 ),\r
- 'NA' => array( 10, 0, 0, 0 ),\r
- 'NPV' => array( 11, -1, 1, 0 ),\r
- 'STDEV' => array( 12, -1, 0, 0 ),\r
- 'DOLLAR' => array( 13, -1, 1, 0 ),\r
- 'FIXED' => array( 14, -1, 1, 0 ),\r
- 'SIN' => array( 15, 1, 1, 0 ),\r
- 'COS' => array( 16, 1, 1, 0 ),\r
- 'TAN' => array( 17, 1, 1, 0 ),\r
- 'ATAN' => array( 18, 1, 1, 0 ),\r
- 'PI' => array( 19, 0, 1, 0 ),\r
- 'SQRT' => array( 20, 1, 1, 0 ),\r
- 'EXP' => array( 21, 1, 1, 0 ),\r
- 'LN' => array( 22, 1, 1, 0 ),\r
- 'LOG10' => array( 23, 1, 1, 0 ),\r
- 'ABS' => array( 24, 1, 1, 0 ),\r
- 'INT' => array( 25, 1, 1, 0 ),\r
- 'SIGN' => array( 26, 1, 1, 0 ),\r
- 'ROUND' => array( 27, 2, 1, 0 ),\r
- 'LOOKUP' => array( 28, -1, 0, 0 ),\r
- 'INDEX' => array( 29, -1, 0, 1 ),\r
- 'REPT' => array( 30, 2, 1, 0 ),\r
- 'MID' => array( 31, 3, 1, 0 ),\r
- 'LEN' => array( 32, 1, 1, 0 ),\r
- 'VALUE' => array( 33, 1, 1, 0 ),\r
- 'TRUE' => array( 34, 0, 1, 0 ),\r
- 'FALSE' => array( 35, 0, 1, 0 ),\r
- 'AND' => array( 36, -1, 0, 0 ),\r
- 'OR' => array( 37, -1, 0, 0 ),\r
- 'NOT' => array( 38, 1, 1, 0 ),\r
- 'MOD' => array( 39, 2, 1, 0 ),\r
- 'DCOUNT' => array( 40, 3, 0, 0 ),\r
- 'DSUM' => array( 41, 3, 0, 0 ),\r
- 'DAVERAGE' => array( 42, 3, 0, 0 ),\r
- 'DMIN' => array( 43, 3, 0, 0 ),\r
- 'DMAX' => array( 44, 3, 0, 0 ),\r
- 'DSTDEV' => array( 45, 3, 0, 0 ),\r
- 'VAR' => array( 46, -1, 0, 0 ),\r
- 'DVAR' => array( 47, 3, 0, 0 ),\r
- 'TEXT' => array( 48, 2, 1, 0 ),\r
- 'LINEST' => array( 49, -1, 0, 0 ),\r
- 'TREND' => array( 50, -1, 0, 0 ),\r
- 'LOGEST' => array( 51, -1, 0, 0 ),\r
- 'GROWTH' => array( 52, -1, 0, 0 ),\r
- 'PV' => array( 56, -1, 1, 0 ),\r
- 'FV' => array( 57, -1, 1, 0 ),\r
- 'NPER' => array( 58, -1, 1, 0 ),\r
- 'PMT' => array( 59, -1, 1, 0 ),\r
- 'RATE' => array( 60, -1, 1, 0 ),\r
- 'MIRR' => array( 61, 3, 0, 0 ),\r
- 'IRR' => array( 62, -1, 0, 0 ),\r
- 'RAND' => array( 63, 0, 1, 1 ),\r
- 'MATCH' => array( 64, -1, 0, 0 ),\r
- 'DATE' => array( 65, 3, 1, 0 ),\r
- 'TIME' => array( 66, 3, 1, 0 ),\r
- 'DAY' => array( 67, 1, 1, 0 ),\r
- 'MONTH' => array( 68, 1, 1, 0 ),\r
- 'YEAR' => array( 69, 1, 1, 0 ),\r
- 'WEEKDAY' => array( 70, -1, 1, 0 ),\r
- 'HOUR' => array( 71, 1, 1, 0 ),\r
- 'MINUTE' => array( 72, 1, 1, 0 ),\r
- 'SECOND' => array( 73, 1, 1, 0 ),\r
- 'NOW' => array( 74, 0, 1, 1 ),\r
- 'AREAS' => array( 75, 1, 0, 1 ),\r
- 'ROWS' => array( 76, 1, 0, 1 ),\r
- 'COLUMNS' => array( 77, 1, 0, 1 ),\r
- 'OFFSET' => array( 78, -1, 0, 1 ),\r
- 'SEARCH' => array( 82, -1, 1, 0 ),\r
- 'TRANSPOSE' => array( 83, 1, 1, 0 ),\r
- 'TYPE' => array( 86, 1, 1, 0 ),\r
- 'ATAN2' => array( 97, 2, 1, 0 ),\r
- 'ASIN' => array( 98, 1, 1, 0 ),\r
- 'ACOS' => array( 99, 1, 1, 0 ),\r
- 'CHOOSE' => array( 100, -1, 1, 0 ),\r
- 'HLOOKUP' => array( 101, -1, 0, 0 ),\r
- 'VLOOKUP' => array( 102, -1, 0, 0 ),\r
- 'ISREF' => array( 105, 1, 0, 0 ),\r
- 'LOG' => array( 109, -1, 1, 0 ),\r
- 'CHAR' => array( 111, 1, 1, 0 ),\r
- 'LOWER' => array( 112, 1, 1, 0 ),\r
- 'UPPER' => array( 113, 1, 1, 0 ),\r
- 'PROPER' => array( 114, 1, 1, 0 ),\r
- 'LEFT' => array( 115, -1, 1, 0 ),\r
- 'RIGHT' => array( 116, -1, 1, 0 ),\r
- 'EXACT' => array( 117, 2, 1, 0 ),\r
- 'TRIM' => array( 118, 1, 1, 0 ),\r
- 'REPLACE' => array( 119, 4, 1, 0 ),\r
- 'SUBSTITUTE' => array( 120, -1, 1, 0 ),\r
- 'CODE' => array( 121, 1, 1, 0 ),\r
- 'FIND' => array( 124, -1, 1, 0 ),\r
- 'CELL' => array( 125, -1, 0, 1 ),\r
- 'ISERR' => array( 126, 1, 1, 0 ),\r
- 'ISTEXT' => array( 127, 1, 1, 0 ),\r
- 'ISNUMBER' => array( 128, 1, 1, 0 ),\r
- 'ISBLANK' => array( 129, 1, 1, 0 ),\r
- 'T' => array( 130, 1, 0, 0 ),\r
- 'N' => array( 131, 1, 0, 0 ),\r
- 'DATEVALUE' => array( 140, 1, 1, 0 ),\r
- 'TIMEVALUE' => array( 141, 1, 1, 0 ),\r
- 'SLN' => array( 142, 3, 1, 0 ),\r
- 'SYD' => array( 143, 4, 1, 0 ),\r
- 'DDB' => array( 144, -1, 1, 0 ),\r
- 'INDIRECT' => array( 148, -1, 1, 1 ),\r
- 'CALL' => array( 150, -1, 1, 0 ),\r
- 'CLEAN' => array( 162, 1, 1, 0 ),\r
- 'MDETERM' => array( 163, 1, 2, 0 ),\r
- 'MINVERSE' => array( 164, 1, 2, 0 ),\r
- 'MMULT' => array( 165, 2, 2, 0 ),\r
- 'IPMT' => array( 167, -1, 1, 0 ),\r
- 'PPMT' => array( 168, -1, 1, 0 ),\r
- 'COUNTA' => array( 169, -1, 0, 0 ),\r
- 'PRODUCT' => array( 183, -1, 0, 0 ),\r
- 'FACT' => array( 184, 1, 1, 0 ),\r
- 'DPRODUCT' => array( 189, 3, 0, 0 ),\r
- 'ISNONTEXT' => array( 190, 1, 1, 0 ),\r
- 'STDEVP' => array( 193, -1, 0, 0 ),\r
- 'VARP' => array( 194, -1, 0, 0 ),\r
- 'DSTDEVP' => array( 195, 3, 0, 0 ),\r
- 'DVARP' => array( 196, 3, 0, 0 ),\r
- 'TRUNC' => array( 197, -1, 1, 0 ),\r
- 'ISLOGICAL' => array( 198, 1, 1, 0 ),\r
- 'DCOUNTA' => array( 199, 3, 0, 0 ),\r
- 'ROUNDUP' => array( 212, 2, 1, 0 ),\r
- 'ROUNDDOWN' => array( 213, 2, 1, 0 ),\r
- 'RANK' => array( 216, -1, 0, 0 ),\r
- 'ADDRESS' => array( 219, -1, 1, 0 ),\r
- 'DAYS360' => array( 220, -1, 1, 0 ),\r
- 'TODAY' => array( 221, 0, 1, 1 ),\r
- 'VDB' => array( 222, -1, 1, 0 ),\r
- 'MEDIAN' => array( 227, -1, 0, 0 ),\r
- 'SUMPRODUCT' => array( 228, -1, 2, 0 ),\r
- 'SINH' => array( 229, 1, 1, 0 ),\r
- 'COSH' => array( 230, 1, 1, 0 ),\r
- 'TANH' => array( 231, 1, 1, 0 ),\r
- 'ASINH' => array( 232, 1, 1, 0 ),\r
- 'ACOSH' => array( 233, 1, 1, 0 ),\r
- 'ATANH' => array( 234, 1, 1, 0 ),\r
- 'DGET' => array( 235, 3, 0, 0 ),\r
- 'INFO' => array( 244, 1, 1, 1 ),\r
- 'DB' => array( 247, -1, 1, 0 ),\r
- 'FREQUENCY' => array( 252, 2, 0, 0 ),\r
- 'ERROR.TYPE' => array( 261, 1, 1, 0 ),\r
- 'REGISTER.ID' => array( 267, -1, 1, 0 ),\r
- 'AVEDEV' => array( 269, -1, 0, 0 ),\r
- 'BETADIST' => array( 270, -1, 1, 0 ),\r
- 'GAMMALN' => array( 271, 1, 1, 0 ),\r
- 'BETAINV' => array( 272, -1, 1, 0 ),\r
- 'BINOMDIST' => array( 273, 4, 1, 0 ),\r
- 'CHIDIST' => array( 274, 2, 1, 0 ),\r
- 'CHIINV' => array( 275, 2, 1, 0 ),\r
- 'COMBIN' => array( 276, 2, 1, 0 ),\r
- 'CONFIDENCE' => array( 277, 3, 1, 0 ),\r
- 'CRITBINOM' => array( 278, 3, 1, 0 ),\r
- 'EVEN' => array( 279, 1, 1, 0 ),\r
- 'EXPONDIST' => array( 280, 3, 1, 0 ),\r
- 'FDIST' => array( 281, 3, 1, 0 ),\r
- 'FINV' => array( 282, 3, 1, 0 ),\r
- 'FISHER' => array( 283, 1, 1, 0 ),\r
- 'FISHERINV' => array( 284, 1, 1, 0 ),\r
- 'FLOOR' => array( 285, 2, 1, 0 ),\r
- 'GAMMADIST' => array( 286, 4, 1, 0 ),\r
- 'GAMMAINV' => array( 287, 3, 1, 0 ),\r
- 'CEILING' => array( 288, 2, 1, 0 ),\r
- 'HYPGEOMDIST' => array( 289, 4, 1, 0 ),\r
- 'LOGNORMDIST' => array( 290, 3, 1, 0 ),\r
- 'LOGINV' => array( 291, 3, 1, 0 ),\r
- 'NEGBINOMDIST' => array( 292, 3, 1, 0 ),\r
- 'NORMDIST' => array( 293, 4, 1, 0 ),\r
- 'NORMSDIST' => array( 294, 1, 1, 0 ),\r
- 'NORMINV' => array( 295, 3, 1, 0 ),\r
- 'NORMSINV' => array( 296, 1, 1, 0 ),\r
- 'STANDARDIZE' => array( 297, 3, 1, 0 ),\r
- 'ODD' => array( 298, 1, 1, 0 ),\r
- 'PERMUT' => array( 299, 2, 1, 0 ),\r
- 'POISSON' => array( 300, 3, 1, 0 ),\r
- 'TDIST' => array( 301, 3, 1, 0 ),\r
- 'WEIBULL' => array( 302, 4, 1, 0 ),\r
- 'SUMXMY2' => array( 303, 2, 2, 0 ),\r
- 'SUMX2MY2' => array( 304, 2, 2, 0 ),\r
- 'SUMX2PY2' => array( 305, 2, 2, 0 ),\r
- 'CHITEST' => array( 306, 2, 2, 0 ),\r
- 'CORREL' => array( 307, 2, 2, 0 ),\r
- 'COVAR' => array( 308, 2, 2, 0 ),\r
- 'FORECAST' => array( 309, 3, 2, 0 ),\r
- 'FTEST' => array( 310, 2, 2, 0 ),\r
- 'INTERCEPT' => array( 311, 2, 2, 0 ),\r
- 'PEARSON' => array( 312, 2, 2, 0 ),\r
- 'RSQ' => array( 313, 2, 2, 0 ),\r
- 'STEYX' => array( 314, 2, 2, 0 ),\r
- 'SLOPE' => array( 315, 2, 2, 0 ),\r
- 'TTEST' => array( 316, 4, 2, 0 ),\r
- 'PROB' => array( 317, -1, 2, 0 ),\r
- 'DEVSQ' => array( 318, -1, 0, 0 ),\r
- 'GEOMEAN' => array( 319, -1, 0, 0 ),\r
- 'HARMEAN' => array( 320, -1, 0, 0 ),\r
- 'SUMSQ' => array( 321, -1, 0, 0 ),\r
- 'KURT' => array( 322, -1, 0, 0 ),\r
- 'SKEW' => array( 323, -1, 0, 0 ),\r
- 'ZTEST' => array( 324, -1, 0, 0 ),\r
- 'LARGE' => array( 325, 2, 0, 0 ),\r
- 'SMALL' => array( 326, 2, 0, 0 ),\r
- 'QUARTILE' => array( 327, 2, 0, 0 ),\r
- 'PERCENTILE' => array( 328, 2, 0, 0 ),\r
- 'PERCENTRANK' => array( 329, -1, 0, 0 ),\r
- 'MODE' => array( 330, -1, 2, 0 ),\r
- 'TRIMMEAN' => array( 331, 2, 0, 0 ),\r
- 'TINV' => array( 332, 2, 1, 0 ),\r
- 'CONCATENATE' => array( 336, -1, 1, 0 ),\r
- 'POWER' => array( 337, 2, 1, 0 ),\r
- 'RADIANS' => array( 342, 1, 1, 0 ),\r
- 'DEGREES' => array( 343, 1, 1, 0 ),\r
- 'SUBTOTAL' => array( 344, -1, 0, 0 ),\r
- 'SUMIF' => array( 345, -1, 0, 0 ),\r
- 'COUNTIF' => array( 346, 2, 0, 0 ),\r
- 'COUNTBLANK' => array( 347, 1, 0, 0 ),\r
- 'ROMAN' => array( 354, -1, 1, 0 )\r
- );\r
-}\r
- \r
-/**\r
-* Convert a token to the proper ptg value.\r
-*\r
-* @access private\r
-* @param mixed $token The token to convert.\r
-* @return mixed the converted token on success. PEAR_Error if the token\r
-* is not recognized\r
-*/\r
-function _convert($token)\r {\r
- if (preg_match("/^\"[^\"]{0,255}\"$/", $token))\r {\r
- return $this->_convertString($token);\r
- }\r elseif (is_numeric($token))\r {\r
- return $this->_convertNumber($token);\r
- }\r
- // match references like A1 or $A$1
- \relseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/',$token))\r {
- return $this->_convertRef2d($token);\r
- }\r
- // match external references like Sheet1:Sheet2!A1\r
- elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-Ia-i]?[A-Za-z](\d+)$/",$token))\r {\r
- return $this->_convertRef3d($token);\r
- }\r
- // match ranges like A1:B2\r
- elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token))\r {\r
- return $this->_convertRange2d($token);\r
- }\r
- // match ranges like A1..B2\r
- elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token))\r {\r
- return $this->_convertRange2d($token);\r
- }\r
- // match external ranges like Sheet1:Sheet2!A1:B2\r
- elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/",$token))\r {\r
- return $this->_convertRange3d($token);\r
- }\r
- // match external ranges like 'Sheet1:Sheet2'!A1:B2\r
- elseif (preg_match("/^'[A-Za-z0-9_ ]+(\:[A-Za-z0-9_ ]+)?'\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/",$token))\r {\r
- return $this->_convertRange3d($token);\r
- }\r
- elseif (isset($this->ptg[$token])) // operators (including parentheses)\r {\r
- return pack("C", $this->ptg[$token]);\r
- }\r
- // commented so argument number can be processed correctly. See toReversePolish().\r
- /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token))\r
- {\r
- return($this->_convertFunction($token,$this->_func_args));\r
- }*/\r
- // if it's an argument, ignore the token (the argument remains)\r
- elseif ($token == 'arg')\r {\r
- return '';\r
- }\r
- // TODO: use real error codes\r
- trigger_error("Unknown token $token", E_USER_ERROR);\r
-}\r
- \r
-/**\r
-* Convert a number token to ptgInt or ptgNum\r
-*\r
-* @access private\r
-* @param mixed $num an integer or double for conversion to its ptg value\r
-*/\r
-function _convertNumber($num)\r {\r
-
- // Integer in the range 0..2**16-1\r
-
- if ((preg_match("/^\d+$/",$num)) and ($num <= 65535)) {\r
- return(pack("Cv", $this->ptg['ptgInt'], $num));\r
- }\r else { // A float\r
- if ($this->_byte_order) { // if it's Big Endian\r
- $num = strrev($num);\r
- }\r
- return pack("Cd", $this->ptg['ptgNum'], $num);\r
- }\r
-}\r
- \r
-/**\r
-* Convert a string token to ptgStr\r
-*\r
-* @access private\r
-* @param string $string A string for conversion to its ptg value\r
-*/\r
-function _convertString($string)\r {\r
- // chop away beggining and ending quotes\r
- $string = substr($string, 1, strlen($string) - 2);\r
- return pack("CC", $this->ptg['ptgStr'], strlen($string)).$string;\r
-}\r
-\r
-/**\r
-* Convert a function to a ptgFunc or ptgFuncVarV depending on the number of\r
-* args that it takes.\r
-*\r
-* @access private\r
-* @param string $token The name of the function for convertion to ptg value.\r
-* @param integer $num_args The number of arguments the function receives.\r
-* @return string The packed ptg for the function\r
-*/\r
-function _convertFunction($token, $num_args)\r {\r
- $args = $this->_functions[$token][1];\r
- $volatile = $this->_functions[$token][3];\r
- \r
- // Fixed number of args eg. TIME($i,$j,$k).\r
- if ($args >= 0) {\r
- return pack("Cv", $this->ptg['ptgFuncV'], $this->_functions[$token][0]);\r
- }\r
- // Variable number of args eg. SUM($i,$j,$k, ..).\r
- if ($args == -1) {\r
- return pack("CCv", $this->ptg['ptgFuncVarV'], $num_args, $this->_functions[$token][0]);\r
- }\r
-}\r
- \r
-/**\r
-* Convert an Excel range such as A1:D4 to a ptgRefV.\r
-*\r
-* @access private\r
-* @param string $range An Excel range in the A1:A2 or A1..A2 format.\r
-*/\r
-function _convertRange2d($range)\r {\r
- $class = 2; // as far as I know, this is magick.\r
- \r
- // Split the range into 2 cell refs\r
- if (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\:([A-Ia-i]?[A-Za-z])(\d+)$/",$range)) {\r
- list($cell1, $cell2) = split(':', $range);\r
- }\r elseif (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\.\.([A-Ia-i]?[A-Za-z])(\d+)$/",$range)) {\r
- list($cell1, $cell2) = split('\.\.', $range);\r
- }\r else {\r
- // TODO: use real error codes\r
- trigger_error("Unknown range separator", E_USER_ERROR);\r
- }\r
- \r
- // Convert the cell references\r
- $cell_array1 = $this->_cellToPackedRowcol($cell1);\r
- if ($this->isError($cell_array1)) {\r
- return $cell_array1;\r
- }\r
- list($row1, $col1) = $cell_array1;\r
- $cell_array2 = $this->_cellToPackedRowcol($cell2);\r
- if ($this->isError($cell_array2)) {\r
- return $cell_array2;\r
- }\r
- list($row2, $col2) = $cell_array2;\r
- \r
- // The ptg value depends on the class of the ptg.\r
- if ($class == 0) {\r
- $ptgArea = pack("C", $this->ptg['ptgArea']);\r
- }\r elseif ($class == 1) {\r
- $ptgArea = pack("C", $this->ptg['ptgAreaV']);\r
- }\r elseif ($class == 2) {\r
- $ptgArea = pack("C", $this->ptg['ptgAreaA']);\r
- }\r else {\r
- // TODO: use real error codes\r
- trigger_error("Unknown class $class", E_USER_ERROR);\r
- }\r
- return $ptgArea . $row1 . $row2 . $col1. $col2;\r
-}\r
- \r
-/**\r
-* Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to\r
-* a ptgArea3dV.\r
-*\r
-* @access private\r
-* @param string $token An Excel range in the Sheet1!A1:A2 format.\r
-*/\r
-function _convertRange3d($token)\r {\r
- $class = 2; // as far as I know, this is magick.\r
-\r
- // Split the ref at the ! symbol\r
- list($ext_ref, $range) = split('!', $token);\r
-\r
- // Convert the external reference part\r
- $ext_ref = $this->_packExtRef($ext_ref);\r
- if ($this->isError($ext_ref)) {\r
- return $ext_ref;\r
- }\r
-\r
- // Split the range into 2 cell refs\r
- list($cell1, $cell2) = split(':', $range);\r
-\r
- // Convert the cell references\r
- if (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/", $cell1))\r {\r
- $cell_array1 = $this->_cellToPackedRowcol($cell1);\r
- if ($this->isError($cell_array1)) {\r
- return $cell_array1;\r
- }\r
- list($row1, $col1) = $cell_array1;\r
- $cell_array2 = $this->_cellToPackedRowcol($cell2);\r
- if ($this->isError($cell_array2)) {\r
- return $cell_array2;\r
- }\r
- list($row2, $col2) = $cell_array2;\r
- }\r else { // It's a columns range (like 26:27)\r
- $cells_array = $this->_rangeToPackedRange($cell1.':'.$cell2);\r
- if ($this->isError($cells_array)) {\r
- return $cells_array;\r
- }\r
- list($row1, $col1, $row2, $col2) = $cells_array;\r
- }\r
- \r
- // The ptg value depends on the class of the ptg.\r
- if ($class == 0) {\r
- $ptgArea = pack("C", $this->ptg['ptgArea3d']);\r
- }\r elseif ($class == 1) {\r
- $ptgArea = pack("C", $this->ptg['ptgArea3dV']);\r
- }\r elseif ($class == 2) {\r
- $ptgArea = pack("C", $this->ptg['ptgArea3dA']);\r
- }\r else {\r
- trigger_error("Unknown class $class", E_USER_ERROR);\r
- }\r
- \r
- return $ptgArea . $ext_ref . $row1 . $row2 . $col1. $col2;\r
-}\r
-\r
-/**\r
-* Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV.\r
-*\r
-* @access private\r
-* @param string $cell An Excel cell reference\r
-* @return string The cell in packed() format with the corresponding ptg\r
-*/\r
-function _convertRef2d($cell)\r {\r
- $class = 2; // as far as I know, this is magick.\r
- \r
- // Convert the cell reference\r
- $cell_array = $this->_cellToPackedRowcol($cell);\r
- if ($this->isError($cell_array)) {\r
- return $cell_array;\r
- }\r
- list($row, $col) = $cell_array;\r
-\r
- // The ptg value depends on the class of the ptg.\r
- if ($class == 0) {\r
- $ptgRef = pack("C", $this->ptg['ptgRef']);\r
- }\r elseif ($class == 1) {\r
- $ptgRef = pack("C", $this->ptg['ptgRefV']);\r
- }\r elseif ($class == 2) {\r
- $ptgRef = pack("C", $this->ptg['ptgRefA']);\r
- }\r else {\r
- // TODO: use real error codes\r
- trigger_error("Unknown class $class",E_USER_ERROR);\r
- }\r
- return $ptgRef.$row.$col;\r
-}\r
- \r
-/**\r
-* Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a\r
-* ptgRef3dV.\r
-*\r
-* @access private\r
-* @param string $cell An Excel cell reference\r
-* @return string The cell in packed() format with the corresponding ptg\r
-*/\r
-function _convertRef3d($cell)\r {\r
- $class = 2; // as far as I know, this is magick.\r
- \r
- // Split the ref at the ! symbol\r
- list($ext_ref, $cell) = split('!', $cell);\r
- \r
- // Convert the external reference part\r
- $ext_ref = $this->_packExtRef($ext_ref);\r
- if ($this->isError($ext_ref)) {\r
- return $ext_ref;\r
- }\r
- \r
- // Convert the cell reference part\r
- list($row, $col) = $this->_cellToPackedRowcol($cell);\r
- \r
- // The ptg value depends on the class of the ptg.\r
- if ($class == 0) {\r
- $ptgRef = pack("C", $this->ptg['ptgRef3d']);\r
- } elseif ($class == 1) {\r
- $ptgRef = pack("C", $this->ptg['ptgRef3dV']);\r
- } elseif ($class == 2) {\r
- $ptgRef = pack("C", $this->ptg['ptgRef3dA']);\r
- }\r else {\r
- trigger_error("Unknown class $class", E_USER_ERROR);\r
- }\r
-\r
- return $ptgRef . $ext_ref. $row . $col;\r
-}\r
-\r
-/**\r
-* Convert the sheet name part of an external reference, for example "Sheet1" or\r
-* "Sheet1:Sheet2", to a packed structure.\r
-*\r
-* @access private\r
-* @param string $ext_ref The name of the external reference\r
-* @return string The reference index in packed() format\r
-*/\r
-function _packExtRef($ext_ref) {\r
- $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.\r
- $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.\r
-\r
- // Check if there is a sheet range eg., Sheet1:Sheet2.\r
- if (preg_match("/:/", $ext_ref))\r {\r
- list($sheet_name1, $sheet_name2) = split(':', $ext_ref);\r
-\r
- $sheet1 = $this->_getSheetIndex($sheet_name1);\r
- if ($sheet1 == -1) {\r
- trigger_error("Unknown sheet name $sheet_name1 in formula",E_USER_ERROR);\r
- }\r
- $sheet2 = $this->_getSheetIndex($sheet_name2);\r
- if ($sheet2 == -1) {\r
- trigger_error("Unknown sheet name $sheet_name2 in formula",E_USER_ERROR);\r
- }\r
-\r
- // Reverse max and min sheet numbers if necessary\r
- if ($sheet1 > $sheet2) {\r
- list($sheet1, $sheet2) = array($sheet2, $sheet1);\r
- }\r
- }\r else { // Single sheet name only.\r
- $sheet1 = $this->_getSheetIndex($ext_ref);\r
- if ($sheet1 == -1) {\r
- trigger_error("Unknown sheet name $ext_ref in formula",E_USER_ERROR);\r
- }\r
- $sheet2 = $sheet1;\r
- }\r
- \r
- // References are stored relative to 0xFFFF.\r
- $offset = -1 - $sheet1;\r
-
- return pack('vdvv', $offset, 0x00, $sheet1, $sheet2);\r
-}\r
-\r
-/**\r
-* Look up the index that corresponds to an external sheet name. The hash of\r
-* sheet names is updated by the addworksheet() method of the \r
-* Spreadsheet_Excel_Writer_Workbook class.\r
-*\r
-* @access private\r
-* @return integer\r
-*/\r
-function _getSheetIndex($sheet_name)\r {\r
- if (!isset($this->_ext_sheets[$sheet_name])) {\r
- return -1;\r
- }\r else {\r
- return $this->_ext_sheets[$sheet_name];\r
- }\r
-}\r
-\r
-/**\r
-* This method is used to update the array of sheet names. It is\r
-* called by the addWorksheet() method of the Spreadsheet_Excel_Writer_Workbook class.\r
-*\r
-* @access private\r
-* @param string $name The name of the worksheet being added\r
-* @param integer $index The index of the worksheet being added\r
-*/\r
-function setExtSheet($name, $index)\r {\r
- $this->_ext_sheets[$name] = $index;\r
-}\r
-\r
-/**\r
-* pack() row and column into the required 3 byte format.\r
-*\r
-* @access private\r
-* @param string $cell The Excel cell reference to be packed\r
-* @return array Array containing the row and column in packed() format\r
-*/\r
-function _cellToPackedRowcol($cell)\r {\r
- $cell = strtoupper($cell);\r
- list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell);\r
- if ($col >= 256) {\r
- trigger_error("Column in: $cell greater than 255", E_USER_ERROR);\r
- }\r
- if ($row >= 16384) {\r
- trigger_error("Row in: $cell greater than 16384 ", E_USER_ERROR);\r
- }\r
-\r
- // Set the high bits to indicate if row or col are relative.\r
- $row |= $col_rel << 14;\r
- $row |= $row_rel << 15;\r
-\r
- $row = pack('v', $row);\r
- $col = pack('C', $col);\r
-\r
- return array($row, $col);\r
-}\r
- \r
-/**\r
-* pack() row range into the required 3 byte format.\r
-* Just using maximun col/rows, which is probably not the correct solution\r
-*\r
-* @access private\r
-* @param string $range The Excel range to be packed\r
-* @return array Array containing (row1,col1,row2,col2) in packed() format\r
-*/\r
-function _rangeToPackedRange($range)\r {\r
- preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match);\r
- // return absolute rows if there is a $ in the ref\r
- $row1_rel = empty($match[1]) ? 1 : 0;\r
- $row1 = $match[2];\r
- $row2_rel = empty($match[3]) ? 1 : 0;\r
- $row2 = $match[4];\r
- // Convert 1-index to zero-index\r
- $row1--;\r
- $row2--;\r
- // Trick poor inocent Excel\r
- $col1 = 0;\r
- $col2 = 16383; // maximum possible value for Excel 5 (change this!!!)\r
-
- //list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell);\r
- if (($row1 >= 16384) or ($row2 >= 16384)) {\r
- trigger_error("Row in: $range greater than 16384 ",E_USER_ERROR);\r
- }\r
-\r
- // Set the high bits to indicate if rows are relative.\r
- $row1 |= $row1_rel << 14;\r
- $row2 |= $row2_rel << 15;\r
-\r
- $row1 = pack('v', $row1);\r
- $row2 = pack('v', $row2);\r
- $col1 = pack('C', $col1);\r
- $col2 = pack('C', $col2);\r
-\r
- return array($row1, $col1, $row2, $col2);\r
-}\r
-\r
-/**\r
-* Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero\r
-* indexed row and column number. Also returns two (0,1) values to indicate\r
-* whether the row or column are relative references.\r
-*\r
-* @access private\r
-* @param string $cell The Excel cell reference in A1 format.\r
-* @return array\r
-*/\r
-function _cellToRowcol($cell)\r {\r
- preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match);\r
- // return absolute column if there is a $ in the ref\r
- $col_rel = empty($match[1]) ? 1 : 0;\r
- $col_ref = $match[2];\r
- $row_rel = empty($match[3]) ? 1 : 0;\r
- $row = $match[4];\r
- \r
- // Convert base26 column string to a number.\r
- $expn = strlen($col_ref) - 1;\r
- $col = 0;\r
- for ($i=0; $i < strlen($col_ref); $i++)\r {\r
- $col += (ord($col_ref{$i}) - ord('A') + 1) * pow(26, $expn);\r
- $expn--;\r
- }\r
- \r
- // Convert 1-index to zero-index\r
- $row--;\r
- $col--;\r
- \r
- return array($row, $col, $row_rel, $col_rel);\r
-}\r
- \r
-/**\r
-* Advance to the next valid token.\r
-*\r
-* @access private\r
-*/\r
-function _advance()\r {\r
- $i = $this->_current_char;\r
- // eat up white spaces\r
- if ($i < strlen($this->_formula))\r {\r
- while ($this->_formula{$i} == " ") {\r
- $i++;\r
- }\r
- if ($i < strlen($this->_formula) - 1) {\r
- $this->_lookahead = $this->_formula{$i+1};\r
- }\r
- $token = "";\r
- }\r
- while ($i < strlen($this->_formula))\r {\r
- $token .= $this->_formula{$i};\r
- if ($i < strlen($this->_formula) - 1) {\r
- $this->_lookahead = $this->_formula{$i+1};\r
- }\r else {\r
- $this->_lookahead = '';\r
- }\r
- if ($this->_match($token) != '')\r {\r
- //if ($i < strlen($this->_formula) - 1) {\r
- // $this->_lookahead = $this->_formula{$i+1};\r
- //}\r
- $this->_current_char = $i + 1;\r
- $this->_current_token = $token;\r
- return 1;\r
- }\r
- if ($i < strlen($this->_formula) - 2) {\r
- $this->_lookahead = $this->_formula{$i+2};\r
- }\r else {\r
- // if we run out of characters _lookahead becomes empty\r
- $this->_lookahead = '';\r
- }\r
- $i++;\r
- }\r
- //die("Lexical error ".$this->_current_char);\r
-}\r
- \r
-/**\r
-* Checks if it's a valid token.\r
-*\r
-* @access private\r
-* @param mixed $token The token to check.\r
-* @return mixed The checked token or false on failure\r
-*/\r
-function _match($token)\r {\r
- switch($token)\r {\r
- case SPREADSHEET_EXCEL_WRITER_ADD:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_SUB:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_MUL:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_DIV:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_OPEN:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_CLOSE:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_SCOLON:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_COMA:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_GT:\r
- if ($this->_lookahead == '=') { // it's a GE token\r
- break;\r
- }\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_LT:\r
- // it's a LE or a NE token\r
- if (($this->_lookahead == '=') or ($this->_lookahead == '>')) {\r
- break;\r
- }\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_GE:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_LE:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_EQ:\r
- return($token);\r
- break;\r
- case SPREADSHEET_EXCEL_WRITER_NE:\r
- return($token);\r
- break;\r
- default:\r
- // if it's a reference\r
- if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and\r
- !ereg("[0-9]",$this->_lookahead) and \r
- ($this->_lookahead != ':') and ($this->_lookahead != '.') and\r
- ($this->_lookahead != '!'))\r {\r
- return $token;\r
- }\r
- // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)\r
- elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-Ia-i]?[A-Za-z][0-9]+$/",$token) and\r
- !ereg("[0-9]",$this->_lookahead) and\r
- ($this->_lookahead != ':') and ($this->_lookahead != '.'))\r {\r
- return $token;\r
- }\r
- // if it's a range (A1:A2)\r
- elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and \r
- !ereg("[0-9]",$this->_lookahead))\r {\r
- return $token;\r
- }\r
- // if it's a range (A1..A2)\r
- elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and \r
- !ereg("[0-9]",$this->_lookahead))\r {\r
- return $token;\r
- }\r
- // If it's an external range like Sheet1:Sheet2!A1:B2\r
- elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/",$token) and\r
- !ereg("[0-9]",$this->_lookahead))\r {\r
- return $token;\r
- }\r
- // If it's an external range like 'Sheet1:Sheet2'!A1:B2\r
- elseif (preg_match("/^'[A-Za-z0-9_ ]+(\:[A-Za-z0-9_ ]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/",$token) and\r
- !ereg("[0-9]",$this->_lookahead))\r {\r
- return $token;\r
- }\r
- // If it's a number (check that it's not a sheet name or range)\r
- elseif (is_numeric($token) and \r
- (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and\r
- ($this->_lookahead != '!') and ($this->_lookahead != ':'))\r {\r
- return $token;\r
- }\r
- // If it's a string (of maximum 255 characters)\r
- elseif (ereg("^\"[^\"]{0,255}\"$",$token))\r {\r
- return $token;\r
- }\r
- // if it's a function call\r
- elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "(")) {\r
- return $token;\r
- }\r
- return '';\r
- }\r
-}\r
- \r
-/**\r
-* The parsing method. It parses a formula.\r
-*\r
-* @access public\r
-* @param string $formula The formula to parse, without the initial equal sign (=).\r
-*/\r
-function parse($formula)\r {\r
- $this->_current_char = 0;\r
- $this->_formula = $formula;\r
- $this->_lookahead = $formula{1};\r
- $this->_advance();\r
- $this->_parse_tree = $this->_condition();\r
- if ($this->isError($this->_parse_tree)) {\r
- return $this->_parse_tree;\r
- }\r
-}\r
- \r
-/**\r
-* It parses a condition. It assumes the following rule:\r
-* Cond -> Expr [(">" | "<") Expr]\r
-*\r
-* @access private\r
-* @return mixed The parsed ptg'd tree\r
-*/\r
-function _condition()\r {\r
- $result = $this->_expression();\r
- if ($this->isError($result)) {\r
- return $result;\r
- }\r
- if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_LT)\r {\r
- $this->_advance();\r
- $result2 = $this->_expression();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgLT', $result, $result2);\r
- }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_GT) \r{\r
- $this->_advance();\r
- $result2 = $this->_expression();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgGT', $result, $result2);\r
- }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_LE) \r{\r
- $this->_advance();\r
- $result2 = $this->_expression();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgLE', $result, $result2);\r
- }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_GE) \r{\r
- $this->_advance();\r
- $result2 = $this->_expression();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgGE', $result, $result2);\r
- }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_EQ) \r{\r
- $this->_advance();\r
- $result2 = $this->_expression();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgEQ', $result, $result2);\r
- }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_NE) \r{\r
- $this->_advance();\r
- $result2 = $this->_expression();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgNE', $result, $result2);\r
- }\r
- return $result;\r
-}\r
-
-/**\r
-* It parses a expression. It assumes the following rule:\r
-* Expr -> Term [("+" | "-") Term]\r
-*\r
-* @access private\r
-* @return mixed The parsed ptg'd tree\r
-*/\r
-function _expression()\r {\r
- // If it's a string return a string node\r
- if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token))\r {\r
- $result = $this->_createTree($this->_current_token, '', '');\r
- $this->_advance();\r
- return $result;\r
- }\r
- $result = $this->_term();\r
- if ($this->isError($result)) {\r
- return $result;\r
- }\r
- while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD) or \r
- ($this->_current_token == SPREADSHEET_EXCEL_WRITER_SUB))\r {\r
- if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD)\r \r{
- $this->_advance();\r
- $result2 = $this->_term();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgAdd', $result, $result2);\r
- }\r else \r{\r
- $this->_advance();\r
- $result2 = $this->_term();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgSub', $result, $result2);\r
- }\r
- }\r
- return $result;\r
-}\r
- \r
-/**\r
-* This function just introduces a ptgParen element in the tree, so that Excel\r
-* doesn't get confused when working with a parenthesized formula afterwards.\r
-*\r
-* @access private\r
-* @see _fact()\r
-* @return mixed The parsed ptg'd tree\r
-*/\r
-function _parenthesizedExpression()\r {\r
- $result = $this->_createTree('ptgParen', $this->_expression(), '');\r
- return $result;\r
-}\r
- \r
-/**\r
-* It parses a term. It assumes the following rule:\r
-* Term -> Fact [("*" | "/") Fact]\r
-*\r
-* @access private\r
-* @return mixed The parsed ptg'd tree\r
-*/\r
-function _term()\r {\r
- $result = $this->_fact();\r
- if ($this->isError($result)) {\r
- return $result;\r
- }\r
- while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL) or \r
- ($this->_current_token == SPREADSHEET_EXCEL_WRITER_DIV)) {
- if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL)\r \r{
- $this->_advance();\r
- $result2 = $this->_fact();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgMul', $result, $result2);\r
- }\r else \r{\r
- $this->_advance();\r
- $result2 = $this->_fact();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('ptgDiv', $result, $result2);\r
- }\r
- }\r
- return $result;\r
-}\r
- \r
-/**\r
-* It parses a factor. It assumes the following rule:\r
-* Fact -> ( Expr )\r
-* | CellRef\r
-* | CellRange\r
-* | Number\r
-* | Function\r
-*\r
-* @access private\r
-* @return mixed The parsed ptg'd tree\r
-*/\r
-function _fact()\r {\r
- if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_OPEN)\r {\r
- $this->_advance(); // eat the "("\r
- $result = $this->_parenthesizedExpression();\r
- if ($this->_current_token != SPREADSHEET_EXCEL_WRITER_CLOSE) {\r
- trigger_error("')' token expected.",E_USER_ERROR);\r
- }\r
- $this->_advance(); // eat the ")"\r
- return $result;\r
- }\r if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$this->_current_token))\r {\r
- // if it's a reference\r
- $result = $this->_createTree($this->_current_token, '', '');\r
- $this->_advance();\r
- return $result;\r
- }\r elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-Ia-i]?[A-Za-z][0-9]+$/",$this->_current_token))\r {\r
- // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)\r
- $result = $this->_createTree($this->_current_token, '', '');\r
- $this->_advance();\r
- return $result;\r
- }\r elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or \r
- preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token))\r {\r
- // if it's a range\r
- $result = $this->_current_token;\r
- $this->_advance();\r
- return $result;\r
- }\r elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/",$this->_current_token))\r {\r
- // If it's an external range (Sheet1!A1:B2)\r
- $result = $this->_current_token;\r
- $this->_advance();\r
- return $result;\r
- }\r elseif (preg_match("/^'[A-Za-z0-9_ ]+(\:[A-Za-z0-9_ ]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/",$this->_current_token))\r {\r
- // If it's an external range ('Sheet1'!A1:B2)\r
- $result = $this->_current_token;\r
- $this->_advance();\r
- return $result;\r
- }\r elseif (is_numeric($this->_current_token))\r {\r
- $result = $this->_createTree($this->_current_token, '', '');\r
- $this->_advance();\r
- return $result;\r
- }\r elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token))\r {\r
- // if it's a function call\r
- $result = $this->_func();\r
- return $result;\r
- }\r
- trigger_error("Sintactic error: ".$this->_current_token.", lookahead: ".\r
- $this->_lookahead.", current char: ".$this->_current_char, E_USER_ERROR);\r
-}\r
- \r
-/**\r
-* It parses a function call. It assumes the following rule:\r
-* Func -> ( Expr [,Expr]* )\r
-*\r
-* @access private\r
-*/\r
-function _func()\r {\r
- $num_args = 0; // number of arguments received\r
- $function = $this->_current_token;\r
- $this->_advance();\r
- $this->_advance(); // eat the "("\r
- while ($this->_current_token != ')')\r {\r
- if ($num_args > 0)\r {\r
- if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_COMA ||
- $this->_current_token == SPREADSHEET_EXCEL_WRITER_SCOLON) {\r
- $this->_advance(); // eat the ","\r
- }\r else {\r
- trigger_error("Sintactic error: coma expected in ".\r
- "function $function, {$num_args}º arg", E_USER_ERROR);\r
- }\r
- $result2 = $this->_condition();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('arg', $result, $result2);\r
- }\r else { // first argument\r
- $result2 = $this->_condition();\r
- if ($this->isError($result2)) {\r
- return $result2;\r
- }\r
- $result = $this->_createTree('arg', '', $result2);\r
- }\r
- $num_args++;\r
- }\r
- $args = $this->_functions[$function][1];\r
- // If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid.\r
- if (($args >= 0) and ($args != $num_args)) {\r
- trigger_error("Incorrect number of arguments in function $function() ",E_USER_ERROR);\r
- }\r
-\r
- $result = $this->_createTree($function, $result, $num_args);\r
- $this->_advance(); // eat the ")"\r
- return $result;\r
-}\r
- \r
-/**\r
-* Creates a tree. In fact an array which may have one or two arrays (sub-trees)\r
-* as elements.\r
-*\r
-* @access private\r
-* @param mixed $value The value of this node.\r
-* @param mixed $left The left array (sub-tree) or a final node.\r
-* @param mixed $right The right array (sub-tree) or a final node.\r
-*/\r
-function _createTree($value, $left, $right)\r {\r
- return(array('value' => $value, 'left' => $left, 'right' => $right));\r
-}\r
- \r
-/**\r
-* Builds a string containing the tree in reverse polish notation (What you \r
-* would use in a HP calculator stack).\r
-* The following tree:\r
-* \r
-* +\r
-* / \\r
-* 2 3\r
-*\r
-* produces: "23+"\r
-*\r
-* The following tree:\r
-*\r
-* +\r
-* / \\r
-* 3 *\r
-* / \\r
-* 6 A1\r
-*\r
-* produces: "36A1*+"\r
-*\r
-* In fact all operands, functions, references, etc... are written as ptg's\r
-*\r
-* @access public\r
-* @param array $tree The optional tree to convert.\r
-* @return string The tree in reverse polish notation\r
-*/\r
-function toReversePolish($tree = array())\r {\r
- $polish = ""; // the string we are going to return\r
- if (empty($tree)) { // If it's the first call use _parse_tree\r
- $tree = $this->_parse_tree;\r
- }\r
- if (is_array($tree['left']))\r {\r
- $converted_tree = $this->toReversePolish($tree['left']);\r
- if ($this->isError($converted_tree)) {\r
- return $converted_tree;\r
- }\r
- $polish .= $converted_tree;\r
- }\r elseif ($tree['left'] != '') { // It's a final node\r
- $converted_tree = $this->_convert($tree['left']);\r
- if ($this->isError($converted_tree)) {\r
- return $converted_tree;\r
- }\r
- $polish .= $converted_tree;\r
- }\r
- if (is_array($tree['right']))\r {\r
- $converted_tree = $this->toReversePolish($tree['right']);\r
- if ($this->isError($converted_tree)) {\r
- return $converted_tree;\r
- }\r
- $polish .= $converted_tree;\r
- }\r elseif ($tree['right'] != '') { // It's a final node\r
- $converted_tree = $this->_convert($tree['right']);\r
- if ($this->isError($converted_tree)) {\r
- return $converted_tree;\r
- }\r
- $polish .= $converted_tree;\r
- }\r
- // if it's a function convert it here (so we can set it's arguments)\r
- if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/",$tree['value']) and\r
- !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and\r
- !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and\r
- !is_numeric($tree['value']) and\r
- !isset($this->ptg[$tree['value']]))\r {\r
- // left subtree for a function is always an array.\r
- if ($tree['left'] != '') {\r
- $left_tree = $this->toReversePolish($tree['left']);\r
- }\r else {\r
- $left_tree = '';\r
- }\r
- if ($this->isError($left_tree)) {\r
- return $left_tree;\r
- }\r
- // add it's left subtree and return.\r
- return $left_tree.$this->_convertFunction($tree['value'], $tree['right']);\r
- }\r else\r {\r
- $converted_tree = $this->_convert($tree['value']);\r
- if ($this->isError($converted_tree)) {\r
- return $converted_tree;\r
- }\r
- }\r
- $polish .= $converted_tree;\r
- return $polish;\r
-}\r
-
-}\r
-
-
-?>
diff --git a/gosa-core/include/php_writeexcel/class.writeexcel_olewriter.inc.php b/gosa-core/include/php_writeexcel/class.writeexcel_olewriter.inc.php
+++ /dev/null
@@ -1,353 +0,0 @@
-<?php
-
-/*
- * Copyleft 2002 Johann Hanne
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * This is the Spreadsheet::WriteExcel Perl package ported to PHP
- * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
- */
-
-class writeexcel_olewriter {
- var $_OLEfilename;
- var $_OLEtmpfilename; /* ABR */
- var $_filehandle;
- var $_fileclosed;
- var $_internal_fh;
- var $_biff_only;
- var $_size_allowed;
- var $_biffsize;
- var $_booksize;
- var $_big_blocks;
- var $_list_blocks;
- var $_root_start;
- var $_block_count;
-
- /*
- * Constructor
- */
- function writeexcel_olewriter($filename) {
-
- $this->_OLEfilename = $filename;
- $this->_filehandle = false;
- $this->_fileclosed = 0;
- $this->_internal_fh = 0;
- $this->_biff_only = 0;
- $this->_size_allowed = 0;
- $this->_biffsize = 0;
- $this->_booksize = 0;
- $this->_big_blocks = 0;
- $this->_list_blocks = 0;
- $this->_root_start = 0;
- $this->_block_count = 4;
-
- $this->_initialize();
- }
-
- /*
- * Check for a valid filename and store the filehandle.
- */
- function _initialize() {
- $OLEfile = $this->_OLEfilename;
-
- /* Check for a filename. Workbook.pm will catch this first. */
- if ($OLEfile == '') {
- trigger_error("Filename required", E_USER_ERROR);
- }
-
- /*
- * If the filename is a resource it is assumed that it is a valid
- * filehandle, if not we create a filehandle.
- */
- if (is_resource($OLEfile)) {
- $fh = $OLEfile;
- } else {
- // Create a new file, open for writing
- $fh = fopen($OLEfile, "wb");
- // The workbook class also checks this but something may have
- // happened since then.
- if (!$fh) {
- trigger_error("Can't open $OLEfile. It may be in use or ".
- "protected", E_USER_ERROR);
- }
-
- $this->_internal_fh = 1;
- }
-
- // Store filehandle
- $this->_filehandle = $fh;
- }
-
- /*
- * Set the size of the data to be written to the OLE stream
- *
- * $big_blocks = (109 depot block x (128 -1 marker word)
- * - (1 x end words)) = 13842
- * $maxsize = $big_blocks * 512 bytes = 7087104
- */
- function set_size($size) {
- $maxsize = 7087104;
-
- if ($size > $maxsize) {
- trigger_error("Maximum file size, $maxsize, exceeded. To create ".
- "files bigger than this limit please use the ".
- "workbookbig class.", E_USER_ERROR);
- return ($this->_size_allowed = 0);
- }
-
- $this->_biffsize = $size;
-
- // Set the min file size to 4k to avoid having to use small blocks
- if ($size > 4096) {
- $this->_booksize = $size;
- } else {
- $this->_booksize = 4096;
- }
-
- return ($this->_size_allowed = 1);
- }
-
- /*
- * Calculate various sizes needed for the OLE stream
- */
- function _calculate_sizes() {
- $datasize = $this->_booksize;
-
- if ($datasize % 512 == 0) {
- $this->_big_blocks = $datasize/512;
- } else {
- $this->_big_blocks = floor($datasize/512)+1;
- }
- // There are 127 list blocks and 1 marker blocks for each big block
- // depot + 1 end of chain block
- $this->_list_blocks = floor(($this->_big_blocks)/127)+1;
- $this->_root_start = $this->_big_blocks;
-
- //print $this->_biffsize. "\n";
- //print $this->_big_blocks. "\n";
- //print $this->_list_blocks. "\n";
- }
-
- /*
- * Write root entry, big block list and close the filehandle.
- * This method must be called so that the file contents are
- * actually written.
- */
- function close() {
-
- if (!$this->_size_allowed) {
- return;
- }
-
- if (!$this->_biff_only) {
- $this->_write_padding();
- $this->_write_property_storage();
- $this->_write_big_block_depot();
- }
-
- // Close the filehandle if it was created internally.
- if ($this->_internal_fh) {
- fclose($this->_filehandle);
- }
-/* ABR */
- if ($this->_OLEtmpfilename != '') {
- $fh = fopen($this->_OLEtmpfilename, "rb");
- if ($fh == false) {
- trigger_error("Can't read temporary file.", E_USER_ERROR);
- }
- fpassthru($fh);
- fclose($fh);
- unlink($this->_OLEtmpfilename);
- };
-
- $this->_fileclosed = 1;
- }
-
- /*
- * Write BIFF data to OLE file.
- */
- function write($data) {
- fputs($this->_filehandle, $data);
- }
-
- /*
- * Write OLE header block.
- */
- function write_header() {
- if ($this->_biff_only) {
- return;
- }
-
- $this->_calculate_sizes();
-
- $root_start = $this->_root_start;
- $num_lists = $this->_list_blocks;
-
- $id = pack("C8", 0xD0, 0xCF, 0x11, 0xE0,
- 0xA1, 0xB1, 0x1A, 0xE1);
- $unknown1 = pack("VVVV", 0x00, 0x00, 0x00, 0x00);
- $unknown2 = pack("vv", 0x3E, 0x03);
- $unknown3 = pack("v", -2);
- $unknown4 = pack("v", 0x09);
- $unknown5 = pack("VVV", 0x06, 0x00, 0x00);
- $num_bbd_blocks = pack("V", $num_lists);
- $root_startblock = pack("V", $root_start);
- $unknown6 = pack("VV", 0x00, 0x1000);
- $sbd_startblock = pack("V", -2);
- $unknown7 = pack("VVV", 0x00, -2 ,0x00);
- $unused = pack("V", -1);
-
- fputs($this->_filehandle, $id);
- fputs($this->_filehandle, $unknown1);
- fputs($this->_filehandle, $unknown2);
- fputs($this->_filehandle, $unknown3);
- fputs($this->_filehandle, $unknown4);
- fputs($this->_filehandle, $unknown5);
- fputs($this->_filehandle, $num_bbd_blocks);
- fputs($this->_filehandle, $root_startblock);
- fputs($this->_filehandle, $unknown6);
- fputs($this->_filehandle, $sbd_startblock);
- fputs($this->_filehandle, $unknown7);
-
- for ($c=1;$c<=$num_lists;$c++) {
- $root_start++;
- fputs($this->_filehandle, pack("V", $root_start));
- }
-
- for ($c=$num_lists;$c<=108;$c++) {
- fputs($this->_filehandle, $unused);
- }
- }
-
- /*
- * Write big block depot.
- */
- function _write_big_block_depot() {
- $num_blocks = $this->_big_blocks;
- $num_lists = $this->_list_blocks;
- $total_blocks = $num_lists * 128;
- $used_blocks = $num_blocks + $num_lists + 2;
-
- $marker = pack("V", -3);
- $end_of_chain = pack("V", -2);
- $unused = pack("V", -1);
-
- for ($i=1;$i<=($num_blocks-1);$i++) {
- fputs($this->_filehandle, pack("V", $i));
- }
-
- fputs($this->_filehandle, $end_of_chain);
- fputs($this->_filehandle, $end_of_chain);
-
- for ($c=1;$c<=$num_lists;$c++) {
- fputs($this->_filehandle, $marker);
- }
-
- for ($c=$used_blocks;$c<=$total_blocks;$c++) {
- fputs($this->_filehandle, $unused);
- }
- }
-
- /*
- * Write property storage. TODO: add summary sheets
- */
- function _write_property_storage() {
- $rootsize = -2;
- $booksize = $this->_booksize;
-
- // name type dir start size
- $this->_write_pps('Root Entry', 0x05, 1, -2, 0x00);
- $this->_write_pps('Book', 0x02, -1, 0x00, $booksize);
- $this->_write_pps('', 0x00, -1, 0x00, 0x0000);
- $this->_write_pps('', 0x00, -1, 0x00, 0x0000);
- }
-
- /*
- * Write property sheet in property storage
- */
- function _write_pps($name, $type, $dir, $start, $size) {
- $names = array();
- $length = 0;
-
- if ($name != '') {
- $name = $name . "\0";
- // Simulate a Unicode string
- $chars=preg_split("''", $name, -1, PREG_SPLIT_NO_EMPTY);
- foreach ($chars as $char) {
- array_push($names, ord($char));
- }
- $length = strlen($name) * 2;
- }
-
- $rawname = call_user_func_array('pack', array_merge(array("v*"), $names));
- $zero = pack("C", 0);
-
- $pps_sizeofname = pack("v", $length); //0x40
- $pps_type = pack("v", $type); //0x42
- $pps_prev = pack("V", -1); //0x44
- $pps_next = pack("V", -1); //0x48
- $pps_dir = pack("V", $dir); //0x4c
-
- $unknown1 = pack("V", 0);
-
- $pps_ts1s = pack("V", 0); //0x64
- $pps_ts1d = pack("V", 0); //0x68
- $pps_ts2s = pack("V", 0); //0x6c
- $pps_ts2d = pack("V", 0); //0x70
- $pps_sb = pack("V", $start); //0x74
- $pps_size = pack("V", $size); //0x78
-
- fputs($this->_filehandle, $rawname);
- fputs($this->_filehandle, str_repeat($zero, (64-$length)));
- fputs($this->_filehandle, $pps_sizeofname);
- fputs($this->_filehandle, $pps_type);
- fputs($this->_filehandle, $pps_prev);
- fputs($this->_filehandle, $pps_next);
- fputs($this->_filehandle, $pps_dir);
- fputs($this->_filehandle, str_repeat($unknown1, 5));
- fputs($this->_filehandle, $pps_ts1s);
- fputs($this->_filehandle, $pps_ts1d);
- fputs($this->_filehandle, $pps_ts2d);
- fputs($this->_filehandle, $pps_ts2d);
- fputs($this->_filehandle, $pps_sb);
- fputs($this->_filehandle, $pps_size);
- fputs($this->_filehandle, $unknown1);
- }
-
- /*
- * Pad the end of the file
- */
- function _write_padding() {
- $biffsize = $this->_biffsize;
-
- if ($biffsize < 4096) {
- $min_size = 4096;
- } else {
- $min_size = 512;
- }
-
- if ($biffsize % $min_size != 0) {
- $padding = $min_size - ($biffsize % $min_size);
- fputs($this->_filehandle, str_repeat("\0", $padding));
- }
- }
-
-}
-
-?>
diff --git a/gosa-core/include/php_writeexcel/class.writeexcel_workbook.inc.php b/gosa-core/include/php_writeexcel/class.writeexcel_workbook.inc.php
+++ /dev/null
@@ -1,1109 +0,0 @@
-<?php
-
-/*
- * Copyleft 2002 Johann Hanne
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * This is the Spreadsheet::WriteExcel Perl package ported to PHP
- * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
- */
-
-require_once "class.writeexcel_biffwriter.inc.php";
-require_once "class.writeexcel_format.inc.php";
-require_once "class.writeexcel_formula.inc.php";
-require_once "class.writeexcel_olewriter.inc.php";
-
-class writeexcel_workbook extends writeexcel_biffwriter {
-
- var $_filename;
- var $_tmpfilename;
- var $_parser;
- var $_tempdir;
- var $_1904;
- var $_activesheet;
- var $_firstsheet;
- var $_selected;
- var $_xf_index;
- var $_fileclosed;
- var $_biffsize;
- var $_sheetname;
- var $_tmp_format;
- var $_url_format;
- var $_worksheets;
- var $_sheetnames;
- var $_formats;
- var $_palette;
-
-###############################################################################
-#
-# new()
-#
-# Constructor. Creates a new Workbook object from a BIFFwriter object.
-#
-function writeexcel_workbook($filename) {
-
- $this->writeexcel_biffwriter();
-
- $tmp_format = new writeexcel_format();
- $byte_order = $this->_byte_order;
- $parser = new writeexcel_formula($byte_order);
-
- $this->_filename = $filename;
- $this->_parser = $parser;
-//? $this->_tempdir = undef;
- $this->_1904 = 0;
- $this->_activesheet = 0;
- $this->_firstsheet = 0;
- $this->_selected = 0;
- $this->_xf_index = 16; # 15 style XF's and 1 cell XF.
- $this->_fileclosed = 0;
- $this->_biffsize = 0;
- $this->_sheetname = "Sheet";
- $this->_tmp_format = $tmp_format;
- $this->_url_format = false;
- $this->_worksheets = array();
- $this->_sheetnames = array();
- $this->_formats = array();
- $this->_palette = array();
-
- # Add the default format for hyperlinks
- $this->_url_format = $this->addformat(array('color' => 'blue', 'underline' => 1));
-
- # Check for a filename
- if ($this->_filename == '') {
-//todo: print error
- return;
- }
-
- # Try to open the named file and see if it throws any errors.
- # If the filename is a reference it is assumed that it is a valid
- # filehandle and ignore
- #
-//todo
-
- # Set colour palette.
- $this->set_palette_xl97();
-}
-
-###############################################################################
-#
-# close()
-#
-# Calls finalization methods and explicitly close the OLEwriter file
-# handle.
-#
-function close() {
- # Prevent close() from being called twice.
- if ($this->_fileclosed) {
- return;
- }
-
- $this->_store_workbook();
- $this->_fileclosed = 1;
-}
-
-//PHPport: method DESTROY deleted
-
-###############################################################################
-#
-# sheets()
-#
-# An accessor for the _worksheets[] array
-#
-# Returns: a list of the worksheet objects in a workbook
-#
-function sheets() {
- return $this->_worksheets;
-}
-
-//PHPport: method worksheets deleted:
-# This method is now deprecated. Use the sheets() method instead.
-
-###############################################################################
-#
-# addworksheet($name)
-#
-# Add a new worksheet to the Excel workbook.
-# TODO: Add accessor for $self->{_sheetname} for international Excel versions.
-#
-# Returns: reference to a worksheet object
-#
-function addworksheet($name="") {
-
- # Check that sheetname is <= 31 chars (Excel limit).
- if (strlen($name) > 31) {
- trigger_error("Sheetname $name must be <= 31 chars", E_USER_ERROR);
- }
-
- $index = sizeof($this->_worksheets);
- $sheetname = $this->_sheetname;
-
- if ($name == "") {
- $name = $sheetname . ($index+1);
- }
-
- # Check that the worksheet name doesn't already exist: a fatal Excel error.
- foreach ($this->_worksheets as $tmp) {
- if ($name == $tmp->get_name()) {
- trigger_error("Worksheet '$name' already exists", E_USER_ERROR);
- }
- }
-
- $worksheet = new writeexcel_worksheet($name, $index, $this->_activesheet,
- $this->_firstsheet,
- $this->_url_format, $this->_parser,
- $this->_tempdir);
-
- $this->_worksheets[$index] = $worksheet; # Store ref for iterator
- $this->_sheetnames[$index] = $name; # Store EXTERNSHEET names
- $this->_parser->set_ext_sheet($name, $index); # Store names in Formula.pm
- return $worksheet;
-}
-
-###############################################################################
-#
-# addformat(%properties)
-#
-# Add a new format to the Excel workbook. This adds an XF record and
-# a FONT record. Also, pass any properties to the Format::new().
-#
-function addformat($para=false) {
- if($para===false) {
- $format = new writeexcel_format($this->_xf_index);
- } else {
- $format = new writeexcel_format($this->_xf_index, $para);
- }
-
- $this->_xf_index += 1;
- # Store format reference
- $this->_formats[]=$format;
-
- return $format;
-}
-
-###############################################################################
-#
-# set_1904()
-#
-# Set the date system: 0 = 1900 (the default), 1 = 1904
-#
-function set_1904($_1904) {
- $this->_1904 = $_1904;
-}
-
-###############################################################################
-#
-# get_1904()
-#
-# Return the date system: 0 = 1900, 1 = 1904
-#
-function get_1904() {
- return $this->_1904;
-}
-
-###############################################################################
-#
-# set_custom_color()
-#
-# Change the RGB components of the elements in the colour palette.
-#
-function set_custom_color($index, $red, $green, $blue) {
-// todo
-/*
- # Match a HTML #xxyyzz style parameter
- if (defined $_[1] and $_[1] =~ /^#(\w\w)(\w\w)(\w\w)/ ) {
- @_ = ($_[0], hex $1, hex $2, hex $3);
- }
-*/
-
- $aref = $this->_palette;
-
- # Check that the colour index is the right range
- if ($index < 8 or $index > 64) {
-//todo carp "Color index $index outside range: 8 <= index <= 64";
- return;
- }
-
- # Check that the colour components are in the right range
- if ( ($red < 0 || $red > 255) ||
- ($green < 0 || $green > 255) ||
- ($blue < 0 || $blue > 255) )
- {
-//todo carp "Color component outside range: 0 <= color <= 255";
- return;
- }
-
- $index -=8; # Adjust colour index (wingless dragonfly)
-
- # Set the RGB value
- $aref[$index] = array($red, $green, $blue, 0);
-
- return $index +8;
-}
-
-###############################################################################
-#
-# set_palette_xl97()
-#
-# Sets the colour palette to the Excel 97+ default.
-#
-function set_palette_xl97() {
- $this->_palette = array(
- array(0x00, 0x00, 0x00, 0x00), # 8
- array(0xff, 0xff, 0xff, 0x00), # 9
- array(0xff, 0x00, 0x00, 0x00), # 10
- array(0x00, 0xff, 0x00, 0x00), # 11
- array(0x00, 0x00, 0xff, 0x00), # 12
- array(0xff, 0xff, 0x00, 0x00), # 13
- array(0xff, 0x00, 0xff, 0x00), # 14
- array(0x00, 0xff, 0xff, 0x00), # 15
- array(0x80, 0x00, 0x00, 0x00), # 16
- array(0x00, 0x80, 0x00, 0x00), # 17
- array(0x00, 0x00, 0x80, 0x00), # 18
- array(0x80, 0x80, 0x00, 0x00), # 19
- array(0x80, 0x00, 0x80, 0x00), # 20
- array(0x00, 0x80, 0x80, 0x00), # 21
- array(0xc0, 0xc0, 0xc0, 0x00), # 22
- array(0x80, 0x80, 0x80, 0x00), # 23
- array(0x99, 0x99, 0xff, 0x00), # 24
- array(0x99, 0x33, 0x66, 0x00), # 25
- array(0xff, 0xff, 0xcc, 0x00), # 26
- array(0xcc, 0xff, 0xff, 0x00), # 27
- array(0x66, 0x00, 0x66, 0x00), # 28
- array(0xff, 0x80, 0x80, 0x00), # 29
- array(0x00, 0x66, 0xcc, 0x00), # 30
- array(0xcc, 0xcc, 0xff, 0x00), # 31
- array(0x00, 0x00, 0x80, 0x00), # 32
- array(0xff, 0x00, 0xff, 0x00), # 33
- array(0xff, 0xff, 0x00, 0x00), # 34
- array(0x00, 0xff, 0xff, 0x00), # 35
- array(0x80, 0x00, 0x80, 0x00), # 36
- array(0x80, 0x00, 0x00, 0x00), # 37
- array(0x00, 0x80, 0x80, 0x00), # 38
- array(0x00, 0x00, 0xff, 0x00), # 39
- array(0x00, 0xcc, 0xff, 0x00), # 40
- array(0xcc, 0xff, 0xff, 0x00), # 41
- array(0xcc, 0xff, 0xcc, 0x00), # 42
- array(0xff, 0xff, 0x99, 0x00), # 43
- array(0x99, 0xcc, 0xff, 0x00), # 44
- array(0xff, 0x99, 0xcc, 0x00), # 45
- array(0xcc, 0x99, 0xff, 0x00), # 46
- array(0xff, 0xcc, 0x99, 0x00), # 47
- array(0x33, 0x66, 0xff, 0x00), # 48
- array(0x33, 0xcc, 0xcc, 0x00), # 49
- array(0x99, 0xcc, 0x00, 0x00), # 50
- array(0xff, 0xcc, 0x00, 0x00), # 51
- array(0xff, 0x99, 0x00, 0x00), # 52
- array(0xff, 0x66, 0x00, 0x00), # 53
- array(0x66, 0x66, 0x99, 0x00), # 54
- array(0x96, 0x96, 0x96, 0x00), # 55
- array(0x00, 0x33, 0x66, 0x00), # 56
- array(0x33, 0x99, 0x66, 0x00), # 57
- array(0x00, 0x33, 0x00, 0x00), # 58
- array(0x33, 0x33, 0x00, 0x00), # 59
- array(0x99, 0x33, 0x00, 0x00), # 60
- array(0x99, 0x33, 0x66, 0x00), # 61
- array(0x33, 0x33, 0x99, 0x00), # 62
- array(0x33, 0x33, 0x33, 0x00), # 63
- );
-
- return 0;
-}
-
-###############################################################################
-#
-# set_palette_xl5()
-#
-# Sets the colour palette to the Excel 5 default.
-#
-function set_palette_xl5() {
- $this->_palette = array(
- array(0x00, 0x00, 0x00, 0x00), # 8
- array(0xff, 0xff, 0xff, 0x00), # 9
- array(0xff, 0x00, 0x00, 0x00), # 10
- array(0x00, 0xff, 0x00, 0x00), # 11
- array(0x00, 0x00, 0xff, 0x00), # 12
- array(0xff, 0xff, 0x00, 0x00), # 13
- array(0xff, 0x00, 0xff, 0x00), # 14
- array(0x00, 0xff, 0xff, 0x00), # 15
- array(0x80, 0x00, 0x00, 0x00), # 16
- array(0x00, 0x80, 0x00, 0x00), # 17
- array(0x00, 0x00, 0x80, 0x00), # 18
- array(0x80, 0x80, 0x00, 0x00), # 19
- array(0x80, 0x00, 0x80, 0x00), # 20
- array(0x00, 0x80, 0x80, 0x00), # 21
- array(0xc0, 0xc0, 0xc0, 0x00), # 22
- array(0x80, 0x80, 0x80, 0x00), # 23
- array(0x80, 0x80, 0xff, 0x00), # 24
- array(0x80, 0x20, 0x60, 0x00), # 25
- array(0xff, 0xff, 0xc0, 0x00), # 26
- array(0xa0, 0xe0, 0xe0, 0x00), # 27
- array(0x60, 0x00, 0x80, 0x00), # 28
- array(0xff, 0x80, 0x80, 0x00), # 29
- array(0x00, 0x80, 0xc0, 0x00), # 30
- array(0xc0, 0xc0, 0xff, 0x00), # 31
- array(0x00, 0x00, 0x80, 0x00), # 32
- array(0xff, 0x00, 0xff, 0x00), # 33
- array(0xff, 0xff, 0x00, 0x00), # 34
- array(0x00, 0xff, 0xff, 0x00), # 35
- array(0x80, 0x00, 0x80, 0x00), # 36
- array(0x80, 0x00, 0x00, 0x00), # 37
- array(0x00, 0x80, 0x80, 0x00), # 38
- array(0x00, 0x00, 0xff, 0x00), # 39
- array(0x00, 0xcf, 0xff, 0x00), # 40
- array(0x69, 0xff, 0xff, 0x00), # 41
- array(0xe0, 0xff, 0xe0, 0x00), # 42
- array(0xff, 0xff, 0x80, 0x00), # 43
- array(0xa6, 0xca, 0xf0, 0x00), # 44
- array(0xdd, 0x9c, 0xb3, 0x00), # 45
- array(0xb3, 0x8f, 0xee, 0x00), # 46
- array(0xe3, 0xe3, 0xe3, 0x00), # 47
- array(0x2a, 0x6f, 0xf9, 0x00), # 48
- array(0x3f, 0xb8, 0xcd, 0x00), # 49
- array(0x48, 0x84, 0x36, 0x00), # 50
- array(0x95, 0x8c, 0x41, 0x00), # 51
- array(0x8e, 0x5e, 0x42, 0x00), # 52
- array(0xa0, 0x62, 0x7a, 0x00), # 53
- array(0x62, 0x4f, 0xac, 0x00), # 54
- array(0x96, 0x96, 0x96, 0x00), # 55
- array(0x1d, 0x2f, 0xbe, 0x00), # 56
- array(0x28, 0x66, 0x76, 0x00), # 57
- array(0x00, 0x45, 0x00, 0x00), # 58
- array(0x45, 0x3e, 0x01, 0x00), # 59
- array(0x6a, 0x28, 0x13, 0x00), # 60
- array(0x85, 0x39, 0x6a, 0x00), # 61
- array(0x4a, 0x32, 0x85, 0x00), # 62
- array(0x42, 0x42, 0x42, 0x00), # 63
- );
-
- return 0;
-}
-
-###############################################################################
-#
-# set_tempdir()
-#
-# Change the default temp directory used by _initialize() in Worksheet.pm.
-#
-function set_tempdir($tempdir) {
-//todo
-/*
- croak "$_[0] is not a valid directory" unless -d $_[0];
- croak "set_tempdir must be called before addworksheet" if $self->sheets();
-*/
-
- $this->_tempdir = $tempdir;
-}
-
-###############################################################################
-#
-# _store_workbook()
-#
-# Assemble worksheets into a workbook and send the BIFF data to an OLE
-# storage.
-#
-function _store_workbook() {
-
- # Ensure that at least one worksheet has been selected.
- if ($this->_activesheet == 0) {
- $this->_worksheets[0]->_selected = 1;
- }
-
- # Calculate the number of selected worksheet tabs and call the finalization
- # methods for each worksheet
- for ($c=0;$c<sizeof($this->_worksheets);$c++) {
- $sheet=$this->_worksheets[$c];
- if ($sheet->_selected) {
- $this->_selected++;
-
- }
- $sheet->_close($this->_sheetnames);
- }
-
- # Add Workbook globals
- $this->_store_bof(0x0005);
-
- $this->_store_externs(); # For print area and repeat rows
-
- $this->_store_names(); # For print area and repeat rows
-
- $this->_store_window1();
-
- $this->_store_1904();
-
- $this->_store_all_fonts();
-
- $this->_store_all_num_formats();
-
- $this->_store_all_xfs();
-
- $this->_store_all_styles();
-
- $this->_store_palette();
-
- $this->_calc_sheet_offsets();
-
- # Add BOUNDSHEET records
- for ($c=0;$c<sizeof($this->_worksheets);$c++) {
- $sheet=$this->_worksheets[$c];
- $this->_store_boundsheet($sheet->_name, $sheet->_offset);
- }
-
- # End Workbook globals
- $this->_store_eof();
-
- # Store the workbook in an OLE container
- $this->_store_OLE_file();
-}
-
-###############################################################################
-#
-# _store_OLE_file()
-#
-# Store the workbook in an OLE container if the total size of the workbook data
-# is less than ~ 7MB.
-#
-function _store_OLE_file() {
-## ABR
- if ($this->_tmpfilename != '') {
- $OLE = new writeexcel_olewriter('/tmp/'.$this->_tmpfilename);
- $OLE->_OLEtmpfilename = '/tmp/'.$this->_tmpfilename;
- } else {
- $OLE = new writeexcel_olewriter($this->_filename);
- $OLE->_OLEtmpfilename = '';
- };
-## END ABR
-
- # Write Worksheet data if data <~ 7MB
- if ($OLE->set_size($this->_biffsize)) {
- $OLE->write_header();
- $OLE->write($this->_data);
-
- for ($c=0;$c<sizeof($this->_worksheets);$c++) {
- $sheet=$this->_worksheets[$c];
- while ($tmp = $sheet->get_data()) {
- $OLE->write($tmp);
- }
- }
- }
-
- $OLE->close();
-}
-
-###############################################################################
-#
-# _calc_sheet_offsets()
-#
-# Calculate offsets for Worksheet BOF records.
-#
-function _calc_sheet_offsets() {
-
- $BOF = 11;
- $EOF = 4;
- $offset = $this->_datasize;
-
- foreach ($this->_worksheets as $sheet) {
- $offset += $BOF + strlen($sheet->_name);
- }
-
- $offset += $EOF;
-
- for ($c=0;$c<sizeof($this->_worksheets);$c++) {
- $sheet=$this->_worksheets[$c];
- $sheet->_offset = $offset;
- $offset += $sheet->_datasize;
- }
-
- $this->_biffsize = $offset;
-}
-
-###############################################################################
-#
-# _store_all_fonts()
-#
-# Store the Excel FONT records.
-#
-function _store_all_fonts() {
- # _tmp_format is added by new(). We use this to write the default XF's
- $format = $this->_tmp_format;
- $font = $format->get_font();
-
- # Note: Fonts are 0-indexed. According to the SDK there is no index 4,
- # so the following fonts are 0, 1, 2, 3, 5
- #
- for ($c=0;$c<5;$c++) {
- $this->_append($font);
- }
-
- # Iterate through the XF objects and write a FONT record if it isn't the
- # same as the default FONT and if it hasn't already been used.
- #
- $index = 6; # The first user defined FONT
-
- $key = $format->get_font_key(); # The default font from _tmp_format
- $fonts[$key] = 0; # Index of the default font
-
- for ($c=0;$c<sizeof($this->_formats);$c++) {
- $format=$this->_formats[$c];
-
- $key = $format->get_font_key();
-
- if (isset($fonts[$key])) {
- # FONT has already been used
- $format->_font_index = $fonts[$key];
- } else {
- # Add a new FONT record
- $fonts[$key] = $index;
- $format->_font_index = $index;
- $index++;
- $font = $format->get_font();
- $this->_append($font);
- }
- }
-}
-
-###############################################################################
-#
-# _store_all_num_formats()
-#
-# Store user defined numerical formats i.e. FORMAT records
-#
-function _store_all_num_formats() {
-
- # Leaning num_format syndrome
- $num_formats_list=array();
- $index = 164;
-
- # Iterate through the XF objects and write a FORMAT record if it isn't a
- # built-in format type and if the FORMAT string hasn't already been used.
- #
-
- for ($c=0;$c<sizeof($this->_formats);$c++) {
- $format=$this->_formats[$c];
-
- $num_format = $format->_num_format;
-
- # Check if $num_format is an index to a built-in format.
- # Also check for a string of zeros, which is a valid format string
- # but would evaluate to zero.
- #
- if (!preg_match('/^0+\d/', $num_format)) {
- if (preg_match('/^\d+$/', $num_format)) {
- # built-in
- continue;
- }
- }
-
- if (isset($num_formats[$num_format])) {
- # FORMAT has already been used
- $format->_num_format = $num_formats[$num_format];
- } else {
- # Add a new FORMAT
- $num_formats[$num_format] = $index;
- $format->_num_format = $index;
- array_push($num_formats_list, $num_format);
- $index++;
- }
- }
-
- # Write the new FORMAT records starting from 0xA4
- $index = 164;
- foreach ($num_formats_list as $num_format) {
- $this->_store_num_format($num_format, $index);
- $index++;
- }
-}
-
-###############################################################################
-#
-# _store_all_xfs()
-#
-# Write all XF records.
-#
-function _store_all_xfs() {
- # _tmp_format is added by new(). We use this to write the default XF's
- # The default font index is 0
- #
- $format = $this->_tmp_format;
- $xf;
-
- for ($c=0;$c<15;$c++) {
- $xf = $format->get_xf('style'); # Style XF
- $this->_append($xf);
- }
-
- $xf = $format->get_xf('cell'); # Cell XF
- $this->_append($xf);
-
- # User defined XFs
- foreach ($this->_formats as $format) {
- $xf = $format->get_xf('cell');
- $this->_append($xf);
- }
-}
-
-###############################################################################
-#
-# _store_all_styles()
-#
-# Write all STYLE records.
-#
-function _store_all_styles() {
- $this->_store_style();
-}
-
-###############################################################################
-#
-# _store_externs()
-#
-# Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for
-# the NAME records.
-#
-function _store_externs() {
-
- # Create EXTERNCOUNT with number of worksheets
- $this->_store_externcount(sizeof($this->_worksheets));
-
- # Create EXTERNSHEET for each worksheet
- foreach ($this->_sheetnames as $sheetname) {
- $this->_store_externsheet($sheetname);
- }
-}
-
-###############################################################################
-#
-# _store_names()
-#
-# Write the NAME record to define the print area and the repeat rows and cols.
-#
-function _store_names() {
-
- # Create the print area NAME records
- foreach ($this->_worksheets as $worksheet) {
- # Write a Name record if the print area has been defined
- if ($worksheet->_print_rowmin!==false) {
- $this->_store_name_short(
- $worksheet->_index,
- 0x06, # NAME type
- $worksheet->_print_rowmin,
- $worksheet->_print_rowmax,
- $worksheet->_print_colmin,
- $worksheet->_print_colmax
- );
- }
- }
-
- # Create the print title NAME records
- foreach ($this->_worksheets as $worksheet) {
-
- $rowmin = $worksheet->_title_rowmin;
- $rowmax = $worksheet->_title_rowmax;
- $colmin = $worksheet->_title_colmin;
- $colmax = $worksheet->_title_colmax;
-
- # Determine if row + col, row, col or nothing has been defined
- # and write the appropriate record
- #
- if ($rowmin!==false && $colmin!==false) {
- # Row and column titles have been defined.
- # Row title has been defined.
- $this->_store_name_long(
- $worksheet->_index,
- 0x07, # NAME type
- $rowmin,
- $rowmax,
- $colmin,
- $colmax
- );
- } elseif ($rowmin!==false) {
- # Row title has been defined.
- $this->_store_name_short(
- $worksheet->_index,
- 0x07, # NAME type
- $rowmin,
- $rowmax,
- 0x00,
- 0xff
- );
- } elseif ($colmin!==false) {
- # Column title has been defined.
- $this->_store_name_short(
- $worksheet->_index,
- 0x07, # NAME type
- 0x0000,
- 0x3fff,
- $colmin,
- $colmax
- );
- } else {
- # Print title hasn't been defined.
- }
- }
-}
-
-###############################################################################
-###############################################################################
-#
-# BIFF RECORDS
-#
-
-###############################################################################
-#
-# _store_window1()
-#
-# Write Excel BIFF WINDOW1 record.
-#
-function _store_window1() {
-
- $record = 0x003D; # Record identifier
- $length = 0x0012; # Number of bytes to follow
-
- $xWn = 0x0000; # Horizontal position of window
- $yWn = 0x0000; # Vertical position of window
- $dxWn = 0x25BC; # Width of window
- $dyWn = 0x1572; # Height of window
-
- $grbit = 0x0038; # Option flags
- $ctabsel = $this->_selected; # Number of workbook tabs selected
- $wTabRatio = 0x0258; # Tab to scrollbar ratio
-
- $itabFirst = $this->_firstsheet; # 1st displayed worksheet
- $itabCur = $this->_activesheet; # Active worksheet
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn,
- $grbit,
- $itabCur, $itabFirst,
- $ctabsel, $wTabRatio);
-
- $this->_append($header . $data);
-}
-
-###############################################################################
-#
-# _store_boundsheet()
-#
-# Writes Excel BIFF BOUNDSHEET record.
-#
-function _store_boundsheet($sheetname, $offset) {
- $record = 0x0085; # Record identifier
- $length = 0x07 + strlen($sheetname); # Number of bytes to follow
-
- //$sheetname = $_[0]; # Worksheet name
- //$offset = $_[1]; # Location of worksheet BOF
- $grbit = 0x0000; # Sheet identifier
- $cch = strlen($sheetname); # Length of sheet name
-
- $header = pack("vv", $record, $length);
- $data = pack("VvC", $offset, $grbit, $cch);
-
- $this->_append($header . $data . $sheetname);
-}
-
-###############################################################################
-#
-# _store_style()
-#
-# Write Excel BIFF STYLE records.
-#
-function _store_style() {
- $record = 0x0293; # Record identifier
- $length = 0x0004; # Bytes to follow
-
- $ixfe = 0x8000; # Index to style XF
- $BuiltIn = 0x00; # Built-in style
- $iLevel = 0xff; # Outline style level
-
- $header = pack("vv", $record, $length);
- $data = pack("vCC", $ixfe, $BuiltIn, $iLevel);
-
- $this->_append($header . $data);
-}
-
-###############################################################################
-#
-# _store_num_format()
-#
-# Writes Excel FORMAT record for non "built-in" numerical formats.
-#
-function _store_num_format($num_format, $index) {
- $record = 0x041E; # Record identifier
- $length = 0x03 + strlen($num_format); # Number of bytes to follow
-
- $format = $num_format; # Custom format string
- $ifmt = $index; # Format index code
- $cch = strlen($format); # Length of format string
-
- $header = pack("vv", $record, $length);
- $data = pack("vC", $ifmt, $cch);
-
- $this->_append($header . $data . $format);
-}
-
-###############################################################################
-#
-# _store_1904()
-#
-# Write Excel 1904 record to indicate the date system in use.
-#
-function _store_1904() {
- $record = 0x0022; # Record identifier
- $length = 0x0002; # Bytes to follow
-
- $f1904 = $this->_1904; # Flag for 1904 date system
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $f1904);
-
- $this->_append($header . $data);
-}
-
-###############################################################################
-#
-# _store_externcount($count)
-#
-# Write BIFF record EXTERNCOUNT to indicate the number of external sheet
-# references in the workbook.
-#
-# Excel only stores references to external sheets that are used in NAME.
-# The workbook NAME record is required to define the print area and the repeat
-# rows and columns.
-#
-# A similar method is used in Worksheet.pm for a slightly different purpose.
-#
-function _store_externcount($par0) {
- $record = 0x0016; # Record identifier
- $length = 0x0002; # Number of bytes to follow
-
- $cxals = $par0; # Number of external references
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $cxals);
-
- $this->_append($header . $data);
-}
-
-###############################################################################
-#
-# _store_externsheet($sheetname)
-#
-#
-# Writes the Excel BIFF EXTERNSHEET record. These references are used by
-# formulas. NAME record is required to define the print area and the repeat
-# rows and columns.
-#
-# A similar method is used in Worksheet.pm for a slightly different purpose.
-#
-function _store_externsheet($par0) {
- $record = 0x0017; # Record identifier
- $length = 0x02 + strlen($par0); # Number of bytes to follow
-
- $sheetname = $par0; # Worksheet name
- $cch = strlen($sheetname); # Length of sheet name
- $rgch = 0x03; # Filename encoding
-
- $header = pack("vv", $record, $length);
- $data = pack("CC", $cch, $rgch);
-
- $this->_append($header . $data . $sheetname);
-}
-
-###############################################################################
-#
-# _store_name_short()
-#
-#
-# Store the NAME record in the short format that is used for storing the print
-# area, repeat rows only and repeat columns only.
-#
-function _store_name_short($par0, $par1, $par2, $par3, $par4, $par5) {
- $record = 0x0018; # Record identifier
- $length = 0x0024; # Number of bytes to follow
-
- $index = $par0; # Sheet index
- $type = $par1;
-
- $grbit = 0x0020; # Option flags
- $chKey = 0x00; # Keyboard shortcut
- $cch = 0x01; # Length of text name
- $cce = 0x0015; # Length of text definition
- $ixals = $index +1; # Sheet index
- $itab = $ixals; # Equal to ixals
- $cchCustMenu = 0x00; # Length of cust menu text
- $cchDescription = 0x00; # Length of description text
- $cchHelptopic = 0x00; # Length of help topic text
- $cchStatustext = 0x00; # Length of status bar text
- $rgch = $type; # Built-in name type
-
- $unknown03 = 0x3b;
- $unknown04 = 0xffff-$index;
- $unknown05 = 0x0000;
- $unknown06 = 0x0000;
- $unknown07 = 0x1087;
- $unknown08 = 0x8005;
-
- $rowmin = $par2; # Start row
- $rowmax = $par3; # End row
- $colmin = $par4; # Start column
- $colmax = $par5; # end column
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $grbit);
- $data .= pack("C", $chKey);
- $data .= pack("C", $cch);
- $data .= pack("v", $cce);
- $data .= pack("v", $ixals);
- $data .= pack("v", $itab);
- $data .= pack("C", $cchCustMenu);
- $data .= pack("C", $cchDescription);
- $data .= pack("C", $cchHelptopic);
- $data .= pack("C", $cchStatustext);
- $data .= pack("C", $rgch);
- $data .= pack("C", $unknown03);
- $data .= pack("v", $unknown04);
- $data .= pack("v", $unknown05);
- $data .= pack("v", $unknown06);
- $data .= pack("v", $unknown07);
- $data .= pack("v", $unknown08);
- $data .= pack("v", $index);
- $data .= pack("v", $index);
- $data .= pack("v", $rowmin);
- $data .= pack("v", $rowmax);
- $data .= pack("C", $colmin);
- $data .= pack("C", $colmax);
-
- $this->_append($header . $data);
-}
-
-###############################################################################
-#
-# _store_name_long()
-#
-#
-# Store the NAME record in the long format that is used for storing the repeat
-# rows and columns when both are specified. This share a lot of code with
-# _store_name_short() but we use a separate method to keep the code clean.
-# Code abstraction for reuse can be carried too far, and I should know. ;-)
-#
-function _store_name_long($par0, $par1, $par2, $par3, $par4, $par5) {
- $record = 0x0018; # Record identifier
- $length = 0x003d; # Number of bytes to follow
-
- $index = $par0; # Sheet index
- $type = $par1;
-
- $grbit = 0x0020; # Option flags
- $chKey = 0x00; # Keyboard shortcut
- $cch = 0x01; # Length of text name
- $cce = 0x002e; # Length of text definition
- $ixals = $index +1; # Sheet index
- $itab = $ixals; # Equal to ixals
- $cchCustMenu = 0x00; # Length of cust menu text
- $cchDescription = 0x00; # Length of description text
- $cchHelptopic = 0x00; # Length of help topic text
- $cchStatustext = 0x00; # Length of status bar text
- $rgch = $type; # Built-in name type
-
- $unknown01 = 0x29;
- $unknown02 = 0x002b;
- $unknown03 = 0x3b;
- $unknown04 = 0xffff-$index;
- $unknown05 = 0x0000;
- $unknown06 = 0x0000;
- $unknown07 = 0x1087;
- $unknown08 = 0x8008;
-
- $rowmin = $par2; # Start row
- $rowmax = $par3; # End row
- $colmin = $par4; # Start column
- $colmax = $par5; # end column
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $grbit);
- $data .= pack("C", $chKey);
- $data .= pack("C", $cch);
- $data .= pack("v", $cce);
- $data .= pack("v", $ixals);
- $data .= pack("v", $itab);
- $data .= pack("C", $cchCustMenu);
- $data .= pack("C", $cchDescription);
- $data .= pack("C", $cchHelptopic);
- $data .= pack("C", $cchStatustext);
- $data .= pack("C", $rgch);
- $data .= pack("C", $unknown01);
- $data .= pack("v", $unknown02);
- # Column definition
- $data .= pack("C", $unknown03);
- $data .= pack("v", $unknown04);
- $data .= pack("v", $unknown05);
- $data .= pack("v", $unknown06);
- $data .= pack("v", $unknown07);
- $data .= pack("v", $unknown08);
- $data .= pack("v", $index);
- $data .= pack("v", $index);
- $data .= pack("v", 0x0000);
- $data .= pack("v", 0x3fff);
- $data .= pack("C", $colmin);
- $data .= pack("C", $colmax);
- # Row definition
- $data .= pack("C", $unknown03);
- $data .= pack("v", $unknown04);
- $data .= pack("v", $unknown05);
- $data .= pack("v", $unknown06);
- $data .= pack("v", $unknown07);
- $data .= pack("v", $unknown08);
- $data .= pack("v", $index);
- $data .= pack("v", $index);
- $data .= pack("v", $rowmin);
- $data .= pack("v", $rowmax);
- $data .= pack("C", 0x00);
- $data .= pack("C", 0xff);
- # End of data
- $data .= pack("C", 0x10);
-
- $this->_append($header . $data);
-}
-
-###############################################################################
-#
-# _store_palette()
-#
-# Stores the PALETTE biff record.
-#
-function _store_palette() {
- $aref = $this->_palette;
-
- $record = 0x0092; # Record identifier
- $length = 2 + 4 * sizeof($aref); # Number of bytes to follow
- $ccv = sizeof($aref); # Number of RGB values to follow
- //$data; # The RGB data
-
- # Pack the RGB data
- foreach($aref as $dat) {
- $data .= call_user_func_array('pack', array_merge(array("CCCC"), $dat));
- }
-
- $header = pack("vvv", $record, $length, $ccv);
-
- $this->_append($header . $data);
-}
-
-}
-
-?>
diff --git a/gosa-core/include/php_writeexcel/class.writeexcel_worksheet.inc.php b/gosa-core/include/php_writeexcel/class.writeexcel_worksheet.inc.php
+++ /dev/null
@@ -1,2951 +0,0 @@
-<?php
-
-/*
- * Copyleft 2002 Johann Hanne
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * This is the Spreadsheet::WriteExcel Perl package ported to PHP
- * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
- */
-
-require_once "class.writeexcel_biffwriter.inc.php";
-
-class writeexcel_worksheet extends writeexcel_biffwriter {
-
- var $_name;
- var $_index;
- var $_activesheet;
- var $_firstsheet;
- var $_url_format;
- var $_parser;
- var $_tempdir;
-
- var $_ext_sheets;
- var $_using_tmpfile;
- var $_filehandle;
- var $_fileclosed;
- var $_offset;
- var $_xls_rowmax;
- var $_xls_colmax;
- var $_xls_strmax;
- var $_dim_rowmin;
- var $_dim_rowmax;
- var $_dim_colmin;
- var $_dim_colmax;
- var $_colinfo;
- var $_selection;
- var $_panes;
- var $_active_pane;
- var $_frozen;
- var $_selected;
-
- var $_paper_size;
- var $_orientation;
- var $_header;
- var $_footer;
- var $_hcenter;
- var $_vcenter;
- var $_margin_head;
- var $_margin_foot;
- var $_margin_left;
- var $_margin_right;
- var $_margin_top;
- var $_margin_bottom;
-
- var $_title_rowmin;
- var $_title_rowmax;
- var $_title_colmin;
- var $_title_colmax;
- var $_print_rowmin;
- var $_print_rowmax;
- var $_print_colmin;
- var $_print_colmax;
-
- var $_print_gridlines;
- var $_screen_gridlines;
- var $_print_headers;
-
- var $_fit_page;
- var $_fit_width;
- var $_fit_height;
-
- var $_hbreaks;
- var $_vbreaks;
-
- var $_protect;
- var $_password;
-
- var $_col_sizes;
- var $_row_sizes;
-
- var $_col_formats;
- var $_row_formats;
-
- var $_zoom;
- var $_print_scale;
-
- /*
- * Constructor. Creates a new Worksheet object from a BIFFwriter object
- */
- function writeexcel_worksheet($name, $index, $activesheet, $firstsheet,
- $url_format, $parser, $tempdir) {
-
- $this->writeexcel_biffwriter();
-
- $rowmax = 65536; // 16384 in Excel 5
- $colmax = 256;
- $strmax = 255;
-
- $this->_name = $name;
- $this->_index = $index;
- $this->_activesheet = $activesheet;
- $this->_firstsheet = $firstsheet;
- $this->_url_format = $url_format;
- $this->_parser = $parser;
- $this->_tempdir = $tempdir;
-
- $this->_ext_sheets = array();
- $this->_using_tmpfile = 1;
- $this->_filehandle = false;
- $this->_fileclosed = 0;
- $this->_offset = 0;
- $this->_xls_rowmax = $rowmax;
- $this->_xls_colmax = $colmax;
- $this->_xls_strmax = $strmax;
- $this->_dim_rowmin = $rowmax +1;
- $this->_dim_rowmax = 0;
- $this->_dim_colmin = $colmax +1;
- $this->_dim_colmax = 0;
- $this->_colinfo = array();
- $this->_selection = array(0, 0);
- $this->_panes = array();
- $this->_active_pane = 3;
- $this->_frozen = 0;
- $this->_selected = 0;
-
- $this->_paper_size = 0x0;
- $this->_orientation = 0x1;
- $this->_header = '';
- $this->_footer = '';
- $this->_hcenter = 0;
- $this->_vcenter = 0;
- $this->_margin_head = 0.50;
- $this->_margin_foot = 0.50;
- $this->_margin_left = 0.75;
- $this->_margin_right = 0.75;
- $this->_margin_top = 1.00;
- $this->_margin_bottom = 1.00;
-
- $this->_title_rowmin = false;
- $this->_title_rowmax = false;
- $this->_title_colmin = false;
- $this->_title_colmax = false;
- $this->_print_rowmin = false;
- $this->_print_rowmax = false;
- $this->_print_colmin = false;
- $this->_print_colmax = false;
-
- $this->_print_gridlines = 1;
- $this->_screen_gridlines = 1;
- $this->_print_headers = 0;
-
- $this->_fit_page = 0;
- $this->_fit_width = 0;
- $this->_fit_height = 0;
-
- $this->_hbreaks = array();
- $this->_vbreaks = array();
-
- $this->_protect = 0;
- $this->_password = false;
-
- $this->_col_sizes = array();
- $this->_row_sizes = array();
-
- $this->_col_formats = array();
- $this->_row_formats = array();
-
- $this->_zoom = 100;
- $this->_print_scale = 100;
-
- $this->_initialize();
- }
-
-###############################################################################
-#
-# _initialize()
-#
-# Open a tmp file to store the majority of the Worksheet data. If this fails,
-# for example due to write permissions, store the data in memory. This can be
-# slow for large files.
-#
-function _initialize() {
-
- # Open tmp file for storing Worksheet data.
- $fh=fopen(tempnam($this->_tempdir, "php_writeexcel"), "w+b");
-
- if ($fh) {
- # Store filehandle
- $this->_filehandle = $fh;
- } else {
- # If tempfile() failed store data in memory
- $this->_using_tmpfile = 0;
-
- if ($this->_index == 0) {
- $dir = $this->_tempdir;
-
-//todo warn "Unable to create temp files in $dir. Refer to set_tempdir()".
-// " in the Spreadsheet::WriteExcel documentation.\n" ;
- }
- }
-}
-
- /*
- * Add data to the beginning of the workbook (note the reverse order)
- * and to the end of the workbook.
- */
- function _close($sheetnames) {
-
- ///////////////////////////////
- // Prepend in reverse order!!
- //
-
- $this->_store_dimensions(); // Prepend the sheet dimensions
- $this->_store_password(); // Prepend the sheet password
- $this->_store_protect(); // Prepend the sheet protection
- $this->_store_setup(); // Prepend the page setup
- $this->_store_margin_bottom(); // Prepend the bottom margin
- $this->_store_margin_top(); // Prepend the top margin
- $this->_store_margin_right(); // Prepend the right margin
- $this->_store_margin_left(); // Prepend the left margin
- $this->_store_vcenter(); // Prepend the page vertical
- // centering
- $this->_store_hcenter(); // Prepend the page horizontal
- // centering
- $this->_store_footer(); // Prepend the page footer
- $this->_store_header(); // Prepend the page header
- $this->_store_vbreak(); // Prepend the vertical page breaks
- $this->_store_hbreak(); // Prepend the horizontal
- // page breaks
- $this->_store_wsbool(); // Prepend WSBOOL
- $this->_store_gridset(); // Prepend GRIDSET
- $this->_store_print_gridlines(); // Prepend PRINTGRIDLINES
- $this->_store_print_headers(); // Prepend PRINTHEADERS
-
- // Prepend EXTERNSHEET references
- $num_sheets = sizeof($sheetnames);
- for ($i = $num_sheets; $i > 0; $i--) {
- $sheetname = $sheetnames[$i-1];
- $this->_store_externsheet($sheetname);
- }
-
- $this->_store_externcount($num_sheets); // Prepend the EXTERNCOUNT
- // of external references.
-
- // Prepend the COLINFO records if they exist
- if (sizeof($this->_colinfo)>0){
- while (sizeof($this->_colinfo)>0) {
- $arrayref = array_pop ($this->_colinfo);
- $this->_store_colinfo($arrayref);
- }
- $this->_store_defcol();
- }
-
- $this->_store_bof(0x0010); // Prepend the BOF record
-
- //
- // End of prepend. Read upwards from here.
- ////////////////////////////////////////////
-
- // Append
- $this->_store_window2();
- $this->_store_zoom();
-
- if (sizeof($this->_panes)>0) {
- $this->_store_panes($this->_panes);
- }
-
- $this->_store_selection($this->_selection);
- $this->_store_eof();
- }
-
- /*
- * Retrieve the worksheet name.
- */
- function get_name() {
- return $this->_name;
- }
-
-###############################################################################
-#
-# get_data().
-#
-# Retrieves data from memory in one chunk, or from disk in $buffer
-# sized chunks.
-#
-function get_data() {
-
- $buffer = 4096;
-
- # Return data stored in memory
- if ($this->_data!==false) {
- $tmp = $this->_data;
- $this->_data=false;
- $fh = $this->_filehandle;
- if ($this->_using_tmpfile) {
- fseek($fh, 0, SEEK_SET);
- }
-
- if ($this->_debug) {
- print "*** worksheet::get_data() called (1):";
- for ($c=0;$c<strlen($tmp);$c++) {
- if ($c%16==0) {
- print "\n";
- }
- printf("%02X ", ord($tmp[$c]));
- }
- print "\n";
- }
-
- return $tmp;
- }
-
- # Return data stored on disk
- if ($this->_using_tmpfile) {
- if ($tmp=fread($this->_filehandle, $buffer)) {
-
- if ($this->_debug) {
- print "*** worksheet::get_data() called (2):";
- for ($c=0;$c<strlen($tmp);$c++) {
- if ($c%16==0) {
- print "\n";
- }
- printf("%02X ", ord($tmp[$c]));
- }
- print "\n";
- }
-
- return $tmp;
- }
- }
-
- # No data to return
- return false;
-}
-
- /*
- * Set this worksheet as a selected worksheet, i.e. the worksheet has
- * its tab highlighted.
- */
- function select() {
- $this->_selected = 1;
- }
-
- /*
- * Set this worksheet as the active worksheet, i.e. the worksheet
- * that is displayed when the workbook is opened. Also set it as
- * selected.
- */
- function activate() {
- $this->_selected = 1;
- $this->_activesheet = $this->_index;
- }
-
- /*
- * Set this worksheet as the first visible sheet. This is necessary
- * when there are a large number of worksheets and the activated
- * worksheet is not visible on the screen.
- */
- function set_first_sheet() {
- $this->_firstsheet = $this->_index;
- }
-
- /*
- * Set the worksheet protection flag to prevent accidental modification
- * and to hide formulas if the locked and hidden format properties have
- * been set.
- */
- function protect($password) {
- $this->_protect = 1;
- $this->_password = $this->_encode_password($password);
- }
-
-###############################################################################
-#
-# set_column($firstcol, $lastcol, $width, $format, $hidden)
-#
-# Set the width of a single column or a range of column.
-# See also: _store_colinfo
-#
-function set_column() {
-
- $_=func_get_args();
-
- $cell = $_[0];
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $cell)) {
- $_ = $this->_substitute_cellref($_);
- }
-
- array_push($this->_colinfo, $_);
-
- # Store the col sizes for use when calculating image vertices taking
- # hidden columns into account. Also store the column formats.
- #
- if (sizeof($_)<3) {
- # Ensure at least $firstcol, $lastcol and $width
- return;
- }
-
- $width = $_[4] ? 0 : $_[2]; # Set width to zero if column is hidden
- $format = $_[3];
-
- list($firstcol, $lastcol) = $_;
-
- for ($col=$firstcol;$col<=$lastcol;$col++) {
- $this->_col_sizes[$col] = $width;
- if ($format) {
- $this->_col_formats[$col] = $format;
- }
- }
-}
-
-###############################################################################
-#
-# set_selection()
-#
-# Set which cell or cells are selected in a worksheet: see also the
-# function _store_selection
-#
-function set_selection() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- $this->_selection = $_;
-}
-
-###############################################################################
-#
-# freeze_panes()
-#
-# Set panes and mark them as frozen. See also _store_panes().
-#
-function freeze_panes() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- $this->_frozen = 1;
- $this->_panes = $_;
-}
-
-###############################################################################
-#
-# thaw_panes()
-#
-# Set panes and mark them as unfrozen. See also _store_panes().
-#
-function thaw_panes() {
-
- $_=func_get_args();
-
- $this->_frozen = 0;
- $this->_panes = $_;
-}
-
- /*
- * Set the page orientation as portrait.
- */
- function set_portrait() {
- $this->_orientation = 1;
- }
-
- /*
- * Set the page orientation as landscape.
- */
- function set_landscape() {
- $this->_orientation = 0;
- }
-
- /*
- * Set the paper type. Ex. 1 = US Letter, 9 = A4
- */
- function set_paper($type) {
- $this->_paper_size = $type;
- }
-
- /*
- * Set the page header caption and optional margin.
- */
- function set_header($string, $margin) {
-
- if (strlen($string) >= 255) {
- trigger_error("Header string must be less than 255 characters",
- E_USER_WARNING);
- return;
- }
-
- $this->_header = $string;
- $this->_margin_head = $margin;
- }
-
- /*
- * Set the page footer caption and optional margin.
- */
- function set_footer($string, $margin) {
- if (strlen($string) >= 255) {
- trigger_error("Footer string must be less than 255 characters",
- E_USER_WARNING);
- return;
- }
-
- $this->_footer = $string;
- $this->_margin_foot = $margin;
- }
-
- /*
- * Center the page horizontally.
- */
- function center_horizontally($hcenter=1) {
- $this->_hcenter = $hcenter;
- }
-
- /*
- * Center the page horizontally.
- */
- function center_vertically($vcenter=1) {
- $this->_vcenter = $vcenter;
- }
-
- /*
- * Set all the page margins to the same value in inches.
- */
- function set_margins($margin) {
- $this->set_margin_left($margin);
- $this->set_margin_right($margin);
- $this->set_margin_top($margin);
- $this->set_margin_bottom($margin);
- }
-
- /*
- * Set the left and right margins to the same value in inches.
- */
- function set_margins_LR($margin) {
- $this->set_margin_left($margin);
- $this->set_margin_right($margin);
- }
-
- /*
- * Set the top and bottom margins to the same value in inches.
- */
- function set_margins_TB($margin) {
- $this->set_margin_top($margin);
- $this->set_margin_bottom($margin);
- }
-
- /*
- * Set the left margin in inches.
- */
- function set_margin_left($margin=0.75) {
- $this->_margin_left = $margin;
- }
-
- /*
- * Set the right margin in inches.
- */
- function set_margin_right($margin=0.75) {
- $this->_margin_right = $margin;
- }
-
- /*
- * Set the top margin in inches.
- */
- function set_margin_top($margin=1.00) {
- $this->_margin_top = $margin;
- }
-
- /*
- * Set the bottom margin in inches.
- */
- function set_margin_bottom($margin=1.00) {
- $this->_margin_bottom = $margin;
- }
-
-###############################################################################
-#
-# repeat_rows($first_row, $last_row)
-#
-# Set the rows to repeat at the top of each printed page. See also the
-# _store_name_xxxx() methods in Workbook.pm.
-#
-function repeat_rows() {
-
- $_=func_get_args();
-
- $this->_title_rowmin = $_[0];
- $this->_title_rowmax = isset($_[1]) ? $_[1] : $_[0]; # Second row is optional
-}
-
-###############################################################################
-#
-# repeat_columns($first_col, $last_col)
-#
-# Set the columns to repeat at the left hand side of each printed page.
-# See also the _store_names() methods in Workbook.pm.
-#
-function repeat_columns() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- $this->_title_colmin = $_[0];
- $this->_title_colmax = isset($_[1]) ? $_[1] : $_[0]; # Second col is optional
-}
-
-###############################################################################
-#
-# print_area($first_row, $first_col, $last_row, $last_col)
-#
-# Set the area of each worksheet that will be printed. See also the
-# _store_names() methods in Workbook.pm.
-#
-function print_area() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- if (sizeof($_) != 4) {
- # Require 4 parameters
- return;
- }
-
- $this->_print_rowmin = $_[0];
- $this->_print_colmin = $_[1];
- $this->_print_rowmax = $_[2];
- $this->_print_colmax = $_[3];
-}
-
- /*
- * Set the option to hide gridlines on the screen and the printed page.
- * There are two ways of doing this in the Excel BIFF format: The first
- * is by setting the DspGrid field of the WINDOW2 record, this turns off
- * the screen and subsequently the print gridline. The second method is
- * to via the PRINTGRIDLINES and GRIDSET records, this turns off the
- * printed gridlines only. The first method is probably sufficient for
- * most cases. The second method is supported for backwards compatibility.
- */
- function hide_gridlines($option=1) {
- if ($option == 0) {
- $this->_print_gridlines = 1; # 1 = display, 0 = hide
- $this->_screen_gridlines = 1;
- } elseif ($option == 1) {
- $this->_print_gridlines = 0;
- $this->_screen_gridlines = 1;
- } else {
- $this->_print_gridlines = 0;
- $this->_screen_gridlines = 0;
- }
- }
-
- /*
- * Set the option to print the row and column headers on the printed page.
- * See also the _store_print_headers() method below.
- */
- function print_row_col_headers($headers=1) {
- $this->_print_headers = $headers;
- }
-
- /*
- * Store the vertical and horizontal number of pages that will define
- * the maximum area printed. See also _store_setup() and _store_wsbool()
- * below.
- */
- function fit_to_pages($width, $height) {
- $this->_fit_page = 1;
- $this->_fit_width = $width;
- $this->_fit_height = $height;
- }
-
- /*
- * Store the horizontal page breaks on a worksheet.
- */
- function set_h_pagebreaks($breaks) {
- $this->_hbreaks=array_merge($this->_hbreaks, $breaks);
- }
-
- /*
- * Store the vertical page breaks on a worksheet.
- */
- function set_v_pagebreaks($breaks) {
- $this->_vbreaks=array_merge($this->_vbreaks, $breaks);
- }
-
- /*
- * Set the worksheet zoom factor.
- */
- function set_zoom($scale=100) {
- // Confine the scale to Excel's range
- if ($scale < 10 || $scale > 400) {
- trigger_error("Zoom factor $scale outside range: ".
- "10 <= zoom <= 400", E_USER_WARNING);
- $scale = 100;
- }
-
- $this->_zoom = $scale;
- }
-
- /*
- * Set the scale factor for the printed page.
- */
- function set_print_scale($scale=100) {
- // Confine the scale to Excel's range
- if ($scale < 10 || $scale > 400) {
- trigger_error("Print scale $scale outside range: ".
- "10 <= zoom <= 400", E_USER_WARNING);
- $scale = 100;
- }
-
- // Turn off "fit to page" option
- $this->_fit_page = 0;
-
- $this->_print_scale = $scale;
- }
-
-###############################################################################
-#
-# write($row, $col, $token, $format)
-#
-# Parse $token call appropriate write method. $row and $column are zero
-# indexed. $format is optional.
-#
-# Returns: return value of called subroutine
-#
-function write() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- $token = $_[2];
-
- # Match an array ref.
- if (is_array($token)) {
- return call_user_method_array('write_row', $this, $_);
- }
-
- # Match number
- if (preg_match('/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/', $token)) {
- return call_user_method_array('write_number', $this, $_);
- }
- # Match http, https or ftp URL
- elseif (preg_match('|^[fh]tt?ps?://|', $token)) {
- return call_user_method_array('write_url', $this, $_);
- }
- # Match mailto:
- elseif (preg_match('/^mailto:/', $token)) {
- return call_user_method_array('write_url', $this, $_);
- }
- # Match internal or external sheet link
- elseif (preg_match('[^(?:in|ex)ternal:]', $token)) {
- return call_user_method_array('write_url', $this, $_);
- }
- # Match formula
- elseif (preg_match('/^=/', $token)) {
- return call_user_method_array('write_formula', $this, $_);
- }
- # Match blank
- elseif ($token == '') {
- array_splice($_, 2, 1); # remove the empty string from the parameter list
- return call_user_method_array('write_blank', $this, $_);
- }
- # Default: match string
- else {
- return call_user_method_array('write_string', $this, $_);
- }
-}
-
-###############################################################################
-#
-# write_row($row, $col, $array_ref, $format)
-#
-# Write a row of data starting from ($row, $col). Call write_col() if any of
-# the elements of the array ref are in turn array refs. This allows the writing
-# of 1D or 2D arrays of data in one go.
-#
-# Returns: the first encountered error value or zero for no errors
-#
-function write_row() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- # Catch non array refs passed by user.
- if (!is_array($_[2])) {
- trigger_error("Not an array ref in call to write_row()!", E_USER_ERROR);
- }
-
- list($row, $col, $tokens)=array_splice($_, 0, 3);
- $options = $_[0];
- $error = 0;
-
- foreach ($tokens as $token) {
-
- # Check for nested arrays
- if (is_array($token)) {
- $ret = $this->write_col($row, $col, $token, $options);
- } else {
- $ret = $this->write ($row, $col, $token, $options);
- }
-
- # Return only the first error encountered, if any.
- $error = $error || $ret;
- $col++;
- }
-
- return $error;
-}
-
-###############################################################################
-#
-# _XF()
-#
-# Returns an index to the XF record in the workbook.
-# TODO
-#
-# Note: this is a function, not a method.
-#
-function _XF($row=false, $col=false, $format=false) {
-
- if ($format) {
- return $format->get_xf_index();
- } elseif (isset($this->_row_formats[$row])) {
- return $this->_row_formats[$row]->get_xf_index();
- } elseif (isset($this->_col_formats[$col])) {
- return $this->_col_formats[$col]->get_xf_index();
- } else {
- return 0x0F;
- }
-}
-
-###############################################################################
-#
-# write_col($row, $col, $array_ref, $format)
-#
-# Write a column of data starting from ($row, $col). Call write_row() if any of
-# the elements of the array ref are in turn array refs. This allows the writing
-# of 1D or 2D arrays of data in one go.
-#
-# Returns: the first encountered error value or zero for no errors
-#
-function write_col() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- # Catch non array refs passed by user.
- if (!is_array($_[2])) {
- trigger_error("Not an array ref in call to write_row()!", E_USER_ERROR);
- }
-
- $row = array_shift($_);
- $col = array_shift($_);
- $tokens = array_shift($_);
- $options = $_;
-
- $error = 0;
-
- foreach ($tokens as $token) {
-
- # write() will deal with any nested arrays
- $ret = $this->write($row, $col, $token, $options);
-
- # Return only the first error encountered, if any.
- $error = $error || $ret;
- $row++;
- }
-
- return $error;
-}
-
-###############################################################################
-###############################################################################
-#
-# Internal methods
-#
-
-###############################################################################
-#
-# _append(), overloaded.
-#
-# Store Worksheet data in memory using the base class _append() or to a
-# temporary file, the default.
-#
-function _append($data) {
-
- if (func_num_args()>1) {
- trigger_error("writeexcel_worksheet::_append() ".
- "called with more than one argument", E_USER_ERROR);
- }
-
- if ($this->_using_tmpfile) {
-
- if ($this->_debug) {
- print "worksheet::_append() called:";
- for ($c=0;$c<strlen($data);$c++) {
- if ($c%16==0) {
- print "\n";
- }
- printf("%02X ", ord($data[$c]));
- }
- print "\n";
- }
-
- # Add CONTINUE records if necessary
- if (strlen($data) > $this->_limit) {
- $data = $this->_add_continue($data);
- }
-
- fputs($this->_filehandle, $data);
- $this->_datasize += strlen($data);
- } else {
- parent::_append($data);
- }
-}
-
-###############################################################################
-#
-# _substitute_cellref()
-#
-# Substitute an Excel cell reference in A1 notation for zero based row and
-# column values in an argument list.
-#
-# Ex: ("A4", "Hello") is converted to (3, 0, "Hello").
-#
-// Exactly one array must be passed!
-function _substitute_cellref($_) {
- $cell = strtoupper(array_shift($_));
-
- # Convert a column range: 'A:A' or 'B:G'
- if (preg_match('/([A-I]?[A-Z]):([A-I]?[A-Z])/', $cell, $reg)) {
- list($dummy, $col1) = $this->_cell_to_rowcol($reg[1] .'1'); # Add a dummy row
- list($dummy, $col2) = $this->_cell_to_rowcol($reg[2] .'1'); # Add a dummy row
- return array_merge(array($col1, $col2), $_);
- }
-
- # Convert a cell range: 'A1:B7'
- if (preg_match('/\$?([A-I]?[A-Z]\$?\d+):\$?([A-I]?[A-Z]\$?\d+)/', $cell, $reg)) {
- list($row1, $col1) = $this->_cell_to_rowcol($reg[1]);
- list($row2, $col2) = $this->_cell_to_rowcol($reg[2]);
- return array_merge(array($row1, $col1, $row2, $col2), $_);
- }
-
- # Convert a cell reference: 'A1' or 'AD2000'
- if (preg_match('/\$?([A-I]?[A-Z]\$?\d+)/', $cell, $reg)) {
- list($row1, $col1) = $this->_cell_to_rowcol($reg[1]);
- return array_merge(array($row1, $col1), $_);
-
- }
-
- trigger_error("Unknown cell reference $cell", E_USER_ERROR);
-}
-
-###############################################################################
-#
-# _cell_to_rowcol($cell_ref)
-#
-# Convert an Excel cell reference in A1 notation to a zero based row and column
-# reference; converts C1 to (0, 2).
-#
-# Returns: row, column
-#
-# TODO use functions in Utility.pm
-#
-function _cell_to_rowcol($cell) {
-
- preg_match('/\$?([A-I]?[A-Z])\$?(\d+)/', $cell, $reg);
-
- $col = $reg[1];
- $row = $reg[2];
-
- # Convert base26 column string to number
- # All your Base are belong to us.
- $chars = preg_split('//', $col, -1, PREG_SPLIT_NO_EMPTY);
- $expn = 0;
- $col = 0;
-
- while (sizeof($chars)) {
- $char = array_pop($chars); # LS char first
- $col += (ord($char) -ord('A') +1) * pow(26, $expn);
- $expn++;
- }
-
- # Convert 1-index to zero-index
- $row--;
- $col--;
-
- return array($row, $col);
-}
-
- /*
- * This is an internal method that is used to filter elements of the
- * array of pagebreaks used in the _store_hbreak() and _store_vbreak()
- * methods. It:
- * 1. Removes duplicate entries from the list.
- * 2. Sorts the list.
- * 3. Removes 0 from the list if present.
- */
- function _sort_pagebreaks($breaks) {
- // Hash slice to remove duplicates
- foreach ($breaks as $break) {
- $hash["$break"]=1;
- }
-
- // Numerical sort
- $breaks=array_keys($hash);
- sort($breaks, SORT_NUMERIC);
-
- // Remove zero
- if ($breaks[0] == 0) {
- array_shift($breaks);
- }
-
- // 1000 vertical pagebreaks appears to be an internal Excel 5 limit.
- // It is slightly higher in Excel 97/200, approx. 1026
- if (sizeof($breaks) > 1000) {
- array_splice($breaks, 1000);
- }
-
- return $breaks;
- }
-
- /*
- * Based on the algorithm provided by Daniel Rentz of OpenOffice.
- */
- function _encode_password($plaintext) {
- $chars=preg_split('//', $plaintext, -1, PREG_SPLIT_NO_EMPTY);
- $count=sizeof($chars);
-
- for ($c=0;$c<sizeof($chars);$c++) {
- $char=$chars[$c];
- $char = ord($char) << ++$i;
- $low_15 = $char & 0x7fff;
- $high_15 = $char & 0x7fff << 15;
- $high_15 = $high_15 >> 15;
- $char = $low_15 | $high_15;
- }
-
- $password = 0x0000;
-
- foreach ($chars as $char) {
- $password ^= $char;
- }
-
- $password ^= $count;
- $password ^= 0xCE4B;
-
- return $password;
- }
-
-###############################################################################
-###############################################################################
-#
-# BIFF RECORDS
-#
-
-###############################################################################
-#
-# write_number($row, $col, $num, $format)
-#
-# Write a double to the specified row and column (zero indexed).
-# An integer can be written as a double. Excel will display an
-# integer. $format is optional.
-#
-# Returns 0 : normal termination
-# -1 : insufficient number of arguments
-# -2 : row or column out of range
-#
-function write_number() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- # Check the number of args
- if (sizeof($_) < 3) {
- return -1;
- }
-
- $record = 0x0203; # Record identifier
- $length = 0x000E; # Number of bytes to follow
-
- $row = $_[0]; # Zero indexed row
- $col = $_[1]; # Zero indexed column
- $num = $_[2];
-//!!!
- $xf = $this->_XF($row, $col, $_[3]); # The cell format
-
- # Check that row and col are valid and store max and min values
- if ($row >= $this->_xls_rowmax) { return -2; }
- if ($col >= $this->_xls_colmax) { return -2; }
- if ($row < $this->_dim_rowmin) { $this->_dim_rowmin = $row; }
- if ($row > $this->_dim_rowmax) { $this->_dim_rowmax = $row; }
- if ($col < $this->_dim_colmin) { $this->_dim_colmin = $col; }
- if ($col > $this->_dim_colmax) { $this->_dim_colmax = $col; }
-
- $header = pack("vv", $record, $length);
- $data = pack("vvv", $row, $col, $xf);
- $xl_double = pack("d", $num);
-
- if ($this->_byte_order) {
-//TODO
- $xl_double = strrev($xl_double);
- }
-
- $this->_append($header . $data . $xl_double);
-
- return 0;
-}
-
-###############################################################################
-#
-# write_string ($row, $col, $string, $format)
-#
-# Write a string to the specified row and column (zero indexed).
-# NOTE: there is an Excel 5 defined limit of 255 characters.
-# $format is optional.
-# Returns 0 : normal termination
-# -1 : insufficient number of arguments
-# -2 : row or column out of range
-# -3 : long string truncated to 255 chars
-#
-function write_string() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- # Check the number of args
- if (sizeof($_) < 3) {
- return -1;
- }
-
- $record = 0x0204; # Record identifier
- $length = 0x0008 + strlen($_[2]); # Bytes to follow
-
- $row = $_[0]; # Zero indexed row
- $col = $_[1]; # Zero indexed column
- $strlen = strlen($_[2]);
- $str = $_[2];
- $xf = $this->_XF($row, $col, $_[3]); # The cell format
-
- $str_error = 0;
-
- # Check that row and col are valid and store max and min values
- if ($row >= $this->_xls_rowmax) { return -2; }
- if ($col >= $this->_xls_colmax) { return -2; }
- if ($row < $this->_dim_rowmin) { $this->_dim_rowmin = $row; }
- if ($row > $this->_dim_rowmax) { $this->_dim_rowmax = $row; }
- if ($col < $this->_dim_colmin) { $this->_dim_colmin = $col; }
- if ($col > $this->_dim_colmax) { $this->_dim_colmax = $col; }
-
- if ($strlen > $this->_xls_strmax) { # LABEL must be < 255 chars
- $str = substr($str, 0, $this->_xls_strmax);
- $length = 0x0008 + $this->_xls_strmax;
- $strlen = $this->_xls_strmax;
- $str_error = -3;
- }
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvv", $row, $col, $xf, $strlen);
-
- $this->_append($header . $data . $str);
-
- return $str_error;
-}
-
-###############################################################################
-#
-# write_blank($row, $col, $format)
-#
-# Write a blank cell to the specified row and column (zero indexed).
-# A blank cell is used to specify formatting without adding a string
-# or a number.
-#
-# A blank cell without a format serves no purpose. Therefore, we don't write
-# a BLANK record unless a format is specified. This is mainly an optimisation
-# for the write_row() and write_col() methods.
-#
-# Returns 0 : normal termination (including no format)
-# -1 : insufficient number of arguments
-# -2 : row or column out of range
-#
-function write_blank() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- # Check the number of args
- if (sizeof($_) < 2) {
- return -1;
- }
-
- # Don't write a blank cell unless it has a format
- if (!isset($_[2])) {
- return 0;
- }
-
- $record = 0x0201; # Record identifier
- $length = 0x0006; # Number of bytes to follow
-
- $row = $_[0]; # Zero indexed row
- $col = $_[1]; # Zero indexed column
- $xf = $this->_XF($row, $col, $_[2]); # The cell format
-
- # Check that row and col are valid and store max and min values
- if ($row >= $this->_xls_rowmax) { return -2; }
- if ($col >= $this->_xls_colmax) { return -2; }
- if ($row < $this->_dim_rowmin) { $this->_dim_rowmin = $row; }
- if ($row > $this->_dim_rowmax) { $this->_dim_rowmax = $row; }
- if ($col < $this->_dim_colmin) { $this->_dim_colmin = $col; }
- if ($col > $this->_dim_colmax) { $this->_dim_colmax = $col; }
-
- $header = pack("vv", $record, $length);
- $data = pack("vvv", $row, $col, $xf);
-
- $this->_append($header . $data);
-
- return 0;
-}
-
-###############################################################################
-#
-# write_formula($row, $col, $formula, $format)
-#
-# Write a formula to the specified row and column (zero indexed).
-# The textual representation of the formula is passed to the parser in
-# Formula.pm which returns a packed binary string.
-#
-# $format is optional.
-#
-# Returns 0 : normal termination
-# -1 : insufficient number of arguments
-# -2 : row or column out of range
-#
-function write_formula() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- # Check the number of args
- if (sizeof($_) < 3) {
- return -1;
- }
-
- $record = 0x0006; # Record identifier
- $length=0; # Bytes to follow
-
- $row = $_[0]; # Zero indexed row
- $col = $_[1]; # Zero indexed column
- $formula = $_[2]; # The formula text string
-
- # Excel normally stores the last calculated value of the formula in $num.
- # Clearly we are not in a position to calculate this a priori. Instead
- # we set $num to zero and set the option flags in $grbit to ensure
- # automatic calculation of the formula when the file is opened.
- #
- $xf = $this->_XF($row, $col, $_[3]); # The cell format
- $num = 0x00; # Current value of formula
- $grbit = 0x03; # Option flags
- $chn = 0x0000; # Must be zero
-
- # Check that row and col are valid and store max and min values
- if ($row >= $this->_xls_rowmax) { return -2; }
- if ($col >= $this->_xls_colmax) { return -2; }
- if ($row < $this->_dim_rowmin) { $this->_dim_rowmin = $row; }
- if ($row > $this->_dim_rowmax) { $this->_dim_rowmax = $row; }
- if ($col < $this->_dim_colmin) { $this->_dim_colmin = $col; }
- if ($col > $this->_dim_colmax) { $this->_dim_colmax = $col; }
-
- # Strip the = sign at the beginning of the formula string
- $formula = preg_replace('/^=/', "", $formula);
-
- # Parse the formula using the parser in Formula.pm
- $parser = $this->_parser;
- $formula = $parser->parse_formula($formula);
-
- $formlen = strlen($formula); # Length of the binary string
- $length = 0x16 + $formlen; # Length of the record data
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvdvVv", $row, $col, $xf, $num,
- $grbit, $chn, $formlen);
-
- $this->_append($header . $data . $formula);
-
- return 0;
-}
-
-###############################################################################
-#
-# write_url($row, $col, $url, $string, $format)
-#
-# Write a hyperlink. This is comprised of two elements: the visible label and
-# the invisible link. The visible label is the same as the link unless an
-# alternative string is specified. The label is written using the
-# write_string() method. Therefore the 255 characters string limit applies.
-# $string and $format are optional and their order is interchangeable.
-#
-# The hyperlink can be to a http, ftp, mail, internal sheet, or external
-# directory url.
-#
-# Returns 0 : normal termination
-# -1 : insufficient number of arguments
-# -2 : row or column out of range
-# -3 : long string truncated to 255 chars
-#
-function write_url() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- # Check the number of args
- if (sizeof($_) < 3) {
- return -1;
- }
-
- # Add start row and col to arg list
- return call_user_method_array('write_url_range', $this,
- array_merge(array($_[0], $_[1]), $_));
-}
-
-###############################################################################
-#
-# write_url_range($row1, $col1, $row2, $col2, $url, $string, $format)
-#
-# This is the more general form of write_url(). It allows a hyperlink to be
-# written to a range of cells. This function also decides the type of hyperlink
-# to be written. These are either, Web (http, ftp, mailto), Internal
-# (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1').
-#
-# See also write_url() above for a general description and return values.
-#
-function write_url_range() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- # Check the number of args
- if (sizeof($_) < 5) {
- return -1;
- }
-
- # Reverse the order of $string and $format if necessary.
-//TODO ($_[5], $_[6]) = ($_[6], $_[5]) if (ref $_[5]);
-
- $url = $_[4];
-
- # Check for internal/external sheet links or default to web link
- if (preg_match('[^internal:]', $url)) {
- return call_user_method_array('_write_url_internal', $this, $_);
- }
-
- if (preg_match('[^external:]', $url)) {
- return call_user_method_array('_write_url_external', $this, $_);
- }
-
- return call_user_method_array('_write_url_web', $this, $_);
-}
-
-###############################################################################
-#
-# _write_url_web($row1, $col1, $row2, $col2, $url, $string, $format)
-#
-# Used to write http, ftp and mailto hyperlinks.
-# The link type ($options) is 0x03 is the same as absolute dir ref without
-# sheet. However it is differentiated by the $unknown2 data stream.
-#
-# See also write_url() above for a general description and return values.
-#
-function _write_url_web() {
-
- $_=func_get_args();
-
- $record = 0x01B8; # Record identifier
- $length = 0x00000; # Bytes to follow
-
- $row1 = $_[0]; # Start row
- $col1 = $_[1]; # Start column
- $row2 = $_[2]; # End row
- $col2 = $_[3]; # End column
- $url = $_[4]; # URL string
- if (isset($_[5])) {
- $str = $_[5]; # Alternative label
- }
- $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format
-
- # Write the visible label using the write_string() method.
- if(!isset($str)) {
- $str = $url;
- }
-
- $str_error = $this->write_string($row1, $col1, $str, $xf);
-
- if ($str_error == -2) {
- return $str_error;
- }
-
- # Pack the undocumented parts of the hyperlink stream
- $unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
- $unknown2 = pack("H*", "E0C9EA79F9BACE118C8200AA004BA90B");
-
- # Pack the option flags
- $options = pack("V", 0x03);
-
- # Convert URL to a null terminated wchar string
- $url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY));
- $url = $url . "\0\0\0";
-
- # Pack the length of the URL
- $url_len = pack("V", strlen($url));
-
- # Calculate the data length
- $length = 0x34 + strlen($url);
-
- # Pack the header data
- $header = pack("vv", $record, $length);
- $data = pack("vvvv", $row1, $row2, $col1, $col2);
-
- # Write the packed data
- $this->_append($header.
- $data.
- $unknown1.
- $options.
- $unknown2.
- $url_len.
- $url);
-
- return $str_error;
-}
-
-###############################################################################
-#
-# _write_url_internal($row1, $col1, $row2, $col2, $url, $string, $format)
-#
-# Used to write internal reference hyperlinks such as "Sheet1!A1".
-#
-# See also write_url() above for a general description and return values.
-#
-function _write_url_internal() {
-
- $_=func_get_args();
-
- $record = 0x01B8; # Record identifier
- $length = 0x00000; # Bytes to follow
-
- $row1 = $_[0]; # Start row
- $col1 = $_[1]; # Start column
- $row2 = $_[2]; # End row
- $col2 = $_[3]; # End column
- $url = $_[4]; # URL string
- if (isset($_[5])) {
- $str = $_[5]; # Alternative label
- }
- $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format
-
- # Strip URL type
- $url = preg_replace('s[^internal:]', '', $url);
-
- # Write the visible label
- if (!isset($str)) {
- $str = $url;
- }
- $str_error = $this->write_string($row1, $col1, $str, $xf);
-
- if ($str_error == -2) {
- return $str_error;
- }
-
- # Pack the undocumented parts of the hyperlink stream
- $unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
-
- # Pack the option flags
- $options = pack("V", 0x08);
-
- # Convert the URL type and to a null terminated wchar string
- $url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY));
- $url = $url . "\0\0\0";
-
- # Pack the length of the URL as chars (not wchars)
- $url_len = pack("V", int(strlen($url)/2));
-
- # Calculate the data length
- $length = 0x24 + strlen($url);
-
- # Pack the header data
- $header = pack("vv", $record, $length);
- $data = pack("vvvv", $row1, $row2, $col1, $col2);
-
- # Write the packed data
- $this->_append($header.
- $data.
- $unknown1.
- $options.
- $url_len.
- $url);
-
- return $str_error;
-}
-
-###############################################################################
-#
-# _write_url_external($row1, $col1, $row2, $col2, $url, $string, $format)
-#
-# Write links to external directory names such as 'c:\foo.xls',
-# c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'.
-#
-# Note: Excel writes some relative links with the $dir_long string. We ignore
-# these cases for the sake of simpler code.
-#
-# See also write_url() above for a general description and return values.
-#
-function _write_url_external() {
-
- $_=func_get_args();
-
- # Network drives are different. We will handle them separately
- # MS/Novell network drives and shares start with \\
- if (preg_match('[^external:\\\\]', $_[4])) {
- return call_user_method_array('_write_url_external_net', $this, $_);
- }
-
- $record = 0x01B8; # Record identifier
- $length = 0x00000; # Bytes to follow
-
- $row1 = $_[0]; # Start row
- $col1 = $_[1]; # Start column
- $row2 = $_[2]; # End row
- $col2 = $_[3]; # End column
- $url = $_[4]; # URL string
- if (isset($_[5])) {
- $str = $_[5]; # Alternative label
- }
- $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format
-
- # Strip URL type and change Unix dir separator to Dos style (if needed)
- #
- $url = preg_replace('[^external:]', '', $url);
- $url = preg_replace('[/]', "\\", $url);
-
- # Write the visible label
- if (!isset($str)) {
- $str = preg_replace('[\#]', ' - ', $url);
- }
- $str_error = $this->write_string($row1, $col1, $str, $xf);
- if ($str_error == -2) {
- return $str_error;
- }
-
- # Determine if the link is relative or absolute:
- # relative if link contains no dir separator, "somefile.xls"
- # relative if link starts with up-dir, "..\..\somefile.xls"
- # otherwise, absolute
- #
- $absolute = 0x02; # Bit mask
-
- if (!preg_match('[\\]', $url)) {
- $absolute = 0x00;
- }
-
- if (preg_match('[^\.\.\\]', $url)) {
- $absolute = 0x00;
- }
-
- # Determine if the link contains a sheet reference and change some of the
- # parameters accordingly.
- # Split the dir name and sheet name (if it exists)
- #
- list($dir_long, $sheet) = preg_split('/\#/', $url);
- $link_type = 0x01 | $absolute;
-
-//!!!
- if (isset($sheet)) {
- $link_type |= 0x08;
- $sheet_len = pack("V", length($sheet) + 0x01);
- $sheet = join("\0", split('', $sheet));
- $sheet .= "\0\0\0";
- } else {
- $sheet_len = '';
- $sheet = '';
- }
-
- # Pack the link type
- $link_type = pack("V", $link_type);
-
-
- # Calculate the up-level dir count e.g.. (..\..\..\ == 3)
-/* TODO
- $up_count = 0;
- $up_count++ while $dir_long =~ s[^\.\.\\][];
- $up_count = pack("v", $up_count);
-*/
-
- # Store the short dos dir name (null terminated)
- $dir_short = $dir_long . "\0";
-
- # Store the long dir name as a wchar string (non-null terminated)
- $dir_long = join("\0", preg_split('', $dir_long, -1, PREG_SPLIT_NO_EMPTY));
- $dir_long = $dir_long . "\0";
-
- # Pack the lengths of the dir strings
- $dir_short_len = pack("V", strlen($dir_short) );
- $dir_long_len = pack("V", strlen($dir_long) );
- $stream_len = pack("V", strlen($dir_long) + 0x06);
-
- # Pack the undocumented parts of the hyperlink stream
- $unknown1 =pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' );
- $unknown2 =pack("H*",'0303000000000000C000000000000046' );
- $unknown3 =pack("H*",'FFFFADDE000000000000000000000000000000000000000');
- $unknown4 =pack("v", 0x03 );
-
- # Pack the main data stream
- $data = pack("vvvv", $row1, $row2, $col1, $col2) .
- $unknown1 .
- $link_type .
- $unknown2 .
- $up_count .
- $dir_short_len.
- $dir_short .
- $unknown3 .
- $stream_len .
- $dir_long_len .
- $unknown4 .
- $dir_long .
- $sheet_len .
- $sheet ;
-
- # Pack the header data
- $length = strlen($data);
- $header = pack("vv", $record, $length);
-
- # Write the packed data
- $this->_append($header . $data);
-
- return $str_error;
-}
-
-###############################################################################
-#
-# write_url_xxx($row1, $col1, $row2, $col2, $url, $string, $format)
-#
-# Write links to external MS/Novell network drives and shares such as
-# '//NETWORK/share/foo.xls' and '//NETWORK/share/foo.xls#Sheet1!A1'.
-#
-# See also write_url() above for a general description and return values.
-#
-function _write_url_external_net() {
-
- $_=func_get_args();
-
- $record = 0x01B8; # Record identifier
- $length = 0x00000; # Bytes to follow
-
- $row1 = $_[0]; # Start row
- $col1 = $_[1]; # Start column
- $row2 = $_[2]; # End row
- $col2 = $_[3]; # End column
- $url = $_[4]; # URL string
- if(isset($_[5])) {
- $str = $_[5]; # Alternative label
- }
- $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format
-
- # Strip URL type and change Unix dir separator to Dos style (if needed)
- #
- $url = preg_replace('[^external:]', "", $url);
- $url = preg_replace('[/]', "\\");
-
- # Write the visible label
- if (!isset($str)) {
- $str = preg_replace('[\#]', " - ", $url);
- }
-
- $str_error = $this->write_string($row1, $col1, $str, $xf);
- if ($str_error == -2) {
- return $str_error;
- }
-
- # Determine if the link contains a sheet reference and change some of the
- # parameters accordingly.
- # Split the dir name and sheet name (if it exists)
- #
- list($dir_long , $sheet) = preg_split('\#', $url);
- $link_type = 0x0103; # Always absolute
-
-//!!!
- if (isset($sheet)) {
- $link_type |= 0x08;
- $sheet_len = pack("V", strlen($sheet) + 0x01);
- $sheet = join("\0", preg_split("''", $sheet, -1, PREG_SPLIT_NO_EMPTY));
- $sheet .= "\0\0\0";
- } else {
- $sheet_len = '';
- $sheet = '';
- }
-
- # Pack the link type
- $link_type = pack("V", $link_type);
-
- # Make the string null terminated
- $dir_long = $dir_long . "\0";
-
- # Pack the lengths of the dir string
- $dir_long_len = pack("V", strlen($dir_long));
-
- # Store the long dir name as a wchar string (non-null terminated)
- $dir_long = join("\0", preg_split("''", $dir_long, -1, PREG_SPLIT_NO_EMPTY));
- $dir_long = $dir_long . "\0";
-
- # Pack the undocumented part of the hyperlink stream
- $unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000');
-
- # Pack the main data stream
- $data = pack("vvvv", $row1, $row2, $col1, $col2) .
- $unknown1 .
- $link_type .
- $dir_long_len .
- $dir_long .
- $sheet_len .
- $sheet ;
-
- # Pack the header data
- $length = strlen($data);
- $header = pack("vv", $record, $length);
-
- # Write the packed data
- $this->_append($header . $data);
-
- return $str_error;
-}
-
-###############################################################################
-#
-# set_row($row, $height, $XF)
-#
-# This method is used to set the height and XF format for a row.
-# Writes the BIFF record ROW.
-#
-function set_row() {
-
- $_=func_get_args();
-
- $record = 0x0208; # Record identifier
- $length = 0x0010; # Number of bytes to follow
-
- $rw = $_[0]; # Row Number
- $colMic = 0x0000; # First defined column
- $colMac = 0x0000; # Last defined column
- //$miyRw; # Row height
- $irwMac = 0x0000; # Used by Excel to optimise loading
- $reserved = 0x0000; # Reserved
- $grbit = 0x01C0; # Option flags. (monkey) see $1 do
- //$ixfe; # XF index
- if (isset($_[2])) {
- $format = $_[2]; # Format object
- }
-
- # Check for a format object
- if (isset($_[2])) {
- $ixfe = $format->get_xf_index();
- } else {
- $ixfe = 0x0F;
- }
-
- # Use set_row($row, undef, $XF) to set XF without setting height
- if (isset($_[1])) {
- $miyRw = $_[1] *20;
- } else {
- $miyRw = 0xff;
- }
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvvvvvv", $rw, $colMic, $colMac, $miyRw,
- $irwMac,$reserved, $grbit, $ixfe);
-
- $this->_append($header . $data);
-
- # Store the row sizes for use when calculating image vertices.
- # Also store the column formats.
- #
- # Ensure at least $row and $height
- if (sizeof($_) < 2) {
- return;
- }
-
- $this->_row_sizes[$_[0]] = $_[1];
- if (isset($_[2])) {
- $this->_row_formats[$_[0]] = $_[2];
- }
-}
-
- /*
- * Writes Excel DIMENSIONS to define the area in which there is data.
- */
- function _store_dimensions() {
- $record = 0x0000; // Record identifier
- $length = 0x000A; // Number of bytes to follow
- $row_min = $this->_dim_rowmin; // First row
- $row_max = $this->_dim_rowmax; // Last row plus 1
- $col_min = $this->_dim_colmin; // First column
- $col_max = $this->_dim_colmax; // Last column plus 1
- $reserved = 0x0000; // Reserved by Excel
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvvv", $row_min, $row_max,
- $col_min, $col_max, $reserved);
- $this->_prepend($header . $data);
- }
-
- /*
- * Write BIFF record Window2.
- */
- function _store_window2() {
- $record = 0x023E; // Record identifier
- $length = 0x000A; // Number of bytes to follow
-
- $grbit = 0x00B6; // Option flags
- $rwTop = 0x0000; // Top row visible in window
- $colLeft = 0x0000; // Leftmost column visible in window
- $rgbHdr = 0x00000000; // Row/column heading and gridline
- // color
-
- // The options flags that comprise $grbit
- $fDspFmla = 0; // 0 - bit
- $fDspGrid = $this->_screen_gridlines; // 1
- $fDspRwCol = 1; // 2
- $fFrozen = $this->_frozen; // 3
- $fDspZeros = 1; // 4
- $fDefaultHdr = 1; // 5
- $fArabic = 0; // 6
- $fDspGuts = 1; // 7
- $fFrozenNoSplit = 0; // 0 - bit
- $fSelected = $this->_selected; // 1
- $fPaged = 1; // 2
-
- $grbit = $fDspFmla;
- $grbit |= $fDspGrid << 1;
- $grbit |= $fDspRwCol << 2;
- $grbit |= $fFrozen << 3;
- $grbit |= $fDspZeros << 4;
- $grbit |= $fDefaultHdr << 5;
- $grbit |= $fArabic << 6;
- $grbit |= $fDspGuts << 7;
- $grbit |= $fFrozenNoSplit << 8;
- $grbit |= $fSelected << 9;
- $grbit |= $fPaged << 10;
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvV", $grbit, $rwTop, $colLeft, $rgbHdr);
-
- $this->_append($header . $data);
- }
-
- /*
- * Write BIFF record DEFCOLWIDTH if COLINFO records are in use.
- */
- function _store_defcol() {
- $record = 0x0055; // Record identifier
- $length = 0x0002; // Number of bytes to follow
-
- $colwidth = 0x0008; // Default column width
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $colwidth);
-
- $this->_prepend($header . $data);
- }
-
-###############################################################################
-#
-# _store_colinfo($firstcol, $lastcol, $width, $format, $hidden)
-#
-# Write BIFF record COLINFO to define column widths
-#
-# Note: The SDK says the record length is 0x0B but Excel writes a 0x0C
-# length record.
-#
-function _store_colinfo($_) {
-
- $record = 0x007D; # Record identifier
- $length = 0x000B; # Number of bytes to follow
-
- $colFirst = $_[0] ? $_[0] : 0; # First formatted column
- $colLast = $_[1] ? $_[1] : 0; # Last formatted column
- $coldx = $_[2] ? $_[2] : 8.43; # Col width, 8.43 is Excel default
-
- $coldx += 0.72; # Fudge. Excel subtracts 0.72 !?
- $coldx *= 256; # Convert to units of 1/256 of a char
-
- //$ixfe; # XF index
- $grbit = $_[4] || 0; # Option flags
- $reserved = 0x00; # Reserved
- $format = $_[3]; # Format object
-
- # Check for a format object
- if (isset($_[3])) {
- $ixfe = $format->get_xf_index();
- } else {
- $ixfe = 0x0F;
- }
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvvvC", $colFirst, $colLast, $coldx,
- $ixfe, $grbit, $reserved);
- $this->_prepend($header . $data);
-}
-
-###############################################################################
-#
-# _store_selection($first_row, $first_col, $last_row, $last_col)
-#
-# Write BIFF record SELECTION.
-#
-function _store_selection($_) {
-
- $record = 0x001D; # Record identifier
- $length = 0x000F; # Number of bytes to follow
-
- $pnn = $this->_active_pane; # Pane position
- $rwAct = $_[0]; # Active row
- $colAct = $_[1]; # Active column
- $irefAct = 0; # Active cell ref
- $cref = 1; # Number of refs
-
- $rwFirst = $_[0]; # First row in reference
- $colFirst = $_[1]; # First col in reference
- $rwLast = $_[2] ? $_[2] : $rwFirst; # Last row in reference
- $colLast = $_[3] ? $_[3] : $colFirst; # Last col in reference
-
- # Swap last row/col for first row/col as necessary
- if ($rwFirst > $rwLast) {
- list($rwFirst, $rwLast) = array($rwLast, $rwFirst);
- }
-
- if ($colFirst > $colLast) {
- list($colFirst, $colLast) = array($colLast, $colFirst);
- }
-
- $header = pack("vv", $record, $length);
- $data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct,
- $irefAct, $cref,
- $rwFirst, $rwLast,
- $colFirst, $colLast);
-
- $this->_append($header . $data);
-}
-
- /*
- * Write BIFF record EXTERNCOUNT to indicate the number of external
- * sheet references in a worksheet.
- *
- * Excel only stores references to external sheets that are used in
- * formulas. For simplicity we store references to all the sheets in
- * the workbook regardless of whether they are used or not. This reduces
- * the overall complexity and eliminates the need for a two way dialogue
- * between the formula parser the worksheet objects.
- */
- function _store_externcount($cxals) {
- // $cxals Number of external references
-
- $record = 0x0016; // Record identifier
- $length = 0x0002; // Number of bytes to follow
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $cxals);
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Writes the Excel BIFF EXTERNSHEET record. These references are used
- * by formulas. A formula references a sheet name via an index. Since we
- * store a reference to all of the external worksheets the EXTERNSHEET
- * index is the same as the worksheet index.
- */
- function _store_externsheet($sheetname) {
- $record = 0x0017; # Record identifier
- // $length Number of bytes to follow
-
- // $cch Length of sheet name
- // $rgch Filename encoding
-
- // References to the current sheet are encoded differently to
- // references to external sheets.
- if ($this->_name == $sheetname) {
- $sheetname = '';
- $length = 0x02; // The following 2 bytes
- $cch = 1; // The following byte
- $rgch = 0x02; // Self reference
- } else {
- $length = 0x02 + strlen($sheetname);
- $cch = strlen($sheetname);
- $rgch = 0x03; // Reference to a sheet in the current
- // workbook
- }
-
- $header = pack("vv", $record, $length);
- $data = pack("CC", $cch, $rgch);
-
- $this->_prepend($header . $data . $sheetname);
- }
-
-###############################################################################
-#
-# _store_panes()
-#
-#
-# Writes the Excel BIFF PANE record.
-# The panes can either be frozen or thawed (unfrozen).
-# Frozen panes are specified in terms of a integer number of rows and columns.
-# Thawed panes are specified in terms of Excel's units for rows and columns.
-#
-function _store_panes() {
-
- $_=func_get_args();
-
- $record = 0x0041; # Record identifier
- $length = 0x000A; # Number of bytes to follow
-
- $y = $_[0] || 0; # Vertical split position
- $x = $_[1] || 0; # Horizontal split position
- if (isset($_[2])) {
- $rwTop = $_[2]; # Top row visible
- }
- if (isset($_[3])) {
- $colLeft = $_[3]; # Leftmost column visible
- }
- if (isset($_[4])) {
- $pnnAct = $_[4]; # Active pane
- }
-
- # Code specific to frozen or thawed panes.
- if ($this->_frozen) {
- # Set default values for $rwTop and $colLeft
- if (!isset($rwTop)) {
- $rwTop = $y;
- }
- if (!isset($colLeft)) {
- $colLeft = $x;
- }
- } else {
- # Set default values for $rwTop and $colLeft
- if (!isset($rwTop)) {
- $rwTop = 0;
- }
- if (!isset($colLeft)) {
- $colLeft = 0;
- }
-
- # Convert Excel's row and column units to the internal units.
- # The default row height is 12.75
- # The default column width is 8.43
- # The following slope and intersection values were interpolated.
- #
- $y = 20*$y + 255;
- $x = 113.879*$x + 390;
- }
-
- # Determine which pane should be active. There is also the undocumented
- # option to override this should it be necessary: may be removed later.
- #
- if (!isset($pnnAct)) {
- # Bottom right
- if ($x != 0 && $y != 0) {
- $pnnAct = 0;
- }
- # Top right
- if ($x != 0 && $y == 0) {
- $pnnAct = 1;
- }
- # Bottom left
- if ($x == 0 && $y != 0) {
- $pnnAct = 2;
- }
- # Top left
- if ($x == 0 && $y == 0) {
- $pnnAct = 3;
- }
- }
-
- $this->_active_pane = $pnnAct; # Used in _store_selection
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct);
-
- $this->_append($header . $data);
-}
-
- /*
- * Store the page setup SETUP BIFF record.
- */
- function _store_setup() {
- $record = 0x00A1; // Record identifier
- $length = 0x0022; // Number of bytes to follow
-
- $iPaperSize = $this->_paper_size; // Paper size
- $iScale = $this->_print_scale; // Print scaling factor
- $iPageStart = 0x01; // Starting page number
- $iFitWidth = $this->_fit_width; // Fit to number of pages wide
- $iFitHeight = $this->_fit_height; // Fit to number of pages high
- $grbit = 0x00; // Option flags
- $iRes = 0x0258; // Print resolution
- $iVRes = 0x0258; // Vertical print resolution
- $numHdr = $this->_margin_head; // Header Margin
- $numFtr = $this->_margin_foot; // Footer Margin
- $iCopies = 0x01; // Number of copies
-
- $fLeftToRight = 0x0; // Print over then down
- $fLandscape = $this->_orientation; // Page orientation
- $fNoPls = 0x0; // Setup not read from printer
- $fNoColor = 0x0; // Print black and white
- $fDraft = 0x0; // Print draft quality
- $fNotes = 0x0; // Print notes
- $fNoOrient = 0x0; // Orientation not set
- $fUsePage = 0x0; // Use custom starting page
-
- $grbit = $fLeftToRight;
- $grbit |= $fLandscape << 1;
- $grbit |= $fNoPls << 2;
- $grbit |= $fNoColor << 3;
- $grbit |= $fDraft << 4;
- $grbit |= $fNotes << 5;
- $grbit |= $fNoOrient << 6;
- $grbit |= $fUsePage << 7;
-
- $numHdr = pack("d", $numHdr);
- $numFtr = pack("d", $numFtr);
-
- if ($this->_byte_order) {
- $numHdr = strrev($numHdr);
- $numFtr = strrev($numFtr);
- }
-
- $header = pack("vv", $record, $length);
- $data1 = pack("vvvvvvvv", $iPaperSize,
- $iScale,
- $iPageStart,
- $iFitWidth,
- $iFitHeight,
- $grbit,
- $iRes,
- $iVRes);
- $data2 = $numHdr . $numFtr;
- $data3 = pack("v", $iCopies);
-
- $this->_prepend($header . $data1 . $data2 . $data3);
- }
-
- /*
- * Store the header caption BIFF record.
- */
- function _store_header() {
- $record = 0x0014; // Record identifier
-
- $str = $this->_header; // header string
- $cch = strlen($str); // Length of header string
- $length = 1 + $cch; // Bytes to follow
-
- $header = pack("vv", $record, $length);
- $data = pack("C", $cch);
-
- $this->_append($header . $data . $str);
- }
-
- /*
- * Store the footer caption BIFF record.
- */
- function _store_footer() {
- $record = 0x0015; // Record identifier
-
- $str = $this->_footer; // Footer string
- $cch = strlen($str); // Length of footer string
- $length = 1 + $cch; // Bytes to follow
-
- $header = pack("vv", $record, $length);
- $data = pack("C", $cch);
-
- $this->_append($header . $data . $str);
- }
-
- /*
- * Store the horizontal centering HCENTER BIFF record.
- */
- function _store_hcenter() {
- $record = 0x0083; // Record identifier
- $length = 0x0002; // Bytes to follow
-
- $fHCenter = $this->_hcenter; // Horizontal centering
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $fHCenter);
-
- $this->_append($header . $data);
- }
-
- /*
- * Store the vertical centering VCENTER BIFF record.
- */
- function _store_vcenter() {
- $record = 0x0084; // Record identifier
- $length = 0x0002; // Bytes to follow
-
- $fVCenter = $this->_vcenter; // Horizontal centering
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $fVCenter);
-
- $this->_append($header . $data);
- }
-
- /*
- * Store the LEFTMARGIN BIFF record.
- */
- function _store_margin_left() {
- $record = 0x0026; // Record identifier
- $length = 0x0008; // Bytes to follow
-
- $margin = $this->_margin_left; // Margin in inches
-
- $header = pack("vv", $record, $length);
- $data = pack("d", $margin);
-
- if ($this->_byte_order) {
- $data = strrev($data);
- }
-
- $this->_append($header . $data);
- }
-
- /*
- * Store the RIGHTMARGIN BIFF record.
- */
- function _store_margin_right() {
- $record = 0x0027; // Record identifier
- $length = 0x0008; // Bytes to follow
-
- $margin = $this->_margin_right; // Margin in inches
-
- $header = pack("vv", $record, $length);
- $data = pack("d", $margin);
-
- if ($this->_byte_order) {
- $data = strrev($data);
- }
-
- $this->_append($header . $data);
- }
-
- /*
- * Store the TOPMARGIN BIFF record.
- */
- function _store_margin_top() {
- $record = 0x0028; // Record identifier
- $length = 0x0008; // Bytes to follow
-
- $margin = $this->_margin_top; // Margin in inches
-
- $header = pack("vv", $record, $length);
- $data = pack("d", $margin);
-
- if ($this->_byte_order) {
- $data = strrev($data);
- }
-
- $this->_append($header . $data);
- }
-
- /*
- * Store the BOTTOMMARGIN BIFF record.
- */
- function _store_margin_bottom() {
- $record = 0x0029; // Record identifier
- $length = 0x0008; // Bytes to follow
-
- $margin = $this->_margin_bottom; // Margin in inches
-
- $header = pack("vv", $record, $length);
- $data = pack("d", $margin);
-
- if ($this->_byte_order) {
- $data = strrev($data);
- }
-
- $this->_append($header . $data);
- }
-
-###############################################################################
-#
-# merge_cells($first_row, $first_col, $last_row, $last_col)
-#
-# This is an Excel97/2000 method. It is required to perform more complicated
-# merging than the normal align merge in Format.pm
-#
-function merge_cells() {
-
- $_=func_get_args();
-
- // Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- $record = 0x00E5; # Record identifier
- $length = 0x000A; # Bytes to follow
-
- $cref = 1; # Number of refs
- $rwFirst = $_[0]; # First row in reference
- $colFirst = $_[1]; # First col in reference
- $rwLast = $_[2] || $rwFirst; # Last row in reference
- $colLast = $_[3] || $colFirst; # Last col in reference
-
- // Swap last row/col for first row/col as necessary
- if ($rwFirst > $rwLast) {
- list($rwFirst, $rwLast) = array($rwLast, $rwFirst);
- }
-
- if ($colFirst > $colLast) {
- list($colFirst, $colLast) = array($colLast, $colFirst);
- }
-
- $header = pack("vv", $record, $length);
- $data = pack("vvvvv", $cref,
- $rwFirst, $rwLast,
- $colFirst, $colLast);
-
- $this->_append($header . $data);
-}
-
- /*
- * Write the PRINTHEADERS BIFF record.
- */
- function _store_print_headers() {
- $record = 0x002a; // Record identifier
- $length = 0x0002; // Bytes to follow
-
- $fPrintRwCol = $this->_print_headers; // Boolean flag
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $fPrintRwCol);
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Write the PRINTGRIDLINES BIFF record. Must be used in conjunction
- * with the GRIDSET record.
- */
- function _store_print_gridlines() {
- $record = 0x002b; // Record identifier
- $length = 0x0002; // Bytes to follow
-
- $fPrintGrid = $this->_print_gridlines; // Boolean flag
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $fPrintGrid);
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Write the GRIDSET BIFF record. Must be used in conjunction with the
- * PRINTGRIDLINES record.
- */
- function _store_gridset() {
- $record = 0x0082; // Record identifier
- $length = 0x0002; // Bytes to follow
-
- $fGridSet = !$this->_print_gridlines; // Boolean flag
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $fGridSet);
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Write the WSBOOL BIFF record, mainly for fit-to-page. Used in
- * conjunction with the SETUP record.
- */
- function _store_wsbool() {
- $record = 0x0081; # Record identifier
- $length = 0x0002; # Bytes to follow
-
- // $grbit Option flags
-
- // The only option that is of interest is the flag for fit to page.
- // So we set all the options in one go.
- if ($this->_fit_page) {
- $grbit = 0x05c1;
- } else {
- $grbit = 0x04c1;
- }
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $grbit);
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Write the HORIZONTALPAGEBREAKS BIFF record.
- */
- function _store_hbreak() {
- // Return if the user hasn't specified pagebreaks
- if(sizeof($this->_hbreaks)==0) {
- return;
- }
-
- # Sort and filter array of page breaks
- $breaks = $this->_sort_pagebreaks($this->_hbreaks);
-
- $record = 0x001b; // Record identifier
- $cbrk = sizeof($breaks); // Number of page breaks
- $length = ($cbrk + 1) * 2; // Bytes to follow
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $cbrk);
-
- // Append each page break
- foreach ($breaks as $break) {
- $data .= pack("v", $break);
- }
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Write the VERTICALPAGEBREAKS BIFF record.
- */
- function _store_vbreak() {
- // Return if the user hasn't specified pagebreaks
- if(sizeof($this->_vbreaks)==0) {
- return;
- }
-
- // Sort and filter array of page breaks
- $breaks = $this->_sort_pagebreaks($this->_vbreaks);
-
- $record = 0x001a; // Record identifier
- $cbrk = sizeof($breaks); // Number of page breaks
- $length = ($cbrk + 1) * 2; // Bytes to follow
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $cbrk);
-
- // Append each page break
- foreach ($breaks as $break) {
- $data .= pack("v", $break);
- }
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Set the Biff PROTECT record to indicate that the worksheet is
- * protected.
- */
- function _store_protect() {
- // Exit unless sheet protection has been specified
- if (!$this->_protect) {
- return;
- }
-
- $record = 0x0012; // Record identifier
- $length = 0x0002; // Bytes to follow
-
- $fLock = $this->_protect; // Worksheet is protected
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $fLock);
-
- $this->_prepend($header . $data);
- }
-
- /*
- * Write the worksheet PASSWORD record.
- */
- function _store_password() {
- // Exit unless sheet protection and password have been specified
- if (!$this->_protect || !$this->_password) {
- return;
- }
-
- $record = 0x0013; // Record identifier
- $length = 0x0002; // Bytes to follow
-
- $wPassword = $this->_password; // Encoded password
-
- $header = pack("vv", $record, $length);
- $data = pack("v", $wPassword);
-
- $this->_prepend($header . $data);
- }
-
-###############################################################################
-#
-# insert_bitmap($row, $col, $filename, $x, $y, $scale_x, $scale_y)
-#
-# Insert a 24bit bitmap image in a worksheet. The main record required is
-# IMDATA but it must be proceeded by a OBJ record to define its position.
-#
-function insert_bitmap() {
-
- $_=func_get_args();
-
- # Check for a cell reference in A1 notation and substitute row and column
- if (preg_match('/^\D/', $_[0])) {
- $_ = $this->_substitute_cellref($_);
- }
-
- $row = $_[0];
- $col = $_[1];
- $bitmap = $_[2];
- $x = $_[3] ? $_[3] : 0;
- $y = $_[4] ? $_[4] : 0;
- $scale_x = $_[5] ? $_[5] : 1;
- $scale_y = $_[6] ? $_[6] : 1;
-
- list($width, $height, $size, $data) = $this->_process_bitmap($bitmap);
-
- # Scale the frame of the image.
- $width *= $scale_x;
- $height *= $scale_y;
-
- # Calculate the vertices of the image and write the OBJ record
- $this->_position_image($col, $row, $x, $y, $width, $height);
-
- # Write the IMDATA record to store the bitmap data
- $record = 0x007f;
- $length = 8 + $size;
- $cf = 0x09;
- $env = 0x01;
- $lcb = $size;
-
- $header = pack("vvvvV", $record, $length, $cf, $env, $lcb);
-
- $this->_append($header . $data);
-}
-
- /*
- * Calculate the vertices that define the position of the image as
- * required by the OBJ record.
- *
- * +------------+------------+
- * | A | B |
- * +-----+------------+------------+
- * | |(x1,y1) | |
- * | 1 |(A1)._______|______ |
- * | | | | |
- * | | | | |
- * +-----+----| BITMAP |-----+
- * | | | | |
- * | 2 | |______________. |
- * | | | (B2)|
- * | | | (x2,y2)|
- * +---- +------------+------------+
- *
- * Example of a bitmap that covers some of the area from cell A1 to
- * cell B2.
- *
- * Based on the width and height of the bitmap we need to calculate 8
- *vars:
- * $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2.
- * The width and height of the cells are also variable and have to be
- * taken into account.
- * The values of $col_start and $row_start are passed in from the calling
- * function. The values of $col_end and $row_end are calculated by
- * subtracting the width and height of the bitmap from the width and
- * height of the underlying cells.
- * The vertices are expressed as a percentage of the underlying cell
- * width as follows (rhs values are in pixels):
- *
- * x1 = X / W *1024
- * y1 = Y / H *256
- * x2 = (X-1) / W *1024
- * y2 = (Y-1) / H *256
- *
- * Where: X is distance from the left side of the underlying cell
- * Y is distance from the top of the underlying cell
- * W is the width of the cell
- * H is the height of the cell
- *
- * Note: the SDK incorrectly states that the height should be expressed
- * as a percentage of 1024.
- */
- function _position_image($col_start, $row_start, $x1, $y1,
- $width, $height) {
- // $col_start Col containing upper left corner of object
- // $x1 Distance to left side of object
-
- // $row_start Row containing top left corner of object
- // $y1 Distance to top of object
-
- // $col_end Col containing lower right corner of object
- // $x2 Distance to right side of object
-
- // $row_end Row containing bottom right corner of object
- // $y2 Distance to bottom of object
-
- // $width Width of image frame
- // $height Height of image frame
-
- // Initialise end cell to the same as the start cell
- $col_end = $col_start;
- $row_end = $row_start;
-
- // Zero the specified offset if greater than the cell dimensions
- if ($x1 >= $this->_size_col($col_start)) {
- $x1 = 0;
- }
- if ($y1 >= $this->_size_row($row_start)) {
- $y1 = 0;
- }
-
- $width = $width + $x1 -1;
- $height = $height + $y1 -1;
-
- // Subtract the underlying cell widths to find the end cell of the
- // image
- while ($width >= $this->_size_col($col_end)) {
- $width -= $this->_size_col($col_end);
- $col_end++;
- }
-
- // Subtract the underlying cell heights to find the end cell of the
- // image
- while ($height >= $this->_size_row($row_end)) {
- $height -= $this->_size_row($row_end);
- $row_end++;
- }
-
- // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a
- // cell with zero height or width.
- if ($this->_size_col($col_start) == 0) { return; }
- if ($this->_size_col($col_end) == 0) { return; }
- if ($this->_size_row($row_start) == 0) { return; }
- if ($this->_size_row($row_end) == 0) { return; }
-
- // Convert the pixel values to the percentage value expected by Excel
- $x1 = $x1 / $this->_size_col($col_start) * 1024;
- $y1 = $y1 / $this->_size_row($row_start) * 256;
- $x2 = $width / $this->_size_col($col_end) * 1024;
- $y2 = $height / $this->_size_row($row_end) * 256;
-
- $this->_store_obj_picture($col_start, $x1, $row_start, $y1,
- $col_end, $x2, $row_end, $y2);
- }
-
- /*
- * Convert the width of a cell from user's units to pixels. By
- * interpolation the relationship is: y = 7x +5. If the width
- * hasn't been set by the user we use the default value. If the
- * col is hidden we use a value of zero.
- */
- function _size_col($col) {
- // Look up the cell value to see if it has been changed
- if (isset($this->_col_sizes[$col])) {
- if ($this->_col_sizes[$col] == 0) {
- return 0;
- } else {
- return floor(7 * $this->_col_sizes[$col] + 5);
- }
- } else {
- return 64;
- }
- }
-
- /*
- * Convert the height of a cell from user's units to pixels. By
- * interpolation # the relationship is: y = 4/3x. If the height
- * hasn't been set by the user we use the default value. If the
- * row is hidden we use a value of zero. (Not possible to hide row
- * yet).
- */
- function _size_row($row) {
- // Look up the cell value to see if it has been changed
- if (isset($this->_row_sizes[$row])) {
- if ($this->_row_sizes[$row] == 0) {
- return 0;
- } else {
- return floor(4/3 * $this->_row_sizes[$row]);
- }
- } else {
- return 17;
- }
- }
-
- /*
- * Store the OBJ record that precedes an IMDATA record. This could
- * be generalized to support other Excel objects.
- */
- function _store_obj_picture($col_start, $x1, $row_start, $y1,
- $col_end, $x2, $row_end, $y2) {
- $record = 0x005d; // Record identifier
- $length = 0x003c; // Bytes to follow
-
- $cObj = 0x0001; // Count of objects in file (set to 1)
- $OT = 0x0008; // Object type. 8 = Picture
- $id = 0x0001; // Object ID
- $grbit = 0x0614; // Option flags
-
- $colL = $col_start; // Col containing upper left corner of
- // object
- $dxL = $x1; // Distance from left side of cell
-
- $rwT = $row_start; // Row containing top left corner of
- // object
- $dyT = $y1; // Distance from top of cell
-
- $colR = $col_end; // Col containing lower right corner of
- // object
- $dxR = $x2; // Distance from right of cell
-
- $rwB = $row_end; // Row containing bottom right corner of
- // object
- $dyB = $y2; // Distance from bottom of cell
-
- $cbMacro = 0x0000; // Length of FMLA structure
- $Reserved1 = 0x0000; // Reserved
- $Reserved2 = 0x0000; // Reserved
-
- $icvBack = 0x09; // Background colour
- $icvFore = 0x09; // Foreground colour
- $fls = 0x00; // Fill pattern
- $fAuto = 0x00; // Automatic fill
- $icv = 0x08; // Line colour
- $lns = 0xff; // Line style
- $lnw = 0x01; // Line weight
- $fAutoB = 0x00; // Automatic border
- $frs = 0x0000; // Frame style
- $cf = 0x0009; // Image format, 9 = bitmap
- $Reserved3 = 0x0000; // Reserved
- $cbPictFmla = 0x0000; // Length of FMLA structure
- $Reserved4 = 0x0000; // Reserved
- $grbit2 = 0x0001; // Option flags
- $Reserved5 = 0x0000; // Reserved
-
- $header = pack("vv", $record, $length);
- $data = pack("V", $cObj);
- $data .= pack("v", $OT);
- $data .= pack("v", $id);
- $data .= pack("v", $grbit);
- $data .= pack("v", $colL);
- $data .= pack("v", $dxL);
- $data .= pack("v", $rwT);
- $data .= pack("v", $dyT);
- $data .= pack("v", $colR);
- $data .= pack("v", $dxR);
- $data .= pack("v", $rwB);
- $data .= pack("v", $dyB);
- $data .= pack("v", $cbMacro);
- $data .= pack("V", $Reserved1);
- $data .= pack("v", $Reserved2);
- $data .= pack("C", $icvBack);
- $data .= pack("C", $icvFore);
- $data .= pack("C", $fls);
- $data .= pack("C", $fAuto);
- $data .= pack("C", $icv);
- $data .= pack("C", $lns);
- $data .= pack("C", $lnw);
- $data .= pack("C", $fAutoB);
- $data .= pack("v", $frs);
- $data .= pack("V", $cf);
- $data .= pack("v", $Reserved3);
- $data .= pack("v", $cbPictFmla);
- $data .= pack("v", $Reserved4);
- $data .= pack("v", $grbit2);
- $data .= pack("V", $Reserved5);
-
- $this->_append($header . $data);
- }
-
- /*
- * Convert a 24 bit bitmap into the modified internal format used by
- * Windows. This is described in BITMAPCOREHEADER and BITMAPCOREINFO
- * structures in the MSDN library.
- */
- function _process_bitmap($bitmap) {
- // Open file and binmode the data in case the platform needs it.
- $bmp=fopen($bitmap, "rb");
- if (!$bmp) {
- trigger_error("Could not open file '$bitmap'.", E_USER_ERROR);
- }
-
- $data=fread($bmp, filesize($bitmap));
-
- // Check that the file is big enough to be a bitmap.
- if (strlen($data) <= 0x36) {
- trigger_error("$bitmap doesn't contain enough data.",
- E_USER_ERROR);
- }
-
- // The first 2 bytes are used to identify the bitmap.
- if (substr($data, 0, 2) != "BM") {
- trigger_error("$bitmap doesn't appear to to be a ".
- "valid bitmap image.", E_USER_ERROR);
- }
-
- // Remove bitmap data: ID.
- $data = substr($data, 2);
-
- // Read and remove the bitmap size. This is more reliable than reading
- // the data size at offset 0x22.
- $array = unpack("Vsize", $data);
- $data = substr($data, 4);
- $size = $array["size"];
- $size -= 0x36; # Subtract size of bitmap header.
- $size += 0x0C; # Add size of BIFF header.
-
- // Remove bitmap data: reserved, offset, header length.
- $data = substr($data, 12);
-
- // Read and remove the bitmap width and height. Verify the sizes.
- $array = unpack("Vwidth/Vheight", $data);
- $data = substr($data, 8);
- $width = $array["width"];
- $height = $array["height"];
-
- if ($width > 0xFFFF) {
- trigger_error("$bitmap: largest image width supported is 64k.",
- E_USER_ERROR);
- }
-
- if ($height > 0xFFFF) {
- trigger_error("$bitmap: largest image height supported is 64k.",
- E_USER_ERROR);
- }
-
- // Read and remove the bitmap planes and bpp data. Verify them.
- $array = unpack("vplanes/vbitcount", $data);
- $data = substr($data, 4);
- $planes = $array["planes"];
- $bitcount = $array["bitcount"];
-
- if ($bitcount != 24) {
- trigger_error("$bitmap isn't a 24bit true color bitmap.",
- E_USER_ERROR);
- }
-
- if ($planes != 1) {
- trigger_error("$bitmap: only 1 plane supported in bitmap image.",
- E_USER_ERROR);
- }
-
- // Read and remove the bitmap compression. Verify compression.
- $array = unpack("Vcompression", $data);
- $data = substr($data, 4);
- $compression = $array["compression"];
-
- if ($compression != 0) {
- trigger_error("$bitmap: compression not supported in bitmap image.",
- E_USER_ERROR);
- }
-
- // Remove bitmap data: data size, hres, vres, colours, imp. colours.
- $data = substr($data, 20);
-
- // Add the BITMAPCOREHEADER data
- $header = pack("Vvvvv", 0x000c, $width, $height, 0x01, 0x18);
- $data = $header . $data;
-
- return array($width, $height, $size, $data);
- }
-
- /*
- * Store the window zoom factor. This should be a reduced fraction but for
- * simplicity we will store all fractions with a numerator of 100.
- */
- function _store_zoom() {
- // If scale is 100% we don't need to write a record
- if ($this->_zoom == 100) {
- return;
- }
-
- $record = 0x00A0; // Record identifier
- $length = 0x0004; // Bytes to follow
-
- $header = pack("vv", $record, $length);
- $data = pack("vv", $this->_zoom, 100);
-
- $this->_append($header . $data);
- }
-
-}
-
-?>
diff --git a/gosa-core/include/php_writeexcel/functions.writeexcel_utility.inc.php b/gosa-core/include/php_writeexcel/functions.writeexcel_utility.inc.php
+++ /dev/null
@@ -1,271 +0,0 @@
-<?php
-
-/*
- * Copyleft 2002 Johann Hanne
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * This is the Spreadsheet::WriteExcel Perl package ported to PHP
- * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
- */
-
-/*
- * Converts numeric $row/$col notation to an Excel cell reference string in
- * A1 notation.
- */
-function xl_rowcol_to_cell($row, $col, $row_abs=false, $col_abs=false) {
-
- $row_abs = $row_abs ? '$' : '';
- $col_abs = $col_abs ? '$' : '';
-
- $int = floor($col / 26);
- $frac = $col % 26;
-
- $chr1 = ''; // Most significant character in AA1
-
- if ($int > 0) {
- $chr1 = chr(ord('A') + $int - 1);
- }
-
- $chr2 = chr(ord('A') + $frac);
-
- // Zero index to 1-index
- $row++;
-
- return $col_abs.$chr1.$chr2.$row_abs.$row;
-}
-
-/*
- * Converts an Excel cell reference string in A1 notation
- * to numeric $row/$col notation.
- *
- * Returns: array($row, $col, $row_absolute, $col_absolute)
- *
- * The $row_absolute and $col_absolute parameters aren't documented because
- * they are mainly used internally and aren't very useful to the user.
- */
-function xl_cell_to_rowcol($cell) {
-
- preg_match('/(\$?)([A-I]?[A-Z])(\$?)(\d+)/', $cell, $reg);
-
- $col_abs = ($reg[1] == "") ? 0 : 1;
- $col = $reg[2];
- $row_abs = ($reg[3] == "") ? 0 : 1;
- $row = $reg[4];
-
- // Convert base26 column string to number
- // All your Base are belong to us.
- $chars = preg_split('//', $col, -1, PREG_SPLIT_NO_EMPTY);
- $expn = 0;
- $col = 0;
-
- while (sizeof($chars)>0) {
- $char = array_pop($chars); // Least significant character first
- $col += (ord($char) - ord('A') + 1) * pow(26, $expn);
- $expn++;
- }
-
- // Convert 1-index to zero-index
- $row--;
- $col--;
-
- return array($row, $col, $row_abs, $col_abs);
-}
-
-/*
- * Increments the row number of an Excel cell reference string
- * in A1 notation.
- * For example C4 to C5
- *
- * Returns: a cell reference string in A1 notation.
- */
-function xl_inc_row($cell) {
- list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
- return xl_rowcol_to_cell(++$row, $col, $row_abs, $col_abs);
-}
-
-/*
- * Decrements the row number of an Excel cell reference string
- * in A1 notation.
- * For example C4 to C3
- *
- * Returns: a cell reference string in A1 notation.
- */
-function xl_dec_row($cell) {
- list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
- return xl_rowcol_to_cell(--$row, $col, $row_abs, $col_abs);
-}
-
-/*
- * Increments the column number of an Excel cell reference string
- * in A1 notation.
- * For example C3 to D3
- *
- * Returns: a cell reference string in A1 notation.
- */
-function xl_inc_col($cell) {
- list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
- return xl_rowcol_to_cell($row, ++$col, $row_abs, $col_abs);
-}
-
-/*
- * Decrements the column number of an Excel cell reference string
- * in A1 notation.
- * For example C3 to B3
- *
- * Returns: a cell reference string in A1 notation.
- */
-function xl_dec_col($cell) {
- list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
- return xl_rowcol_to_cell($row, --$col, $row_abs, $col_abs);
-}
-
-function xl_date_list($year, $month=1, $day=1,
- $hour=0, $minute=0, $second=0) {
-
- $monthdays=array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
-
- // Leap years since 1900 (year is dividable by 4)
- $leapyears=floor(($year-1900)/4);
-
- // Non-leap years since 1900 (year is dividable by 100)
- $nonleapyears=floor(($year-1900)/100);
-
- // Non-non-leap years since 1900 (year is dividable by 400)
- // (Yes, it MUST be "1600", not "1900")
- $nonnonleapyears=floor(($year-1600)/400);
-
- // Don't count the leap day of the specified year if it didn't
- // happen yet (i.e. before 1 March)
- //
- // Please note that $leapyears becomes -1 for dates before 1 March 1900;
- // this is not logical, but later we will add a day for Excel's
- // phantasie leap day in 1900 without checking if the date is actually
- // after 28 February 1900; so these two logic errors "neutralize"
- // each other
- if ($year%4==0 && $month<3) {
- $leapyears--;
- }
-
- $days=365*($year-1900)+$leapyears-$nonleapyears+$nonnonleapyears;
-
- for ($c=1;$c<$month;$c++) {
- $days+=$monthdays[$c-1];
- }
-
- // Excel actually wants the days since 31 December 1899, not since
- // 1 January 1900; this will also add this extra day
- $days+=$day;
-
- // Excel treats 1900 erroneously as a leap year, so we must
- // add one day
- //
- // Please note that we DON'T have to check if the date is after
- // 28 February 1900, because for such dates $leapyears is -1
- // (see above)
- $days++;
-
- return (float)($days+($hour*3600+$minute*60+$second)/86400);
-}
-
-function xl_parse_time($time) {
-
- if (preg_match('/(\d{1,2}):(\d\d):?((?:\d\d)(?:\.\d+)?)?(?:\s+)?(am|pm)?/i', $time, $reg)) {
-
- $hours = $reg[1];
- $minutes = $reg[2];
- $seconds = $reg[3] || 0;
- $meridian = strtolower($reg[4]) || '';
-
- // Normalise midnight and midday
- if ($hours == 12 && $meridian != '') {
- $hours = 0;
- }
-
- // Add 12 hours to the pm times. Note: 12.00 pm has been set to 0.00.
- if ($meridian == 'pm') {
- $hours += 12;
- }
-
- // Calculate the time as a fraction of 24 hours in seconds
- return (float)(($hours*3600+$minutes*60+$seconds)/86400);
-
- } else {
- return false; // Not a valid time string
- }
-}
-
-/*
- * Automagically converts almost any date/time string to an Excel date.
- * This function will always only be as good as strtotime() is.
- */
-function xl_parse_date($date) {
-
- $unixtime=strtotime($date);
-
- $year=date("Y", $unixtime);
- $month=date("m", $unixtime);
- $day=date("d", $unixtime);
- $hour=date("H", $unixtime);
- $minute=date("i", $unixtime);
- $second=date("s", $unixtime);
-
- // Convert to Excel date
- return xl_date_list($year, $month, $day, $hour, $minute, $second);
-}
-
-/*
- * Dummy function to be "compatible" to Spreadsheet::WriteExcel
- */
-function xl_parse_date_init() {
- // Erm... do nothing...
- // strtotime() doesn't require anything to be initialized
- // (do not ask me how to set the timezone...)
-}
-
-/*
- * xl_decode_date_EU() and xl_decode_date_US() are mapped
- * to xl_parse_date(); there seems to be no PHP function that
- * differentiates between EU and US dates; I've never seen
- * somebody using dd/mm/yyyy anyway, it always should be one of:
- * - yyyy-mm-dd (international)
- * - dd.mm.yyyy (european)
- * - mm/dd/yyyy (english/US/british?)
-*/
-
-function xl_decode_date_EU($date) {
- return xl_parse_date($date);
-}
-
-function xl_decode_date_US($date) {
- return xl_parse_date($date);
-}
-
-function xl_date_1904($exceldate) {
-
- if ($exceldate < 1462) {
- // date is before 1904
- $exceldate = 0;
- } else {
- $exceldate -= 1462;
- }
-
- return $exceldate;
-}
-
-?>
diff --git a/gosa-core/include/utils/excel/class.writeexcel_biffwriter.inc.php b/gosa-core/include/utils/excel/class.writeexcel_biffwriter.inc.php
--- /dev/null
@@ -0,0 +1,208 @@
+<?php
+
+/*
+ * Copyleft 2002 Johann Hanne
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * This is the Spreadsheet::WriteExcel Perl package ported to PHP
+ * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
+ */
+
+class writeexcel_biffwriter {
+ var $byte_order;
+ var $BIFF_version;
+ var $_byte_order;
+ var $_data;
+ var $_datasize;
+ var $_limit;
+
+ /*
+ * Constructor
+ */
+ function writeexcel_biffwriter() {
+
+ $this->byte_order = '';
+ $this->BIFF_version = 0x0500;
+ $this->_byte_order = '';
+ $this->_data = false;
+ $this->_datasize = 0;
+ $this->_limit = 2080;
+
+ $this->_set_byte_order();
+ }
+
+ /*
+ * Determine the byte order and store it as class data to avoid
+ * recalculating it for each call to new().
+ */
+ function _set_byte_order() {
+ $this->byteorder=0;
+ // Check if "pack" gives the required IEEE 64bit float
+ $teststr = pack("d", 1.2345);
+ $number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
+
+ if ($number == $teststr) {
+ $this->byte_order = 0; // Little Endian
+ } elseif ($number == strrev($teststr)) {
+ $this->byte_order = 1; // Big Endian
+ } else {
+ // Give up
+ trigger_error("Required floating point format not supported ".
+ "on this platform. See the portability section ".
+ "of the documentation.", E_USER_ERROR);
+ }
+
+ $this->_byte_order = $this->byte_order;
+ }
+
+ /*
+ * General storage function
+ */
+ function _prepend($data) {
+
+ if (func_num_args()>1) {
+ trigger_error("writeexcel_biffwriter::_prepend() ".
+ "called with more than one argument", E_USER_ERROR);
+ }
+
+ if ($this->_debug) {
+ print "*** writeexcel_biffwriter::_prepend() called:";
+ for ($c=0;$c<strlen($data);$c++) {
+ if ($c%16==0) {
+ print "\n";
+ }
+ printf("%02X ", ord($data[$c]));
+ }
+ print "\n";
+ }
+
+ if (strlen($data) > $this->_limit) {
+ $data = $this->_add_continue($data);
+ }
+
+ $this->_data = $data . $this->_data;
+ $this->_datasize += strlen($data);
+ }
+
+ /*
+ * General storage function
+ */
+ function _append($data) {
+
+ if (func_num_args()>1) {
+ trigger_error("writeexcel_biffwriter::_append() ".
+ "called with more than one argument", E_USER_ERROR);
+ }
+
+ if ($this->_debug) {
+ print "*** writeexcel_biffwriter::_append() called:";
+ for ($c=0;$c<strlen($data);$c++) {
+ if ($c%16==0) {
+ print "\n";
+ }
+ printf("%02X ", ord($data[$c]));
+ }
+ print "\n";
+ }
+
+ if (strlen($data) > $this->_limit) {
+ $data = $this->_add_continue($data);
+ }
+
+ $this->_data = $this->_data . $data;
+ $this->_datasize += strlen($data);
+ }
+
+ /*
+ * Writes Excel BOF record to indicate the beginning of a stream or
+ * sub-stream in the BIFF file.
+ *
+ * $type = 0x0005, Workbook
+ * $type = 0x0010, Worksheet
+ */
+ function _store_bof($type) {
+
+ $record = 0x0809; // Record identifier
+ $length = 0x0008; // Number of bytes to follow
+
+ $version = $this->BIFF_version;
+
+ // According to the SDK $build and $year should be set to zero.
+ // However, this throws a warning in Excel 5. So, use these
+ // magic numbers.
+ $build = 0x096C;
+ $year = 0x07C9;
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvv", $version, $type, $build, $year);
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Writes Excel EOF record to indicate the end of a BIFF stream.
+ */
+ function _store_eof() {
+
+ $record = 0x000A; // Record identifier
+ $length = 0x0000; // Number of bytes to follow
+
+ $header = pack("vv", $record, $length);
+
+ $this->_append($header);
+ }
+
+ /*
+ * Excel limits the size of BIFF records. In Excel 5 the limit is 2084
+ * bytes. In Excel 97 the limit is 8228 bytes. Records that are longer
+ * than these limits must be split up into CONTINUE blocks.
+ *
+ * This function take a long BIFF record and inserts CONTINUE records as
+ * necessary.
+ */
+ function _add_continue($data) {
+
+ $limit = $this->_limit;
+ $record = 0x003C; // Record identifier
+
+ // The first 2080/8224 bytes remain intact. However, we have to change
+ // the length field of the record.
+ $tmp = substr($data, 0, $limit);
+ $data = substr($data, $limit);
+ $tmp = substr($tmp, 0, 2) . pack ("v", $limit-4) . substr($tmp, 4);
+
+ // Strip out chunks of 2080/8224 bytes +4 for the header.
+ while (strlen($data) > $limit) {
+ $header = pack("vv", $record, $limit);
+ $tmp .= $header;
+ $tmp .= substr($data, 0, $limit);
+ $data = substr($data, $limit);
+ }
+
+ // Mop up the last of the data
+ $header = pack("vv", $record, strlen($data));
+ $tmp .= $header;
+ $tmp .= $data;
+
+ return $tmp;
+ }
+
+}
+
+?>
diff --git a/gosa-core/include/utils/excel/class.writeexcel_format.inc.php b/gosa-core/include/utils/excel/class.writeexcel_format.inc.php
--- /dev/null
@@ -0,0 +1,702 @@
+<?php
+
+/*
+ * Copyleft 2002 Johann Hanne
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * This is the Spreadsheet::WriteExcel Perl package ported to PHP
+ * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
+ */
+
+class writeexcel_format {
+
+ var $_xf_index;
+ var $_font_index;
+ var $_font;
+ var $_size;
+ var $_bold;
+ var $_italic;
+ var $_color;
+ var $_underline;
+ var $_font_strikeout;
+ var $_font_outline;
+ var $_font_shadow;
+ var $_font_script;
+ var $_font_family;
+ var $_font_charset;
+ var $_num_format;
+ var $_hidden;
+ var $_locked;
+ var $_text_h_align;
+ var $_text_wrap;
+ var $_text_v_align;
+ var $_text_justlast;
+ var $_rotation;
+ var $_fg_color;
+ var $_bg_color;
+ var $_pattern;
+ var $_bottom;
+ var $_top;
+ var $_left;
+ var $_right;
+ var $_bottom_color;
+ var $_top_color;
+ var $_left_color;
+ var $_right_color;
+
+ /*
+ * Constructor
+ */
+ function writeexcel_format() {
+ $_=func_get_args();
+
+ $this->_xf_index = (sizeof($_)>0) ? array_shift($_) : 0;
+
+ $this->_font_index = 0;
+ $this->_font = 'Arial';
+ $this->_size = 10;
+ $this->_bold = 0x0190;
+ $this->_italic = 0;
+ $this->_color = 0x7FFF;
+ $this->_underline = 0;
+ $this->_font_strikeout = 0;
+ $this->_font_outline = 0;
+ $this->_font_shadow = 0;
+ $this->_font_script = 0;
+ $this->_font_family = 0;
+ $this->_font_charset = 0;
+
+ $this->_num_format = 0;
+
+ $this->_hidden = 0;
+ $this->_locked = 1;
+
+ $this->_text_h_align = 0;
+ $this->_text_wrap = 0;
+ $this->_text_v_align = 2;
+ $this->_text_justlast = 0;
+ $this->_rotation = 0;
+
+ $this->_fg_color = 0x40;
+ $this->_bg_color = 0x41;
+
+ $this->_pattern = 0;
+
+ $this->_bottom = 0;
+ $this->_top = 0;
+ $this->_left = 0;
+ $this->_right = 0;
+
+ $this->_bottom_color = 0x40;
+ $this->_top_color = 0x40;
+ $this->_left_color = 0x40;
+ $this->_right_color = 0x40;
+
+ // Set properties passed to writeexcel_workbook::addformat()
+ if (sizeof($_)>0) {
+ call_user_method_array('set_properties', $this, $_);
+ }
+ }
+
+ /*
+ * Copy the attributes of another writeexcel_format object.
+ */
+ function copy($other) {
+ $xf = $this->_xf_index; // Backup XF index
+
+ /* A better way to copy member vars, ... won't cause fatal errors in PHP5.
+ The only thing i can understand is : For what is this function used,
+ it is never used by any object, as I can see in the source code.
+ ...
+ */
+ foreach(get_object_vars($other) as $var => $val){
+ $this->$var = $val;
+ }
+// $this = $other; // Copy properties
+ $this->_xf_index = $xf; // Restore XF index
+ }
+
+ /*
+ * Generate an Excel BIFF XF record.
+ */
+ function get_xf() {
+
+ $_=func_get_args();
+
+ // $record Record identifier
+ // $length Number of bytes to follow
+
+ // $ifnt Index to FONT record
+ // $ifmt Index to FORMAT record
+ // $style Style and other options
+ // $align Alignment
+ // $icv fg and bg pattern colors
+ // $fill Fill and border line style
+ // $border1 Border line style and color
+ // $border2 Border color
+
+ // Set the type of the XF record and some of the attributes.
+ if ($_[0] == "style") {
+ $style = 0xFFF5;
+ } else {
+ $style = $this->_locked;
+ $style |= $this->_hidden << 1;
+ }
+
+ // Flags to indicate if attributes have been set.
+ $atr_num = ($this->_num_format != 0) ? 1 : 0;
+ $atr_fnt = ($this->_font_index != 0) ? 1 : 0;
+ $atr_alc = $this->_text_wrap ? 1 : 0;
+ $atr_bdr = ($this->_bottom ||
+ $this->_top ||
+ $this->_left ||
+ $this->_right) ? 1 : 0;
+ $atr_pat = ($this->_fg_color != 0x41 ||
+ $this->_bg_color != 0x41 ||
+ $this->_pattern != 0x00) ? 1 : 0;
+ $atr_prot = 0;
+
+ // Reset the default colors for the non-font properties
+ if ($this->_fg_color == 0x7FFF) $this->_fg_color = 0x40;
+ if ($this->_bg_color == 0x7FFF) $this->_bg_color = 0x41;
+ if ($this->_bottom_color == 0x7FFF) $this->_bottom_color = 0x41;
+ if ($this->_top_color == 0x7FFF) $this->_top_color = 0x41;
+ if ($this->_left_color == 0x7FFF) $this->_left_color = 0x41;
+ if ($this->_right_color == 0x7FFF) $this->_right_color = 0x41;
+
+ // Zero the default border colour if the border has not been set.
+ if ($this->_bottom == 0) {
+ $this->_bottom_color = 0;
+ }
+ if ($this->_top == 0) {
+ $this->_top_color = 0;
+ }
+ if ($this->_right == 0) {
+ $this->_right_color = 0;
+ }
+ if ($this->_left == 0) {
+ $this->_left_color = 0;
+ }
+
+ // The following 2 logical statements take care of special cases in
+ // relation to cell colors and patterns:
+ // 1. For a solid fill (_pattern == 1) Excel reverses the role of
+ // foreground and background colors
+ // 2. If the user specifies a foreground or background color
+ // without a pattern they probably wanted a solid fill, so we
+ // fill in the defaults.
+ if ($this->_pattern <= 0x01 &&
+ $this->_bg_color != 0x41 &&
+ $this->_fg_color == 0x40 )
+ {
+ $this->_fg_color = $this->_bg_color;
+ $this->_bg_color = 0x40;
+ $this->_pattern = 1;
+ }
+
+ if ($this->_pattern <= 0x01 &&
+ $this->_bg_color == 0x41 &&
+ $this->_fg_color != 0x40 )
+ {
+ $this->_bg_color = 0x40;
+ $this->_pattern = 1;
+ }
+
+ $record = 0x00E0;
+ $length = 0x0010;
+
+ $ifnt = $this->_font_index;
+ $ifmt = $this->_num_format;
+
+ $align = $this->_text_h_align;
+ $align |= $this->_text_wrap << 3;
+ $align |= $this->_text_v_align << 4;
+ $align |= $this->_text_justlast << 7;
+ $align |= $this->_rotation << 8;
+ $align |= $atr_num << 10;
+ $align |= $atr_fnt << 11;
+ $align |= $atr_alc << 12;
+ $align |= $atr_bdr << 13;
+ $align |= $atr_pat << 14;
+ $align |= $atr_prot << 15;
+
+ $icv = $this->_fg_color;
+ $icv |= $this->_bg_color << 7;
+
+ $fill = $this->_pattern;
+ $fill |= $this->_bottom << 6;
+ $fill |= $this->_bottom_color << 9;
+
+ $border1 = $this->_top;
+ $border1 |= $this->_left << 3;
+ $border1 |= $this->_right << 6;
+ $border1 |= $this->_top_color << 9;
+
+ $border2 = $this->_left_color;
+ $border2 |= $this->_right_color << 7;
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align,
+ $icv, $fill,
+ $border1, $border2);
+
+ return($header . $data);
+ }
+
+ /*
+ * Generate an Excel BIFF FONT record.
+ */
+ function get_font() {
+
+ // $record Record identifier
+ // $length Record length
+
+ // $dyHeight Height of font (1/20 of a point)
+ // $grbit Font attributes
+ // $icv Index to color palette
+ // $bls Bold style
+ // $sss Superscript/subscript
+ // $uls Underline
+ // $bFamily Font family
+ // $bCharSet Character set
+ // $reserved Reserved
+ // $cch Length of font name
+ // $rgch Font name
+
+ $dyHeight = $this->_size * 20;
+ $icv = $this->_color;
+ $bls = $this->_bold;
+ $sss = $this->_font_script;
+ $uls = $this->_underline;
+ $bFamily = $this->_font_family;
+ $bCharSet = $this->_font_charset;
+ $rgch = $this->_font;
+
+ $cch = strlen($rgch);
+ $record = 0x31;
+ $length = 0x0F + $cch;
+ $reserved = 0x00;
+
+ $grbit = 0x00;
+
+ if ($this->_italic) {
+ $grbit |= 0x02;
+ }
+
+ if ($this->_font_strikeout) {
+ $grbit |= 0x08;
+ }
+
+ if ($this->_font_outline) {
+ $grbit |= 0x10;
+ }
+
+ if ($this->_font_shadow) {
+ $grbit |= 0x20;
+ }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls,
+ $sss, $uls, $bFamily,
+ $bCharSet, $reserved, $cch);
+
+ return($header . $data . $this->_font);
+ }
+
+ /*
+ * Returns a unique hash key for a font.
+ * Used by writeexcel_workbook::_store_all_fonts()
+ */
+ function get_font_key() {
+
+ # The following elements are arranged to increase the probability of
+ # generating a unique key. Elements that hold a large range of numbers
+ # eg. _color are placed between two binary elements such as _italic
+ #
+ $key = $this->_font.$this->_size.
+ $this->_font_script.$this->_underline.
+ $this->_font_strikeout.$this->_bold.$this->_font_outline.
+ $this->_font_family.$this->_font_charset.
+ $this->_font_shadow.$this->_color.$this->_italic;
+
+ $key = preg_replace('/ /', '_', $key); # Convert the key to a single word
+
+ return $key;
+ }
+
+ /*
+ * Returns the used by Worksheet->_XF()
+ */
+ function get_xf_index() {
+ return $this->_xf_index;
+ }
+
+ /*
+ * Used in conjunction with the set_xxx_color methods to convert a color
+ * string into a number. Color range is 0..63 but we will restrict it
+ * to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15.
+ */
+ function _get_color($color=false) {
+
+ $colors = array(
+ 'aqua' => 0x0F,
+ 'cyan' => 0x0F,
+ 'black' => 0x08,
+ 'blue' => 0x0C,
+ 'brown' => 0x10,
+ 'magenta' => 0x0E,
+ 'fuchsia' => 0x0E,
+ 'gray' => 0x17,
+ 'grey' => 0x17,
+ 'green' => 0x11,
+ 'lime' => 0x0B,
+ 'navy' => 0x12,
+ 'orange' => 0x35,
+ 'purple' => 0x14,
+ 'red' => 0x0A,
+ 'silver' => 0x16,
+ 'white' => 0x09,
+ 'yellow' => 0x0D
+ );
+
+ // Return the default color, 0x7FFF, if undef,
+ if ($color===false) {
+ return 0x7FFF;
+ }
+
+ // or the color string converted to an integer,
+ if (isset($colors[strtolower($color)])) {
+ return $colors[strtolower($color)];
+ }
+
+ // or the default color if string is unrecognised,
+ if (preg_match('/\D/', $color)) {
+ return 0x7FFF;
+ }
+
+ // or an index < 8 mapped into the correct range,
+ if ($color<8) {
+ return $color + 8;
+ }
+
+ // or the default color if arg is outside range,
+ if ($color>63) {
+ return 0x7FFF;
+ }
+
+ // or an integer in the valid range
+ return $color;
+ }
+
+ /*
+ * Set cell alignment.
+ */
+ function set_align($location) {
+
+ // Ignore numbers
+ if (preg_match('/\d/', $location)) {
+ return;
+ }
+
+ $location = strtolower($location);
+
+ switch ($location) {
+
+ case 'left':
+ $this->set_text_h_align(1);
+ break;
+
+ case 'centre':
+ case 'center':
+ $this->set_text_h_align(2);
+ break;
+
+ case 'right':
+ $this->set_text_h_align(3);
+ break;
+
+ case 'fill':
+ $this->set_text_h_align(4);
+ break;
+
+ case 'justify':
+ $this->set_text_h_align(5);
+ break;
+
+ case 'merge':
+ $this->set_text_h_align(6);
+ break;
+
+ case 'equal_space':
+ $this->set_text_h_align(7);
+ break;
+
+ case 'top':
+ $this->set_text_v_align(0);
+ break;
+
+ case 'vcentre':
+ case 'vcenter':
+ $this->set_text_v_align(1);
+ break;
+ break;
+
+ case 'bottom':
+ $this->set_text_v_align(2);
+ break;
+
+ case 'vjustify':
+ $this->set_text_v_align(3);
+ break;
+
+ case 'vequal_space':
+ $this->set_text_v_align(4);
+ break;
+ }
+ }
+
+ /*
+ * Set vertical cell alignment. This is required by the set_properties()
+ * method to differentiate between the vertical and horizontal properties.
+ */
+ function set_valign($location) {
+ $this->set_align($location);
+ }
+
+ /*
+ * This is an alias for the unintuitive set_align('merge')
+ */
+ function set_merge() {
+ $this->set_text_h_align(6);
+ }
+
+ /*
+ * Bold has a range 0x64..0x3E8.
+ * 0x190 is normal. 0x2BC is bold.
+ */
+ function set_bold($weight=1) {
+
+ if ($weight == 1) {
+ // Bold text
+ $weight = 0x2BC;
+ }
+
+ if ($weight == 0) {
+ // Normal text
+ $weight = 0x190;
+ }
+
+ if ($weight < 0x064) {
+ // Lower bound
+ $weight = 0x190;
+ }
+
+ if ($weight > 0x3E8) {
+ // Upper bound
+ $weight = 0x190;
+ }
+
+ $this->_bold = $weight;
+ }
+
+ /*
+ * Set all cell borders (bottom, top, left, right) to the same style
+ */
+ function set_border($style) {
+ $this->set_bottom($style);
+ $this->set_top($style);
+ $this->set_left($style);
+ $this->set_right($style);
+ }
+
+ /*
+ * Set all cell borders (bottom, top, left, right) to the same color
+ */
+ function set_border_color($color) {
+ $this->set_bottom_color($color);
+ $this->set_top_color($color);
+ $this->set_left_color($color);
+ $this->set_right_color($color);
+ }
+
+ /*
+ * Convert hashes of properties to method calls.
+ */
+ function set_properties() {
+
+ $_=func_get_args();
+
+ $properties=array();
+ foreach($_ as $props) {
+ if (is_array($props)) {
+ $properties=array_merge($properties, $props);
+ } else {
+ $properties[]=$props;
+ }
+ }
+
+ foreach ($properties as $key=>$value) {
+
+ // Strip leading "-" from Tk style properties eg. -color => 'red'.
+ $key = preg_replace('/^-/', '', $key);
+
+ /* Make sure method names are alphanumeric characters only, in
+ case tainted data is passed to the eval(). */
+ if (preg_match('/\W/', $key)) {
+ trigger_error("Unknown property: $key.",
+ E_USER_ERROR);
+ }
+
+ /* Evaling all $values as a strings gets around the problem of
+ some numerical format strings being evaluated as numbers, for
+ example "00000" for a zip code. */
+ if (is_int($key)) {
+ eval("\$this->set_$value();");
+ } else {
+ eval("\$this->set_$key('$value');");
+ }
+
+ }
+ }
+
+ function set_font($font) {
+ $this->_font=$font;
+ }
+
+ function set_size($size) {
+ $this->_size=$size;
+ }
+
+ function set_italic($italic=1) {
+ $this->_italic=$italic;
+ }
+
+ function set_color($color) {
+ $this->_color=$this->_get_color($color);
+ }
+
+ function set_underline($underline=1) {
+ $this->_underline=$underline;
+ }
+
+ function set_font_strikeout($font_strikeout=1) {
+ $this->_font_strikeout=$font_strikeout;
+ }
+
+ function set_font_outline($font_outline=1) {
+ $this->_font_outline=$font_outline;
+ }
+
+ function set_font_shadow($font_shadow=1) {
+ $this->_font_shadow=$font_shadow;
+ }
+
+ function set_font_script($font_script=1) {
+ $this->_font_script=$font_script;
+ }
+
+ /* Undocumented */
+ function set_font_family($font_family=1) {
+ $this->_font_family=$font_family;
+ }
+
+ /* Undocumented */
+ function set_font_charset($font_charset=1) {
+ $this->_font_charset=$font_charset;
+ }
+
+ function set_num_format($num_format=1) {
+ $this->_num_format=$num_format;
+ }
+
+ function set_hidden($hidden=1) {
+ $this->_hidden=$hidden;
+ }
+
+ function set_locked($locked=1) {
+ $this->_locked=$locked;
+ }
+
+ function set_text_h_align($align) {
+ $this->_text_h_align=$align;
+ }
+
+ function set_text_wrap($wrap=1) {
+ $this->_text_wrap=$wrap;
+ }
+
+ function set_text_v_align($align) {
+ $this->_text_v_align=$align;
+ }
+
+ function set_text_justlast($text_justlast=1) {
+ $this->_text_justlast=$text_justlast;
+ }
+
+ function set_rotation($rotation=1) {
+ $this->_rotation=$rotation;
+ }
+
+ function set_fg_color($color) {
+ $this->_fg_color=$this->_get_color($color);
+ }
+
+ function set_bg_color($color) {
+ $this->_bg_color=$this->_get_color($color);
+ }
+
+ function set_pattern($pattern=1) {
+ $this->_pattern=$pattern;
+ }
+
+ function set_bottom($bottom=1) {
+ $this->_bottom=$bottom;
+ }
+
+ function set_top($top=1) {
+ $this->_top=$top;
+ }
+
+ function set_left($left=1) {
+ $this->_left=$left;
+ }
+
+ function set_right($right=1) {
+ $this->_right=$right;
+ }
+
+ function set_bottom_color($color) {
+ $this->_bottom_color=$this->_get_color($color);
+ }
+
+ function set_top_color($color) {
+ $this->_top_color=$this->_get_color($color);
+ }
+
+ function set_left_color($color) {
+ $this->_left_color=$this->_get_color($color);
+ }
+
+ function set_right_color($color) {
+ $this->_right_color=$this->_get_color($color);
+ }
+
+}
+
+?>
diff --git a/gosa-core/include/utils/excel/class.writeexcel_formula.inc.php b/gosa-core/include/utils/excel/class.writeexcel_formula.inc.php
--- /dev/null
@@ -0,0 +1,1413 @@
+<?php
+
+/*
+ * Copyleft 2002 Johann Hanne
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* This file contains source from the PEAR::Spreadsheet class Parser.php file version 0.4 .
+ The raiseError was replaced by triggerError function.
+ The PEAR::isError was imported to keep compatibility to PEAR::Spreadsheet class
+
+ Imported and adapted by Andreas Brodowski 2003 (andreas.brodowski@oscar-gmbh.com).
+
+ There should be no license rights in question because the Parser.php from PEAR class is
+ published under GNU License the same way like this class.
+
+ Changes: 03/08/27 Added SPREADSHEET_EXCEL_WRITER_SCOLON for arg seperation in excel functions
+ */
+
+/*
+ * This is the Spreadsheet::WriteExcel Perl package ported to PHP
+ * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
+ */
+
+define('SPREADSHEET_EXCEL_WRITER_ADD',"+");\r // @const SPREADSHEET_EXCEL_WRITER_ADD token identifier for character "+"\r
+define('SPREADSHEET_EXCEL_WRITER_SUB',"-");\r // @const SPREADSHEET_EXCEL_WRITER_SUB token identifier for character "-"\r
+define('SPREADSHEET_EXCEL_WRITER_MUL',"*");\r // @const SPREADSHEET_EXCEL_WRITER_MUL token identifier for character "*"\r
+define('SPREADSHEET_EXCEL_WRITER_DIV',"/");\r // @const SPREADSHEET_EXCEL_WRITER_DIV token identifier for character "/"\r
+define('SPREADSHEET_EXCEL_WRITER_OPEN',"(");\r // @const SPREADSHEET_EXCEL_WRITER_OPEN token identifier for character "("\r
+define('SPREADSHEET_EXCEL_WRITER_CLOSE',")"); \r // @const SPREADSHEET_EXCEL_WRITER_CLOSE token identifier for character ")"\r
+define('SPREADSHEET_EXCEL_WRITER_COMA',",");\r // @const SPREADSHEET_EXCEL_WRITER_COMA token identifier for character ","\r
+define('SPREADSHEET_EXCEL_WRITER_SCOLON',";"); \r// @const SPREADSHEET_EXCEL_WRITER_SCOLON token identifier for character ";"\r
+define('SPREADSHEET_EXCEL_WRITER_GT',">");\r // @const SPREADSHEET_EXCEL_WRITER_GT token identifier for character ">"\r
+define('SPREADSHEET_EXCEL_WRITER_LT',"<");\r // @const SPREADSHEET_EXCEL_WRITER_LT token identifier for character "<"\r
+define('SPREADSHEET_EXCEL_WRITER_LE',"<=");\r // @const SPREADSHEET_EXCEL_WRITER_LE token identifier for character "<="\r
+define('SPREADSHEET_EXCEL_WRITER_GE',">=");\r // @const SPREADSHEET_EXCEL_WRITER_GE token identifier for character ">="\r
+define('SPREADSHEET_EXCEL_WRITER_EQ',"=");\r // @const SPREADSHEET_EXCEL_WRITER_EQ token identifier for character "="\r
+define('SPREADSHEET_EXCEL_WRITER_NE',"<>");\r // @const SPREADSHEET_EXCEL_WRITER_NE token identifier for character "<>"\r
+\r
+
+class writeexcel_formula {
+
+###############################################################################
+#
+# Class data.
+#
+var $parser;
+var $ptg;
+var $_functions;
+var $_current_char;
+var $_current_token;
+var $_lookahead;
+var $_debug;
+var $_byte_order;
+var $_volatile;
+var $_workbook;
+var $_ext_sheets;
+var $_formula;
+
+###############################################################################
+#
+# new()
+#
+# Constructor
+#
+function writeexcel_formula($byte_order) {
+
+ $this->parser = false;
+ $this->ptg = array();
+ $this->_functions = array();
+ $this->_debug = 0;
+ $this->_byte_order = $byte_order;
+ $this->_volatile = 0;
+ $this->_workbook = "";
+ $this->_ext_sheets = array();
+ $this->_current_token = '';
+ $this->_lookahead = '';
+ $this->_current_char = 0;
+ $this->_formula = '';
+}
+
+###############################################################################
+#
+# _init_parser()
+#
+# There is a small overhead involved in generating the parser. Therefore, the
+# initialisation is delayed until a formula is required. TODO: use a pre-
+# compiled header.
+#
+function _init_parser() {
+
+ $this->_initializeHashes();
+
+
+ if ($this->_debug) {
+ print "Init_parser.\n\n";
+ }
+}
+
+###############################################################################
+#
+# parse_formula()
+#
+# This is the only public method. It takes a textual description of a formula
+# and returns a RPN encoded byte string.
+#
+function parse_formula() {
+
+ $_=func_get_args();
+
+ # Initialise the parser if this is the first call
+ if ($this->parser===false) {
+ $this->_init_parser();
+ }
+
+ $formula = array_shift($_);
+ //$str;
+ //$tokens;
+
+ if ($this->_debug) {
+ print "$formula\n";
+ }
+
+ # Build the parse tree for the formula
+
+ $this->_formula = $formula;
+ $this->_current_char = 0;
+ $this->_lookahead = $this->_formula{1};
+ $this->_advance($formula);
+ $parsetree = $this->_condition();
+
+ $str = $this->toReversePolish($parsetree);
+
+ return $str;
+}
+
+function set_ext_sheet($key, $value) {
+
+ $this->_ext_sheets->$key = $value;
+}
+
+function isError($data) {
+ return (bool)(is_object($data) &&
+ (get_class($data) == 'pear_error' ||
+ is_subclass_of($data, 'pear_error')));
+}
+\r
+/**\r
+* Class for parsing Excel formulas\r
+*\r
+* @author Xavier Noguer <xnoguer@rezebra.com>\r
+* @category FileFormats\r
+* @package Spreadsheet_Excel_Writer\r
+*/\r
+\r
+ \r
+/**\r
+* Initialize the ptg and function hashes. \r
+*\r
+* @access private\r
+*/\r
+function _initializeHashes()\r {\r
+ // The Excel ptg indices\r
+ $this->ptg = array(\r
+ 'ptgExp' => 0x01,\r 'ptgTbl' => 0x02,\r 'ptgAdd' => 0x03,\r 'ptgSub' => 0x04,\r
+ 'ptgMul' => 0x05,\r 'ptgDiv' => 0x06,\r 'ptgPower' => 0x07, 'ptgConcat' => 0x08,\r
+ 'ptgLT' => 0x09,\r 'ptgLE' => 0x0A,\r 'ptgEQ' => 0x0B,\r 'ptgGE' => 0x0C,\r
+ 'ptgGT' => 0x0D,\r 'ptgNE' => 0x0E,\r 'ptgIsect' => 0x0F,\r 'ptgUnion' => 0x10,\r
+ 'ptgRange' => 0x11,\r 'ptgUplus' => 0x12,\r 'ptgUminus' => 0x13,\r 'ptgPercent' => 0x14,\r
+ 'ptgParen' => 0x15,\r 'ptgMissArg' => 0x16,\r 'ptgStr' => 0x17,\r 'ptgAttr' => 0x19,\r
+ 'ptgSheet' => 0x1A,\r 'ptgEndSheet' => 0x1B,\r 'ptgErr' => 0x1C,\r 'ptgBool' => 0x1D,\r
+ 'ptgInt' => 0x1E,\r 'ptgNum' => 0x1F,\r 'ptgArray' => 0x20,\r 'ptgFunc' => 0x21,\r
+ 'ptgFuncVar' => 0x22,\r 'ptgName' => 0x23,\r 'ptgRef' => 0x24,\r 'ptgArea' => 0x25,\r
+ 'ptgMemArea' => 0x26,\r 'ptgMemErr' => 0x27,\r 'ptgMemNoMem' => 0x28,\r 'ptgMemFunc' => 0x29,\r
+ 'ptgRefErr' => 0x2A,\r 'ptgAreaErr' => 0x2B,\r 'ptgRefN' => 0x2C,\r 'ptgAreaN' => 0x2D,\r
+ 'ptgMemAreaN' => 0x2E,\r 'ptgMemNoMemN' => 0x2F,\r 'ptgNameX' => 0x39,\r 'ptgRef3d' => 0x3A,
+\r 'ptgArea3d' => 0x3B,\r 'ptgRefErr3d' => 0x3C,\r 'ptgAreaErr3d' => 0x3D,\r 'ptgArrayV' => 0x40,\r
+ 'ptgFuncV' => 0x41,\r 'ptgFuncVarV' => 0x42,\r 'ptgNameV' => 0x43,\r 'ptgRefV' => 0x44,\r
+ 'ptgAreaV' => 0x45,\r 'ptgMemAreaV' => 0x46,\r 'ptgMemErrV' => 0x47,\r 'ptgMemNoMemV' => 0x48,\r
+ 'ptgMemFuncV' => 0x49,\r 'ptgRefErrV' => 0x4A,\r 'ptgAreaErrV' => 0x4B,\r 'ptgRefNV' => 0x4C,\r
+ 'ptgAreaNV' => 0x4D,\r 'ptgMemAreaNV' => 0x4E,\r 'ptgMemNoMemN' => 0x4F,\r 'ptgFuncCEV' => 0x58,\r
+ 'ptgNameXV' => 0x59,\r 'ptgRef3dV' => 0x5A,\r 'ptgArea3dV' => 0x5B, 'ptgRefErr3dV' => 0x5C,\r
+ 'ptgAreaErr3d' => 0x5D,\r 'ptgArrayA' => 0x60,\r 'ptgFuncA' => 0x61,\r 'ptgFuncVarA' => 0x62,\r
+ 'ptgNameA' => 0x63, 'ptgRefA' => 0x64,\r 'ptgAreaA' => 0x65,\r 'ptgMemAreaA' => 0x66,\r
+ 'ptgMemErrA' => 0x67,\r 'ptgMemNoMemA' => 0x68,\r 'ptgMemFuncA' => 0x69,\r 'ptgRefErrA' => 0x6A,\r
+ 'ptgAreaErrA' => 0x6B,\r 'ptgRefNA' => 0x6C,\r 'ptgAreaNA' => 0x6D,\r 'ptgMemAreaNA' => 0x6E,\r
+ 'ptgMemNoMemN' => 0x6F,\r 'ptgFuncCEA' => 0x78,\r 'ptgNameXA' => 0x79,\r 'ptgRef3dA' => 0x7A,\r
+ 'ptgArea3dA' => 0x7B,\r 'ptgRefErr3dA' => 0x7C,\r 'ptgAreaErr3d' => 0x7D\r
+ );\r
+ \r
+ // Thanks to Michael Meeks and Gnumeric for the initial arg values.\r
+ //\r
+ // The following hash was generated by "function_locale.pl" in the distro.\r
+ // Refer to function_locale.pl for non-English function names.\r
+ //\r
+ // The array elements are as follow:\r
+ // ptg: The Excel function ptg code.\r
+ // args: The number of arguments that the function takes:\r
+ // >=0 is a fixed number of arguments.\r
+ // -1 is a variable number of arguments.\r
+ // class: The reference, value or array class of the function args.\r
+ // vol: The function is volatile.\r
+ //\r
+ $this->_functions = array(\r
+ // function ptg args class vol\r
+ 'COUNT' => array( 0, -1, 0, 0 ),\r
+ 'IF' => array( 1, -1, 1, 0 ),\r
+ 'ISNA' => array( 2, 1, 1, 0 ),\r
+ 'ISERROR' => array( 3, 1, 1, 0 ),\r
+ 'SUM' => array( 4, -1, 0, 0 ),\r
+ 'AVERAGE' => array( 5, -1, 0, 0 ),\r
+ 'MIN' => array( 6, -1, 0, 0 ),\r
+ 'MAX' => array( 7, -1, 0, 0 ),\r
+ 'ROW' => array( 8, -1, 0, 0 ),\r
+ 'COLUMN' => array( 9, -1, 0, 0 ),\r
+ 'NA' => array( 10, 0, 0, 0 ),\r
+ 'NPV' => array( 11, -1, 1, 0 ),\r
+ 'STDEV' => array( 12, -1, 0, 0 ),\r
+ 'DOLLAR' => array( 13, -1, 1, 0 ),\r
+ 'FIXED' => array( 14, -1, 1, 0 ),\r
+ 'SIN' => array( 15, 1, 1, 0 ),\r
+ 'COS' => array( 16, 1, 1, 0 ),\r
+ 'TAN' => array( 17, 1, 1, 0 ),\r
+ 'ATAN' => array( 18, 1, 1, 0 ),\r
+ 'PI' => array( 19, 0, 1, 0 ),\r
+ 'SQRT' => array( 20, 1, 1, 0 ),\r
+ 'EXP' => array( 21, 1, 1, 0 ),\r
+ 'LN' => array( 22, 1, 1, 0 ),\r
+ 'LOG10' => array( 23, 1, 1, 0 ),\r
+ 'ABS' => array( 24, 1, 1, 0 ),\r
+ 'INT' => array( 25, 1, 1, 0 ),\r
+ 'SIGN' => array( 26, 1, 1, 0 ),\r
+ 'ROUND' => array( 27, 2, 1, 0 ),\r
+ 'LOOKUP' => array( 28, -1, 0, 0 ),\r
+ 'INDEX' => array( 29, -1, 0, 1 ),\r
+ 'REPT' => array( 30, 2, 1, 0 ),\r
+ 'MID' => array( 31, 3, 1, 0 ),\r
+ 'LEN' => array( 32, 1, 1, 0 ),\r
+ 'VALUE' => array( 33, 1, 1, 0 ),\r
+ 'TRUE' => array( 34, 0, 1, 0 ),\r
+ 'FALSE' => array( 35, 0, 1, 0 ),\r
+ 'AND' => array( 36, -1, 0, 0 ),\r
+ 'OR' => array( 37, -1, 0, 0 ),\r
+ 'NOT' => array( 38, 1, 1, 0 ),\r
+ 'MOD' => array( 39, 2, 1, 0 ),\r
+ 'DCOUNT' => array( 40, 3, 0, 0 ),\r
+ 'DSUM' => array( 41, 3, 0, 0 ),\r
+ 'DAVERAGE' => array( 42, 3, 0, 0 ),\r
+ 'DMIN' => array( 43, 3, 0, 0 ),\r
+ 'DMAX' => array( 44, 3, 0, 0 ),\r
+ 'DSTDEV' => array( 45, 3, 0, 0 ),\r
+ 'VAR' => array( 46, -1, 0, 0 ),\r
+ 'DVAR' => array( 47, 3, 0, 0 ),\r
+ 'TEXT' => array( 48, 2, 1, 0 ),\r
+ 'LINEST' => array( 49, -1, 0, 0 ),\r
+ 'TREND' => array( 50, -1, 0, 0 ),\r
+ 'LOGEST' => array( 51, -1, 0, 0 ),\r
+ 'GROWTH' => array( 52, -1, 0, 0 ),\r
+ 'PV' => array( 56, -1, 1, 0 ),\r
+ 'FV' => array( 57, -1, 1, 0 ),\r
+ 'NPER' => array( 58, -1, 1, 0 ),\r
+ 'PMT' => array( 59, -1, 1, 0 ),\r
+ 'RATE' => array( 60, -1, 1, 0 ),\r
+ 'MIRR' => array( 61, 3, 0, 0 ),\r
+ 'IRR' => array( 62, -1, 0, 0 ),\r
+ 'RAND' => array( 63, 0, 1, 1 ),\r
+ 'MATCH' => array( 64, -1, 0, 0 ),\r
+ 'DATE' => array( 65, 3, 1, 0 ),\r
+ 'TIME' => array( 66, 3, 1, 0 ),\r
+ 'DAY' => array( 67, 1, 1, 0 ),\r
+ 'MONTH' => array( 68, 1, 1, 0 ),\r
+ 'YEAR' => array( 69, 1, 1, 0 ),\r
+ 'WEEKDAY' => array( 70, -1, 1, 0 ),\r
+ 'HOUR' => array( 71, 1, 1, 0 ),\r
+ 'MINUTE' => array( 72, 1, 1, 0 ),\r
+ 'SECOND' => array( 73, 1, 1, 0 ),\r
+ 'NOW' => array( 74, 0, 1, 1 ),\r
+ 'AREAS' => array( 75, 1, 0, 1 ),\r
+ 'ROWS' => array( 76, 1, 0, 1 ),\r
+ 'COLUMNS' => array( 77, 1, 0, 1 ),\r
+ 'OFFSET' => array( 78, -1, 0, 1 ),\r
+ 'SEARCH' => array( 82, -1, 1, 0 ),\r
+ 'TRANSPOSE' => array( 83, 1, 1, 0 ),\r
+ 'TYPE' => array( 86, 1, 1, 0 ),\r
+ 'ATAN2' => array( 97, 2, 1, 0 ),\r
+ 'ASIN' => array( 98, 1, 1, 0 ),\r
+ 'ACOS' => array( 99, 1, 1, 0 ),\r
+ 'CHOOSE' => array( 100, -1, 1, 0 ),\r
+ 'HLOOKUP' => array( 101, -1, 0, 0 ),\r
+ 'VLOOKUP' => array( 102, -1, 0, 0 ),\r
+ 'ISREF' => array( 105, 1, 0, 0 ),\r
+ 'LOG' => array( 109, -1, 1, 0 ),\r
+ 'CHAR' => array( 111, 1, 1, 0 ),\r
+ 'LOWER' => array( 112, 1, 1, 0 ),\r
+ 'UPPER' => array( 113, 1, 1, 0 ),\r
+ 'PROPER' => array( 114, 1, 1, 0 ),\r
+ 'LEFT' => array( 115, -1, 1, 0 ),\r
+ 'RIGHT' => array( 116, -1, 1, 0 ),\r
+ 'EXACT' => array( 117, 2, 1, 0 ),\r
+ 'TRIM' => array( 118, 1, 1, 0 ),\r
+ 'REPLACE' => array( 119, 4, 1, 0 ),\r
+ 'SUBSTITUTE' => array( 120, -1, 1, 0 ),\r
+ 'CODE' => array( 121, 1, 1, 0 ),\r
+ 'FIND' => array( 124, -1, 1, 0 ),\r
+ 'CELL' => array( 125, -1, 0, 1 ),\r
+ 'ISERR' => array( 126, 1, 1, 0 ),\r
+ 'ISTEXT' => array( 127, 1, 1, 0 ),\r
+ 'ISNUMBER' => array( 128, 1, 1, 0 ),\r
+ 'ISBLANK' => array( 129, 1, 1, 0 ),\r
+ 'T' => array( 130, 1, 0, 0 ),\r
+ 'N' => array( 131, 1, 0, 0 ),\r
+ 'DATEVALUE' => array( 140, 1, 1, 0 ),\r
+ 'TIMEVALUE' => array( 141, 1, 1, 0 ),\r
+ 'SLN' => array( 142, 3, 1, 0 ),\r
+ 'SYD' => array( 143, 4, 1, 0 ),\r
+ 'DDB' => array( 144, -1, 1, 0 ),\r
+ 'INDIRECT' => array( 148, -1, 1, 1 ),\r
+ 'CALL' => array( 150, -1, 1, 0 ),\r
+ 'CLEAN' => array( 162, 1, 1, 0 ),\r
+ 'MDETERM' => array( 163, 1, 2, 0 ),\r
+ 'MINVERSE' => array( 164, 1, 2, 0 ),\r
+ 'MMULT' => array( 165, 2, 2, 0 ),\r
+ 'IPMT' => array( 167, -1, 1, 0 ),\r
+ 'PPMT' => array( 168, -1, 1, 0 ),\r
+ 'COUNTA' => array( 169, -1, 0, 0 ),\r
+ 'PRODUCT' => array( 183, -1, 0, 0 ),\r
+ 'FACT' => array( 184, 1, 1, 0 ),\r
+ 'DPRODUCT' => array( 189, 3, 0, 0 ),\r
+ 'ISNONTEXT' => array( 190, 1, 1, 0 ),\r
+ 'STDEVP' => array( 193, -1, 0, 0 ),\r
+ 'VARP' => array( 194, -1, 0, 0 ),\r
+ 'DSTDEVP' => array( 195, 3, 0, 0 ),\r
+ 'DVARP' => array( 196, 3, 0, 0 ),\r
+ 'TRUNC' => array( 197, -1, 1, 0 ),\r
+ 'ISLOGICAL' => array( 198, 1, 1, 0 ),\r
+ 'DCOUNTA' => array( 199, 3, 0, 0 ),\r
+ 'ROUNDUP' => array( 212, 2, 1, 0 ),\r
+ 'ROUNDDOWN' => array( 213, 2, 1, 0 ),\r
+ 'RANK' => array( 216, -1, 0, 0 ),\r
+ 'ADDRESS' => array( 219, -1, 1, 0 ),\r
+ 'DAYS360' => array( 220, -1, 1, 0 ),\r
+ 'TODAY' => array( 221, 0, 1, 1 ),\r
+ 'VDB' => array( 222, -1, 1, 0 ),\r
+ 'MEDIAN' => array( 227, -1, 0, 0 ),\r
+ 'SUMPRODUCT' => array( 228, -1, 2, 0 ),\r
+ 'SINH' => array( 229, 1, 1, 0 ),\r
+ 'COSH' => array( 230, 1, 1, 0 ),\r
+ 'TANH' => array( 231, 1, 1, 0 ),\r
+ 'ASINH' => array( 232, 1, 1, 0 ),\r
+ 'ACOSH' => array( 233, 1, 1, 0 ),\r
+ 'ATANH' => array( 234, 1, 1, 0 ),\r
+ 'DGET' => array( 235, 3, 0, 0 ),\r
+ 'INFO' => array( 244, 1, 1, 1 ),\r
+ 'DB' => array( 247, -1, 1, 0 ),\r
+ 'FREQUENCY' => array( 252, 2, 0, 0 ),\r
+ 'ERROR.TYPE' => array( 261, 1, 1, 0 ),\r
+ 'REGISTER.ID' => array( 267, -1, 1, 0 ),\r
+ 'AVEDEV' => array( 269, -1, 0, 0 ),\r
+ 'BETADIST' => array( 270, -1, 1, 0 ),\r
+ 'GAMMALN' => array( 271, 1, 1, 0 ),\r
+ 'BETAINV' => array( 272, -1, 1, 0 ),\r
+ 'BINOMDIST' => array( 273, 4, 1, 0 ),\r
+ 'CHIDIST' => array( 274, 2, 1, 0 ),\r
+ 'CHIINV' => array( 275, 2, 1, 0 ),\r
+ 'COMBIN' => array( 276, 2, 1, 0 ),\r
+ 'CONFIDENCE' => array( 277, 3, 1, 0 ),\r
+ 'CRITBINOM' => array( 278, 3, 1, 0 ),\r
+ 'EVEN' => array( 279, 1, 1, 0 ),\r
+ 'EXPONDIST' => array( 280, 3, 1, 0 ),\r
+ 'FDIST' => array( 281, 3, 1, 0 ),\r
+ 'FINV' => array( 282, 3, 1, 0 ),\r
+ 'FISHER' => array( 283, 1, 1, 0 ),\r
+ 'FISHERINV' => array( 284, 1, 1, 0 ),\r
+ 'FLOOR' => array( 285, 2, 1, 0 ),\r
+ 'GAMMADIST' => array( 286, 4, 1, 0 ),\r
+ 'GAMMAINV' => array( 287, 3, 1, 0 ),\r
+ 'CEILING' => array( 288, 2, 1, 0 ),\r
+ 'HYPGEOMDIST' => array( 289, 4, 1, 0 ),\r
+ 'LOGNORMDIST' => array( 290, 3, 1, 0 ),\r
+ 'LOGINV' => array( 291, 3, 1, 0 ),\r
+ 'NEGBINOMDIST' => array( 292, 3, 1, 0 ),\r
+ 'NORMDIST' => array( 293, 4, 1, 0 ),\r
+ 'NORMSDIST' => array( 294, 1, 1, 0 ),\r
+ 'NORMINV' => array( 295, 3, 1, 0 ),\r
+ 'NORMSINV' => array( 296, 1, 1, 0 ),\r
+ 'STANDARDIZE' => array( 297, 3, 1, 0 ),\r
+ 'ODD' => array( 298, 1, 1, 0 ),\r
+ 'PERMUT' => array( 299, 2, 1, 0 ),\r
+ 'POISSON' => array( 300, 3, 1, 0 ),\r
+ 'TDIST' => array( 301, 3, 1, 0 ),\r
+ 'WEIBULL' => array( 302, 4, 1, 0 ),\r
+ 'SUMXMY2' => array( 303, 2, 2, 0 ),\r
+ 'SUMX2MY2' => array( 304, 2, 2, 0 ),\r
+ 'SUMX2PY2' => array( 305, 2, 2, 0 ),\r
+ 'CHITEST' => array( 306, 2, 2, 0 ),\r
+ 'CORREL' => array( 307, 2, 2, 0 ),\r
+ 'COVAR' => array( 308, 2, 2, 0 ),\r
+ 'FORECAST' => array( 309, 3, 2, 0 ),\r
+ 'FTEST' => array( 310, 2, 2, 0 ),\r
+ 'INTERCEPT' => array( 311, 2, 2, 0 ),\r
+ 'PEARSON' => array( 312, 2, 2, 0 ),\r
+ 'RSQ' => array( 313, 2, 2, 0 ),\r
+ 'STEYX' => array( 314, 2, 2, 0 ),\r
+ 'SLOPE' => array( 315, 2, 2, 0 ),\r
+ 'TTEST' => array( 316, 4, 2, 0 ),\r
+ 'PROB' => array( 317, -1, 2, 0 ),\r
+ 'DEVSQ' => array( 318, -1, 0, 0 ),\r
+ 'GEOMEAN' => array( 319, -1, 0, 0 ),\r
+ 'HARMEAN' => array( 320, -1, 0, 0 ),\r
+ 'SUMSQ' => array( 321, -1, 0, 0 ),\r
+ 'KURT' => array( 322, -1, 0, 0 ),\r
+ 'SKEW' => array( 323, -1, 0, 0 ),\r
+ 'ZTEST' => array( 324, -1, 0, 0 ),\r
+ 'LARGE' => array( 325, 2, 0, 0 ),\r
+ 'SMALL' => array( 326, 2, 0, 0 ),\r
+ 'QUARTILE' => array( 327, 2, 0, 0 ),\r
+ 'PERCENTILE' => array( 328, 2, 0, 0 ),\r
+ 'PERCENTRANK' => array( 329, -1, 0, 0 ),\r
+ 'MODE' => array( 330, -1, 2, 0 ),\r
+ 'TRIMMEAN' => array( 331, 2, 0, 0 ),\r
+ 'TINV' => array( 332, 2, 1, 0 ),\r
+ 'CONCATENATE' => array( 336, -1, 1, 0 ),\r
+ 'POWER' => array( 337, 2, 1, 0 ),\r
+ 'RADIANS' => array( 342, 1, 1, 0 ),\r
+ 'DEGREES' => array( 343, 1, 1, 0 ),\r
+ 'SUBTOTAL' => array( 344, -1, 0, 0 ),\r
+ 'SUMIF' => array( 345, -1, 0, 0 ),\r
+ 'COUNTIF' => array( 346, 2, 0, 0 ),\r
+ 'COUNTBLANK' => array( 347, 1, 0, 0 ),\r
+ 'ROMAN' => array( 354, -1, 1, 0 )\r
+ );\r
+}\r
+ \r
+/**\r
+* Convert a token to the proper ptg value.\r
+*\r
+* @access private\r
+* @param mixed $token The token to convert.\r
+* @return mixed the converted token on success. PEAR_Error if the token\r
+* is not recognized\r
+*/\r
+function _convert($token)\r {\r
+ if (preg_match("/^\"[^\"]{0,255}\"$/", $token))\r {\r
+ return $this->_convertString($token);\r
+ }\r elseif (is_numeric($token))\r {\r
+ return $this->_convertNumber($token);\r
+ }\r
+ // match references like A1 or $A$1
+ \relseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/',$token))\r {
+ return $this->_convertRef2d($token);\r
+ }\r
+ // match external references like Sheet1:Sheet2!A1\r
+ elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-Ia-i]?[A-Za-z](\d+)$/",$token))\r {\r
+ return $this->_convertRef3d($token);\r
+ }\r
+ // match ranges like A1:B2\r
+ elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token))\r {\r
+ return $this->_convertRange2d($token);\r
+ }\r
+ // match ranges like A1..B2\r
+ elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token))\r {\r
+ return $this->_convertRange2d($token);\r
+ }\r
+ // match external ranges like Sheet1:Sheet2!A1:B2\r
+ elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/",$token))\r {\r
+ return $this->_convertRange3d($token);\r
+ }\r
+ // match external ranges like 'Sheet1:Sheet2'!A1:B2\r
+ elseif (preg_match("/^'[A-Za-z0-9_ ]+(\:[A-Za-z0-9_ ]+)?'\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/",$token))\r {\r
+ return $this->_convertRange3d($token);\r
+ }\r
+ elseif (isset($this->ptg[$token])) // operators (including parentheses)\r {\r
+ return pack("C", $this->ptg[$token]);\r
+ }\r
+ // commented so argument number can be processed correctly. See toReversePolish().\r
+ /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token))\r
+ {\r
+ return($this->_convertFunction($token,$this->_func_args));\r
+ }*/\r
+ // if it's an argument, ignore the token (the argument remains)\r
+ elseif ($token == 'arg')\r {\r
+ return '';\r
+ }\r
+ // TODO: use real error codes\r
+ trigger_error("Unknown token $token", E_USER_ERROR);\r
+}\r
+ \r
+/**\r
+* Convert a number token to ptgInt or ptgNum\r
+*\r
+* @access private\r
+* @param mixed $num an integer or double for conversion to its ptg value\r
+*/\r
+function _convertNumber($num)\r {\r
+
+ // Integer in the range 0..2**16-1\r
+
+ if ((preg_match("/^\d+$/",$num)) and ($num <= 65535)) {\r
+ return(pack("Cv", $this->ptg['ptgInt'], $num));\r
+ }\r else { // A float\r
+ if ($this->_byte_order) { // if it's Big Endian\r
+ $num = strrev($num);\r
+ }\r
+ return pack("Cd", $this->ptg['ptgNum'], $num);\r
+ }\r
+}\r
+ \r
+/**\r
+* Convert a string token to ptgStr\r
+*\r
+* @access private\r
+* @param string $string A string for conversion to its ptg value\r
+*/\r
+function _convertString($string)\r {\r
+ // chop away beggining and ending quotes\r
+ $string = substr($string, 1, strlen($string) - 2);\r
+ return pack("CC", $this->ptg['ptgStr'], strlen($string)).$string;\r
+}\r
+\r
+/**\r
+* Convert a function to a ptgFunc or ptgFuncVarV depending on the number of\r
+* args that it takes.\r
+*\r
+* @access private\r
+* @param string $token The name of the function for convertion to ptg value.\r
+* @param integer $num_args The number of arguments the function receives.\r
+* @return string The packed ptg for the function\r
+*/\r
+function _convertFunction($token, $num_args)\r {\r
+ $args = $this->_functions[$token][1];\r
+ $volatile = $this->_functions[$token][3];\r
+ \r
+ // Fixed number of args eg. TIME($i,$j,$k).\r
+ if ($args >= 0) {\r
+ return pack("Cv", $this->ptg['ptgFuncV'], $this->_functions[$token][0]);\r
+ }\r
+ // Variable number of args eg. SUM($i,$j,$k, ..).\r
+ if ($args == -1) {\r
+ return pack("CCv", $this->ptg['ptgFuncVarV'], $num_args, $this->_functions[$token][0]);\r
+ }\r
+}\r
+ \r
+/**\r
+* Convert an Excel range such as A1:D4 to a ptgRefV.\r
+*\r
+* @access private\r
+* @param string $range An Excel range in the A1:A2 or A1..A2 format.\r
+*/\r
+function _convertRange2d($range)\r {\r
+ $class = 2; // as far as I know, this is magick.\r
+ \r
+ // Split the range into 2 cell refs\r
+ if (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\:([A-Ia-i]?[A-Za-z])(\d+)$/",$range)) {\r
+ list($cell1, $cell2) = split(':', $range);\r
+ }\r elseif (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\.\.([A-Ia-i]?[A-Za-z])(\d+)$/",$range)) {\r
+ list($cell1, $cell2) = split('\.\.', $range);\r
+ }\r else {\r
+ // TODO: use real error codes\r
+ trigger_error("Unknown range separator", E_USER_ERROR);\r
+ }\r
+ \r
+ // Convert the cell references\r
+ $cell_array1 = $this->_cellToPackedRowcol($cell1);\r
+ if ($this->isError($cell_array1)) {\r
+ return $cell_array1;\r
+ }\r
+ list($row1, $col1) = $cell_array1;\r
+ $cell_array2 = $this->_cellToPackedRowcol($cell2);\r
+ if ($this->isError($cell_array2)) {\r
+ return $cell_array2;\r
+ }\r
+ list($row2, $col2) = $cell_array2;\r
+ \r
+ // The ptg value depends on the class of the ptg.\r
+ if ($class == 0) {\r
+ $ptgArea = pack("C", $this->ptg['ptgArea']);\r
+ }\r elseif ($class == 1) {\r
+ $ptgArea = pack("C", $this->ptg['ptgAreaV']);\r
+ }\r elseif ($class == 2) {\r
+ $ptgArea = pack("C", $this->ptg['ptgAreaA']);\r
+ }\r else {\r
+ // TODO: use real error codes\r
+ trigger_error("Unknown class $class", E_USER_ERROR);\r
+ }\r
+ return $ptgArea . $row1 . $row2 . $col1. $col2;\r
+}\r
+ \r
+/**\r
+* Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to\r
+* a ptgArea3dV.\r
+*\r
+* @access private\r
+* @param string $token An Excel range in the Sheet1!A1:A2 format.\r
+*/\r
+function _convertRange3d($token)\r {\r
+ $class = 2; // as far as I know, this is magick.\r
+\r
+ // Split the ref at the ! symbol\r
+ list($ext_ref, $range) = split('!', $token);\r
+\r
+ // Convert the external reference part\r
+ $ext_ref = $this->_packExtRef($ext_ref);\r
+ if ($this->isError($ext_ref)) {\r
+ return $ext_ref;\r
+ }\r
+\r
+ // Split the range into 2 cell refs\r
+ list($cell1, $cell2) = split(':', $range);\r
+\r
+ // Convert the cell references\r
+ if (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/", $cell1))\r {\r
+ $cell_array1 = $this->_cellToPackedRowcol($cell1);\r
+ if ($this->isError($cell_array1)) {\r
+ return $cell_array1;\r
+ }\r
+ list($row1, $col1) = $cell_array1;\r
+ $cell_array2 = $this->_cellToPackedRowcol($cell2);\r
+ if ($this->isError($cell_array2)) {\r
+ return $cell_array2;\r
+ }\r
+ list($row2, $col2) = $cell_array2;\r
+ }\r else { // It's a columns range (like 26:27)\r
+ $cells_array = $this->_rangeToPackedRange($cell1.':'.$cell2);\r
+ if ($this->isError($cells_array)) {\r
+ return $cells_array;\r
+ }\r
+ list($row1, $col1, $row2, $col2) = $cells_array;\r
+ }\r
+ \r
+ // The ptg value depends on the class of the ptg.\r
+ if ($class == 0) {\r
+ $ptgArea = pack("C", $this->ptg['ptgArea3d']);\r
+ }\r elseif ($class == 1) {\r
+ $ptgArea = pack("C", $this->ptg['ptgArea3dV']);\r
+ }\r elseif ($class == 2) {\r
+ $ptgArea = pack("C", $this->ptg['ptgArea3dA']);\r
+ }\r else {\r
+ trigger_error("Unknown class $class", E_USER_ERROR);\r
+ }\r
+ \r
+ return $ptgArea . $ext_ref . $row1 . $row2 . $col1. $col2;\r
+}\r
+\r
+/**\r
+* Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV.\r
+*\r
+* @access private\r
+* @param string $cell An Excel cell reference\r
+* @return string The cell in packed() format with the corresponding ptg\r
+*/\r
+function _convertRef2d($cell)\r {\r
+ $class = 2; // as far as I know, this is magick.\r
+ \r
+ // Convert the cell reference\r
+ $cell_array = $this->_cellToPackedRowcol($cell);\r
+ if ($this->isError($cell_array)) {\r
+ return $cell_array;\r
+ }\r
+ list($row, $col) = $cell_array;\r
+\r
+ // The ptg value depends on the class of the ptg.\r
+ if ($class == 0) {\r
+ $ptgRef = pack("C", $this->ptg['ptgRef']);\r
+ }\r elseif ($class == 1) {\r
+ $ptgRef = pack("C", $this->ptg['ptgRefV']);\r
+ }\r elseif ($class == 2) {\r
+ $ptgRef = pack("C", $this->ptg['ptgRefA']);\r
+ }\r else {\r
+ // TODO: use real error codes\r
+ trigger_error("Unknown class $class",E_USER_ERROR);\r
+ }\r
+ return $ptgRef.$row.$col;\r
+}\r
+ \r
+/**\r
+* Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a\r
+* ptgRef3dV.\r
+*\r
+* @access private\r
+* @param string $cell An Excel cell reference\r
+* @return string The cell in packed() format with the corresponding ptg\r
+*/\r
+function _convertRef3d($cell)\r {\r
+ $class = 2; // as far as I know, this is magick.\r
+ \r
+ // Split the ref at the ! symbol\r
+ list($ext_ref, $cell) = split('!', $cell);\r
+ \r
+ // Convert the external reference part\r
+ $ext_ref = $this->_packExtRef($ext_ref);\r
+ if ($this->isError($ext_ref)) {\r
+ return $ext_ref;\r
+ }\r
+ \r
+ // Convert the cell reference part\r
+ list($row, $col) = $this->_cellToPackedRowcol($cell);\r
+ \r
+ // The ptg value depends on the class of the ptg.\r
+ if ($class == 0) {\r
+ $ptgRef = pack("C", $this->ptg['ptgRef3d']);\r
+ } elseif ($class == 1) {\r
+ $ptgRef = pack("C", $this->ptg['ptgRef3dV']);\r
+ } elseif ($class == 2) {\r
+ $ptgRef = pack("C", $this->ptg['ptgRef3dA']);\r
+ }\r else {\r
+ trigger_error("Unknown class $class", E_USER_ERROR);\r
+ }\r
+\r
+ return $ptgRef . $ext_ref. $row . $col;\r
+}\r
+\r
+/**\r
+* Convert the sheet name part of an external reference, for example "Sheet1" or\r
+* "Sheet1:Sheet2", to a packed structure.\r
+*\r
+* @access private\r
+* @param string $ext_ref The name of the external reference\r
+* @return string The reference index in packed() format\r
+*/\r
+function _packExtRef($ext_ref) {\r
+ $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.\r
+ $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.\r
+\r
+ // Check if there is a sheet range eg., Sheet1:Sheet2.\r
+ if (preg_match("/:/", $ext_ref))\r {\r
+ list($sheet_name1, $sheet_name2) = split(':', $ext_ref);\r
+\r
+ $sheet1 = $this->_getSheetIndex($sheet_name1);\r
+ if ($sheet1 == -1) {\r
+ trigger_error("Unknown sheet name $sheet_name1 in formula",E_USER_ERROR);\r
+ }\r
+ $sheet2 = $this->_getSheetIndex($sheet_name2);\r
+ if ($sheet2 == -1) {\r
+ trigger_error("Unknown sheet name $sheet_name2 in formula",E_USER_ERROR);\r
+ }\r
+\r
+ // Reverse max and min sheet numbers if necessary\r
+ if ($sheet1 > $sheet2) {\r
+ list($sheet1, $sheet2) = array($sheet2, $sheet1);\r
+ }\r
+ }\r else { // Single sheet name only.\r
+ $sheet1 = $this->_getSheetIndex($ext_ref);\r
+ if ($sheet1 == -1) {\r
+ trigger_error("Unknown sheet name $ext_ref in formula",E_USER_ERROR);\r
+ }\r
+ $sheet2 = $sheet1;\r
+ }\r
+ \r
+ // References are stored relative to 0xFFFF.\r
+ $offset = -1 - $sheet1;\r
+
+ return pack('vdvv', $offset, 0x00, $sheet1, $sheet2);\r
+}\r
+\r
+/**\r
+* Look up the index that corresponds to an external sheet name. The hash of\r
+* sheet names is updated by the addworksheet() method of the \r
+* Spreadsheet_Excel_Writer_Workbook class.\r
+*\r
+* @access private\r
+* @return integer\r
+*/\r
+function _getSheetIndex($sheet_name)\r {\r
+ if (!isset($this->_ext_sheets[$sheet_name])) {\r
+ return -1;\r
+ }\r else {\r
+ return $this->_ext_sheets[$sheet_name];\r
+ }\r
+}\r
+\r
+/**\r
+* This method is used to update the array of sheet names. It is\r
+* called by the addWorksheet() method of the Spreadsheet_Excel_Writer_Workbook class.\r
+*\r
+* @access private\r
+* @param string $name The name of the worksheet being added\r
+* @param integer $index The index of the worksheet being added\r
+*/\r
+function setExtSheet($name, $index)\r {\r
+ $this->_ext_sheets[$name] = $index;\r
+}\r
+\r
+/**\r
+* pack() row and column into the required 3 byte format.\r
+*\r
+* @access private\r
+* @param string $cell The Excel cell reference to be packed\r
+* @return array Array containing the row and column in packed() format\r
+*/\r
+function _cellToPackedRowcol($cell)\r {\r
+ $cell = strtoupper($cell);\r
+ list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell);\r
+ if ($col >= 256) {\r
+ trigger_error("Column in: $cell greater than 255", E_USER_ERROR);\r
+ }\r
+ if ($row >= 16384) {\r
+ trigger_error("Row in: $cell greater than 16384 ", E_USER_ERROR);\r
+ }\r
+\r
+ // Set the high bits to indicate if row or col are relative.\r
+ $row |= $col_rel << 14;\r
+ $row |= $row_rel << 15;\r
+\r
+ $row = pack('v', $row);\r
+ $col = pack('C', $col);\r
+\r
+ return array($row, $col);\r
+}\r
+ \r
+/**\r
+* pack() row range into the required 3 byte format.\r
+* Just using maximun col/rows, which is probably not the correct solution\r
+*\r
+* @access private\r
+* @param string $range The Excel range to be packed\r
+* @return array Array containing (row1,col1,row2,col2) in packed() format\r
+*/\r
+function _rangeToPackedRange($range)\r {\r
+ preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match);\r
+ // return absolute rows if there is a $ in the ref\r
+ $row1_rel = empty($match[1]) ? 1 : 0;\r
+ $row1 = $match[2];\r
+ $row2_rel = empty($match[3]) ? 1 : 0;\r
+ $row2 = $match[4];\r
+ // Convert 1-index to zero-index\r
+ $row1--;\r
+ $row2--;\r
+ // Trick poor inocent Excel\r
+ $col1 = 0;\r
+ $col2 = 16383; // maximum possible value for Excel 5 (change this!!!)\r
+
+ //list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell);\r
+ if (($row1 >= 16384) or ($row2 >= 16384)) {\r
+ trigger_error("Row in: $range greater than 16384 ",E_USER_ERROR);\r
+ }\r
+\r
+ // Set the high bits to indicate if rows are relative.\r
+ $row1 |= $row1_rel << 14;\r
+ $row2 |= $row2_rel << 15;\r
+\r
+ $row1 = pack('v', $row1);\r
+ $row2 = pack('v', $row2);\r
+ $col1 = pack('C', $col1);\r
+ $col2 = pack('C', $col2);\r
+\r
+ return array($row1, $col1, $row2, $col2);\r
+}\r
+\r
+/**\r
+* Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero\r
+* indexed row and column number. Also returns two (0,1) values to indicate\r
+* whether the row or column are relative references.\r
+*\r
+* @access private\r
+* @param string $cell The Excel cell reference in A1 format.\r
+* @return array\r
+*/\r
+function _cellToRowcol($cell)\r {\r
+ preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match);\r
+ // return absolute column if there is a $ in the ref\r
+ $col_rel = empty($match[1]) ? 1 : 0;\r
+ $col_ref = $match[2];\r
+ $row_rel = empty($match[3]) ? 1 : 0;\r
+ $row = $match[4];\r
+ \r
+ // Convert base26 column string to a number.\r
+ $expn = strlen($col_ref) - 1;\r
+ $col = 0;\r
+ for ($i=0; $i < strlen($col_ref); $i++)\r {\r
+ $col += (ord($col_ref{$i}) - ord('A') + 1) * pow(26, $expn);\r
+ $expn--;\r
+ }\r
+ \r
+ // Convert 1-index to zero-index\r
+ $row--;\r
+ $col--;\r
+ \r
+ return array($row, $col, $row_rel, $col_rel);\r
+}\r
+ \r
+/**\r
+* Advance to the next valid token.\r
+*\r
+* @access private\r
+*/\r
+function _advance()\r {\r
+ $i = $this->_current_char;\r
+ // eat up white spaces\r
+ if ($i < strlen($this->_formula))\r {\r
+ while ($this->_formula{$i} == " ") {\r
+ $i++;\r
+ }\r
+ if ($i < strlen($this->_formula) - 1) {\r
+ $this->_lookahead = $this->_formula{$i+1};\r
+ }\r
+ $token = "";\r
+ }\r
+ while ($i < strlen($this->_formula))\r {\r
+ $token .= $this->_formula{$i};\r
+ if ($i < strlen($this->_formula) - 1) {\r
+ $this->_lookahead = $this->_formula{$i+1};\r
+ }\r else {\r
+ $this->_lookahead = '';\r
+ }\r
+ if ($this->_match($token) != '')\r {\r
+ //if ($i < strlen($this->_formula) - 1) {\r
+ // $this->_lookahead = $this->_formula{$i+1};\r
+ //}\r
+ $this->_current_char = $i + 1;\r
+ $this->_current_token = $token;\r
+ return 1;\r
+ }\r
+ if ($i < strlen($this->_formula) - 2) {\r
+ $this->_lookahead = $this->_formula{$i+2};\r
+ }\r else {\r
+ // if we run out of characters _lookahead becomes empty\r
+ $this->_lookahead = '';\r
+ }\r
+ $i++;\r
+ }\r
+ //die("Lexical error ".$this->_current_char);\r
+}\r
+ \r
+/**\r
+* Checks if it's a valid token.\r
+*\r
+* @access private\r
+* @param mixed $token The token to check.\r
+* @return mixed The checked token or false on failure\r
+*/\r
+function _match($token)\r {\r
+ switch($token)\r {\r
+ case SPREADSHEET_EXCEL_WRITER_ADD:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_SUB:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_MUL:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_DIV:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_OPEN:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_CLOSE:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_SCOLON:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_COMA:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_GT:\r
+ if ($this->_lookahead == '=') { // it's a GE token\r
+ break;\r
+ }\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_LT:\r
+ // it's a LE or a NE token\r
+ if (($this->_lookahead == '=') or ($this->_lookahead == '>')) {\r
+ break;\r
+ }\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_GE:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_LE:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_EQ:\r
+ return($token);\r
+ break;\r
+ case SPREADSHEET_EXCEL_WRITER_NE:\r
+ return($token);\r
+ break;\r
+ default:\r
+ // if it's a reference\r
+ if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and\r
+ !ereg("[0-9]",$this->_lookahead) and \r
+ ($this->_lookahead != ':') and ($this->_lookahead != '.') and\r
+ ($this->_lookahead != '!'))\r {\r
+ return $token;\r
+ }\r
+ // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)\r
+ elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-Ia-i]?[A-Za-z][0-9]+$/",$token) and\r
+ !ereg("[0-9]",$this->_lookahead) and\r
+ ($this->_lookahead != ':') and ($this->_lookahead != '.'))\r {\r
+ return $token;\r
+ }\r
+ // if it's a range (A1:A2)\r
+ elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and \r
+ !ereg("[0-9]",$this->_lookahead))\r {\r
+ return $token;\r
+ }\r
+ // if it's a range (A1..A2)\r
+ elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and \r
+ !ereg("[0-9]",$this->_lookahead))\r {\r
+ return $token;\r
+ }\r
+ // If it's an external range like Sheet1:Sheet2!A1:B2\r
+ elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/",$token) and\r
+ !ereg("[0-9]",$this->_lookahead))\r {\r
+ return $token;\r
+ }\r
+ // If it's an external range like 'Sheet1:Sheet2'!A1:B2\r
+ elseif (preg_match("/^'[A-Za-z0-9_ ]+(\:[A-Za-z0-9_ ]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/",$token) and\r
+ !ereg("[0-9]",$this->_lookahead))\r {\r
+ return $token;\r
+ }\r
+ // If it's a number (check that it's not a sheet name or range)\r
+ elseif (is_numeric($token) and \r
+ (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and\r
+ ($this->_lookahead != '!') and ($this->_lookahead != ':'))\r {\r
+ return $token;\r
+ }\r
+ // If it's a string (of maximum 255 characters)\r
+ elseif (ereg("^\"[^\"]{0,255}\"$",$token))\r {\r
+ return $token;\r
+ }\r
+ // if it's a function call\r
+ elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "(")) {\r
+ return $token;\r
+ }\r
+ return '';\r
+ }\r
+}\r
+ \r
+/**\r
+* The parsing method. It parses a formula.\r
+*\r
+* @access public\r
+* @param string $formula The formula to parse, without the initial equal sign (=).\r
+*/\r
+function parse($formula)\r {\r
+ $this->_current_char = 0;\r
+ $this->_formula = $formula;\r
+ $this->_lookahead = $formula{1};\r
+ $this->_advance();\r
+ $this->_parse_tree = $this->_condition();\r
+ if ($this->isError($this->_parse_tree)) {\r
+ return $this->_parse_tree;\r
+ }\r
+}\r
+ \r
+/**\r
+* It parses a condition. It assumes the following rule:\r
+* Cond -> Expr [(">" | "<") Expr]\r
+*\r
+* @access private\r
+* @return mixed The parsed ptg'd tree\r
+*/\r
+function _condition()\r {\r
+ $result = $this->_expression();\r
+ if ($this->isError($result)) {\r
+ return $result;\r
+ }\r
+ if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_LT)\r {\r
+ $this->_advance();\r
+ $result2 = $this->_expression();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgLT', $result, $result2);\r
+ }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_GT) \r{\r
+ $this->_advance();\r
+ $result2 = $this->_expression();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgGT', $result, $result2);\r
+ }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_LE) \r{\r
+ $this->_advance();\r
+ $result2 = $this->_expression();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgLE', $result, $result2);\r
+ }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_GE) \r{\r
+ $this->_advance();\r
+ $result2 = $this->_expression();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgGE', $result, $result2);\r
+ }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_EQ) \r{\r
+ $this->_advance();\r
+ $result2 = $this->_expression();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgEQ', $result, $result2);\r
+ }\r elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_NE) \r{\r
+ $this->_advance();\r
+ $result2 = $this->_expression();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgNE', $result, $result2);\r
+ }\r
+ return $result;\r
+}\r
+
+/**\r
+* It parses a expression. It assumes the following rule:\r
+* Expr -> Term [("+" | "-") Term]\r
+*\r
+* @access private\r
+* @return mixed The parsed ptg'd tree\r
+*/\r
+function _expression()\r {\r
+ // If it's a string return a string node\r
+ if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token))\r {\r
+ $result = $this->_createTree($this->_current_token, '', '');\r
+ $this->_advance();\r
+ return $result;\r
+ }\r
+ $result = $this->_term();\r
+ if ($this->isError($result)) {\r
+ return $result;\r
+ }\r
+ while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD) or \r
+ ($this->_current_token == SPREADSHEET_EXCEL_WRITER_SUB))\r {\r
+ if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD)\r \r{
+ $this->_advance();\r
+ $result2 = $this->_term();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgAdd', $result, $result2);\r
+ }\r else \r{\r
+ $this->_advance();\r
+ $result2 = $this->_term();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgSub', $result, $result2);\r
+ }\r
+ }\r
+ return $result;\r
+}\r
+ \r
+/**\r
+* This function just introduces a ptgParen element in the tree, so that Excel\r
+* doesn't get confused when working with a parenthesized formula afterwards.\r
+*\r
+* @access private\r
+* @see _fact()\r
+* @return mixed The parsed ptg'd tree\r
+*/\r
+function _parenthesizedExpression()\r {\r
+ $result = $this->_createTree('ptgParen', $this->_expression(), '');\r
+ return $result;\r
+}\r
+ \r
+/**\r
+* It parses a term. It assumes the following rule:\r
+* Term -> Fact [("*" | "/") Fact]\r
+*\r
+* @access private\r
+* @return mixed The parsed ptg'd tree\r
+*/\r
+function _term()\r {\r
+ $result = $this->_fact();\r
+ if ($this->isError($result)) {\r
+ return $result;\r
+ }\r
+ while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL) or \r
+ ($this->_current_token == SPREADSHEET_EXCEL_WRITER_DIV)) {
+ if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL)\r \r{
+ $this->_advance();\r
+ $result2 = $this->_fact();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgMul', $result, $result2);\r
+ }\r else \r{\r
+ $this->_advance();\r
+ $result2 = $this->_fact();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('ptgDiv', $result, $result2);\r
+ }\r
+ }\r
+ return $result;\r
+}\r
+ \r
+/**\r
+* It parses a factor. It assumes the following rule:\r
+* Fact -> ( Expr )\r
+* | CellRef\r
+* | CellRange\r
+* | Number\r
+* | Function\r
+*\r
+* @access private\r
+* @return mixed The parsed ptg'd tree\r
+*/\r
+function _fact()\r {\r
+ if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_OPEN)\r {\r
+ $this->_advance(); // eat the "("\r
+ $result = $this->_parenthesizedExpression();\r
+ if ($this->_current_token != SPREADSHEET_EXCEL_WRITER_CLOSE) {\r
+ trigger_error("')' token expected.",E_USER_ERROR);\r
+ }\r
+ $this->_advance(); // eat the ")"\r
+ return $result;\r
+ }\r if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$this->_current_token))\r {\r
+ // if it's a reference\r
+ $result = $this->_createTree($this->_current_token, '', '');\r
+ $this->_advance();\r
+ return $result;\r
+ }\r elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-Ia-i]?[A-Za-z][0-9]+$/",$this->_current_token))\r {\r
+ // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)\r
+ $result = $this->_createTree($this->_current_token, '', '');\r
+ $this->_advance();\r
+ return $result;\r
+ }\r elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or \r
+ preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token))\r {\r
+ // if it's a range\r
+ $result = $this->_current_token;\r
+ $this->_advance();\r
+ return $result;\r
+ }\r elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/",$this->_current_token))\r {\r
+ // If it's an external range (Sheet1!A1:B2)\r
+ $result = $this->_current_token;\r
+ $this->_advance();\r
+ return $result;\r
+ }\r elseif (preg_match("/^'[A-Za-z0-9_ ]+(\:[A-Za-z0-9_ ]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/",$this->_current_token))\r {\r
+ // If it's an external range ('Sheet1'!A1:B2)\r
+ $result = $this->_current_token;\r
+ $this->_advance();\r
+ return $result;\r
+ }\r elseif (is_numeric($this->_current_token))\r {\r
+ $result = $this->_createTree($this->_current_token, '', '');\r
+ $this->_advance();\r
+ return $result;\r
+ }\r elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token))\r {\r
+ // if it's a function call\r
+ $result = $this->_func();\r
+ return $result;\r
+ }\r
+ trigger_error("Sintactic error: ".$this->_current_token.", lookahead: ".\r
+ $this->_lookahead.", current char: ".$this->_current_char, E_USER_ERROR);\r
+}\r
+ \r
+/**\r
+* It parses a function call. It assumes the following rule:\r
+* Func -> ( Expr [,Expr]* )\r
+*\r
+* @access private\r
+*/\r
+function _func()\r {\r
+ $num_args = 0; // number of arguments received\r
+ $function = $this->_current_token;\r
+ $this->_advance();\r
+ $this->_advance(); // eat the "("\r
+ while ($this->_current_token != ')')\r {\r
+ if ($num_args > 0)\r {\r
+ if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_COMA ||
+ $this->_current_token == SPREADSHEET_EXCEL_WRITER_SCOLON) {\r
+ $this->_advance(); // eat the ","\r
+ }\r else {\r
+ trigger_error("Sintactic error: coma expected in ".\r
+ "function $function, {$num_args}º arg", E_USER_ERROR);\r
+ }\r
+ $result2 = $this->_condition();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('arg', $result, $result2);\r
+ }\r else { // first argument\r
+ $result2 = $this->_condition();\r
+ if ($this->isError($result2)) {\r
+ return $result2;\r
+ }\r
+ $result = $this->_createTree('arg', '', $result2);\r
+ }\r
+ $num_args++;\r
+ }\r
+ $args = $this->_functions[$function][1];\r
+ // If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid.\r
+ if (($args >= 0) and ($args != $num_args)) {\r
+ trigger_error("Incorrect number of arguments in function $function() ",E_USER_ERROR);\r
+ }\r
+\r
+ $result = $this->_createTree($function, $result, $num_args);\r
+ $this->_advance(); // eat the ")"\r
+ return $result;\r
+}\r
+ \r
+/**\r
+* Creates a tree. In fact an array which may have one or two arrays (sub-trees)\r
+* as elements.\r
+*\r
+* @access private\r
+* @param mixed $value The value of this node.\r
+* @param mixed $left The left array (sub-tree) or a final node.\r
+* @param mixed $right The right array (sub-tree) or a final node.\r
+*/\r
+function _createTree($value, $left, $right)\r {\r
+ return(array('value' => $value, 'left' => $left, 'right' => $right));\r
+}\r
+ \r
+/**\r
+* Builds a string containing the tree in reverse polish notation (What you \r
+* would use in a HP calculator stack).\r
+* The following tree:\r
+* \r
+* +\r
+* / \\r
+* 2 3\r
+*\r
+* produces: "23+"\r
+*\r
+* The following tree:\r
+*\r
+* +\r
+* / \\r
+* 3 *\r
+* / \\r
+* 6 A1\r
+*\r
+* produces: "36A1*+"\r
+*\r
+* In fact all operands, functions, references, etc... are written as ptg's\r
+*\r
+* @access public\r
+* @param array $tree The optional tree to convert.\r
+* @return string The tree in reverse polish notation\r
+*/\r
+function toReversePolish($tree = array())\r {\r
+ $polish = ""; // the string we are going to return\r
+ if (empty($tree)) { // If it's the first call use _parse_tree\r
+ $tree = $this->_parse_tree;\r
+ }\r
+ if (is_array($tree['left']))\r {\r
+ $converted_tree = $this->toReversePolish($tree['left']);\r
+ if ($this->isError($converted_tree)) {\r
+ return $converted_tree;\r
+ }\r
+ $polish .= $converted_tree;\r
+ }\r elseif ($tree['left'] != '') { // It's a final node\r
+ $converted_tree = $this->_convert($tree['left']);\r
+ if ($this->isError($converted_tree)) {\r
+ return $converted_tree;\r
+ }\r
+ $polish .= $converted_tree;\r
+ }\r
+ if (is_array($tree['right']))\r {\r
+ $converted_tree = $this->toReversePolish($tree['right']);\r
+ if ($this->isError($converted_tree)) {\r
+ return $converted_tree;\r
+ }\r
+ $polish .= $converted_tree;\r
+ }\r elseif ($tree['right'] != '') { // It's a final node\r
+ $converted_tree = $this->_convert($tree['right']);\r
+ if ($this->isError($converted_tree)) {\r
+ return $converted_tree;\r
+ }\r
+ $polish .= $converted_tree;\r
+ }\r
+ // if it's a function convert it here (so we can set it's arguments)\r
+ if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/",$tree['value']) and\r
+ !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and\r
+ !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and\r
+ !is_numeric($tree['value']) and\r
+ !isset($this->ptg[$tree['value']]))\r {\r
+ // left subtree for a function is always an array.\r
+ if ($tree['left'] != '') {\r
+ $left_tree = $this->toReversePolish($tree['left']);\r
+ }\r else {\r
+ $left_tree = '';\r
+ }\r
+ if ($this->isError($left_tree)) {\r
+ return $left_tree;\r
+ }\r
+ // add it's left subtree and return.\r
+ return $left_tree.$this->_convertFunction($tree['value'], $tree['right']);\r
+ }\r else\r {\r
+ $converted_tree = $this->_convert($tree['value']);\r
+ if ($this->isError($converted_tree)) {\r
+ return $converted_tree;\r
+ }\r
+ }\r
+ $polish .= $converted_tree;\r
+ return $polish;\r
+}\r
+
+}\r
+
+
+?>
diff --git a/gosa-core/include/utils/excel/class.writeexcel_olewriter.inc.php b/gosa-core/include/utils/excel/class.writeexcel_olewriter.inc.php
--- /dev/null
@@ -0,0 +1,353 @@
+<?php
+
+/*
+ * Copyleft 2002 Johann Hanne
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * This is the Spreadsheet::WriteExcel Perl package ported to PHP
+ * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
+ */
+
+class writeexcel_olewriter {
+ var $_OLEfilename;
+ var $_OLEtmpfilename; /* ABR */
+ var $_filehandle;
+ var $_fileclosed;
+ var $_internal_fh;
+ var $_biff_only;
+ var $_size_allowed;
+ var $_biffsize;
+ var $_booksize;
+ var $_big_blocks;
+ var $_list_blocks;
+ var $_root_start;
+ var $_block_count;
+
+ /*
+ * Constructor
+ */
+ function writeexcel_olewriter($filename) {
+
+ $this->_OLEfilename = $filename;
+ $this->_filehandle = false;
+ $this->_fileclosed = 0;
+ $this->_internal_fh = 0;
+ $this->_biff_only = 0;
+ $this->_size_allowed = 0;
+ $this->_biffsize = 0;
+ $this->_booksize = 0;
+ $this->_big_blocks = 0;
+ $this->_list_blocks = 0;
+ $this->_root_start = 0;
+ $this->_block_count = 4;
+
+ $this->_initialize();
+ }
+
+ /*
+ * Check for a valid filename and store the filehandle.
+ */
+ function _initialize() {
+ $OLEfile = $this->_OLEfilename;
+
+ /* Check for a filename. Workbook.pm will catch this first. */
+ if ($OLEfile == '') {
+ trigger_error("Filename required", E_USER_ERROR);
+ }
+
+ /*
+ * If the filename is a resource it is assumed that it is a valid
+ * filehandle, if not we create a filehandle.
+ */
+ if (is_resource($OLEfile)) {
+ $fh = $OLEfile;
+ } else {
+ // Create a new file, open for writing
+ $fh = fopen($OLEfile, "wb");
+ // The workbook class also checks this but something may have
+ // happened since then.
+ if (!$fh) {
+ trigger_error("Can't open $OLEfile. It may be in use or ".
+ "protected", E_USER_ERROR);
+ }
+
+ $this->_internal_fh = 1;
+ }
+
+ // Store filehandle
+ $this->_filehandle = $fh;
+ }
+
+ /*
+ * Set the size of the data to be written to the OLE stream
+ *
+ * $big_blocks = (109 depot block x (128 -1 marker word)
+ * - (1 x end words)) = 13842
+ * $maxsize = $big_blocks * 512 bytes = 7087104
+ */
+ function set_size($size) {
+ $maxsize = 7087104;
+
+ if ($size > $maxsize) {
+ trigger_error("Maximum file size, $maxsize, exceeded. To create ".
+ "files bigger than this limit please use the ".
+ "workbookbig class.", E_USER_ERROR);
+ return ($this->_size_allowed = 0);
+ }
+
+ $this->_biffsize = $size;
+
+ // Set the min file size to 4k to avoid having to use small blocks
+ if ($size > 4096) {
+ $this->_booksize = $size;
+ } else {
+ $this->_booksize = 4096;
+ }
+
+ return ($this->_size_allowed = 1);
+ }
+
+ /*
+ * Calculate various sizes needed for the OLE stream
+ */
+ function _calculate_sizes() {
+ $datasize = $this->_booksize;
+
+ if ($datasize % 512 == 0) {
+ $this->_big_blocks = $datasize/512;
+ } else {
+ $this->_big_blocks = floor($datasize/512)+1;
+ }
+ // There are 127 list blocks and 1 marker blocks for each big block
+ // depot + 1 end of chain block
+ $this->_list_blocks = floor(($this->_big_blocks)/127)+1;
+ $this->_root_start = $this->_big_blocks;
+
+ //print $this->_biffsize. "\n";
+ //print $this->_big_blocks. "\n";
+ //print $this->_list_blocks. "\n";
+ }
+
+ /*
+ * Write root entry, big block list and close the filehandle.
+ * This method must be called so that the file contents are
+ * actually written.
+ */
+ function close() {
+
+ if (!$this->_size_allowed) {
+ return;
+ }
+
+ if (!$this->_biff_only) {
+ $this->_write_padding();
+ $this->_write_property_storage();
+ $this->_write_big_block_depot();
+ }
+
+ // Close the filehandle if it was created internally.
+ if ($this->_internal_fh) {
+ fclose($this->_filehandle);
+ }
+/* ABR */
+ if ($this->_OLEtmpfilename != '') {
+ $fh = fopen($this->_OLEtmpfilename, "rb");
+ if ($fh == false) {
+ trigger_error("Can't read temporary file.", E_USER_ERROR);
+ }
+ fpassthru($fh);
+ fclose($fh);
+ unlink($this->_OLEtmpfilename);
+ };
+
+ $this->_fileclosed = 1;
+ }
+
+ /*
+ * Write BIFF data to OLE file.
+ */
+ function write($data) {
+ fputs($this->_filehandle, $data);
+ }
+
+ /*
+ * Write OLE header block.
+ */
+ function write_header() {
+ if ($this->_biff_only) {
+ return;
+ }
+
+ $this->_calculate_sizes();
+
+ $root_start = $this->_root_start;
+ $num_lists = $this->_list_blocks;
+
+ $id = pack("C8", 0xD0, 0xCF, 0x11, 0xE0,
+ 0xA1, 0xB1, 0x1A, 0xE1);
+ $unknown1 = pack("VVVV", 0x00, 0x00, 0x00, 0x00);
+ $unknown2 = pack("vv", 0x3E, 0x03);
+ $unknown3 = pack("v", -2);
+ $unknown4 = pack("v", 0x09);
+ $unknown5 = pack("VVV", 0x06, 0x00, 0x00);
+ $num_bbd_blocks = pack("V", $num_lists);
+ $root_startblock = pack("V", $root_start);
+ $unknown6 = pack("VV", 0x00, 0x1000);
+ $sbd_startblock = pack("V", -2);
+ $unknown7 = pack("VVV", 0x00, -2 ,0x00);
+ $unused = pack("V", -1);
+
+ fputs($this->_filehandle, $id);
+ fputs($this->_filehandle, $unknown1);
+ fputs($this->_filehandle, $unknown2);
+ fputs($this->_filehandle, $unknown3);
+ fputs($this->_filehandle, $unknown4);
+ fputs($this->_filehandle, $unknown5);
+ fputs($this->_filehandle, $num_bbd_blocks);
+ fputs($this->_filehandle, $root_startblock);
+ fputs($this->_filehandle, $unknown6);
+ fputs($this->_filehandle, $sbd_startblock);
+ fputs($this->_filehandle, $unknown7);
+
+ for ($c=1;$c<=$num_lists;$c++) {
+ $root_start++;
+ fputs($this->_filehandle, pack("V", $root_start));
+ }
+
+ for ($c=$num_lists;$c<=108;$c++) {
+ fputs($this->_filehandle, $unused);
+ }
+ }
+
+ /*
+ * Write big block depot.
+ */
+ function _write_big_block_depot() {
+ $num_blocks = $this->_big_blocks;
+ $num_lists = $this->_list_blocks;
+ $total_blocks = $num_lists * 128;
+ $used_blocks = $num_blocks + $num_lists + 2;
+
+ $marker = pack("V", -3);
+ $end_of_chain = pack("V", -2);
+ $unused = pack("V", -1);
+
+ for ($i=1;$i<=($num_blocks-1);$i++) {
+ fputs($this->_filehandle, pack("V", $i));
+ }
+
+ fputs($this->_filehandle, $end_of_chain);
+ fputs($this->_filehandle, $end_of_chain);
+
+ for ($c=1;$c<=$num_lists;$c++) {
+ fputs($this->_filehandle, $marker);
+ }
+
+ for ($c=$used_blocks;$c<=$total_blocks;$c++) {
+ fputs($this->_filehandle, $unused);
+ }
+ }
+
+ /*
+ * Write property storage. TODO: add summary sheets
+ */
+ function _write_property_storage() {
+ $rootsize = -2;
+ $booksize = $this->_booksize;
+
+ // name type dir start size
+ $this->_write_pps('Root Entry', 0x05, 1, -2, 0x00);
+ $this->_write_pps('Book', 0x02, -1, 0x00, $booksize);
+ $this->_write_pps('', 0x00, -1, 0x00, 0x0000);
+ $this->_write_pps('', 0x00, -1, 0x00, 0x0000);
+ }
+
+ /*
+ * Write property sheet in property storage
+ */
+ function _write_pps($name, $type, $dir, $start, $size) {
+ $names = array();
+ $length = 0;
+
+ if ($name != '') {
+ $name = $name . "\0";
+ // Simulate a Unicode string
+ $chars=preg_split("''", $name, -1, PREG_SPLIT_NO_EMPTY);
+ foreach ($chars as $char) {
+ array_push($names, ord($char));
+ }
+ $length = strlen($name) * 2;
+ }
+
+ $rawname = call_user_func_array('pack', array_merge(array("v*"), $names));
+ $zero = pack("C", 0);
+
+ $pps_sizeofname = pack("v", $length); //0x40
+ $pps_type = pack("v", $type); //0x42
+ $pps_prev = pack("V", -1); //0x44
+ $pps_next = pack("V", -1); //0x48
+ $pps_dir = pack("V", $dir); //0x4c
+
+ $unknown1 = pack("V", 0);
+
+ $pps_ts1s = pack("V", 0); //0x64
+ $pps_ts1d = pack("V", 0); //0x68
+ $pps_ts2s = pack("V", 0); //0x6c
+ $pps_ts2d = pack("V", 0); //0x70
+ $pps_sb = pack("V", $start); //0x74
+ $pps_size = pack("V", $size); //0x78
+
+ fputs($this->_filehandle, $rawname);
+ fputs($this->_filehandle, str_repeat($zero, (64-$length)));
+ fputs($this->_filehandle, $pps_sizeofname);
+ fputs($this->_filehandle, $pps_type);
+ fputs($this->_filehandle, $pps_prev);
+ fputs($this->_filehandle, $pps_next);
+ fputs($this->_filehandle, $pps_dir);
+ fputs($this->_filehandle, str_repeat($unknown1, 5));
+ fputs($this->_filehandle, $pps_ts1s);
+ fputs($this->_filehandle, $pps_ts1d);
+ fputs($this->_filehandle, $pps_ts2d);
+ fputs($this->_filehandle, $pps_ts2d);
+ fputs($this->_filehandle, $pps_sb);
+ fputs($this->_filehandle, $pps_size);
+ fputs($this->_filehandle, $unknown1);
+ }
+
+ /*
+ * Pad the end of the file
+ */
+ function _write_padding() {
+ $biffsize = $this->_biffsize;
+
+ if ($biffsize < 4096) {
+ $min_size = 4096;
+ } else {
+ $min_size = 512;
+ }
+
+ if ($biffsize % $min_size != 0) {
+ $padding = $min_size - ($biffsize % $min_size);
+ fputs($this->_filehandle, str_repeat("\0", $padding));
+ }
+ }
+
+}
+
+?>
diff --git a/gosa-core/include/utils/excel/class.writeexcel_workbook.inc.php b/gosa-core/include/utils/excel/class.writeexcel_workbook.inc.php
--- /dev/null
@@ -0,0 +1,1109 @@
+<?php
+
+/*
+ * Copyleft 2002 Johann Hanne
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * This is the Spreadsheet::WriteExcel Perl package ported to PHP
+ * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
+ */
+
+require_once "class.writeexcel_biffwriter.inc.php";
+require_once "class.writeexcel_format.inc.php";
+require_once "class.writeexcel_formula.inc.php";
+require_once "class.writeexcel_olewriter.inc.php";
+
+class writeexcel_workbook extends writeexcel_biffwriter {
+
+ var $_filename;
+ var $_tmpfilename;
+ var $_parser;
+ var $_tempdir;
+ var $_1904;
+ var $_activesheet;
+ var $_firstsheet;
+ var $_selected;
+ var $_xf_index;
+ var $_fileclosed;
+ var $_biffsize;
+ var $_sheetname;
+ var $_tmp_format;
+ var $_url_format;
+ var $_worksheets;
+ var $_sheetnames;
+ var $_formats;
+ var $_palette;
+
+###############################################################################
+#
+# new()
+#
+# Constructor. Creates a new Workbook object from a BIFFwriter object.
+#
+function writeexcel_workbook($filename) {
+
+ $this->writeexcel_biffwriter();
+
+ $tmp_format = new writeexcel_format();
+ $byte_order = $this->_byte_order;
+ $parser = new writeexcel_formula($byte_order);
+
+ $this->_filename = $filename;
+ $this->_parser = $parser;
+//? $this->_tempdir = undef;
+ $this->_1904 = 0;
+ $this->_activesheet = 0;
+ $this->_firstsheet = 0;
+ $this->_selected = 0;
+ $this->_xf_index = 16; # 15 style XF's and 1 cell XF.
+ $this->_fileclosed = 0;
+ $this->_biffsize = 0;
+ $this->_sheetname = "Sheet";
+ $this->_tmp_format = $tmp_format;
+ $this->_url_format = false;
+ $this->_worksheets = array();
+ $this->_sheetnames = array();
+ $this->_formats = array();
+ $this->_palette = array();
+
+ # Add the default format for hyperlinks
+ $this->_url_format = $this->addformat(array('color' => 'blue', 'underline' => 1));
+
+ # Check for a filename
+ if ($this->_filename == '') {
+//todo: print error
+ return;
+ }
+
+ # Try to open the named file and see if it throws any errors.
+ # If the filename is a reference it is assumed that it is a valid
+ # filehandle and ignore
+ #
+//todo
+
+ # Set colour palette.
+ $this->set_palette_xl97();
+}
+
+###############################################################################
+#
+# close()
+#
+# Calls finalization methods and explicitly close the OLEwriter file
+# handle.
+#
+function close() {
+ # Prevent close() from being called twice.
+ if ($this->_fileclosed) {
+ return;
+ }
+
+ $this->_store_workbook();
+ $this->_fileclosed = 1;
+}
+
+//PHPport: method DESTROY deleted
+
+###############################################################################
+#
+# sheets()
+#
+# An accessor for the _worksheets[] array
+#
+# Returns: a list of the worksheet objects in a workbook
+#
+function sheets() {
+ return $this->_worksheets;
+}
+
+//PHPport: method worksheets deleted:
+# This method is now deprecated. Use the sheets() method instead.
+
+###############################################################################
+#
+# addworksheet($name)
+#
+# Add a new worksheet to the Excel workbook.
+# TODO: Add accessor for $self->{_sheetname} for international Excel versions.
+#
+# Returns: reference to a worksheet object
+#
+function addworksheet($name="") {
+
+ # Check that sheetname is <= 31 chars (Excel limit).
+ if (strlen($name) > 31) {
+ trigger_error("Sheetname $name must be <= 31 chars", E_USER_ERROR);
+ }
+
+ $index = sizeof($this->_worksheets);
+ $sheetname = $this->_sheetname;
+
+ if ($name == "") {
+ $name = $sheetname . ($index+1);
+ }
+
+ # Check that the worksheet name doesn't already exist: a fatal Excel error.
+ foreach ($this->_worksheets as $tmp) {
+ if ($name == $tmp->get_name()) {
+ trigger_error("Worksheet '$name' already exists", E_USER_ERROR);
+ }
+ }
+
+ $worksheet = new writeexcel_worksheet($name, $index, $this->_activesheet,
+ $this->_firstsheet,
+ $this->_url_format, $this->_parser,
+ $this->_tempdir);
+
+ $this->_worksheets[$index] = $worksheet; # Store ref for iterator
+ $this->_sheetnames[$index] = $name; # Store EXTERNSHEET names
+ $this->_parser->set_ext_sheet($name, $index); # Store names in Formula.pm
+ return $worksheet;
+}
+
+###############################################################################
+#
+# addformat(%properties)
+#
+# Add a new format to the Excel workbook. This adds an XF record and
+# a FONT record. Also, pass any properties to the Format::new().
+#
+function addformat($para=false) {
+ if($para===false) {
+ $format = new writeexcel_format($this->_xf_index);
+ } else {
+ $format = new writeexcel_format($this->_xf_index, $para);
+ }
+
+ $this->_xf_index += 1;
+ # Store format reference
+ $this->_formats[]=$format;
+
+ return $format;
+}
+
+###############################################################################
+#
+# set_1904()
+#
+# Set the date system: 0 = 1900 (the default), 1 = 1904
+#
+function set_1904($_1904) {
+ $this->_1904 = $_1904;
+}
+
+###############################################################################
+#
+# get_1904()
+#
+# Return the date system: 0 = 1900, 1 = 1904
+#
+function get_1904() {
+ return $this->_1904;
+}
+
+###############################################################################
+#
+# set_custom_color()
+#
+# Change the RGB components of the elements in the colour palette.
+#
+function set_custom_color($index, $red, $green, $blue) {
+// todo
+/*
+ # Match a HTML #xxyyzz style parameter
+ if (defined $_[1] and $_[1] =~ /^#(\w\w)(\w\w)(\w\w)/ ) {
+ @_ = ($_[0], hex $1, hex $2, hex $3);
+ }
+*/
+
+ $aref = $this->_palette;
+
+ # Check that the colour index is the right range
+ if ($index < 8 or $index > 64) {
+//todo carp "Color index $index outside range: 8 <= index <= 64";
+ return;
+ }
+
+ # Check that the colour components are in the right range
+ if ( ($red < 0 || $red > 255) ||
+ ($green < 0 || $green > 255) ||
+ ($blue < 0 || $blue > 255) )
+ {
+//todo carp "Color component outside range: 0 <= color <= 255";
+ return;
+ }
+
+ $index -=8; # Adjust colour index (wingless dragonfly)
+
+ # Set the RGB value
+ $aref[$index] = array($red, $green, $blue, 0);
+
+ return $index +8;
+}
+
+###############################################################################
+#
+# set_palette_xl97()
+#
+# Sets the colour palette to the Excel 97+ default.
+#
+function set_palette_xl97() {
+ $this->_palette = array(
+ array(0x00, 0x00, 0x00, 0x00), # 8
+ array(0xff, 0xff, 0xff, 0x00), # 9
+ array(0xff, 0x00, 0x00, 0x00), # 10
+ array(0x00, 0xff, 0x00, 0x00), # 11
+ array(0x00, 0x00, 0xff, 0x00), # 12
+ array(0xff, 0xff, 0x00, 0x00), # 13
+ array(0xff, 0x00, 0xff, 0x00), # 14
+ array(0x00, 0xff, 0xff, 0x00), # 15
+ array(0x80, 0x00, 0x00, 0x00), # 16
+ array(0x00, 0x80, 0x00, 0x00), # 17
+ array(0x00, 0x00, 0x80, 0x00), # 18
+ array(0x80, 0x80, 0x00, 0x00), # 19
+ array(0x80, 0x00, 0x80, 0x00), # 20
+ array(0x00, 0x80, 0x80, 0x00), # 21
+ array(0xc0, 0xc0, 0xc0, 0x00), # 22
+ array(0x80, 0x80, 0x80, 0x00), # 23
+ array(0x99, 0x99, 0xff, 0x00), # 24
+ array(0x99, 0x33, 0x66, 0x00), # 25
+ array(0xff, 0xff, 0xcc, 0x00), # 26
+ array(0xcc, 0xff, 0xff, 0x00), # 27
+ array(0x66, 0x00, 0x66, 0x00), # 28
+ array(0xff, 0x80, 0x80, 0x00), # 29
+ array(0x00, 0x66, 0xcc, 0x00), # 30
+ array(0xcc, 0xcc, 0xff, 0x00), # 31
+ array(0x00, 0x00, 0x80, 0x00), # 32
+ array(0xff, 0x00, 0xff, 0x00), # 33
+ array(0xff, 0xff, 0x00, 0x00), # 34
+ array(0x00, 0xff, 0xff, 0x00), # 35
+ array(0x80, 0x00, 0x80, 0x00), # 36
+ array(0x80, 0x00, 0x00, 0x00), # 37
+ array(0x00, 0x80, 0x80, 0x00), # 38
+ array(0x00, 0x00, 0xff, 0x00), # 39
+ array(0x00, 0xcc, 0xff, 0x00), # 40
+ array(0xcc, 0xff, 0xff, 0x00), # 41
+ array(0xcc, 0xff, 0xcc, 0x00), # 42
+ array(0xff, 0xff, 0x99, 0x00), # 43
+ array(0x99, 0xcc, 0xff, 0x00), # 44
+ array(0xff, 0x99, 0xcc, 0x00), # 45
+ array(0xcc, 0x99, 0xff, 0x00), # 46
+ array(0xff, 0xcc, 0x99, 0x00), # 47
+ array(0x33, 0x66, 0xff, 0x00), # 48
+ array(0x33, 0xcc, 0xcc, 0x00), # 49
+ array(0x99, 0xcc, 0x00, 0x00), # 50
+ array(0xff, 0xcc, 0x00, 0x00), # 51
+ array(0xff, 0x99, 0x00, 0x00), # 52
+ array(0xff, 0x66, 0x00, 0x00), # 53
+ array(0x66, 0x66, 0x99, 0x00), # 54
+ array(0x96, 0x96, 0x96, 0x00), # 55
+ array(0x00, 0x33, 0x66, 0x00), # 56
+ array(0x33, 0x99, 0x66, 0x00), # 57
+ array(0x00, 0x33, 0x00, 0x00), # 58
+ array(0x33, 0x33, 0x00, 0x00), # 59
+ array(0x99, 0x33, 0x00, 0x00), # 60
+ array(0x99, 0x33, 0x66, 0x00), # 61
+ array(0x33, 0x33, 0x99, 0x00), # 62
+ array(0x33, 0x33, 0x33, 0x00), # 63
+ );
+
+ return 0;
+}
+
+###############################################################################
+#
+# set_palette_xl5()
+#
+# Sets the colour palette to the Excel 5 default.
+#
+function set_palette_xl5() {
+ $this->_palette = array(
+ array(0x00, 0x00, 0x00, 0x00), # 8
+ array(0xff, 0xff, 0xff, 0x00), # 9
+ array(0xff, 0x00, 0x00, 0x00), # 10
+ array(0x00, 0xff, 0x00, 0x00), # 11
+ array(0x00, 0x00, 0xff, 0x00), # 12
+ array(0xff, 0xff, 0x00, 0x00), # 13
+ array(0xff, 0x00, 0xff, 0x00), # 14
+ array(0x00, 0xff, 0xff, 0x00), # 15
+ array(0x80, 0x00, 0x00, 0x00), # 16
+ array(0x00, 0x80, 0x00, 0x00), # 17
+ array(0x00, 0x00, 0x80, 0x00), # 18
+ array(0x80, 0x80, 0x00, 0x00), # 19
+ array(0x80, 0x00, 0x80, 0x00), # 20
+ array(0x00, 0x80, 0x80, 0x00), # 21
+ array(0xc0, 0xc0, 0xc0, 0x00), # 22
+ array(0x80, 0x80, 0x80, 0x00), # 23
+ array(0x80, 0x80, 0xff, 0x00), # 24
+ array(0x80, 0x20, 0x60, 0x00), # 25
+ array(0xff, 0xff, 0xc0, 0x00), # 26
+ array(0xa0, 0xe0, 0xe0, 0x00), # 27
+ array(0x60, 0x00, 0x80, 0x00), # 28
+ array(0xff, 0x80, 0x80, 0x00), # 29
+ array(0x00, 0x80, 0xc0, 0x00), # 30
+ array(0xc0, 0xc0, 0xff, 0x00), # 31
+ array(0x00, 0x00, 0x80, 0x00), # 32
+ array(0xff, 0x00, 0xff, 0x00), # 33
+ array(0xff, 0xff, 0x00, 0x00), # 34
+ array(0x00, 0xff, 0xff, 0x00), # 35
+ array(0x80, 0x00, 0x80, 0x00), # 36
+ array(0x80, 0x00, 0x00, 0x00), # 37
+ array(0x00, 0x80, 0x80, 0x00), # 38
+ array(0x00, 0x00, 0xff, 0x00), # 39
+ array(0x00, 0xcf, 0xff, 0x00), # 40
+ array(0x69, 0xff, 0xff, 0x00), # 41
+ array(0xe0, 0xff, 0xe0, 0x00), # 42
+ array(0xff, 0xff, 0x80, 0x00), # 43
+ array(0xa6, 0xca, 0xf0, 0x00), # 44
+ array(0xdd, 0x9c, 0xb3, 0x00), # 45
+ array(0xb3, 0x8f, 0xee, 0x00), # 46
+ array(0xe3, 0xe3, 0xe3, 0x00), # 47
+ array(0x2a, 0x6f, 0xf9, 0x00), # 48
+ array(0x3f, 0xb8, 0xcd, 0x00), # 49
+ array(0x48, 0x84, 0x36, 0x00), # 50
+ array(0x95, 0x8c, 0x41, 0x00), # 51
+ array(0x8e, 0x5e, 0x42, 0x00), # 52
+ array(0xa0, 0x62, 0x7a, 0x00), # 53
+ array(0x62, 0x4f, 0xac, 0x00), # 54
+ array(0x96, 0x96, 0x96, 0x00), # 55
+ array(0x1d, 0x2f, 0xbe, 0x00), # 56
+ array(0x28, 0x66, 0x76, 0x00), # 57
+ array(0x00, 0x45, 0x00, 0x00), # 58
+ array(0x45, 0x3e, 0x01, 0x00), # 59
+ array(0x6a, 0x28, 0x13, 0x00), # 60
+ array(0x85, 0x39, 0x6a, 0x00), # 61
+ array(0x4a, 0x32, 0x85, 0x00), # 62
+ array(0x42, 0x42, 0x42, 0x00), # 63
+ );
+
+ return 0;
+}
+
+###############################################################################
+#
+# set_tempdir()
+#
+# Change the default temp directory used by _initialize() in Worksheet.pm.
+#
+function set_tempdir($tempdir) {
+//todo
+/*
+ croak "$_[0] is not a valid directory" unless -d $_[0];
+ croak "set_tempdir must be called before addworksheet" if $self->sheets();
+*/
+
+ $this->_tempdir = $tempdir;
+}
+
+###############################################################################
+#
+# _store_workbook()
+#
+# Assemble worksheets into a workbook and send the BIFF data to an OLE
+# storage.
+#
+function _store_workbook() {
+
+ # Ensure that at least one worksheet has been selected.
+ if ($this->_activesheet == 0) {
+ $this->_worksheets[0]->_selected = 1;
+ }
+
+ # Calculate the number of selected worksheet tabs and call the finalization
+ # methods for each worksheet
+ for ($c=0;$c<sizeof($this->_worksheets);$c++) {
+ $sheet=$this->_worksheets[$c];
+ if ($sheet->_selected) {
+ $this->_selected++;
+
+ }
+ $sheet->_close($this->_sheetnames);
+ }
+
+ # Add Workbook globals
+ $this->_store_bof(0x0005);
+
+ $this->_store_externs(); # For print area and repeat rows
+
+ $this->_store_names(); # For print area and repeat rows
+
+ $this->_store_window1();
+
+ $this->_store_1904();
+
+ $this->_store_all_fonts();
+
+ $this->_store_all_num_formats();
+
+ $this->_store_all_xfs();
+
+ $this->_store_all_styles();
+
+ $this->_store_palette();
+
+ $this->_calc_sheet_offsets();
+
+ # Add BOUNDSHEET records
+ for ($c=0;$c<sizeof($this->_worksheets);$c++) {
+ $sheet=$this->_worksheets[$c];
+ $this->_store_boundsheet($sheet->_name, $sheet->_offset);
+ }
+
+ # End Workbook globals
+ $this->_store_eof();
+
+ # Store the workbook in an OLE container
+ $this->_store_OLE_file();
+}
+
+###############################################################################
+#
+# _store_OLE_file()
+#
+# Store the workbook in an OLE container if the total size of the workbook data
+# is less than ~ 7MB.
+#
+function _store_OLE_file() {
+## ABR
+ if ($this->_tmpfilename != '') {
+ $OLE = new writeexcel_olewriter('/tmp/'.$this->_tmpfilename);
+ $OLE->_OLEtmpfilename = '/tmp/'.$this->_tmpfilename;
+ } else {
+ $OLE = new writeexcel_olewriter($this->_filename);
+ $OLE->_OLEtmpfilename = '';
+ };
+## END ABR
+
+ # Write Worksheet data if data <~ 7MB
+ if ($OLE->set_size($this->_biffsize)) {
+ $OLE->write_header();
+ $OLE->write($this->_data);
+
+ for ($c=0;$c<sizeof($this->_worksheets);$c++) {
+ $sheet=$this->_worksheets[$c];
+ while ($tmp = $sheet->get_data()) {
+ $OLE->write($tmp);
+ }
+ }
+ }
+
+ $OLE->close();
+}
+
+###############################################################################
+#
+# _calc_sheet_offsets()
+#
+# Calculate offsets for Worksheet BOF records.
+#
+function _calc_sheet_offsets() {
+
+ $BOF = 11;
+ $EOF = 4;
+ $offset = $this->_datasize;
+
+ foreach ($this->_worksheets as $sheet) {
+ $offset += $BOF + strlen($sheet->_name);
+ }
+
+ $offset += $EOF;
+
+ for ($c=0;$c<sizeof($this->_worksheets);$c++) {
+ $sheet=$this->_worksheets[$c];
+ $sheet->_offset = $offset;
+ $offset += $sheet->_datasize;
+ }
+
+ $this->_biffsize = $offset;
+}
+
+###############################################################################
+#
+# _store_all_fonts()
+#
+# Store the Excel FONT records.
+#
+function _store_all_fonts() {
+ # _tmp_format is added by new(). We use this to write the default XF's
+ $format = $this->_tmp_format;
+ $font = $format->get_font();
+
+ # Note: Fonts are 0-indexed. According to the SDK there is no index 4,
+ # so the following fonts are 0, 1, 2, 3, 5
+ #
+ for ($c=0;$c<5;$c++) {
+ $this->_append($font);
+ }
+
+ # Iterate through the XF objects and write a FONT record if it isn't the
+ # same as the default FONT and if it hasn't already been used.
+ #
+ $index = 6; # The first user defined FONT
+
+ $key = $format->get_font_key(); # The default font from _tmp_format
+ $fonts[$key] = 0; # Index of the default font
+
+ for ($c=0;$c<sizeof($this->_formats);$c++) {
+ $format=$this->_formats[$c];
+
+ $key = $format->get_font_key();
+
+ if (isset($fonts[$key])) {
+ # FONT has already been used
+ $format->_font_index = $fonts[$key];
+ } else {
+ # Add a new FONT record
+ $fonts[$key] = $index;
+ $format->_font_index = $index;
+ $index++;
+ $font = $format->get_font();
+ $this->_append($font);
+ }
+ }
+}
+
+###############################################################################
+#
+# _store_all_num_formats()
+#
+# Store user defined numerical formats i.e. FORMAT records
+#
+function _store_all_num_formats() {
+
+ # Leaning num_format syndrome
+ $num_formats_list=array();
+ $index = 164;
+
+ # Iterate through the XF objects and write a FORMAT record if it isn't a
+ # built-in format type and if the FORMAT string hasn't already been used.
+ #
+
+ for ($c=0;$c<sizeof($this->_formats);$c++) {
+ $format=$this->_formats[$c];
+
+ $num_format = $format->_num_format;
+
+ # Check if $num_format is an index to a built-in format.
+ # Also check for a string of zeros, which is a valid format string
+ # but would evaluate to zero.
+ #
+ if (!preg_match('/^0+\d/', $num_format)) {
+ if (preg_match('/^\d+$/', $num_format)) {
+ # built-in
+ continue;
+ }
+ }
+
+ if (isset($num_formats[$num_format])) {
+ # FORMAT has already been used
+ $format->_num_format = $num_formats[$num_format];
+ } else {
+ # Add a new FORMAT
+ $num_formats[$num_format] = $index;
+ $format->_num_format = $index;
+ array_push($num_formats_list, $num_format);
+ $index++;
+ }
+ }
+
+ # Write the new FORMAT records starting from 0xA4
+ $index = 164;
+ foreach ($num_formats_list as $num_format) {
+ $this->_store_num_format($num_format, $index);
+ $index++;
+ }
+}
+
+###############################################################################
+#
+# _store_all_xfs()
+#
+# Write all XF records.
+#
+function _store_all_xfs() {
+ # _tmp_format is added by new(). We use this to write the default XF's
+ # The default font index is 0
+ #
+ $format = $this->_tmp_format;
+ $xf;
+
+ for ($c=0;$c<15;$c++) {
+ $xf = $format->get_xf('style'); # Style XF
+ $this->_append($xf);
+ }
+
+ $xf = $format->get_xf('cell'); # Cell XF
+ $this->_append($xf);
+
+ # User defined XFs
+ foreach ($this->_formats as $format) {
+ $xf = $format->get_xf('cell');
+ $this->_append($xf);
+ }
+}
+
+###############################################################################
+#
+# _store_all_styles()
+#
+# Write all STYLE records.
+#
+function _store_all_styles() {
+ $this->_store_style();
+}
+
+###############################################################################
+#
+# _store_externs()
+#
+# Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for
+# the NAME records.
+#
+function _store_externs() {
+
+ # Create EXTERNCOUNT with number of worksheets
+ $this->_store_externcount(sizeof($this->_worksheets));
+
+ # Create EXTERNSHEET for each worksheet
+ foreach ($this->_sheetnames as $sheetname) {
+ $this->_store_externsheet($sheetname);
+ }
+}
+
+###############################################################################
+#
+# _store_names()
+#
+# Write the NAME record to define the print area and the repeat rows and cols.
+#
+function _store_names() {
+
+ # Create the print area NAME records
+ foreach ($this->_worksheets as $worksheet) {
+ # Write a Name record if the print area has been defined
+ if ($worksheet->_print_rowmin!==false) {
+ $this->_store_name_short(
+ $worksheet->_index,
+ 0x06, # NAME type
+ $worksheet->_print_rowmin,
+ $worksheet->_print_rowmax,
+ $worksheet->_print_colmin,
+ $worksheet->_print_colmax
+ );
+ }
+ }
+
+ # Create the print title NAME records
+ foreach ($this->_worksheets as $worksheet) {
+
+ $rowmin = $worksheet->_title_rowmin;
+ $rowmax = $worksheet->_title_rowmax;
+ $colmin = $worksheet->_title_colmin;
+ $colmax = $worksheet->_title_colmax;
+
+ # Determine if row + col, row, col or nothing has been defined
+ # and write the appropriate record
+ #
+ if ($rowmin!==false && $colmin!==false) {
+ # Row and column titles have been defined.
+ # Row title has been defined.
+ $this->_store_name_long(
+ $worksheet->_index,
+ 0x07, # NAME type
+ $rowmin,
+ $rowmax,
+ $colmin,
+ $colmax
+ );
+ } elseif ($rowmin!==false) {
+ # Row title has been defined.
+ $this->_store_name_short(
+ $worksheet->_index,
+ 0x07, # NAME type
+ $rowmin,
+ $rowmax,
+ 0x00,
+ 0xff
+ );
+ } elseif ($colmin!==false) {
+ # Column title has been defined.
+ $this->_store_name_short(
+ $worksheet->_index,
+ 0x07, # NAME type
+ 0x0000,
+ 0x3fff,
+ $colmin,
+ $colmax
+ );
+ } else {
+ # Print title hasn't been defined.
+ }
+ }
+}
+
+###############################################################################
+###############################################################################
+#
+# BIFF RECORDS
+#
+
+###############################################################################
+#
+# _store_window1()
+#
+# Write Excel BIFF WINDOW1 record.
+#
+function _store_window1() {
+
+ $record = 0x003D; # Record identifier
+ $length = 0x0012; # Number of bytes to follow
+
+ $xWn = 0x0000; # Horizontal position of window
+ $yWn = 0x0000; # Vertical position of window
+ $dxWn = 0x25BC; # Width of window
+ $dyWn = 0x1572; # Height of window
+
+ $grbit = 0x0038; # Option flags
+ $ctabsel = $this->_selected; # Number of workbook tabs selected
+ $wTabRatio = 0x0258; # Tab to scrollbar ratio
+
+ $itabFirst = $this->_firstsheet; # 1st displayed worksheet
+ $itabCur = $this->_activesheet; # Active worksheet
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn,
+ $grbit,
+ $itabCur, $itabFirst,
+ $ctabsel, $wTabRatio);
+
+ $this->_append($header . $data);
+}
+
+###############################################################################
+#
+# _store_boundsheet()
+#
+# Writes Excel BIFF BOUNDSHEET record.
+#
+function _store_boundsheet($sheetname, $offset) {
+ $record = 0x0085; # Record identifier
+ $length = 0x07 + strlen($sheetname); # Number of bytes to follow
+
+ //$sheetname = $_[0]; # Worksheet name
+ //$offset = $_[1]; # Location of worksheet BOF
+ $grbit = 0x0000; # Sheet identifier
+ $cch = strlen($sheetname); # Length of sheet name
+
+ $header = pack("vv", $record, $length);
+ $data = pack("VvC", $offset, $grbit, $cch);
+
+ $this->_append($header . $data . $sheetname);
+}
+
+###############################################################################
+#
+# _store_style()
+#
+# Write Excel BIFF STYLE records.
+#
+function _store_style() {
+ $record = 0x0293; # Record identifier
+ $length = 0x0004; # Bytes to follow
+
+ $ixfe = 0x8000; # Index to style XF
+ $BuiltIn = 0x00; # Built-in style
+ $iLevel = 0xff; # Outline style level
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vCC", $ixfe, $BuiltIn, $iLevel);
+
+ $this->_append($header . $data);
+}
+
+###############################################################################
+#
+# _store_num_format()
+#
+# Writes Excel FORMAT record for non "built-in" numerical formats.
+#
+function _store_num_format($num_format, $index) {
+ $record = 0x041E; # Record identifier
+ $length = 0x03 + strlen($num_format); # Number of bytes to follow
+
+ $format = $num_format; # Custom format string
+ $ifmt = $index; # Format index code
+ $cch = strlen($format); # Length of format string
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vC", $ifmt, $cch);
+
+ $this->_append($header . $data . $format);
+}
+
+###############################################################################
+#
+# _store_1904()
+#
+# Write Excel 1904 record to indicate the date system in use.
+#
+function _store_1904() {
+ $record = 0x0022; # Record identifier
+ $length = 0x0002; # Bytes to follow
+
+ $f1904 = $this->_1904; # Flag for 1904 date system
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $f1904);
+
+ $this->_append($header . $data);
+}
+
+###############################################################################
+#
+# _store_externcount($count)
+#
+# Write BIFF record EXTERNCOUNT to indicate the number of external sheet
+# references in the workbook.
+#
+# Excel only stores references to external sheets that are used in NAME.
+# The workbook NAME record is required to define the print area and the repeat
+# rows and columns.
+#
+# A similar method is used in Worksheet.pm for a slightly different purpose.
+#
+function _store_externcount($par0) {
+ $record = 0x0016; # Record identifier
+ $length = 0x0002; # Number of bytes to follow
+
+ $cxals = $par0; # Number of external references
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $cxals);
+
+ $this->_append($header . $data);
+}
+
+###############################################################################
+#
+# _store_externsheet($sheetname)
+#
+#
+# Writes the Excel BIFF EXTERNSHEET record. These references are used by
+# formulas. NAME record is required to define the print area and the repeat
+# rows and columns.
+#
+# A similar method is used in Worksheet.pm for a slightly different purpose.
+#
+function _store_externsheet($par0) {
+ $record = 0x0017; # Record identifier
+ $length = 0x02 + strlen($par0); # Number of bytes to follow
+
+ $sheetname = $par0; # Worksheet name
+ $cch = strlen($sheetname); # Length of sheet name
+ $rgch = 0x03; # Filename encoding
+
+ $header = pack("vv", $record, $length);
+ $data = pack("CC", $cch, $rgch);
+
+ $this->_append($header . $data . $sheetname);
+}
+
+###############################################################################
+#
+# _store_name_short()
+#
+#
+# Store the NAME record in the short format that is used for storing the print
+# area, repeat rows only and repeat columns only.
+#
+function _store_name_short($par0, $par1, $par2, $par3, $par4, $par5) {
+ $record = 0x0018; # Record identifier
+ $length = 0x0024; # Number of bytes to follow
+
+ $index = $par0; # Sheet index
+ $type = $par1;
+
+ $grbit = 0x0020; # Option flags
+ $chKey = 0x00; # Keyboard shortcut
+ $cch = 0x01; # Length of text name
+ $cce = 0x0015; # Length of text definition
+ $ixals = $index +1; # Sheet index
+ $itab = $ixals; # Equal to ixals
+ $cchCustMenu = 0x00; # Length of cust menu text
+ $cchDescription = 0x00; # Length of description text
+ $cchHelptopic = 0x00; # Length of help topic text
+ $cchStatustext = 0x00; # Length of status bar text
+ $rgch = $type; # Built-in name type
+
+ $unknown03 = 0x3b;
+ $unknown04 = 0xffff-$index;
+ $unknown05 = 0x0000;
+ $unknown06 = 0x0000;
+ $unknown07 = 0x1087;
+ $unknown08 = 0x8005;
+
+ $rowmin = $par2; # Start row
+ $rowmax = $par3; # End row
+ $colmin = $par4; # Start column
+ $colmax = $par5; # end column
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $grbit);
+ $data .= pack("C", $chKey);
+ $data .= pack("C", $cch);
+ $data .= pack("v", $cce);
+ $data .= pack("v", $ixals);
+ $data .= pack("v", $itab);
+ $data .= pack("C", $cchCustMenu);
+ $data .= pack("C", $cchDescription);
+ $data .= pack("C", $cchHelptopic);
+ $data .= pack("C", $cchStatustext);
+ $data .= pack("C", $rgch);
+ $data .= pack("C", $unknown03);
+ $data .= pack("v", $unknown04);
+ $data .= pack("v", $unknown05);
+ $data .= pack("v", $unknown06);
+ $data .= pack("v", $unknown07);
+ $data .= pack("v", $unknown08);
+ $data .= pack("v", $index);
+ $data .= pack("v", $index);
+ $data .= pack("v", $rowmin);
+ $data .= pack("v", $rowmax);
+ $data .= pack("C", $colmin);
+ $data .= pack("C", $colmax);
+
+ $this->_append($header . $data);
+}
+
+###############################################################################
+#
+# _store_name_long()
+#
+#
+# Store the NAME record in the long format that is used for storing the repeat
+# rows and columns when both are specified. This share a lot of code with
+# _store_name_short() but we use a separate method to keep the code clean.
+# Code abstraction for reuse can be carried too far, and I should know. ;-)
+#
+function _store_name_long($par0, $par1, $par2, $par3, $par4, $par5) {
+ $record = 0x0018; # Record identifier
+ $length = 0x003d; # Number of bytes to follow
+
+ $index = $par0; # Sheet index
+ $type = $par1;
+
+ $grbit = 0x0020; # Option flags
+ $chKey = 0x00; # Keyboard shortcut
+ $cch = 0x01; # Length of text name
+ $cce = 0x002e; # Length of text definition
+ $ixals = $index +1; # Sheet index
+ $itab = $ixals; # Equal to ixals
+ $cchCustMenu = 0x00; # Length of cust menu text
+ $cchDescription = 0x00; # Length of description text
+ $cchHelptopic = 0x00; # Length of help topic text
+ $cchStatustext = 0x00; # Length of status bar text
+ $rgch = $type; # Built-in name type
+
+ $unknown01 = 0x29;
+ $unknown02 = 0x002b;
+ $unknown03 = 0x3b;
+ $unknown04 = 0xffff-$index;
+ $unknown05 = 0x0000;
+ $unknown06 = 0x0000;
+ $unknown07 = 0x1087;
+ $unknown08 = 0x8008;
+
+ $rowmin = $par2; # Start row
+ $rowmax = $par3; # End row
+ $colmin = $par4; # Start column
+ $colmax = $par5; # end column
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $grbit);
+ $data .= pack("C", $chKey);
+ $data .= pack("C", $cch);
+ $data .= pack("v", $cce);
+ $data .= pack("v", $ixals);
+ $data .= pack("v", $itab);
+ $data .= pack("C", $cchCustMenu);
+ $data .= pack("C", $cchDescription);
+ $data .= pack("C", $cchHelptopic);
+ $data .= pack("C", $cchStatustext);
+ $data .= pack("C", $rgch);
+ $data .= pack("C", $unknown01);
+ $data .= pack("v", $unknown02);
+ # Column definition
+ $data .= pack("C", $unknown03);
+ $data .= pack("v", $unknown04);
+ $data .= pack("v", $unknown05);
+ $data .= pack("v", $unknown06);
+ $data .= pack("v", $unknown07);
+ $data .= pack("v", $unknown08);
+ $data .= pack("v", $index);
+ $data .= pack("v", $index);
+ $data .= pack("v", 0x0000);
+ $data .= pack("v", 0x3fff);
+ $data .= pack("C", $colmin);
+ $data .= pack("C", $colmax);
+ # Row definition
+ $data .= pack("C", $unknown03);
+ $data .= pack("v", $unknown04);
+ $data .= pack("v", $unknown05);
+ $data .= pack("v", $unknown06);
+ $data .= pack("v", $unknown07);
+ $data .= pack("v", $unknown08);
+ $data .= pack("v", $index);
+ $data .= pack("v", $index);
+ $data .= pack("v", $rowmin);
+ $data .= pack("v", $rowmax);
+ $data .= pack("C", 0x00);
+ $data .= pack("C", 0xff);
+ # End of data
+ $data .= pack("C", 0x10);
+
+ $this->_append($header . $data);
+}
+
+###############################################################################
+#
+# _store_palette()
+#
+# Stores the PALETTE biff record.
+#
+function _store_palette() {
+ $aref = $this->_palette;
+
+ $record = 0x0092; # Record identifier
+ $length = 2 + 4 * sizeof($aref); # Number of bytes to follow
+ $ccv = sizeof($aref); # Number of RGB values to follow
+ //$data; # The RGB data
+
+ # Pack the RGB data
+ foreach($aref as $dat) {
+ $data .= call_user_func_array('pack', array_merge(array("CCCC"), $dat));
+ }
+
+ $header = pack("vvv", $record, $length, $ccv);
+
+ $this->_append($header . $data);
+}
+
+}
+
+?>
diff --git a/gosa-core/include/utils/excel/class.writeexcel_worksheet.inc.php b/gosa-core/include/utils/excel/class.writeexcel_worksheet.inc.php
--- /dev/null
@@ -0,0 +1,2951 @@
+<?php
+
+/*
+ * Copyleft 2002 Johann Hanne
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * This is the Spreadsheet::WriteExcel Perl package ported to PHP
+ * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
+ */
+
+require_once "class.writeexcel_biffwriter.inc.php";
+
+class writeexcel_worksheet extends writeexcel_biffwriter {
+
+ var $_name;
+ var $_index;
+ var $_activesheet;
+ var $_firstsheet;
+ var $_url_format;
+ var $_parser;
+ var $_tempdir;
+
+ var $_ext_sheets;
+ var $_using_tmpfile;
+ var $_filehandle;
+ var $_fileclosed;
+ var $_offset;
+ var $_xls_rowmax;
+ var $_xls_colmax;
+ var $_xls_strmax;
+ var $_dim_rowmin;
+ var $_dim_rowmax;
+ var $_dim_colmin;
+ var $_dim_colmax;
+ var $_colinfo;
+ var $_selection;
+ var $_panes;
+ var $_active_pane;
+ var $_frozen;
+ var $_selected;
+
+ var $_paper_size;
+ var $_orientation;
+ var $_header;
+ var $_footer;
+ var $_hcenter;
+ var $_vcenter;
+ var $_margin_head;
+ var $_margin_foot;
+ var $_margin_left;
+ var $_margin_right;
+ var $_margin_top;
+ var $_margin_bottom;
+
+ var $_title_rowmin;
+ var $_title_rowmax;
+ var $_title_colmin;
+ var $_title_colmax;
+ var $_print_rowmin;
+ var $_print_rowmax;
+ var $_print_colmin;
+ var $_print_colmax;
+
+ var $_print_gridlines;
+ var $_screen_gridlines;
+ var $_print_headers;
+
+ var $_fit_page;
+ var $_fit_width;
+ var $_fit_height;
+
+ var $_hbreaks;
+ var $_vbreaks;
+
+ var $_protect;
+ var $_password;
+
+ var $_col_sizes;
+ var $_row_sizes;
+
+ var $_col_formats;
+ var $_row_formats;
+
+ var $_zoom;
+ var $_print_scale;
+
+ /*
+ * Constructor. Creates a new Worksheet object from a BIFFwriter object
+ */
+ function writeexcel_worksheet($name, $index, $activesheet, $firstsheet,
+ $url_format, $parser, $tempdir) {
+
+ $this->writeexcel_biffwriter();
+
+ $rowmax = 65536; // 16384 in Excel 5
+ $colmax = 256;
+ $strmax = 255;
+
+ $this->_name = $name;
+ $this->_index = $index;
+ $this->_activesheet = $activesheet;
+ $this->_firstsheet = $firstsheet;
+ $this->_url_format = $url_format;
+ $this->_parser = $parser;
+ $this->_tempdir = $tempdir;
+
+ $this->_ext_sheets = array();
+ $this->_using_tmpfile = 1;
+ $this->_filehandle = false;
+ $this->_fileclosed = 0;
+ $this->_offset = 0;
+ $this->_xls_rowmax = $rowmax;
+ $this->_xls_colmax = $colmax;
+ $this->_xls_strmax = $strmax;
+ $this->_dim_rowmin = $rowmax +1;
+ $this->_dim_rowmax = 0;
+ $this->_dim_colmin = $colmax +1;
+ $this->_dim_colmax = 0;
+ $this->_colinfo = array();
+ $this->_selection = array(0, 0);
+ $this->_panes = array();
+ $this->_active_pane = 3;
+ $this->_frozen = 0;
+ $this->_selected = 0;
+
+ $this->_paper_size = 0x0;
+ $this->_orientation = 0x1;
+ $this->_header = '';
+ $this->_footer = '';
+ $this->_hcenter = 0;
+ $this->_vcenter = 0;
+ $this->_margin_head = 0.50;
+ $this->_margin_foot = 0.50;
+ $this->_margin_left = 0.75;
+ $this->_margin_right = 0.75;
+ $this->_margin_top = 1.00;
+ $this->_margin_bottom = 1.00;
+
+ $this->_title_rowmin = false;
+ $this->_title_rowmax = false;
+ $this->_title_colmin = false;
+ $this->_title_colmax = false;
+ $this->_print_rowmin = false;
+ $this->_print_rowmax = false;
+ $this->_print_colmin = false;
+ $this->_print_colmax = false;
+
+ $this->_print_gridlines = 1;
+ $this->_screen_gridlines = 1;
+ $this->_print_headers = 0;
+
+ $this->_fit_page = 0;
+ $this->_fit_width = 0;
+ $this->_fit_height = 0;
+
+ $this->_hbreaks = array();
+ $this->_vbreaks = array();
+
+ $this->_protect = 0;
+ $this->_password = false;
+
+ $this->_col_sizes = array();
+ $this->_row_sizes = array();
+
+ $this->_col_formats = array();
+ $this->_row_formats = array();
+
+ $this->_zoom = 100;
+ $this->_print_scale = 100;
+
+ $this->_initialize();
+ }
+
+###############################################################################
+#
+# _initialize()
+#
+# Open a tmp file to store the majority of the Worksheet data. If this fails,
+# for example due to write permissions, store the data in memory. This can be
+# slow for large files.
+#
+function _initialize() {
+
+ # Open tmp file for storing Worksheet data.
+ $fh=fopen(tempnam($this->_tempdir, "php_writeexcel"), "w+b");
+
+ if ($fh) {
+ # Store filehandle
+ $this->_filehandle = $fh;
+ } else {
+ # If tempfile() failed store data in memory
+ $this->_using_tmpfile = 0;
+
+ if ($this->_index == 0) {
+ $dir = $this->_tempdir;
+
+//todo warn "Unable to create temp files in $dir. Refer to set_tempdir()".
+// " in the Spreadsheet::WriteExcel documentation.\n" ;
+ }
+ }
+}
+
+ /*
+ * Add data to the beginning of the workbook (note the reverse order)
+ * and to the end of the workbook.
+ */
+ function _close($sheetnames) {
+
+ ///////////////////////////////
+ // Prepend in reverse order!!
+ //
+
+ $this->_store_dimensions(); // Prepend the sheet dimensions
+ $this->_store_password(); // Prepend the sheet password
+ $this->_store_protect(); // Prepend the sheet protection
+ $this->_store_setup(); // Prepend the page setup
+ $this->_store_margin_bottom(); // Prepend the bottom margin
+ $this->_store_margin_top(); // Prepend the top margin
+ $this->_store_margin_right(); // Prepend the right margin
+ $this->_store_margin_left(); // Prepend the left margin
+ $this->_store_vcenter(); // Prepend the page vertical
+ // centering
+ $this->_store_hcenter(); // Prepend the page horizontal
+ // centering
+ $this->_store_footer(); // Prepend the page footer
+ $this->_store_header(); // Prepend the page header
+ $this->_store_vbreak(); // Prepend the vertical page breaks
+ $this->_store_hbreak(); // Prepend the horizontal
+ // page breaks
+ $this->_store_wsbool(); // Prepend WSBOOL
+ $this->_store_gridset(); // Prepend GRIDSET
+ $this->_store_print_gridlines(); // Prepend PRINTGRIDLINES
+ $this->_store_print_headers(); // Prepend PRINTHEADERS
+
+ // Prepend EXTERNSHEET references
+ $num_sheets = sizeof($sheetnames);
+ for ($i = $num_sheets; $i > 0; $i--) {
+ $sheetname = $sheetnames[$i-1];
+ $this->_store_externsheet($sheetname);
+ }
+
+ $this->_store_externcount($num_sheets); // Prepend the EXTERNCOUNT
+ // of external references.
+
+ // Prepend the COLINFO records if they exist
+ if (sizeof($this->_colinfo)>0){
+ while (sizeof($this->_colinfo)>0) {
+ $arrayref = array_pop ($this->_colinfo);
+ $this->_store_colinfo($arrayref);
+ }
+ $this->_store_defcol();
+ }
+
+ $this->_store_bof(0x0010); // Prepend the BOF record
+
+ //
+ // End of prepend. Read upwards from here.
+ ////////////////////////////////////////////
+
+ // Append
+ $this->_store_window2();
+ $this->_store_zoom();
+
+ if (sizeof($this->_panes)>0) {
+ $this->_store_panes($this->_panes);
+ }
+
+ $this->_store_selection($this->_selection);
+ $this->_store_eof();
+ }
+
+ /*
+ * Retrieve the worksheet name.
+ */
+ function get_name() {
+ return $this->_name;
+ }
+
+###############################################################################
+#
+# get_data().
+#
+# Retrieves data from memory in one chunk, or from disk in $buffer
+# sized chunks.
+#
+function get_data() {
+
+ $buffer = 4096;
+
+ # Return data stored in memory
+ if ($this->_data!==false) {
+ $tmp = $this->_data;
+ $this->_data=false;
+ $fh = $this->_filehandle;
+ if ($this->_using_tmpfile) {
+ fseek($fh, 0, SEEK_SET);
+ }
+
+ if ($this->_debug) {
+ print "*** worksheet::get_data() called (1):";
+ for ($c=0;$c<strlen($tmp);$c++) {
+ if ($c%16==0) {
+ print "\n";
+ }
+ printf("%02X ", ord($tmp[$c]));
+ }
+ print "\n";
+ }
+
+ return $tmp;
+ }
+
+ # Return data stored on disk
+ if ($this->_using_tmpfile) {
+ if ($tmp=fread($this->_filehandle, $buffer)) {
+
+ if ($this->_debug) {
+ print "*** worksheet::get_data() called (2):";
+ for ($c=0;$c<strlen($tmp);$c++) {
+ if ($c%16==0) {
+ print "\n";
+ }
+ printf("%02X ", ord($tmp[$c]));
+ }
+ print "\n";
+ }
+
+ return $tmp;
+ }
+ }
+
+ # No data to return
+ return false;
+}
+
+ /*
+ * Set this worksheet as a selected worksheet, i.e. the worksheet has
+ * its tab highlighted.
+ */
+ function select() {
+ $this->_selected = 1;
+ }
+
+ /*
+ * Set this worksheet as the active worksheet, i.e. the worksheet
+ * that is displayed when the workbook is opened. Also set it as
+ * selected.
+ */
+ function activate() {
+ $this->_selected = 1;
+ $this->_activesheet = $this->_index;
+ }
+
+ /*
+ * Set this worksheet as the first visible sheet. This is necessary
+ * when there are a large number of worksheets and the activated
+ * worksheet is not visible on the screen.
+ */
+ function set_first_sheet() {
+ $this->_firstsheet = $this->_index;
+ }
+
+ /*
+ * Set the worksheet protection flag to prevent accidental modification
+ * and to hide formulas if the locked and hidden format properties have
+ * been set.
+ */
+ function protect($password) {
+ $this->_protect = 1;
+ $this->_password = $this->_encode_password($password);
+ }
+
+###############################################################################
+#
+# set_column($firstcol, $lastcol, $width, $format, $hidden)
+#
+# Set the width of a single column or a range of column.
+# See also: _store_colinfo
+#
+function set_column() {
+
+ $_=func_get_args();
+
+ $cell = $_[0];
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $cell)) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ array_push($this->_colinfo, $_);
+
+ # Store the col sizes for use when calculating image vertices taking
+ # hidden columns into account. Also store the column formats.
+ #
+ if (sizeof($_)<3) {
+ # Ensure at least $firstcol, $lastcol and $width
+ return;
+ }
+
+ $width = $_[4] ? 0 : $_[2]; # Set width to zero if column is hidden
+ $format = $_[3];
+
+ list($firstcol, $lastcol) = $_;
+
+ for ($col=$firstcol;$col<=$lastcol;$col++) {
+ $this->_col_sizes[$col] = $width;
+ if ($format) {
+ $this->_col_formats[$col] = $format;
+ }
+ }
+}
+
+###############################################################################
+#
+# set_selection()
+#
+# Set which cell or cells are selected in a worksheet: see also the
+# function _store_selection
+#
+function set_selection() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ $this->_selection = $_;
+}
+
+###############################################################################
+#
+# freeze_panes()
+#
+# Set panes and mark them as frozen. See also _store_panes().
+#
+function freeze_panes() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ $this->_frozen = 1;
+ $this->_panes = $_;
+}
+
+###############################################################################
+#
+# thaw_panes()
+#
+# Set panes and mark them as unfrozen. See also _store_panes().
+#
+function thaw_panes() {
+
+ $_=func_get_args();
+
+ $this->_frozen = 0;
+ $this->_panes = $_;
+}
+
+ /*
+ * Set the page orientation as portrait.
+ */
+ function set_portrait() {
+ $this->_orientation = 1;
+ }
+
+ /*
+ * Set the page orientation as landscape.
+ */
+ function set_landscape() {
+ $this->_orientation = 0;
+ }
+
+ /*
+ * Set the paper type. Ex. 1 = US Letter, 9 = A4
+ */
+ function set_paper($type) {
+ $this->_paper_size = $type;
+ }
+
+ /*
+ * Set the page header caption and optional margin.
+ */
+ function set_header($string, $margin) {
+
+ if (strlen($string) >= 255) {
+ trigger_error("Header string must be less than 255 characters",
+ E_USER_WARNING);
+ return;
+ }
+
+ $this->_header = $string;
+ $this->_margin_head = $margin;
+ }
+
+ /*
+ * Set the page footer caption and optional margin.
+ */
+ function set_footer($string, $margin) {
+ if (strlen($string) >= 255) {
+ trigger_error("Footer string must be less than 255 characters",
+ E_USER_WARNING);
+ return;
+ }
+
+ $this->_footer = $string;
+ $this->_margin_foot = $margin;
+ }
+
+ /*
+ * Center the page horizontally.
+ */
+ function center_horizontally($hcenter=1) {
+ $this->_hcenter = $hcenter;
+ }
+
+ /*
+ * Center the page horizontally.
+ */
+ function center_vertically($vcenter=1) {
+ $this->_vcenter = $vcenter;
+ }
+
+ /*
+ * Set all the page margins to the same value in inches.
+ */
+ function set_margins($margin) {
+ $this->set_margin_left($margin);
+ $this->set_margin_right($margin);
+ $this->set_margin_top($margin);
+ $this->set_margin_bottom($margin);
+ }
+
+ /*
+ * Set the left and right margins to the same value in inches.
+ */
+ function set_margins_LR($margin) {
+ $this->set_margin_left($margin);
+ $this->set_margin_right($margin);
+ }
+
+ /*
+ * Set the top and bottom margins to the same value in inches.
+ */
+ function set_margins_TB($margin) {
+ $this->set_margin_top($margin);
+ $this->set_margin_bottom($margin);
+ }
+
+ /*
+ * Set the left margin in inches.
+ */
+ function set_margin_left($margin=0.75) {
+ $this->_margin_left = $margin;
+ }
+
+ /*
+ * Set the right margin in inches.
+ */
+ function set_margin_right($margin=0.75) {
+ $this->_margin_right = $margin;
+ }
+
+ /*
+ * Set the top margin in inches.
+ */
+ function set_margin_top($margin=1.00) {
+ $this->_margin_top = $margin;
+ }
+
+ /*
+ * Set the bottom margin in inches.
+ */
+ function set_margin_bottom($margin=1.00) {
+ $this->_margin_bottom = $margin;
+ }
+
+###############################################################################
+#
+# repeat_rows($first_row, $last_row)
+#
+# Set the rows to repeat at the top of each printed page. See also the
+# _store_name_xxxx() methods in Workbook.pm.
+#
+function repeat_rows() {
+
+ $_=func_get_args();
+
+ $this->_title_rowmin = $_[0];
+ $this->_title_rowmax = isset($_[1]) ? $_[1] : $_[0]; # Second row is optional
+}
+
+###############################################################################
+#
+# repeat_columns($first_col, $last_col)
+#
+# Set the columns to repeat at the left hand side of each printed page.
+# See also the _store_names() methods in Workbook.pm.
+#
+function repeat_columns() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ $this->_title_colmin = $_[0];
+ $this->_title_colmax = isset($_[1]) ? $_[1] : $_[0]; # Second col is optional
+}
+
+###############################################################################
+#
+# print_area($first_row, $first_col, $last_row, $last_col)
+#
+# Set the area of each worksheet that will be printed. See also the
+# _store_names() methods in Workbook.pm.
+#
+function print_area() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ if (sizeof($_) != 4) {
+ # Require 4 parameters
+ return;
+ }
+
+ $this->_print_rowmin = $_[0];
+ $this->_print_colmin = $_[1];
+ $this->_print_rowmax = $_[2];
+ $this->_print_colmax = $_[3];
+}
+
+ /*
+ * Set the option to hide gridlines on the screen and the printed page.
+ * There are two ways of doing this in the Excel BIFF format: The first
+ * is by setting the DspGrid field of the WINDOW2 record, this turns off
+ * the screen and subsequently the print gridline. The second method is
+ * to via the PRINTGRIDLINES and GRIDSET records, this turns off the
+ * printed gridlines only. The first method is probably sufficient for
+ * most cases. The second method is supported for backwards compatibility.
+ */
+ function hide_gridlines($option=1) {
+ if ($option == 0) {
+ $this->_print_gridlines = 1; # 1 = display, 0 = hide
+ $this->_screen_gridlines = 1;
+ } elseif ($option == 1) {
+ $this->_print_gridlines = 0;
+ $this->_screen_gridlines = 1;
+ } else {
+ $this->_print_gridlines = 0;
+ $this->_screen_gridlines = 0;
+ }
+ }
+
+ /*
+ * Set the option to print the row and column headers on the printed page.
+ * See also the _store_print_headers() method below.
+ */
+ function print_row_col_headers($headers=1) {
+ $this->_print_headers = $headers;
+ }
+
+ /*
+ * Store the vertical and horizontal number of pages that will define
+ * the maximum area printed. See also _store_setup() and _store_wsbool()
+ * below.
+ */
+ function fit_to_pages($width, $height) {
+ $this->_fit_page = 1;
+ $this->_fit_width = $width;
+ $this->_fit_height = $height;
+ }
+
+ /*
+ * Store the horizontal page breaks on a worksheet.
+ */
+ function set_h_pagebreaks($breaks) {
+ $this->_hbreaks=array_merge($this->_hbreaks, $breaks);
+ }
+
+ /*
+ * Store the vertical page breaks on a worksheet.
+ */
+ function set_v_pagebreaks($breaks) {
+ $this->_vbreaks=array_merge($this->_vbreaks, $breaks);
+ }
+
+ /*
+ * Set the worksheet zoom factor.
+ */
+ function set_zoom($scale=100) {
+ // Confine the scale to Excel's range
+ if ($scale < 10 || $scale > 400) {
+ trigger_error("Zoom factor $scale outside range: ".
+ "10 <= zoom <= 400", E_USER_WARNING);
+ $scale = 100;
+ }
+
+ $this->_zoom = $scale;
+ }
+
+ /*
+ * Set the scale factor for the printed page.
+ */
+ function set_print_scale($scale=100) {
+ // Confine the scale to Excel's range
+ if ($scale < 10 || $scale > 400) {
+ trigger_error("Print scale $scale outside range: ".
+ "10 <= zoom <= 400", E_USER_WARNING);
+ $scale = 100;
+ }
+
+ // Turn off "fit to page" option
+ $this->_fit_page = 0;
+
+ $this->_print_scale = $scale;
+ }
+
+###############################################################################
+#
+# write($row, $col, $token, $format)
+#
+# Parse $token call appropriate write method. $row and $column are zero
+# indexed. $format is optional.
+#
+# Returns: return value of called subroutine
+#
+function write() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ $token = $_[2];
+
+ # Match an array ref.
+ if (is_array($token)) {
+ return call_user_method_array('write_row', $this, $_);
+ }
+
+ # Match number
+ if (preg_match('/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/', $token)) {
+ return call_user_method_array('write_number', $this, $_);
+ }
+ # Match http, https or ftp URL
+ elseif (preg_match('|^[fh]tt?ps?://|', $token)) {
+ return call_user_method_array('write_url', $this, $_);
+ }
+ # Match mailto:
+ elseif (preg_match('/^mailto:/', $token)) {
+ return call_user_method_array('write_url', $this, $_);
+ }
+ # Match internal or external sheet link
+ elseif (preg_match('[^(?:in|ex)ternal:]', $token)) {
+ return call_user_method_array('write_url', $this, $_);
+ }
+ # Match formula
+ elseif (preg_match('/^=/', $token)) {
+ return call_user_method_array('write_formula', $this, $_);
+ }
+ # Match blank
+ elseif ($token == '') {
+ array_splice($_, 2, 1); # remove the empty string from the parameter list
+ return call_user_method_array('write_blank', $this, $_);
+ }
+ # Default: match string
+ else {
+ return call_user_method_array('write_string', $this, $_);
+ }
+}
+
+###############################################################################
+#
+# write_row($row, $col, $array_ref, $format)
+#
+# Write a row of data starting from ($row, $col). Call write_col() if any of
+# the elements of the array ref are in turn array refs. This allows the writing
+# of 1D or 2D arrays of data in one go.
+#
+# Returns: the first encountered error value or zero for no errors
+#
+function write_row() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ # Catch non array refs passed by user.
+ if (!is_array($_[2])) {
+ trigger_error("Not an array ref in call to write_row()!", E_USER_ERROR);
+ }
+
+ list($row, $col, $tokens)=array_splice($_, 0, 3);
+ $options = $_[0];
+ $error = 0;
+
+ foreach ($tokens as $token) {
+
+ # Check for nested arrays
+ if (is_array($token)) {
+ $ret = $this->write_col($row, $col, $token, $options);
+ } else {
+ $ret = $this->write ($row, $col, $token, $options);
+ }
+
+ # Return only the first error encountered, if any.
+ $error = $error || $ret;
+ $col++;
+ }
+
+ return $error;
+}
+
+###############################################################################
+#
+# _XF()
+#
+# Returns an index to the XF record in the workbook.
+# TODO
+#
+# Note: this is a function, not a method.
+#
+function _XF($row=false, $col=false, $format=false) {
+
+ if ($format) {
+ return $format->get_xf_index();
+ } elseif (isset($this->_row_formats[$row])) {
+ return $this->_row_formats[$row]->get_xf_index();
+ } elseif (isset($this->_col_formats[$col])) {
+ return $this->_col_formats[$col]->get_xf_index();
+ } else {
+ return 0x0F;
+ }
+}
+
+###############################################################################
+#
+# write_col($row, $col, $array_ref, $format)
+#
+# Write a column of data starting from ($row, $col). Call write_row() if any of
+# the elements of the array ref are in turn array refs. This allows the writing
+# of 1D or 2D arrays of data in one go.
+#
+# Returns: the first encountered error value or zero for no errors
+#
+function write_col() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ # Catch non array refs passed by user.
+ if (!is_array($_[2])) {
+ trigger_error("Not an array ref in call to write_row()!", E_USER_ERROR);
+ }
+
+ $row = array_shift($_);
+ $col = array_shift($_);
+ $tokens = array_shift($_);
+ $options = $_;
+
+ $error = 0;
+
+ foreach ($tokens as $token) {
+
+ # write() will deal with any nested arrays
+ $ret = $this->write($row, $col, $token, $options);
+
+ # Return only the first error encountered, if any.
+ $error = $error || $ret;
+ $row++;
+ }
+
+ return $error;
+}
+
+###############################################################################
+###############################################################################
+#
+# Internal methods
+#
+
+###############################################################################
+#
+# _append(), overloaded.
+#
+# Store Worksheet data in memory using the base class _append() or to a
+# temporary file, the default.
+#
+function _append($data) {
+
+ if (func_num_args()>1) {
+ trigger_error("writeexcel_worksheet::_append() ".
+ "called with more than one argument", E_USER_ERROR);
+ }
+
+ if ($this->_using_tmpfile) {
+
+ if ($this->_debug) {
+ print "worksheet::_append() called:";
+ for ($c=0;$c<strlen($data);$c++) {
+ if ($c%16==0) {
+ print "\n";
+ }
+ printf("%02X ", ord($data[$c]));
+ }
+ print "\n";
+ }
+
+ # Add CONTINUE records if necessary
+ if (strlen($data) > $this->_limit) {
+ $data = $this->_add_continue($data);
+ }
+
+ fputs($this->_filehandle, $data);
+ $this->_datasize += strlen($data);
+ } else {
+ parent::_append($data);
+ }
+}
+
+###############################################################################
+#
+# _substitute_cellref()
+#
+# Substitute an Excel cell reference in A1 notation for zero based row and
+# column values in an argument list.
+#
+# Ex: ("A4", "Hello") is converted to (3, 0, "Hello").
+#
+// Exactly one array must be passed!
+function _substitute_cellref($_) {
+ $cell = strtoupper(array_shift($_));
+
+ # Convert a column range: 'A:A' or 'B:G'
+ if (preg_match('/([A-I]?[A-Z]):([A-I]?[A-Z])/', $cell, $reg)) {
+ list($dummy, $col1) = $this->_cell_to_rowcol($reg[1] .'1'); # Add a dummy row
+ list($dummy, $col2) = $this->_cell_to_rowcol($reg[2] .'1'); # Add a dummy row
+ return array_merge(array($col1, $col2), $_);
+ }
+
+ # Convert a cell range: 'A1:B7'
+ if (preg_match('/\$?([A-I]?[A-Z]\$?\d+):\$?([A-I]?[A-Z]\$?\d+)/', $cell, $reg)) {
+ list($row1, $col1) = $this->_cell_to_rowcol($reg[1]);
+ list($row2, $col2) = $this->_cell_to_rowcol($reg[2]);
+ return array_merge(array($row1, $col1, $row2, $col2), $_);
+ }
+
+ # Convert a cell reference: 'A1' or 'AD2000'
+ if (preg_match('/\$?([A-I]?[A-Z]\$?\d+)/', $cell, $reg)) {
+ list($row1, $col1) = $this->_cell_to_rowcol($reg[1]);
+ return array_merge(array($row1, $col1), $_);
+
+ }
+
+ trigger_error("Unknown cell reference $cell", E_USER_ERROR);
+}
+
+###############################################################################
+#
+# _cell_to_rowcol($cell_ref)
+#
+# Convert an Excel cell reference in A1 notation to a zero based row and column
+# reference; converts C1 to (0, 2).
+#
+# Returns: row, column
+#
+# TODO use functions in Utility.pm
+#
+function _cell_to_rowcol($cell) {
+
+ preg_match('/\$?([A-I]?[A-Z])\$?(\d+)/', $cell, $reg);
+
+ $col = $reg[1];
+ $row = $reg[2];
+
+ # Convert base26 column string to number
+ # All your Base are belong to us.
+ $chars = preg_split('//', $col, -1, PREG_SPLIT_NO_EMPTY);
+ $expn = 0;
+ $col = 0;
+
+ while (sizeof($chars)) {
+ $char = array_pop($chars); # LS char first
+ $col += (ord($char) -ord('A') +1) * pow(26, $expn);
+ $expn++;
+ }
+
+ # Convert 1-index to zero-index
+ $row--;
+ $col--;
+
+ return array($row, $col);
+}
+
+ /*
+ * This is an internal method that is used to filter elements of the
+ * array of pagebreaks used in the _store_hbreak() and _store_vbreak()
+ * methods. It:
+ * 1. Removes duplicate entries from the list.
+ * 2. Sorts the list.
+ * 3. Removes 0 from the list if present.
+ */
+ function _sort_pagebreaks($breaks) {
+ // Hash slice to remove duplicates
+ foreach ($breaks as $break) {
+ $hash["$break"]=1;
+ }
+
+ // Numerical sort
+ $breaks=array_keys($hash);
+ sort($breaks, SORT_NUMERIC);
+
+ // Remove zero
+ if ($breaks[0] == 0) {
+ array_shift($breaks);
+ }
+
+ // 1000 vertical pagebreaks appears to be an internal Excel 5 limit.
+ // It is slightly higher in Excel 97/200, approx. 1026
+ if (sizeof($breaks) > 1000) {
+ array_splice($breaks, 1000);
+ }
+
+ return $breaks;
+ }
+
+ /*
+ * Based on the algorithm provided by Daniel Rentz of OpenOffice.
+ */
+ function _encode_password($plaintext) {
+ $chars=preg_split('//', $plaintext, -1, PREG_SPLIT_NO_EMPTY);
+ $count=sizeof($chars);
+
+ for ($c=0;$c<sizeof($chars);$c++) {
+ $char=$chars[$c];
+ $char = ord($char) << ++$i;
+ $low_15 = $char & 0x7fff;
+ $high_15 = $char & 0x7fff << 15;
+ $high_15 = $high_15 >> 15;
+ $char = $low_15 | $high_15;
+ }
+
+ $password = 0x0000;
+
+ foreach ($chars as $char) {
+ $password ^= $char;
+ }
+
+ $password ^= $count;
+ $password ^= 0xCE4B;
+
+ return $password;
+ }
+
+###############################################################################
+###############################################################################
+#
+# BIFF RECORDS
+#
+
+###############################################################################
+#
+# write_number($row, $col, $num, $format)
+#
+# Write a double to the specified row and column (zero indexed).
+# An integer can be written as a double. Excel will display an
+# integer. $format is optional.
+#
+# Returns 0 : normal termination
+# -1 : insufficient number of arguments
+# -2 : row or column out of range
+#
+function write_number() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ # Check the number of args
+ if (sizeof($_) < 3) {
+ return -1;
+ }
+
+ $record = 0x0203; # Record identifier
+ $length = 0x000E; # Number of bytes to follow
+
+ $row = $_[0]; # Zero indexed row
+ $col = $_[1]; # Zero indexed column
+ $num = $_[2];
+//!!!
+ $xf = $this->_XF($row, $col, $_[3]); # The cell format
+
+ # Check that row and col are valid and store max and min values
+ if ($row >= $this->_xls_rowmax) { return -2; }
+ if ($col >= $this->_xls_colmax) { return -2; }
+ if ($row < $this->_dim_rowmin) { $this->_dim_rowmin = $row; }
+ if ($row > $this->_dim_rowmax) { $this->_dim_rowmax = $row; }
+ if ($col < $this->_dim_colmin) { $this->_dim_colmin = $col; }
+ if ($col > $this->_dim_colmax) { $this->_dim_colmax = $col; }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvv", $row, $col, $xf);
+ $xl_double = pack("d", $num);
+
+ if ($this->_byte_order) {
+//TODO
+ $xl_double = strrev($xl_double);
+ }
+
+ $this->_append($header . $data . $xl_double);
+
+ return 0;
+}
+
+###############################################################################
+#
+# write_string ($row, $col, $string, $format)
+#
+# Write a string to the specified row and column (zero indexed).
+# NOTE: there is an Excel 5 defined limit of 255 characters.
+# $format is optional.
+# Returns 0 : normal termination
+# -1 : insufficient number of arguments
+# -2 : row or column out of range
+# -3 : long string truncated to 255 chars
+#
+function write_string() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ # Check the number of args
+ if (sizeof($_) < 3) {
+ return -1;
+ }
+
+ $record = 0x0204; # Record identifier
+ $length = 0x0008 + strlen($_[2]); # Bytes to follow
+
+ $row = $_[0]; # Zero indexed row
+ $col = $_[1]; # Zero indexed column
+ $strlen = strlen($_[2]);
+ $str = $_[2];
+ $xf = $this->_XF($row, $col, $_[3]); # The cell format
+
+ $str_error = 0;
+
+ # Check that row and col are valid and store max and min values
+ if ($row >= $this->_xls_rowmax) { return -2; }
+ if ($col >= $this->_xls_colmax) { return -2; }
+ if ($row < $this->_dim_rowmin) { $this->_dim_rowmin = $row; }
+ if ($row > $this->_dim_rowmax) { $this->_dim_rowmax = $row; }
+ if ($col < $this->_dim_colmin) { $this->_dim_colmin = $col; }
+ if ($col > $this->_dim_colmax) { $this->_dim_colmax = $col; }
+
+ if ($strlen > $this->_xls_strmax) { # LABEL must be < 255 chars
+ $str = substr($str, 0, $this->_xls_strmax);
+ $length = 0x0008 + $this->_xls_strmax;
+ $strlen = $this->_xls_strmax;
+ $str_error = -3;
+ }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvv", $row, $col, $xf, $strlen);
+
+ $this->_append($header . $data . $str);
+
+ return $str_error;
+}
+
+###############################################################################
+#
+# write_blank($row, $col, $format)
+#
+# Write a blank cell to the specified row and column (zero indexed).
+# A blank cell is used to specify formatting without adding a string
+# or a number.
+#
+# A blank cell without a format serves no purpose. Therefore, we don't write
+# a BLANK record unless a format is specified. This is mainly an optimisation
+# for the write_row() and write_col() methods.
+#
+# Returns 0 : normal termination (including no format)
+# -1 : insufficient number of arguments
+# -2 : row or column out of range
+#
+function write_blank() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ # Check the number of args
+ if (sizeof($_) < 2) {
+ return -1;
+ }
+
+ # Don't write a blank cell unless it has a format
+ if (!isset($_[2])) {
+ return 0;
+ }
+
+ $record = 0x0201; # Record identifier
+ $length = 0x0006; # Number of bytes to follow
+
+ $row = $_[0]; # Zero indexed row
+ $col = $_[1]; # Zero indexed column
+ $xf = $this->_XF($row, $col, $_[2]); # The cell format
+
+ # Check that row and col are valid and store max and min values
+ if ($row >= $this->_xls_rowmax) { return -2; }
+ if ($col >= $this->_xls_colmax) { return -2; }
+ if ($row < $this->_dim_rowmin) { $this->_dim_rowmin = $row; }
+ if ($row > $this->_dim_rowmax) { $this->_dim_rowmax = $row; }
+ if ($col < $this->_dim_colmin) { $this->_dim_colmin = $col; }
+ if ($col > $this->_dim_colmax) { $this->_dim_colmax = $col; }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvv", $row, $col, $xf);
+
+ $this->_append($header . $data);
+
+ return 0;
+}
+
+###############################################################################
+#
+# write_formula($row, $col, $formula, $format)
+#
+# Write a formula to the specified row and column (zero indexed).
+# The textual representation of the formula is passed to the parser in
+# Formula.pm which returns a packed binary string.
+#
+# $format is optional.
+#
+# Returns 0 : normal termination
+# -1 : insufficient number of arguments
+# -2 : row or column out of range
+#
+function write_formula() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ # Check the number of args
+ if (sizeof($_) < 3) {
+ return -1;
+ }
+
+ $record = 0x0006; # Record identifier
+ $length=0; # Bytes to follow
+
+ $row = $_[0]; # Zero indexed row
+ $col = $_[1]; # Zero indexed column
+ $formula = $_[2]; # The formula text string
+
+ # Excel normally stores the last calculated value of the formula in $num.
+ # Clearly we are not in a position to calculate this a priori. Instead
+ # we set $num to zero and set the option flags in $grbit to ensure
+ # automatic calculation of the formula when the file is opened.
+ #
+ $xf = $this->_XF($row, $col, $_[3]); # The cell format
+ $num = 0x00; # Current value of formula
+ $grbit = 0x03; # Option flags
+ $chn = 0x0000; # Must be zero
+
+ # Check that row and col are valid and store max and min values
+ if ($row >= $this->_xls_rowmax) { return -2; }
+ if ($col >= $this->_xls_colmax) { return -2; }
+ if ($row < $this->_dim_rowmin) { $this->_dim_rowmin = $row; }
+ if ($row > $this->_dim_rowmax) { $this->_dim_rowmax = $row; }
+ if ($col < $this->_dim_colmin) { $this->_dim_colmin = $col; }
+ if ($col > $this->_dim_colmax) { $this->_dim_colmax = $col; }
+
+ # Strip the = sign at the beginning of the formula string
+ $formula = preg_replace('/^=/', "", $formula);
+
+ # Parse the formula using the parser in Formula.pm
+ $parser = $this->_parser;
+ $formula = $parser->parse_formula($formula);
+
+ $formlen = strlen($formula); # Length of the binary string
+ $length = 0x16 + $formlen; # Length of the record data
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvdvVv", $row, $col, $xf, $num,
+ $grbit, $chn, $formlen);
+
+ $this->_append($header . $data . $formula);
+
+ return 0;
+}
+
+###############################################################################
+#
+# write_url($row, $col, $url, $string, $format)
+#
+# Write a hyperlink. This is comprised of two elements: the visible label and
+# the invisible link. The visible label is the same as the link unless an
+# alternative string is specified. The label is written using the
+# write_string() method. Therefore the 255 characters string limit applies.
+# $string and $format are optional and their order is interchangeable.
+#
+# The hyperlink can be to a http, ftp, mail, internal sheet, or external
+# directory url.
+#
+# Returns 0 : normal termination
+# -1 : insufficient number of arguments
+# -2 : row or column out of range
+# -3 : long string truncated to 255 chars
+#
+function write_url() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ # Check the number of args
+ if (sizeof($_) < 3) {
+ return -1;
+ }
+
+ # Add start row and col to arg list
+ return call_user_method_array('write_url_range', $this,
+ array_merge(array($_[0], $_[1]), $_));
+}
+
+###############################################################################
+#
+# write_url_range($row1, $col1, $row2, $col2, $url, $string, $format)
+#
+# This is the more general form of write_url(). It allows a hyperlink to be
+# written to a range of cells. This function also decides the type of hyperlink
+# to be written. These are either, Web (http, ftp, mailto), Internal
+# (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1').
+#
+# See also write_url() above for a general description and return values.
+#
+function write_url_range() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ # Check the number of args
+ if (sizeof($_) < 5) {
+ return -1;
+ }
+
+ # Reverse the order of $string and $format if necessary.
+//TODO ($_[5], $_[6]) = ($_[6], $_[5]) if (ref $_[5]);
+
+ $url = $_[4];
+
+ # Check for internal/external sheet links or default to web link
+ if (preg_match('[^internal:]', $url)) {
+ return call_user_method_array('_write_url_internal', $this, $_);
+ }
+
+ if (preg_match('[^external:]', $url)) {
+ return call_user_method_array('_write_url_external', $this, $_);
+ }
+
+ return call_user_method_array('_write_url_web', $this, $_);
+}
+
+###############################################################################
+#
+# _write_url_web($row1, $col1, $row2, $col2, $url, $string, $format)
+#
+# Used to write http, ftp and mailto hyperlinks.
+# The link type ($options) is 0x03 is the same as absolute dir ref without
+# sheet. However it is differentiated by the $unknown2 data stream.
+#
+# See also write_url() above for a general description and return values.
+#
+function _write_url_web() {
+
+ $_=func_get_args();
+
+ $record = 0x01B8; # Record identifier
+ $length = 0x00000; # Bytes to follow
+
+ $row1 = $_[0]; # Start row
+ $col1 = $_[1]; # Start column
+ $row2 = $_[2]; # End row
+ $col2 = $_[3]; # End column
+ $url = $_[4]; # URL string
+ if (isset($_[5])) {
+ $str = $_[5]; # Alternative label
+ }
+ $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format
+
+ # Write the visible label using the write_string() method.
+ if(!isset($str)) {
+ $str = $url;
+ }
+
+ $str_error = $this->write_string($row1, $col1, $str, $xf);
+
+ if ($str_error == -2) {
+ return $str_error;
+ }
+
+ # Pack the undocumented parts of the hyperlink stream
+ $unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
+ $unknown2 = pack("H*", "E0C9EA79F9BACE118C8200AA004BA90B");
+
+ # Pack the option flags
+ $options = pack("V", 0x03);
+
+ # Convert URL to a null terminated wchar string
+ $url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY));
+ $url = $url . "\0\0\0";
+
+ # Pack the length of the URL
+ $url_len = pack("V", strlen($url));
+
+ # Calculate the data length
+ $length = 0x34 + strlen($url);
+
+ # Pack the header data
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvv", $row1, $row2, $col1, $col2);
+
+ # Write the packed data
+ $this->_append($header.
+ $data.
+ $unknown1.
+ $options.
+ $unknown2.
+ $url_len.
+ $url);
+
+ return $str_error;
+}
+
+###############################################################################
+#
+# _write_url_internal($row1, $col1, $row2, $col2, $url, $string, $format)
+#
+# Used to write internal reference hyperlinks such as "Sheet1!A1".
+#
+# See also write_url() above for a general description and return values.
+#
+function _write_url_internal() {
+
+ $_=func_get_args();
+
+ $record = 0x01B8; # Record identifier
+ $length = 0x00000; # Bytes to follow
+
+ $row1 = $_[0]; # Start row
+ $col1 = $_[1]; # Start column
+ $row2 = $_[2]; # End row
+ $col2 = $_[3]; # End column
+ $url = $_[4]; # URL string
+ if (isset($_[5])) {
+ $str = $_[5]; # Alternative label
+ }
+ $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format
+
+ # Strip URL type
+ $url = preg_replace('s[^internal:]', '', $url);
+
+ # Write the visible label
+ if (!isset($str)) {
+ $str = $url;
+ }
+ $str_error = $this->write_string($row1, $col1, $str, $xf);
+
+ if ($str_error == -2) {
+ return $str_error;
+ }
+
+ # Pack the undocumented parts of the hyperlink stream
+ $unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
+
+ # Pack the option flags
+ $options = pack("V", 0x08);
+
+ # Convert the URL type and to a null terminated wchar string
+ $url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY));
+ $url = $url . "\0\0\0";
+
+ # Pack the length of the URL as chars (not wchars)
+ $url_len = pack("V", int(strlen($url)/2));
+
+ # Calculate the data length
+ $length = 0x24 + strlen($url);
+
+ # Pack the header data
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvv", $row1, $row2, $col1, $col2);
+
+ # Write the packed data
+ $this->_append($header.
+ $data.
+ $unknown1.
+ $options.
+ $url_len.
+ $url);
+
+ return $str_error;
+}
+
+###############################################################################
+#
+# _write_url_external($row1, $col1, $row2, $col2, $url, $string, $format)
+#
+# Write links to external directory names such as 'c:\foo.xls',
+# c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'.
+#
+# Note: Excel writes some relative links with the $dir_long string. We ignore
+# these cases for the sake of simpler code.
+#
+# See also write_url() above for a general description and return values.
+#
+function _write_url_external() {
+
+ $_=func_get_args();
+
+ # Network drives are different. We will handle them separately
+ # MS/Novell network drives and shares start with \\
+ if (preg_match('[^external:\\\\]', $_[4])) {
+ return call_user_method_array('_write_url_external_net', $this, $_);
+ }
+
+ $record = 0x01B8; # Record identifier
+ $length = 0x00000; # Bytes to follow
+
+ $row1 = $_[0]; # Start row
+ $col1 = $_[1]; # Start column
+ $row2 = $_[2]; # End row
+ $col2 = $_[3]; # End column
+ $url = $_[4]; # URL string
+ if (isset($_[5])) {
+ $str = $_[5]; # Alternative label
+ }
+ $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format
+
+ # Strip URL type and change Unix dir separator to Dos style (if needed)
+ #
+ $url = preg_replace('[^external:]', '', $url);
+ $url = preg_replace('[/]', "\\", $url);
+
+ # Write the visible label
+ if (!isset($str)) {
+ $str = preg_replace('[\#]', ' - ', $url);
+ }
+ $str_error = $this->write_string($row1, $col1, $str, $xf);
+ if ($str_error == -2) {
+ return $str_error;
+ }
+
+ # Determine if the link is relative or absolute:
+ # relative if link contains no dir separator, "somefile.xls"
+ # relative if link starts with up-dir, "..\..\somefile.xls"
+ # otherwise, absolute
+ #
+ $absolute = 0x02; # Bit mask
+
+ if (!preg_match('[\\]', $url)) {
+ $absolute = 0x00;
+ }
+
+ if (preg_match('[^\.\.\\]', $url)) {
+ $absolute = 0x00;
+ }
+
+ # Determine if the link contains a sheet reference and change some of the
+ # parameters accordingly.
+ # Split the dir name and sheet name (if it exists)
+ #
+ list($dir_long, $sheet) = preg_split('/\#/', $url);
+ $link_type = 0x01 | $absolute;
+
+//!!!
+ if (isset($sheet)) {
+ $link_type |= 0x08;
+ $sheet_len = pack("V", length($sheet) + 0x01);
+ $sheet = join("\0", split('', $sheet));
+ $sheet .= "\0\0\0";
+ } else {
+ $sheet_len = '';
+ $sheet = '';
+ }
+
+ # Pack the link type
+ $link_type = pack("V", $link_type);
+
+
+ # Calculate the up-level dir count e.g.. (..\..\..\ == 3)
+/* TODO
+ $up_count = 0;
+ $up_count++ while $dir_long =~ s[^\.\.\\][];
+ $up_count = pack("v", $up_count);
+*/
+
+ # Store the short dos dir name (null terminated)
+ $dir_short = $dir_long . "\0";
+
+ # Store the long dir name as a wchar string (non-null terminated)
+ $dir_long = join("\0", preg_split('', $dir_long, -1, PREG_SPLIT_NO_EMPTY));
+ $dir_long = $dir_long . "\0";
+
+ # Pack the lengths of the dir strings
+ $dir_short_len = pack("V", strlen($dir_short) );
+ $dir_long_len = pack("V", strlen($dir_long) );
+ $stream_len = pack("V", strlen($dir_long) + 0x06);
+
+ # Pack the undocumented parts of the hyperlink stream
+ $unknown1 =pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' );
+ $unknown2 =pack("H*",'0303000000000000C000000000000046' );
+ $unknown3 =pack("H*",'FFFFADDE000000000000000000000000000000000000000');
+ $unknown4 =pack("v", 0x03 );
+
+ # Pack the main data stream
+ $data = pack("vvvv", $row1, $row2, $col1, $col2) .
+ $unknown1 .
+ $link_type .
+ $unknown2 .
+ $up_count .
+ $dir_short_len.
+ $dir_short .
+ $unknown3 .
+ $stream_len .
+ $dir_long_len .
+ $unknown4 .
+ $dir_long .
+ $sheet_len .
+ $sheet ;
+
+ # Pack the header data
+ $length = strlen($data);
+ $header = pack("vv", $record, $length);
+
+ # Write the packed data
+ $this->_append($header . $data);
+
+ return $str_error;
+}
+
+###############################################################################
+#
+# write_url_xxx($row1, $col1, $row2, $col2, $url, $string, $format)
+#
+# Write links to external MS/Novell network drives and shares such as
+# '//NETWORK/share/foo.xls' and '//NETWORK/share/foo.xls#Sheet1!A1'.
+#
+# See also write_url() above for a general description and return values.
+#
+function _write_url_external_net() {
+
+ $_=func_get_args();
+
+ $record = 0x01B8; # Record identifier
+ $length = 0x00000; # Bytes to follow
+
+ $row1 = $_[0]; # Start row
+ $col1 = $_[1]; # Start column
+ $row2 = $_[2]; # End row
+ $col2 = $_[3]; # End column
+ $url = $_[4]; # URL string
+ if(isset($_[5])) {
+ $str = $_[5]; # Alternative label
+ }
+ $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format
+
+ # Strip URL type and change Unix dir separator to Dos style (if needed)
+ #
+ $url = preg_replace('[^external:]', "", $url);
+ $url = preg_replace('[/]', "\\");
+
+ # Write the visible label
+ if (!isset($str)) {
+ $str = preg_replace('[\#]', " - ", $url);
+ }
+
+ $str_error = $this->write_string($row1, $col1, $str, $xf);
+ if ($str_error == -2) {
+ return $str_error;
+ }
+
+ # Determine if the link contains a sheet reference and change some of the
+ # parameters accordingly.
+ # Split the dir name and sheet name (if it exists)
+ #
+ list($dir_long , $sheet) = preg_split('\#', $url);
+ $link_type = 0x0103; # Always absolute
+
+//!!!
+ if (isset($sheet)) {
+ $link_type |= 0x08;
+ $sheet_len = pack("V", strlen($sheet) + 0x01);
+ $sheet = join("\0", preg_split("''", $sheet, -1, PREG_SPLIT_NO_EMPTY));
+ $sheet .= "\0\0\0";
+ } else {
+ $sheet_len = '';
+ $sheet = '';
+ }
+
+ # Pack the link type
+ $link_type = pack("V", $link_type);
+
+ # Make the string null terminated
+ $dir_long = $dir_long . "\0";
+
+ # Pack the lengths of the dir string
+ $dir_long_len = pack("V", strlen($dir_long));
+
+ # Store the long dir name as a wchar string (non-null terminated)
+ $dir_long = join("\0", preg_split("''", $dir_long, -1, PREG_SPLIT_NO_EMPTY));
+ $dir_long = $dir_long . "\0";
+
+ # Pack the undocumented part of the hyperlink stream
+ $unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000');
+
+ # Pack the main data stream
+ $data = pack("vvvv", $row1, $row2, $col1, $col2) .
+ $unknown1 .
+ $link_type .
+ $dir_long_len .
+ $dir_long .
+ $sheet_len .
+ $sheet ;
+
+ # Pack the header data
+ $length = strlen($data);
+ $header = pack("vv", $record, $length);
+
+ # Write the packed data
+ $this->_append($header . $data);
+
+ return $str_error;
+}
+
+###############################################################################
+#
+# set_row($row, $height, $XF)
+#
+# This method is used to set the height and XF format for a row.
+# Writes the BIFF record ROW.
+#
+function set_row() {
+
+ $_=func_get_args();
+
+ $record = 0x0208; # Record identifier
+ $length = 0x0010; # Number of bytes to follow
+
+ $rw = $_[0]; # Row Number
+ $colMic = 0x0000; # First defined column
+ $colMac = 0x0000; # Last defined column
+ //$miyRw; # Row height
+ $irwMac = 0x0000; # Used by Excel to optimise loading
+ $reserved = 0x0000; # Reserved
+ $grbit = 0x01C0; # Option flags. (monkey) see $1 do
+ //$ixfe; # XF index
+ if (isset($_[2])) {
+ $format = $_[2]; # Format object
+ }
+
+ # Check for a format object
+ if (isset($_[2])) {
+ $ixfe = $format->get_xf_index();
+ } else {
+ $ixfe = 0x0F;
+ }
+
+ # Use set_row($row, undef, $XF) to set XF without setting height
+ if (isset($_[1])) {
+ $miyRw = $_[1] *20;
+ } else {
+ $miyRw = 0xff;
+ }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvvvvvv", $rw, $colMic, $colMac, $miyRw,
+ $irwMac,$reserved, $grbit, $ixfe);
+
+ $this->_append($header . $data);
+
+ # Store the row sizes for use when calculating image vertices.
+ # Also store the column formats.
+ #
+ # Ensure at least $row and $height
+ if (sizeof($_) < 2) {
+ return;
+ }
+
+ $this->_row_sizes[$_[0]] = $_[1];
+ if (isset($_[2])) {
+ $this->_row_formats[$_[0]] = $_[2];
+ }
+}
+
+ /*
+ * Writes Excel DIMENSIONS to define the area in which there is data.
+ */
+ function _store_dimensions() {
+ $record = 0x0000; // Record identifier
+ $length = 0x000A; // Number of bytes to follow
+ $row_min = $this->_dim_rowmin; // First row
+ $row_max = $this->_dim_rowmax; // Last row plus 1
+ $col_min = $this->_dim_colmin; // First column
+ $col_max = $this->_dim_colmax; // Last column plus 1
+ $reserved = 0x0000; // Reserved by Excel
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvvv", $row_min, $row_max,
+ $col_min, $col_max, $reserved);
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Write BIFF record Window2.
+ */
+ function _store_window2() {
+ $record = 0x023E; // Record identifier
+ $length = 0x000A; // Number of bytes to follow
+
+ $grbit = 0x00B6; // Option flags
+ $rwTop = 0x0000; // Top row visible in window
+ $colLeft = 0x0000; // Leftmost column visible in window
+ $rgbHdr = 0x00000000; // Row/column heading and gridline
+ // color
+
+ // The options flags that comprise $grbit
+ $fDspFmla = 0; // 0 - bit
+ $fDspGrid = $this->_screen_gridlines; // 1
+ $fDspRwCol = 1; // 2
+ $fFrozen = $this->_frozen; // 3
+ $fDspZeros = 1; // 4
+ $fDefaultHdr = 1; // 5
+ $fArabic = 0; // 6
+ $fDspGuts = 1; // 7
+ $fFrozenNoSplit = 0; // 0 - bit
+ $fSelected = $this->_selected; // 1
+ $fPaged = 1; // 2
+
+ $grbit = $fDspFmla;
+ $grbit |= $fDspGrid << 1;
+ $grbit |= $fDspRwCol << 2;
+ $grbit |= $fFrozen << 3;
+ $grbit |= $fDspZeros << 4;
+ $grbit |= $fDefaultHdr << 5;
+ $grbit |= $fArabic << 6;
+ $grbit |= $fDspGuts << 7;
+ $grbit |= $fFrozenNoSplit << 8;
+ $grbit |= $fSelected << 9;
+ $grbit |= $fPaged << 10;
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvV", $grbit, $rwTop, $colLeft, $rgbHdr);
+
+ $this->_append($header . $data);
+ }
+
+ /*
+ * Write BIFF record DEFCOLWIDTH if COLINFO records are in use.
+ */
+ function _store_defcol() {
+ $record = 0x0055; // Record identifier
+ $length = 0x0002; // Number of bytes to follow
+
+ $colwidth = 0x0008; // Default column width
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $colwidth);
+
+ $this->_prepend($header . $data);
+ }
+
+###############################################################################
+#
+# _store_colinfo($firstcol, $lastcol, $width, $format, $hidden)
+#
+# Write BIFF record COLINFO to define column widths
+#
+# Note: The SDK says the record length is 0x0B but Excel writes a 0x0C
+# length record.
+#
+function _store_colinfo($_) {
+
+ $record = 0x007D; # Record identifier
+ $length = 0x000B; # Number of bytes to follow
+
+ $colFirst = $_[0] ? $_[0] : 0; # First formatted column
+ $colLast = $_[1] ? $_[1] : 0; # Last formatted column
+ $coldx = $_[2] ? $_[2] : 8.43; # Col width, 8.43 is Excel default
+
+ $coldx += 0.72; # Fudge. Excel subtracts 0.72 !?
+ $coldx *= 256; # Convert to units of 1/256 of a char
+
+ //$ixfe; # XF index
+ $grbit = $_[4] || 0; # Option flags
+ $reserved = 0x00; # Reserved
+ $format = $_[3]; # Format object
+
+ # Check for a format object
+ if (isset($_[3])) {
+ $ixfe = $format->get_xf_index();
+ } else {
+ $ixfe = 0x0F;
+ }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvvvC", $colFirst, $colLast, $coldx,
+ $ixfe, $grbit, $reserved);
+ $this->_prepend($header . $data);
+}
+
+###############################################################################
+#
+# _store_selection($first_row, $first_col, $last_row, $last_col)
+#
+# Write BIFF record SELECTION.
+#
+function _store_selection($_) {
+
+ $record = 0x001D; # Record identifier
+ $length = 0x000F; # Number of bytes to follow
+
+ $pnn = $this->_active_pane; # Pane position
+ $rwAct = $_[0]; # Active row
+ $colAct = $_[1]; # Active column
+ $irefAct = 0; # Active cell ref
+ $cref = 1; # Number of refs
+
+ $rwFirst = $_[0]; # First row in reference
+ $colFirst = $_[1]; # First col in reference
+ $rwLast = $_[2] ? $_[2] : $rwFirst; # Last row in reference
+ $colLast = $_[3] ? $_[3] : $colFirst; # Last col in reference
+
+ # Swap last row/col for first row/col as necessary
+ if ($rwFirst > $rwLast) {
+ list($rwFirst, $rwLast) = array($rwLast, $rwFirst);
+ }
+
+ if ($colFirst > $colLast) {
+ list($colFirst, $colLast) = array($colLast, $colFirst);
+ }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct,
+ $irefAct, $cref,
+ $rwFirst, $rwLast,
+ $colFirst, $colLast);
+
+ $this->_append($header . $data);
+}
+
+ /*
+ * Write BIFF record EXTERNCOUNT to indicate the number of external
+ * sheet references in a worksheet.
+ *
+ * Excel only stores references to external sheets that are used in
+ * formulas. For simplicity we store references to all the sheets in
+ * the workbook regardless of whether they are used or not. This reduces
+ * the overall complexity and eliminates the need for a two way dialogue
+ * between the formula parser the worksheet objects.
+ */
+ function _store_externcount($cxals) {
+ // $cxals Number of external references
+
+ $record = 0x0016; // Record identifier
+ $length = 0x0002; // Number of bytes to follow
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $cxals);
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Writes the Excel BIFF EXTERNSHEET record. These references are used
+ * by formulas. A formula references a sheet name via an index. Since we
+ * store a reference to all of the external worksheets the EXTERNSHEET
+ * index is the same as the worksheet index.
+ */
+ function _store_externsheet($sheetname) {
+ $record = 0x0017; # Record identifier
+ // $length Number of bytes to follow
+
+ // $cch Length of sheet name
+ // $rgch Filename encoding
+
+ // References to the current sheet are encoded differently to
+ // references to external sheets.
+ if ($this->_name == $sheetname) {
+ $sheetname = '';
+ $length = 0x02; // The following 2 bytes
+ $cch = 1; // The following byte
+ $rgch = 0x02; // Self reference
+ } else {
+ $length = 0x02 + strlen($sheetname);
+ $cch = strlen($sheetname);
+ $rgch = 0x03; // Reference to a sheet in the current
+ // workbook
+ }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("CC", $cch, $rgch);
+
+ $this->_prepend($header . $data . $sheetname);
+ }
+
+###############################################################################
+#
+# _store_panes()
+#
+#
+# Writes the Excel BIFF PANE record.
+# The panes can either be frozen or thawed (unfrozen).
+# Frozen panes are specified in terms of a integer number of rows and columns.
+# Thawed panes are specified in terms of Excel's units for rows and columns.
+#
+function _store_panes() {
+
+ $_=func_get_args();
+
+ $record = 0x0041; # Record identifier
+ $length = 0x000A; # Number of bytes to follow
+
+ $y = $_[0] || 0; # Vertical split position
+ $x = $_[1] || 0; # Horizontal split position
+ if (isset($_[2])) {
+ $rwTop = $_[2]; # Top row visible
+ }
+ if (isset($_[3])) {
+ $colLeft = $_[3]; # Leftmost column visible
+ }
+ if (isset($_[4])) {
+ $pnnAct = $_[4]; # Active pane
+ }
+
+ # Code specific to frozen or thawed panes.
+ if ($this->_frozen) {
+ # Set default values for $rwTop and $colLeft
+ if (!isset($rwTop)) {
+ $rwTop = $y;
+ }
+ if (!isset($colLeft)) {
+ $colLeft = $x;
+ }
+ } else {
+ # Set default values for $rwTop and $colLeft
+ if (!isset($rwTop)) {
+ $rwTop = 0;
+ }
+ if (!isset($colLeft)) {
+ $colLeft = 0;
+ }
+
+ # Convert Excel's row and column units to the internal units.
+ # The default row height is 12.75
+ # The default column width is 8.43
+ # The following slope and intersection values were interpolated.
+ #
+ $y = 20*$y + 255;
+ $x = 113.879*$x + 390;
+ }
+
+ # Determine which pane should be active. There is also the undocumented
+ # option to override this should it be necessary: may be removed later.
+ #
+ if (!isset($pnnAct)) {
+ # Bottom right
+ if ($x != 0 && $y != 0) {
+ $pnnAct = 0;
+ }
+ # Top right
+ if ($x != 0 && $y == 0) {
+ $pnnAct = 1;
+ }
+ # Bottom left
+ if ($x == 0 && $y != 0) {
+ $pnnAct = 2;
+ }
+ # Top left
+ if ($x == 0 && $y == 0) {
+ $pnnAct = 3;
+ }
+ }
+
+ $this->_active_pane = $pnnAct; # Used in _store_selection
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct);
+
+ $this->_append($header . $data);
+}
+
+ /*
+ * Store the page setup SETUP BIFF record.
+ */
+ function _store_setup() {
+ $record = 0x00A1; // Record identifier
+ $length = 0x0022; // Number of bytes to follow
+
+ $iPaperSize = $this->_paper_size; // Paper size
+ $iScale = $this->_print_scale; // Print scaling factor
+ $iPageStart = 0x01; // Starting page number
+ $iFitWidth = $this->_fit_width; // Fit to number of pages wide
+ $iFitHeight = $this->_fit_height; // Fit to number of pages high
+ $grbit = 0x00; // Option flags
+ $iRes = 0x0258; // Print resolution
+ $iVRes = 0x0258; // Vertical print resolution
+ $numHdr = $this->_margin_head; // Header Margin
+ $numFtr = $this->_margin_foot; // Footer Margin
+ $iCopies = 0x01; // Number of copies
+
+ $fLeftToRight = 0x0; // Print over then down
+ $fLandscape = $this->_orientation; // Page orientation
+ $fNoPls = 0x0; // Setup not read from printer
+ $fNoColor = 0x0; // Print black and white
+ $fDraft = 0x0; // Print draft quality
+ $fNotes = 0x0; // Print notes
+ $fNoOrient = 0x0; // Orientation not set
+ $fUsePage = 0x0; // Use custom starting page
+
+ $grbit = $fLeftToRight;
+ $grbit |= $fLandscape << 1;
+ $grbit |= $fNoPls << 2;
+ $grbit |= $fNoColor << 3;
+ $grbit |= $fDraft << 4;
+ $grbit |= $fNotes << 5;
+ $grbit |= $fNoOrient << 6;
+ $grbit |= $fUsePage << 7;
+
+ $numHdr = pack("d", $numHdr);
+ $numFtr = pack("d", $numFtr);
+
+ if ($this->_byte_order) {
+ $numHdr = strrev($numHdr);
+ $numFtr = strrev($numFtr);
+ }
+
+ $header = pack("vv", $record, $length);
+ $data1 = pack("vvvvvvvv", $iPaperSize,
+ $iScale,
+ $iPageStart,
+ $iFitWidth,
+ $iFitHeight,
+ $grbit,
+ $iRes,
+ $iVRes);
+ $data2 = $numHdr . $numFtr;
+ $data3 = pack("v", $iCopies);
+
+ $this->_prepend($header . $data1 . $data2 . $data3);
+ }
+
+ /*
+ * Store the header caption BIFF record.
+ */
+ function _store_header() {
+ $record = 0x0014; // Record identifier
+
+ $str = $this->_header; // header string
+ $cch = strlen($str); // Length of header string
+ $length = 1 + $cch; // Bytes to follow
+
+ $header = pack("vv", $record, $length);
+ $data = pack("C", $cch);
+
+ $this->_append($header . $data . $str);
+ }
+
+ /*
+ * Store the footer caption BIFF record.
+ */
+ function _store_footer() {
+ $record = 0x0015; // Record identifier
+
+ $str = $this->_footer; // Footer string
+ $cch = strlen($str); // Length of footer string
+ $length = 1 + $cch; // Bytes to follow
+
+ $header = pack("vv", $record, $length);
+ $data = pack("C", $cch);
+
+ $this->_append($header . $data . $str);
+ }
+
+ /*
+ * Store the horizontal centering HCENTER BIFF record.
+ */
+ function _store_hcenter() {
+ $record = 0x0083; // Record identifier
+ $length = 0x0002; // Bytes to follow
+
+ $fHCenter = $this->_hcenter; // Horizontal centering
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $fHCenter);
+
+ $this->_append($header . $data);
+ }
+
+ /*
+ * Store the vertical centering VCENTER BIFF record.
+ */
+ function _store_vcenter() {
+ $record = 0x0084; // Record identifier
+ $length = 0x0002; // Bytes to follow
+
+ $fVCenter = $this->_vcenter; // Horizontal centering
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $fVCenter);
+
+ $this->_append($header . $data);
+ }
+
+ /*
+ * Store the LEFTMARGIN BIFF record.
+ */
+ function _store_margin_left() {
+ $record = 0x0026; // Record identifier
+ $length = 0x0008; // Bytes to follow
+
+ $margin = $this->_margin_left; // Margin in inches
+
+ $header = pack("vv", $record, $length);
+ $data = pack("d", $margin);
+
+ if ($this->_byte_order) {
+ $data = strrev($data);
+ }
+
+ $this->_append($header . $data);
+ }
+
+ /*
+ * Store the RIGHTMARGIN BIFF record.
+ */
+ function _store_margin_right() {
+ $record = 0x0027; // Record identifier
+ $length = 0x0008; // Bytes to follow
+
+ $margin = $this->_margin_right; // Margin in inches
+
+ $header = pack("vv", $record, $length);
+ $data = pack("d", $margin);
+
+ if ($this->_byte_order) {
+ $data = strrev($data);
+ }
+
+ $this->_append($header . $data);
+ }
+
+ /*
+ * Store the TOPMARGIN BIFF record.
+ */
+ function _store_margin_top() {
+ $record = 0x0028; // Record identifier
+ $length = 0x0008; // Bytes to follow
+
+ $margin = $this->_margin_top; // Margin in inches
+
+ $header = pack("vv", $record, $length);
+ $data = pack("d", $margin);
+
+ if ($this->_byte_order) {
+ $data = strrev($data);
+ }
+
+ $this->_append($header . $data);
+ }
+
+ /*
+ * Store the BOTTOMMARGIN BIFF record.
+ */
+ function _store_margin_bottom() {
+ $record = 0x0029; // Record identifier
+ $length = 0x0008; // Bytes to follow
+
+ $margin = $this->_margin_bottom; // Margin in inches
+
+ $header = pack("vv", $record, $length);
+ $data = pack("d", $margin);
+
+ if ($this->_byte_order) {
+ $data = strrev($data);
+ }
+
+ $this->_append($header . $data);
+ }
+
+###############################################################################
+#
+# merge_cells($first_row, $first_col, $last_row, $last_col)
+#
+# This is an Excel97/2000 method. It is required to perform more complicated
+# merging than the normal align merge in Format.pm
+#
+function merge_cells() {
+
+ $_=func_get_args();
+
+ // Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ $record = 0x00E5; # Record identifier
+ $length = 0x000A; # Bytes to follow
+
+ $cref = 1; # Number of refs
+ $rwFirst = $_[0]; # First row in reference
+ $colFirst = $_[1]; # First col in reference
+ $rwLast = $_[2] || $rwFirst; # Last row in reference
+ $colLast = $_[3] || $colFirst; # Last col in reference
+
+ // Swap last row/col for first row/col as necessary
+ if ($rwFirst > $rwLast) {
+ list($rwFirst, $rwLast) = array($rwLast, $rwFirst);
+ }
+
+ if ($colFirst > $colLast) {
+ list($colFirst, $colLast) = array($colLast, $colFirst);
+ }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vvvvv", $cref,
+ $rwFirst, $rwLast,
+ $colFirst, $colLast);
+
+ $this->_append($header . $data);
+}
+
+ /*
+ * Write the PRINTHEADERS BIFF record.
+ */
+ function _store_print_headers() {
+ $record = 0x002a; // Record identifier
+ $length = 0x0002; // Bytes to follow
+
+ $fPrintRwCol = $this->_print_headers; // Boolean flag
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $fPrintRwCol);
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Write the PRINTGRIDLINES BIFF record. Must be used in conjunction
+ * with the GRIDSET record.
+ */
+ function _store_print_gridlines() {
+ $record = 0x002b; // Record identifier
+ $length = 0x0002; // Bytes to follow
+
+ $fPrintGrid = $this->_print_gridlines; // Boolean flag
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $fPrintGrid);
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Write the GRIDSET BIFF record. Must be used in conjunction with the
+ * PRINTGRIDLINES record.
+ */
+ function _store_gridset() {
+ $record = 0x0082; // Record identifier
+ $length = 0x0002; // Bytes to follow
+
+ $fGridSet = !$this->_print_gridlines; // Boolean flag
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $fGridSet);
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Write the WSBOOL BIFF record, mainly for fit-to-page. Used in
+ * conjunction with the SETUP record.
+ */
+ function _store_wsbool() {
+ $record = 0x0081; # Record identifier
+ $length = 0x0002; # Bytes to follow
+
+ // $grbit Option flags
+
+ // The only option that is of interest is the flag for fit to page.
+ // So we set all the options in one go.
+ if ($this->_fit_page) {
+ $grbit = 0x05c1;
+ } else {
+ $grbit = 0x04c1;
+ }
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $grbit);
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Write the HORIZONTALPAGEBREAKS BIFF record.
+ */
+ function _store_hbreak() {
+ // Return if the user hasn't specified pagebreaks
+ if(sizeof($this->_hbreaks)==0) {
+ return;
+ }
+
+ # Sort and filter array of page breaks
+ $breaks = $this->_sort_pagebreaks($this->_hbreaks);
+
+ $record = 0x001b; // Record identifier
+ $cbrk = sizeof($breaks); // Number of page breaks
+ $length = ($cbrk + 1) * 2; // Bytes to follow
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $cbrk);
+
+ // Append each page break
+ foreach ($breaks as $break) {
+ $data .= pack("v", $break);
+ }
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Write the VERTICALPAGEBREAKS BIFF record.
+ */
+ function _store_vbreak() {
+ // Return if the user hasn't specified pagebreaks
+ if(sizeof($this->_vbreaks)==0) {
+ return;
+ }
+
+ // Sort and filter array of page breaks
+ $breaks = $this->_sort_pagebreaks($this->_vbreaks);
+
+ $record = 0x001a; // Record identifier
+ $cbrk = sizeof($breaks); // Number of page breaks
+ $length = ($cbrk + 1) * 2; // Bytes to follow
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $cbrk);
+
+ // Append each page break
+ foreach ($breaks as $break) {
+ $data .= pack("v", $break);
+ }
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Set the Biff PROTECT record to indicate that the worksheet is
+ * protected.
+ */
+ function _store_protect() {
+ // Exit unless sheet protection has been specified
+ if (!$this->_protect) {
+ return;
+ }
+
+ $record = 0x0012; // Record identifier
+ $length = 0x0002; // Bytes to follow
+
+ $fLock = $this->_protect; // Worksheet is protected
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $fLock);
+
+ $this->_prepend($header . $data);
+ }
+
+ /*
+ * Write the worksheet PASSWORD record.
+ */
+ function _store_password() {
+ // Exit unless sheet protection and password have been specified
+ if (!$this->_protect || !$this->_password) {
+ return;
+ }
+
+ $record = 0x0013; // Record identifier
+ $length = 0x0002; // Bytes to follow
+
+ $wPassword = $this->_password; // Encoded password
+
+ $header = pack("vv", $record, $length);
+ $data = pack("v", $wPassword);
+
+ $this->_prepend($header . $data);
+ }
+
+###############################################################################
+#
+# insert_bitmap($row, $col, $filename, $x, $y, $scale_x, $scale_y)
+#
+# Insert a 24bit bitmap image in a worksheet. The main record required is
+# IMDATA but it must be proceeded by a OBJ record to define its position.
+#
+function insert_bitmap() {
+
+ $_=func_get_args();
+
+ # Check for a cell reference in A1 notation and substitute row and column
+ if (preg_match('/^\D/', $_[0])) {
+ $_ = $this->_substitute_cellref($_);
+ }
+
+ $row = $_[0];
+ $col = $_[1];
+ $bitmap = $_[2];
+ $x = $_[3] ? $_[3] : 0;
+ $y = $_[4] ? $_[4] : 0;
+ $scale_x = $_[5] ? $_[5] : 1;
+ $scale_y = $_[6] ? $_[6] : 1;
+
+ list($width, $height, $size, $data) = $this->_process_bitmap($bitmap);
+
+ # Scale the frame of the image.
+ $width *= $scale_x;
+ $height *= $scale_y;
+
+ # Calculate the vertices of the image and write the OBJ record
+ $this->_position_image($col, $row, $x, $y, $width, $height);
+
+ # Write the IMDATA record to store the bitmap data
+ $record = 0x007f;
+ $length = 8 + $size;
+ $cf = 0x09;
+ $env = 0x01;
+ $lcb = $size;
+
+ $header = pack("vvvvV", $record, $length, $cf, $env, $lcb);
+
+ $this->_append($header . $data);
+}
+
+ /*
+ * Calculate the vertices that define the position of the image as
+ * required by the OBJ record.
+ *
+ * +------------+------------+
+ * | A | B |
+ * +-----+------------+------------+
+ * | |(x1,y1) | |
+ * | 1 |(A1)._______|______ |
+ * | | | | |
+ * | | | | |
+ * +-----+----| BITMAP |-----+
+ * | | | | |
+ * | 2 | |______________. |
+ * | | | (B2)|
+ * | | | (x2,y2)|
+ * +---- +------------+------------+
+ *
+ * Example of a bitmap that covers some of the area from cell A1 to
+ * cell B2.
+ *
+ * Based on the width and height of the bitmap we need to calculate 8
+ *vars:
+ * $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2.
+ * The width and height of the cells are also variable and have to be
+ * taken into account.
+ * The values of $col_start and $row_start are passed in from the calling
+ * function. The values of $col_end and $row_end are calculated by
+ * subtracting the width and height of the bitmap from the width and
+ * height of the underlying cells.
+ * The vertices are expressed as a percentage of the underlying cell
+ * width as follows (rhs values are in pixels):
+ *
+ * x1 = X / W *1024
+ * y1 = Y / H *256
+ * x2 = (X-1) / W *1024
+ * y2 = (Y-1) / H *256
+ *
+ * Where: X is distance from the left side of the underlying cell
+ * Y is distance from the top of the underlying cell
+ * W is the width of the cell
+ * H is the height of the cell
+ *
+ * Note: the SDK incorrectly states that the height should be expressed
+ * as a percentage of 1024.
+ */
+ function _position_image($col_start, $row_start, $x1, $y1,
+ $width, $height) {
+ // $col_start Col containing upper left corner of object
+ // $x1 Distance to left side of object
+
+ // $row_start Row containing top left corner of object
+ // $y1 Distance to top of object
+
+ // $col_end Col containing lower right corner of object
+ // $x2 Distance to right side of object
+
+ // $row_end Row containing bottom right corner of object
+ // $y2 Distance to bottom of object
+
+ // $width Width of image frame
+ // $height Height of image frame
+
+ // Initialise end cell to the same as the start cell
+ $col_end = $col_start;
+ $row_end = $row_start;
+
+ // Zero the specified offset if greater than the cell dimensions
+ if ($x1 >= $this->_size_col($col_start)) {
+ $x1 = 0;
+ }
+ if ($y1 >= $this->_size_row($row_start)) {
+ $y1 = 0;
+ }
+
+ $width = $width + $x1 -1;
+ $height = $height + $y1 -1;
+
+ // Subtract the underlying cell widths to find the end cell of the
+ // image
+ while ($width >= $this->_size_col($col_end)) {
+ $width -= $this->_size_col($col_end);
+ $col_end++;
+ }
+
+ // Subtract the underlying cell heights to find the end cell of the
+ // image
+ while ($height >= $this->_size_row($row_end)) {
+ $height -= $this->_size_row($row_end);
+ $row_end++;
+ }
+
+ // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a
+ // cell with zero height or width.
+ if ($this->_size_col($col_start) == 0) { return; }
+ if ($this->_size_col($col_end) == 0) { return; }
+ if ($this->_size_row($row_start) == 0) { return; }
+ if ($this->_size_row($row_end) == 0) { return; }
+
+ // Convert the pixel values to the percentage value expected by Excel
+ $x1 = $x1 / $this->_size_col($col_start) * 1024;
+ $y1 = $y1 / $this->_size_row($row_start) * 256;
+ $x2 = $width / $this->_size_col($col_end) * 1024;
+ $y2 = $height / $this->_size_row($row_end) * 256;
+
+ $this->_store_obj_picture($col_start, $x1, $row_start, $y1,
+ $col_end, $x2, $row_end, $y2);
+ }
+
+ /*
+ * Convert the width of a cell from user's units to pixels. By
+ * interpolation the relationship is: y = 7x +5. If the width
+ * hasn't been set by the user we use the default value. If the
+ * col is hidden we use a value of zero.
+ */
+ function _size_col($col) {
+ // Look up the cell value to see if it has been changed
+ if (isset($this->_col_sizes[$col])) {
+ if ($this->_col_sizes[$col] == 0) {
+ return 0;
+ } else {
+ return floor(7 * $this->_col_sizes[$col] + 5);
+ }
+ } else {
+ return 64;
+ }
+ }
+
+ /*
+ * Convert the height of a cell from user's units to pixels. By
+ * interpolation # the relationship is: y = 4/3x. If the height
+ * hasn't been set by the user we use the default value. If the
+ * row is hidden we use a value of zero. (Not possible to hide row
+ * yet).
+ */
+ function _size_row($row) {
+ // Look up the cell value to see if it has been changed
+ if (isset($this->_row_sizes[$row])) {
+ if ($this->_row_sizes[$row] == 0) {
+ return 0;
+ } else {
+ return floor(4/3 * $this->_row_sizes[$row]);
+ }
+ } else {
+ return 17;
+ }
+ }
+
+ /*
+ * Store the OBJ record that precedes an IMDATA record. This could
+ * be generalized to support other Excel objects.
+ */
+ function _store_obj_picture($col_start, $x1, $row_start, $y1,
+ $col_end, $x2, $row_end, $y2) {
+ $record = 0x005d; // Record identifier
+ $length = 0x003c; // Bytes to follow
+
+ $cObj = 0x0001; // Count of objects in file (set to 1)
+ $OT = 0x0008; // Object type. 8 = Picture
+ $id = 0x0001; // Object ID
+ $grbit = 0x0614; // Option flags
+
+ $colL = $col_start; // Col containing upper left corner of
+ // object
+ $dxL = $x1; // Distance from left side of cell
+
+ $rwT = $row_start; // Row containing top left corner of
+ // object
+ $dyT = $y1; // Distance from top of cell
+
+ $colR = $col_end; // Col containing lower right corner of
+ // object
+ $dxR = $x2; // Distance from right of cell
+
+ $rwB = $row_end; // Row containing bottom right corner of
+ // object
+ $dyB = $y2; // Distance from bottom of cell
+
+ $cbMacro = 0x0000; // Length of FMLA structure
+ $Reserved1 = 0x0000; // Reserved
+ $Reserved2 = 0x0000; // Reserved
+
+ $icvBack = 0x09; // Background colour
+ $icvFore = 0x09; // Foreground colour
+ $fls = 0x00; // Fill pattern
+ $fAuto = 0x00; // Automatic fill
+ $icv = 0x08; // Line colour
+ $lns = 0xff; // Line style
+ $lnw = 0x01; // Line weight
+ $fAutoB = 0x00; // Automatic border
+ $frs = 0x0000; // Frame style
+ $cf = 0x0009; // Image format, 9 = bitmap
+ $Reserved3 = 0x0000; // Reserved
+ $cbPictFmla = 0x0000; // Length of FMLA structure
+ $Reserved4 = 0x0000; // Reserved
+ $grbit2 = 0x0001; // Option flags
+ $Reserved5 = 0x0000; // Reserved
+
+ $header = pack("vv", $record, $length);
+ $data = pack("V", $cObj);
+ $data .= pack("v", $OT);
+ $data .= pack("v", $id);
+ $data .= pack("v", $grbit);
+ $data .= pack("v", $colL);
+ $data .= pack("v", $dxL);
+ $data .= pack("v", $rwT);
+ $data .= pack("v", $dyT);
+ $data .= pack("v", $colR);
+ $data .= pack("v", $dxR);
+ $data .= pack("v", $rwB);
+ $data .= pack("v", $dyB);
+ $data .= pack("v", $cbMacro);
+ $data .= pack("V", $Reserved1);
+ $data .= pack("v", $Reserved2);
+ $data .= pack("C", $icvBack);
+ $data .= pack("C", $icvFore);
+ $data .= pack("C", $fls);
+ $data .= pack("C", $fAuto);
+ $data .= pack("C", $icv);
+ $data .= pack("C", $lns);
+ $data .= pack("C", $lnw);
+ $data .= pack("C", $fAutoB);
+ $data .= pack("v", $frs);
+ $data .= pack("V", $cf);
+ $data .= pack("v", $Reserved3);
+ $data .= pack("v", $cbPictFmla);
+ $data .= pack("v", $Reserved4);
+ $data .= pack("v", $grbit2);
+ $data .= pack("V", $Reserved5);
+
+ $this->_append($header . $data);
+ }
+
+ /*
+ * Convert a 24 bit bitmap into the modified internal format used by
+ * Windows. This is described in BITMAPCOREHEADER and BITMAPCOREINFO
+ * structures in the MSDN library.
+ */
+ function _process_bitmap($bitmap) {
+ // Open file and binmode the data in case the platform needs it.
+ $bmp=fopen($bitmap, "rb");
+ if (!$bmp) {
+ trigger_error("Could not open file '$bitmap'.", E_USER_ERROR);
+ }
+
+ $data=fread($bmp, filesize($bitmap));
+
+ // Check that the file is big enough to be a bitmap.
+ if (strlen($data) <= 0x36) {
+ trigger_error("$bitmap doesn't contain enough data.",
+ E_USER_ERROR);
+ }
+
+ // The first 2 bytes are used to identify the bitmap.
+ if (substr($data, 0, 2) != "BM") {
+ trigger_error("$bitmap doesn't appear to to be a ".
+ "valid bitmap image.", E_USER_ERROR);
+ }
+
+ // Remove bitmap data: ID.
+ $data = substr($data, 2);
+
+ // Read and remove the bitmap size. This is more reliable than reading
+ // the data size at offset 0x22.
+ $array = unpack("Vsize", $data);
+ $data = substr($data, 4);
+ $size = $array["size"];
+ $size -= 0x36; # Subtract size of bitmap header.
+ $size += 0x0C; # Add size of BIFF header.
+
+ // Remove bitmap data: reserved, offset, header length.
+ $data = substr($data, 12);
+
+ // Read and remove the bitmap width and height. Verify the sizes.
+ $array = unpack("Vwidth/Vheight", $data);
+ $data = substr($data, 8);
+ $width = $array["width"];
+ $height = $array["height"];
+
+ if ($width > 0xFFFF) {
+ trigger_error("$bitmap: largest image width supported is 64k.",
+ E_USER_ERROR);
+ }
+
+ if ($height > 0xFFFF) {
+ trigger_error("$bitmap: largest image height supported is 64k.",
+ E_USER_ERROR);
+ }
+
+ // Read and remove the bitmap planes and bpp data. Verify them.
+ $array = unpack("vplanes/vbitcount", $data);
+ $data = substr($data, 4);
+ $planes = $array["planes"];
+ $bitcount = $array["bitcount"];
+
+ if ($bitcount != 24) {
+ trigger_error("$bitmap isn't a 24bit true color bitmap.",
+ E_USER_ERROR);
+ }
+
+ if ($planes != 1) {
+ trigger_error("$bitmap: only 1 plane supported in bitmap image.",
+ E_USER_ERROR);
+ }
+
+ // Read and remove the bitmap compression. Verify compression.
+ $array = unpack("Vcompression", $data);
+ $data = substr($data, 4);
+ $compression = $array["compression"];
+
+ if ($compression != 0) {
+ trigger_error("$bitmap: compression not supported in bitmap image.",
+ E_USER_ERROR);
+ }
+
+ // Remove bitmap data: data size, hres, vres, colours, imp. colours.
+ $data = substr($data, 20);
+
+ // Add the BITMAPCOREHEADER data
+ $header = pack("Vvvvv", 0x000c, $width, $height, 0x01, 0x18);
+ $data = $header . $data;
+
+ return array($width, $height, $size, $data);
+ }
+
+ /*
+ * Store the window zoom factor. This should be a reduced fraction but for
+ * simplicity we will store all fractions with a numerator of 100.
+ */
+ function _store_zoom() {
+ // If scale is 100% we don't need to write a record
+ if ($this->_zoom == 100) {
+ return;
+ }
+
+ $record = 0x00A0; // Record identifier
+ $length = 0x0004; // Bytes to follow
+
+ $header = pack("vv", $record, $length);
+ $data = pack("vv", $this->_zoom, 100);
+
+ $this->_append($header . $data);
+ }
+
+}
+
+?>
diff --git a/gosa-core/include/utils/excel/functions.writeexcel_utility.inc.php b/gosa-core/include/utils/excel/functions.writeexcel_utility.inc.php
--- /dev/null
@@ -0,0 +1,271 @@
+<?php
+
+/*
+ * Copyleft 2002 Johann Hanne
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * This is the Spreadsheet::WriteExcel Perl package ported to PHP
+ * Spreadsheet::WriteExcel was written by John McNamara, jmcnamara@cpan.org
+ */
+
+/*
+ * Converts numeric $row/$col notation to an Excel cell reference string in
+ * A1 notation.
+ */
+function xl_rowcol_to_cell($row, $col, $row_abs=false, $col_abs=false) {
+
+ $row_abs = $row_abs ? '$' : '';
+ $col_abs = $col_abs ? '$' : '';
+
+ $int = floor($col / 26);
+ $frac = $col % 26;
+
+ $chr1 = ''; // Most significant character in AA1
+
+ if ($int > 0) {
+ $chr1 = chr(ord('A') + $int - 1);
+ }
+
+ $chr2 = chr(ord('A') + $frac);
+
+ // Zero index to 1-index
+ $row++;
+
+ return $col_abs.$chr1.$chr2.$row_abs.$row;
+}
+
+/*
+ * Converts an Excel cell reference string in A1 notation
+ * to numeric $row/$col notation.
+ *
+ * Returns: array($row, $col, $row_absolute, $col_absolute)
+ *
+ * The $row_absolute and $col_absolute parameters aren't documented because
+ * they are mainly used internally and aren't very useful to the user.
+ */
+function xl_cell_to_rowcol($cell) {
+
+ preg_match('/(\$?)([A-I]?[A-Z])(\$?)(\d+)/', $cell, $reg);
+
+ $col_abs = ($reg[1] == "") ? 0 : 1;
+ $col = $reg[2];
+ $row_abs = ($reg[3] == "") ? 0 : 1;
+ $row = $reg[4];
+
+ // Convert base26 column string to number
+ // All your Base are belong to us.
+ $chars = preg_split('//', $col, -1, PREG_SPLIT_NO_EMPTY);
+ $expn = 0;
+ $col = 0;
+
+ while (sizeof($chars)>0) {
+ $char = array_pop($chars); // Least significant character first
+ $col += (ord($char) - ord('A') + 1) * pow(26, $expn);
+ $expn++;
+ }
+
+ // Convert 1-index to zero-index
+ $row--;
+ $col--;
+
+ return array($row, $col, $row_abs, $col_abs);
+}
+
+/*
+ * Increments the row number of an Excel cell reference string
+ * in A1 notation.
+ * For example C4 to C5
+ *
+ * Returns: a cell reference string in A1 notation.
+ */
+function xl_inc_row($cell) {
+ list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
+ return xl_rowcol_to_cell(++$row, $col, $row_abs, $col_abs);
+}
+
+/*
+ * Decrements the row number of an Excel cell reference string
+ * in A1 notation.
+ * For example C4 to C3
+ *
+ * Returns: a cell reference string in A1 notation.
+ */
+function xl_dec_row($cell) {
+ list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
+ return xl_rowcol_to_cell(--$row, $col, $row_abs, $col_abs);
+}
+
+/*
+ * Increments the column number of an Excel cell reference string
+ * in A1 notation.
+ * For example C3 to D3
+ *
+ * Returns: a cell reference string in A1 notation.
+ */
+function xl_inc_col($cell) {
+ list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
+ return xl_rowcol_to_cell($row, ++$col, $row_abs, $col_abs);
+}
+
+/*
+ * Decrements the column number of an Excel cell reference string
+ * in A1 notation.
+ * For example C3 to B3
+ *
+ * Returns: a cell reference string in A1 notation.
+ */
+function xl_dec_col($cell) {
+ list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
+ return xl_rowcol_to_cell($row, --$col, $row_abs, $col_abs);
+}
+
+function xl_date_list($year, $month=1, $day=1,
+ $hour=0, $minute=0, $second=0) {
+
+ $monthdays=array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+
+ // Leap years since 1900 (year is dividable by 4)
+ $leapyears=floor(($year-1900)/4);
+
+ // Non-leap years since 1900 (year is dividable by 100)
+ $nonleapyears=floor(($year-1900)/100);
+
+ // Non-non-leap years since 1900 (year is dividable by 400)
+ // (Yes, it MUST be "1600", not "1900")
+ $nonnonleapyears=floor(($year-1600)/400);
+
+ // Don't count the leap day of the specified year if it didn't
+ // happen yet (i.e. before 1 March)
+ //
+ // Please note that $leapyears becomes -1 for dates before 1 March 1900;
+ // this is not logical, but later we will add a day for Excel's
+ // phantasie leap day in 1900 without checking if the date is actually
+ // after 28 February 1900; so these two logic errors "neutralize"
+ // each other
+ if ($year%4==0 && $month<3) {
+ $leapyears--;
+ }
+
+ $days=365*($year-1900)+$leapyears-$nonleapyears+$nonnonleapyears;
+
+ for ($c=1;$c<$month;$c++) {
+ $days+=$monthdays[$c-1];
+ }
+
+ // Excel actually wants the days since 31 December 1899, not since
+ // 1 January 1900; this will also add this extra day
+ $days+=$day;
+
+ // Excel treats 1900 erroneously as a leap year, so we must
+ // add one day
+ //
+ // Please note that we DON'T have to check if the date is after
+ // 28 February 1900, because for such dates $leapyears is -1
+ // (see above)
+ $days++;
+
+ return (float)($days+($hour*3600+$minute*60+$second)/86400);
+}
+
+function xl_parse_time($time) {
+
+ if (preg_match('/(\d{1,2}):(\d\d):?((?:\d\d)(?:\.\d+)?)?(?:\s+)?(am|pm)?/i', $time, $reg)) {
+
+ $hours = $reg[1];
+ $minutes = $reg[2];
+ $seconds = $reg[3] || 0;
+ $meridian = strtolower($reg[4]) || '';
+
+ // Normalise midnight and midday
+ if ($hours == 12 && $meridian != '') {
+ $hours = 0;
+ }
+
+ // Add 12 hours to the pm times. Note: 12.00 pm has been set to 0.00.
+ if ($meridian == 'pm') {
+ $hours += 12;
+ }
+
+ // Calculate the time as a fraction of 24 hours in seconds
+ return (float)(($hours*3600+$minutes*60+$seconds)/86400);
+
+ } else {
+ return false; // Not a valid time string
+ }
+}
+
+/*
+ * Automagically converts almost any date/time string to an Excel date.
+ * This function will always only be as good as strtotime() is.
+ */
+function xl_parse_date($date) {
+
+ $unixtime=strtotime($date);
+
+ $year=date("Y", $unixtime);
+ $month=date("m", $unixtime);
+ $day=date("d", $unixtime);
+ $hour=date("H", $unixtime);
+ $minute=date("i", $unixtime);
+ $second=date("s", $unixtime);
+
+ // Convert to Excel date
+ return xl_date_list($year, $month, $day, $hour, $minute, $second);
+}
+
+/*
+ * Dummy function to be "compatible" to Spreadsheet::WriteExcel
+ */
+function xl_parse_date_init() {
+ // Erm... do nothing...
+ // strtotime() doesn't require anything to be initialized
+ // (do not ask me how to set the timezone...)
+}
+
+/*
+ * xl_decode_date_EU() and xl_decode_date_US() are mapped
+ * to xl_parse_date(); there seems to be no PHP function that
+ * differentiates between EU and US dates; I've never seen
+ * somebody using dd/mm/yyyy anyway, it always should be one of:
+ * - yyyy-mm-dd (international)
+ * - dd.mm.yyyy (european)
+ * - mm/dd/yyyy (english/US/british?)
+*/
+
+function xl_decode_date_EU($date) {
+ return xl_parse_date($date);
+}
+
+function xl_decode_date_US($date) {
+ return xl_parse_date($date);
+}
+
+function xl_date_1904($exceldate) {
+
+ if ($exceldate < 1462) {
+ // date is before 1904
+ $exceldate = 0;
+ } else {
+ $exceldate -= 1462;
+ }
+
+ return $exceldate;
+}
+
+?>