From: <rob...@us...> - 2010-10-30 00:07:38
|
Revision: 30419 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=30419&view=rev Author: robertplummer Date: 2010-10-30 00:07:28 +0000 (Sat, 30 Oct 2010) Log Message: ----------- [ADD] Added the profile handler for sheets. Still doesn't handle formulas, we'll call it an alpha. But it works! Modified Paths: -------------- branches/6.x/lib/profilelib/installlib.php Modified: branches/6.x/lib/profilelib/installlib.php =================================================================== --- branches/6.x/lib/profilelib/installlib.php 2010-10-29 21:50:14 UTC (rev 30418) +++ branches/6.x/lib/profilelib/installlib.php 2010-10-30 00:07:28 UTC (rev 30419) @@ -40,6 +40,7 @@ 'extwiki' => 'Tiki_Profile_InstallHandler_ExtWiki', 'webmail_account' => 'Tiki_Profile_InstallHandler_WebmailAccount', 'webmail' => 'Tiki_Profile_InstallHandler_Webmail', + 'sheet' => 'Tiki_Profile_InstallHandler_Sheet', ); private static $typeMap = array( @@ -2685,3 +2686,79 @@ } } } // }}} + +class Tiki_Profile_InstallHandler_Sheet extends Tiki_Profile_InstallHandler // {{{ +{ + function getData() + { + if( $this->data ) + return $this->data; + $data = $this->obj->getData(); + $this->replaceReferences($data); + + return $this->data = $data; + } + + function canInstall() + { + $data = $this->getData(); + + if (isset($data)) return true; + else return false; + } + + function _install() + { + if ($this->canInstall()) + { + global $user; + require_once ('lib/sheet/grid.php'); + + //here we convert the array to that of what is acceptable to the sheet lib + $parentSheetId; + $sheets = array(); + + for ($sheetI = 0; $sheetI < count($this->data); $sheetI++) + { + for ($r = 0; $r < count($this->data[$sheetI]); $r++) + { + for ($c = 0; $c < count($this->data[$sheetI][$r]); $c++) + { + $value; + $formula; + $rawValue = $this->data[$sheetI][$r][$c]; + + if (substr($rawValue, 0, 1) == "=") { + $formula = $rawValue; + } else { + $value = $rawValue; + } + + $ri = 'r'.$r; + $ci = 'c'.$c; + + $sheets[$sheetI]->data->$ri->$ci->formula = $formula; + $sheets[$sheetI]->data->$ri->$ci->value = $value; + + $sheets[$sheetI]->data->$ri->$ci->width = 1; + $sheets[$sheetI]->data->$ri->$ci->height = 1; + } + } + + $sheets[$sheetI]->metadata->rows = (count($this->data[$sheetI]) - 1); + $sheets[$sheetI]->metadata->columns = (count($this->data[$sheetI][0]) - 1); + + $id = $sheetlib->replace_sheet(0, "Profile Test", "", $user, $parentSheetId); + $parentSheetId = ($parentSheetId ? $parentSheetId : $id); + + $grid = new TikiSheet($id); + $handler = new TikiSheetHTMLTableHandler($sheets[$sheetI]); + $res = $grid->import($handler); + $handler = new TikiSheetDatabaseHandler($id); + $grid->export($handler); + } + + return $parentSheetId; + } + } +} // }}} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |