本文整理汇总了PHP中CSV::PublishData方法的典型用法代码示例。如果您正苦于以下问题:PHP CSV::PublishData方法的具体用法?PHP CSV::PublishData怎么用?PHP CSV::PublishData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSV
的用法示例。
在下文中一共展示了CSV::PublishData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnLoadPageData
function OnLoadPageData()
{
# Require an API key to include personal contact details to avoid spam bots picking them up
$api_keys = $this->GetSettings()->GetApiKeys();
$valid_key = false;
if (isset($_GET['key']) and in_array($_GET['key'], $api_keys)) {
$valid_key = true;
}
$data = array();
$data[] = array("Match id", "Title", "Start time", "Latitude", "Longitude", "Website", "Description");
require_once 'stoolball/match-manager.class.php';
require_once "search/match-search-adapter.class.php";
$match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection());
$match_manager->FilterByDateStart(gmdate("U"));
$match_manager->ReadByMatchId();
while ($match_manager->MoveNext()) {
$match = $match_manager->GetItem();
$adapter = new MatchSearchAdapter($match);
/* @var $match Match */
# Add this match to the data array
$data[] = array($match->GetId(), $match->GetTitle(), $match->GetStartTime(), $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetLatitude() : "", $match->GetGround() instanceof Ground ? $match->GetGround()->GetAddress()->GetLongitude() : "", "https://" . $this->GetSettings()->GetDomain() . $match->GetNavigateUrl(), $adapter->GetSearchDescription());
}
unset($match_manager);
require_once "data/csv.class.php";
CSV::PublishData($data);
# Test code only. Comment out CSV publish line above to enable display as a table.
require_once "xhtml/tables/xhtml-table.class.php";
$table = new XhtmlTable();
$table->BindArray($data, false, false);
echo $table;
}
示例2: OnLoadPageData
function OnLoadPageData()
{
# Require an API key to include personal contact details to avoid spam bots picking them up
$api_keys = $this->GetSettings()->GetApiKeys();
$valid_key = false;
if (isset($_GET['key']) and in_array($_GET['key'], $api_keys)) {
$valid_key = true;
}
$data = array();
$data[] = array("Club/ facility name", "Address 1", "Address 2", "Address 3", "Address 4", "Address 5", "City", "Postcode", "Country", "Tel", "Email", "Website", "Activities", "Opening times");
require_once 'stoolball/team-manager.class.php';
$team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection());
$team_manager->FilterByActive(true);
$team_manager->FilterByTeamType(array(Team::REGULAR));
$team_manager->ReadById();
while ($team_manager->MoveNext()) {
/* @var $team Team */
$team = $team_manager->GetItem();
# NHS choices can only import records with a postcode
if (!$team->GetGround()->GetAddress()->GetPostcode()) {
continue;
}
$address = array();
if ($team->GetGround()->GetAddress()->GetSaon()) {
$address[] = $team->GetGround()->GetAddress()->GetSaon();
}
if ($team->GetGround()->GetAddress()->GetPaon()) {
$address[] = $team->GetGround()->GetAddress()->GetPaon();
}
if ($team->GetGround()->GetAddress()->GetStreetDescriptor()) {
$address[] = $team->GetGround()->GetAddress()->GetStreetDescriptor();
}
if ($team->GetGround()->GetAddress()->GetLocality()) {
$address[] = $team->GetGround()->GetAddress()->GetLocality();
}
if ($team->GetGround()->GetAddress()->GetAdministrativeArea()) {
$address[] = $team->GetGround()->GetAddress()->GetAdministrativeArea();
}
$data[] = array($team->GetName() . " Stoolball Club", isset($address[0]) ? $address[0] : "", isset($address[1]) ? $address[1] : "", isset($address[2]) ? $address[2] : "", isset($address[3]) ? $address[3] : "", isset($address[4]) ? $address[4] : "", $team->GetGround()->GetAddress()->GetTown(), $team->GetGround()->GetAddress()->GetPostcode(), "England", $valid_key ? $team->GetContactPhone() : "", $valid_key ? $team->GetContactEmail() : "", $team->GetWebsiteUrl() ? $team->GetWebsiteUrl() : "https://" . $this->GetSettings()->GetDomain() . $team->GetNavigateUrl(), "stoolball", preg_replace('/\\[[^]]+\\]/', "", $team->GetPlayingTimes()));
}
unset($team_manager);
require_once "data/csv.class.php";
CSV::PublishData($data);
# Test code only. Comment out CSV publish line above to enable display as a table.
require_once "xhtml/tables/xhtml-table.class.php";
$table = new XhtmlTable();
$table->BindArray($data, false, false);
echo $table;
}
示例3: OnLoadPageData
function OnLoadPageData()
{
# Require an API key to include personal contact details to avoid spam bots picking them up
$api_keys = $this->GetSettings()->GetApiKeys();
$valid_key = false;
if (isset($_GET['key']) and in_array($_GET['key'], $api_keys)) {
$valid_key = true;
}
$data = array();
$data[] = array("Team id", "Team name", "Player type", "Home ground name", "Street name", "Locality", "Town", "Administrative area", "Postcode", "Country", "Latitude", "Longitude", "Contact phone", "Contact email", "Website", "Description");
require_once 'stoolball/team-manager.class.php';
$team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection());
$team_manager->FilterByActive(true);
$team_manager->FilterByTeamType(array(Team::REGULAR));
$team_manager->ReadById();
while ($team_manager->MoveNext()) {
$team = $team_manager->GetItem();
/* @var $team Team */
# Spogo can only import records with contact details
if (!$team->GetContactPhone() and !$team->GetContactEmail()) {
continue;
}
# Combine free text fields into a description field
$description = $team->GetIntro();
if ($description) {
$description .= "\n\n";
}
if ($team->GetPlayingTimes()) {
$description .= $team->GetPlayingTimes() . "\n\n";
}
if ($team->GetCost()) {
$description .= $team->GetCost();
}
# Add this team to the data array
$data[] = array($team->GetId(), $team->GetName() . " Stoolball Club", PlayerType::Text($team->GetPlayerType()), $team->GetGround()->GetAddress()->GetPaon(), $team->GetGround()->GetAddress()->GetStreetDescriptor(), $team->GetGround()->GetAddress()->GetLocality(), $team->GetGround()->GetAddress()->GetTown(), $team->GetGround()->GetAddress()->GetAdministrativeArea(), $team->GetGround()->GetAddress()->GetPostcode(), "England", $team->GetGround()->GetAddress()->GetLatitude(), $team->GetGround()->GetAddress()->GetLongitude(), $valid_key ? $team->GetContactPhone() : "", $valid_key ? $team->GetContactEmail() : "", $team->GetWebsiteUrl() ? $team->GetWebsiteUrl() : "https://" . $this->GetSettings()->GetDomain() . $team->GetNavigateUrl(), trim(html_entity_decode(strip_tags($description), ENT_QUOTES)));
}
unset($team_manager);
require_once "data/csv.class.php";
CSV::PublishData($data);
# Test code only. Comment out CSV publish line above to enable display as a table.
require_once "xhtml/tables/xhtml-table.class.php";
$table = new XhtmlTable();
$table->BindArray($data, false, false);
echo $table;
}
示例4: OnLoadPageData
//.........这里部分代码省略.........
break;
default:
$matches = array();
$is_match = preg_match("/^most-scores-of-([0-9]+)\$/", $this->which_statistic, $matches);
if ($is_match === 1) {
$match_scores_of = $matches[1];
require_once "stoolball/statistics/most-scores-of.class.php";
$this->statistic = new MostScoresOf($match_scores_of, $statistics_manager);
}
$is_match = preg_match("/^most-([0-9][0-9]?)-wickets\$/", $this->which_statistic, $matches);
if ($is_match === 1) {
$how_many_wickets = $matches[1];
require_once "stoolball/statistics/most-wicket-hauls-of.class.php";
$this->statistic = new \Stoolball\Statistics\MostWicketHaulsOf($how_many_wickets, $statistics_manager);
}
break;
}
# Is this a request for CSV data?
$csv = (isset($_GET["format"]) and $_GET["format"] == "csv");
if ($csv) {
$statistics_manager->OutputAsCsv($this->statistic->ColumnHeaders());
}
# Apply player filter first because it can be used to limit the choices for other filters
if ($this->statistic->SupportsFilterByPlayer()) {
$this->filter .= StatisticsFilter::ApplyPlayerFilter($this->GetSettings(), $this->GetDataConnection(), $statistics_manager);
}
# Apply filters common to all statistics
$this->filter_control = new StatisticsFilterControl();
if ($this->statistic->SupportsFilterByBattingPosition()) {
$filter_batting_position = StatisticsFilter::SupportBattingPositionFilter($statistics_manager);
$this->filter_control->SupportBattingPositionFilter($filter_batting_position);
$this->filter .= $filter_batting_position[2];
}
$match_type_filter_description = "";
# If player filter applied, no point filtering by player type because they're associated with a team of one player type.
# There is the edge case of a ladies team playing in a mixed match, but it would be more confusing than useful to offer it.
if (!isset($_GET['player'])) {
$filter_player_type = StatisticsFilter::SupportPlayerTypeFilter($statistics_manager);
$this->filter_control->SupportPlayerTypeFilter($filter_player_type);
$match_type_filter_description .= $filter_player_type[2];
}
$filter_match_type = StatisticsFilter::SupportMatchTypeFilter($statistics_manager);
$this->filter_control->SupportMatchTypeFilter($filter_match_type);
$match_type_filter_description .= $filter_match_type[2];
$this->filter .= StatisticsFilter::CombineMatchTypeDescriptions($match_type_filter_description);
# If player filter applied, no point filtering by team. Check for player filter is stricter than this
# but this is good enough. If this applies, but the player filter isn't applied, it's because someone
# is playing with the query string, so that's tough.
if (!isset($_GET['player'])) {
$filter_team = StatisticsFilter::SupportTeamFilter($statistics_manager);
$this->filter_control->SupportTeamFilter($filter_team);
$this->filter .= $filter_team[2];
}
$filter_opposition = StatisticsFilter::SupportOppositionFilter($statistics_manager);
$this->filter_control->SupportOppositionFilter($filter_opposition);
$this->filter .= $filter_opposition[2];
$filter_competition = StatisticsFilter::SupportCompetitionFilter($statistics_manager);
$this->filter_control->SupportCompetitionFilter($filter_competition);
$this->filter .= $filter_competition[2];
$this->filter .= StatisticsFilter::ApplySeasonFilter($this->GetSettings(), $this->GetDataConnection(), $statistics_manager);
$filter_ground = StatisticsFilter::SupportGroundFilter($statistics_manager);
$this->filter_control->SupportGroundFilter($filter_ground);
$this->filter .= $filter_ground[2];
$filter_date = StatisticsFilter::SupportDateFilter($statistics_manager);
if (!is_null($filter_date[0])) {
$this->filter_control->SupportAfterDateFilter($filter_date[0]);
}
if (!is_null($filter_date[1])) {
$this->filter_control->SupportBeforeDateFilter($filter_date[1]);
}
$this->filter .= $filter_date[2];
$this->filter .= StatisticsFilter::ApplyTournamentFilter($this->GetSettings(), $this->GetDataConnection(), $statistics_manager);
$filter_innings = StatisticsFilter::SupportInningsFilter($statistics_manager);
$this->filter_control->SupportInningsFilter($filter_innings[1]);
$this->filter .= $filter_innings[2];
$filter_won_match = StatisticsFilter::SupportMatchResultFilter($statistics_manager);
$this->filter_control->SupportMatchResultFilter($filter_won_match[1]);
$this->filter .= $filter_won_match[2];
# Configure paging of results
if (!$csv and $this->statistic->SupportsPagedResults()) {
require_once 'data/paged-results.class.php';
$this->paging = new PagedResults();
$this->paging->SetPageName($this->which_statistic);
$this->paging->SetQueryString(preg_replace("/statistic={$this->which_statistic}&?/", "", $this->paging->GetQueryString()));
$this->paging->SetPageSize(50);
$this->paging->SetResultsTextSingular($this->statistic->ItemTypeSingular());
$this->paging->SetResultsTextPlural($this->statistic->ItemTypePlural());
$statistics_manager->FilterByPage($this->paging->GetPageSize(), $this->paging->GetCurrentPage());
}
$this->data = $this->statistic->ReadStatistic();
if (is_array($this->data)) {
if ($csv) {
require_once "data/csv.class.php";
CSV::PublishData($this->data);
} else {
$this->paging->SetTotalResults(array_shift($this->data));
}
}
unset($statistics_manager);
}