<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\Web\Classes\Api;


class BlaetternAPI
{
  
  public static function getInstance()
  {
    static $instance = null;
    if (is_null($instance)) {
      $instance = new BlaetternAPI();
    }

    return $instance;
  }

  
  public function convertBlaetternToBlaetternLink($pBlaettern, $pRest)
  {
    $result = new \BlaetternLink();
    $result->aktuelleSeite = $pBlaettern->getCurrentPage();
    $result->anzahlSeiten = $pBlaettern->getPagesCount();
    $result->rest = $pRest;

    return $result;
  }

  
  public function getBlaetternLeiste($pBlaettern)
  {
    $createSight = new \CreateSight();
    $exp = new \ExpBlaettern();
    $exp->setBlaetternInfo($pBlaettern);

    $blaetterLinks = array();
    for ($i = 0; $i < $pBlaettern->anzahlSeiten; $i++) {
      $blaetterLink = $pBlaettern->copy();
      
      $blaetterLinks[] = $blaetterLink;
    }

    return $createSight->createList($pBlaettern, 585, $blaetterLinks, $exp, $exp);
  }
}