本文整理匯總了PHP中Piwik_DataTable::addRowsFromArrayWithIndexLabel方法的典型用法代碼示例。如果您正苦於以下問題:PHP Piwik_DataTable::addRowsFromArrayWithIndexLabel方法的具體用法?PHP Piwik_DataTable::addRowsFromArrayWithIndexLabel怎麽用?PHP Piwik_DataTable::addRowsFromArrayWithIndexLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik_DataTable
的用法示例。
在下文中一共展示了Piwik_DataTable::addRowsFromArrayWithIndexLabel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getPlanetRatios
public function getPlanetRatios()
{
$planetRatios = array('Mercury' => 0.382, 'Venus' => 0.949, 'Earth' => 1.0, 'Mars' => 0.532, 'Jupiter' => 11.209, 'Saturn' => 9.449, 'Uranus' => 4.007, 'Neptune' => 3.883);
// convert this array to a DataTable object
$dataTable = new Piwik_DataTable();
$dataTable->addRowsFromArrayWithIndexLabel($planetRatios);
return $dataTable;
}
示例2: getRank
/**
* Get rank
*
* @param string $url URL to request Ranks for
* @return Piwik_DataTable
*/
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$rank = new Piwik_SEO_RankChecker($url);
$data = array('Google PageRank' => array('rank' => $rank->getPageRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'pagerank'), Piwik_Translate('SEO_AlexaRank') => array('rank' => $rank->getAlexaRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://alexa.com'), 'id' => 'alexa'), Piwik_Translate('SEO_DomainAge') => array('rank' => $rank->getAge(), 'logo' => 'plugins/SEO/images/whois.png', 'id' => 'domain-age'));
$dataTable = new Piwik_DataTable();
$dataTable->addRowsFromArrayWithIndexLabel($data);
return $dataTable;
}
示例3: getRank
/**
* Get rank
*
* @param string $url URL to request Ranks for
* @return Piwik_DataTable
*/
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$rank = new Piwik_SEO_RankChecker($url);
$data = array('Google PageRank' => array('rank' => $rank->getPageRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'pagerank'), Piwik_Translate('SEO_Google_IndexedPages') => array('rank' => $rank->getIndexedPagesGoogle(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'google-index'), Piwik_Translate('SEO_Bing_IndexedPages') => array('rank' => $rank->getIndexedPagesBing(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://bing.com'), 'id' => 'bing-index'), Piwik_Translate('SEO_AlexaRank') => array('rank' => $rank->getAlexaRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://alexa.com'), 'id' => 'alexa'), Piwik_Translate('SEO_DomainAge') => array('rank' => $rank->getAge(), 'logo' => 'plugins/SEO/images/whois.png', 'id' => 'domain-age'));
// Add DMOZ only if > 0 entries found
$dmozRank = array('rank' => $rank->getDmoz(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://dmoz.org'), 'id' => 'dmoz');
if ($dmozRank['rank'] > 0) {
$data[Piwik_Translate('SEO_Dmoz')] = $dmozRank;
}
$dataTable = new Piwik_DataTable();
$dataTable->addRowsFromArrayWithIndexLabel($data);
return $dataTable;
}
示例4: getDataTableWithSubtablesFromArraysIndexedByLabel
/**
* Helper function that returns the multiple serialized DataTable of the given PHP array.
* The DataTable here associates a subtable to every row of the level 0 array.
* This is used for example for search engines.
* Every search engine (level 0) has a subtable containing the keywords.
*
* The $arrayLevel0 must have the format
* Example: array (
* // Yahoo.com => array( kwd1 => stats, kwd2 => stats )
* LABEL => array(col1 => X, col2 => Y),
* LABEL2 => array(col1 => X, col2 => Y),
* )
*
* The $subArrayLevel1ByKey must have the format
* Example: array(
* // Yahoo.com => array( stats )
* LABEL => #Piwik_DataTable_ForLABEL,
* LABEL2 => #Piwik_DataTable_ForLABEL2,
* )
*
*
* @param array $arrayLevel0
* @param array of Piwik_DataTable $subArrayLevel1ByKey
* @return array Array with N elements: the strings of the datatable serialized
*/
public function getDataTableWithSubtablesFromArraysIndexedByLabel($arrayLevel0, $subArrayLevel1ByKey)
{
$tablesByLabel = array();
foreach ($arrayLevel0 as $label => $aAllRowsForThisLabel) {
$table = new Piwik_DataTable();
$table->addRowsFromArrayWithIndexLabel($aAllRowsForThisLabel);
$tablesByLabel[$label] = $table;
}
$parentTableLevel0 = new Piwik_DataTable();
$parentTableLevel0->addRowsFromArrayWithIndexLabel($subArrayLevel1ByKey, $tablesByLabel);
return $parentTableLevel0;
}
示例5: getDatabaseUsageSummary
/**
* Returns a datatable summarizing how data is distributed among Piwik tables.
*
* This function will group tracker tables, numeric archive tables, blob archive tables
* and other tables together so only four rows are shown.
*
* @return Piwik_DataTable A datatable with three columns: 'data_size', 'index_size', 'row_count'.
*/
public function getDatabaseUsageSummary()
{
Piwik::checkUserIsSuperUser();
$emptyRow = array('data_size' => 0, 'index_size' => 0, 'row_count' => 0);
$rows = array('tracker_data' => $emptyRow, 'metric_data' => $emptyRow, 'report_data' => $emptyRow, 'other_data' => $emptyRow);
foreach ($this->metadataProvider->getAllTablesStatus() as $status) {
if ($this->isNumericArchiveTable($status['Name'])) {
$rowToAddTo =& $rows['metric_data'];
} else {
if ($this->isBlobArchiveTable($status['Name'])) {
$rowToAddTo =& $rows['report_data'];
} else {
if ($this->isTrackerTable($status['Name'])) {
$rowToAddTo =& $rows['tracker_data'];
} else {
$rowToAddTo =& $rows['other_data'];
}
}
}
$rowToAddTo['data_size'] += $status['Data_length'];
$rowToAddTo['index_size'] += $status['Index_length'];
$rowToAddTo['row_count'] += $status['Rows'];
}
$result = new Piwik_DataTable();
$result->addRowsFromArrayWithIndexLabel($rows);
return $result;
}