public function equals(Cell $dst) { if ($this == $dst) { return true; } return $this->ch == $dst->getCh() && $this->fg == $dst->getFg() && $this->bg == $dst->getBg(); }
public function addCell(\Cell $cell) { if ($this->cellExists($cell->getX(), $cell->getY())) { throw new \LogicException('tato bunka j*z na hraci plose existuje'); } $this->cells[$cell->getX()][$cell->getY()] = $cell; }
/** * Draw HTML output */ function draw() { global $c, $sid; echo '<td colspan="' . $this->cells . '"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>'; $widget = new Cell("clc", "", 1, $this->width, 40); $widget->draw(); echo "</tr><tr>\n"; $widget = new Label("lbl", $this->headline, "headbox", 1); $widget->draw(); echo "</tr><tr>\n"; $widget = new FormImage($c["docroot"] . "modules/stats/widgets/statsimage.php?sid={$sid}&diagram=" . $this->diagramType . "&width=" . $this->width . "&height=" . $this->height . "&spid=" . $this->spid, $this->width, $this->height, 1); $widget->draw(); // Draw Legend... echo "</tr><tr>\n"; $widget = new Cell("clc", "", 1, $this->width, 10); $widget->draw(); $colors[0] = __RED; $colors[1] = __BLUE; $colors[2] = __YELLOW; $colors[3] = __GREEN; for ($i = 0; $i < count($this->legend); $i++) { echo "</tr><tr><td>"; echo '<table width="100%" border="0" cellpadding="2" cellspacing="0"><tr>'; echo '<td width="10">' . ($i + 1) . '.</td>'; echo '<td width="11">'; echo '<table width="11" height="11" border="0" cellspacing="0" cellpadding="0"><tr><td style="background-color:' . $colors[$i] . ';">' . drawSpacer(11, 11) . '</td></tr></table>'; echo '</td>'; echo '<td>' . $this->legend[$i] . '</td>'; echo '</tr></table></td>'; } echo "</tr></table></td>"; return $this->cells; }
/** @param $station<Station> */ function createStationTableRow($station, $marker_img, $class_name) { global $website; $station_marker = $station->marker; $station_name = $station_marker->name; $marker_link = new MarkerLink($station_marker->getLat(), $station_marker->getLng(), new Image("images/{$marker_img}", 0)); #echo $marker_link->toString() . "<br/>"; $station_row = new Row($station_name, $class_name); //$station_cell = new Cell(null, null, null, $marker_link); #echo $station_cell->toString(); #$station_row->addCell($station_cell); $station_row->addCell(new Cell(null, "stationMarkerLink", "text-align: center", $marker_link)); $station_row->addCell(new Cell("stationName", $station_name)); $lines_cell = new Cell("stationLines"); $lines = $station_marker->getLines(); foreach ($lines as $line) { foreach ($line->getConnections() as $connection) { if ($connection->type != "transfer") { $line_img = $line->img; $line_url = $website . $line->url; $link = new Link("javascript:void(0);", new Image(null, null, "images/{$line_img}", $line->name, null, 20), "window.open('{$line_url}');"); //echo $link->toString(); $lines_cell->addData($link); break; } } } $station_row->addCell($lines_cell); #echo "<!--" . $station_row->toString() . "-->"; return $station_row; }
/** * Test border size */ public function testBorderSize() { $object = new Cell(); $value = 120; $expected = array($value, $value, $value, $value); $object->setStyleValue('borderSize', $value); $this->assertEquals($expected, $object->getBorderSize()); }
public function testCellWithFourNighbours() { $cell = new Cell(); $cell->livingStatus(true); $cell->addNighbours(4); $newCell = $cell->nextGen(); $this->assertFalse($cell->isAlive(), 'This test is okay'); }
function view_row() { echo "<tr>"; for ($i = 0; $i <= $this->end_array; $i++) { $cell_table = new Cell($this->row_array[text][$i], $this->row_array[col][$i], $this->row_array[row][$i], $this->row_array[font][$i]); $cell_table->view_cell(); } echo "</tr>"; }
/** * Bind value to a cell * * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell * @return boolean */ public function bindValue(Cell $cell, $value = null) { // sanitize UTF-8 strings if (is_string($value)) { $value = Shared_String::SanitizeUTF8($value); } // Set value explicit $cell->setValueExplicit($value, Cell_DataType::dataTypeForValue($value)); // Done! return true; }
/** * Draw HTML output */ function draw() { global $c, $sid; echo '<td colspan="' . $this->cells . '"><table width="600" border="0" cellpadding="0" cellspacing="0"><tr>'; $widget = new Cell("clc", "", 2, $this->width, 20); $widget->draw(); echo "</tr><tr>\n"; $widget = new Label("lbl", '<br><h3>' . $this->headline . '</h3>', '', 2); $widget->draw(); echo "</tr>\n"; echo $this->container; echo "</tr></table></td>"; return $this->cells; }
/** * Draw HTML output */ function draw() { global $c, $sid; echo '<td colspan="' . $this->cells . '" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>'; $widget = new Cell("clc", "", 4, $this->width, 20); $widget->draw(); echo "</tr><tr>\n"; $widget = new Label("lbl", $this->headline, "stats_headline", 4); $widget->draw(); echo "</tr>\n"; echo $this->container; echo "</tr></table></td>"; return $this->cells; }
/** * @test */ public function rules() { $this->assertFalse($this->object->getNextState(0, true)); $this->assertFalse($this->object->getNextState(1, true)); $this->assertTrue($this->object->getNextState(2, true)); $this->assertTrue($this->object->getNextState(3, true)); $this->assertFalse($this->object->getNextState(4, true)); $this->assertFalse($this->object->getNextState(2, false)); $this->assertTrue($this->object->getNextState(3, false)); $this->assertFalse($this->object->getNextState(4, false)); }
/** * Calculates the neighbours of a given cell. * @param Cell $cell The cell the neighbours should be calculated for. * @return int Amount of neighbours. */ public function getNeighboursByCell(Cell $cell) { $y = $cell->getCoordY(); $x = $cell->getCoordX(); $neighbours = 0; for ($nY = $y - 1; $nY <= $y + 1; $nY++) { for ($nX = $x - 1; $nX <= $x + 1; $nX++) { if ($this->getCellByCoords($nX, $nY) && !($nX == $x && $nY == $y)) { if ($this->getCellByCoords($nX, $nY)->isAlive()) { $neighbours++; } } } } return $neighbours; }
public static function createFromString($string) { $lines = explode('\\n', $string); $rows = count($lines); $cols = strlen($lines[0]); $player = new Player($cols, $rows); foreach ($lines as $y => $line) { foreach (str_split($line) as $x => $char) { if ($char == '*') { $cell = new Cell(); $cell->setMature(); $player->university->setObjTo($x, $y, $cell); } } } return $player; }
function __do_response_reply_count($response) { global $config, $speak, $segment; $e = File::E($response->path); $replies = count(glob(COMMENT . DS . '*_*_' . Date::slug($response->id) . '.{txt,hold}', GLOB_NOSORT | GLOB_BRACE)); $t = Jot::icon('reply-all') . ' ' . $replies; $tt = array('title' => $replies . ' ' . ($replies === 1 ? $speak->{$segment[0] . '_reply'} : $speak->{$segment[0] . '_replies'})); echo ($e === 'hold' || $replies === 0 ? Cell::span($t, $tt) : Cell::a($config->manager->slug . '/' . $segment[0] . '?filter=parent%3A' . $response->id, $t, null, $tt)) . ' · '; }
/** * Include specified cell * @param Cell $cell * @return Range */ public function expand(Cell $cell) { if ($cell->getRow() > $this->rowTo) { $this->setRowTo($cell->getRow()); } if ($cell->getCol() > $this->colTo) { $this->setColTo($cell->getCol()); } return $this; }
private function setNextStatesForDeathCellsInNeigbohrOfLiveCells() { $cells = $this->desk->getCells(); foreach ($cells as $cell) { $x = $cell->getX(); $y = $cell->getY(); foreach ($this->desk->getNeigbohrsCoordinates($x, $y) as $coords) { if (!$this->desk->cellExists($coords[0], $coords[1])) { $countOfAliveNeighbors = $this->desk->getCountOfLiveCellsInNeigbohr($coords[0], $coords[1]); $nextStateOfNonExistingCell = $this->rules->getNextState($countOfAliveNeighbors, false); if ($nextStateOfNonExistingCell === true) { $newLiveCell = new \Cell($coords[0], $coords[1], false); $newLiveCell->setNextState($nextStateOfNonExistingCell); $this->desk->addCell($newLiveCell); } } } } }
/** * Draw HTML output */ function draw() { global $c, $sid, $lang; echo '<td colspan="3"><table width="100%" border="0" cellpadding="3" cellspacing="0"><tr>'; $widget = new Cell("clc", "", 2, $this->width, 20); $widget->draw(); echo "</tr><tr>\n"; echo '<td colspan="2"align="right"> </td>'; echo '<td align="right">'; $lbi = new Button("action", $lang->get("print", "print"), "navelement", "button", "window.open('" . $_SERVER['REQUEST_URI'] . "&print=1');"); $lbi->draw(); echo " "; $lbi = new Button("action", $lang->get("refresh", "refresh"), "navelement", "button", "document.location.href = document.location.href;"); $lbi->draw(); retain("action", ""); retain("sid", $sid); echo "</td></tr></table></td>"; return $this->cells; }
public static function sieve($input, $paramPredicate) { $x = $input->first(); $cell = new Cell($x, null); $cell->cdr = function () use($input, $paramPredicate, $x) { return Cell::sieve($input->rest()->filter(function ($n) use($paramPredicate, $x) { return $paramPredicate($n, $x); }), $paramPredicate); }; return $cell; }
/** * Delete a cell in cache identified by coordinate address * * @param string $pCoord Coordinate address of the cell to delete * @throws Exception */ public function deleteCacheData($pCoord) { if ($pCoord === $this->_currentObjectID) { $this->_currentObject->detach(); $this->_currentObjectID = $this->_currentObject = null; } if (isset($this->_cellCache[$pCoord])) { $this->_cellCache[$pCoord]->detach(); unset($this->_cellCache[$pCoord]); } }
/** * @test */ public function countOfLiveNeigbohrs() { $cell = new \Cell(1, 1, true); $this->object->addCell($cell); $this->assertEquals(1, $this->object->getCountOfLiveCellsInNeigbohr(1, 2)); $this->assertEquals(1, $this->object->getCountOfLiveCellsInNeigbohr(1, 0)); $this->assertEquals(0, $this->object->getCountOfLiveCellsInNeigbohr(1, 1)); $this->assertEquals(1, $this->object->getCountOfLiveCellsInNeigbohr(2, 2)); $this->assertEquals(0, $this->object->getCountOfLiveCellsInNeigbohr(10, 10)); }
/** * Draw HTML output */ function draw() { global $c, $sid, $lang; echo '<form name="form1">'; echo '<td colspan="' . $this->cells . '"><table width="100%" border="0" cellpadding="3" cellspacing="0"><tr>'; $widget = new Cell("clc", "", 2, $this->width, 20); $widget->draw(); echo "</tr><tr>\n"; $widget = new Label("lbl", $this->headline, "stats_headline", 2); $widget->draw(); echo "</tr>\n"; echo "<tr><td colspan=\"" . $this->cells . "\" class=\"bcopy\">" . $lang->get("pta", "Select page to analyze:") . "</td></tr>"; echo "<tr>"; $this->sps->draw(); echo "<td> "; $lbi = new LinkButton("action", $lang->get("go", "Go"), "navelement", "submit"); $lbi->draw(); retain("action", ""); retain("sid", $sid); echo "</td></tr></table></td>"; echo "</form>"; return $this->cells; }
public function __construct($id = null, $position = null) { if ($id == null) { self::$lastAutoId++; $id = self::$lastAutoId; } if ($position == null) { self::$lastAutoPosition++; $position = self::$lastAutoPosition; } $this->id = $id; $this->content = $id; $this->position = $position; parent::__construct(); }
/** * Parse row * @return array */ protected function parseRow() { $content = []; if ($this->reader->hasHeader) { $this->initHeader(); } $cells = $this->row->getCellIterator(); $i = 0; foreach ($cells as $this->cell) { $header = $this->reader->hasHeader ? $this->header[$i] : $i; if ($this->needParsed($header, $i)) { $content[$header] = $this->cell->getValue(); } $i++; } return $content; }
/** * Create a new RichText instance * * @param Cell $pCell * @throws Exception */ public function __construct(Cell $pCell = null) { // Initialise variables $this->richTextElements = array(); // Rich-Text string attached to cell? if ($pCell !== null) { // Add cell text and style if ($pCell->getValue() != "") { $objRun = new RichText\Run($pCell->getValue()); $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); $this->addText($objRun); } // Set parent value $pCell->setValueExplicit($this, Cell\DataType::TYPE_STRING); } }
protected function cell($cell) { return Cell::make($cell['id'])->type($cell['type'])->source($cell['source'])->visible($cell['visible'] == 'yes'); }
/** * Loads PHPExcel from file into PHPExcel instance * * @param string $pFilename * @param PHPExcel $objPHPExcel * @return PHPExcel * @throws Exception */ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { // Check if file exists if (!file_exists($pFilename)) { throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); } // Create new PHPExcel while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { $objPHPExcel->createSheet(); } $objPHPExcel->setActiveSheetIndex($this->_sheetIndex); $fromFormats = array('\\-', '\\ '); $toFormats = array('-', ' '); // Open file $fileHandle = fopen($pFilename, 'r'); if ($fileHandle === false) { throw new Exception("Could not open file {$pFilename} for reading."); } // Loop through file $rowData = array(); $column = $row = ''; // loop through one row (line) at a time in the file while (($rowData = fgets($fileHandle)) !== FALSE) { // convert SYLK encoded $rowData to UTF-8 $rowData = Shared_String::SYLKtoUTF8($rowData); // explode each row at semicolons while taking into account that literal semicolon (;) // is escaped like this (;;) $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData))))); $dataType = array_shift($rowData); // Read shared styles if ($dataType == 'P') { $formatArray = array(); foreach ($rowData as $rowDatum) { switch ($rowDatum[0]) { case 'P': $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); break; case 'E': case 'F': $formatArray['font']['name'] = substr($rowDatum, 1); break; case 'L': $formatArray['font']['size'] = substr($rowDatum, 1); break; case 'S': $styleSettings = substr($rowDatum, 1); for ($i = 0; $i < strlen($styleSettings); ++$i) { switch ($styleSettings[$i]) { case 'I': $formatArray['font']['italic'] = true; break; case 'D': $formatArray['font']['bold'] = true; break; case 'T': $formatArray['borders']['top']['style'] = Style_Border::BORDER_THIN; break; case 'B': $formatArray['borders']['bottom']['style'] = Style_Border::BORDER_THIN; break; case 'L': $formatArray['borders']['left']['style'] = Style_Border::BORDER_THIN; break; case 'R': $formatArray['borders']['right']['style'] = Style_Border::BORDER_THIN; break; } } break; } } $this->_formats['P' . $this->_format++] = $formatArray; // Read cell value data } elseif ($dataType == 'C') { $hasCalculatedValue = false; $cellData = $cellDataFormula = ''; foreach ($rowData as $rowDatum) { switch ($rowDatum[0]) { case 'C': case 'X': $column = substr($rowDatum, 1); break; case 'R': case 'Y': $row = substr($rowDatum, 1); break; case 'K': $cellData = substr($rowDatum, 1); break; case 'E': $cellDataFormula = '=' . substr($rowDatum, 1); // Convert R1C1 style references to A1 style references (but only when not quoted) $temp = explode('"', $cellDataFormula); foreach ($temp as $key => &$value) { // Only count/replace in alternate array entries if ($key % 2 == 0) { preg_match_all('/(R(\\[?-?\\d*\\]?))(C(\\[?-?\\d*\\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // through the formula from left to right. Reversing means that we work right to left.through // the formula $cellReferences = array_reverse($cellReferences); // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, // then modify the formula to use that new reference foreach ($cellReferences as $cellReference) { $rowReference = $cellReference[2][0]; // Empty R reference is the current row if ($rowReference == '') { $rowReference = $row; } // Bracketed R references are relative to the current row if ($rowReference[0] == '[') { $rowReference = $row + trim($rowReference, '[]'); } $columnReference = $cellReference[4][0]; // Empty C reference is the current column if ($columnReference == '') { $columnReference = $column; } // Bracketed C references are relative to the current column if ($columnReference[0] == '[') { $columnReference = $column + trim($columnReference, '[]'); } $A1CellReference = Cell::stringFromColumnIndex($columnReference - 1) . $rowReference; $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); } } } unset($value); // Then rebuild the formula string $cellDataFormula = implode('"', $temp); $hasCalculatedValue = true; break; } } $columnLetter = Cell::stringFromColumnIndex($column - 1); $cellData = Calculation::_unwrapResult($cellData); // Set cell value $objPHPExcel->getActiveSheet()->getCell($columnLetter . $row)->setValue($hasCalculatedValue ? $cellDataFormula : $cellData); if ($hasCalculatedValue) { $cellData = Calculation::_unwrapResult($cellData); $objPHPExcel->getActiveSheet()->getCell($columnLetter . $row)->setCalculatedValue($cellData); } // Read cell formatting } elseif ($dataType == 'F') { $formatStyle = $columnWidth = $styleSettings = ''; $styleData = array(); foreach ($rowData as $rowDatum) { switch ($rowDatum[0]) { case 'C': case 'X': $column = substr($rowDatum, 1); break; case 'R': case 'Y': $row = substr($rowDatum, 1); break; case 'P': $formatStyle = $rowDatum; break; case 'W': list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1)); break; case 'S': $styleSettings = substr($rowDatum, 1); for ($i = 0; $i < strlen($styleSettings); ++$i) { switch ($styleSettings[$i]) { case 'I': $styleData['font']['italic'] = true; break; case 'D': $styleData['font']['bold'] = true; break; case 'T': $styleData['borders']['top']['style'] = Style_Border::BORDER_THIN; break; case 'B': $styleData['borders']['bottom']['style'] = Style_Border::BORDER_THIN; break; case 'L': $styleData['borders']['left']['style'] = Style_Border::BORDER_THIN; break; case 'R': $styleData['borders']['right']['style'] = Style_Border::BORDER_THIN; break; } } break; } } if ($formatStyle > '' && $column > '' && $row > '') { $columnLetter = Cell::stringFromColumnIndex($column - 1); $objPHPExcel->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->_formats[$formatStyle]); } if (count($styleData) > 0 && $column > '' && $row > '') { $columnLetter = Cell::stringFromColumnIndex($column - 1); $objPHPExcel->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($styleData); } if ($columnWidth > '') { if ($startCol == $endCol) { $startCol = Cell::stringFromColumnIndex($startCol - 1); $objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); } else { $startCol = Cell::stringFromColumnIndex($startCol - 1); $endCol = Cell::stringFromColumnIndex($endCol - 1); $objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); do { $objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth); } while ($startCol != $endCol); } } } else { foreach ($rowData as $rowDatum) { switch ($rowDatum[0]) { case 'C': case 'X': $column = substr($rowDatum, 1); break; case 'R': case 'Y': $row = substr($rowDatum, 1); break; } } } } // Close file fclose($fileHandle); // Return return $objPHPExcel; }
/** * @param string $cellName * @return string */ public function getValue($cellName) { $Cell = Cell::factoryFromName($cellName); return $this->_cells[$Cell->getYCoordinate()][$Cell->getXCoordinate()]; }
<h4><i class="fa fa-comments"></i> <?php echo $speak->responses; ?> </h4> <?php if ($responses = glob(RESPONSE . DS . '*', GLOB_ONLYDIR)) { ?> <ul> <?php foreach ($responses as $response) { ?> <?php $s = File::B($response); ?> <li><?php echo Cell::a($config->manager->slug . '/' . $s, isset($speak->{$s}) ? $speak->{$s} : Text::parse($s, '->title'), null, array('data-tooltip' => Text::parse(count(glob($response . DS . '*.txt', GLOB_NOSORT)) . ' ' . $speak->approved . ', ' . count(glob($response . DS . '*.hold', GLOB_NOSORT)) . ' ' . $speak->pending, '->text'))); ?> (<?php echo count(glob($response . DS . '*.*', GLOB_NOSORT)); ?> )</li> <?php } ?> </ul> <?php } ?> </div> <div class="grid span-2"> <h4><i class="fa fa-users"></i> <?php
/** * Draws the Envelope. */ function draw() { echo "<td colspan=\"2\" width=\"100%\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n"; if (count($this->container) > 0 ) { echo "<tr>"; $cl1 = new Cell("cl1", $style, 1, 200, 1); $cl3 = new Cell("cl2", $style, 1, 400, 1); $cl1->draw(); $cl3->draw(); echo "</tr>"; } $col = 1; for ($i = 0; $i < count($this->container); $i++) { if ($col == 1) echo "<tr>"; $col += $this->container[$i]->draw(); if ($col > 2) { $col = 0; echo "</tr>"; } $col++; } if ($col != 1) echo "</tr>"; if (count($this->container) > 0 ) { echo "<tr>"; $cl = new Cell("cl3", $style, 3, 600,20); $cl->draw(); echo "</tr>"; } echo "</table></td>"; return 2; }
$menus[$speak->error] = array('icon' => 'exclamation-triangle', 'url' => $config->manager->slug . '/error', 'count' => $total, 'stack' => 9.130000000000001); } } if ($config->page_type !== '404' && $config->is->post) { $type = $config->page_type; $id = $config->{$type}->id; $text = Config::speak($type); $text_repair = Config::speak('manager._this_', array($speak->edit, $text)); $text_kill = Config::speak('manager._this_', array($speak->delete, $text)); $bars[$text] = array('icon' => 'plus', 'url' => $config->manager->slug . '/' . $type . '/ignite', 'description' => Config::speak('manager.title_new_', $text), 'stack' => 9.029999999999999); $bars[$speak->edit] = array('icon' => 'pencil', 'url' => $config->manager->slug . '/' . $type . '/repair/id:' . $id, 'description' => $text_repair, 'stack' => 9.039999999999999); $bars[$speak->delete] = array('icon' => 'times', 'url' => $config->manager->slug . '/' . $type . '/kill/id:' . $id, 'description' => $text_kill, 'stack' => 9.050000000000001); } else { $link = Cell::a($config->manager->slug . '/article/ignite', Config::speak('manager.title_new_', $speak->article)); $link .= ' · '; $link .= Cell::a($config->manager->slug . '/page/ignite', Config::speak('manager.title_new_', $speak->page)); $bars[$speak->add] = array('icon' => 'plus', 'url' => $config->manager->slug . '/article/ignite', 'description' => $link, 'stack' => 9.029999999999999); } Config::merge('manager_menu', $menus); Config::merge('manager_bar', $bars); }); } // Loading frontend task(s) and route(s) Weapon::add('routes_before', function () use($config, $speak) { require __DIR__ . DS . 'workers' . DS . 'task.comment.ignite.php'; require __DIR__ . DS . 'workers' . DS . 'route.login.php'; }); // Add log in/out link in shield footer function do_footer_manager_link($content, $path) { global $config, $speak;