示例#1
0
/*----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()) {
示例#2
0
<?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.
示例#3
0
 /**
  * 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();
 }