Exemplo n.º 1
0
 /**
  * @access 	protected
  * @param 	string			$type				
  * @param 	string			$element			
  * @param 	string			$str				
  * @param 	object			$parent				
  * @return 	object								s
  */
 protected function _addElement($type, $element, $str = null, $parent = null)
 {
     try {
         if ($str) {
             $new = $this->core->createElementNS($this->nameSpaces[$type], $type . ':' . $element, Fonction::checkString($str));
         } else {
             $new = $this->core->createElementNS($this->nameSpaces[$type], $type . ':' . $element);
         }
         if (!$parent) {
             $this->root->appendChild($new);
         } else {
             $parent->appendChild($new);
         }
         return $new;
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 2
0
 public static function scanRecursiveDir($dir)
 {
     $files = scandir($dir);
     $allFiles = array();
     foreach ($files as $file) {
         if ($file != '.' && $file != '..') {
             if (is_dir($dir . $file)) {
                 $allFiles = array_merge($allFiles, Fonction::scanRecursiveDir($dir . $file));
             } else {
                 $allFiles[] = str_replace('//', '/', $dir . '/' . $file);
             }
         }
     }
     return $allFiles;
 }
Exemplo n.º 3
0
 /**
  * Ajoute un meta utilisateur particulier
  *
  * @access 	public
  * @param 	string			$attr					L'attribut du meta
  * @param 	string			$str					Le contenu du meta
  * @return 	void
  */
 public function addUserDefined($attr, $str)
 {
     $new = $this->_addMetaElement('user-defined', $str);
     $new->setAttribute('meta:name', Fonction::checkAttribute($attr));
 }
 /**
  * @access 	public
  * @param 	boolean			$in_file		
  * @return 	object|boolean							
  */
 public function save($in_file = true, $report_title = '', $keyword = '', $owner = '', $report_id_in = '', $print_ok = '')
 {
     $this->_saveFile();
     $zip = new EasyZIP();
     if ($handle = opendir($this->pathSave)) {
         while (false !== ($filename = readdir($handle))) {
             if ($filename != '.' && $filename != '..') {
                 if (is_dir($this->pathSave . '/' . $filename)) {
                     $zip->addDir($this->pathSave, $filename);
                 } else {
                     $zip->addFile($filename, $this->pathSave . '/');
                 }
             }
         }
         closedir($handle);
     }
     $fileName = $in_file ? $this->documentName : '';
     $result = $zip->zipFile($fileName, $report_title, $keyword, $owner, $report_id_in, $print_ok);
     Fonction::delDir($this->pathSave);
     return $result;
 }
Exemplo n.º 5
0
 /**
  * @access 	public
  * @param 	string			$media_type	
  * @param 	string			$full_path			
  * @return 	void
  */
 public function addFileEntry($media_type, $full_path)
 {
     $new = $this->_addManifestElement('file-entry');
     $new->setAttribute('manifest:media-type', Fonction::checkAttribute($media_type));
     $new->setAttribute('manifest:full-path', Fonction::checkAttribute($full_path));
 }
Exemplo n.º 6
0
 /**
  * Fonction qui set comme contenu de cellule une somme (par exemple A1:B6;C10)
  *
  * @access 	public
  * @param 	string			$formula				La formule (par exemple 'A1:B6;C10')
  * @return 	void
  */
 public function setFormulaSUM($formula)
 {
     $f = strpos($formula, '=SUM(') === false ? '=SUM(' . $formula . ')' : $formula;
     // On sauve la formule
     $f = str_replace('(', '([.', $f);
     $f = str_replace(')', '])', $f);
     $f = str_replace(';', '];[.', $f);
     $f = str_replace(':', ':.', $f);
     // On en extrait les donn�s
     $formula = ltrim($formula, '=SUM(');
     $formula = rtrim($formula, ')');
     $l = Fonction::getLetters(true);
     $somme = 0;
     $blocs = explode(';', $formula);
     $cellules = $this->parent->getCells();
     foreach ($blocs as $bloc) {
         $cells = explode(':', $bloc);
         $tab = array();
         foreach ($cells as $cell) {
             $cols = '';
             $row = '';
             for ($i = 0; $i < strlen($cell); $i++) {
                 if (is_int($cell[$i]) || is_float($cell[$i]) || is_numeric($cell[$i])) {
                     $row .= $cell[$i];
                 } else {
                     $cols .= $cell[$i];
                 }
             }
             $col = array_search(strtolower($cols), $l);
             $tab[] = $cellules[$row][$col];
         }
         if (count($tab) == 1) {
             $somme += $tab[0]->getContent() * 1;
         } else {
             $cells = $this->parent->getRangeCells($tab[0], $tab[1], '_setSum', '', $somme);
         }
     }
     $this->formula = $f;
     $this->contenu = $somme;
     $this->type = 'float';
     return $this->type;
 }
Exemplo n.º 7
0
 /**
  * @access 	public
  * @param 	integer			$col				
  * @return 	string					
  */
 public function getColumnName($col)
 {
     $lettres = Fonction::getLetters(true);
     if (isset($lettres[$col])) {
         return $lettres[$col];
     } else {
         return 0;
     }
 }
Exemplo n.º 8
0
 /**
  * @access 	public
  * @return 	TableCell		$style			
  */
 public function getCellAddress()
 {
     $cell = $this->cellAddress;
     $l = Fonction::getLetters(true);
     return $this->sheetAddress . '.' . $l[$cell->getX()] . $cell->getY();
 }
Exemplo n.º 9
0
 /**
  * @access 	protected
  * @return 	boolean							
  */
 protected function _beforeSave()
 {
     $styles = array('col' => array(), 'colused' => array(), 'row' => array(), 'rowused' => array(), 'cel' => array(), 'celused' => array(), 'gra' => array(), 'graused' => array(), 'leg' => array(), 'legused' => array(), 'tab' => array(), 'tabused' => array(), 'num' => array(), 'numused' => array());
     $sheetsCols = array();
     $fonts = array();
     $maxCol = 0;
     $colDef = 'co1';
     foreach ($this->sheets as $key => $sheet) {
         $cells = $sheet->getCells();
         $cols = array();
         foreach ($cells as $row => $obj) {
             foreach ($obj as $col => $cell) {
                 $used = $this->_getUsedCellStyles($cell, $styles);
                 $cell->setStyleName($used);
                 $fonts[] = $cell->getFontFamily();
                 if (!isset($cols[$col]) || $cols[$col] == '' || $used['col'] != $colDef) {
                     $cols[$col] = $used['col'];
                 }
             }
         }
         if ($maxCol < $sheet->getNbColsMax()) {
             $maxCol = $sheet->getNbColsMax();
         }
         $sheetsCols[$key] = Fonction::array_count_followed_values($cols, $colDef, $maxCol);
         foreach ($sheet->getPictures() as $pict) {
             $used = $this->_getUsedGraphStyles($pict, $styles);
             $pict->setStyle = $used['gra'];
             $pict->setTextStyle = $used['text'];
         }
     }
     $this->_insertFontFamilies($fonts);
     $this->_insertStyles($styles);
     foreach ($this->sheets as $key => $sheet) {
         $cells = $sheet->getCells();
         foreach ($sheetsCols[$key] as $col) {
             $tbCol = $this->_addTableElement('table-column', null, $sheet->getXML());
             $tbCol->setAttribute('table:style-name', $col['value']);
             if ($col['nb'] > 1) {
                 $tbCol->setAttribute('table:number-columns-repeated', $col['nb']);
             }
         }
         $rowCourant = 0;
         ksort($cells);
         foreach ($cells as $row => $obj) {
             ksort($obj);
             $cell = current($obj);
             $st = $cell->getStyleName();
             if ($rowCourant < $row - 1) {
                 $tbRow = $this->_addTableElement('table-row', null, $sheet->getXML());
                 $tbRow->setAttribute('table:number-rows-repeated', $row - $rowCourant - 1);
                 $tbCell = $this->_addTableElement('table-cell', null, $tbRow);
                 $tbCell->setAttribute('table:style-name', 'ce1');
             }
             $tbRow = $this->_addTableElement('table-row', null, $sheet->getXML());
             $tbRow->setAttribute('table:style-name', $st['row']);
             $colCourant = 0;
             foreach ($obj as $col => $cell) {
                 $st = $cell->getStyleName();
                 if ($colCourant < $col - 1) {
                     $tbCell = $this->_addTableElement('table-cell', null, $tbRow);
                     $tbCell->setAttribute('table:number-columns-repeated', $col - $colCourant - 1);
                 }
                 $tbCell = $this->_addTableElement('table-cell', null, $tbRow);
                 $tbCell->setAttribute('table:style-name', $st['cel']);
                 if ($cell->getFormula() != '') {
                     $tbCell->setAttribute('table:formula', 'oooc:' . $cell->getFormula());
                 }
                 if ($cell->getSpannedRows() > 1) {
                     $tbCell->setAttribute('table:number-rows-spanned', $cell->getSpannedRows());
                 }
                 if ($cell->getSpannedCols() > 1) {
                     $tbCell->setAttribute('table:number-columns-spanned', $cell->getSpannedCols());
                 }
                 if ($cell->getType() == 'float') {
                     $tbCell->setAttribute('office:value-type', $cell->getType());
                     $tbCell->setAttribute('office:value', $cell->getContent());
                 }
                 if ($cell->getContent() != '') {
                     $content = $this->_addTextElement('p', $cell->getContent(), $tbCell);
                 }
                 $colCourant = $col;
             }
             $rowCourant = $row;
         }
         foreach ($sheet->getPictures() as $pict) {
             //copy($pict->getPathName(), $this->pathSave.'/Pictures/'.$pict->getName());
             copy($pict->getPathName(), $this->pathSave . '/Pictures/' . $pict->getName());
             //copy('/home/sanjeewa/public_html/sahana-phase2/mod/rs/S4010230.JPG', $this->pathSave.'/Pictures/'.$pict->getName());
             $this->parent->manifest->addFileEntry($pict->getType(), 'Pictures/' . $pict->getName());
             $tbFrame = $this->_addDrawElement('frame', null, $tbCell);
             $tbFrame->setAttribute('table:end-cell-address', Fonction::checkAttribute($pict->getCellAddress()));
             $tbFrame->setAttribute('table:end-x', $pict->getXEnd());
             $tbFrame->setAttribute('table:end-y', $pict->getYEnd());
             $tbFrame->setAttribute('draw:z-index', $pict->getZIndex());
             $tbFrame->setAttribute('draw:name', Fonction::checkAttribute($pict->getName()));
             $tbFrame->setAttribute('draw:style-name', $pict->getStyle());
             $tbFrame->setAttribute('draw:text-style-name', $pict->getTextStyle());
             $tbFrame->setAttribute('svg:width', $pict->getWidth());
             $tbFrame->setAttribute('svg:height', $pict->getHeight());
             $tbFrame->setAttribute('svg:x', $pict->getSVGX());
             $tbFrame->setAttribute('svg:y', $pict->getSVGY());
             $tbImage = $this->_addDrawElement('image', null, $tbFrame);
             $tbImage->setAttribute('xlink:href', $pict->getPath() . '/' . $pict->getName());
             //Fonction::checkAttribute($pict->getPath())
             $tbImage->setAttribute('xlink:type', $pict->getType());
             $tbImage->setAttribute('xlink:show', $pict->getShow());
             $tbImage->setAttribute('xlink:actuate', $pict->getActuate());
         }
     }
     return true;
 }