/**
  * 
  */
 public function empfehlung($type)
 {
     $tarifModel = new Application_Model_Tarif();
     switch ($type) {
         case 'preis':
             return $tarifModel->getById(1);
             break;
         case 'bonus':
             $allTarif = $tarifModel->getAll();
             /* Tarif für suggestion:größter Wechselbonus suchen */
             $bestBoniTarif = null;
             $bestBoniSumme = 0;
             foreach ($allTarif as $actualTarif) {
                 $boniSumme = $actualTarif->getBoniSum() - $actualTarif->preis_start;
                 if ($boniSumme >= $bestBoniSumme) {
                     $bestBoniTarif = $actualTarif;
                     $bestBoniSumme = $boniSumme;
                 }
             }
             return $bestBoniTarif;
             break;
         case 'bewertung':
             return $tarifModel->getBest();
             break;
     }
 }
 public function detailsAction()
 {
     $foundId = null;
     $tarifModel = new Application_Model_Tarif();
     $allTarifs = $tarifModel->getAll();
     $allNames = array();
     foreach ($allTarifs as $tarif) {
         $allNames[strtolower(preg_replace('/[^A-z0-9]/', '-', $tarif->anbieter) . '-' . preg_replace('/[^A-z0-9]/', '-', $tarif->name))] = $tarif->id;
     }
     $foundId = @$allNames[$this->getRequest()->getParam('name', null)];
     if (!$foundId) {
         $this->_forward('error');
     }
     $tarif = $tarifModel->getById($foundId);
     if (!$tarif) {
         $this->_forward('error');
     }
     $this->view->assign('tarif', $tarif);
     /**
      * Tarif bewerten
      */
     if ($this->getRequest()->isPost()) {
         $bewertungModel = new Application_Model_Bewertung();
         if ($bewertungModel->isAllowedToInsertRating($_SERVER['REMOTE_ADDR'])) {
             if ($foundId && strlen($this->getRequest()->getParam('username')) && strlen($this->getRequest()->getParam('comment')) && strlen($this->getRequest()->getParam('email')) && $this->getRequest()->getParam('email') == '5' && !strlen($this->getRequest()->getParam('email2'))) {
                 if ($this->getRequest()->getParam('rating', false)) {
                     $rating = strip_tags($this->getRequest()->getParam('rating', NULL));
                 } else {
                     $rating = NULL;
                 }
                 $bewertungModel->insertRating($foundId, strip_tags($this->getRequest()->getParam('username')), $rating, strip_tags($this->getRequest()->getParam('comment')), $_SERVER['REMOTE_ADDR']);
                 $this->view->assign('bewerten_ok', true);
             } else {
                 $this->view->assign('bewerten_error', true);
                 $this->view->assign('params', $this->getRequest()->getParams());
             }
         } else {
             $this->view->assign('bewerten_timeout', true);
             $this->getResponse()->setHttpResponseCode(500);
         }
     }
 }
 /**
  * 
  */
 public function empfehlungen($type, $limit = 5)
 {
     $tarifModel = new Application_Model_Tarif();
     $type = strtolower($type);
     switch ($type) {
         case 'd2':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 if ($element->netz == 'Vodafone' || $element->netz == 'Alle' || $element->netz == 'D+E-Netz') {
                     $sortHelperArray[] = $element->anordnung;
                     $elementList[] = $element;
                 }
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = array_reverse($elementList);
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'd1':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 if ($element->netz == 'T-Mobile' || $element->netz == 'Alle' || $element->netz == 'D+E-Netz') {
                     $sortHelperArray[] = $element->anordnung;
                     $elementList[] = $element;
                 }
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = array_reverse($elementList);
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'e-plus':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 if ($element->netz == 'e-Plus' || $element->netz == 'Alle' || $element->netz == 'D+E-Netz') {
                     $sortHelperArray[] = $element->anordnung;
                     $elementList[] = $element;
                 }
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = array_reverse($elementList);
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'o2':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 if ($element->netz == 'O2') {
                     $sortHelperArray[] = $element->anordnung;
                     $elementList[] = $element;
                 }
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = array_reverse($elementList);
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'tarif':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 /* @var $element Application_Model_Row_Tarif */
                 $min = min(array($element->preis_intern, $element->preis_festnetz, $element->preis_tmobile, $element->preis_vodafone, $element->preis_eplus, $element->preis_o2));
                 $max = max(array($element->preis_intern, $element->preis_festnetz, $element->preis_tmobile, $element->preis_vodafone, $element->preis_eplus, $element->preis_o2));
                 if ($min != $max) {
                     $add = 0.0001;
                 } else {
                     $add = 0;
                 }
                 $elementList[] = $element;
                 $sortHelperArray[] = ($element->preis_intern + $element->preis_festnetz + $element->preis_tmobile + $element->preis_vodafone + $element->preis_eplus + $element->preis_o2) / 6 + $add;
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = $elementList;
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'bonus':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 $kostenAktionenSumme = $element->getAktionenAmount(array(Application_Model_Aktion::TYP_GUTHABEN, Application_Model_Aktion::TYP_RUFNUMMER));
                 $sortHelperArray[] = $kostenAktionenSumme;
                 $elementList[] = $element;
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = array_reverse($elementList);
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'kostenlos':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 if ($element->preis_start <= 0) {
                     $sortHelperArray[] = $element->anordnung;
                     $elementList[] = $element;
                 }
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = array_reverse($elementList);
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'bewertung':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 $rating = $element->getRating();
                 if ($rating !== null) {
                     $sortHelperArray[] = $rating;
                     $elementList[] = $element;
                 }
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = array_reverse($elementList);
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'kostenstopp':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 if ($element->kostenstopp == 'Y') {
                     $sortHelperArray[] = $element->kostenstopp_limit;
                     $elementList[] = $element;
                 }
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = $elementList;
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
         case 'postpaid':
             $unsortedElements = $tarifModel->getAll();
             $elementList = array();
             $sortHelperArray = array();
             foreach ($unsortedElements as $element) {
                 if (strstr($element->aufladen, 'Rechnung')) {
                     $sortHelperArray[] = $element->anordnung;
                     $elementList[] = $element;
                 }
             }
             array_multisort($sortHelperArray, $elementList);
             $sortedElements = array_reverse($elementList);
             if (count($sortedElements) < $limit) {
                 $limit = count($sortedElements);
             }
             $returnList = array();
             for ($i = 0; $i < $limit; $i++) {
                 $returnList[] = $sortedElements[$i];
             }
             return $returnList;
             break;
     }
 }
 /**
  * 
  */
 public function Homepagetitel()
 {
     $tarifModel = new Application_Model_Tarif();
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $controllerAndAction = $controller . '/' . $action;
     switch ($controllerAndAction) {
         case 'index/index':
         case 'vergleich/index':
             return 'Prepaid Vergleich für ' . count($tarifModel->getAll()) . ' Prepaid Tarife für Handy und Smartphone';
             break;
         case 'empfehlung/index':
             return 'Prepaid Karten und Prepaid Tarif Empfehlungen für D1, D2, e-Plus und O2';
             break;
         case 'empfehlung/details':
             switch ($request->getParam('name', null)) {
                 case 'guenstigste-prepaid-karten-nach-tarif':
                     return 'Vergleich der günstigsten Prepaid Karten und Prepaid Tarife';
                     break;
                 case 'prepaid-karten-mit-groessten-startbonus':
                     return 'Vergleich der Prepaid Karten und Prepaid Tarife mit groeßten Bonus ';
                     break;
                 case 'kostenlose-prepaid-karten':
                     return 'Kostenlose Prepaid Karten im Vergleich';
                     break;
                 case 'prepaid-karten-mit-bester-nutzerbewertung':
                     return 'Vergleich der Prepaid Karten und Prepaid Tarif mit bester Nutzerbewertung ';
                     break;
                 case 'beste-prepaid-karten-im-d2-netz':
                     return 'Vergleich der Besten Prepaid Karten und Prepaid Tarif im D2 Netz ';
                     break;
                 case 'beste-prepaid-karten-im-d1-netz':
                     return 'Vergleich der Besten Prepaid Karten und Prepaid Tarif im D1 Netz ';
                     break;
                 case 'beste-prepaid-karten-im-o2-netz':
                     return 'Vergleich der Besten Prepaid Karten und Prepaid Tarif im O2 Netz ';
                     break;
                 case 'beste-prepaid-karten-im-e-plus-netz':
                     return 'Vergleich der Besten Prepaid Karten und Prepaid Tarif im e-Plus Netz ';
                     break;
                 case 'prepaid-karten-tarif-mit-kostenstopp':
                     return 'Vergleich der Prepaid Karten und Prepaid Tarif mit Kostenstopp';
                     break;
                 case 'prepaid-karten-tarif-mit-postpaid-rechnung':
                     return 'Vergleich der Prepaid Karten und Prepaid Tarif mit Postpaid (Rechnung) Zahloption';
                     break;
                 default:
                     return 'Prepaid Karten und Prepaid Tarif Empfehlungen für D1, D2, e-Plus und O2';
                     break;
             }
             break;
         case 'index/vergleich':
             return 'Individueller Vergleich von verschiedenen Prepaid Tarifen';
             break;
         case 'index/details':
             $foundId = null;
             $tarifModel = new Application_Model_Tarif();
             $allTarifs = $tarifModel->getAll();
             $allNames = array();
             foreach ($allTarifs as $tarif) {
                 $allNames[strtolower(preg_replace('/[^A-z0-9]/', '-', $tarif->anbieter) . '-' . preg_replace('/[^A-z0-9]/', '-', $tarif->name))] = $tarif->id;
             }
             $foundId = $allNames[$request->getParam('name', null)];
             if ($foundId === null) {
                 $this->_forward('uebersicht');
             }
             $tarif = $tarifModel->getById($foundId);
             if (!$tarif) {
                 $name = '';
             } else {
                 $name = $tarif->anbieter . ' mit ' . $tarif->name . ' im ' . $tarif->netz . '-Netz mit Nutzerbewertungen';
             }
             return 'Prepaid Vergleich : Details von ' . $name;
             break;
         case 'news/index':
             return 'Prepaid Karten und Prepaid Tarif News';
             break;
         case 'news/details':
             return 'Prepaid Karten und Prepaid Tarif News : Details';
             break;
     }
 }
 /**
  * 
  */
 public function countall()
 {
     $tarifModel = new Application_Model_Tarif();
     return count($tarifModel->getAll());
 }
 public function detailsAction()
 {
     $tarifModel = new Application_Model_Tarif();
     $this->view->assign('countAll', count($tarifModel->getAll()));
     $this->view->assign('lastChange', $tarifModel->getLastUpdate());
     switch ($this->getRequest()->getParam('name', '')) {
         case 'guenstigste-prepaid-karten-nach-tarif':
             $this->_redirect('empfehlung/guenstigste-prepaid-tarife', array('code' => 301));
             break;
         case 'guenstigste-prepaid-tarife':
             $this->renderScript('empfehlung/_partials_details/guenstig.phtml');
             break;
         case 'kostenlose-prepaid-karten':
             $this->renderScript('empfehlung/_partials_details/kostenlos.phtml');
             break;
         case 'prepaid-karten-tarif-mit-kostenstopp':
             $this->_redirect('empfehlung/prepaid-tarif-mit-kostenstopp', array('code' => 301));
             break;
         case 'prepaid-tarif-mit-kostenstopp':
             $this->renderScript('empfehlung/_partials_details/kostenstopp.phtml');
             break;
         case 'prepaid-karten-mit-groessten-startbonus ':
             $this->_redirect('empfehlung/prepaid-tarif-mit-startguthaben', array('code' => 301));
             break;
         case 'prepaid-tarif-mit-startguthaben':
             $this->renderScript('empfehlung/_partials_details/startguthaben.phtml');
             break;
         case 'prepaid-karten-tarif-mit-postpaid-rechnung':
             $this->_redirect('empfehlung/prepaid-tarif-auf-rechnung', array('code' => 301));
             break;
         case 'prepaid-tarif-auf-rechnung':
             $this->renderScript('empfehlung/_partials_details/postpaid.phtml');
             break;
         case 'prepaid-karten-mit-bester-nutzerbewertung':
             $this->_redirect('empfehlung/prepaid-tarif-mit-bester-nutzerbewertung', array('code' => 301));
             break;
         case 'prepaid-tarif-mit-bester-nutzerbewertung':
             $this->renderScript('empfehlung/_partials_details/bewertung.phtml');
             break;
         case 'beste-prepaid-karten-im-d2-netz':
             $this->_redirect('empfehlung/beste-d2-prepaid-tarife', array('code' => 301));
             break;
         case 'beste-d2-prepaid-tarife':
             $this->renderScript('empfehlung/_partials_details/d2.phtml');
             break;
         case 'beste-prepaid-karten-im-d1-netz':
             $this->_redirect('empfehlung/beste-d1-prepaid-tarife', array('code' => 301));
             break;
         case 'beste-d1-prepaid-tarife':
             $this->renderScript('empfehlung/_partials_details/d1.phtml');
             break;
         case 'beste-prepaid-karten-im-o2-netz':
             $this->_redirect('empfehlung/beste-o2-prepaid-tarife', array('code' => 301));
             break;
         case 'beste-o2-prepaid-tarife':
             $this->renderScript('empfehlung/_partials_details/o2.phtml');
             break;
         case 'beste-prepaid-karten-im-e-plus-netz':
             $this->_redirect('empfehlung/beste-eplus-prepaid-tarife', array('code' => 301));
             break;
         case 'beste-eplus-prepaid-tarife':
             $this->renderScript('empfehlung/_partials_details/eplus.phtml');
             break;
         default:
             $this->_redirect('index');
             break;
     }
 }
 /**
  * 
  */
 public function Metakeywords()
 {
     $tarifModel = new Application_Model_Tarif();
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $controllerAndAction = $controller . '/' . $action;
     $permanent = "Prepaid, Prepaid Karte, Prepaid Vergleich, Prepaid Tarif, SIM, SIM Vergleich, SIM Karte";
     switch ($controllerAndAction) {
         case 'index/index':
             return $permanent . '';
             break;
         case 'index/details':
             $foundId = null;
             $tarifModel = new Application_Model_Tarif();
             $allTarifs = $tarifModel->getAll();
             $allNames = array();
             foreach ($allTarifs as $tarif) {
                 $allNames[strtolower(preg_replace('/[^A-z0-9]/', '-', $tarif->anbieter) . '-' . preg_replace('/[^A-z0-9]/', '-', $tarif->name))] = $tarif->id;
             }
             $foundId = $allNames[$request->getParam('name', null)];
             if ($foundId === null) {
                 $this->_forward('uebersicht');
             }
             $tarif = $tarifModel->getById($foundId);
             if (!$tarif) {
                 $name = '';
             } else {
                 $name = $tarif->anbieter . ' mit ' . $tarif->name . ' im ' . $tarif->netz . '-Netz mit Nutzerbewertungen';
             }
             return $permanent . ', Details, Tarif, Tarifdetails, Kosten, Flatrates, ' . $tarif->anbieter . ', ' . $tarif->name;
             break;
         case 'empfehlung/index':
             return $permanent . ', Empfehlung';
             break;
         case 'empfehlung/details':
             switch ($request->getParam('name', null)) {
                 case 'guenstigste-prepaid-karten-nach-tarif':
                     return $permanent . ', Empfehlung, günstigster, billigster, preiswert';
                     break;
                 case 'prepaid-karten-mit-groessten-startbonus':
                     return $permanent . ', Empfehlung, Bonus, Wechselbonus, Startguthaben, Guthaben';
                     break;
                 case 'kostenlose-prepaid-karten':
                     return 'kostenlos, ohne Kosten, gebührenfrei';
                     break;
                 case 'prepaid-karten-mit-bester-nutzerbewertung':
                     return $permanent . ', Empfehlung, Nutzerbewertung, 5 Sterne, Testsieger';
                     break;
                 case 'beste-prepaid-karten-im-d2-netz':
                     return $permanent . ', D2, D2-Netz, Vodafone, Vodafone-Netz';
                     break;
                 case 'beste-prepaid-karten-im-d1-netz':
                     return $permanent . ', D1, D1-Netz, T-Mobile, T-Mobile-Netz';
                     break;
                 case 'beste-prepaid-karten-im-o2-netz':
                     return $permanent . ', O2, O2-Netz';
                     break;
                 case 'beste-prepaid-karten-im-e-plus-netz':
                     return $permanent . ', e-Plus, e-Plus-Netz';
                     break;
                 case 'prepaid-karten-tarif-mit-kostenstopp':
                     return $permanent . ', Kosten-Stopp, kostenstopp, Kostenbremse, ';
                     break;
                 case 'prepaid-karten-tarif-mit-postpaid-rechnung':
                     return ', auf Rechnung, Postpaid, Post-Paid, Zahloption';
                     break;
                 default:
                     return $permanent . ', Empfehlung';
                     break;
             }
             break;
         case 'news/index':
             return 'Neuigkeiten, News, Aktion';
             break;
         case 'seiten/impressum':
             return 'Impressum';
             break;
         case 'seiten/kontakt':
             return 'Kontakt';
             break;
     }
 }