Example #1
0
 /**
  * Prepares the view and returns the according template for rendering.
  *
  * @param $view
  * @param array $params
  * @return string
  * @throws Zend_Paginator_Exception
  */
 public function prepareConfigurationView($view, $params)
 {
     $view->msg = [];
     $tokens = new OnlineShop_Framework_VoucherService_Token_List();
     try {
         $tokens->setFilterConditions($params['id'], $params);
     } catch (Exception $e) {
         $this->template = "voucher/voucher-code-tab-error.php";
         $view->errors[] = $e->getMessage() . " | Error-Code: " . $e->getCode();
     }
     if ($tokens) {
         $paginator = Zend_Paginator::factory($tokens);
         if ($params['tokensPerPage']) {
             $paginator->setItemCountPerPage((int) $params['tokensPerPage']);
         } else {
             $paginator->setItemCountPerPage(25);
         }
         $paginator->setCurrentPageNumber($params['page']);
         $view->paginator = $paginator;
         $view->count = sizeof($tokens);
     } else {
         $view->msg['result'] = $view->ts('plugin_onlineshop_voucherservice_msg-error-token-noresult');
     }
     $view->msg['error'] = $params['error'];
     $view->msg['success'] = $params['success'];
     // Settings parsed via foreach in view -> key is translation
     $view->settings = [$view->ts('plugin_onlineshop_voucherservice_settings-count') => $this->getConfiguration()->getCount(), $view->ts('plugin_onlineshop_voucherservice_settings-prefix') => $this->getConfiguration()->getPrefix(), $view->ts('plugin_onlineshop_voucherservice_settings-length') => $this->getConfiguration()->getLength(), $view->ts('plugin_onlineshop_voucherservice_settings-exampletoken') => $this->getExampleToken()];
     $statisticUsagePeriod = 30;
     if (isset($params['statisticUsagePeriod'])) {
         $statisticUsagePeriod = $params['statisticUsagePeriod'];
     }
     $view->tokenLengths = $this->series->getExistingLengths();
     $view->statistics = $this->getStatistics($statisticUsagePeriod);
     return $this->template;
 }