当前位置: 首页>>代码示例>>PHP>>正文


PHP UTIL_String::replaceVars方法代码示例

本文整理汇总了PHP中UTIL_String::replaceVars方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_String::replaceVars方法的具体用法?PHP UTIL_String::replaceVars怎么用?PHP UTIL_String::replaceVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UTIL_String的用法示例。


在下文中一共展示了UTIL_String::replaceVars方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateCache

 public function generateCache($languageId)
 {
     $event = new BASE_CLASS_EventCollector('base.add_global_lang_keys');
     OW::getEventManager()->trigger($event);
     $globalVars = call_user_func_array('array_merge', $event->getData());
     $values = $this->keyDao->findAllWithValues($languageId);
     $result = array();
     // fix begin
     // remove cache files from \ow_pluginfiles\base\lang_{1,2}.php and open site in debug mode
     $valuesReserv = $this->keyDao->findAllWithValues($languageId == 1 ? 2 : 1);
     foreach ($valuesReserv as $v) {
         $key = $v['prefix'] . '+' . $v['key'];
         $v['value'] = UTIL_String::replaceVars($v['value'], $globalVars);
         $result[$key] = $v['value'];
     }
     // fix end
     foreach ($values as $v) {
         $key = $v['prefix'] . '+' . $v['key'];
         $v['value'] = UTIL_String::replaceVars($v['value'], $globalVars);
         $result[$key] = $v['value'];
     }
     $cacheContent = "<?php\n\$language[{$languageId}] = " . var_export($result, true) . ";\n?>";
     $filename = $this->languageCacheDir . 'lang_' . $languageId . '.php';
     file_put_contents($filename, $cacheContent);
     @chmod($filename, 0666);
     $this->loadFromCahce();
 }
开发者ID:vazahat,项目名称:dudex,代码行数:27,代码来源:language_service.php

示例2: text

 public function text($prefix, $key, array $vars = null)
 {
     if (empty($prefix) || empty($key)) {
         return $prefix . '+' . $key;
     }
     $text = null;
     try {
         $text = BOL_LanguageService::getInstance()->getText(BOL_LanguageService::getInstance()->getCurrent()->getId(), $prefix, $key);
     } catch (Exception $e) {
         return $prefix . '+' . $key;
     }
     if ($text === null) {
         return $prefix . '+' . $key;
     }
     $text = UTIL_String::replaceVars($text, $vars);
     return $text;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:17,代码来源:language.php

示例3: text

 public function text($prefix, $key, array $vars = null)
 {
     if (empty($prefix) || empty($key)) {
         return $prefix . '+' . $key;
     }
     $text = null;
     try {
         $text = BOL_LanguageService::getInstance()->getText(BOL_LanguageService::getInstance()->getCurrent()->getId(), $prefix, $key);
     } catch (Exception $e) {
         return $prefix . '+' . $key;
     }
     if ($text === null) {
         return $prefix . '+' . $key;
     }
     $event = new OW_Event("core.get_text", array("prefix" => $prefix, "key" => $key, "vars" => $vars));
     $this->eventManager->trigger($event);
     if ($event->getData() !== null) {
         return $event->getData();
     }
     $text = UTIL_String::replaceVars($text, $vars);
     return $text;
 }
开发者ID:vBulleteen,项目名称:oxwall,代码行数:22,代码来源:language.php

示例4: getText

 /**
  * @param int $languageId
  * @param string $prefix
  * @param string $key
  * @param array $vars
  * @return string
  */
 public function getText($languageId, $prefix, $key, $vars = array())
 {
     $text = $this->getTextTemplate($languageId, $prefix, $key);
     if (!empty($vars) && is_array($vars)) {
         foreach ($vars as $key => &$value) {
             if (UTIL_Serialize::isSerializedObject($value)) {
                 $object = UTIL_Serialize::unserialize($value);
                 if (empty($object) || !$object instanceof BASE_CLASS_LanguageParams) {
                     $value = '';
                 }
                 $value = $object->fetch();
             }
         }
     }
     $event = new OW_Event("core.get_text", array("prefix" => $prefix, "key" => $key, "vars" => $vars));
     OW::getEventManager()->trigger($event);
     if ($event->getData() !== null) {
         return $event->getData();
     }
     $text = UTIL_String::replaceVars($text, $vars);
     return $text;
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:29,代码来源:language_service.php

示例5: sendVerificationMail

function sendVerificationMail($type, $params)
{
    global $getConfig;
    global $getFeedback;
    //global $getRouter;
    global $language;
    global $getMailer;
    global $EmailVerifyService;
    $subject = $params['subject'];
    $template_html = $params['body_html'];
    $template_text = $params['body_text'];
    switch ($type) {
        case "user":
            $user = $params['user'];
            $email = $user->email;
            $userId = $user->id;
            break;
        case "site":
            $email = $getConfig->getValue('base', 'unverify_site_email');
            $userId = 0;
            break;
        default:
            $getFeedback->error($language->text('base', 'email_verify_verify_mail_was_not_sent'));
            return;
    }
    $emailVerifiedData = $EmailVerifyService->findByEmailAndUserId($email, $userId, $type);
    if ($emailVerifiedData !== null) {
        $timeLimit = 60 * 60 * 24 * 3;
        // 3 days
        if (time() - (int) $emailVerifiedData->createStamp >= $timeLimit) {
            $emailVerifiedData = null;
        }
    }
    if ($emailVerifiedData === null) {
        $emailVerifiedData = new BOL_EmailVerify();
        $emailVerifiedData->userId = $userId;
        $emailVerifiedData->email = trim($email);
        $emailVerifiedData->hash = randomNumber();
        $emailVerifiedData->createStamp = time();
        $emailVerifiedData->type = $type;
        $EmailVerifyService->batchReplace(array($emailVerifiedData));
    }
    $vars = array('code' => $emailVerifiedData->hash);
    $language = $language;
    $subject = UTIL_String::replaceVars($subject, $vars);
    $template_html = UTIL_String::replaceVars($template_html, $vars);
    $template_text = UTIL_String::replaceVars($template_text, $vars);
    $mail = $getMailer->createMail();
    $mail->addRecipientEmail($emailVerifiedData->email);
    $mail->setSubject($subject);
    $mail->setHtmlContent($template_html);
    $mail->setTextContent($template_text);
    $getMailer->send($mail);
    if (!isset($params['feedback']) || $params['feedback'] !== false) {
        $getFeedback->info($language->text('base', 'email_verify_verify_mail_was_sent'));
    }
}
开发者ID:bhushansonar,项目名称:hammu,代码行数:57,代码来源:index_4_7_2015.php

示例6: index

 public function index($params = array())
 {
     $userService = BOL_UserService::getInstance();
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('admin', 'massmailing'));
     $this->setPageHeadingIconClass('ow_ic_script');
     $massMailingForm = new Form('massMailingForm');
     $massMailingForm->setId('massMailingForm');
     $rolesList = BOL_AuthorizationService::getInstance()->getRoleList();
     $userRoles = new CheckboxGroup('userRoles');
     $userRoles->setLabel($language->text('admin', 'massmailing_user_roles_label'));
     foreach ($rolesList as $role) {
         if ($role->name != 'guest') {
             $userRoles->addOption($role->name, $language->text('base', 'authorization_role_' . $role->name));
         }
     }
     $massMailingForm->addElement($userRoles);
     $emailFormat = new Selectbox('emailFormat');
     $emailFormat->setLabel($language->text('admin', 'massmailing_email_format_label'));
     $emailFormat->setOptions(array(self::EMAIL_FORMAT_TEXT => $language->text('admin', 'massmailing_email_format_text'), self::EMAIL_FORMAT_HTML => $language->text('admin', 'massmailing_email_format_html')));
     $emailFormat->setValue(self::EMAIL_FORMAT_TEXT);
     $emailFormat->setHasInvitation(false);
     if (!empty($_POST['emailFormat'])) {
         $emailFormat->setValue($_POST['emailFormat']);
     }
     $massMailingForm->addElement($emailFormat);
     $subject = new TextField('subject');
     $subject->addAttribute('class', 'ow_text');
     $subject->addAttribute('style', 'width: auto;');
     $subject->setRequired();
     $subject->setLabel($language->text('admin', 'massmailing_subject_label'));
     if (!empty($_POST['subject'])) {
         $subject->setValue($_POST['subject']);
     }
     $massMailingForm->addElement($subject);
     $body = new Textarea('body');
     if ($emailFormat->getValue() == self::EMAIL_FORMAT_HTML) {
         $body = new WysiwygTextarea('body');
         $body->forceAddButtons(array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_HTML));
     }
     $body->addAttribute('class', 'ow_text');
     $body->addAttribute('style', 'width: auto;');
     $body->setRequired();
     $body->setLabel($language->text('admin', 'massmailing_body_label'));
     if (!empty($_POST['body'])) {
         $body->setValue($_POST['body']);
     }
     $massMailingForm->addElement($body);
     $submit = new Submit('startMailing');
     $submit->addAttribute('class', 'ow_button');
     $submit->setValue($language->text('admin', 'massmailing_start_mailing_button'));
     $massMailingForm->addElement($submit);
     $this->addForm($massMailingForm);
     $ignoreUnsubscribe = false;
     $isActive = true;
     if (defined('OW_PLUGIN_XP')) {
         $massMailingTimestamp = OW::getConfig()->getValue('admin', 'mass_mailing_timestamp');
         $timeout = $massMailingTimestamp + 60 * 60 * 24 - time();
         if ($timeout > 0) {
             $isActive = false;
             $this->assign('expireText', $language->text('admin', 'massmailing_expire_text', array('hours' => (int) ceil($timeout / (60 * 60)))));
         }
     }
     $this->assign('isActive', $isActive);
     $total = $userService->findMassMailingUserCount($ignoreUnsubscribe);
     if (OW::getRequest()->isPost() && $isActive && isset($_POST['startMailing'])) {
         if ($massMailingForm->isValid($_POST)) {
             $data = $massMailingForm->getValues();
             $start = 0;
             $count = self::MAILS_ARRAY_MAX_RECORDS;
             $mailCount = 0;
             $total = $userService->findMassMailingUserCount($ignoreUnsubscribe, $data['userRoles']);
             while ($start < $total) {
                 $result = $this->userService->findMassMailingUsers($start, $count, $ignoreUnsubscribe, $data['userRoles']);
                 $mails = array();
                 $userIdList = array();
                 foreach ($result as $user) {
                     $userIdList[] = $user->id;
                 }
                 $displayNameList = $this->userService->getDisplayNamesForList($userIdList);
                 $event = new BASE_CLASS_EventCollector('base.add_global_lang_keys');
                 OW::getEventManager()->trigger($event);
                 $vars = call_user_func_array('array_merge', $event->getData());
                 foreach ($result as $key => $user) {
                     $vars['user_email'] = $user->email;
                     $mail = OW::getMailer()->createMail();
                     $mail->addRecipientEmail($user->email);
                     $vars['user_name'] = $displayNameList[$user->id];
                     $code = md5($user->username . $user->password);
                     $link = OW::getRouter()->urlForRoute('base_massmailing_unsubscribe', array('id' => $user->id, 'code' => $code));
                     $subjectText = UTIL_String::replaceVars($data['subject'], $vars);
                     $mail->setSubject($subjectText);
                     if ($data['emailFormat'] === self::EMAIL_FORMAT_HTML) {
                         $htmlContent = UTIL_String::replaceVars($data['body'], $vars);
                         $htmlContent .= $language->text('admin', 'massmailing_unsubscribe_link_html', array('link' => $link));
                         $mail->setHtmlContent($htmlContent);
                         $textContent = preg_replace("/\\<br\\s*[\\/]?\\s*\\>/", "\n", $htmlContent);
                         $textContent = strip_tags($textContent);
                         $mail->setTextContent($textContent);
                     } else {
//.........这里部分代码省略.........
开发者ID:vazahat,项目名称:dudex,代码行数:101,代码来源:mass_mailing.php

示例7: renderInput

 /**
  * @see FormElement::renderInput()
  *
  * @param array $params
  * @return string
  */
 public function renderInput($params = null)
 {
     $html = parent::renderInput($params);
     $template = '
                     <div class="clearfix question_value_block" style="cursor:move;">
                             <span class="tag">
                                 <input type="hidden" value="{$value}">
                                 <span class="label" style="max-width:250px;overflow:hidden;">{$label}</span>
                                 <a title=' . json_encode(OW::getLanguage()->text('admin', 'remove_value')) . ' class="remove" href="javascript://"></a>
                             </span>
                     </div>';
     $template = UTIL_String::replaceVars($template, array('label' => '', 'value' => 0));
     $json = json_encode(array('tagFieldId' => $this->tag->getId(), 'dataFieldId' => $this->getId(), 'value' => $this->value, 'order' => array_keys($this->value), 'template' => $template));
     OW::getDocument()->addOnloadScript("\n            if ( !window.addInfiniteQuestionValues )\n            {\n                window.addInfiniteQuestionValues = {};\n            }\n\n            window.addInfiniteQuestionValues[" . json_encode($this->getId()) . "] = new infiniteQuestionValuesField(" . $json . "); ");
     return $html;
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:22,代码来源:form_fields.php

示例8: renderInput

 /**
  * @see FormElement::renderInput()
  *
  * @param array $params
  * @return string
  */
 public function renderInput($params = null)
 {
     if ($this->disabled) {
         $attributes = $this->attributes;
         unset($attributes['name']);
         $message = OW::getLanguage()->text('admin', 'possible_values_disable_message');
         $event = new OW_Event('admin.get.possible_values_disable_message', array('name' => $this->getName(), 'id' => $this->getId()), $message);
         OW::getEventManager()->trigger($event);
         $message = $event->getData();
         return UTIL_HtmlTag::generateTag('div', $attributes, true, $message);
     }
     parent::renderInput($params);
     $template = '
                     <div class="clearfix question_value_block" style="cursor:move;">
                             <span class="tag">
                                 <input type="hidden" value="{$value}">
                                 <span class="label" style="max-width:250px;overflow:hidden;">{$label}</span>
                                 <a title=' . json_encode(OW::getLanguage()->text('admin', 'remove_value')) . ' class="remove" href="javascript://"></a>
                             </span>
                     </div>';
     $values = '';
     if (!empty($this->value) && is_array($this->value)) {
         foreach ($this->value as $value => $label) {
             $data = $template;
             $values .= UTIL_String::replaceVars($data, array('label' => $label, 'value' => $value));
         }
     }
     $template = UTIL_String::replaceVars($template, array('label' => '', 'value' => 0));
     $addButtonName = $this->getName() . '_add_button';
     $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "questions.js");
     $json = json_encode(array('tagFieldId' => $this->tag->getId(), 'dataFieldId' => $this->getId(), 'value' => $this->value, 'order' => array_keys($this->value), 'template' => $template));
     OW::getDocument()->addOnloadScript("\n            if ( !window.addQuestionValues )\n            {\n                window.addQuestionValues = {};\n            }\n\n            window.addQuestionValues[" . json_encode($this->getId()) . "] = new questionValuesField(" . $json . "); ");
     OW::getLanguage()->addKeyForJs('admin', 'questions_edit_delete_value_confirm_message');
     $inputValues = array();
     foreach ($this->value as $key => $val) {
         $inputValues[] = array($key => $val);
     }
     $html = '<div class="values_list">
             </div>
             <input type="hidden" id=' . json_encode($this->getId()) . ' name=' . json_encode($this->getName()) . ' value=' . json_encode($inputValues) . ' />
             <input type="hidden" id=' . json_encode($this->getId() . "_deleted_values") . ' name=' . json_encode($this->getName() . "_deleted_values") . ' value="" />
             <div style="padding-left: 4px;" class="ow_smallmargin">' . OW::getLanguage()->text('admin', 'add_question_value_description') . '</div>
             <div class="clearfix">
                 <div class="ow_left" style="width: 260px;">' . $this->tag->renderInput() . '</div>
                 <div class="ow_right">
                     <span class="ow_button">
                         <span class="ow_ic_add">
                             <input type="button" value=' . json_encode(OW::getLanguage()->text('admin', 'add_button')) . ' class="ow_ic_add" name="' . $addButtonName . '">
                         </span>
                     </span>
                 </div>
             </div>';
     return $html;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:61,代码来源:form_fields.php

示例9: sendVerificationMail

 public function sendVerificationMail($type, $params)
 {
     $subject = $params['subject'];
     $template_html = $params['body_html'];
     $template_text = $params['body_text'];
     switch ($type) {
         case self::TYPE_USER_EMAIL:
             $user = $params['user'];
             $email = $user->email;
             $userId = $user->id;
             break;
         case self::TYPE_SITE_EMAIL:
             $email = OW::getConfig()->getValue('base', 'unverify_site_email');
             $userId = 0;
             break;
         default:
             OW::getFeedback()->error($language->text('base', 'email_verify_verify_mail_was_not_sent'));
             return;
     }
     $emailVerifiedData = BOL_EmailVerifyService::getInstance()->findByEmailAndUserId($email, $userId, $type);
     if ($emailVerifiedData !== null) {
         $timeLimit = 60 * 60 * 24 * 3;
         // 3 days
         if (time() - (int) $emailVerifiedData->createStamp >= $timeLimit) {
             $emailVerifiedData = null;
         }
     }
     if ($emailVerifiedData === null) {
         $emailVerifiedData = new BOL_EmailVerify();
         $emailVerifiedData->userId = $userId;
         $emailVerifiedData->email = trim($email);
         $emailVerifiedData->hash = BOL_EmailVerifyService::getInstance()->generateHash();
         $emailVerifiedData->createStamp = time();
         $emailVerifiedData->type = $type;
         BOL_EmailVerifyService::getInstance()->batchReplace(array($emailVerifiedData));
     }
     $vars = array('code' => $emailVerifiedData->hash, 'url' => OW::getRouter()->urlForRoute('base_email_verify_code_check', array('code' => $emailVerifiedData->hash)), 'verification_page_url' => OW::getRouter()->urlForRoute('base_email_verify_code_form'));
     $language = OW::getLanguage();
     $subject = UTIL_String::replaceVars($subject, $vars);
     $template_html = UTIL_String::replaceVars($template_html, $vars);
     $template_text = UTIL_String::replaceVars($template_text, $vars);
     $mail = OW::getMailer()->createMail();
     $mail->addRecipientEmail($emailVerifiedData->email);
     $mail->setSubject($subject);
     $mail->setHtmlContent($template_html);
     $mail->setTextContent($template_text);
     OW::getMailer()->send($mail);
     if (!isset($params['feedback']) || $params['feedback'] !== false) {
         OW::getFeedback()->info($language->text('base', 'email_verify_verify_mail_was_sent'));
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:51,代码来源:email_verify_service.php


注:本文中的UTIL_String::replaceVars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。