当前位置: 首页>>代码示例>>PHP>>正文


PHP DataSource::createCollectiveReader方法代码示例

本文整理汇总了PHP中DataSource::createCollectiveReader方法的典型用法代码示例。如果您正苦于以下问题:PHP DataSource::createCollectiveReader方法的具体用法?PHP DataSource::createCollectiveReader怎么用?PHP DataSource::createCollectiveReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataSource的用法示例。


在下文中一共展示了DataSource::createCollectiveReader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Stier

/*----Import libs----*/
require "Html.php";
require "Stier.php";
require "lib/SiteContext.php";
require "lib/StatSite.php";
require "lib/Localizer.php";
/*----Init vars----*/
//Stier og options
$stier = new Stier();
//Henter variable udefra
$ind = Html::setPostOrGetVars($HTTP_POST_VARS, $HTTP_GET_VARS);
//Tjekker brugernavnet
$collReader = DataSource::createCollectiveReader($stier);
//Instantierer klassen med standardkode
$datasource = DataSource::createCollectiveReader($stier);
$lib = new Html($ind, $datasource);
//Instantierer <code>SiteContext</code>-objektet.
$siteContext = new SiteContext($lib, $stier, $ind, 'da');
$lib->setSiteContext($siteContext);
$lib->setStier($stier);
//Sets the code lib in the site context
$siteContext->setCodeLib($lib);
//Was the datafile fetched successfully
/*	$errors = new Errors();
	if ($res === -2) {
		$errors->addError(new Error(2, sprintf($siteContext->getLocale('errDamagedDatasource'), $stier->getOption('name_of_service'))));
	} elseif (! $res or $res === 0) {
		$errors->addError(new Error(2, sprintf($siteContext->getLocale('errDatasourceInaccessible'), $stier->getOption('name_of_service'))));
	}
	if ($errors->isOccured()) {
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:30,代码来源:collective.php

示例2: dirname

<?php

/*----Import libs----*/
require_once dirname(__FILE__) . "/Html.php";
require_once dirname(__FILE__) . "/Stier.php";
require_once dirname(__FILE__) . "/lib/SiteContext.php";
require_once dirname(__FILE__) . "/lib/StatSite.php";
require_once dirname(__FILE__) . "/lib/Localizer.php";
/*----Init vars----*/
//Paths and options.
$settings = new Stier();
//Get site parameters.
$http_vars = Html::setPostOrGetVars($HTTP_POST_VARS, $HTTP_GET_VARS);
//Instantierer klassen med standardkode
$datasource = DataSource::createCollectiveReader($settings);
$lib = new Html($http_vars, $datasource);
//Make a SiteContext (in da=danish)
$siteContext = new SiteContext($lib, $settings, $http_vars, 'da');
$lib->setSiteContext($siteContext);
$lib->setStier($settings);
//Sets the code lib in the site context
$siteContext->setCodeLib($lib);
//Show index or stat site?
$dateInfo = Html::getDateFromPathinfo();
if (count($dateInfo) === 0) {
    //instantiate the stat site with the default type.
    $indexSite = new CollectiveIndex($siteContext, '');
    //Generate HTML
    $pageHtml = $indexSite->generateSiteCached();
    $indexSite->outputHeaders();
    //Tell the browser much there is.
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:31,代码来源:total.php

示例3: generateSite

 /**
  * Generates the site.
  *
  * @public
  * @return the code for the site.
  */
 function generateSite()
 {
     //Initialise
     $sg =& $this->siteGenerator;
     $locale =& $this->siteContext->getLocalizer();
     $lib =& $this->siteContext->getCodeLib();
     $options =& $lib->getStier();
     $collReader = DataSource::createCollectiveReader($lib->getStier());
     //Adds the main title
     $headline = $locale->getLocale('collIndexHeadline');
     $mainTitle = $sg->newElement('headline');
     $mainTitle->setHeadline($headline);
     $mainTitle->setSize(1);
     $sg->addElement($mainTitle);
     //Tell the time span
     $timeSpanText = $sg->newElement('text');
     $timeSpanText->setText($locale->getLocale('collIndexDesc'));
     $timeSpanText->setParagraph(1);
     $sg->addElement($timeSpanText);
     //Get the data.
     $collDates = $collReader->getDataDates();
     //And show it:
     $months = $locale->getLocale('months');
     $weekLabel = $locale->getLocale('colCalWeek');
     $weeks = $locale->getLocale('shortWeekDays');
     //Make week start monday.
     Html::array_rotate($weeks);
     //Insert an empty string a index 0 to comply with the class.
     array_unshift($months, "");
     array_unshift($weeks, "");
     //Make months upper case.
     foreach ($months as $i => $month) {
         $months[$i] = ucfirst($month);
     }
     $totalBaseurl = $options->getOption('urlTotal');
     $currentMonthNo = -1;
     $calMaker = NULL;
     $dayLinks = NULL;
     //Generate data and save it for each month.
     foreach ($collDates as $date) {
         //Print each month only once. For the other days, build the data for the month.
         $monthNo = date('n', $date);
         if ($monthNo !== $currentMonthNo) {
             $currentMonthNo = $monthNo;
             //Print the month.
             if ($calMaker !== NULL) {
                 $calMaker->setDayLinks($dayLinks);
                 $calMaker->setWeekLinks($weekLinks);
                 $sg->addElement($calMaker);
             }
             //Start a new one.
             $calMaker = $sg->newElement('calendarMaker');
             $calMaker->setDayNames($weeks);
             $calMaker->setWeekLabel($weekLabel);
             $calMaker->setMonthNames($months);
             $calMaker->setMonthTimestamp($date);
             $calMaker->setMonthLink($totalBaseurl . date('/Y/m/', $date));
             $calMaker->setYearLink($totalBaseurl . date('/Y/', $date));
             //Make an empty string for each day and week.
             $dayLinks = array_pad(array(), date('t', $date) + 1, '');
             $weekLinks = array_fill(0, date('W', $date), '');
         }
         //And day and week links.
         $dayLinks[date('j', $date)] = $totalBaseurl . date('/Y/m/d/', $date);
         $weekDay = date('w', $date) - 1;
         //0-6, Sunday = -1
         if ($weekDay === -1) {
             $weekDay = 6;
         }
         //Monday = 0, Sunday = 6
         $weekStart = $date - $weekDay * 24 * 3600;
         //Always the start of the week.
         $weekLinks[date('W', $weekStart)] = $totalBaseurl . date('/Y/m/d/\\w\\e\\e\\k/', $weekStart);
     }
     return $sg->getSite();
 }
开发者ID:simonmikkelsen,项目名称:zipstat,代码行数:82,代码来源:StatSite.php


注:本文中的DataSource::createCollectiveReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。