├── js ├── support.js ├── loadgoogle.js ├── htmldrawer.js ├── datatablesdrawer.js └── googlechartdrawer.js ├── google-visualization ├── .gitignore ├── Base │ ├── ErrorMessages │ │ ├── en.txt │ │ ├── en_US.txt │ │ └── root.txt │ ├── StatusType.php │ ├── TypeMismatchException.php │ ├── InvalidQueryException.php │ ├── Warning.php │ ├── TextFormat.php │ ├── DataSourceException.php │ ├── OutputType.php │ ├── ReasonType.php │ ├── BooleanFormat.php │ ├── ResponseStatus.php │ ├── LocaleUtil.php │ └── MessagesEnum.php ├── LICENSE.md ├── Query │ ├── SortOrder.php │ ├── ColumnLookup.php │ ├── Engine │ │ ├── RowTitle.php │ │ ├── AggregationPath.php │ │ ├── MetaTable.php │ │ ├── ColumnIndices.php │ │ ├── ScalarFunctionColumnTitle.php │ │ ├── TableRowComparator.php │ │ ├── GroupingComparators.php │ │ ├── TableAggregator.php │ │ ├── AggregationTree.php │ │ └── AggregationNode.php │ ├── AggregationType.php │ ├── ScalarFunction │ │ ├── ScalarFunction.php │ │ ├── TimeComponent.php │ │ ├── CurrentDateTime.php │ │ ├── Constant.php │ │ ├── ConcatenationWithSeparator.php │ │ ├── Lower.php │ │ ├── Upper.php │ │ ├── AbsoluteValue.php │ │ ├── Concatenation.php │ │ ├── Left.php │ │ ├── Right.php │ │ ├── ToNumber.php │ │ ├── Sum.php │ │ ├── Modulo.php │ │ ├── Product.php │ │ ├── Difference.php │ │ ├── Round.php │ │ ├── Quotient.php │ │ ├── DateDiff.php │ │ ├── ToDate.php │ │ └── ToDateBoundary.php │ ├── AbstractColumn.php │ ├── QueryFilter.php │ ├── ColumnSort.php │ ├── DataTableColumnLookup.php │ ├── QueryOptions.php │ ├── GenericColumnLookup.php │ ├── Parser │ │ └── QueryBuilder.php │ ├── ColumnIsNullFilter.php │ ├── QueryPivot.php │ ├── QueryGroup.php │ ├── QuerySelection.php │ ├── NegationFilter.php │ ├── QueryFormat.php │ ├── SimpleColumn.php │ ├── QueryLabels.php │ ├── ColumnColumnFilter.php │ ├── QuerySort.php │ ├── ColumnValueFilter.php │ ├── ComparisonFilter.php │ └── CompoundFilter.php ├── Util │ ├── Pdo │ │ └── PdoDataSourceHelperInterface.php │ ├── Comparator.php │ ├── Set.php │ ├── TreeSet.php │ ├── TreeMap.php │ └── Map.php ├── DataTable │ ├── Value │ │ ├── NullValueException.php │ │ ├── TimeOfDayValue.php │ │ ├── ValueType.php │ │ ├── DateTimeValue.php │ │ ├── NumberValue.php │ │ ├── BooleanValue.php │ │ ├── Value.php │ │ ├── TextValue.php │ │ └── DateValue.php │ ├── TableRow.php │ ├── TableCell.php │ └── ColumnDescription.php ├── Capabilities.php ├── DataTableGenerator.php ├── DataSource.php ├── QueryPair.php └── Render │ └── CsvRenderer.php ├── uninstall.php ├── LICENSE ├── css └── mqttcogs_styles.css ├── README.md ├── sskaje ├── mqtt │ ├── Exception.php │ ├── Exception │ │ ├── BadUTF8.php │ │ ├── ConnectError.php │ │ ├── NetworkError.php │ │ ├── Protocol.php │ │ └── UTF8Null.php │ ├── Message │ │ ├── PINGREQ.php │ │ ├── PUBCOMP.php │ │ ├── DISCONNECT.php │ │ ├── PUBACK.php │ │ ├── UNSUBACK.php │ │ ├── PUBREC.php │ │ ├── PUBREL.php │ │ ├── CONNACK.php │ │ ├── PINGRESP.php │ │ ├── Header │ │ │ ├── PINGRESP.php │ │ │ ├── PINGREQ.php │ │ │ ├── SUBACK.php │ │ │ ├── SUBSCRIBE.php │ │ │ ├── UNSUBACK.php │ │ │ ├── DISCONNECT.php │ │ │ ├── UNSUBSCRIBE.php │ │ │ ├── PUBREC.php │ │ │ ├── PUBREL.php │ │ │ ├── PUBACK.php │ │ │ └── PUBCOMP.php │ │ ├── UNSUBSCRIBE.php │ │ └── SUBACK.php │ ├── PacketIdentifierStoreInterface.php │ ├── PacketIdentifierStore │ │ └── PhpStatic.php │ ├── PacketIdentifier.php │ └── MessageHandler.php └── autoload.example.php ├── mqtt-cogs_init.php ├── MqttCogs_ShortCodeLoader.php ├── MqttCogs_ShortCodeScriptLoader.php └── AutoLoadByNamespace.php /js/support.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /google-visualization/.gitignore: -------------------------------------------------------------------------------- 1 | Base/ErrorMessages/*.res 2 | -------------------------------------------------------------------------------- /google-visualization/Base/ErrorMessages/en.txt: -------------------------------------------------------------------------------- 1 | en { 2 | } 3 | -------------------------------------------------------------------------------- /google-visualization/Base/ErrorMessages/en_US.txt: -------------------------------------------------------------------------------- 1 | en_US { 2 | } 3 | -------------------------------------------------------------------------------- /js/loadgoogle.js: -------------------------------------------------------------------------------- 1 | google.charts.load("current", {"mapsApiKey":params.mapsApiKey,"packages":["corechart","bar","table","gauge","map","imagesparkline"]}); 2 | -------------------------------------------------------------------------------- /google-visualization/LICENSE.md: -------------------------------------------------------------------------------- 1 | This is a derivative of [google-visualization-java](https://code.google.com/p/google-visualization-java/), which uses the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) 2 | -------------------------------------------------------------------------------- /google-visualization/Query/SortOrder.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /google-visualization/Util/Pdo/PdoDataSourceHelperInterface.php: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /google-visualization/Base/StatusType.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/NullValueException.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /google-visualization/Query/ColumnLookup.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /google-visualization/Query/Engine/RowTitle.php: -------------------------------------------------------------------------------- 1 | values = $values; 11 | } 12 | } 13 | ?> 14 | -------------------------------------------------------------------------------- /google-visualization/Query/AggregationType.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /google-visualization/Util/Comparator.php: -------------------------------------------------------------------------------- 1 | $method; 8 | return call_user_func_array($closure, $args); 9 | } 10 | } 11 | ?> 12 | -------------------------------------------------------------------------------- /google-visualization/Capabilities.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /google-visualization/DataTableGenerator.php: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /google-visualization/Base/TypeMismatchException.php: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /google-visualization/Base/InvalidQueryException.php: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /google-visualization/Util/Set.php: -------------------------------------------------------------------------------- 1 | getArrayCopy(); 9 | if (!in_array($e, $a)) 10 | { 11 | $this->append($e); 12 | return TRUE; 13 | } 14 | return FALSE; 15 | } 16 | } 17 | ?> 18 | -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/TimeOfDayValue.php: -------------------------------------------------------------------------------- 1 | dateTime->format("G"); 14 | } 15 | } 16 | ?> 17 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/ScalarFunction.php: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/TimeComponent.php: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /google-visualization/DataSource.php: -------------------------------------------------------------------------------- 1 | isRestrictedAccessMode()); 9 | } 10 | 11 | protected function isRestrictedAccessMode() 12 | { 13 | return TRUE; 14 | } 15 | 16 | public function getCapabilities() 17 | { 18 | return Capabilities::NONE; 19 | } 20 | } 21 | ?> 22 | -------------------------------------------------------------------------------- /google-visualization/Util/TreeSet.php: -------------------------------------------------------------------------------- 1 | comparator = $comparator; 12 | } 13 | 14 | public function add($e) 15 | { 16 | if (parent::add($e)) 17 | { 18 | $this->uasort($this->comparator->compare); 19 | return TRUE; 20 | } 21 | return FALSE; 22 | } 23 | } 24 | ?> 25 | -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/ValueType.php: -------------------------------------------------------------------------------- 1 | getConstants(); 19 | } 20 | } 21 | ?> 22 | -------------------------------------------------------------------------------- /google-visualization/Query/AbstractColumn.php: -------------------------------------------------------------------------------- 1 | getCell($lookup, $row)->getValue(); 11 | } 12 | 13 | public function getCell(ColumnLookup $lookup, TableRow $row) 14 | { 15 | $columnIndex = $lookup->getColumnIndex($this); 16 | return $row->getCell($columnIndex); 17 | } 18 | } 19 | ?> 20 | -------------------------------------------------------------------------------- /google-visualization/Query/QueryFilter.php: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /google-visualization/Base/Warning.php: -------------------------------------------------------------------------------- 1 | reasonType = $reasonType; 13 | $this->messageToUser = $messageToUser; 14 | } 15 | 16 | public function getReasonType() 17 | { 18 | return $this->reasonType; 19 | } 20 | 21 | public function getMessage() 22 | { 23 | return $this->messageToUser; 24 | } 25 | } 26 | ?> 27 | -------------------------------------------------------------------------------- /google-visualization/Base/TextFormat.php: -------------------------------------------------------------------------------- 1 | 26 | -------------------------------------------------------------------------------- /uninstall.php: -------------------------------------------------------------------------------- 1 | prefix}data"); 14 | //error_log("DROP TABLE IF EXISTS {$wpdb->prefix}buffer"); 15 | 16 | $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}mqttcogs_plugin_buffer"); 17 | $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}mqttcogs_plugin_data"); 18 | ?> -------------------------------------------------------------------------------- /google-visualization/Base/DataSourceException.php: -------------------------------------------------------------------------------- 1 | messageToUser = $messageToUser; 12 | $this->reasonType = $reasonType; 13 | parent::__construct($messageToUser); 14 | } 15 | 16 | public function getMessageToUser() 17 | { 18 | return $this->messageToUser; 19 | } 20 | 21 | public function getReasonType() 22 | { 23 | return $this->reasonType; 24 | } 25 | } 26 | ?> 27 | -------------------------------------------------------------------------------- /google-visualization/Query/ColumnSort.php: -------------------------------------------------------------------------------- 1 | column = $column; 11 | $this->order = $order; 12 | } 13 | 14 | public function getColumn() 15 | { 16 | return $this->column; 17 | } 18 | 19 | public function getOrder() 20 | { 21 | return $this->order; 22 | } 23 | 24 | public function toQueryString() 25 | { 26 | return $this->column->toQueryString() . ($this->order == SortOrder::DESCENDING ? " DESC" : ""); 27 | } 28 | } 29 | ?> 30 | -------------------------------------------------------------------------------- /google-visualization/Base/OutputType.php: -------------------------------------------------------------------------------- 1 | getConstants())) 25 | { 26 | return $code; 27 | } 28 | } 29 | } 30 | ?> 31 | -------------------------------------------------------------------------------- /google-visualization/Query/DataTableColumnLookup.php: -------------------------------------------------------------------------------- 1 | table = $table; 13 | } 14 | 15 | public function getColumnIndex(AbstractColumn $column) 16 | { 17 | return $this->table->getColumnIndex($column->getId()); 18 | } 19 | 20 | public function containsColumn(AbstractColumn $column) 21 | { 22 | return $this->table->containsColumn($column->getId()); 23 | } 24 | } 25 | ?> 26 | -------------------------------------------------------------------------------- /google-visualization/QueryPair.php: -------------------------------------------------------------------------------- 1 | dataSourceQuery = $dataSourceQuery; 14 | $this->completionQuery = $completionQuery; 15 | } 16 | 17 | public function getDataSourceQuery() 18 | { 19 | return $this->dataSourceQuery; 20 | } 21 | 22 | public function getCompletionQuery() 23 | { 24 | return $this->completionQuery; 25 | } 26 | } 27 | ?> 28 | -------------------------------------------------------------------------------- /google-visualization/Query/Engine/AggregationPath.php: -------------------------------------------------------------------------------- 1 | values = array(); 13 | } 14 | 15 | public function add(Value $value) 16 | { 17 | $this->values[] = $value; 18 | return $this; 19 | } 20 | 21 | public function getValues() 22 | { 23 | return $this->values; 24 | } 25 | 26 | public function reverse() 27 | { 28 | $this->values = array_reverse($this->values); 29 | return $this; 30 | } 31 | } 32 | ?> 33 | -------------------------------------------------------------------------------- /google-visualization/Query/QueryOptions.php: -------------------------------------------------------------------------------- 1 | noValues = FALSE; 12 | $this->noFormat = FALSE; 13 | } 14 | 15 | public function setNoValues($noValues) 16 | { 17 | $this->noValues = $noValues; 18 | return $this; 19 | } 20 | 21 | public function setNoFormat($noFormat) 22 | { 23 | $this->noFormat = $noFormat; 24 | return $this; 25 | } 26 | 27 | public function isDefault() 28 | { 29 | return !$this->noFormat && !$this->noValues; 30 | } 31 | } 32 | ?> 33 | -------------------------------------------------------------------------------- /google-visualization/DataTable/TableRow.php: -------------------------------------------------------------------------------- 1 | cells[] = $cell; 14 | return $this; 15 | } 16 | 17 | public function getCells() 18 | { 19 | return $this->cells; 20 | } 21 | 22 | public function setCell($index, $cell) 23 | { 24 | $this->cells[$index] = $cell; 25 | return $this; 26 | } 27 | 28 | public function getCell($index) 29 | { 30 | return $this->cells[$index]; 31 | } 32 | } 33 | ?> 34 | -------------------------------------------------------------------------------- /google-visualization/Util/TreeMap.php: -------------------------------------------------------------------------------- 1 | comparator = $comparator; 12 | } 13 | 14 | public function comparator() 15 | { 16 | return $this->comparator; 17 | } 18 | 19 | public function put($key, $value) 20 | { 21 | parent::put($key, $value); 22 | uasort($this->keys, array($this->comparator, "compare")); 23 | $sortedValues = array(); 24 | foreach ($this->keys as $i => $key) 25 | { 26 | $sortedValues[] = $this->values[$i]; 27 | } 28 | $this->keys = array_values($this->keys); 29 | $this->values = $sortedValues; 30 | return $this; 31 | } 32 | } 33 | ?> 34 | -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/DateTimeValue.php: -------------------------------------------------------------------------------- 1 | dateTime->format("H"); 12 | } 13 | 14 | public function getMinute() 15 | { 16 | return (int) $this->dateTime->format("i"); 17 | } 18 | 19 | public function getSecond() 20 | { 21 | return (int) $this->dateTime->format("s"); 22 | } 23 | 24 | public function getMillisecond() 25 | { 26 | return (int) $this->dateTime->format("u") * 1000; 27 | } 28 | 29 | public function getType() 30 | { 31 | return ValueType::DATETIME; 32 | } 33 | } 34 | ?> 35 | -------------------------------------------------------------------------------- /google-visualization/Query/Engine/MetaTable.php: -------------------------------------------------------------------------------- 1 | data = new Map(); 14 | } 15 | 16 | public function put(RowTitle $rowTitle, ColumnTitle $columnTitle, TableCell $cell) 17 | { 18 | $rowData = $this->data->get($rowTitle); 19 | if (is_null($rowData)) 20 | { 21 | $rowData = new Map(); 22 | $this->data->put($rowTitle, $rowData); 23 | } 24 | $rowData->put($columnTitle, $cell); 25 | return $this; 26 | } 27 | 28 | public function getRow(RowTitle $rowTitle) 29 | { 30 | return $this->data->get($rowTitle); 31 | } 32 | } 33 | ?> 34 | -------------------------------------------------------------------------------- /google-visualization/Base/ReasonType.php: -------------------------------------------------------------------------------- 1 | 25 | -------------------------------------------------------------------------------- /google-visualization/Query/GenericColumnLookup.php: -------------------------------------------------------------------------------- 1 | columns = array(); 12 | $this->indices = array(); 13 | } 14 | 15 | public function clear() 16 | { 17 | $this->columns = array(); 18 | $this->indices = array(); 19 | return $this; 20 | } 21 | 22 | public function put(AbstractColumn $col, $index) 23 | { 24 | $this->columns[] = $col; 25 | $this->indices[] = $index; 26 | return $this; 27 | } 28 | 29 | public function getColumnIndex(AbstractColumn $column) 30 | { 31 | return $this->indices[array_search($column, $this->columns)]; 32 | } 33 | 34 | public function containsColumn(AbstractColumn $column) 35 | { 36 | return in_array($column, $this->columns); 37 | } 38 | } 39 | ?> 40 | -------------------------------------------------------------------------------- /google-visualization/Query/Engine/ColumnIndices.php: -------------------------------------------------------------------------------- 1 | columns = array(); 14 | $this->indices = array(); 15 | } 16 | 17 | public function put(AbstractColumn $col, $index) 18 | { 19 | $this->columns[] = $col; 20 | $this->indices[] = $index; 21 | return $this; 22 | } 23 | 24 | public function getColumnIndices(AbstractColumn $col) 25 | { 26 | $a = array(); 27 | foreach (array_keys($this->columns, $col) as $i) 28 | { 29 | $a[] = $this->indices[$i]; 30 | } 31 | return $a; 32 | } 33 | 34 | public function clear() 35 | { 36 | $this->columns = array(); 37 | $this->indices = array(); 38 | return $this; 39 | } 40 | } 41 | ?> 42 | -------------------------------------------------------------------------------- /google-visualization/Query/Parser/QueryBuilder.php: -------------------------------------------------------------------------------- 1 | getMessage(); 23 | throw new InvalidQueryException(MessagesEnum::getMessageWithArgs(MessagesEnum::PARSE_ERROR, $ulocale, $messageToUserAndLog)); 24 | } 25 | $query->setLocaleForUserMessages($ulocale); 26 | $query->validate(); 27 | } 28 | return $query; 29 | } 30 | } 31 | ?> 32 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/CurrentDateTime.php: -------------------------------------------------------------------------------- 1 | 42 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Constant.php: -------------------------------------------------------------------------------- 1 | value = $value; 13 | } 14 | 15 | public function getFunctionName() 16 | { 17 | return $this->value->toQueryString(); 18 | } 19 | 20 | public function evaluate($values) 21 | { 22 | return $this->value; 23 | } 24 | 25 | public function getReturnType($types) 26 | { 27 | return $this->value->getType(); 28 | } 29 | 30 | public function validateParameters($types) 31 | { 32 | if (count($types) != 0) 33 | { 34 | throw new InvalidQueryException("The constant function should not get any parameters"); 35 | } 36 | return $this; 37 | } 38 | 39 | public function toQueryString($argumentsQueryStrings) 40 | { 41 | return $this->value->toQueryString(); 42 | } 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Chris Knowles 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/ConcatenationWithSeparator.php: -------------------------------------------------------------------------------- 1 | 42 | -------------------------------------------------------------------------------- /google-visualization/DataTable/TableCell.php: -------------------------------------------------------------------------------- 1 | value = $value; 15 | $this->formattedValue = $formattedValue; 16 | } 17 | 18 | public function getValue() 19 | { 20 | return $this->value; 21 | } 22 | 23 | public function getFormattedValue() 24 | { 25 | return $this->formattedValue; 26 | } 27 | 28 | public function setFormattedValue($formattedValue) 29 | { 30 | $this->formattedValue = $formattedValue; 31 | return $this; 32 | } 33 | 34 | public function getType() 35 | { 36 | return $this->value->getType(); 37 | } 38 | 39 | public function isNull() 40 | { 41 | return $this->value->isNull(); 42 | } 43 | 44 | public function getCustomProperties() 45 | { 46 | if (is_null($this->customProperties)) 47 | { 48 | return array(); 49 | } 50 | return $this->customProperties; 51 | } 52 | } 53 | ?> 54 | -------------------------------------------------------------------------------- /google-visualization/Query/ColumnIsNullFilter.php: -------------------------------------------------------------------------------- 1 | column = $column; 14 | } 15 | 16 | public function getColumn() 17 | { 18 | return $this->column; 19 | } 20 | 21 | public function getAllColumnIds() 22 | { 23 | return $this->column->getAllSimpleColumnIds(); 24 | } 25 | 26 | public function getScalarFunctionColumns() 27 | { 28 | return $this->column->getAllScalarFunctionColumns(); 29 | } 30 | 31 | public function getAggregationColumns() 32 | { 33 | return $this->column->getAllAggregationColumns(); 34 | } 35 | 36 | public function isMatch(DataTable $table, TableRow $row) 37 | { 38 | $lookup = new DataTableColumnLookup($table); 39 | return is_null($this->column->getValue($lookup, $row)); 40 | } 41 | 42 | public function toQueryString() 43 | { 44 | return $this->column->toQueryString() . " IS NULL"; 45 | } 46 | } 47 | ?> 48 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Lower.php: -------------------------------------------------------------------------------- 1 | getValue())); 19 | } 20 | 21 | public function getReturnType($types) 22 | { 23 | return ValueType::TEXT; 24 | } 25 | 26 | public function validateParameters($types) 27 | { 28 | if (count($types) != 1) 29 | { 30 | throw new InvalidQueryException(self::FUNCTION_NAME . " requires 1 parameter"); 31 | } 32 | if ($types[0] != ValueType::TEXT) 33 | { 34 | throw new InvalidQueryException(self::FUNCTION_NAME . " takes a text paramter"); 35 | } 36 | return $this; 37 | } 38 | 39 | public function toQueryString($argumentsQueryStrings) 40 | { 41 | return self::FUNCTION_NAME . "(" . $argumentsQueryStrings[0] . ")"; 42 | } 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Upper.php: -------------------------------------------------------------------------------- 1 | getValue())); 19 | } 20 | 21 | public function getReturnType($types) 22 | { 23 | return ValueType::TEXT; 24 | } 25 | 26 | public function validateParameters($types) 27 | { 28 | if (count($types) != 1) 29 | { 30 | throw new InvalidQueryException(self::FUNCTION_NAME . " requires 1 parameter"); 31 | } 32 | if ($types[0] != ValueType::TEXT) 33 | { 34 | throw new InvalidQueryException(self::FUNCTION_NAME . " takes a text paramter"); 35 | } 36 | return $this; 37 | } 38 | 39 | public function toQueryString($argumentsQueryStrings) 40 | { 41 | return self::FUNCTION_NAME . "(" . $argumentsQueryStrings[0] . ")"; 42 | } 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/AbsoluteValue.php: -------------------------------------------------------------------------------- 1 | getValue())); 19 | } 20 | 21 | public function getReturnType($types) 22 | { 23 | return ValueType::Number; 24 | } 25 | 26 | public function validateParameters($types) 27 | { 28 | if (count($types) != 1) 29 | { 30 | throw new InvalidQueryException(self::FUNCTION_NAME . " requires 1 parameter"); 31 | } 32 | if ($types[0] != ValueType::NUMBER) 33 | { 34 | throw new InvalidQueryException(self::FUNCTION_NAME . " takes a number paramter"); 35 | } 36 | return $this; 37 | } 38 | 39 | public function toQueryString($argumentsQueryString) 40 | { 41 | return self::FUNCTION_NAME + "(" + $argumentsQueryStrings[0] + ")"; 42 | } 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /google-visualization/Query/QueryPivot.php: -------------------------------------------------------------------------------- 1 | columns = array(); 11 | } 12 | 13 | public function addColumn(AbstractColumn $column) 14 | { 15 | $this->columns[] = $column; 16 | return $this; 17 | } 18 | 19 | public function getColumnIds() 20 | { 21 | $columnIds = array(); 22 | foreach ($this->columns as $col) 23 | { 24 | $columnIds[] = $col->getId(); 25 | } 26 | return $columnIds; 27 | } 28 | 29 | public function getSimpleColumnIds() 30 | { 31 | $columnIds = array(); 32 | foreach ($this->columns as $col) 33 | { 34 | $columnIds[] = $col->getId(); 35 | } 36 | return $columnIds; 37 | } 38 | 39 | public function getColumns() 40 | { 41 | return $this->columns; 42 | } 43 | 44 | public function getScalarFunctionColumns() 45 | { 46 | $scalarFunctionColumns = array(); 47 | foreach ($this->columns as $col) 48 | { 49 | $scalarFunctionColumns = array_merge($scalarFunctionColumns, $col->getAllScalarFunctionColumns()); 50 | } 51 | return $scalarFunctionColumns; 52 | } 53 | } 54 | ?> 55 | -------------------------------------------------------------------------------- /google-visualization/DataTable/ColumnDescription.php: -------------------------------------------------------------------------------- 1 | id = $id; 15 | $this->type = $type; 16 | $this->label = $label; 17 | $this->pattern = ""; 18 | } 19 | 20 | public function getId() 21 | { 22 | return $this->id; 23 | } 24 | 25 | public function getType() 26 | { 27 | return $this->type; 28 | } 29 | 30 | public function getLabel() 31 | { 32 | return $this->label; 33 | } 34 | 35 | public function getPattern() 36 | { 37 | return $this->pattern; 38 | } 39 | 40 | public function setPattern($pattern) 41 | { 42 | $this->pattern = $pattern; 43 | return $this; 44 | } 45 | 46 | public function setLabel($label) 47 | { 48 | $this->label = $label; 49 | return $this; 50 | } 51 | 52 | public function getCustomProperties() 53 | { 54 | if (is_null($this->customProperties)) 55 | { 56 | return array(); 57 | } 58 | return $this->customProperties; 59 | } 60 | } 61 | ?> 62 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Concatenation.php: -------------------------------------------------------------------------------- 1 | isNull()) 22 | { 23 | return TextValue::getNullValue(); 24 | } 25 | $c .= $value->getValue(); 26 | } 27 | return new TextValue($c); 28 | } 29 | 30 | public function getReturnType($types) 31 | { 32 | return ValueType::TEXT; 33 | } 34 | 35 | public function validateParameters($types) 36 | { 37 | if (count($types) == 0) 38 | { 39 | throw new InvalidQueryException("The function " . self::FUNCTION_NAME . " requires at least one parameter"); 40 | } 41 | return $this; 42 | } 43 | 44 | public function toQueryString($argumentsQueryStrings) 45 | { 46 | return "CONCAT(" . implode(",", $argumentsQueryStrings) . ")"; 47 | } 48 | } 49 | ?> 50 | -------------------------------------------------------------------------------- /google-visualization/Query/Engine/ScalarFunctionColumnTitle.php: -------------------------------------------------------------------------------- 1 | containsColumn($column->getId())) 14 | { 15 | $label .= $originalTable->getColumnDescription($column->getId())->getLabel(); 16 | } else 17 | { 18 | if ($column instanceof AggregationColumn) 19 | { 20 | $label .= $originalTable->getColumnDescription($column->getAggregatedColumn()->getId())->getLabel(); 21 | } else 22 | { 23 | $scalarFunctionColumn = $column; 24 | $columns = $scalarFunctionColumn->getColumns(); 25 | $label .= $scalarFunctionColumn->getFunction()->getFunctionName() . "("; 26 | foreach ($columns as $abstractColumn) 27 | { 28 | $label .= self::getColumnDescriptionLabel($originalTable, $abstractColumn); 29 | } 30 | $label .= ")"; 31 | } 32 | } 33 | return $label; 34 | } 35 | } 36 | ?> 37 | -------------------------------------------------------------------------------- /google-visualization/Query/QueryGroup.php: -------------------------------------------------------------------------------- 1 | columns = array(); 11 | } 12 | 13 | public function addColumn(AbstractColumn $column) 14 | { 15 | $this->columns[] = $column; 16 | return $this; 17 | } 18 | 19 | public function getColumnIds() 20 | { 21 | $columnIds = array(); 22 | foreach ($this->columns as $col) 23 | { 24 | $columnIds[] = $col->getId(); 25 | } 26 | return $columnIds; 27 | } 28 | 29 | public function getSimpleColumnIds() 30 | { 31 | $columnIds = array(); 32 | foreach ($this->columns as $col) 33 | { 34 | $columnIds = array_merge($columnIds, $col->getAllSimpleColumnIds()); 35 | } 36 | return $columnIds; 37 | } 38 | 39 | public function getScalarFunctionColumns() 40 | { 41 | $scalarFunctionColumns = array(); 42 | foreach ($this->columns as $col) 43 | { 44 | $scalarFunctionColumns = array_merge($scalarFunctionColumns, $col->getAllScalarFunctionColumns()); 45 | } 46 | return $scalarFunctionColumns; 47 | } 48 | 49 | public function getColumns() 50 | { 51 | return $this->columns; 52 | } 53 | 54 | public function toQueryString() 55 | { 56 | return Query::columnListToQueryString($this->columns); 57 | } 58 | } 59 | ?> 60 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Left.php: -------------------------------------------------------------------------------- 1 | getValue(), 0, $values[1]->getValue())); 19 | } 20 | 21 | public function getReturnType($types) 22 | { 23 | return ValueType::TEXT; 24 | } 25 | 26 | public function validateParameters($types) 27 | { 28 | if (count($types) != 2) 29 | { 30 | throw new InvalidQueryException(self::FUNCTION_NAME . " requires 2 parameter"); 31 | } 32 | if ($types[0] != ValueType::TEXT) 33 | { 34 | throw new InvalidQueryException(self::FUNCTION_NAME . " takes a text parameter"); 35 | } 36 | if ($types[1] != ValueType::NUMBER) 37 | { 38 | throw new InvalidQueryException(self::FUNCTION_NAME . " takes a numeric parameter"); 39 | } 40 | return $this; 41 | } 42 | 43 | public function toQueryString($argumentsQueryStrings) 44 | { 45 | return self::FUNCTION_NAME . "(" . $argumentsQueryStrings[0] . ", " . $argumentsQueryStrings[1] . ")"; 46 | } 47 | } 48 | ?> 49 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Right.php: -------------------------------------------------------------------------------- 1 | getValue(), -$values[1]->getValue())); 19 | } 20 | 21 | public function getReturnType($types) 22 | { 23 | return ValueType::TEXT; 24 | } 25 | 26 | public function validateParameters($types) 27 | { 28 | if (count($types) != 2) 29 | { 30 | throw new InvalidQueryException(self::FUNCTION_NAME . " requires 2 parameter"); 31 | } 32 | if ($types[0] != ValueType::TEXT) 33 | { 34 | throw new InvalidQueryException(self::FUNCTION_NAME . " takes a text parameter"); 35 | } 36 | if ($types[1] != ValueType::NUMBER) 37 | { 38 | throw new InvalidQueryException(self::FUNCTION_NAME . " takes a numeric parameter"); 39 | } 40 | return $this; 41 | } 42 | 43 | public function toQueryString($argumentsQueryStrings) 44 | { 45 | return self::FUNCTION_NAME . "(" . $argumentsQueryStrings[0] . ", " . $argumentsQueryStrings[1] . ")"; 46 | } 47 | } 48 | ?> 49 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/ToNumber.php: -------------------------------------------------------------------------------- 1 | getType()) 22 | { 23 | case ValueType::TEXT: 24 | echo $value; 25 | $numberValue = new NumberValue($value); 26 | echo 'done'; 27 | break; 28 | 29 | default: 30 | throw new RuntimeException("Value type was not found: " . $value->getType()); 31 | } 32 | return $numberValue; 33 | } 34 | 35 | public function getReturnType($types) 36 | { 37 | return ValueType::NUMBER; 38 | } 39 | 40 | public function validateParameters($types) 41 | { 42 | if ($types[0] != ValueType::TEXT) 43 | { 44 | throw new InvalidQueryException(self::FUNCTION_NAME . " takes a text parameter"); 45 | } 46 | return $this; 47 | } 48 | 49 | public function toQueryString($argumentsQueryStrings) 50 | { 51 | return "cast(".$argumentsQueryStrings[0]." as DECIMAL)"; 52 | /* self::FUNCTION_NAME . "(" . $argumentsQueryStrings[0] . ")";*/ 53 | } 54 | } 55 | ?> 56 | -------------------------------------------------------------------------------- /google-visualization/Query/QuerySelection.php: -------------------------------------------------------------------------------- 1 | columns = array(); 11 | } 12 | 13 | public function isEmpty() 14 | { 15 | return !count($this->columns); 16 | } 17 | 18 | public function addColumn(AbstractColumn $column) 19 | { 20 | $this->columns[] = $column; 21 | return $this; 22 | } 23 | 24 | public function getColumns() 25 | { 26 | return $this->columns; 27 | } 28 | 29 | public function getAggregationColumns() 30 | { 31 | $result = array(); 32 | foreach ($this->columns as $col) 33 | { 34 | $result = array_merge($result, $col->getAllAggregationColumns()); 35 | } 36 | return $result; 37 | } 38 | 39 | public function getSimpleColumns() 40 | { 41 | $result = array(); 42 | foreach ($this->columns as $col) 43 | { 44 | $result = array_merge($result, $col->getAllSimpleColumns()); 45 | } 46 | return $result; 47 | } 48 | 49 | public function getScalarFunctionColumns() 50 | { 51 | $result = array(); 52 | foreach ($this->columns as $col) 53 | { 54 | $result = array_merge($result, $col->getAllScalarFunctionColumns()); 55 | } 56 | return $result; 57 | } 58 | 59 | public function toQueryString() 60 | { 61 | return Query::columnListToQueryString($this->columns); 62 | } 63 | } 64 | ?> 65 | -------------------------------------------------------------------------------- /css/mqttcogs_styles.css: -------------------------------------------------------------------------------- 1 | .group-card { 2 | padding-top: 0px; 3 | padding-right: 5px; 4 | background-color: #f2f2f2; 5 | padding-left: 5px; 6 | border-radius: 2px; 7 | box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12), 0 3px 1px -2px rgba(0,0,0,0.2); 8 | transition:0.3s; 9 | } 10 | 11 | .group-card h3 { 12 | padding-top:10px; 13 | font-weight:400!important; 14 | } 15 | .group-card h4 { 16 | padding-top:10px; 17 | font-weight:400!important; 18 | } 19 | 20 | .group-card { 21 | padding-top: 0px; 22 | padding-right: 5px; 23 | background-color: #f2f2f2; 24 | padding-left: 5px; 25 | border-radius: 2px; 26 | box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12), 0 3px 1px -2px rgba(0,0,0,0.2); 27 | transition:0.3s; 28 | } 29 | 30 | .group-card h3 { 31 | padding-top:10px; 32 | font-weight:400!important; 33 | } 34 | .group-card h4 { 35 | padding-top:10px; 36 | font-weight:400!important; 37 | } 38 | 39 | .cssHeaderRow { 40 | background-color: #2A94D6; 41 | } 42 | .cssTableRow { 43 | background-color: #F0F1F2; 44 | } 45 | .cssOddTableRow { 46 | background-color: #F0F1F2; 47 | } 48 | .cssSelectedTableRow { 49 | font-size: 20px; 50 | font-weight:bold; 51 | } 52 | .cssHoverTableRow { 53 | background: #ccc; 54 | } 55 | .cssHeaderCell { 56 | color: #FFFFFF; 57 | font-size: 16px; 58 | padding: 10px !important; 59 | border: solid 1px #FFFFFF; 60 | } 61 | .cssTableCell { 62 | font-size: 16px; 63 | padding: 10px !important; 64 | border: solid 1px #FFFFFF; 65 | } 66 | .cssRowNumberCell { 67 | text-align: center; 68 | } -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/NumberValue.php: -------------------------------------------------------------------------------- 1 | value = (float) $value; 13 | } 14 | 15 | public static function getNullValue() 16 | { 17 | return new static(-9999); // WTF? 18 | } 19 | 20 | public function getType() 21 | { 22 | return ValueType::NUMBER; 23 | } 24 | 25 | public function getValue() 26 | { 27 | if (is_null($this->value)) 28 | { 29 | throw new NullValueException("This null number has no value"); 30 | } 31 | return $this->value; 32 | } 33 | 34 | public function __toString() 35 | { 36 | return (string) $this->value; 37 | } 38 | 39 | public function isNull() 40 | { 41 | return is_null($this->value); 42 | } 43 | 44 | public function compareTo(Value $other) 45 | { 46 | if ($this == $other) { return 0; } 47 | if ($this->isNull()) { return -1; } 48 | if ($other->isNull()) { return 1; } 49 | return min(max($this->value - $other->value, -1), 1); 50 | } 51 | 52 | public function getObjectToFormat() 53 | { 54 | if ($this->isNull()) 55 | { 56 | return NULL; 57 | } 58 | return $this->value; 59 | } 60 | 61 | public function innerToQueryString() 62 | { 63 | return $this->value; 64 | } 65 | } 66 | ?> 67 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Sum.php: -------------------------------------------------------------------------------- 1 | isNull() || $values[1]->isNull()) 19 | { 20 | return NumberValue::getNullValue(); 21 | } 22 | $sum = $values[0]->getValue() + $values[1]->getValue(); 23 | return new NumberValue($sum); 24 | } 25 | 26 | public function getReturnType($types) 27 | { 28 | return ValueType::NUMBER; 29 | } 30 | 31 | public function validateParameters($types) 32 | { 33 | if (count($types) != 2) 34 | { 35 | throw new InvalidQueryException("The function " . self::FUNCTION_NAME . " requires two parameters"); 36 | } 37 | foreach ($types as $type) 38 | { 39 | if ($type != ValueType::NUMBER) 40 | { 41 | throw new InvalidQueryException("Can't perform the function " . self::FUNCTION_NAME . " on values that are not numbers"); 42 | } 43 | } 44 | return $this; 45 | } 46 | 47 | public function toQueryString($argumentsQueryStrings) 48 | { 49 | return "(" . $argumentsQueryStrings[0] . " + " . $argumentsQueryStrings[1] . ")"; 50 | } 51 | } 52 | ?> 53 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Modulo.php: -------------------------------------------------------------------------------- 1 | isNull() || $values[1]->isNull()) 19 | { 20 | return NumberValue::getNullValue(); 21 | } 22 | $modulo = $values[0]->getValue() % $values[1]->getValue(); 23 | return new NumberValue($sum); 24 | } 25 | 26 | public function getReturnType($types) 27 | { 28 | return ValueType::NUMBER; 29 | } 30 | 31 | public function validateParameters($types) 32 | { 33 | if (count($types) != 2) 34 | { 35 | throw new InvalidQueryException("The function " . self::FUNCTION_NAME . " requires two parameters"); 36 | } 37 | foreach ($types as $type) 38 | { 39 | if ($type != ValueType::NUMBER) 40 | { 41 | throw new InvalidQueryException("Can't perform the function " . self::FUNCTION_NAME . " on values that are not numbers"); 42 | } 43 | } 44 | return $this; 45 | } 46 | 47 | public function toQueryString($argumentsQueryStrings) 48 | { 49 | return "(" . $argumentsQueryStrings[0] . " % " . $argumentsQueryStrings[1] . ")"; 50 | } 51 | } 52 | ?> 53 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Product.php: -------------------------------------------------------------------------------- 1 | isNull() || $values[1]->isNull()) 19 | { 20 | return NumberValue::getNullValue(); 21 | } 22 | $sum = $values[0]->getValue() * $values[1]->getValue(); 23 | return new NumberValue($sum); 24 | } 25 | 26 | public function getReturnType($types) 27 | { 28 | return ValueType::NUMBER; 29 | } 30 | 31 | public function validateParameters($types) 32 | { 33 | if (count($types) != 2) 34 | { 35 | throw new InvalidQueryException("The function " . self::FUNCTION_NAME . " requires two parameters"); 36 | } 37 | foreach ($types as $type) 38 | { 39 | if ($type != ValueType::NUMBER) 40 | { 41 | throw new InvalidQueryException("Can't perform the function " . self::FUNCTION_NAME . " on values that are not numbers"); 42 | } 43 | } 44 | return $this; 45 | } 46 | 47 | public function toQueryString($argumentsQueryStrings) 48 | { 49 | return "(" . $argumentsQueryStrings[0] . " * " . $argumentsQueryStrings[1] . ")"; 50 | } 51 | } 52 | ?> 53 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Difference.php: -------------------------------------------------------------------------------- 1 | isNull() || $values[1]->isNull()) 19 | { 20 | return NumberValue::getNullValue(); 21 | } 22 | $diff = $values[0]->getValue() - $values[1]->getValue(); 23 | return new NumberValue($diff); 24 | } 25 | 26 | public function getReturnType($types) 27 | { 28 | return ValueType::NUMBER; 29 | } 30 | 31 | public function validateParameters($types) 32 | { 33 | if (count($types) != 2) 34 | { 35 | throw new InvalidQueryException("The function " . self::FUNCTION_NAME . " requires two parameters"); 36 | } 37 | foreach ($types as $type) 38 | { 39 | if ($type != ValueType::NUMBER) 40 | { 41 | throw new InvalidQueryException("Can't perform the function " . self::FUNCTION_NAME . " on values that are not numbers"); 42 | } 43 | } 44 | return $this; 45 | } 46 | 47 | public function toQueryString($argumentsQueryStrings) 48 | { 49 | return "(" . $argumentsQueryStrings[0] . " - " . $argumentsQueryStrings[1] . ")"; 50 | } 51 | } 52 | ?> 53 | -------------------------------------------------------------------------------- /google-visualization/Query/Engine/TableRowComparator.php: -------------------------------------------------------------------------------- 1 | valueComparator = Value::getLocalizedComparator($locale); 20 | $this->columnLookup = $columnLookup; 21 | $columns = $sort->getSortColumns(); 22 | $this->sortColumns = array(); 23 | $this->sortColumnOrder = array(); 24 | foreach ($columns as $columnSort) 25 | { 26 | $this->sortColumns[] = $columnSort->getColumn(); 27 | $this->sortColumnOrder[] = $columnSort->getOrder(); 28 | } 29 | } 30 | 31 | public function compare(TableRow $r1, TableRow $r2) 32 | { 33 | foreach ($this->sortColumns as $i=> $col) 34 | { 35 | $cc = $this->valueComparator->compare($col->getValue($this->columnLookup, $r1), $col->getValue($this->columnLookup, $r2)); 36 | if ($cc != 0) 37 | { 38 | return $this->sortColumnOrder[$i] == SortOrder::ASCENDING ? $cc : -$cc; 39 | } 40 | } 41 | return 0; 42 | } 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /google-visualization/Util/Map.php: -------------------------------------------------------------------------------- 1 | clear(); 12 | } 13 | 14 | public function clear() 15 | { 16 | $this->keys = array(); 17 | $this->values = array(); 18 | return $this; 19 | } 20 | 21 | public function containsKey($key) 22 | { 23 | return in_array($key, $this->keys); 24 | } 25 | 26 | public function containsValue($value) 27 | { 28 | return in_array($value, $this->values); 29 | } 30 | 31 | public function get($key) 32 | { 33 | if (($i = array_search($key, $this->keys)) === FALSE) 34 | { 35 | return NULL; 36 | } 37 | return $this->values[$i]; 38 | } 39 | 40 | public function isEmpty() 41 | { 42 | return $this->size() == 0; 43 | } 44 | 45 | public function keySet() 46 | { 47 | return $this->keys; 48 | } 49 | 50 | public function put($key, $value) 51 | { 52 | $this->keys[] = $key; 53 | $this->values[] = $value; 54 | return $this; 55 | } 56 | 57 | public function remove($key) 58 | { 59 | $i = array_search($key, $this->keys); 60 | array_splice($this->keys, $i, 1); 61 | array_splice($this->values, $i, 1); 62 | return $this; 63 | } 64 | 65 | public function size() 66 | { 67 | return count($this->keys); 68 | } 69 | 70 | public function values() 71 | { 72 | return $this->values; 73 | } 74 | } 75 | ?> 76 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Round.php: -------------------------------------------------------------------------------- 1 | isNull() || $values[1]->isNull()) 19 | { 20 | return NumberValue::getNullValue(); 21 | } 22 | $rounded = round($values[0]->getValue(), $values[1]->getValue()); 23 | return new NumberValue($rounded); 24 | } 25 | 26 | public function getReturnType($types) 27 | { 28 | return ValueType::NUMBER; 29 | } 30 | 31 | public function validateParameters($types) 32 | { 33 | if (count($types) != 2) 34 | { 35 | throw new InvalidQueryException("The function " . self::FUNCTION_NAME . " requires two parameters"); 36 | } 37 | foreach ($types as $type) 38 | { 39 | if ($type != ValueType::NUMBER) 40 | { 41 | throw new InvalidQueryException("Can't perform the function " . self::FUNCTION_NAME . " on values that are not numbers"); 42 | } 43 | } 44 | return $this; 45 | } 46 | 47 | public function toQueryString($argumentsQueryStrings) 48 | { 49 | return self::FUNCTION_NAME . "(" . $argumentsQueryStrings[0] . ", " . $argumentsQueryStrings[1] . ")"; 50 | } 51 | } 52 | ?> 53 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/Quotient.php: -------------------------------------------------------------------------------- 1 | isNull() || $values[1]->isNull() || $values[1]->getValue() == 0) 19 | { 20 | return NumberValue::getNullValue(); 21 | } 22 | $sum = $values[0]->getValue() / $values[1]->getValue(); 23 | return new NumberValue($sum); 24 | } 25 | 26 | public function getReturnType($types) 27 | { 28 | return ValueType::NUMBER; 29 | } 30 | 31 | public function validateParameters($types) 32 | { 33 | if (count($types) != 2) 34 | { 35 | throw new InvalidQueryException("The function " . self::FUNCTION_NAME . " requires two parameters"); 36 | } 37 | foreach ($types as $type) 38 | { 39 | if ($type != ValueType::NUMBER) 40 | { 41 | throw new InvalidQueryException("Can't perform the function " . self::FUNCTION_NAME . " on values that are not numbers"); 42 | } 43 | } 44 | return $this; 45 | } 46 | 47 | public function toQueryString($argumentsQueryStrings) 48 | { 49 | return "(" . $argumentsQueryStrings[0] . " / " . $argumentsQueryStrings[1] . ")"; 50 | } 51 | } 52 | ?> 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mqtt-cogs 2 | Wordpress MQTT plugin 3 | 4 | ## Synopsis 5 | 6 | MqttCogs maintains a persistent (well semi persistent) connection to an Mqtt Broker. When a message arrives on a subscribed topic, it persists it to a custom database table in wordpress. 7 | 8 | So that you can ‘see’ the data in your blog it provides a number shortcodes for visualizing your data. Visualization uses Google Visualization 9 | 10 | ## Code Example 11 | 12 | [ mqttcogs_drawgoogle charttype=”LineChart” ] 13 | 14 | [ mqttcogs_data limit=”40″ topics=”mysensors_out/100/1/1/0/0″ ] 15 | 16 | [ /mqttcogs_drawgoogle ] 17 | 18 | ## Motivation 19 | 20 | I’ve been mucking around with IoT (internet of things) projects for over a year now. I started with Arduino & the MySensors project. Annoyingly, it really isn’t as easy as you think! 21 | 22 | I didn’t want to rent a server and then have to install IOT Controller software. What I do have though is a wordpress blog. This costs me $1.50 per month to rent. So I started wondering about getting MQTT data into the WordPress database and visualizing the data on my blog. 23 | 24 | ## Demo & Documentation 25 | 26 | http://mqttcogs.sailresults.org/ 27 | 28 | ## Installation 29 | 30 | http://mqttcogs.sailresults.org/get-started-with-mqttcogs/ 31 | 32 | 33 | ## Shortcode Reference 34 | 35 | http://mqttcogs.sailresults.org/shortcodes/ 36 | 37 | ## Hook Reference 38 | 39 | http://mqttcogs.sailresults.org/hooks/ 40 | 41 | ## Contributors 42 | 43 | Me at the moment but let me know if you want to help out. See http://mqttcogs.sailresults.org/about/ for contact information 44 | 45 | ## License 46 | 47 | A short snippet describing the license (MIT, Apache, etc.) 48 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/DateDiff.php: -------------------------------------------------------------------------------- 1 | getDateTime->diff($secondValue->getDateTime()); 24 | return new NumberValue($di->d); 25 | } 26 | 27 | public function getReturnType($types) 28 | { 29 | return ValueType::NUMBER; 30 | } 31 | 32 | public function validateParameters($types) 33 | { 34 | if (count($types) != 2) 35 | { 36 | throw new InvalidQueryException("Number of parameters for the dateDiff function is wrong: " . count($types)); 37 | } else if (!$this->isDateOrDateTimeValue($types[0]) || !$this->isDateOrDateTimeValue($types[1])) 38 | { 39 | throw new InvalidQueryException("Can't perform the function 'dateDiff' on values that are not a Date or DateTime values"); 40 | } 41 | return $this; 42 | } 43 | 44 | protected function isDateOrDateTimeValue($type) 45 | { 46 | return $type == ValueType::DATE || $type == ValueType::DATETIME; 47 | } 48 | 49 | public function toQueryString($argumentsQueryStrings) 50 | { 51 | return self::FUNCTION_NAME . "(" . $argumentsQueryStrings[0] . ", " . $argumentsQueryStrings[1] . ")"; 52 | } 53 | } 54 | ?> 55 | -------------------------------------------------------------------------------- /google-visualization/Query/NegationFilter.php: -------------------------------------------------------------------------------- 1 | subFilter = $subFilter; 14 | } 15 | 16 | public function isMatch(DataTable $table, TableRow $row) 17 | { 18 | return !$this->subFilter->isMatch($table, $row); 19 | } 20 | 21 | public function getAllColumnIds() 22 | { 23 | return $this->subFilter->getAllColumnIds(); 24 | } 25 | 26 | public function getScalarFunctionColumns() 27 | { 28 | return $this->subFilter->getScalarFunctionColumns(); 29 | } 30 | 31 | public function getAggregationColumns() 32 | { 33 | return $this->subFilter->getAggregationColumns(); 34 | } 35 | 36 | public function getSubFilter() 37 | { 38 | return $this->subFilter; 39 | } 40 | 41 | public function toQueryString() 42 | { 43 | return "NOT (" . $this->subFilter->toQueryString() . ")"; 44 | } 45 | 46 | public function equals($o) 47 | { 48 | if ($this == $o) 49 | { 50 | return TRUE; 51 | } 52 | if (is_null($o)) 53 | { 54 | return FALSE; 55 | } 56 | if (get_class($this) != get_class($o)) 57 | { 58 | return FALSE; 59 | } 60 | if (is_null($this->subFilter)) 61 | { 62 | if (!is_null($o->subFilter)) 63 | { 64 | return FALSE; 65 | } 66 | return TRUE; 67 | } 68 | } 69 | } 70 | ?> 71 | -------------------------------------------------------------------------------- /google-visualization/Base/BooleanFormat.php: -------------------------------------------------------------------------------- 1 | trueString = $trueString; 30 | $this->falseString = $falseString; 31 | } 32 | 33 | public function format($obj, $appendTo = "", $pos = array()) 34 | { 35 | if (!is_null($obj) && !is_bool($obj)) 36 | { 37 | throw new IllegalArgumentException(); 38 | } 39 | $val = $obj; 40 | if (is_null($val)) 41 | { 42 | $pos[0] = 0; 43 | $pos[1] = 0; 44 | } else if ($val) 45 | { 46 | $appendTo .= $this->trueString; 47 | $pos[0] = 0; 48 | $pos[1] = strlen($this->trueString) - 1; 49 | } else 50 | { 51 | $appendTo .= $this->falseString; 52 | $pos[0] = 0; 53 | $pos[1] = strlen($this->falseString) - 1; 54 | } 55 | return $appendTo; 56 | } 57 | } 58 | ?> 59 | -------------------------------------------------------------------------------- /google-visualization/Query/QueryFormat.php: -------------------------------------------------------------------------------- 1 | columns = array(); 12 | $this->columnPatterns = array(); 13 | } 14 | 15 | public function addPattern(AbstractColumn $column, $pattern) 16 | { 17 | if (in_array($column, $this->columns)) 18 | { 19 | $messageToLogAndUser = "Column [" . $column . "] is specified more than once in FORMAT."; 20 | //$this->log->error($messageToLogAndUser); 21 | throw new InvalidQueryException($messageToLogAndUser); 22 | } 23 | $this->columns[] = $column; 24 | $this->columnPatterns[] = $pattern; 25 | return $this; 26 | } 27 | 28 | public function getPattern(AbstractColumn $column) 29 | { 30 | return $this->columnPatterns[array_search($column, $this->columns)]; 31 | } 32 | 33 | public function getColumns() 34 | { 35 | return $this->columns; 36 | } 37 | 38 | public function getScalarFunctionColumns() 39 | { 40 | $result = array(); 41 | foreach ($this->columns as $col) 42 | { 43 | foreach ($col->getAllScalarFunctionColumns() as $innerCol) 44 | { 45 | if (!in_array($innerCol, $result)) 46 | { 47 | $result[] = $innerCol; 48 | } 49 | } 50 | } 51 | return $result; 52 | } 53 | 54 | public function getAggregationColumns() 55 | { 56 | $result = array(); 57 | foreach ($this->columns as $col) 58 | { 59 | $result = array_merge($result, $col->getAllAggregationColumns()); 60 | } 61 | return $result; 62 | } 63 | } 64 | ?> 65 | -------------------------------------------------------------------------------- /sskaje/mqtt/Exception.php: -------------------------------------------------------------------------------- 1 | columnId = $columnId; 13 | } 14 | 15 | public function getColumnId() 16 | { 17 | return $this->columnId; 18 | } 19 | 20 | public function getId() 21 | { 22 | return $this->columnId; 23 | } 24 | 25 | public function __toString() 26 | { 27 | return $this->columnId; 28 | } 29 | 30 | public function getAllSimpleColumnIds() 31 | { 32 | return array($this->columnId); 33 | } 34 | 35 | public function equals($o) 36 | { 37 | if ($o instanceof SimpleColumn) 38 | { 39 | return $this->columnId == $o->columnId; 40 | } 41 | return FALSE; 42 | } 43 | 44 | public function toString() { return $this->columnId; } 45 | 46 | public function getAllAggregationColumns() 47 | { 48 | return array(); 49 | } 50 | 51 | public function getAllSimpleColumns() 52 | { 53 | return array($this); 54 | } 55 | 56 | public function getAllScalarFunctionColumns() 57 | { 58 | return array(); 59 | } 60 | 61 | public function getValueType(DataTable $dataTable) 62 | { 63 | return $dataTable->getColumnDescription($this->columnId)->getType(); 64 | } 65 | 66 | public function toQueryString() 67 | { 68 | if (strpos($this->columnId, "`") !== FALSE) 69 | { 70 | throw new \RuntimeException("Column ID cannot contain backtick (`)"); 71 | } 72 | return "`" . $this->columnId . "`"; 73 | } 74 | } 75 | ?> 76 | -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/BooleanValue.php: -------------------------------------------------------------------------------- 1 | value = (boolean) $value; 13 | } 14 | 15 | public static function getNullValue() 16 | { 17 | return new static(FALSE); 18 | } 19 | 20 | public function getType() 21 | { 22 | return ValueType::BOOLEAN; 23 | } 24 | 25 | public function getValue() 26 | { 27 | if (is_null($this->value)) 28 | { 29 | throw new NullValueException("This null boolean has no value"); 30 | } 31 | return $this->value; 32 | } 33 | 34 | public function isNull() 35 | { 36 | return is_null($this->value); 37 | } 38 | 39 | public function compareTo(Value $other) 40 | { 41 | if ($this == $other) 42 | { 43 | return 0; 44 | } 45 | if ($this->isNull()) 46 | { 47 | return -1; 48 | } 49 | if ($other->isNull()) 50 | { 51 | return 1; 52 | } 53 | return ($this->value == $other->value ? 0 : ($this->value ? 1 : -1)); 54 | } 55 | 56 | public function __toString() 57 | { 58 | if (is_null($this->value)) 59 | { 60 | return "null"; 61 | } 62 | return $this->value ? "true" : "false"; 63 | } 64 | 65 | public function getObjectToFormat() 66 | { 67 | if ($this->isNull()) 68 | { 69 | return NULL; 70 | } 71 | return $this->value; 72 | } 73 | 74 | public function innerToQueryString() 75 | { 76 | return $this->value ? "true" : "false"; 77 | } 78 | } 79 | ?> 80 | -------------------------------------------------------------------------------- /google-visualization/Base/ResponseStatus.php: -------------------------------------------------------------------------------- 1 | statusType = $statusType; 15 | $this->reasonType = $reasonType; 16 | $this->description = $description; 17 | } 18 | 19 | public static function createResponseStatus(DataSourceException $dse) 20 | { 21 | return new self(StatusType::ERROR, $dse->getReasonType(), $dse->getMessageToUser()); 22 | } 23 | 24 | public static function getModifiedResponseStatus(ResponseStatus $responseStatus) 25 | { 26 | $signInString = LocaleUtil::getLocalizedMessageFromBundle(__NAMESPACE__ . "\ErrorMessages", self::SIGN_IN_MESSAGE_KEY, NULL); 27 | if ($responseStatus->getReasonType() == ReasonType::USER_NOT_AUTHENTICATED) 28 | { 29 | $msg = $responseStatus->getDescription(); 30 | if (strpos($msg, " ") !== FALSE && (strpos($msg, "http://") === 0 || strpos($msg, "https://") === 0)) 31 | { 32 | $sb = ''.$signInString.''; 33 | $responseStatus = new ResponseStatus($responseStatus->getStatusType(), $responseStatus->getReasonType(), $sb); 34 | } 35 | } 36 | return $responseStatus; 37 | } 38 | 39 | public function getStatusType() 40 | { 41 | return $this->statusType; 42 | } 43 | 44 | public function getReasonType() 45 | { 46 | return $this->reasonType; 47 | } 48 | 49 | public function getDescription() 50 | { 51 | return $this->description; 52 | } 53 | } 54 | ?> 55 | -------------------------------------------------------------------------------- /google-visualization/Query/ScalarFunction/ToDate.php: -------------------------------------------------------------------------------- 1 | getType()) 22 | { 23 | case ValueType::DATE; 24 | case ValueType::DATETIME: 25 | $dateValue = new DateValue($value); 26 | break; 27 | case ValueType::NUMBER: 28 | $dateValue = new DateValue(DateTime::createFromFormat($value->getValue() / 1000)); 29 | break; 30 | default: 31 | throw new RuntimeException("Value type was not found: " . $value->getType()); 32 | } 33 | return $dateValue; 34 | } 35 | 36 | public function getReturnType($types) 37 | { 38 | return ValueType::DATE; 39 | } 40 | 41 | public function validateParameters($types) 42 | { 43 | if (count($types) != 1) 44 | { 45 | throw new InvalidQueryException("Number of parameters for the date function is wrong: " . count($types)); 46 | } else if ($types[0] != ValueType::DATETIME && $types[0] != ValueType::DATE && $types[0] != ValueType::NUMBER) 47 | { 48 | throw new InvalidQueryException("Can't perform the function 'date' on values that are not date, dateTime, or number values"); 49 | } 50 | return $this; 51 | } 52 | 53 | public function toQueryString($argumentsQueryStrings) 54 | { 55 | return self::FUNCTION_NAME . "(" . $argumentsQueryStrings[0] . ")"; 56 | } 57 | } 58 | ?> 59 | -------------------------------------------------------------------------------- /sskaje/mqtt/Exception/BadUTF8.php: -------------------------------------------------------------------------------- 1 | get($key);*/ 46 | } 47 | 48 | public static function getLocalizedMessageFromBundleWithArguments($bundleName, $key, $args, $locale) 49 | { 50 | return $key; 51 | /* 52 | $rawMessage = self::getLocalizedMessageFromBundle($bundleName, $key, $locale); 53 | if (!is_null($args) && count($args)) 54 | { 55 | return MessageFormatter::formatMessage($locale, $rawMessage, $args); 56 | } 57 | return $rawMessage;*/ 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /google-visualization/Query/QueryLabels.php: -------------------------------------------------------------------------------- 1 | columns = array(); 12 | $this->labels = array(); 13 | } 14 | 15 | public function addLabel(AbstractColumn $column, $label) 16 | { 17 | if (in_array($column, $this->columns)) 18 | { 19 | $messageToLogAndUser = "Column [" . $column->toString() . "] is specified mor than once in LABEL."; 20 | //$this->log->error($messageToLogAndUser); 21 | throw new InvalidQueryException($messageToLogAndUser); 22 | } 23 | $this->columns[] = $column; 24 | $this->labels[] = $label; 25 | return $this; 26 | } 27 | 28 | public function getLabel(AbstractColumn $column) 29 | { 30 | return $this->labels[array_search($column, $this->columns)]; 31 | } 32 | 33 | public function getColumns() 34 | { 35 | return $this->columns; 36 | } 37 | 38 | public function getScalarFunctionColumns() 39 | { 40 | $result = array(); 41 | foreach ($this->columns as $col) 42 | { 43 | $result = array_merge($result, $col->getAllScalarFunctionColumns()); 44 | } 45 | return $result; 46 | } 47 | 48 | public function getAggregationColumns() 49 | { 50 | $result = array(); 51 | foreach ($this->columns as $col) 52 | { 53 | $result = array_merge($result, $col->getAllAggregationColumns()); 54 | } 55 | return $result; 56 | } 57 | 58 | public function toQueryString() 59 | { 60 | $stringList = array(); 61 | foreach ($this->columns as $i => $col) 62 | { 63 | $stringList[] = $col->toQueryString() . " " . Query::stringToQueryStringLiteral($this->labels[$i]); 64 | } 65 | return implode(", ", $stringList); 66 | } 67 | } 68 | ?> 69 | -------------------------------------------------------------------------------- /google-visualization/Query/ColumnColumnFilter.php: -------------------------------------------------------------------------------- 1 | firstColumn = $firstColumn; 16 | $this->secondColumn = $secondColumn; 17 | } 18 | 19 | public function isMatch(DataTable $table, TableRow $row) 20 | { 21 | $lookup = new DataTableColumnLookup($table); 22 | $firstValue = $this->firstColumn->getValue($lookup, $row); 23 | $secondValue = $this->secondColumn->getValue($lookup, $row); 24 | return $this->isOperatorMatch($firstValue, $secondValue); 25 | } 26 | 27 | public function getAllColumnIds() 28 | { 29 | return array_merge($this->firstColumn->getAllSimpleColumnIds(), $this->secondColumn->getAllSimpleColumnIds()); 30 | } 31 | 32 | public function getScalarFunctionColumns() 33 | { 34 | return array_merge($this->firstColumn->getScalarFunctionColumns(), $this->secondColumn->getScalarFunctionColumns()); 35 | } 36 | 37 | public function getAggregationColumns() 38 | { 39 | return array_merge($this->firstColumn->getAllAggregationColumns(), $this->secondColumn->getAllAggregationColumns()); 40 | } 41 | 42 | public function getFirstColumn() 43 | { 44 | return $this->firstColumn; 45 | } 46 | 47 | public function getSecondColumn() 48 | { 49 | return $this->secondColumn; 50 | } 51 | 52 | public function toQueryString() 53 | { 54 | return $this->firstColumn->toQueryString() . " " . $this->operator . " " . $this->secondColumn->toQueryString(); 55 | } 56 | } 57 | ?> 58 | -------------------------------------------------------------------------------- /sskaje/mqtt/Message/PINGREQ.php: -------------------------------------------------------------------------------- 1 | Server 45 | * 46 | * 3.12 PINGREQ – PING request 47 | */ 48 | class PINGREQ extends Base 49 | { 50 | protected $message_type = Message::PINGREQ; 51 | protected $protocol_type = self::FIXED_ONLY; 52 | } 53 | 54 | # EOF -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/Value.php: -------------------------------------------------------------------------------- 1 | isNull()) 36 | { 37 | throw new RuntimeException("Cannot run toQueryString() on a null value."); 38 | } 39 | return $this->innerToQueryString(); 40 | } 41 | 42 | public static function getLocalizedComparator($ulocale) 43 | { 44 | $comparator = new Comparator(); 45 | $textValueComparator = TextValue::getTextLocalizedComparator($ulocale); 46 | $comparator->compare = function(Value $value1, Value $value2) use ($textValueComparator) 47 | { 48 | if ($value1 == $value2) 49 | { 50 | return 0; 51 | } 52 | if ($value1->getType() == ValueType::TEXT) 53 | { 54 | return $textValueComparator->compare($value1, $value2); 55 | } else 56 | { 57 | return $value1->compareTo($value2); 58 | } 59 | }; 60 | return $comparator; 61 | } 62 | } 63 | ?> 64 | -------------------------------------------------------------------------------- /google-visualization/Base/MessagesEnum.php: -------------------------------------------------------------------------------- 1 | 42 | -------------------------------------------------------------------------------- /sskaje/mqtt/Message/PUBCOMP.php: -------------------------------------------------------------------------------- 1 | Server 46 | */ 47 | class PUBCOMP extends Base 48 | { 49 | protected $message_type = Message::PUBCOMP; 50 | protected $protocol_type = self::WITH_VARIABLE; 51 | protected $read_bytes = 4; 52 | 53 | } 54 | 55 | # EOF -------------------------------------------------------------------------------- /google-visualization/Query/Engine/GroupingComparators.php: -------------------------------------------------------------------------------- 1 | compare = function($l1, $l2) 12 | { 13 | for ($i = 0; $i < min(count($l1), count($l2)); $i++) 14 | { 15 | $localCompare = $l1[$i]->compareTo($l2[$i]); 16 | if ($localCompare != 0) 17 | { 18 | return $localCompare; 19 | } 20 | } 21 | 22 | if ($i < count($l1)) 23 | { 24 | $localCompare = 1; 25 | } else if ($i < count($l2)) 26 | { 27 | $localCompare = -1; 28 | } else 29 | { 30 | $localCompare = 0; 31 | } 32 | return $localCompare; 33 | }; 34 | return $comparator; 35 | } 36 | 37 | public static function rowTitleComparator() 38 | { 39 | $comparator = new Comparator(); 40 | $comparator->compare = function(RowTitle $col1, RowTitle $col2) 41 | { 42 | return self::valueListComparator($col1->values, $col2->values); 43 | }; 44 | return $comparator; 45 | } 46 | 47 | public static function getColumnTitleDynamicComparator($columnAggregations) 48 | { 49 | $comparator = new Comparator(); 50 | $comparator->compare = function(ColumnTitle $col1, ColumnTitle $col2) use ($columnAggregations) 51 | { 52 | $listCompare = self::valueListComparator()->compare($col1->getValues(), $col2->getValues()); 53 | if ($listCompare != 0) 54 | { 55 | return $listCompare; 56 | } 57 | $i1 = array_search($col1->aggregation, $columnAggregations); 58 | $i2 = array_search($col2->aggregation, $columnAggregations); 59 | return strcmp($i1, $i2); 60 | }; 61 | return $comparator; 62 | } 63 | } 64 | ?> 65 | -------------------------------------------------------------------------------- /sskaje/mqtt/Message/DISCONNECT.php: -------------------------------------------------------------------------------- 1 | Server 46 | * 47 | * 3.14 DISCONNECT – Disconnect notification 48 | */ 49 | class DISCONNECT extends Base 50 | { 51 | protected $message_type = Message::DISCONNECT; 52 | protected $protocol_type = self::FIXED_ONLY; 53 | } 54 | 55 | # EOF -------------------------------------------------------------------------------- /js/htmldrawer.js: -------------------------------------------------------------------------------- 1 | 2 | if (allhtmls && allhtmls.length>0) { 3 | for(var i=0;i1) { 23 | val= data.getValue(parseInt(matches[0]), parseInt(matches[1])); 24 | } 25 | else { 26 | val = data.getValue(0, parseInt(matches[0])); 27 | } 28 | if ((val instanceof Date) && (this.dateformat)) { 29 | val = moment(val).format(this.dateformat); 30 | } 31 | return val; 32 | }); 33 | target.html(content); 34 | } 35 | } 36 | 37 | 38 | htmlinfo.responseHandler = function (response) { 39 | var self = this; 40 | if (response.isError()) { 41 | alert("Error in query: " + response.getMessage() + " " + response.getDetailedMessage()); 42 | } 43 | else { 44 | var data = response.getDataTable(); 45 | 46 | if (self.script) { 47 | self.script(data); 48 | } 49 | } 50 | 51 | if (parseInt(self.refresh_secs)>0) { 52 | setTimeout(function () { 53 | self.query.send(self.responseHandler.bind(self)); 54 | },parseInt(self.refresh_secs)*1000); 55 | } 56 | }; 57 | 58 | htmlinfo.onLoadCallback = function () { 59 | var self = this; 60 | self.query = new google.visualization.Query(self.querystring); 61 | self.query.send(self.responseHandler.bind(self)); 62 | }; 63 | 64 | google.charts.setOnLoadCallback(htmlinfo.onLoadCallback.bind(htmlinfo)); 65 | } 66 | } 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /sskaje/mqtt/Message/PUBACK.php: -------------------------------------------------------------------------------- 1 | Server 46 | * 47 | * 3.4 PUBACK – Publish acknowledgement 48 | */ 49 | class PUBACK extends Base 50 | { 51 | protected $message_type = Message::PUBACK; 52 | protected $protocol_type = self::WITH_VARIABLE; 53 | protected $read_bytes = 4; 54 | 55 | } 56 | 57 | # EOF -------------------------------------------------------------------------------- /sskaje/mqtt/Message/UNSUBACK.php: -------------------------------------------------------------------------------- 1 | Server 46 | * 47 | * 3.5 PUBREC – Publish received (QoS 2 publish received, part 1) 48 | */ 49 | class PUBREC extends Base 50 | { 51 | protected $message_type = Message::PUBREC; 52 | protected $protocol_type = self::WITH_VARIABLE; 53 | protected $read_bytes = 4; 54 | 55 | } 56 | 57 | # EOF -------------------------------------------------------------------------------- /sskaje/mqtt/Message/PUBREL.php: -------------------------------------------------------------------------------- 1 | Server 46 | * 47 | * 3.6 PUBREL – Publish release (QoS 2 publish received, part 2) 48 | */ 49 | class PUBREL extends Base 50 | { 51 | protected $message_type = Message::PUBREL; 52 | protected $protocol_type = self::WITH_VARIABLE; 53 | protected $read_bytes = 4; 54 | 55 | } 56 | 57 | # EOF -------------------------------------------------------------------------------- /google-visualization/Query/Engine/TableAggregator.php: -------------------------------------------------------------------------------- 1 | groupByColumns = $groupByColumns; 18 | $this->aggregateColumns = $aggregateColumns; 19 | $this->tree = new AggregationTree($aggregateColumns, $table); 20 | 21 | foreach ($table->getRows() as $row) 22 | { 23 | $this->tree->aggregate($this->getRowPath($row, $table, count($groupByColumns) - 1), $this->getValuesToAggregate($row, $table)); 24 | } 25 | } 26 | 27 | public function getRowPath(TableRow $row, DataTable $table, $depth) 28 | { 29 | $result = new AggregationPath(); 30 | for ($i = 0; $i <= $depth; $i++) 31 | { 32 | $columnId = $this->groupByColumns[$i]; 33 | $curValue = $row->getCell($table->getColumnIndex($columnId))->getValue(); 34 | $result->add($curValue); 35 | } 36 | return $result; 37 | } 38 | 39 | public function getPathsToLeaves() 40 | { 41 | return $this->tree->getPathsToLeaves(); 42 | } 43 | 44 | public function getValuesToAggregate(TableRow $row, DataTable $table) 45 | { 46 | $result = new Map(); 47 | foreach ($this->aggregateColumns as $columnId) 48 | { 49 | $curValue = $row->getCell($table->getColumnIndex($columnId))->getValue(); 50 | $result->put($columnId, $curValue); 51 | } 52 | return $result; 53 | } 54 | 55 | public function getAggregationValue(AggregationPath $path, $columnId, $type) 56 | { 57 | return $this->tree->getNode($path)->getAggregationValue($columnId, $type); 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /google-visualization/Query/QuerySort.php: -------------------------------------------------------------------------------- 1 | sortColumns = array(); 11 | } 12 | 13 | public function isEmpty() 14 | { 15 | return !count($this->sortColumns); 16 | } 17 | 18 | public function addSort(ColumnSort $columnSort) 19 | { 20 | $this->sortColumns[] = $columnSort; 21 | return $this; 22 | } 23 | 24 | public function getSortColumns() 25 | { 26 | return $this->sortColumns; 27 | } 28 | 29 | public function getColumns() 30 | { 31 | $result = array(); 32 | foreach ($this->sortColumns as $columnSort) 33 | { 34 | $result[] = $columnSort->getColumn(); 35 | } 36 | return $result; 37 | } 38 | 39 | public function getAggregationColumns() 40 | { 41 | $result = array(); 42 | foreach ($this->sortColumns as $columnSort) 43 | { 44 | $col = $columnSort->getColumn(); 45 | foreach ($col->getAllAggregationColumns() as $innerCol) 46 | { 47 | if (!in_array($innerCol, $result)) 48 | { 49 | $result[] = $innerCol; 50 | } 51 | } 52 | } 53 | return $result; 54 | } 55 | 56 | public function getScalarFunctionColumns() 57 | { 58 | $result = array(); 59 | foreach ($this->sortColumns as $columnSort) 60 | { 61 | $col = $columnSort->getColumn(); 62 | foreach ($col->getAllScalarFunctionColumns() as $innercol) 63 | { 64 | if (!in_array($innerCol, $result)) 65 | { 66 | $result[] = $innerCol; 67 | } 68 | } 69 | } 70 | return $result; 71 | } 72 | 73 | public function toQueryString() 74 | { 75 | $stringList = array(); 76 | foreach ($this->sortColumns as $colSort) 77 | { 78 | $stringList[] = $colSort->toQueryString(); 79 | } 80 | return implode(", ", $stringList); 81 | } 82 | } 83 | ?> 84 | -------------------------------------------------------------------------------- /sskaje/mqtt/Message/CONNACK.php: -------------------------------------------------------------------------------- 1 | isNull() || $values[1]->isNull()) 21 | { 22 | return DateTimeValue::getNullValue(); 23 | } 24 | return new DateTimeValue($values[0]); 25 | } 26 | 27 | public function getReturnType($types) 28 | { 29 | return ValueType::DATETIME; 30 | } 31 | 32 | public function validateParameters($types) 33 | { 34 | if (count($types) != 2) 35 | { 36 | throw new InvalidQueryException("The function " . self::FUNCTION_NAME . " requires two parameters"); 37 | } 38 | 39 | if (($types[0] != ValueType::DATE) || ($types[0] != ValueType::DATETIME)) { 40 | throw new InvalidQueryException("Can't perform the function " . self::FUNCTION_NAME . " parameter one should be a date or datetime"); 41 | } 42 | 43 | if ($types[1] != ValueType::NUMBER){ 44 | throw new InvalidQueryException("Can't perform the function " . self::FUNCTION_NAME . " parameter two should be a number of seconds"); 45 | } 46 | return $this; 47 | } 48 | 49 | public function toQueryString($argumentsQueryStrings) 50 | { 51 | return "FROM_UNIXTIME(UNIX_TIMESTAMP(" . $argumentsQueryStrings[0]. ") - UNIX_TIMESTAMP(" . $argumentsQueryStrings[0]. ") mod ". $argumentsQueryStrings[1]. ")" ; 52 | // return "(" . $argumentsQueryStrings[0] . " - " . $argumentsQueryStrings[1] . ")"; 53 | // return $argumentsQueryStrings[0]; 54 | } 55 | } 56 | ?> 57 | -------------------------------------------------------------------------------- /google-visualization/Query/ColumnValueFilter.php: -------------------------------------------------------------------------------- 1 | column = $column; 18 | $this->value = $value; 19 | $this->isComparisonOrderReversed = $isComparisonOrderReversed; 20 | } 21 | 22 | public function isMatch(DataTable $table, TableRow $row) 23 | { 24 | $lookup = new DataTableColumnLookup($table); 25 | $columnValue = $this->column->getValue($lookup, $row); 26 | return $this->isComparisonOrderReversed ? $this->isOperatorMatch($this->value, $columnValue) : $this->isOperatorMatch($columnValue, $this->value); 27 | } 28 | 29 | public function getAllColumnIds() 30 | { 31 | return $this->column->getAllSimpleColumnIds(); 32 | } 33 | 34 | public function getScalarFunctionColumns() 35 | { 36 | return $this->column->getAllScalarFunctionColumns(); 37 | } 38 | 39 | public function getAggregationColumns() 40 | { 41 | return $this->column->getAllAggregationColumns(); 42 | } 43 | 44 | public function getColumn() 45 | { 46 | return $this->column; 47 | } 48 | 49 | public function getValue() 50 | { 51 | return $this->value; 52 | } 53 | 54 | public function toQueryString() 55 | { 56 | if ($this->isComparisonOrderReversed) 57 | { 58 | return $this->value->toQueryString() . " " . $this->operator . " " . $this->column->toQueryString(); 59 | } else 60 | { 61 | return $this->column->toQueryString() . " " . $this->operator . " " . $this->value->toQueryString(); 62 | } 63 | } 64 | } 65 | ?> 66 | -------------------------------------------------------------------------------- /mqtt-cogs_init.php: -------------------------------------------------------------------------------- 1 | isInstalled()) { 34 | $aPlugin->install(); 35 | } 36 | else { 37 | // Perform any version-upgrade activities prior to activation (e.g. database changes) 38 | $aPlugin->upgrade(); 39 | } 40 | 41 | // Add callbacks to hooks 42 | $aPlugin->addActionsAndFilters(); 43 | 44 | if (!$file) { 45 | $file = __FILE__; 46 | } 47 | // Register the Plugin Activation Hook 48 | register_activation_hook($file, array(&$aPlugin, 'activate')); 49 | 50 | 51 | // Register the Plugin Deactivation Hook 52 | register_deactivation_hook($file, array(&$aPlugin, 'deactivate')); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/TextValue.php: -------------------------------------------------------------------------------- 1 | value = (string) $value; 16 | } 17 | 18 | public static function getNullValue() 19 | { 20 | return new static(""); 21 | } 22 | 23 | public function getType() 24 | { 25 | return ValueType::TEXT; 26 | } 27 | 28 | public function __toString() 29 | { 30 | return $this->value; 31 | } 32 | 33 | public function isNull() 34 | { 35 | return is_null($this->value); 36 | } 37 | 38 | public function compareTo(Value $other) 39 | { 40 | if ($this == $other) 41 | { 42 | return 0; 43 | } 44 | return strcmp($this->value, $other->value); 45 | } 46 | 47 | public function getObjectToFormat() 48 | { 49 | return $this->value; 50 | } 51 | 52 | public function getTextLocalizedComparator($ulocale) 53 | { 54 | $comparator = new Comparator(); 55 | $collator = new Collator($ulocale); 56 | $comparator->compare = function(TextValue $tv1, TextValue $tv2) use ($collator) 57 | { 58 | if ($tv1 == $tv2) 59 | { 60 | return 0; 61 | } 62 | return $collator->compare($tv1, $tv2); 63 | }; 64 | return $comparator; 65 | } 66 | 67 | public function getValue() 68 | { 69 | return $this->value; 70 | } 71 | 72 | public function innerToQueryString() 73 | { 74 | if (strpos($this->value, "\"") !== FALSE) 75 | { 76 | if (strpos($this->value, "'") !== FALSE) 77 | { 78 | throw new RuntimeException("Cannot run toQueryString() on string values that contain both \" and '."); 79 | } else 80 | { 81 | return "'" . $this->value . "'"; 82 | } 83 | } else 84 | { 85 | return "\"" . $this->value . "\""; 86 | } 87 | } 88 | } 89 | ?> 90 | -------------------------------------------------------------------------------- /sskaje/mqtt/PacketIdentifierStoreInterface.php: -------------------------------------------------------------------------------- 1 | id; 57 | } 58 | 59 | /** 60 | * Next Packet Identifier 61 | * 62 | * @return int 63 | */ 64 | public function next() 65 | { 66 | return ++$this->id; 67 | } 68 | 69 | /** 70 | * Set A New ID 71 | * 72 | * @param $new_id 73 | * @return void 74 | */ 75 | public function set($new_id) 76 | { 77 | $this->id = (int) $new_id; 78 | } 79 | } -------------------------------------------------------------------------------- /sskaje/mqtt/Message/Header/PINGRESP.php: -------------------------------------------------------------------------------- 1 | decodePacketIdentifier($packet_data, $pos); 75 | } 76 | } 77 | 78 | # EOF -------------------------------------------------------------------------------- /sskaje/mqtt/Message/Header/SUBSCRIBE.php: -------------------------------------------------------------------------------- 1 | decodePacketIdentifier($packet_data, $pos); 75 | } 76 | } 77 | 78 | # EOF -------------------------------------------------------------------------------- /sskaje/mqtt/Message/Header/DISCONNECT.php: -------------------------------------------------------------------------------- 1 | decodePacketIdentifier($packet_data, $pos); 76 | } 77 | } 78 | 79 | # EOF -------------------------------------------------------------------------------- /sskaje/mqtt/Message/Header/PUBREL.php: -------------------------------------------------------------------------------- 1 | decodePacketIdentifier($packet_data, $pos); 76 | } 77 | } 78 | 79 | # EOF -------------------------------------------------------------------------------- /MqttCogs_ShortCodeLoader.php: -------------------------------------------------------------------------------- 1 | registerShortcodeToFunction($shortcodeName, 'handleShortcode'); 33 | } 34 | 35 | /** 36 | * @param $shortcodeName mixed either string name of the shortcode 37 | * (as it would appear in a post, e.g. [shortcodeName]) 38 | * or an array of such names in case you want to have more than one name 39 | * for the same shortcode 40 | * @param $functionName string name of public function in this class to call as the 41 | * shortcode handler 42 | * @return void 43 | */ 44 | protected function registerShortcodeToFunction($shortcodeName, $functionName) { 45 | if (is_array($shortcodeName)) { 46 | foreach ($shortcodeName as $aName) { 47 | add_shortcode($aName, array($this, $functionName)); 48 | } 49 | } 50 | else { 51 | add_shortcode($shortcodeName, array($this, $functionName)); 52 | } 53 | } 54 | 55 | /** 56 | * @abstract Override this function and add actual shortcode handling here 57 | * @param $atts shortcode inputs 58 | * @return string shortcode content 59 | */ 60 | public abstract function handleShortcode($atts, $content); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /sskaje/mqtt/Message/Header/PUBACK.php: -------------------------------------------------------------------------------- 1 | decodePacketIdentifier($packet_data, $pos); 76 | } 77 | } 78 | 79 | # EOF -------------------------------------------------------------------------------- /google-visualization/Query/Engine/AggregationTree.php: -------------------------------------------------------------------------------- 1 | columnsToAggregate = $columnsToAggregate; 17 | $this->table = $table; 18 | $this->root = new AggregationNode($columnsToAggregate, $table); 19 | } 20 | 21 | public function aggregate(AggregationPath $path, Map $valuesToAggregate) 22 | { 23 | $curNode = $this->root; 24 | $this->root->aggregate($valuesToAggregate); 25 | foreach ($path->getValues() as $curValue) 26 | { 27 | if (!$curNode->containsChild($curValue)) 28 | { 29 | $curNode->addChild($curValue, $this->columnsToAggregate, $this->table); 30 | } 31 | $curNode = $curNode->getChild($curValue); 32 | $curNode->aggregate($valuesToAggregate); 33 | } 34 | return $this; 35 | } 36 | 37 | public function getNode(AggregationPath $path) 38 | { 39 | $curNode = $this->root; 40 | foreach ($path->getValues() as $curValue) 41 | { 42 | $curNode = $curNode->getChild($curValue); 43 | } 44 | return $curNode; 45 | } 46 | 47 | public function getPathsToLeaves() 48 | { 49 | $result = new Set(); 50 | $this->getPathsToLeavesInternal($this->root, $result); 51 | return $result; 52 | } 53 | 54 | protected function getPathsToLeavesInternal(AggregationNode $node, Set $result) 55 | { 56 | $children = $node->getChildren(); 57 | if ($children->isEmpty()) 58 | { 59 | $result->add($this->getPathToNode($node)); 60 | } else 61 | { 62 | foreach ($children->values() as $curNode) 63 | { 64 | self::getPathsToLeavesInternal($curNode, $result); 65 | } 66 | } 67 | return $this; 68 | } 69 | 70 | final protected static function getPathToNode(AggregationNode $node) 71 | { 72 | $result = new AggregationPath(); 73 | $curNode = $node; 74 | while (!is_null($curNode->getValue())) 75 | { 76 | $result->add($curNode->getValue()); 77 | $curNode = $curNode->getParent(); 78 | } 79 | $result->reverse(); 80 | return $result; 81 | } 82 | } 83 | ?> 84 | -------------------------------------------------------------------------------- /sskaje/mqtt/Message/Header/PUBCOMP.php: -------------------------------------------------------------------------------- 1 | decodePacketIdentifier($packet_data, $pos); 76 | } 77 | 78 | } 79 | 80 | # EOF -------------------------------------------------------------------------------- /MqttCogs_ShortCodeScriptLoader.php: -------------------------------------------------------------------------------- 1 | registerShortcodeToFunction($shortcodeName, 'handleShortcodeWrapper'); 37 | 38 | // It will be too late to enqueue the script in the header, 39 | // but can add them to the footer 40 | add_action('wp_footer', array($this, 'addScriptWrapper')); 41 | } 42 | 43 | public function handleShortcodeWrapper($atts) { 44 | // Flag that we need to add the script 45 | $this->doAddScript = true; 46 | return $this->handleShortcode($atts); 47 | } 48 | 49 | 50 | public function addScriptWrapper() { 51 | // Only add the script if the shortcode was actually called 52 | if ($this->doAddScript) { 53 | $this->addScript(); 54 | } 55 | } 56 | 57 | /** 58 | * @abstract override this function with calls to insert scripts needed by your shortcode in the footer 59 | * Example: 60 | * wp_register_script('my-script', plugins_url('js/my-script.js', __FILE__), array('jquery'), '1.0', true); 61 | * wp_print_scripts('my-script'); 62 | * @return void 63 | */ 64 | public abstract function addScript(); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /AutoLoadByNamespace.php: -------------------------------------------------------------------------------- 1 | 8 | * 13 | * 14 | * 15 | * @author Brent G. Gardner 16 | */ 17 | 18 | class AutoloadByNamespace 19 | { 20 | /** 21 | * @var array Associative array for paths 22 | */ 23 | static private $paths = array(); 24 | 25 | /** 26 | * The autoload function to be added to the autoload stack via spl_autoload_register. 27 | * 28 | * @param string $class The fully qualified class name to be autoloaded 29 | */ 30 | static public function autoload($class, $base = '') 31 | { 32 | if (($pos = strpos($class, '\\')) === FALSE) 33 | { 34 | // No base namespace given 35 | return; 36 | } 37 | $base .= substr($class, 0, $pos); 38 | $class = substr($class, $pos); 39 | if (in_array($base, array_keys(self::$paths)) === FALSE) 40 | { 41 | self::autoload(substr($class, 1), $base . "\\"); // Check for nested base namespace (MyKey\MySubkey\MyClass) 42 | // Base namespace not registered 43 | return; 44 | } 45 | $classPath = self::$paths[$base].'/'.str_replace('\\', '/', $class) . '.php'; 46 | if (($realClassPath = realpath($classPath)) === FALSE) 47 | { 48 | self::autoload(substr($class, 1), $base . "\\"); // Check for nested base namespace (MyKey\MySubkey\MyClass) 49 | // Invalid path 50 | return; 51 | } 52 | require_once $realClassPath; 53 | return; 54 | } 55 | 56 | /** 57 | * Maps a base namespace to a path on the filesystem. 58 | * 59 | * @param string $base The base namespace. 60 | * @param string $path The absolute filesystem path where the class files exist. 61 | * @return string Returns the canonicalized absolute path on success or FALSE on failure. 62 | */ 63 | static public function register($base, $path) 64 | { 65 | if (($path = realpath($path)) !== FALSE) 66 | { 67 | self::$paths[$base] = $path; 68 | } 69 | return $path; 70 | } 71 | } 72 | ?> 73 | -------------------------------------------------------------------------------- /google-visualization/Query/ComparisonFilter.php: -------------------------------------------------------------------------------- 1 | "; 9 | const OPERATOR_LT = "<"; 10 | const OPERATOR_GT = ">"; 11 | const OPERATOR_LE = "<="; 12 | const OPERATOR_GE = ">="; 13 | const OPERATOR_CONTAINS = "CONTAINS"; 14 | const OPERATOR_STARTS_WITH = "STARTS WTIH"; 15 | const OPERATOR_ENDS_WITH = "ENDS WITH"; 16 | const OPERATOR_MATCHES = "MATCHES"; 17 | const OPERATOR_LIKE = "LIKE"; 18 | 19 | protected $operator; 20 | 21 | public function __construct($operator) 22 | { 23 | $this->operator = $operator; 24 | } 25 | 26 | public function isOperatorMatch($v1, $v2) 27 | { 28 | switch ($this->operator) 29 | { 30 | case self::OPERATOR_EQ: 31 | case self::OPERATOR_NE1: 32 | case self::OPERATOR_NE2: 33 | case self::OPERATOR_LT: 34 | case self::OPERATOR_GT: 35 | case self::OPERATOR_LE: 36 | case self::OPERATOR_GE: 37 | if ($v1->getType() != $v2->getType()) { return FALSE; } 38 | default: 39 | } 40 | switch ($this->operator) 41 | { 42 | case self::OPERATOR_EQ: 43 | return $v1->compareTo($v2) == 0; 44 | case self::OPERATOR_NE1: 45 | case self::OPERATOR_NE2: 46 | return $v1->compareTo($v2) != 0; 47 | case self::OPERATOR_LT: 48 | return $v1->compareTo($v2) < 0; 49 | case self::OPERATOR_GT: 50 | return $v1->compareTo($v2) > 0; 51 | case self::OPERATOR_LE: 52 | return $v1->compareTo($v2) <= 0; 53 | case self::OPERATOR_GE: 54 | return $v1->compareTo($v2) >= 0; 55 | case self::OPERATOR_CONTAINS: 56 | return strpos($v1->__toString(), $v2->__toString()); 57 | case self::OPERATOR_STARTS_WITH: 58 | return strpos($v1->__toString(), $v2->__toString()) === 0; 59 | case self::OPERATOR_ENDS_WITH: 60 | return strpos(strrev($v1->__toString()), strrev($v2->__toString())) === 0; 61 | case self::OPERATOR_MATCHES: 62 | return preg_match("/" . $v2->__toString() . "/", $v1->__toString()) === 1; 63 | case self::OPERATOR_LIKE: 64 | return preg_match("/" . str_replace("_", ".", str_replace("%", ".*", $v2->__toString())) . "/", $v2->__toString()) === 1; 65 | } 66 | return FALSE; 67 | } 68 | 69 | public function getOperator() 70 | { 71 | return $this->operator; 72 | } 73 | } 74 | ?> 75 | -------------------------------------------------------------------------------- /google-visualization/Render/CsvRenderer.php: -------------------------------------------------------------------------------- 1 | getColumnDescriptions(); 22 | if (count($columns) == 0) 23 | { 24 | return ""; 25 | } 26 | 27 | $sb = ""; 28 | foreach ($columns as $column) 29 | { 30 | $sb .= self::escapeString($column->getLabel()) . $separator; 31 | } 32 | 33 | $sb = substr($sb, 0, -1) . "\n"; 34 | 35 | $formatters = ValueFormatter::createDefaultFormatters($locale); 36 | 37 | $rows = $dataTable->getRows(); 38 | foreach ($rows as $row) 39 | { 40 | $cells = $row->getCells(); 41 | foreach ($cells as $cell) 42 | { 43 | $formattedValue = $cell->getFormattedValue(); 44 | if (is_null($formattedValue)) 45 | { 46 | $formattedValue = $formatters->get($cell->getType())->format($cell->getValue()); 47 | } 48 | if (is_null($cell)) 49 | { 50 | $sb .= "null"; 51 | } else 52 | { 53 | $type = $cell->getType(); 54 | if (strpos($formattedValue, ",") !== FALSE || $type == ValueType::TEXT) 55 | { 56 | $sb .= self::escapeString($formattedValue); 57 | } else 58 | { 59 | $sb .= $formattedValue; 60 | } 61 | } 62 | $sb .= $separator; 63 | } 64 | $sb = substr($sb, 0, -1) . "\n"; 65 | } 66 | return $sb; 67 | } 68 | 69 | protected static function escapeString($input) 70 | { 71 | $sb = "\""; 72 | $sb .= str_replace("\"", "\"\"", $input); 73 | $sb .= "\""; 74 | return $sb; 75 | } 76 | 77 | public static function renderCsvError(ResponseStatus $responseStatus) 78 | { 79 | $sb = "Error: " . ReasonType::getMessageForReasonType($responseStatus->getReasonType(), NULL); 80 | $sb .= ". " . $responseStatus->getDescription(); 81 | return self::escapeString($sb); 82 | } 83 | } 84 | ?> 85 | -------------------------------------------------------------------------------- /sskaje/mqtt/PacketIdentifier.php: -------------------------------------------------------------------------------- 1 | pi = new PhpStatic(); 57 | } 58 | 59 | /** 60 | * Next Packet Identifier 61 | * 62 | * @return int 63 | */ 64 | public function next() 65 | { 66 | return $this->pi->next() % 65535 + 1; 67 | } 68 | 69 | /** 70 | * Current Packet Identifier 71 | * 72 | * @return mixed 73 | */ 74 | public function get() 75 | { 76 | return $this->pi->get() % 65535 + 1; 77 | } 78 | 79 | /** 80 | * Set A New ID 81 | * 82 | * @param int $new_id 83 | * @return void 84 | */ 85 | public function set($new_id) 86 | { 87 | $this->pi->set($new_id); 88 | } 89 | } 90 | 91 | 92 | # EOF -------------------------------------------------------------------------------- /google-visualization/DataTable/Value/DateValue.php: -------------------------------------------------------------------------------- 1 | dateTime = new DateTime($dateStr); 19 | $this->year = $this->dateTime->format("Y") + 0; 20 | $this->month = $this->dateTime->format("n") - 1; 21 | $this->dayOfMonth = $this->dateTime->format("j"); 22 | } 23 | } 24 | 25 | public static function getNullValue() 26 | { 27 | return new static(); 28 | } 29 | 30 | public function __toString() 31 | { 32 | if (is_null($this->dateTime)) 33 | { 34 | return "null"; 35 | } 36 | return $this->dateTime->format("Y-m-d"); 37 | } 38 | 39 | public function getDateTime() 40 | { 41 | return $this->dateTime; 42 | } 43 | 44 | public function getYear() 45 | { 46 | return $this->year; 47 | } 48 | 49 | public function getMonth() 50 | { 51 | return $this->month; 52 | } 53 | 54 | public function getDayOfMonth() 55 | { 56 | return $this->dayOfMonth; 57 | } 58 | 59 | public function getType() 60 | { 61 | return ValueType::DATE; 62 | } 63 | 64 | public function getObjectToFormat() 65 | { 66 | if ($this->isNull()) 67 | { 68 | return NULL; 69 | } 70 | return $this->dateTime; 71 | } 72 | 73 | public function isNull() 74 | { 75 | return is_null($this->dateTime); 76 | } 77 | 78 | public function compareTo(Value $other) 79 | { 80 | if ($this == $other) 81 | { 82 | return 0; 83 | } 84 | $otherDate = $other; 85 | if ($this->isNull()) 86 | { 87 | return -1; 88 | } 89 | if ($otherDate->isNull()) 90 | { 91 | return 1; 92 | } 93 | if ($this->dateTime > $otherDate->dateTime) 94 | { 95 | return 1; 96 | } else if ($this->dateTime < $otherDate->dateTime) 97 | { 98 | return -1; 99 | } 100 | return 0; 101 | } 102 | 103 | protected function innerToQueryString() 104 | { 105 | return "DATE '" . $this->getYear() . "-" . sprintf("%02d", $this->getMonth() + 1) . "-" . sprintf("%02d", $this->getDayOfMonth()) . "'"; 106 | } 107 | } 108 | ?> 109 | -------------------------------------------------------------------------------- /google-visualization/Query/Engine/AggregationNode.php: -------------------------------------------------------------------------------- 1 | columnAggregators = new Map(); 19 | $this->children = new Map(); 20 | foreach ($columnsToAggregate as $columnId) 21 | { 22 | $this->columnAggregators->put($columnId, new ValueAggregator($table->getColumnDescription($columnId)->getType())); 23 | } 24 | } 25 | 26 | public function aggregate(Map $valuesByColumn) 27 | { 28 | foreach ($valuesByColumn->keySet() as $columnId) 29 | { 30 | $this->columnAggregators->get($columnId)->aggregate($valuesByColumn->get($columnId)); 31 | } 32 | return $this; 33 | } 34 | 35 | public function getAggregationValue($columnId, $type) 36 | { 37 | $valuesAggregator = $this->columnAggregators->get($columnId); 38 | if (is_null($valuesAggregator)) 39 | { 40 | throw new IllegalArgumentException("Column " . $columnId . " is not aggregated"); 41 | } 42 | return $valuesAggregator->getValue($type); 43 | } 44 | 45 | public function getChild(Value $v) 46 | { 47 | $result = $this->children->get($v); 48 | if (is_null($result)) 49 | { 50 | throw new NoSuchElementException("Value " . $v . " is not a child."); 51 | } 52 | return $result; 53 | } 54 | 55 | public function containsChild(Value $v) 56 | { 57 | return $this->children->containsKey($v); 58 | } 59 | 60 | public function addChild(Value $key, $columnsToAggregate, DataTable $table) 61 | { 62 | if ($this->children->containsKey($key)) 63 | { 64 | throw new IllegalArgumentException("A child with key: " . $key . " already exists."); 65 | } 66 | $node = new AggregationNode($columnsToAggregate, $table); 67 | $node->parent = $this; 68 | $node->value = $key; 69 | $this->children->put($key, $node); 70 | return $this; 71 | } 72 | 73 | public function getChildren() 74 | { 75 | return $this->children; 76 | } 77 | 78 | public function getValue() 79 | { 80 | return $this->value; 81 | } 82 | 83 | public function getParent() 84 | { 85 | return $this->parent; 86 | } 87 | } 88 | ?> 89 | -------------------------------------------------------------------------------- /sskaje/mqtt/MessageHandler.php: -------------------------------------------------------------------------------- 1 | 0) { 3 | for(var i=0;ithead>tr').first(); 17 | 18 | for (var cidx=0;cidx' + data.getColumnId(cidx) + ''); 20 | } 21 | datatable = jQuery('#' + this.id).DataTable(this.options); 22 | this.datatable = datatable; 23 | 24 | //datatables can't handle nulls.... 25 | for(var cidx=0;cidx0) { 74 | setTimeout(function () { 75 | self.query.send(self.responseHandler.bind(self)); 76 | },parseInt(self.refresh_secs)*1000); 77 | } 78 | }; 79 | 80 | tableinfo.onLoadCallback = function () { 81 | var self = this; 82 | self.query = new google.visualization.Query(self.querystring); 83 | self.query.send(self.responseHandler.bind(self)); 84 | }; 85 | 86 | 87 | google.charts.setOnLoadCallback(tableinfo.onLoadCallback.bind(tableinfo)); 88 | } 89 | } 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /google-visualization/Base/ErrorMessages/root.txt: -------------------------------------------------------------------------------- 1 | root { 2 | UNKNOWN_DATA_SOURCE_ID { "Unknown data source ID" } 3 | ACCESS_DENIED { "Access denied" } 4 | USER_NOT_AUTHENTICATED { "User not signed in" } 5 | UNSUPPORTED_QUERY_OPERATION { "Unsupported query operation" } 6 | INVALID_QUERY { "Invalid query" } 7 | INVALID_REQUEST { "Invalid request" } 8 | INTERNAL_ERROR { "Internal error" } 9 | NOT_SUPPORTED { "Operation not supported" } 10 | DATA_TRUNCATED { "Retrieved data was truncated" } 11 | NOT_MODIFIED { "Data not modified" } 12 | TIMEOUT { "Request timeout" } 13 | ILLEGAL_FORMATTING_PATTERNS { "Illegal formatting patterns" } 14 | OTHER { "Could not complete request" } 15 | SIGN_IN { "Sign in" } 16 | // QUERY Errors 17 | NO_COLUMN { "Column [{0}] does not exist in table." } 18 | AVG_SUM_ONLY_NUMERIC { "'Average' and 'sum' aggreagation functions can be applied only on numeric values." } 19 | INVALID_AGG_TYPE { "Invalid aggregation type: {0}" } 20 | // Parse 21 | PARSE_ERROR { "Query parse error: {0}" } 22 | CANNOT_BE_IN_GROUP_BY { "Column [{0}] cannot be in GROUP BY because it has an aggregation." } 23 | CANNOT_BE_IN_PIVOT { "Column [{0}] cannot be in PIVOT because it has an aggregation." } 24 | CANNOT_BE_IN_WHERE { "Column [{0}] cannot appear in WHERE because it has an aggregation." } 25 | SELECT_WITH_AND_WITHOUT_AGG { "Column [{0}] cannot be selected both with and without aggregation in SELECT." } 26 | COL_AGG_NOT_IN_SELECT { "Column [{0}] which is aggregated in SELECT, cannot appear in GROUP BY." } 27 | CANNOT_GROUP_WITHOUT_AGG { "Cannot use GROUP BY when no aggregations are defined in SELECT." } 28 | CANNOT_PIVOT_WITHOUT_AGG { "Cannot use PIVOT when no aggregations are defined in SELECT." } 29 | AGG_IN_SELECT_NO_PIVOT { "Column [{0}] which is aggregated in SELECT, cannot appear in PIVOT." } 30 | FORMAT_COL_NOT_IN_SELECT { "Column [{0}] which is referenced in FORMAT, is not part of SELECT clause." } 31 | LABEL_COL_NOT_IN_SELECT { "Column [{0}] which is referenced in LABEL, is not part of SELECT clause." } 32 | ADD_COL_TO_GROUP_BY_OR_AGG { "Column [{0}] should be added to GROUP BY, removed from SELECT, or aggregated in SELECT." } 33 | AGG_IN_ORDER_NOT_IN_SELECT { "Aggregation [{0}] found in ORDER BY but was not found in SELECT" } 34 | NO_AGG_IN_ORDER_WHEN_PIVOT { "Column [{0}] cannot be aggregated in ORDER BY when PIVOT is used." } 35 | COL_IN_ORDER_MUST_BE_IN_SELECT { "Column [{0}] which appears in ORDER BY, must be in SELECT as well because SELECT contains aggregated columns." } 36 | NO_COL_IN_GROUP_AND_PIVOT { "Column [{0}] cannot appear both in GROUP BY and in PIVOT." } 37 | INVALID_LIMIT { "Invalid value for row limit: {0}" } 38 | INVALID_OFFSET { "Invalid value for row offset: {0}" } 39 | INVALID_SKIPPING { "Invalid value for row skipping: {0}" } 40 | COLUMN_ONLY_ONCE { "Column [{0}] cannot appear more than once in {1}." } 41 | } 42 | -------------------------------------------------------------------------------- /google-visualization/Query/CompoundFilter.php: -------------------------------------------------------------------------------- 1 | operator = $operator; 20 | foreach ($subFilters as $subFilter) 21 | { 22 | if (!($subFilter instanceof QueryFilter)) 23 | { 24 | throw new RuntimeException("Compound filter subfilter is not of type QueryFilter"); 25 | } 26 | } 27 | $this->subFilters = $subFilters; 28 | } 29 | 30 | public function isMatch(DataTable $table, TableRow $row) 31 | { 32 | if (!count($this->subFilters)) 33 | { 34 | throw new RuntimeException("Compound filter has no subfilters"); 35 | } 36 | foreach ($this->subFilters as $subFilter) 37 | { 38 | $result = $subFilter->isMatch($table, $row); 39 | if ((($this->operator == self::LOGICAL_OPERATOR_AND) && !$result) || (($this->operator == self::LOGICAL_OPERATOR_OR) && $result)) 40 | { 41 | return $result; 42 | } 43 | } 44 | return $this->operator == self::LOGICAL_OPERATOR_AND; 45 | } 46 | 47 | public function getAllColumnIds() 48 | { 49 | $result = array(); 50 | foreach ($this->subFilters as $subFilter) 51 | { 52 | $result = array_merge($result, $subFilter->getAllColumnIds()); 53 | } 54 | return $result; 55 | } 56 | 57 | public function getScalarFunctionColumns() 58 | { 59 | $result = array(); 60 | foreach ($this->subFilters as $subFilter) 61 | { 62 | $result = array_merge($result, $subFilter->getScalarFunctionColumns()); 63 | } 64 | return $result; 65 | } 66 | 67 | public function getAggregationColumns() 68 | { 69 | $result = array(); 70 | foreach ($this->subFilters as $subFilter) 71 | { 72 | $result = array_merge($result, $subFilter->getAggregationColumns()); 73 | } 74 | return $result; 75 | } 76 | 77 | public function getOperator() 78 | { 79 | return $this->operator; 80 | } 81 | 82 | public function getSubFilters() 83 | { 84 | return $this->subFilters; 85 | } 86 | 87 | public function toQueryString() 88 | { 89 | $subFilterStrings = array(); 90 | foreach ($this->subFilters as $subFilter) 91 | { 92 | $subFilterStrings[] = "(" . $subFilter->toQueryString() . ")"; 93 | } 94 | return implode(" " . $this->operator . " ", $subFilterStrings); 95 | } 96 | } 97 | ?> 98 | -------------------------------------------------------------------------------- /sskaje/mqtt/Message/UNSUBSCRIBE.php: -------------------------------------------------------------------------------- 1 | Server 48 | * 49 | * 3.10 UNSUBSCRIBE – Unsubscribe from topics 50 | */ 51 | class UNSUBSCRIBE extends Base 52 | { 53 | protected $message_type = Message::UNSUBSCRIBE; 54 | protected $protocol_type = self::WITH_PAYLOAD; 55 | 56 | protected $topics = array(); 57 | 58 | public function addTopic($topic_filter) 59 | { 60 | Utility::CheckTopicFilter($topic_filter); 61 | $this->topics[] = $topic_filter; 62 | } 63 | 64 | protected function payload() 65 | { 66 | if (empty($this->topics)) { 67 | /* 68 | The Topic Filters in an UNSUBSCRIBE packet MUST be UTF-8 encoded strings as 69 | defined in Section 1.5.3, packed contiguously [MQTT-3.10.3-1]. 70 | */ 71 | throw new Exception('Missing topics!'); 72 | } 73 | 74 | $buffer = ""; 75 | 76 | # Payload 77 | foreach ($this->topics as $topic) { 78 | $buffer .= Utility::PackStringWithLength($topic); 79 | } 80 | 81 | return $buffer; 82 | } 83 | } 84 | 85 | # EOF -------------------------------------------------------------------------------- /sskaje/mqtt/Message/SUBACK.php: -------------------------------------------------------------------------------- 1 | return_codes; 70 | } 71 | 72 | /** 73 | * Decode Payload 74 | * 75 | * @param string & $packet_data 76 | * @param int & $payload_pos 77 | * @return void 78 | */ 79 | protected function decodePayload(& $packet_data, & $payload_pos) 80 | { 81 | $return_code = array(); 82 | 83 | while (isset($packet_data[$payload_pos])) { 84 | $return_code[] = ord($packet_data[$payload_pos]); 85 | 86 | ++ $payload_pos; 87 | } 88 | 89 | $this->return_codes = $return_code; 90 | } 91 | } 92 | 93 | # EOF -------------------------------------------------------------------------------- /js/googlechartdrawer.js: -------------------------------------------------------------------------------- 1 | 2 | if (allcharts && allcharts.length>0) { 3 | for(var i=0;i0) { 70 | setTimeout(function () { 71 | self.query.send(self.responseHandler.bind(self)); 72 | },parseInt(self.refresh_secs)*1000); 73 | } 74 | }; 75 | 76 | chartinfo.onLoadCallback = function () { 77 | var self = this; 78 | self.chart = new google.visualization[self.charttype](document.getElementById(self.id)); 79 | self.query = new google.visualization.Query(self.querystring); 80 | self.query.send(self.responseHandler.bind(self)); 81 | }; 82 | 83 | 84 | google.charts.setOnLoadCallback(chartinfo.onLoadCallback.bind(chartinfo)); 85 | } 86 | } 87 | --------------------------------------------------------------------------------