Ejemplo n.º 1
0
 /**
  * Controller
  */
 public function process()
 {
     $aGatewayData = $this->getParam('gateway_data');
     // http://www.phpfox.com/tracker/view/15093/
     $bIsThickBox = $this->getParam('bIsThickBox');
     $this->template()->assign(array('aGateways' => Api_Service_Gateway_Gateway::instance()->get($aGatewayData), 'aGatewayData' => $aGatewayData, 'bIsThickBox' => $bIsThickBox));
 }
Ejemplo n.º 2
0
 public function getPackagesForCompare($bIsAdminCP = false)
 {
     $aPackages = $this->getPackages(false, true);
     $aCompare = $this->database()->select('*')->from(Phpfox::getT('subscribe_compare'))->execute('getSlaveRows');
     $aForCompare = array('packages' => array(), 'features' => array());
     // We store here the packages that have at least one feature assigned, others will be removed
     $aUsedPackages = array();
     // figure out the cost, recurring cost and symbol based on my currency
     foreach ($aPackages as $iKey => $aPackage) {
         $aPackage['aCosts'] = unserialize($aPackage['cost']);
         // Assign the initial fee
         foreach ($aPackage['aCosts'] as $sCurrency => $iAmount) {
             if ($sCurrency == Phpfox::getService('core.currency')->getDefault()) {
                 $aPackages[$iKey]['initial_fee'] = $iAmount;
                 break;
             }
         }
         // Assign the recurring fee
         if (empty($aPackage['recurring_cost']) || !Phpfox::getLib('parse.format')->isSerialized($aPackage['recurring_cost']) || $aPackage['recurring_period'] == 0) {
             $aPackages[$iKey]['recurring_fee'] = (int) $aPackage['recurring_cost'];
         } else {
             $aPackage['aRecurring'] = unserialize($aPackage['recurring_cost']);
             foreach ($aPackage['aRecurring'] as $sCurrency => $iAmount) {
                 if ($sCurrency == Phpfox::getService('core.currency')->getDefault()) {
                     $aPackages[$iKey]['recurring_fee'] = $iAmount;
                     break;
                 }
             }
         }
     }
     // Shape the final array
     foreach ($aCompare as $aRow) {
         $aRow['feature_value'] = json_decode($aRow['feature_value'], true);
         $aForCompare['features'][$aRow['feature_title']] = array();
         foreach ($aPackages as $aPackage) {
             foreach ($aRow['feature_value'] as $iKey => $aFeatureValue) {
                 if ($aFeatureValue['package_id'] == $aPackage['package_id']) {
                     if ($bIsAdminCP) {
                         $aForCompare['features'][$aRow['feature_title']][$aPackage['package_id']] = $aFeatureValue['value'];
                     } else {
                         $aForCompare['features'][$aRow['feature_title']][$aPackage['package_id']] = array('feature_value' => $aFeatureValue['value'], 'background_color' => $aPackage['background_color']);
                     }
                     $aUsedPackages[$aPackage['package_id']] = 1;
                 }
             }
         }
     }
     foreach ($aPackages as $aPackage) {
         if (!isset($aPackage['default_recurring_cost']) && (!isset($aPackage['recurring_period']) || !isset($aPackage['recurring_fee']) || !isset($aPackage['initial_fee']) || !isset($aPackage['currency_symbol']))) {
             continue;
         }
         if ($aPackage['recurring_period'] == '0') {
             $aPackage['recurring_fee'] = $aPackage['default_cost'];
         }
         $aForCompare['packages'][$aPackage['package_id']] = array('title' => $aPackage['title'], 'package_id' => $aPackage['package_id'], 'description' => $aPackage['description'], 'background_color' => $aPackage['background_color'], 'price_phrase' => isset($aPackage['default_recurring_cost']) ? $aPackage['default_recurring_cost'] : Api_Service_Gateway_Gateway::instance()->getPeriodPhrase($aPackage['recurring_period'], $aPackage['recurring_fee'], $aPackage['initial_fee'], $aPackage['currency_symbol']));
     }
     if ($bIsAdminCP == false) {
         // Remove unused packages
         foreach ($aForCompare['packages'] as $iPackageId => $sTitle) {
             if (!isset($aUsedPackages[$iPackageId])) {
                 unset($aForCompare['packages'][$iPackageId]);
             }
         }
         // Add empty cells
         foreach ($aForCompare['features'] as $iFeatureId => $aFeature) {
             foreach ($aForCompare['packages'] as $iPackageId => $aPackage) {
                 if (!isset($aForCompare['features'][$iFeatureId][$iPackageId])) {
                     if ($bIsAdminCP) {
                         $aForCompare['features'][$iFeatureId][$iPackageId] = '';
                     } else {
                         $aForCompare['features'][$iFeatureId][$iPackageId] = array('feature_value' => '', 'background_color' => $aPackage['background_color']);
                     }
                 }
             }
         }
     }
     /*
     foreach ($aForCompare['features'] as $iKey => $aFeature)
     {
     	ksort($aForCompare['features'][$iKey]);
     }
     */
     return $aForCompare;
 }
Ejemplo n.º 3
0
 /**
  * Controller
  */
 public function process()
 {
     if (!($oGateway = Api_Service_Gateway_Gateway::instance()->callback($this->request()->get('req4')))) {
     }
     exit;
 }