How to use DataTable class

Best Cucumber Common Library code snippet using DataTable

API.php

Source:API.php Github

copy

Full Screen

...10use Exception;11use Piwik\API\Request;12use Piwik\Archive;13use Piwik\Common;14use Piwik\DataTable;15use Piwik\Date;16use Piwik\Metrics;17use Piwik\Piwik;18use Piwik\Plugins\CustomVariables\API as APICustomVariables;19use Piwik\Plugins\Actions\Actions\ActionSiteSearch;20use Piwik\Tracker\Action;21use Piwik\Tracker\PageUrl;22/**23 * The Actions API lets you request reports for all your Visitor Actions: Page URLs, Page titles (Piwik Events),24 * File Downloads and Clicks on external websites.25 *26 * For example, "getPageTitles" will return all your page titles along with standard <a href='http://piwik.org/docs/analytics-api/reference/#toc-metric-definitions' target='_blank'>Actions metrics</a> for each row.27 *28 * It is also possible to request data for a specific Page Title with "getPageTitle"29 * and setting the parameter pageName to the page title you wish to request.30 * Similarly, you can request metrics for a given Page URL via "getPageUrl", a Download file via "getDownload"31 * and an outlink via "getOutlink".32 *33 * Note: pageName, pageUrl, outlinkUrl, downloadUrl parameters must be URL encoded before you call the API.34 * @method static \Piwik\Plugins\Actions\API getInstance()35 */36class API extends \Piwik\Plugin\API37{38 /**39 * Returns the list of metrics (pages, downloads, outlinks)40 *41 * @param int $idSite42 * @param string $period43 * @param string $date44 * @param bool|string $segment45 * @param bool|array $columns46 * @return DataTable47 */48 public function get($idSite, $period, $date, $segment = false, $columns = false)49 {50 Piwik::checkUserHasViewAccess($idSite);51 $archive = Archive::build($idSite, $period, $date, $segment);52 $metrics = Archiver::$actionsAggregateMetrics;53 $metrics['Actions_avg_time_generation'] = 'avg_time_generation';54 // get requested columns55 $columns = Piwik::getArrayFromApiParameter($columns);56 if (!empty($columns)) {57 // get the columns that are available and requested58 $columns = array_intersect($columns, array_values($metrics));59 $columns = array_values($columns); // make sure indexes are right60 $nameReplace = array();61 foreach ($columns as $i => $column) {62 $fullColumn = array_search($column, $metrics);63 $columns[$i] = $fullColumn;64 $nameReplace[$fullColumn] = $column;65 }66 if (false !== ($avgGenerationTimeRequested = array_search('Actions_avg_time_generation', $columns))) {67 unset($columns[$avgGenerationTimeRequested]);68 $avgGenerationTimeRequested = true;69 }70 } else {71 // get all columns72 unset($metrics['Actions_avg_time_generation']);73 $columns = array_keys($metrics);74 $nameReplace = & $metrics;75 $avgGenerationTimeRequested = true;76 }77 if ($avgGenerationTimeRequested) {78 $tempColumns = array(79 Archiver::METRIC_SUM_TIME_RECORD_NAME,80 Archiver::METRIC_HITS_TIMED_RECORD_NAME,81 );82 $columns = array_merge($columns, $tempColumns);83 $columns = array_unique($columns);84 $nameReplace[Archiver::METRIC_SUM_TIME_RECORD_NAME] = 'sum_time_generation';85 $nameReplace[Archiver::METRIC_HITS_TIMED_RECORD_NAME] = 'nb_hits_with_time_generation';86 }87 $table = $archive->getDataTableFromNumeric($columns);88 // replace labels (remove Actions_)89 $table->filter('ReplaceColumnNames', array($nameReplace));90 // compute avg generation time91 if ($avgGenerationTimeRequested) {92 $table->filter('ColumnCallbackAddColumnQuotient', array('avg_time_generation', 'sum_time_generation', 'nb_hits_with_time_generation', 3));93 $table->deleteColumns(array('sum_time_generation', 'nb_hits_with_time_generation'));94 }95 return $table;96 }97 /**98 * @param int $idSite99 * @param string $period100 * @param Date $date101 * @param bool $segment102 * @param bool $expanded103 * @param bool|int $idSubtable104 * @param bool|int $depth105 *106 * @return DataTable|DataTable\Map107 */108 public function getPageUrls($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false,109 $depth = false)110 {111 $dataTable = $this->getDataTableFromArchive('Actions_actions_url', $idSite, $period, $date, $segment, $expanded, $idSubtable, $depth);112 $this->filterPageDatatable($dataTable);113 $this->filterActionsDataTable($dataTable, $expanded);114 return $dataTable;115 }116 /**117 * @param int $idSite118 * @param string $period119 * @param Date $date120 * @param bool $segment121 * @param bool $expanded122 * @param bool $idSubtable123 *124 * @return DataTable|DataTable\Map125 */126 public function getPageUrlsFollowingSiteSearch($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false)127 {128 $dataTable = $this->getPageUrls($idSite, $period, $date, $segment, $expanded, $idSubtable);129 $this->keepPagesFollowingSearch($dataTable);130 return $dataTable;131 }132 /**133 * @param int $idSite134 * @param string $period135 * @param Date $date136 * @param bool $segment137 * @param bool $expanded138 * @param bool $idSubtable139 *140 * @return DataTable|DataTable\Map141 */142 public function getPageTitlesFollowingSiteSearch($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false)143 {144 $dataTable = $this->getPageTitles($idSite, $period, $date, $segment, $expanded, $idSubtable);145 $this->keepPagesFollowingSearch($dataTable);146 return $dataTable;147 }148 /**149 * @param DataTable $dataTable150 */151 protected function keepPagesFollowingSearch($dataTable)152 {153 // Keep only pages which are following site search154 $dataTable->filter('ColumnCallbackDeleteRow', array(155 'nb_hits_following_search',156 function ($value) {157 return $value <= 0;158 }159 ));160 }161 /**162 * Returns a DataTable with analytics information for every unique entry page URL, for163 * the specified site, period & segment.164 */165 public function getEntryPageUrls($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false)166 {167 $dataTable = $this->getPageUrls($idSite, $period, $date, $segment, $expanded, $idSubtable);168 $this->filterNonEntryActions($dataTable);169 return $dataTable;170 }171 /**172 * Returns a DataTable with analytics information for every unique exit page URL, for173 * the specified site, period & segment.174 */175 public function getExitPageUrls($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false)176 {177 $dataTable = $this->getPageUrls($idSite, $period, $date, $segment, $expanded, $idSubtable);178 $this->filterNonExitActions($dataTable);179 return $dataTable;180 }181 public function getPageUrl($pageUrl, $idSite, $period, $date, $segment = false)182 {183 $callBackParameters = array('Actions_actions_url', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false);184 $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $pageUrl, Action::TYPE_PAGE_URL);185 $this->filterPageDatatable($dataTable);186 $this->filterActionsDataTable($dataTable);187 return $dataTable;188 }189 public function getPageTitles($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false)190 {191 $dataTable = $this->getDataTableFromArchive('Actions_actions', $idSite, $period, $date, $segment, $expanded, $idSubtable);192 $this->filterPageDatatable($dataTable);193 $this->filterActionsDataTable($dataTable, $expanded);194 return $dataTable;195 }196 /**197 * Returns a DataTable with analytics information for every unique entry page title198 * for the given site, time period & segment.199 */200 public function getEntryPageTitles($idSite, $period, $date, $segment = false, $expanded = false,201 $idSubtable = false)202 {203 $dataTable = $this->getPageTitles($idSite, $period, $date, $segment, $expanded, $idSubtable);204 $this->filterNonEntryActions($dataTable);205 return $dataTable;206 }207 /**208 * Returns a DataTable with analytics information for every unique exit page title209 * for the given site, time period & segment.210 */211 public function getExitPageTitles($idSite, $period, $date, $segment = false, $expanded = false,212 $idSubtable = false)213 {214 $dataTable = $this->getPageTitles($idSite, $period, $date, $segment, $expanded, $idSubtable);215 $this->filterNonExitActions($dataTable);216 return $dataTable;217 }218 public function getPageTitle($pageName, $idSite, $period, $date, $segment = false)219 {220 $callBackParameters = array('Actions_actions', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false);221 $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $pageName, Action::TYPE_PAGE_TITLE);222 $this->filterPageDatatable($dataTable);223 $this->filterActionsDataTable($dataTable);224 return $dataTable;225 }226 public function getDownloads($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false)227 {228 $dataTable = $this->getDataTableFromArchive('Actions_downloads', $idSite, $period, $date, $segment, $expanded, $idSubtable);229 $this->filterActionsDataTable($dataTable, $expanded);230 return $dataTable;231 }232 public function getDownload($downloadUrl, $idSite, $period, $date, $segment = false)233 {234 $callBackParameters = array('Actions_downloads', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false);235 $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $downloadUrl, Action::TYPE_DOWNLOAD);236 $this->filterActionsDataTable($dataTable);237 return $dataTable;238 }239 public function getOutlinks($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false)240 {241 $dataTable = $this->getDataTableFromArchive('Actions_outlink', $idSite, $period, $date, $segment, $expanded, $idSubtable);242 $this->filterActionsDataTable($dataTable, $expanded);243 return $dataTable;244 }245 public function getOutlink($outlinkUrl, $idSite, $period, $date, $segment = false)246 {247 $callBackParameters = array('Actions_outlink', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false);248 $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $outlinkUrl, Action::TYPE_OUTLINK);249 $this->filterActionsDataTable($dataTable);250 return $dataTable;251 }252 public function getSiteSearchKeywords($idSite, $period, $date, $segment = false)253 {254 $dataTable = $this->getSiteSearchKeywordsRaw($idSite, $period, $date, $segment);255 $dataTable->deleteColumn(Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT);256 $this->filterPageDatatable($dataTable);257 $this->filterActionsDataTable($dataTable);258 $this->addPagesPerSearchColumn($dataTable);259 return $dataTable;260 }261 /**262 * Visitors can search, and then click "next" to view more results. This is the average number of search results pages viewed for this keyword.263 *264 * @param DataTable|DataTable\Simple|DataTable\Map $dataTable265 * @param string $columnToRead266 */267 protected function addPagesPerSearchColumn($dataTable, $columnToRead = 'nb_hits')268 {269 $dataTable->filter('ColumnCallbackAddColumnQuotient', array('nb_pages_per_search', $columnToRead, 'nb_visits', $precision = 1));270 }271 protected function getSiteSearchKeywordsRaw($idSite, $period, $date, $segment)272 {273 $dataTable = $this->getDataTableFromArchive('Actions_sitesearch', $idSite, $period, $date, $segment, $expanded = false);274 return $dataTable;275 }276 public function getSiteSearchNoResultKeywords($idSite, $period, $date, $segment = false)277 {278 $dataTable = $this->getSiteSearchKeywordsRaw($idSite, $period, $date, $segment);279 // Delete all rows that have some results280 $dataTable->filter('ColumnCallbackDeleteRow',281 array(282 Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT,283 function ($value) {284 return $value < 1;285 }286 ));287 $dataTable->deleteRow(DataTable::ID_SUMMARY_ROW);288 $dataTable->deleteColumn(Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT);289 $this->filterPageDatatable($dataTable);290 $this->filterActionsDataTable($dataTable);291 $this->addPagesPerSearchColumn($dataTable);292 return $dataTable;293 }294 /**295 * @param int $idSite296 * @param string $period297 * @param Date $date298 * @param bool $segment299 *300 * @return DataTable|DataTable\Map301 */302 public function getSiteSearchCategories($idSite, $period, $date, $segment = false)303 {304 Actions::checkCustomVariablesPluginEnabled();305 $customVariables = APICustomVariables::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true);306 $customVarNameToLookFor = ActionSiteSearch::CVAR_KEY_SEARCH_CATEGORY;307 $dataTable = new DataTable();308 // Handle case where date=last30&period=day309 // FIXMEA: this logic should really be refactored somewhere, this is ugly!310 if ($customVariables instanceof DataTable\Map) {311 $dataTable = $customVariables->getEmptyClone();312 $customVariableDatatables = $customVariables->getDataTables();313 foreach ($customVariableDatatables as $key => $customVariableTableForDate) {314 // we do not enter the IF, in the case idSite=1,3 AND period=day&date=datefrom,dateto,315 if ($customVariableTableForDate instanceof DataTable316 && $customVariableTableForDate->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)317 ) {318 $row = $customVariableTableForDate->getRowFromLabel($customVarNameToLookFor);319 if ($row) {320 $dateRewrite = $customVariableTableForDate->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart()->toString();321 $idSubtable = $row->getIdSubDataTable();322 $categories = APICustomVariables::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $dateRewrite, $idSubtable, $segment);323 $dataTable->addTable($categories, $key);324 }325 }326 }327 } elseif ($customVariables instanceof DataTable) {328 $row = $customVariables->getRowFromLabel($customVarNameToLookFor);329 if ($row) {330 $idSubtable = $row->getIdSubDataTable();331 $dataTable = APICustomVariables::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment);332 }333 }334 $this->filterActionsDataTable($dataTable);335 $this->addPagesPerSearchColumn($dataTable, $columnToRead = 'nb_actions');336 return $dataTable;337 }338 /**339 * Will search in the DataTable for a Label matching the searched string340 * and return only the matching row, or an empty datatable341 */342 protected function getFilterPageDatatableSearch($callBackParameters, $search, $actionType, $table = false,343 $searchTree = false)344 {345 if ($searchTree === false) {346 // build the query parts that are searched inside the tree347 if ($actionType == Action::TYPE_PAGE_TITLE) {348 $searchedString = Common::unsanitizeInputValue($search);349 } else {350 $idSite = $callBackParameters[1];351 try {352 $searchedString = PageUrl::excludeQueryParametersFromUrl($search, $idSite);353 } catch (Exception $e) {354 $searchedString = $search;355 }356 }357 ArchivingHelper::reloadConfig();358 $searchTree = ArchivingHelper::getActionExplodedNames($searchedString, $actionType);359 }360 if ($table === false) {361 // fetch the data table362 $table = call_user_func_array(array($this, 'getDataTableFromArchive'), $callBackParameters);363 if ($table instanceof DataTable\Map) {364 // search an array of tables, e.g. when using date=last30365 // note that if the root is an array, we filter all children366 // if an array occurs inside the nested table, we only look for the first match (see below)367 $dataTableMap = $table->getEmptyClone();368 foreach ($table->getDataTables() as $label => $subTable) {369 $newSubTable = $this->doFilterPageDatatableSearch($callBackParameters, $subTable, $searchTree);370 $dataTableMap->addTable($newSubTable, $label);371 }372 return $dataTableMap;373 }374 }375 return $this->doFilterPageDatatableSearch($callBackParameters, $table, $searchTree);376 }377 /**378 * This looks very similar to LabelFilter.php should it be refactored somehow? FIXME379 */380 protected function doFilterPageDatatableSearch($callBackParameters, $table, $searchTree)381 {382 // filter a data table array383 if ($table instanceof DataTable\Map) {384 foreach ($table->getDataTables() as $subTable) {385 $filteredSubTable = $this->doFilterPageDatatableSearch($callBackParameters, $subTable, $searchTree);386 if ($filteredSubTable->getRowsCount() > 0) {387 // match found in a sub table, return and stop searching the others388 return $filteredSubTable;389 }390 }391 // nothing found in all sub tables392 return new DataTable;393 }394 // filter regular data table395 if ($table instanceof DataTable) {396 // search for the first part of the tree search397 $search = array_shift($searchTree);398 $row = $table->getRowFromLabel($search);399 if ($row === false) {400 // not found401 $result = new DataTable;402 $result->setAllTableMetadata($table->getAllTableMetadata());403 return $result;404 }405 // end of tree search reached406 if (count($searchTree) == 0) {407 $result = new DataTable();408 $result->addRow($row);409 $result->setAllTableMetadata($table->getAllTableMetadata());410 return $result;411 }412 // match found on this level and more levels remaining: go deeper413 $idSubTable = $row->getIdSubDataTable();414 $callBackParameters[6] = $idSubTable;415 /**416 * @var \Piwik\Period $period417 */418 $period = $table->getMetadata('period');419 if (!empty($period)) {420 $callBackParameters[3] = $period->getDateStart() . ',' . $period->getDateEnd();421 }422 $table = call_user_func_array(array($this, 'getDataTableFromArchive'), $callBackParameters);423 return $this->doFilterPageDatatableSearch($callBackParameters, $table, $searchTree);424 }425 throw new Exception("For this API function, DataTable " . get_class($table) . " is not supported");426 }427 /**428 * Common filters for Page URLs and Page Titles429 *430 * @param DataTable|DataTable\Simple|DataTable\Map $dataTable431 */432 protected function filterPageDatatable($dataTable)433 {434 $columnsToRemove = array('bounce_rate');435 $dataTable->queueFilter('ColumnDelete', array($columnsToRemove));436 // Average time on page = total time on page / number visits on that page437 $dataTable->queueFilter('ColumnCallbackAddColumnQuotient',438 array('avg_time_on_page',439 'sum_time_spent',440 'nb_visits',441 0)442 );443 // Bounce rate = single page visits on this page / visits started on this page444 $dataTable->queueFilter('ColumnCallbackAddColumnPercentage',445 array('bounce_rate',446 'entry_bounce_count',447 'entry_nb_visits',448 0));449 // % Exit = Number of visits that finished on this page / visits on this page450 $dataTable->queueFilter('ColumnCallbackAddColumnPercentage',451 array('exit_rate',452 'exit_nb_visits',453 'nb_visits',454 0)455 );456 // Handle performance analytics457 $hasTimeGeneration = (array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_SUM_TIME_GENERATION)) > 0);458 if ($hasTimeGeneration) {459 // Average generation time = total generation time / number of pageviews460 $precisionAvgTimeGeneration = 3;461 $dataTable->queueFilter('ColumnCallbackAddColumnQuotient',462 array('avg_time_generation',463 'sum_time_generation',464 'nb_hits_with_time_generation',465 $precisionAvgTimeGeneration)466 );467 $dataTable->queueFilter('ColumnDelete', array(array('sum_time_generation')));468 } else {469 // No generation time: remove it from the API output and add it to empty_columns metadata, so that470 // the columns can also be removed from the view471 $dataTable->filter('ColumnDelete', array(array(472 Metrics::INDEX_PAGE_SUM_TIME_GENERATION,473 Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION,474 Metrics::INDEX_PAGE_MIN_TIME_GENERATION,475 Metrics::INDEX_PAGE_MAX_TIME_GENERATION476 )));477 if ($dataTable instanceof DataTable) {478 $emptyColumns = $dataTable->getMetadata(DataTable::EMPTY_COLUMNS_METADATA_NAME);479 if (!is_array($emptyColumns)) {480 $emptyColumns = array();481 }482 $emptyColumns[] = 'sum_time_generation';483 $emptyColumns[] = 'avg_time_generation';484 $emptyColumns[] = 'min_time_generation';485 $emptyColumns[] = 'max_time_generation';486 $dataTable->setMetadata(DataTable::EMPTY_COLUMNS_METADATA_NAME, $emptyColumns);487 }488 }489 }490 /**491 * Common filters for all Actions API492 *493 * @param DataTable|DataTable\Simple|DataTable\Map $dataTable494 * @param bool $expanded495 */496 protected function filterActionsDataTable($dataTable, $expanded = false)497 {498 // Must be applied before Sort in this case, since the DataTable can contain both int and strings indexes499 // (in the transition period between pre 1.2 and post 1.2 datatable structure)500 $dataTable->filter('ReplaceColumnNames');501 $dataTable->filter('Sort', array('nb_visits', 'desc', $naturalSort = false, $expanded));502 $dataTable->queueFilter('ReplaceSummaryRowLabel');503 }504 /**505 * Removes DataTable rows referencing actions that were never the first action of a visit.506 *507 * @param DataTable $dataTable508 */509 private function filterNonEntryActions($dataTable)510 {511 $dataTable->filter('ColumnCallbackDeleteRow',512 array('entry_nb_visits',513 function ($visits) {514 return !strlen($visits);515 }516 )517 );518 }519 /**520 * Removes DataTable rows referencing actions that were never the last action of a visit.521 *522 * @param DataTable $dataTable523 */524 private function filterNonExitActions($dataTable)525 {526 $dataTable->filter('ColumnCallbackDeleteRow',527 array('exit_nb_visits',528 function ($visits) {529 return !strlen($visits);530 })531 );532 }533 protected function getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null, $depth = null)534 {535 $skipAggregationOfSubTables = false;536 if ($period == 'range'537 && empty($idSubtable)538 && empty($expanded)539 && !Request::shouldLoadFlatten()540 ) {541 $skipAggregationOfSubTables = false;542 }543 return Archive::getDataTableFromArchive($name, $idSite, $period, $date, $segment, $expanded, $idSubtable, $skipAggregationOfSubTables, $depth);544 }545}...

Full Screen

Full Screen

class.uiitem.inc.php

Source:class.uiitem.inc.php Github

copy

Full Screen

...53 'vendor' => 'invoice'54 );55 $this->dry_run = false;56 $datatable = array();57 $this->populateDataTable($datatable);58 $json = $this->populateJson($datatable);59 if(phpgw::get_var('phpgw_return_as') == 'json')60 {61 return $json;62 }63 $datatable['json_data'] = json_encode($json);64 // Prepare template variables and process XSLT65 $template_vars = array();66 $template_vars['datatable'] = $datatable;67 $GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));68 //print_r($template_vars);69 $GLOBALS['phpgw']->xslttpl->set_var('phpgw', $template_vars);70 $this->setupCss();71 //Title of Page72 $GLOBALS['phpgw_info']['flags']['app_header'] = lang('actor') . ': ' . lang('list ' . $this->role);73 }74 private function populateJson(&$datatable)75 {76 $json = array77 (78 'recordsReturned' => $datatable['pagination']['records_returned'],79 'totalRecords' => (int)$datatable['pagination']['records_total'],80 'startIndex' => $datatable['pagination']['records_start'],81 'sort' => $datatable['sorting']['order'],82 'dir' => $datatable['sorting']['sort'],83 'records' => array()84 );85 // values for datatable86 if(isset($datatable['rows']['row']) && is_array($datatable['rows']['row']))87 {88 foreach($datatable['rows']['row'] as $row)89 {90 $json_row = array();91 foreach($row['column'] as $column)92 {93 if(isset($column['format']) && $column['format'] == "link" && $column['java_link'] == true)94 {95 $json_row[$column['name']] = "<a href='#' id='" . $column['link'] . "' onclick='javascript:filter_data(this.id);'>" . $column['value'] . "</a>";96 }97 elseif(isset($column['format']) && $column['format'] == "link")98 {99 $json_row[$column['name']] = "<a href='" . $column['link'] . "'>" . $column['value'] . "</a>";100 }101 else102 {103 $json_row[$column['name']] = $column['value'];104 }105 }106 $json['records'][] = $json_row;107 }108 }109 110 // right in datatable111 if(isset($datatable['rowactions']['action']) && is_array($datatable['rowactions']['action']))112 {113 $json ['rights'] = $datatable['rowactions']['action'];114 }115 return $json;116 }117 private function populateDataTable(&$datatable)118 {119 if(phpgw::get_var('phpgw_return_as') != 'json')120 {121 $this->setFormAndNonJsonProperties($datatable);122 }123 $item_list = $this->so->read($this->dry_run);124 $uicols = $this->so->uicols;125 $uicols_count = count($uicols['name']);126 127 $this->populateDatatableRows($item_list, $datatable, $uicols, $uicols_count);128 $this->addRowActionsToDatatable($datatable);129 $this->populateColumnNames($datatable, $uicols, $uicols_count);130 131 // Pagination and sort values...

Full Screen

Full Screen

DataTable

Using AI Code Generation

copy

Full Screen

1require_once 'Cucumber/Common/DataTable.php';2$dt = new Cucumber_Common_DataTable();3$dt->loadFile('data.txt');4$dt->loadFile('data2.txt');5$dt->loadFile('data3.txt');6print_r($dt->getRows());7 (8 (9 (10 (11 (12 (13 (14 (15 (16 (

Full Screen

Full Screen

DataTable

Using AI Code Generation

copy

Full Screen

1require_once('CucumberCommonLibrary.php');2$dt = new DataTable();3$dt->addColumns(array("ID","Name","Age"));4$dt->addRow(array("1","John","22"));5$dt->addRow(array("2","Peter","23"));6$dt->addRow(array("3","Mark","24"));7$dt->addRow(array("4","Steve","25"));8$dt->addRow(array("5","John","26"));9$dt->addRow(array("6","Peter","27"));10$dt->addRow(array("7","Mark","28"));11$dt->addRow(array("8","Steve","29"));12$dt->addRow(array("9","John","30"));13$dt->addRow(array("10","Peter","31"));14$dt->addRow(array("11","Mark","32"));15$dt->addRow(array("12","Steve","33"));16$dt->addRow(array("13","John","34"));17$dt->addRow(array("14","Peter","35"));18$dt->addRow(array("15","Mark","36"));19$dt->addRow(array("16","Steve","37"));20$dt->addRow(array("17","John","38"));21$dt->addRow(array("18","Peter","39"));22$dt->addRow(array("19","Mark","40"));23$dt->addRow(array("20","Steve","41"));24$dt->addRow(array("21","John","42"));25$dt->addRow(array("22","Peter","43"));26$dt->addRow(array("23","Mark","44"));27$dt->addRow(array("24","Steve","45"));28$dt->addRow(array("25","John","46"));29$dt->addRow(array("26","Peter","47"));30$dt->addRow(array("27","Mark","48"));31$dt->addRow(array("28","Steve","49"));32$dt->addRow(array("29","John","50"));33$dt->addRow(array("30","Peter","51"));34$dt->addRow(array("31","Mark","52"));35$dt->addRow(array("32","Steve","53"));36$dt->addRow(array("33","John","54"));37$dt->addRow(array("34","Peter","55"));38$dt->addRow(array("35","Mark","56"));39$dt->addRow(array("36","Steve","57"));

Full Screen

Full Screen

DataTable

Using AI Code Generation

copy

Full Screen

1include_once("DataTable.php");2$dataTable = new DataTable();3$myArray = array();4$myArray = $dataTable->getDataFromTable("testData", "testData", "testData", "testData", "testData");5print_r($myArray);6foreach($myArray as $key=>$value)7{8";9}

Full Screen

Full Screen

DataTable

Using AI Code Generation

copy

Full Screen

1require_once '../cucumber/Cucumber.php';2$dt = new DataTable();3$dt->getExcelData('data.xlsx');4$dt->getCSVData('data.csv');5$dt->getJSONData('data.json');6$dt->getXMLData('data.xml');7$dt->getDBData('SELECT * FROM table_name');8$dt->getArrayData(array(array('name'=>'John','age'=>25),array('name'=>'Jane','age'=>20)));9$dt->getObjectData((object)array(array('name'=>'John','age'=>25),array('name'=>'Jane','age'=>20)));10$dt->getStringData("name,age11Jane,20");12$dt->getStringData("name,age13Jane,20");14$dt->getStringData("name,age15Jane,20");16$dt->getStringData("name,age17Jane,20");18$dt->getStringData("name,age19Jane,20");20$dt->getStringData("name,age21Jane,20");22$dt->getStringData("name,age23Jane,20");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cucumber Common Library automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in DataTable

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful