/** @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; }
/** * Add cell */ public function testAddCell() { $oRow = new Row(); $element = $oRow->addCell(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Cell', $element); $this->assertCount(1, $oRow->getCells()); }
/** * Constructor * Use $db->createResult( $parent, $name ) instead * * @param Database|Result|Row $parent * @param string $name */ function __construct($parent, $name) { if ($parent instanceof Database) { // basic result $this->db = $parent; $this->table = $this->db->getAlias($name); } else { // Row or Result // result referenced to parent $this->parent_ = $parent; $this->db = $parent->getDatabase(); // determine type of reference based on conventions and user hints $fullName = $name; $name = preg_replace('/List$/', '', $fullName); $this->table = $this->db->getAlias($name); $this->single = $name === $fullName; if ($this->single) { $this->key = $this->db->getPrimary($this->getTable()); $this->parentKey = $this->db->getReference($parent->getTable(), $name); } else { $this->key = $this->db->getBackReference($parent->getTable(), $name); $this->parentKey = $this->db->getPrimary($parent->getTable()); } } }
public function testGetPrimaryKey() { $expected = 'table_id'; $table = $this->getMockBuilder(Table::class)->disableOriginalConstructor()->getMock(); $table->expects($this->once())->method('getPrimaryKey')->will($this->returnValue($expected)); $row = new Row($table, self::$languageRow); $this->assertSame($expected, $row->getPrimaryKey()); }
public function isRowEmpty(Row $row) { foreach ($this->getColumns() as $column) { if ($column->isRowIndexOccupied($row->getIndex())) { return false; } } return true; }
/** * Deletes a generic {@link Row} * * @param integer $id * @param string $table_name * @return True on success, false otherwise */ public static function deleteRow($id, $table_name) { $DbConnection = DbConnection::getInstance(); $Row = new Row($table_name, (int) $data["id_{$table_name}"], $DbConnection); if ($Row->delete()) { return false; } return true; }
/** Creates a new Markdown row. @param string $message contains the body. @param string $header could contain the headline. @return object **/ public static function genMarkdownRow($message, $header = '') { $panel = new TextPanel(''); $panel->setMode(TextPanel::MARKDOWN); $panel->setContent($message); $row = new Row($header); $row->addPanel($panel); return $row; }
/** * Write a Row to the File. The Fieldset of the Row must match the * * @param Row $row * * @throws Exception */ public function writeRow(Row $row) { if (!$row->isValid()) { throw new Exception('Cant add invalid row'); } if ($row->getFieldset() != $this->fieldset) { throw new Exception('Cant add row with different fieldset'); } $this->data .= $row->render() . "\r\n"; }
public function testFill() { $data = array('id' => 1); $row = new Row('user', $data, $this->phactory); $arr = $row->toArray(); $this->assertEquals($data, $arr); $data['name'] = null; $arr = $row->fill()->toArray(); $this->assertEquals($data, $arr); }
/** * Add an array of head items to the table * * @param array|Surface\Row $head * @return \Surface */ public function setHead($head) { if (!$head instanceof Row) { $head = new Row($head); } foreach ($head->getData() as $headItem) { $headItem->setElementType(Element::TH); } $this->_head = $head; return $this; }
/** * Parse a line into a row * * @param string $line * @param string $line * @return net.daringfireball.markdown.Row */ private function parseRow($line, $type) { if (null === ($cells = $this->cellsIn($line))) { return null; } $row = new Row(); foreach ($cells as $pos => $cell) { $alignment = isset($this->alignment[$pos]) ? $this->alignment[$pos] : null; $this->tokenize(new Line(trim($cell)), $row->add(new Cell($type, $alignment))); } return $row; }
public function getRow($n) { if ($n == 1) { return new Row(array(1)); } $thePreviousRow = $this->getRow($n - 1); $theRow = new Row(); for ($i = 0; $i < $n; $i++) { $theRow->set($i, $thePreviousRow->get($i - 1) + $thePreviousRow->get($i)); } return $theRow; }
/** * Render row item detail button * @param Row $row * @return Html */ public function renderButton($row) { $a = Html::el('a')->href($this->grid->link('getItemDetail!', ['id' => $row->getId()]))->data('toggle-detail', $row->getId())->data('toggle-detail-grid', $this->grid->getName()); $this->tryAddIcon($a, $this->getIcon(), $this->getText()); $a->addText($this->text); if ($this->title) { $a->title($this->grid->getTranslator()->translate($this->title)); } if ($this->class) { $a->class($this->class); } return $a; }
/** * Create a back reference * * @param $key * * @return $this * * @since 1.0.0 */ public function via($key) { if ($this->parent instanceof DatabaseTable) { $this->db->schema()->setReference($this->parent->getTable(), $this->table, $key); } return $this; }
/** * Test properties with boolean value */ public function testBooleanValue() { $object = new Row(); $properties = array('tblHeader' => true, 'cantSplit' => false, 'exactHeight' => true); foreach ($properties as $key => $value) { // set/get $set = "set{$key}"; $get = "get{$key}"; $expected = $value ? 1 : 0; $object->{$set}($value); $this->assertEquals($expected, $object->{$get}()); // setStyleValue $value = !$value; $expected = $value ? 1 : 0; $object->setStyleValue("{$key}", $value); $this->assertEquals($expected, $object->{$get}()); } }
/** * @param array $columns */ public function __construct(array $columns) { parent::__construct($columns); foreach ($columns as $key) { $name = str_replace('_', ' ', $key); $name = ucfirst($name); $this->setValue($key, $name); } }
/** * Render row item detail button * @param Row $row * @return Html */ public function renderButton($row) { $a = Html::el('a')->href($this->grid->link('getItemDetail!', ['id' => $row->getId()]))->data('toggle-detail', $row->getId())->data('toggle-detail-grid', $this->grid->getName()); if ($this->icon) { $a->add(Html::el('span')->class(DataGrid::$icon_prefix . $this->icon)); if (strlen($this->text)) { $a->add(' '); } } $a->add($this->text); if ($this->title) { $a->title($this->title); } if ($this->class) { $a->class($this->class); } return $a; }
/** * Load data to row * @param array $data * @return Row */ public function loadRow($data, $newInstance = false) { if ($data instanceof Row) { return $data; } if (!is_array($data)) { $data = array(); } if ($newInstance) { $row = $this->table->row(); $row->init($data); return $row; } if (null === $this->row) { $this->row = $this->table->row(); } $this->row->init($data); return $this->row; }
public function __set($key, $value) { if ($key == 'column') { $value = (int) $value; foreach ($this->cells as $row => $cell) { $this->cells[$row]->column = $value; } } parent::__set($key, $value); }
/** * Put Row * * @author WN * @param Row $content * @param int $offset * @return $this */ public function put(Row $content, $offset = 0) { if ($offset < 0) { $offset = $this->getWidth() + $offset; } if ($offset + $content->getWidth() > $this->getWidth()) { throw new \OutOfBoundsException('Row is to long to put in here'); } foreach ($content as $char) { $this->row[$offset++]->inherit($char); } return $this; }
protected function makeRow($attrs) { $row = new Row(); $row->setFormName($this->getName()); $row->setAttrs($attrs); $row->setValue($this->getValue($attrs['name'])); $row->setArgs($this->getArgs($attrs['name'])); return $row; }
public static function makeFromString($string, $color = null, $option = null, $bgcolor = null) { if (!is_string($string)) { throw new \InvalidArgumentException('Argument must be string'); } $ar = explode("\n", $string); $height = count($ar); $width = strlen(max($ar)); $obj = new self($width, $height, $color, $option, $bgcolor); $i = 0; foreach ($obj as $row) { $row->put(Row::makeFromString($ar[$i++], $color, $option, $bgcolor)); } return $obj; }
/** * 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; }
/** * Connects to the specified schema and assigns it to all models which need it. * * @param $schema schema * @return CDbConnection */ protected function connectDb($schema) { // Assign request $this->request = Yii::app()->getRequest(); // Check parameter if (is_null($schema)) { $this->db = null; return null; } // Connect to database $connectionString = 'mysql:host=' . Yii::app()->user->host . ';port=' . Yii::app()->user->port . ';dbname=' . $schema . '; charset=utf8'; $this->db = new CDbConnection($connectionString, utf8_decode(Yii::app()->user->name), utf8_decode(Yii::app()->user->password)); $this->db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES \'utf8\''); $this->db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET CHARACTER SET \'utf8\''); $this->db->charset = 'utf8'; $this->db->emulatePrepare = true; $this->db->active = true; // Schema name is set in connection string // $this->db->createCommand('USE ' . $this->db->quoteTableName($schema))->execute(); // Assign to all models which need it ActiveRecord::$db = Routine::$db = Row::$db = Trigger::$db = View::$db = $this->db; // Return connection return $this->db; }
/** * Add button to form * * @param array|Elements\Abstraction\Element $buttons * @return Form */ public function addButtonsRow($buttons = []) { if (!is_array($buttons)) { $buttons = [$buttons]; } $row = Row::forge()->addField($buttons); return $this->addContent($row); }
public function addMatrix($arr) { foreach ($arr as $rowCtn) { $row = new Row(); foreach ($rowCtn as $cellCtn) { $cell = new Cell($cellCtn); $row->addCell($cell); } $this->addRow($row); } }
public function actionSearch() { $operatorConfig = array('LIKE' => array('needsValue' => true), 'NOT LIKE' => array('needsValue' => true), '=' => array('needsValue' => true), '!=' => array('needsValue' => true), 'REGEXP' => array('needsValue' => "?"), 'NOT REGEXP' => array('needsValue' => "?"), 'IS NULL' => array('needsValue' => false), 'IS NOT NULL' => array('needsValue' => false)); $operators = array_keys($operatorConfig); $config = array_values($operatorConfig); Row::$db = $this->db; Row::$schema = $this->schema; Row::$table = $this->table; $row = new Row(); $commandBuilder = $this->db->getCommandBuilder(); if (isset($_POST['Row'])) { $criteria = new CDbCriteria(); $i = 0; foreach ($_POST['Row'] as $column => $value) { $operator = $operators[$_POST['operator'][$column]]; if (strlen($value) > 0) { $criteria->condition .= ($i > 0 ? ' AND ' : ' ') . $this->db->quoteColumnName($column) . ' ' . $operator . ' ' . $this->db->quoteValue($value); $i++; } elseif (isset($_POST['operator'][$column]) && $config[$_POST['operator'][$column]]['needsValue'] === false) { $criteria->condition .= ($i > 0 ? ' AND ' : ' ') . $this->db->quoteColumnName($column) . ' ' . $operator; $i++; } } $query = $this->db->getCommandBuilder()->createFindCommand($this->table, $criteria)->getText(); } elseif (isset($_POST['query'])) { $query = $_POST['query']; } if (isset($query)) { $browsePage = new BrowsePage(); $browsePage->schema = $this->schema; $browsePage->table = $this->table; $browsePage->db = $this->db; $browsePage->route = 'schema/' . $this->schema . '/tables/' . $this->table . '/browse'; $browsePage->formTarget = 'schema/' . $this->schema . '/tables/' . $this->table . '/sql'; $browsePage->execute = true; $browsePage->query = $query; $browsePage->run(); $this->render('../global/browse', array('model' => $browsePage)); } else { $this->render('../table/search', array('row' => $row, 'operators' => $operators)); } }
$default_zoom = 14; $start_zoom = 12; $location_marker = "mm_20_yellow.png"; $station_marker_img = "mm_20_blue.png"; $transfer_marker_img = "mm_20_orange.png"; $start_marker_img = "mm_20_green.png"; $end_marker_img = "mm_20_red.png"; $WALKING_SPEED = 2 / 3600; $debug = false; $logging = false; $current_url = $_SERVER['PHP_SELF']; $slogan = getSlogan(); $linksTable = new Table("linkstable"); $homeCell = new Cell("link", new Link("/", "home")); $aboutCell = new Cell("link", new Link("/about.php", "about")); $linksRow = new Row(); $linksRow->addCell($homeCell); $linksRow->addCell($aboutCell); $linksTable->addRow($linksRow); $linksDiv = new Div("about", "noselect", null, $linksTable); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta name="Description" content="<?php echo $description; ?> " /> <meta name="Keywords" content="<?php echo $keywords; ?>
print "<br><br> Длина массива:" . count($title_table_7[text]); print "<br>Общая Длина массива:" . ($q = count($title_table_7, COUNT_RECURSIVE) . "<br>"); print_r($title_table_7); function __autoload($class_name) { include 'Classes/class-' . $class_name . '.php'; } // Вывод таблицы echo "<table>"; // Вывод первой строки заголовка таблицы $row_table = new Row($title_table_1); $row_table->view_row(); // Вывод второй строки заголовка таблицы $row_table = new Row($title_table_2); $row_table->view_row(); // Вывод третьей строки заголовка таблицы $row_table = new Row($title_table_3); $row_table->view_row(); // Вывод четвертой строки заголовка таблицы $row_table = new Row($title_table_4); $row_table->view_row(); // Вывод пятой строки заголовка таблицы $row_table = new Row($title_table_5); $row_table->view_row(); // Вывод шестой строки заголовка таблицы $row_table = new Row($title_table_6); $row_table->view_row(); // Вывод седьмой строки заголовка таблицы $row_table = new Row($title_table_7); $row_table->view_row(); echo "</table>";
public function queryObject($q) { $_start = $this->_getTime(); $qTab = explode(' ', Inflector::lower($q)); $qFirst = $qTab[0]; $rowAffected = $qFirst == 'insert' || $qFirst == 'update' || $qFirst == 'delete'; $res = $this->_query($q); if (is_array($res)) { $count = count($res); } else { $count = $res->rowCount(); } $this->_incQueries($_start); if (true === $rowAffected) { return $count; } if (false === $res) { return null; } if ($count == 0) { return null; } else { $collection = new QueryCollection(); foreach ($res as $row) { $obj = new Row(); $collection[] = $obj->populate($row); } return $collection; } }