本文整理匯總了PHP中Piwik_DataTable::getKeyName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Piwik_DataTable::getKeyName方法的具體用法?PHP Piwik_DataTable::getKeyName怎麽用?PHP Piwik_DataTable::getKeyName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik_DataTable
的用法示例。
在下文中一共展示了Piwik_DataTable::getKeyName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderTable
/**
* Computes the output for the given data table
*
* @param Piwik_DataTable $table
* @return string
* @throws Exception
*/
protected function renderTable($table)
{
if (!$table instanceof Piwik_DataTable_Array || $table->getKeyName() != 'date') {
throw new Exception("RSS feeds can be generated for one specific website &idSite=X." . "\nPlease specify only one idSite or consider using &format=XML instead.");
}
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
$period = Piwik_Common::getRequestVar('period');
$piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName() . "?module=CoreHome&action=index&idSite=" . $idSite . "&period=" . $period;
$out = "";
$moreRecentFirst = array_reverse($table->getArray(), true);
foreach ($moreRecentFirst as $date => $subtable) {
$timestamp = $table->metadata[$date]['timestamp'];
$site = $table->metadata[$date]['site'];
$pudDate = date('r', $timestamp);
$dateInSiteTimezone = Piwik_Date::factory($timestamp)->setTimezone($site->getTimezone())->toString('Y-m-d');
$thisPiwikUrl = Piwik_Common::sanitizeInputValue($piwikUrl . "&date={$dateInSiteTimezone}");
$siteName = $site->getName();
$title = $siteName . " on " . $date;
$out .= "\t<item>\n\t\t<pubDate>{$pudDate}</pubDate>\n\t\t<guid>{$thisPiwikUrl}</guid>\n\t\t<link>{$thisPiwikUrl}</link>\n\t\t<title>{$title}</title>\n\t\t<author>http://piwik.org</author>\n\t\t<description>";
$out .= Piwik_Common::sanitizeInputValue($this->renderDataTable($subtable));
$out .= "</description>\n\t</item>\n";
}
$header = $this->getRssHeader();
$footer = $this->getRssFooter();
return $header . $out . $footer;
}
示例2: manipulate
/**
* This method can be used by subclasses to iterate over data tables that might be
* data table arrays. It calls back the template method self::doManipulate for each table.
* This way, data table arrays can be handled in a transparent fashion.
*
* @param Piwik_DataTable_Array|Piwik_DataTable $dataTable
* @throws Exception
* @return Piwik_DataTable_Array|Piwik_DataTable
*/
protected function manipulate($dataTable)
{
if ($dataTable instanceof Piwik_DataTable_Array) {
$newTableArray = new Piwik_DataTable_Array();
$newTableArray->metadata = $dataTable->metadata;
$newTableArray->setKeyName($dataTable->getKeyName());
foreach ($dataTable->getArray() as $date => $subTable) {
// for period=week, the label is "2011-08-15 to 2011-08-21", which is
// an invalid date parameter => only use the first date
// in other languages the whole string does not start with the date so
// we need to preg match it.
if (!preg_match('/[0-9]{4}(-[0-9]{2})?(-[0-9]{2})?/', $date, $match)) {
throw new Exception("Could not recognize date: {$date}");
}
$dateForApiRequest = $match[0];
$subTable = $this->doManipulate($subTable, $dateForApiRequest);
$newTableArray->addTable($subTable, $date);
}
return $newTableArray;
}
if ($dataTable instanceof Piwik_DataTable) {
return $this->doManipulate($dataTable);
}
return $dataTable;
}
示例3: renderTable
/**
* Computes the output for the given data table
*
* @param Piwik_DataTable $table
* @return string
*/
protected function renderTable($table)
{
if ($table instanceof Piwik_DataTable_Array) {
foreach ($table->getArray() as $date => $subtable) {
if ($subtable->getRowsCount()) {
$this->buildTableStructure($subtable, '_' . $table->getKeyName(), $date);
}
}
} else {
if ($table->getRowsCount()) {
$this->buildTableStructure($table);
}
}
$out = $this->renderDataTable();
return $out;
}