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

Source for file Style.php

Documentation is available at Style.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_Style
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.0, 2009-08-10
  26.  */
  27.  
  28.  
  29. /** PHPExcel root directory */
  30. if (!defined('PHPEXCEL_ROOT')) {
  31.     /**
  32.      * @ignore
  33.      */
  34.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../');
  35. }
  36.  
  37. /** PHPExcel_Style_Color */
  38. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Color.php';
  39.  
  40. /** PHPExcel_Style_Font */
  41. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Font.php';
  42.  
  43. /** PHPExcel_Style_Fill */
  44. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Fill.php';
  45.  
  46. /** PHPExcel_Style_Borders */
  47. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Borders.php';
  48.  
  49. /** PHPExcel_Style_Alignment */
  50. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Alignment.php';
  51.  
  52. /** PHPExcel_Style_NumberFormat */
  53. require_once PHPEXCEL_ROOT 'PHPExcel/Style/NumberFormat.php';
  54.  
  55. /** PHPExcel_Style_Conditional */
  56. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Conditional.php';
  57.  
  58. /** PHPExcel_Style_Protection */
  59. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Protection.php';
  60.  
  61. /** PHPExcel_IComparable */
  62. require_once PHPEXCEL_ROOT 'PHPExcel/IComparable.php';
  63.  
  64. /**
  65.  * PHPExcel_Style
  66.  *
  67.  * @category   PHPExcel
  68.  * @package    PHPExcel_Style
  69.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  70.  */
  71. class PHPExcel_Style implements PHPExcel_IComparable
  72. {
  73.     /**
  74.      * Font
  75.      *
  76.      * @var PHPExcel_Style_Font 
  77.      */
  78.     private $_font;
  79.     
  80.     /**
  81.      * Fill
  82.      *
  83.      * @var PHPExcel_Style_Fill 
  84.      */
  85.     private $_fill;
  86.  
  87.     /**
  88.      * Borders
  89.      *
  90.      * @var PHPExcel_Style_Borders 
  91.      */
  92.     private $_borders;
  93.     
  94.     /**
  95.      * Alignment
  96.      *
  97.      * @var PHPExcel_Style_Alignment 
  98.      */
  99.     private $_alignment;
  100.     
  101.     /**
  102.      * Number Format
  103.      *
  104.      * @var PHPExcel_Style_NumberFormat 
  105.      */
  106.     private $_numberFormat;
  107.     
  108.     /**
  109.      * Conditional styles
  110.      *
  111.      * @var PHPExcel_Style_Conditional[] 
  112.      */
  113.     private $_conditionalStyles;
  114.     
  115.     /**
  116.      * Protection
  117.      *
  118.      * @var PHPExcel_Style_Protection 
  119.      */
  120.     private $_protection;
  121.  
  122.     /**
  123.      * Style supervisor?
  124.      *
  125.      * @var boolean 
  126.      */
  127.     private $_isSupervisor;
  128.  
  129.     /**
  130.      * Parent. Only used for style supervisor
  131.      *
  132.      * @var PHPExcel 
  133.      */
  134.     private $_parent;
  135.  
  136.     /**
  137.      * Index of style in collection. Only used for real style.
  138.      *
  139.      * @var int 
  140.      */
  141.     private $_index;
  142.  
  143.     /**
  144.      * Create a new PHPExcel_Style
  145.      *
  146.      * @param boolean $isSupervisor 
  147.      */
  148.     public function __construct($isSupervisor false)
  149.     {
  150.         // Supervisor?
  151.         $this->_isSupervisor = $isSupervisor;
  152.  
  153.         // Initialise values
  154.         $this->_conditionalStyles     = array();
  155.         $this->_font                = new PHPExcel_Style_Font($isSupervisor);
  156.         $this->_fill                = new PHPExcel_Style_Fill($isSupervisor);
  157.         $this->_borders                = new PHPExcel_Style_Borders($isSupervisor);
  158.         $this->_alignment            = new PHPExcel_Style_Alignment($isSupervisor);
  159.         $this->_numberFormat        = new PHPExcel_Style_NumberFormat($isSupervisor);
  160.         $this->_protection            = new PHPExcel_Style_Protection($isSupervisor);
  161.  
  162.         // bind parent if we are a supervisor
  163.         if ($isSupervisor{
  164.             $this->_font->bindParent($this);
  165.             $this->_fill->bindParent($this);
  166.             $this->_borders->bindParent($this);
  167.             $this->_alignment->bindParent($this);
  168.             $this->_numberFormat->bindParent($this);
  169.             $this->_protection->bindParent($this);
  170.         }
  171.     }
  172.  
  173.     /**
  174.      * Bind parent. Only used for supervisor
  175.      *
  176.      * @param PHPExcel $parent 
  177.      * @return PHPExcel_Style 
  178.      */
  179.     public function bindParent($parent)
  180.     {
  181.         $this->_parent = $parent;
  182.         return $this;
  183.     }
  184.     
  185.     /**
  186.      * Is this a supervisor or a real style component?
  187.      *
  188.      * @return boolean 
  189.      */
  190.     public function getIsSupervisor()
  191.     {
  192.         return $this->_isSupervisor;
  193.     }
  194.  
  195.     /**
  196.      * Get the shared style component for the currently active cell in currently active sheet.
  197.      * Only used for style supervisor
  198.      *
  199.      * @return PHPExcel_Style 
  200.      */
  201.     public function getSharedComponent()
  202.     {
  203.         $activeSheet $this->getActiveSheet();
  204.         $selectedCell $this->getXActiveCell()// e.g. 'A1'
  205.  
  206.         if ($activeSheet->cellExists($selectedCell)) {
  207.             $cell $activeSheet->getCell($selectedCell);
  208.             $xfIndex $cell->getXfIndex();
  209.         else {
  210.             $xfIndex 0;
  211.         }
  212.  
  213.         $activeStyle $this->_parent->getCellXfByIndex($xfIndex);
  214.         return $activeStyle;
  215.     }
  216.  
  217.     /**
  218.      * Get the currently active sheet. Only used for supervisor
  219.      *
  220.      * @return PHPExcel_Worksheet 
  221.      */
  222.     public function getActiveSheet()
  223.     {
  224.         return $this->_parent->getActiveSheet();
  225.     }
  226.  
  227.     /**
  228.      * Get the currently active cell coordinate in currently active sheet.
  229.      * Only used for supervisor
  230.      *
  231.      * @return string E.g. 'A1'
  232.      */
  233.     public function getXSelectedCells()
  234.     {
  235.         return $this->_parent->getActiveSheet()->getXSelectedCells();
  236.     }
  237.  
  238.     /**
  239.      * Get the currently active cell coordinate in currently active sheet.
  240.      * Only used for supervisor
  241.      *
  242.      * @return string E.g. 'A1'
  243.      */
  244.     public function getXActiveCell()
  245.     {
  246.         return $this->_parent->getActiveSheet()->getXActiveCell();
  247.     }
  248.  
  249.     /**
  250.      * Get parent. Only used for style supervisor
  251.      *
  252.      * @return PHPExcel 
  253.      */
  254.     public function getParent()
  255.     {
  256.         return $this->_parent;
  257.     }
  258.  
  259.     /**
  260.      * Apply styles from array
  261.      * 
  262.      * <code>
  263.      * $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray(
  264.      *         array(
  265.      *             'font'    => array(
  266.      *                 'name'      => 'Arial',
  267.      *                 'bold'      => true,
  268.      *                 'italic'    => false,
  269.      *                 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
  270.      *                 'strike'    => false,
  271.      *                 'color'     => array(
  272.      *                     'rgb' => '808080'
  273.      *                 )
  274.      *             ),
  275.      *             'borders' => array(
  276.      *                 'bottom'     => array(
  277.      *                     'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
  278.      *                     'color' => array(
  279.      *                         'rgb' => '808080'
  280.      *                     )
  281.      *                 ),
  282.      *                 'top'     => array(
  283.      *                     'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
  284.      *                     'color' => array(
  285.      *                         'rgb' => '808080'
  286.      *                     )
  287.      *                 )
  288.      *             )
  289.      *         )
  290.      * );
  291.      * </code>
  292.      * 
  293.      * @param    array    $pStyles    Array containing style information
  294.      * @param     boolean        $pAdvanced    Advanced mode for setting borders.
  295.      * @throws    Exception
  296.      * @return PHPExcel_Style 
  297.      */
  298.     public function applyFromArray($pStyles null$pAdvanced true{
  299.         if (is_array($pStyles)) {
  300.             if ($this->_isSupervisor{
  301.  
  302.                 $pRange $this->getXSelectedCells();
  303.  
  304.                 if (is_array($pStyles)) {
  305.                     // Uppercase coordinate
  306.                     $pRange strtoupper($pRange);
  307.  
  308.                     // Is it a cell range or a single cell?
  309.                     $rangeA     '';
  310.                     $rangeB     '';
  311.                     if (strpos($pRange':'=== false{
  312.                         $rangeA $pRange;
  313.                         $rangeB $pRange;
  314.                     else {
  315.                         list($rangeA$rangeBexplode(':'$pRange);
  316.                     }
  317.  
  318.                     // Calculate range outer borders
  319.                     $rangeStart PHPExcel_Cell::coordinateFromString($rangeA);
  320.                     $rangeEnd     PHPExcel_Cell::coordinateFromString($rangeB);
  321.  
  322.                     // Translate column into index
  323.                     $rangeStart[0]    PHPExcel_Cell::columnIndexFromString($rangeStart[0]1;
  324.                     $rangeEnd[0]    PHPExcel_Cell::columnIndexFromString($rangeEnd[0]1;
  325.  
  326.                     // Make sure we can loop upwards on rows and columns
  327.                     if ($rangeStart[0$rangeEnd[0&& $rangeStart[1$rangeEnd[1]{
  328.                         $tmp $rangeStart;
  329.                         $rangeStart $rangeEnd;
  330.                         $rangeEnd $tmp;
  331.                     }
  332.  
  333.                     // Advanced mode
  334.                     if ($pAdvanced && isset($pStyles['borders'])) {
  335.  
  336.                         // 'allborders' is a shorthand property for 'outline' and 'inside' and
  337.                         //        it applies to components that have not been set explicitly
  338.                         if (isset($pStyles['borders']['allborders'])) {
  339.                             foreach (array('outline''inside'as $component{
  340.                                 if (!isset($pStyles['borders'][$component])) {
  341.                                     $pStyles['borders'][$component$pStyles['borders']['allborders'];
  342.                                 }
  343.                             }
  344.                             unset($pStyles['borders']['allborders'])// not needed any more
  345.                         }
  346.  
  347.                         // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left'
  348.                         //        it applies to components that have not been set explicitly
  349.                         if (isset($pStyles['borders']['outline'])) {
  350.                             foreach (array('top''right''bottom''left'as $component{
  351.                                 if (!isset($pStyles['borders'][$component])) {
  352.                                     $pStyles['borders'][$component$pStyles['borders']['outline'];
  353.                                 }
  354.                             }
  355.                             unset($pStyles['borders']['outline'])// not needed any more
  356.                         }
  357.  
  358.                         // 'inside' is a shorthand property for 'vertical' and 'horizontal'
  359.                         //        it applies to components that have not been set explicitly
  360.                         if (isset($pStyles['borders']['inside'])) {
  361.                             foreach (array('vertical''horizontal'as $component{
  362.                                 if (!isset($pStyles['borders'][$component])) {
  363.                                     $pStyles['borders'][$component$pStyles['borders']['inside'];
  364.                                 }
  365.                             }
  366.                             unset($pStyles['borders']['inside'])// not needed any more
  367.                         }
  368.  
  369.                         // width and height characteristics of selection, 1, 2, or 3 (for 3 or more)
  370.                         $xMax min($rangeEnd[0$rangeStart[013);
  371.                         $yMax min($rangeEnd[1$rangeStart[113);
  372.  
  373.                         // loop through up to 3 x 3 = 9 regions
  374.                         for ($x 1$x <= $xMax++$x{
  375.                             // start column index for region
  376.                             $colStart ($x == 3
  377.                                 PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0])
  378.                                     : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0$x 1);
  379.  
  380.                             // end column index for region
  381.                             $colEnd ($x == 1?
  382.                                 PHPExcel_Cell::stringFromColumnIndex($rangeStart[0])
  383.                                     : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0$xMax $x);
  384.  
  385.                             for ($y 1$y <= $yMax++$y{
  386.  
  387.                                 // which edges are touching the region
  388.                                 $edges array();
  389.  
  390.                                 // are we at left edge
  391.                                 if ($x == 1{
  392.                                     $edges['left';
  393.                                 }
  394.  
  395.                                 // are we at right edge
  396.                                 if ($x == $xMax{
  397.                                     $edges['right';
  398.                                 }
  399.  
  400.                                 // are we at top edge?
  401.                                 if ($y == 1{
  402.                                     $edges['top';
  403.                                 }
  404.  
  405.                                 // are we at bottom edge?
  406.                                 if ($y == $yMax{
  407.                                     $edges['bottom';
  408.                                 }
  409.  
  410.                                 // start row index for region
  411.                                 $rowStart ($y == 3?
  412.                                     $rangeEnd[1$rangeStart[1$y 1;
  413.  
  414.                                 // end row index for region
  415.                                 $rowEnd ($y == 1?
  416.                                     $rangeStart[1$rangeEnd[1$yMax $y;
  417.  
  418.                                 // build range for region
  419.                                 $range $colStart $rowStart ':' $colEnd $rowEnd;
  420.                                 
  421.                                 // retrieve relevant style array for region
  422.                                 $regionStyles $pStyles;
  423.                                 unset($regionStyles['borders']['inside']);
  424.  
  425.                                 // what are the inner edges of the region when looking at the selection
  426.                                 $innerEdges array_diffarray('top''right''bottom''left')$edges );
  427.  
  428.                                 // inner edges that are not touching the region should take the 'inside' border properties if they have been set
  429.                                 foreach ($innerEdges as $innerEdge{
  430.                                     switch ($innerEdge{
  431.                                         case 'top':
  432.                                         case 'bottom':
  433.                                             // should pick up 'horizontal' border property if set
  434.                                             if (isset($pStyles['borders']['horizontal'])) {
  435.                                                 $regionStyles['borders'][$innerEdge$pStyles['borders']['horizontal'];
  436.                                             else {
  437.                                                 unset($regionStyles['borders'][$innerEdge]);
  438.                                             }
  439.                                             break;
  440.                                         case 'left':
  441.                                         case 'right':
  442.                                             // should pick up 'vertical' border property if set
  443.                                             if (isset($pStyles['borders']['vertical'])) {
  444.                                                 $regionStyles['borders'][$innerEdge$pStyles['borders']['vertical'];
  445.                                             else {
  446.                                                 unset($regionStyles['borders'][$innerEdge]);
  447.                                             }
  448.                                             break;
  449.                                     }
  450.                                 }
  451.  
  452.                                 // apply region style to region by calling applyFromArray() in simple mode
  453.                                 $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStylesfalse);
  454.                             }
  455.                         }
  456.                         return;
  457.                     }
  458.  
  459.                     // Simple mode
  460.                     
  461.                     // First loop through cells to find out which styles are affected by this operation
  462.                     $oldXfIndexes array();
  463.                     for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  464.                         for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  465.                             $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col$row)->getXfIndex()true;
  466.                         }
  467.                     }
  468.  
  469.                     // clone each of the affected styles, apply the style arrray, and add the new styles to the workbook
  470.                     $workbook $this->getActiveSheet()->getParent();
  471.                     foreach ($oldXfIndexes as $oldXfIndex => $dummy{
  472.                         $style $workbook->getCellXfByIndex($oldXfIndex);
  473.                         $newStyle clone $style;
  474.                         $newStyle->applyFromArray($pStyles);
  475.                         
  476.                         if ($existingStyle $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
  477.                             // there is already such cell Xf in our collection
  478.                             $newXfIndexes[$oldXfIndex$existingStyle->getIndex();
  479.                         else {
  480.                             // we don't have such a cell Xf, need to add
  481.                             $workbook->addCellXf($newStyle);
  482.                             $newXfIndexes[$oldXfIndex$newStyle->getIndex();
  483.                         }
  484.                     }
  485.                     
  486.                     // Loop through cells again and update the XF index
  487.                     for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  488.                         for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  489.                             $cell $this->getActiveSheet()->getCellByColumnAndRow($col$row);
  490.                             $oldXfIndex $cell->getXfIndex();
  491.                             $cell->setXfIndex($newXfIndexes[$oldXfIndex]);
  492.                         }
  493.                     }
  494.  
  495.                 else {
  496.                     throw new Exception("Invalid style array passed.");
  497.                 }
  498.                 
  499.             else {
  500.                 if (array_key_exists('fill'$pStyles)) {
  501.                     $this->getFill()->applyFromArray($pStyles['fill']);
  502.                 }
  503.                 if (array_key_exists('font'$pStyles)) {
  504.                     $this->getFont()->applyFromArray($pStyles['font']);
  505.                 }
  506.                 if (array_key_exists('borders'$pStyles)) {
  507.                     $this->getBorders()->applyFromArray($pStyles['borders']);
  508.                 }
  509.                 if (array_key_exists('alignment'$pStyles)) {
  510.                     $this->getAlignment()->applyFromArray($pStyles['alignment']);
  511.                 }
  512.                 if (array_key_exists('numberformat'$pStyles)) {
  513.                     $this->getNumberFormat()->applyFromArray($pStyles['numberformat']);
  514.                 }
  515.                 if (array_key_exists('protection'$pStyles)) {
  516.                     $this->getProtection()->applyFromArray($pStyles['protection']);
  517.                 }
  518.             }
  519.         else {
  520.             throw new Exception("Invalid style array passed.");
  521.         }
  522.         return $this;
  523.     }
  524.  
  525.     /**
  526.      * Get Fill
  527.      *
  528.      * @return PHPExcel_Style_Fill 
  529.      */
  530.     public function getFill({
  531.         return $this->_fill;
  532.     }
  533.     
  534.     /**
  535.      * Get Font
  536.      *
  537.      * @return PHPExcel_Style_Font 
  538.      */
  539.     public function getFont({
  540.         return $this->_font;
  541.     }
  542.  
  543.     /**
  544.      * Set font
  545.      *
  546.      * @param PHPExcel_Style_Font $font 
  547.      * @return PHPExcel_Style 
  548.      */
  549.     public function setFont(PHPExcel_Style_Font $font)
  550.     {
  551.         $this->_font = $font;
  552.         return $this;
  553.     }
  554.  
  555.     /**
  556.      * Get Borders
  557.      *
  558.      * @return PHPExcel_Style_Borders 
  559.      */
  560.     public function getBorders({
  561.         return $this->_borders;
  562.     }
  563.     
  564.     /**
  565.      * Get Alignment
  566.      *
  567.      * @return PHPExcel_Style_Alignment 
  568.      */
  569.     public function getAlignment({
  570.         return $this->_alignment;
  571.     }
  572.     
  573.     /**
  574.      * Get Number Format
  575.      *
  576.      * @return PHPExcel_Style_NumberFormat 
  577.      */
  578.     public function getNumberFormat({
  579.         return $this->_numberFormat;
  580.     }
  581.     
  582.     /**
  583.      * Get Conditional Styles. Only used on supervisor.
  584.      *
  585.      * @return PHPExcel_Style_Conditional[] 
  586.      */
  587.     public function getConditionalStyles({
  588.         return $this->getActiveSheet()->getConditionalStyles($this->getXActiveCell());
  589.     }
  590.        
  591.     /**
  592.      * Set Conditional Styles. Only used on supervisor.
  593.      *
  594.      * @param PHPExcel_Style_Conditional[]    $pValue    Array of condtional styles
  595.      * @return PHPExcel_Style 
  596.      */
  597.     public function setConditionalStyles($pValue null{
  598.         if (is_array($pValue)) {
  599.             foreach (PHPExcel_Cell::extractAllCellReferencesInRange($this->getXSelectedCells()) as $cellReference{
  600.                 $this->getActiveSheet()->setConditionalStyles($cellReference$pValue);
  601.             }
  602.         }
  603.         return $this;
  604.     }
  605.     
  606.     /**
  607.      * Get Protection
  608.      *
  609.      * @return PHPExcel_Style_Protection 
  610.      */
  611.     public function getProtection({
  612.         return $this->_protection;
  613.     }
  614.    
  615.     /**
  616.      * Get hash code
  617.      *
  618.      * @return string    Hash code
  619.      */    
  620.     public function getHashCode({
  621.         $hashConditionals '';
  622.         foreach ($this->_conditionalStyles as $conditional{
  623.             $hashConditionals .= $conditional->getHashCode();
  624.         }
  625.         
  626.         return md5(
  627.               $this->getFill()->getHashCode()
  628.             . $this->getFont()->getHashCode()
  629.             . $this->getBorders()->getHashCode()
  630.             . $this->getAlignment()->getHashCode()
  631.             . $this->getNumberFormat()->getHashCode()
  632.             . $hashConditionals
  633.             . $this->getProtection()->getHashCode()
  634.             . __CLASS__
  635.         );
  636.     }
  637.     
  638.     /**
  639.      * Hash index
  640.      *
  641.      * @var string 
  642.      */
  643.     private $_hashIndex;
  644.     
  645.     /**
  646.      * Get hash index
  647.      * 
  648.      * Note that this index may vary during script execution! Only reliable moment is
  649.      * while doing a write of a workbook and when changes are not allowed.
  650.      *
  651.      * @return string    Hash index
  652.      */
  653.     public function getHashIndex({
  654.         return $this->_hashIndex;
  655.     }
  656.     
  657.     /**
  658.      * Set hash index
  659.      * 
  660.      * Note that this index may vary during script execution! Only reliable moment is
  661.      * while doing a write of a workbook and when changes are not allowed.
  662.      *
  663.      * @param string    $value    Hash index
  664.      */
  665.     public function setHashIndex($value{
  666.         $this->_hashIndex = $value;
  667.     }
  668.  
  669.     /**
  670.      * Get own index in style collection
  671.      *
  672.      * @return int 
  673.      */
  674.     public function getIndex()
  675.     {
  676.         return $this->_index;
  677.     }
  678.  
  679.     /**
  680.      * Set own index in style collection
  681.      *
  682.      * @param int $pValue 
  683.      */
  684.     public function setIndex($pValue)
  685.     {
  686.         $this->_index = $pValue;
  687.     }
  688.  
  689.     /**
  690.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  691.      */
  692.     public function __clone({
  693.         $vars get_object_vars($this);
  694.         foreach ($vars as $key => $value{
  695.             if (is_object($value)) {
  696.                 $this->$key clone $value;
  697.             else {
  698.                 $this->$key $value;
  699.             }
  700.         }
  701.     }
  702. }

Documentation generated on Mon, 10 Aug 2009 08:08:08 +0200 by phpDocumentor 1.4.1