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


PHP Translate::getDefaultLang方法代码示例

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


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

示例1: Translate

 /**
  *  Send new password by email
  *
  *  @param	User	$user           Object user that send email
  *  @param	string	$password       New password
  *	@param	int		$changelater	1=Change password only after clicking on confirm email
  *  @return int 		            < 0 si erreur, > 0 si ok
  */
 function send_password($user, $password = '', $changelater = 0)
 {
     global $conf, $langs;
     global $dolibarr_main_url_root;
     require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
     $msgishtml = 0;
     // Define $msg
     $mesg = '';
     $outputlangs = new Translate("", $conf);
     if (isset($this->conf->MAIN_LANG_DEFAULT) && $this->conf->MAIN_LANG_DEFAULT != 'auto') {
         // If user has defined its own language (rare because in most cases, auto is used)
         $outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT);
     } else {
         // If user has not defined its own language, we used current language
         $outputlangs = $langs;
     }
     $outputlangs->load("main");
     $outputlangs->load("errors");
     $outputlangs->load("users");
     $outputlangs->load("other");
     $subject = $outputlangs->transnoentitiesnoconv("SubjectNewPassword");
     // Define $urlwithroot
     //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
     //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
     $urlwithroot = DOL_MAIN_URL_ROOT;
     // This is to use same domain name than current
     if (!$changelater) {
         $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived") . ".\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyIs") . " :\n\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("Login") . " = " . $this->login . "\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("Password") . " = " . $password . "\n\n";
         $mesg .= "\n";
         $url = $urlwithroot . '/';
         $mesg .= $outputlangs->transnoentitiesnoconv("ClickHereToGoTo", $conf->global->MAIN_APPLICATION_TITLE) . ': ' . $url . "\n\n";
         $mesg .= "--\n";
         $mesg .= $user->getFullName($outputlangs);
         // Username that make then sending
     } else {
         $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived") . "\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyWillBe") . " :\n\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("Login") . " = " . $this->login . "\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("Password") . " = " . $password . "\n\n";
         $mesg .= "\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("YouMustClickToChange") . " :\n";
         $url = $urlwithroot . '/user/passwordforgotten.php?action=validatenewpassword&username=' . $this->login . "&passwordhash=" . dol_hash($password);
         $mesg .= $url . "\n\n";
         $mesg .= $outputlangs->transnoentitiesnoconv("ForgetIfNothing") . "\n\n";
         dol_syslog(get_class($this) . "::send_password url=" . $url);
     }
     $mailfile = new CMailFile($subject, $this->email, $conf->notification->email_from, $mesg, array(), array(), array(), '', '', 0, $msgishtml);
     if ($mailfile->sendfile()) {
         return 1;
     } else {
         $langs->trans("errors");
         $this->error = $langs->trans("ErrorFailedToSendPassword") . ' ' . $mailfile->error;
         return -1;
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:66,代码来源:user.class.php

示例2: Translate

 /**
  *   \brief     	Envoie mot de passe par mail
  *   \param     	user            Object user de l'utilisateur qui fait l'envoi
  *   \param			password        Nouveau mot de passe
  *	 \param			changelater		1=Change password only after clicking on confirm email
  *   \return    	int             < 0 si erreur, > 0 si ok
  */
 function send_password($user, $password = '', $changelater = 0)
 {
     global $conf, $langs;
     require_once DOL_DOCUMENT_ROOT . "/lib/CMailFile.class.php";
     $subject = $langs->trans("SubjectNewPassword");
     $msgishtml = 0;
     // Define $msg
     $mesg = '';
     $outputlangs = new Translate("", $conf);
     if (isset($this->conf->MAIN_LANG_DEFAULT) && $this->conf->MAIN_LANG_DEFAULT != 'auto') {
         // If user has defined its own language (rare because in most cases, auto is used)
         $outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT);
     } else {
         // If user has not defined its own language, we used current language
         $outputlangs = $langs;
     }
     // Define urlwithouturlroot
     if (!empty($_SERVER["HTTP_HOST"])) {
         $urlwithouturlroot = 'http://' . preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', $_SERVER["HTTP_HOST"]);
     } else {
         $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', $dolibarr_main_url_root);
     }
     if (!empty($dolibarr_main_force_https)) {
         $urlwithouturlroot = preg_replace('/http:/i', 'https:', $urlwithouturlroot);
     }
     // TODO Use outputlangs to translate messages
     if (!$changelater) {
         $mesg .= "A request to change your Dolibarr password has been received.\n";
         $mesg .= "This is your new keys to login:\n\n";
         $mesg .= $langs->trans("Login") . " : {$this->login}\n";
         $mesg .= $langs->trans("Password") . " : {$password}\n\n";
         $mesg .= "\n";
         $url = $urlwithouturlroot . DOL_URL_ROOT;
         $mesg .= 'Click here to go to Dolibarr: ' . $url . "\n\n";
         $mesg .= "--\n";
         $mesg .= $user->getFullName($langs);
         // Username that make then sending
     } else {
         $mesg .= "A request to change your Dolibarr password has been received.\n";
         $mesg .= "Your new key to login will be:\n\n";
         $mesg .= $langs->trans("Login") . " : {$this->login}\n";
         $mesg .= $langs->trans("Password") . " : {$password}\n\n";
         $mesg .= "\n";
         $mesg .= "You must click on the folowing link to validate its change.\n";
         $url = $urlwithouturlroot . DOL_URL_ROOT . '/user/passwordforgotten.php?action=validatenewpassword&username=' . $this->login . "&passwordmd5=" . md5($password);
         $mesg .= $url . "\n\n";
         $mesg .= "If you didn't ask anything, just forget this email\n\n";
         dol_syslog("User::send_password url=" . $url);
     }
     $mailfile = new CMailFile($subject, $this->email, $conf->notification->email_from, $mesg, array(), array(), array(), '', '', 0, $msgishtml);
     if ($mailfile->sendfile()) {
         return 1;
     } else {
         $this->error = $langs->trans("ErrorFailedToSendPassword") . ' ' . $mailfile->error;
         //print nl2br($mesg);
         return -1;
     }
 }
开发者ID:netors,项目名称:dolibarr,代码行数:65,代码来源:user.class.php


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