本文整理汇总了PHP中Piwik\DataTable::getKeyName方法的典型用法代码示例。如果您正苦于以下问题:PHP DataTable::getKeyName方法的具体用法?PHP DataTable::getKeyName怎么用?PHP DataTable::getKeyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\DataTable
的用法示例。
在下文中一共展示了DataTable::getKeyName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderTable
/**
* Computes the output for the given data table
*
* @param DataTable $table
* @return string
* @throws Exception
*/
protected function renderTable($table)
{
if (!$table instanceof DataTable\Map || $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 = Common::getRequestVar('idSite', 1, 'int');
$period = Common::getRequestVar('period');
$piwikUrl = SettingsPiwik::getPiwikUrl() . "?module=CoreHome&action=index&idSite=" . $idSite . "&period=" . $period;
$out = "";
$moreRecentFirst = array_reverse($table->getDataTables(), true);
foreach ($moreRecentFirst as $date => $subtable) {
/** @var DataTable $subtable */
$timestamp = $subtable->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart()->getTimestamp();
$site = $subtable->getMetadata(Archive\DataTableFactory::TABLE_METADATA_SITE_INDEX);
$pudDate = date('r', $timestamp);
$dateInSiteTimezone = Date::factory($timestamp);
if ($site) {
$dateInSiteTimezone = $dateInSiteTimezone->setTimezone($site->getTimezone());
}
$dateInSiteTimezone = $dateInSiteTimezone->toString('Y-m-d');
$thisPiwikUrl = Common::sanitizeInputValue($piwikUrl . "&date={$dateInSiteTimezone}");
$siteName = $site ? $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 .= Common::sanitizeInputValue($this->renderDataTable($subtable));
$out .= "</description>\n\t</item>\n";
}
$header = $this->getRssHeader();
$footer = $this->getRssFooter();
return $header . $out . $footer;
}