/**
  * Validate Db_Row
  *
  * @param Gpf_DbEngine_Row $row
  * @throws Gpf_DbEngine_Row_ConstraintException
  */
 public function validate(Gpf_DbEngine_Row $row)
 {
     $template = new Gpf_Templates_Template($row->get($this->columnName), '', Gpf_Templates_Template::FETCH_TEXT);
     if (!$template->isValid()) {
         $this->throwException();
     }
 }
    private function generateExportFile(Pap_Db_PayoutOption $payoutOption, $affiliateNote = '') {
        $header = new Gpf_Templates_Template($payoutOption->getExportHeaderTemplate(), '', Gpf_Templates_Template::FETCH_TEXT);
        $content = $header->getHTML(); 
        $currency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency();
        $affiliates = 0;
        $commissions = 0;
        
        $selectBuilder = $this->getAffiliatesToPaySelect($payoutOption->getID());
        foreach ($selectBuilder->getAllRowsIterator() as $row) {
            $user = new Pap_Common_User();
            $user->fillFromRecord($row);
            $payout = new Pap_Common_Payout($user, $currency, $row->get('amountRaw'),$this->generateInvoiceNumber());
            $payout->setAffiliateNote($affiliateNote);
            $affiliates++;
            $commissions += $row->get('amountRaw');
            
            $content .= $payout->getExportRow();
        }

        $footer = new Gpf_Templates_Template($payoutOption->getExportFooterTemplate(), '', Gpf_Templates_Template::FETCH_TEXT);
        $footer->assign('affiliates', $affiliates);
        $footer->assign('commissions', round($commissions, Pap_Common_Utils_CurrencyUtils::getDefaultCurrency()->getPrecision()));
        $content .= $footer->getHTML();
        
        $content = str_replace('\t', "\t", $content);
        $content = str_replace('\n', "\n", $content);
                
        return $content;        
    }
 public function render() {
     $settings = new Pap_Install_RecommendedSettings();
     
     $template = new Gpf_Templates_Template('installer_recommended_settings.stpl');
     $template->assign('settings', $settings->getSettings());
     return $template->getHTML();
 }
Example #4
0
 /**
  * Set mail variable, which can be replaced in subject or body of mail
  *
  * @param string $id
  * @param string $value
  */
 public function setVariable($id, $value)
 {
     if (!isset($this->templateObject)) {
         $this->templateObject = new Gpf_Templates_Template('gpf_db_mail.tpl');
     }
     $this->templateObject->assign($id, $value);
 }
 private function output($message)
 {
     $template = new Gpf_Templates_Template('quick_task.stpl');
     $template->assign('message', $message);
     $template->assign('title', Gpf_Application::getInstance()->getName() . ' - ' . $this->_('Merchant'));
     echo $template->getHTML();
 }
 public function render() {
     $requirements = new Pap_Install_Requirements();
     
     $template = new Gpf_Templates_Template('installer_check_requirements.stpl');
     $template->assign('requirements', $requirements->getRequirements());
     return $template->getHTML();
 }
	protected function fillDataToTemplate(Gpf_Templates_Template $tmpl, Gpf_Rpc_Params $params) {
		$stats = array();
		$stats['clicks'] = new Pap_Stats_Clicks($this->statParams);
		$stats['transactionTypes'] = new Pap_Stats_TransactionTypeStats($this->statParams);
		$stats['transactionTypesFirstTier'] = new Pap_Stats_TransactionTypeStatsFirstTier($this->statParams);
		$tmpl->assign('selected', $stats);
		$tmpl->assign('actionFilter', $this->action);
		$tmpl->assign('commtypeidFilter', $this->commTypeId);
		return $tmpl;
	}
 protected function checkAndSavePayoutInvoice(Gpf_Rpc_Form $form, $templateSource, $settingName) {
 	$template = new Gpf_Templates_Template($templateSource, '', Gpf_Templates_Template::FETCH_TEXT);
     if ($template->isValid()) {
     	Gpf_Settings::set($settingName, $templateSource);
         $form->setInfoMessage($this->getInfoMessage());
         return;
     }
     $form->setErrorMessage($this->_('Invalid Smarty syntax. More information: ') .
     Gpf_Application::getKnowledgeHelpUrl(Pap_Common_Constants::SMARTY_SYNTAX_URL));
 }
	/**
	 * Get banner preview for Window element
	 *
	 * @service banner read
	 * @param Gpf_Rpc_Params $params
	 * @return Pap_Affiliates_Promo_BannerPreview
	 */
	public function getWindowBannerPreview(Gpf_Rpc_Params $params) {
		$form = new Gpf_Rpc_Form($params);
		$bannerFactory = new Pap_Common_Banner_Factory();
		$banner = $bannerFactory->getBanner($form->getFieldValue('bannerId'));
		
		$template = new Gpf_Templates_Template('html_window_preview.stpl');
		$template->assign('bannercode', $banner->getPreview($this->getUser()));
		$this->preview = $template->getHTML();
		
		return $this;
	}
	protected function fillDataToTemplate(Gpf_Templates_Template $tmpl, Gpf_Rpc_Params $params) {
		$stats = array();
		$stats['clicks'] = new Pap_Stats_Clicks($this->statParams);
		$stats['impressions'] = new Pap_Stats_Impressions($this->statParams);
		$stats['transactionTypes'] = new Pap_Stats_TransactionTypeStats($this->statParams);
		$stats['transactionTypesFirstTier'] = new Pap_Stats_TransactionTypeStatsFirstTier($this->statParams);
		$stats['transactions'] = new Pap_Stats_Transactions($this->statParams);
		$stats['transactionsFirstTier'] = new Pap_Stats_TransactionsFirstTier($this->statParams);
		$stats['transactionsHigherTier'] = new Pap_Stats_TransactionsHigherTiers($this->statParams);
		$tmpl->assign('selected', $stats);
		return $tmpl;
	}
Example #11
0
 function addBannersForPreview(Gpf_Templates_Template $template ,Pap_Common_User $user){
     $bannersPreview = '';
     $counter = 0;
     foreach ($this->rotatedBanners as $row) {
         $bannerId = $row->get(Pap_Db_Table_BannersInRotators::ROTATED_BANNER_ID);
         $rank = $row->get(Pap_Db_Table_BannersInRotators::RANK);
         try {
             $bannersPreview .= '<div>'. $this->bannerFactory->getBanner($bannerId)->getPreview($user).'</div><hr>';
             $counter ++;
         } catch (Gpf_Exception $e) {
         }
     }
     if ($counter >= 5) {
         $bannersPreview = '<div class="BannerRotatorPreview">' . $bannersPreview . '</div>';
     }
     $template->assign("banners",$bannersPreview);
 }
 /**
  *
  * @service
  * @anonym
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Data
  */
 public function getHtml(Gpf_Rpc_Params $params)
 {
     $smarty = new Gpf_Templates_Template("update_version.stpl");
     try {
         $smarty->assign('installedVersion', Gpf_Application::getInstance()->getInstalledVersion());
         $smarty->assign('gpfInstalledVersion', Gpf_Application::getInstance()->getInstalledVersion(true));
     } catch (Gpf_Exception $e) {
         $smarty->assign('installedVersion', $this->_('Not availible'));
         $smarty->assign('gpfInstalledVersion', $this->_('Not availible'));
     }
     $smarty->assign('newVersion', Gpf_Application::getInstance()->getVersion());
     $smarty->assign('gpfNewVersion', Gpf::GPF_VERSION);
     $smarty->assign('applicationName', Gpf_Application::getInstance()->getName());
     return $smarty->getDataResponse();
 }
    protected function fillDataToTemplate(Gpf_Templates_Template $tmpl, Gpf_Rpc_Params $params) {
        $tmpl->assign('sumTransaction', new Pap_Merchants_Reports_QuickReportDataTransactionsSum());

        $tmpl->assign('clicks', new Pap_Stats_Clicks($this->statsParams));

        $tmpl->assign('impressions', new Pap_Stats_Impressions($this->statsParams));

        $tmpl->assign('salesTier', new Pap_Stats_SalesHigherTiers($this->statsParams));
        $tmpl->assign('transactionTypesTier', new Pap_Stats_TransactionTypeStatsHigherTiers($this->statsParams));

        return $tmpl;
    }
Example #14
0
 /**
  *
  * @return Gpf_Db_Mail
  */
 protected function createMail($toRecipients, $bccRecipients = null)
 {
     //save mail
     $mail = new Gpf_Db_Mail();
     $mail->setSubject($this->subjectTemplate->getHTML());
     $mail->setHtmlBody($this->bodyHtmlTemplate->getHTML());
     $mail->setTextBody($this->bodyTextTemplate->getHTML());
     $mail->setRecipients($toRecipients);
     if (!is_null($bccRecipients) || $bccRecipients != '') {
         $mail->setBccRecipients($bccRecipients);
     }
     if ($this->mailAccount !== null) {
         $mail->setMailAccount($this->mailAccount);
     }
     $mail->setFromMail($this->fromMail);
     $mail->setReplyTo($this->replyTo);
     $mail->insert();
     $this->createMailAttachments($this->mailTemplate, $mail);
     return $mail;
 }
Example #15
0
 public static function assignTemplateVariables(Gpf_Templates_Template $template)
 {
     if (Gpf_Session::getAuthUser()->isLogged()) {
         $template->assign('isLogged', '1');
     } else {
         $template->assign('isLogged', '0');
     }
     $template->assign('papCopyrightText', Gpf_Settings::get(Pap_Settings::BRANDING_TEXT));
     $template->assign('papVersionText', 'version ' . Gpf_Application::getInstance()->getVersion());
     $template->assign('postAffiliatePro', Gpf_Settings::get(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO));
     $template->assign('qualityUnitPostaffiliateproLink', Gpf_Settings::get(Pap_Settings::BRANDING_QUALITYUNIT_POSTAFFILIATEPRO_LINK));
     $template->assign('postAffiliateProHelp', Gpf_Settings::get(Pap_Settings::BRANDING_POST_AFFILIATE_PRO_HELP_LINK));
     $template->assign('qualityUnitChangeLog', Gpf_Settings::get(Pap_Settings::BRANDING_QUALITYUNIT_CHANGELOG_LINK));
     $template->assign('knowledgebaseUrl', Gpf_Settings::get(Pap_Settings::BRANDING_KNOWLEDGEBASE_LINK));
     $template->assign('PAP', Gpf_Settings::get(Pap_Settings::BRANDING_QUALITYUNIT_PAP));
     $template->assign('tutorialVideosBaseLink', Gpf_Settings::get(Pap_Settings::BRANDING_TUTORIAL_VIDEOS_BASE_LINK));
 }
 public function __construct($templateName, $panel='') {
     parent::__construct(null);
     $this->templateName = $templateName;
     $template = new Gpf_Templates_Template($templateName, $panel);
     $this->templateHtml = $template->getHTML();
 }
Example #17
0
 public function getTemplateTimestamp($templateName)
 {
     $template = new Gpf_Templates_Template($templateName, $this->panelName);
     return $template->getTimestamp();
 }
Example #18
0
    private function assignPayoutVariablesToTemplate(Gpf_Templates_Template $template) {
        $template->assignAttributes($this->user);
        $template->assign('vat_number', $this->vatNumber);
        $template->assign('reg_number', $this->regNumber);
        $template->assign('amount_of_reg_capital', $this->amountOfRegCapital);
        $template->assign('vat_percentage', $this->vatPercentage);
        $template->assign('payoutcurrency', $this->currency->getName());
        $template->assign('affiliate_note', $this->getAffiliateNote());
        $template->assign('payment', $this->getAmount());
        $template->assign('amount', str_replace('.', ',', $this->getAmount()));
        $template->assign('currency', $this->currency->getName());

        if ($this->payoutOption != null) {
            $template->assign('payoutmethod', $this->_localize($this->payoutOption->getName()));
        }
        $template->assign('payment_vat_part', $this->amountVatPart);
        $template->assign('payment_incl_vat', $this->amountWithVat);
        $template->assign('payment_excl_vat', $this->amountWithoutWat);

        $historyItem = $this->getPayoutHistoryItem();
        if ($historyItem === null) {
            
            $template->assign('date', Gpf_Common_DateUtils::getDateInLocaleFormat());
            $template->assign('time', Gpf_Common_DateUtils::getTimeInLocaleFormat());
        } else {
            $time = new Gpf_DateTime($historyItem->getDateInserted());
            $template->assign('date', Gpf_Common_DateUtils::getDateInLocaleFormat($time->toTimestamp()));
            $template->assign('time', Gpf_Common_DateUtils::getTimeInLocaleFormat($time->toTimestamp()));
        }
        $template->assign('invoicenumber',$this->getInvoiceNumber());

        if ($this->payoutOptionFields != null) {
            $userPayoutOptions = Pap_Db_Table_UserPayoutOptions::getInstance()->getValues(
            $this->payoutOption->getFormId(), $this->user->getId());
            foreach ($this->payoutOptionFields as $payoutOptionField) {
                $code = $payoutOptionField->get('code');
                if (array_key_exists($code, $userPayoutOptions)) {
                    $template->assign($code, $userPayoutOptions[$code]->getValue());
                }
            }
        }
    }
Example #19
0
 public function toText()
 {
     if ($this->panelWidth == 0) {
         $this->panelWidth = $this->getWidth();
     }
     if ($this->panelHeight == 0) {
         $this->panelHeight = $this->getHeight();
     }
     $template = new Gpf_Templates_Template($this->getTemplateName());
     $template->setDelimiter('/*{', '}*/');
     $template->assign('id', $this->getId());
     $template->assign('name', $this->getName());
     $template->assign('url', $this->getUrl());
     $template->assign('width', $this->getWidth());
     $template->assign('height', $this->getHeight());
     $template->assign('panelWidth', $this->panelWidth - 40);
     $template->assign('panelHeight', $this->panelHeight - 75);
     $template->assign('properties', $this->getProperties());
     $template->assign('autoRefreshTime', $this->getAutorefreshTime());
     return $template->getHTML();
 }
 protected function checkBeforeSave(Gpf_DbEngine_RowBase $row, Gpf_Rpc_Form $form, $operationType = self::EDIT) {
     $template = new Gpf_Templates_Template($row->getExportRowTemplate(), '', Gpf_Templates_Template::FETCH_TEXT);
     if (!$template->isValid()) {
     	 $form->setErrorMessage($this->_('Invalid Smarty syntax. More information: ') . 
     	 Gpf_Application::getKnowledgeHelpUrl(Pap_Common_Constants::SMARTY_SYNTAX_URL));
     	 return false;
     }
     return true;
 }   
Example #21
0
 private function postResponseTo($url, $response)
 {
     $template = new Gpf_Templates_Template("post_response.stpl");
     $cumulativeErrorMessage = "";
     $fields = array();
     foreach ($response as $field) {
         $error = $field->get(Gpf_Rpc_Form::FIELD_ERROR);
         $fields[] = array("name" => $field->get(Gpf_Rpc_Form::FIELD_NAME), "value" => $field->get(Gpf_Rpc_Form::FIELD_VALUE), "error" => $error);
         if ($error != "") {
             $cumulativeErrorMessage .= $error . "<br>";
         }
     }
     if ($response->getErrorMessage() != '') {
         $cumulativeErrorMessage .= $response->getErrorMessage() . "<br>";
     }
     $template->assign('fields', $fields);
     $template->assign('errorMessage', $response->getErrorMessage());
     $template->assign('cumulativeErrorMessage', $cumulativeErrorMessage);
     $template->assign('successMessage', $response->getInfoMessage());
     $template->assign('url', $url);
     return $template->getHTML();
 }
	private function createList() {
		$payAffTemplate = new Gpf_Templates_Template('pay_affiliates_list.tpl', 'merchants');
		$payAffTemplate->assignByRef('payaffiliates', $this->iterator);
		$payAffTemplate->assignByRef('currency', Pap_Common_Utils_CurrencyUtils::getDefaultCurrency()->getSymbol());
		return $payAffTemplate->getHTML();
	}
    /**
     * @service theme write
     * @return Gpf_Rpc_Form
     */
    public function saveFile(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);
        $theme = $form->getFieldValue('themeId');
        $fileName = ltrim($form->getFieldValue("id"), '/');
        $panel = basename($this->getThemeFile($form->getFieldValue('panelName')));
        $text = $form->getFieldValue('text');
        
        $template = new Gpf_Templates_Template($text, $panel, Gpf_Templates_Template::FETCH_TEXT, $theme);
        if ($this->getFileExtension($fileName) == 'tpl' || $this->getFileExtension($fileName) == 'stpl') {
            try {
                $template->check();
            } catch (Gpf_Templates_SmartySyntaxException $e) {
                $form->setErrorMessage($e->getMessage());
                return $form;
            }
        }
        
		$file = $this->getTemplateFile($panel, $theme, $fileName);
        try {
            if (!$file->getParent()->isExists()) {
                $file->getParent()->mkdir(true);
            }
        } catch (Exception $ex) {
            $form->setErrorMessage($this->_('Error creating directory %s '.$ex->getMessage(), $file->getParent()->getFileName()));
            return $form;
        }
        try {
        	if (!$file->isExists()) {
				$file->open('w');
				$file->close();
			}
        } catch (Exception $ex) {
            $form->setErrorMessage($this->_('Error creating file %s '.$ex->getMessage(), $file->getFileName()));
            return $form;
        }
        try {
        	$template = $this->getTemplateObject($panel, $theme, $fileName);
            $template->saveTemplateToFile($text);
        } catch(Exception $ex){
            $form->setErrorMessage($this->_('Error writing to file %s '.$ex->getMessage(), $file->getFileName()));
            return $form;
        }
        $form->setInfoMessage($this->_('File %s was saved.', $file->getFileName()));
        return $form;
    }
Example #24
0
 public function assignTemplateVariables(Gpf_Templates_Template $template) {
     if ($this->channels === null) {
         $this->loadChannels();
     }
     $template->assign('channels', $this->channels);
 }
 /**
  *
  * @service
  * @anonym
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Data
  */
 public function getHtml(Gpf_Rpc_Params $params) {
     $smarty = new Gpf_Templates_Template("update_check_requirements.stpl");
     return $smarty->getDataResponse();
 }
 /**
  * @service template write
  * @param $fields
  * @return Gpf_Rpc_Action
  */
 public function createFile(Gpf_Rpc_Params $params)
 {
     $action = new Gpf_Rpc_Action($params);
     $templateName = $this->fixTemplateName($action->getParam("templatename"));
     $panelName = '';
     if ($params->exists("panelname")) {
         $panelName = $action->getParam("panelname");
     }
     if ($params->exists("theme") && $action->getParam("theme") != null && $action->getParam("theme") != "") {
         $theme = $action->getParam("theme");
     } else {
         throw new Gpf_Exception("Theme not set");
     }
     $commonTemplate = new Gpf_Templates_Template($templateName, $panelName, Gpf_Templates_Template::FETCH_FILE, trim(Gpf_Paths::DEFAULT_THEME, '/'));
     $commonTemplate->getTemplateSource();
     $paths = Gpf_Paths::getInstance()->clonePaths($theme);
     $templatePaths = $paths->getTemplateSearchPaths($panelName);
     $filePath = $templatePaths[0] . $templateName;
     $templateFile = new Gpf_Io_File($filePath);
     try {
         $templateFile->open('w');
     } catch (Gpf_Exception $e) {
         if (!$this->createDirectory($filePath)) {
             $action->setErrorMessage('Unable to create directory: ' . $directory);
             $action->addError();
             return $action;
         }
         $templateFile->open('w');
     }
     $templateFile->write($commonTemplate->getTemplateSource());
     $action->setInfoMessage($this->_("File added"));
     $action->addOk();
     return $action;
 }
Example #27
0
    protected function fillDataToTemplate(Gpf_Templates_Template $tmpl, Gpf_Rpc_Params $params) {
        $todayParams = $this->getStatsParams('T');
        $thisMonthParams = $this->getStatsParams('TM');
        
        $tmpl->assign('todayClicks', new Pap_Stats_Clicks($todayParams));
        $tmpl->assign('todayImpressions', new Pap_Stats_Impressions($todayParams));
        $tmpl->assign('todaySales', new Pap_Stats_Sales($todayParams));
        $tmpl->assign('todayCommissions', new Pap_Stats_Transactions($todayParams));
        $tmpl->assign('todayRefunds', new Pap_Stats_Refunds($todayParams));
        $tmpl->assign('todayChargebacks', new Pap_Stats_Chargebacks($todayParams));
        $tmpl->assign('todayTransactionTypes', new Pap_Stats_TransactionTypeStats($todayParams));
        
        $signupBonus = new Pap_Stats_Transactions($todayParams);
        $signupBonus->setTransactionType(Pap_Db_Transaction::TYPE_SIGNUP_BONUS);
        $tmpl->assign('todaySignupBonus', $signupBonus);
        
        $tmpl->assign('thisMonthClicks', new Pap_Stats_Clicks($thisMonthParams));
        $tmpl->assign('thisMonthImpressions', new Pap_Stats_Impressions($thisMonthParams));
        $tmpl->assign('thisMonthSales', $s = new Pap_Stats_Sales($thisMonthParams));
        $tmpl->assign('thisMonthCommissions', new Pap_Stats_Transactions($thisMonthParams));
        $tmpl->assign('thisMonthRefunds', new Pap_Stats_Refunds($thisMonthParams));
        $tmpl->assign('thisMonthChargebacks', new Pap_Stats_Chargebacks($thisMonthParams));
        $tmpl->assign('thisMonthTransactionTypes', new Pap_Stats_TransactionTypeStats($thisMonthParams));
        
        $signupBonusMonth = new Pap_Stats_Transactions($thisMonthParams);
        $signupBonusMonth->setTransactionType(Pap_Db_Transaction::TYPE_SIGNUP_BONUS);
        $tmpl->assign('thisMonthSignupBonus', $signupBonusMonth);

        $actionCommissionsEnabled = Gpf::NO;
        $types = new Pap_Stats_TransactionTypeStatsFirstTier($thisMonthParams);
        foreach ($types->getTypes() as $transactionType) {
            if($transactionType->getType() == Pap_Common_Constants::TYPE_ACTION) {
                $actionCommissionsEnabled = Gpf::YES;
                $tmpl->assign('todayActionCommissions', new Pap_Stats_Actions($todayParams));
                $tmpl->assign('thisMonthActionCommissions', new Pap_Stats_Actions($thisMonthParams));
                break;
            }
        }
        $tmpl->assign('actionCommissionsEnabled', $actionCommissionsEnabled);

        if (Gpf_Session::getAuthUser()->hasPrivilege(Pap_Privileges::PENDING_TASK, Pap_Privileges::P_READ)) {
            $pendingTasksGadget = new Pap_Merchants_ApplicationGadgets_PendingTasksGadgets();
            $pendingTasksData = $pendingTasksGadget->load($params);
            $tmpl->assign('pendingTasks', array('affiliates' => $pendingTasksData->getValue('pendingAffiliates'),'links'=>$pendingTasksData->getValue('pendingDirectLinks'),'emails'=>$pendingTasksData->getValue('unsentEmails'),'commissions'=>$pendingTasksData->getValue('pendingCommissions'),'totalcosts'=>$pendingTasksData->getValue('totalCommissions')));
        } else {
            $tmpl->assign('pendingTasks', false);
        }
        
        return $tmpl;
    }
 protected function getTemplateFromFile() {
     $tmpl = new Gpf_Templates_Template(self::MAIL_TEMPLATE_DIR . $this->mailTemplateFile, 'install');
     return $tmpl->getTemplateSource();
 }
 public function getTemplateNoRpc($templateName)
 {
     $template = new Gpf_Templates_Template($templateName . '.tpl');
     return $this->createTemplateRecordSet($templateName, $template->getHTML());
 }
Example #30
0
 /**
  * @return Gpf_Templates_Template
  */
 protected function getBodyTemplate()
 {
     $template = new Gpf_Templates_Template($this->bodyTemplateName);
     $template->assign('content', $this->getContentTemplate()->getHTML());
     return $template;
 }