コード例 #1
0
ファイル: Sheet.php プロジェクト: rjsmelo/tiki
 function _install()
 {
     if ($this->canInstall()) {
         global $user;
         $sheetlib = TikiLib::lib('sheet');
         require_once 'lib/sheet/grid.php';
         //here we convert the array to that of what is acceptable to the sheet lib
         $parentSheetId = 0;
         $sheets = array();
         $nbsheets = count($this->data);
         for ($sheetI = 0; $sheetI < $nbsheets; $sheetI++) {
             $sheets[$sheetI] = new stdClass();
             $sheets[$sheetI]->rows = array();
             $sheets[$sheetI]->metadata = new stdClass();
             $sheets[$sheetI]->metadata->widths = array();
             $title = $this->data[$sheetI]['title'];
             $title = $title ? $title : "Untitled - From Profile Import";
             $nbdatasheetI = count($this->data[$sheetI]);
             if (in_array('title', array_keys($this->data[$sheetI]))) {
                 $nbdatasheetI--;
                 // do not take the title into account on the number of rows
             }
             for ($r = 0; $r < $nbdatasheetI; $r++) {
                 $nbdatasheetIr = count($this->data[$sheetI][$r]);
                 $sheets[$sheetI]->rows[$r]->columns = array();
                 for ($c = 0; $c < $nbdatasheetIr; $c++) {
                     $sheets[$sheetI]->rows[$r]->columns[$c] = new stdClass();
                     $value = "";
                     $formula = "";
                     $rawValue = $this->data[$sheetI][$r][$c];
                     if (substr($rawValue, 0, 1) == "=") {
                         $formula = $rawValue;
                     } else {
                         $value = $rawValue;
                     }
                     $sheets[$sheetI]->rows[$r]->columns[$c]->formula = $formula;
                     $sheets[$sheetI]->rows[$r]->columns[$c]->value = $value;
                     $sheets[$sheetI]->rows[$r]->columns[$c]->width = 1;
                     $sheets[$sheetI]->rows[$r]->columns[$c]->height = 1;
                 }
             }
             $sheets[$sheetI]->metadata->widths[] = $nbdatasheetIr;
             $sheets[$sheetI]->metadata->rows = $nbdatasheetI;
             $sheets[$sheetI]->metadata->columns = count($this->data[$sheetI][0]);
             $id = $sheetlib->replace_sheet(0, $title, "", $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;
     }
 }
コード例 #2
0
ファイル: SheetSource.php プロジェクト: jkimdon/cohomeals
 function getDocument($objectId, Search_Type_Factory_Interface $typeFactory)
 {
     $sheetlib = TikiLib::lib('sheet');
     $info = $sheetlib->get_sheet_info($objectId);
     $values = $this->db->table('tiki_sheet_values');
     $contributors = $values->fetchColumn($values->expr('DISTINCT `user`'), array('sheetId' => $objectId));
     $lastModif = $values->fetchOne($values->max('begin'), array('sheetId' => $objectId));
     $loader = new TikiSheetDatabaseHandler($objectId);
     $writer = new TikiSheetCSVHandler('php://output');
     $grid = new TikiSheet();
     $grid->import($loader);
     $grid->export($writer);
     $text = $writer->output;
     $data = array('title' => $typeFactory->sortable($info['title']), 'description' => $typeFactory->sortable($info['description']), 'modification_date' => $typeFactory->timestamp($lastModif), 'contributors' => $typeFactory->multivalue($contributors), 'sheet_content' => $typeFactory->plaintext($text), 'view_permission' => $typeFactory->identifier('tiki_p_view_sheet'));
     return $data;
 }
コード例 #3
0
ファイル: Sheet.php プロジェクト: jkimdon/cohomeals
 function _install()
 {
     if ($this->canInstall()) {
         global $user, $sheetlib;
         require_once 'lib/sheet/grid.php';
         //here we convert the array to that of what is acceptable to the sheet lib
         $parentSheetId = null;
         $sheets = array();
         $nbsheets = count($this->data);
         for ($sheetI = 0; $sheetI < $nbsheets; $sheetI++) {
             $title = $this->data[$sheetI]['title'];
             $title = $title ? $title : "Untitled - From Profile Import";
             $nbdatasheetI = count($this->data[$sheetI]);
             for ($r = 0; $r < $nbdatasheetI; $r++) {
                 $nbdatasheetIr = count($this->data[$sheetI][$r]);
                 for ($c = 0; $c < $nbdatasheetIr; $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]);
             $sheets[$sheetI]->metadata->columns = count($this->data[$sheetI][0]);
             $id = $sheetlib->replace_sheet(0, $title, "", $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;
     }
 }
コード例 #4
0
ファイル: tiki-graph_sheet.php プロジェクト: linuxwhy/tiki-1
     if ($s == 'y0') {
         $series[] = 'y0';
         $series[] = 'y1';
         $series[] = 'y2';
         $series[] = 'y3';
         $series[] = 'y4';
     } else {
         $series[] = $s;
     }
 }
 $smarty->assign('mode', 'param');
 $smarty->assign('series', $series);
 $smarty->assign('graph', $graph);
 $smarty->assign('renderer', $_GET['renderer']);
 $handler = new TikiSheetDatabaseHandler($sheetId);
 $grid = new TikiSheet($_REQUEST['sheetId']);
 $grid->import($handler);
 $dataGrid = $grid->getTableHtml(true);
 require_once 'lib/sheet/grid.php';
 $sheetlib->setup_jquery_sheet();
 $headerlib->add_jq_onready('$("div.tiki_sheet").sheet($.extend($.sheet.tikiOptions, {editable: false}));');
 $smarty->assign('dataGrid', $dataGrid);
 if (function_exists('pdf_new')) {
     $smarty->assign('format', $_GET['format']);
     $smarty->assign('orientation', $_GET['orientation']);
 }
 if (function_exists('imagepng')) {
     $smarty->assign('im_width', $_GET['width']);
     $smarty->assign('im_height', $_GET['height']);
 }
 if (is_a($g, 'GridBasedGraphic')) {
コード例 #5
0
ファイル: grid.php プロジェクト: linuxwhy/tiki-1
 function _load(TikiSheet &$sheet)
 {
     $d = $this->data;
     foreach ($d->metadata->widths as $c => $width) {
     }
     foreach ($d->rows as $r => $row) {
         foreach ($row->columns as $c => $column) {
             $sheet->initCell($r, $c);
             //if cell has formula, use it, otherwise, use value, if value if blank, use ''
             if (!empty($column->formula)) {
                 $sheet->setCalculation($column->formula);
             } else {
                 $sheet->setValue(isset($column->value) ? $column->value : '');
             }
             //Make cell able to span multi columns and rows
             $rowSpan = 1;
             $colSpan = 1;
             if (isset($column->rowspan)) {
                 $rowSpan = $column->rowspan;
             }
             if (isset($column->colspan)) {
                 $colSpan = $column->colspan;
             }
             $sheet->setRowSpan($rowSpan);
             $sheet->setColSpan($colSpan);
             $sheet->setDeadCells();
             //setup cell css style
             if (!empty($column->style)) {
                 $sheet->setStyle($column->style);
             }
             //setup cell html class
             if (isset($column->class)) {
                 $sheet->setClass($column->class);
             }
         }
     }
     return true;
 }
コード例 #6
0
ファイル: Builder.php プロジェクト: linuxwhy/tiki-1
 function outputSheet($name = "")
 {
     $sheetlib = TikiLib::lib("sheet");
     if (empty($name)) {
         $name = $this->type;
     }
     $handler = new TikiSheetSimpleArrayHandler(array("values" => $this->outputArray(), "name" => $name));
     $grid = new TikiSheet();
     $grid->import($handler);
     return $grid->getTableHtml();
 }
コード例 #7
0
ファイル: tiki-import_sheet.php プロジェクト: rjsmelo/tiki
    $smarty->assign('Incorrect parameter');
    $smarty->display('error.tpl');
    die;
}
$objectperms = Perms::get('sheet', $_REQUEST['sheetId']);
if ($tiki_p_admin != 'y' && !$objectperms->view_sheet && !($user && $info['author'] == $user)) {
    $smarty->assign('msg', tra('Permission denied'));
    $smarty->display('error.tpl');
    die;
}
$smarty->assign('sheetId', $_REQUEST["sheetId"]);
$smarty->assign('title', $info['title']);
$smarty->assign('description', $info['description']);
$smarty->assign('page_mode', 'form');
// Process the insertion or modification of a gallery here
$grid = new TikiSheet();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $smarty->assign('page_mode', 'submit');
    $sheetId = $_REQUEST['sheetId'];
    $handler = $_REQUEST['handler'];
    $encoding = $_REQUEST['encoding'];
    // Instanciate the handler
    switch ($handler) {
        case 'TikiSheetWikiTableHandler':
            // Well known, special handlers
            $handler = new $handler($_POST['page']);
            break;
        default:
            // All file based handlers registered
            if (!in_array($handler, TikiSheet::getHandlerList())) {
                $smarty->assign('msg', "Handler is not allowed.");
コード例 #8
0
ファイル: grid.php プロジェクト: jkimdon/cohomeals
 function _save(&$sheet)
 {
     global $tikilib, $user, $prefs;
     // Load the current database state {{{3
     $current = new TikiSheet();
     $handler = new TikiSheetDatabaseHandler($this->id);
     $current->import($handler);
     // Find differences {{{3
     $mods = array();
     for ($row = 0; $sheet->getRowCount() > $row; $row++) {
         for ($col = 0; $sheet->getColumnCount() > $col; $col++) {
             if (!$sheet->equals($current, $row, $col)) {
                 $mods[] = array("row" => $row, "col" => $col);
             }
         }
     }
     $stamp = time();
     $inserts = array();
     $updates = array();
     $updates[] = $stamp;
     $updates[] = $this->id;
     // Update the database {{{3
     if (is_array($mods)) {
         foreach ($mods as $coord) {
             extract($coord);
             $value = $sheet->dataGrid[$row][$col];
             $calc = $sheet->calcGrid[$row][$col];
             $width = $sheet->cellInfo[$row][$col]['width'];
             $height = $sheet->cellInfo[$row][$col]['height'];
             $format = $sheet->cellInfo[$row][$col]['format'];
             $style = $sheet->cellInfo[$row][$col]['style'];
             $class = $sheet->cellInfo[$row][$col]['class'];
             $updates[] = $row;
             $updates[] = $col;
             //Now that sheets have styles, many things can change and the cell not have a value.
             //if ( !$sheet->isEmpty( $row, $col ) )
             $inserts[] = array((int) $this->id, $stamp, $row, $col, $value, $calc, $width, $height, $format, $style, $class, $user);
         }
     }
     $updates[] = $sheet->getRowCount();
     $updates[] = $sheet->getColumnCount();
     $conditions = str_repeat("( rowIndex = ? AND columnIndex = ? ) OR ", (count($updates) - 4) / 2);
     if ($prefs['feature_actionlog'] == 'y') {
         // must keep the previous value to do the difference
         $query = "SELECT `rowIndex`, `columnIndex`, `value`, `style`, `class` FROM `tiki_sheet_values` WHERE `sheetId` = ? AND  `end` IS NULL";
         $result = $tikilib->query($query, array($this->id));
         $old = array();
         while ($row = $result->fetchRow()) {
             $old[$row['rowIndex'] . '-' . $row['columnIndex']] = $row['value'];
             $old[$row['rowIndex'] . '-' . $row['columnIndex']]['style'] = $row['style'];
             $old[$row['rowIndex'] . '-' . $row['columnIndex']]['class'] = $row['class'];
         }
     }
     $tikilib->query("UPDATE `tiki_sheet_values` SET `end` = ?  WHERE `sheetId` = ? AND `end` IS NULL AND ( {$conditions}`rowIndex` >= ? OR `columnIndex` >= ? )", $updates);
     if (count($inserts) > 0) {
         foreach ($inserts as $values) {
             $tikilib->query("INSERT INTO `tiki_sheet_values` (`sheetId`, `begin`, `rowIndex`, `columnIndex`, `value`, `calculation`, `width`, `height`, `format`, `style`, `class`, `user` ) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )", $values);
         }
     }
     if ($prefs['feature_actionlog'] == 'y') {
         global $logslib;
         include_once 'lib/logs/logslib.php';
         $add = 0;
         $del = 0;
         foreach ($inserts as $values) {
             $add += strlen($values[4]);
             if (!empty($old[$values[2] . '-' . $values[3]])) {
                 $del += strlen($old[$values[2] . '-' . $values[3]]);
             }
         }
         if ($prefs['feature_contribution'] == 'y' && isset($_REQUEST['contributions'])) {
             global $contributionlib;
             include_once 'lib/contribution/contributionlib.php';
             $contributionlib->assign_contributions($_REQUEST['contributions'], $this->id, 'sheet', '', '', '');
         }
         if (isset($_REQUEST['contributions'])) {
             $logslib->add_action('Updated', $this->id, 'sheet', "add={$add}&amp;del={$del}&amp;sheetId=" . $this->id, '', '', '', '', $_REQUEST['contributions']);
         } else {
             $logslib->add_action('Updated', $this->id, 'sheet', "add={$add}&amp;del={$del}&amp;sheetId=" . $this->id);
         }
     }
     // }}}3
     return true;
 }
コード例 #9
0
ファイル: tiki-view_sheets.php プロジェクト: linuxwhy/tiki-1
    $grid = new TikiSheet();
    $grid->import($handler);
    $tableHtml[0] = $grid->getTableHtml();
    $smarty->assign('notEditable', 'true');
    if ($handler->truncated) {
        $smarty->assign('msg', tra('Spreadsheet truncated'));
    }
} else {
    //Database sheet
    $handler = new TikiSheetDatabaseHandler($_REQUEST['sheetId']);
    //We make sheet able to look at other date save
    if (isset($_REQUEST['readdate']) && !empty($_REQUEST['readdate'])) {
        $smarty->assign('read_date', $_REQUEST['readdate']);
        $handler->setReadDate($_REQUEST['readdate']);
    }
    $grid = new TikiSheet();
    $grid->import($handler);
    //ensure that sheet isn't being edited, then parse values if needed
    if ($_REQUEST['parse'] != 'edit') {
        $grid->parseValues = true;
    } else {
        $grid->parseValues = false;
    }
    $smarty->assign('parseValues', $grid->parseValues);
    $tableHtml[0] = $grid->getTableHtml(true, isset($_REQUEST['readdate']) ? $_REQUEST['readdate'] : null);
    if (!empty($relatedTrackersAsHtml)) {
        $tableHtml[0] .= $relatedTrackersAsHtml;
    }
}
if (isset($_REQUEST['sheetonly']) && $_REQUEST['sheetonly'] == 'y') {
    foreach ($tableHtml as $table) {
コード例 #10
0
    $grid = new TikiSheet();
    $grid->import($handler);
    $tableHtml[0] = $grid->getTableHtml();
    $smarty->assign('notEditable', 'true');
    if ($handler->truncated) {
        $smarty->assign('msg', tra('Spreadsheet truncated'));
    }
} else {
    //Database sheet
    $handler = new TikiSheetDatabaseHandler($_REQUEST['sheetId']);
    //We make sheet able to look at other date save
    if (isset($_REQUEST['readdate']) && !empty($_REQUEST['readdate'])) {
        $smarty->assign('read_date', $_REQUEST['readdate']);
        $handler->setReadDate($_REQUEST['readdate']);
    }
    $grid = new TikiSheet();
    $grid->import($handler);
    //ensure that sheet isn't being edited, then parse values if needed
    if ($_REQUEST['parse'] != 'edit') {
        $grid->parseValues = true;
    } else {
        $grid->parseValues = false;
    }
    $smarty->assign('parseValues', $grid->parseValues);
    $tableHtml[0] = $grid->getTableHtml(true, $_REQUEST['readdate']);
    if (strlen($relatedTrackersAsHtml) > 0) {
        $tableHtml[0] = $tableHtml[0] . $relatedTrackersAsHtml;
    }
}
if (isset($_REQUEST['sheetonly']) && $_REQUEST['sheetonly'] == 'y') {
    foreach ($tableHtml as $table) {
コード例 #11
0
ファイル: sheetlib.php プロジェクト: railfuture/tiki-website
 function join_with_sub_grids($id, $date)
 {
     global $prefs, $sheetlib;
     $result1 = "";
     $result2 = "";
     $handler = new TikiSheetDatabaseHandler($id, $date);
     $handler->setReadDate($date);
     $grid = new TikiSheet();
     $grid->import($handler);
     $childSheetIds = $sheetlib->get_related_sheet_ids($grid->id);
     $i = 0;
     $grids = array($grid);
     foreach ($childSheetIds as $childSheetId) {
         $handler = new TikiSheetDatabaseHandler($childSheetId, $date);
         $handler->setReadDate($date);
         $childSheet = new TikiSheet();
         $childSheet->import($handler);
         array_push($grids, $childSheet);
         $i++;
     }
     return $grids;
 }
コード例 #12
0
ファイル: wikiplugin_sheet.php プロジェクト: rodin/mcskb
function wikiplugin_sheet($data, $params)
{
    global $dbTiki, $tiki_p_edit_sheet, $tiki_p_edit, $tiki_p_admin_sheet, $tiki_p_admin, $prefs, $user, $sheetlib, $page, $tikilib;
    extract($params, EXTR_SKIP);
    if (!class_exists('TikiSheet')) {
        require "lib/sheet/grid.php";
    }
    static $index = 0;
    ++$index;
    if (!isset($id)) {
        if ($tiki_p_edit_sheet != 'y' || $tiki_p_edit != 'y') {
            return "<b>missing id parameter for plugin</b><br />";
        } else {
            if (isset($_POST['create_sheet'], $_POST['index']) && $index == $_POST['index']) {
                // Create a new sheet and rewrite page
                $sheetId = $sheetlib->replace_sheet(null, tra('New sheet in page: ') . $page, '', $user);
                $page = htmlentities($page);
                $content = htmlentities($data);
                $formId = "form{$index}";
                return <<<EOF
~np~
<form id="{$formId}" method="post" action="tiki-wikiplugin_edit.php">
<div>
\t<input type="hidden" name="page" value="{$page}"/>
\t<input type="hidden" name="content" value="{$data}"/>
\t<input type="hidden" name="index" value="{$index}"/>
\t<input type="hidden" name="type" value="sheet"/>
\t<input type="hidden" name="params[id]" value="{$sheetId}"/>
</div>
</form>
<script type="text/javascript">
document.getElementById('{$formId}').submit();
</script>
~/np~
EOF;
            } else {
                $intro = tra('Incomplete call to plugin: No target sheet.');
                $label = tra('Create new sheet');
                return <<<EOF
~np~
<form method="post" action="">
\t<p>{$intro}</p>
\t<p>
\t\t<input type="submit" name="create_sheet" value="{$label}"/>
\t\t<input type="hidden" name="index" value="{$index}"/>
\t</p>
</form>
~/np~
EOF;
            }
        }
    }
    // Build required objects
    $sheet = new TikiSheet();
    $db = new TikiSheetDatabaseHandler($id);
    $out = new TikiSheetOutputHandler($data);
    // Fetch sheet from database
    $sheet->import($db);
    // Grab sheet output
    ob_start();
    $sheet->export($out);
    $ret = ob_get_contents();
    ob_end_clean();
    if ($tiki_p_edit_sheet == 'y' || $tiki_p_admin_sheet == 'y' || $tiki_p_admin == 'y') {
        $ret .= "<a href='tiki-view_sheets.php?sheetId={$id}&readdate=" . time() . "&mode=edit' class='linkbut'>" . tra("Edit Sheet") . "</a>";
    }
    return $ret;
}
コード例 #13
0
}
$objectperms = Perms::get('sheet', $_REQUEST['sheetId']);
if ($tiki_p_admin != 'y' && !$objectperms->view_sheet && !($user && $info['author'] == $user)) {
    $smarty->assign('msg', tra('Permission denied'));
    $smarty->display('error.tpl');
    die;
}
$encoding = new Encoding();
$charsetList = $encoding->get_input_supported_encodings();
$smarty->assign_by_ref("charsets", $charsetList);
$smarty->assign('title', $info['title']);
$smarty->assign('description', $info['description']);
$smarty->assign('page_mode', 'form');
$smarty->assign('sheetId', $_REQUEST['sheetId']);
// Process the insertion or modification of a gallery here
$grid = new TikiSheet();
$history = $sheetlib->sheet_history($_REQUEST['sheetId']);
$smarty->assign_by_ref('history', $history);
if (isset($_REQUEST['encoding'])) {
    $smarty->assign('page_mode', 'submit');
    $handler = new TikiSheetDatabaseHandler($_REQUEST['sheetId'], $_REQUEST['readdate']);
    $grid->import($handler);
    $handler = $_REQUEST['handler'];
    if (!in_array($handler, TikiSheet::getHandlerList())) {
        $smarty->assign('msg', "Handler is not allowed.");
        $smarty->display("error.tpl");
        die;
    }
    $handler = new $handler("php://stdout", 'UTF-8', $_REQUEST['encoding']);
    $grid->export($handler);
    header("Content-type: text/comma-separated-values");
コード例 #14
0
ファイル: sheetlib.php プロジェクト: linuxwhy/tiki-1
 function diff_sheets_as_html($id, $dates = null)
 {
     global $prefs;
     $count_longest = function ($array1, $array2) {
         return max(count($array1), count($array2));
     };
     $join_with_sub_grids = function ($id, $date) {
         global $prefs;
         $handler = new TikiSheetDatabaseHandler($id, $date);
         $handler->setReadDate($date);
         $grid = new TikiSheet();
         $grid->import($handler);
         $childSheetIds = $this->get_related_sheet_ids($grid->id);
         $i = 0;
         $grids = array($grid);
         foreach ($childSheetIds as $childSheetId) {
             $handler = new TikiSheetDatabaseHandler($childSheetId, $date);
             $handler->setReadDate($date);
             $childSheet = new TikiSheet();
             $childSheet->import($handler);
             array_push($grids, $childSheet);
             $i++;
         }
         return $grids;
     };
     $sanitize_for_diff = function ($val) {
         $val = str_replace("<br/>", "<br>", $val);
         $val = str_replace("<br />", "<br>", $val);
         $val = str_replace("<br  />", "<br>", $val);
         $val = str_replace("<BR/>", "<br>", $val);
         $val = str_replace("<BR />", "<br>", $val);
         $val = str_replace("<BR  />", "<br>", $val);
         return explode("<br>", $val);
     };
     $diff_to_html = function ($changes) use($count_longest) {
         $result = array("", "");
         for ($i = 0; $i < $count_longest($changes->orig, $changes->final); $i++) {
             $class = array("", "");
             $char = array("", "");
             $vals = array(trim($changes->orig[$i]), trim($changes->final[$i]));
             if ($vals[0] && $vals[1]) {
                 if ($vals[0] != $vals[1]) {
                     $class[1] .= "diffadded";
                 }
             } else {
                 if ($vals[0]) {
                     $class[0] .= "diffadded";
                     $class[1] .= "diffdeleted";
                     $vals[1] = $vals[0];
                     $char[1] = "-";
                 } else {
                     if ($vals[1]) {
                         $class[0] .= "diffdeleted";
                         $class[1] .= "diffadded";
                         $char[1] = "+";
                     }
                 }
             }
             if ($vals[0]) {
                 $result[0] .= "<td class='{$class['0']}'>" . $char[0] . $vals[0] . "</td>";
             }
             if ($vals[1]) {
                 $result[1] .= "<td class='{$class['1']}'>" . $char[1] . $vals[1] . "</td>";
             }
         }
         return $result;
     };
     $grids1 = $join_with_sub_grids($id, $dates[0]);
     $grids2 = $join_with_sub_grids($id, $dates[1]);
     $result1 = '';
     $result2 = '';
     for ($i = 0; $i < $count_longest($grids1, $grids2); $i++) {
         //cycle through the sheets within a spreadsheet
         $result1 .= "<table title='" . $grids1[$i]->name() . "'>";
         $result2 .= "<table title='" . $grids2[$i]->name() . "'>";
         for ($row = 0; $row < $count_longest($grids1[$i]->dataGrid, $grids2[$i]->dataGrid); $row++) {
             //cycle through rows
             $result1 .= "<tr>";
             $result2 .= "<tr>";
             for ($col = 0; $col < $count_longest($grids1[$i]->dataGrid[$row], $grids2[$i]->dataGrid[$row]); $col++) {
                 //cycle through columns
                 $diff = new Text_Diff($sanitize_for_diff(html_entity_decode($grids1[$i]->dataGrid[$row][$col])), $sanitize_for_diff(html_entity_decode($grids2[$i]->dataGrid[$row][$col])));
                 $changes = $diff->getDiff();
                 //I left this diff switch, but it really isn't being used as of now, in the future we may though.
                 switch (get_class($changes[0])) {
                     case 'Text_Diff_Op_copy':
                         $values = $diff_to_html($changes[0]);
                         break;
                     case 'Text_Diff_Op_change':
                         $values = $diff_to_html($changes[0]);
                         break;
                     case 'Text_Diff_Op_delete':
                         $values = $diff_to_html($changes[0]);
                         break;
                     case 'Text_Diff_Op_add':
                         $values = $diff_to_html($changes[0]);
                         break;
                     default:
                         $values = $diff_to_html($changes[0]);
                 }
                 $result1 .= empty($values[0]) ? '<td></td>' : $values[0];
                 $result2 .= empty($values[1]) ? '<td></td>' : $values[1];
             }
             $result1 .= "</tr>";
             $result2 .= "</tr>";
         }
         $result1 .= "</table>";
         $result2 .= "</table>";
     }
     return array($result1, $result2);
 }
コード例 #15
0
function wikiplugin_sheet($data, $params)
{
    global $dbTiki, $tiki_p_edit_sheet, $tiki_p_edit, $tiki_p_admin_sheet, $tiki_p_admin, $prefs, $user, $sheetlib, $page, $tikilib, $smarty;
    extract($params, EXTR_SKIP);
    $style = isset($height) ? "height: {$height} !important;" : '';
    $style .= isset($width) ? "width: {$width};" : '';
    //	$urlHeight = (isset($height)) ? "&height=$height" : '';
    //	$urlHeight .= (isset($width)) ? "&width=$width" : '';
    $urlHeight = isset($height) ? "&height=100" : '';
    // not setting any height or width in the sheet params created for me the literal '...&height=100%&...' or '...&width=100%&...' in the url with a 400 error (bad request). Hardcoding to 100 (instead of 100%) to avoid this error until a better fix is found
    $urlHeight .= isset($width) ? "&width=100" : '';
    // not setting any height or width in the sheet params created for me the literal '...&height=100%&...' or '...&width=100%&...' in the url with a 400 error (bad request). Hardcoding to 100 (instead of 100%) to avoid this error until a better fix is found
    $editable = isset($editable) && $editable == 'n' ? false : true;
    $subsheets = isset($subsheets) && $subsheets == 'n' ? false : true;
    $class = isset($class) ? " {$class}" : '';
    $sheetlib = TikiLib::lib("sheet");
    static $index = 0;
    ++$index;
    if (empty($id) && empty($url)) {
        if ($tiki_p_edit_sheet != 'y' || $tiki_p_edit != 'y') {
            return "<b>missing id parameter for plugin</b><br />";
        } else {
            if (isset($_POST['create_sheet'], $_POST['index']) && $index == $_POST['index']) {
                // Create a new sheet and rewrite page
                $sheetId = $sheetlib->replace_sheet(null, tra('New sheet in page: ') . $page, '', $user);
                $page = htmlentities($page);
                $content = htmlentities($data);
                $formId = "form{$index}";
                return <<<EOF
\t\t\t\t~np~
\t\t\t\t<form id="{$formId}" method="post" action="tiki-wikiplugin_edit.php">
\t\t\t\t<div>
\t\t\t\t\t<input type="hidden" name="page" value="{$page}"/>
\t\t\t\t\t<input type="hidden" name="content" value="{$data}"/>
\t\t\t\t\t<input type="hidden" name="index" value="{$index}"/>
\t\t\t\t\t<input type="hidden" name="type" value="sheet"/>
\t\t\t\t\t<input type="hidden" name="params[id]" value="{$sheetId}"/>
\t\t\t\t</div>
\t\t\t\t</form>
\t\t\t\t<script type="text/javascript">
\t\t\t\tdocument.getElementById('{$formId}').submit();
\t\t\t\t</script>
\t\t\t\t~/np~
EOF;
            } else {
                $label = tra('Create New Sheet');
                return <<<EOF
~np~
<form method="post" action="">
\t<p>
\t\t<input type="submit" name="create_sheet" value="{$label}"/>
\t\t<input type="hidden" name="index" value="{$index}"/>
\t</p>
</form>
~/np~
EOF;
            }
        }
    }
    $sheet = new TikiSheet();
    if (empty($url)) {
        $info;
        if (!empty($id)) {
            $info = $sheetlib->get_sheet_info($id);
        }
        if (empty($info)) {
            return tra("Error loading spreadsheet");
        }
        $objectperms = Perms::get('sheet', $id);
        if (!$objectperms->view_sheet && !($user && $info['author'] == $user)) {
            return tra('Permission denied');
        }
        // Build required objects
        $db = new TikiSheetDatabaseHandler($id);
        //$out = new TikiSheetOutputHandler($data);
        // Fetch sheet from database
        $sheet->import($db);
    } else {
        if (!isset($simple)) {
            $simple = 'y';
        }
    }
    $calcOff = '';
    if (!empty($range)) {
        $sheet->setRange($range);
        $calcOff = ',calcOff: true';
    }
    // Grab sheet output
    if (isset($url)) {
        $file = file_get_contents($url);
        $pathInfo = pathinfo($url);
        if ($pathInfo['extension'] == 'csv') {
            $handler = new TikiSheetCSVHandler($url);
            $grid = new TikiSheet();
            $grid->import($handler);
            $ret = $grid->getTableHtml(true, null, false);
        } else {
            $ret = file_get_contents($url);
        }
    } else {
        $ret = $sheet->getTableHtml($subsheets);
    }
    if (strpos($ret, '<table ') === false) {
        return '~np~' . $ret . '~/np~';
        // return a single cell raw
    }
    if (!isset($simple) || $simple != 'y') {
        global $headerlib;
        $sheetlib->setup_jquery_sheet();
        $headerlib->add_jq_onready('$("div.tiki_sheet").each(function() {
				$(this).sheet($.extend($.sheet.tikiOptions,{
				editable:false' . $calcOff . '}));
			});');
    }
    $ret = '<div id="tiki_sheet' . $sheet->instance . '" class="tiki_sheet' . $class . '" style="overflow:hidden;' . $style . '">' . $ret . '</div>';
    if ($editable && ($objectperms->edit_sheet || $objectperms->admin_sheet || $tiki_p_admin == 'y')) {
        $smarty->loadPlugin('smarty_function_button');
        //If you've given the sheet a url, you can't edit it, disable if not possible
        if (!isset($url)) {
            $button_params = array('_text' => tra("Edit Sheet"), '_script' => "tiki-view_sheets.php?sheetId={$id}&parse=edit{$urlHeight}&page={$page}");
        }
        $ret .= smarty_function_button($button_params, $smarty);
    }
    return '~np~' . $ret . '~/np~';
}
コード例 #16
0
ファイル: tiki-import_sheet.php プロジェクト: noikiy/owaspbwa
    }
    if (!$grid->import($handler)) {
        $smarty->assign('msg', "Impossible to import the file.");
        $smarty->display("error.tpl");
        die;
    }
    $handler =& new TikiSheetDatabaseHandler($sheetId);
    $grid->export($handler);
    ob_start();
    $handler =& new TikiSheetOutputHandler();
    $grid->export($handler);
    $smarty->assign("grid_content", ob_get_contents());
    ob_end_clean();
} else {
    $list = array();
    $handlers = TikiSheet::getHandlerList();
    foreach ($handlers as $key => $handler) {
        $temp =& new $handler();
        if (!$temp->supports(TIKISHEET_LOAD_DATA | TIKISHEET_LOAD_CALC)) {
            continue;
        }
        $list[$key] = array("name" => $temp->name(), "version" => $temp->version(), "class" => $handler);
    }
    $smarty->assign_by_ref("handlers", $list);
}
$cat_type = 'sheet';
$cat_objid = $_REQUEST["sheetId"];
include_once "categorize_list.php";
$section = 'sheet';
include_once 'tiki-section_options.php';
ask_ticket('sheet');
コード例 #17
0
ファイル: grid.php プロジェクト: railfuture/tiki-website
 function _load(TikiSheet &$sheet)
 {
     $d = $this->data;
     $rows = (int) $d->metadata->rows;
     $cols = (int) $d->metadata->columns;
     for ($r = 0; $r < $rows; $r++) {
         for ($c = 0; $c < $cols; $c++) {
             $ri = 'r' . $r;
             $ci = 'c' . $c;
             if (isset($d->data->{$ri}->{$ci}->value)) {
                 $val = $d->data->{$ri}->{$ci}->value;
             } else {
                 $val = '';
             }
             $sheet->initCell($r, $c);
             if (isset($d->data->{$ri}->{$ci}->width) || isset($d->data->{$ri}->{$ci}->height)) {
                 $sheet->setSize(isset($d->data->{$ri}->{$ci}->width) ? $d->data->{$ri}->{$ci}->width : 1, isset($d->data->{$ri}->{$ci}->height) ? $d->data->{$ri}->{$ci}->height : 1);
             } else {
                 $sheet->setSize(1, 1);
             }
             $sheet->setValue($val);
             if (isset($d->data->{$ri}->{$ci}->formula)) {
                 $formula = substr($d->data->{$ri}->{$ci}->formula, 1, strlen($d->data->{$ri}->{$ci}->formula) - 1);
                 if (!empty($formula)) {
                     $sheet->setCalculation($formula);
                 }
             }
             if (isset($d->data->{$ri}->{$ci}->stl)) {
                 $style = $d->data->{$ri}->{$ci}->stl;
                 if (!empty($style)) {
                     $sheet->setStyle($style);
                 }
             }
             if (isset($d->data->{$ri}->{$ci}->cl)) {
                 $class = $d->data->{$ri}->{$ci}->cl;
                 if (!empty($class)) {
                     $sheet->setClass($class);
                 }
             }
         }
     }
     return true;
 }