本文整理汇总了PHP中Languages::get_language_id_by_code方法的典型用法代码示例。如果您正苦于以下问题:PHP Languages::get_language_id_by_code方法的具体用法?PHP Languages::get_language_id_by_code怎么用?PHP Languages::get_language_id_by_code使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Languages
的用法示例。
在下文中一共展示了Languages::get_language_id_by_code方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Create
/**
* Create a new customer
*
* List of all the array parameters
*
* @param array_item firstname
* @param array_item lastname
* @param array_item email
* @param array_item password
* @param array_item company
* @param array_item statusId
* @param array_item gender
* @param array_item birthplace
* @param array_item birthdate
* @param array_item birthcountry
* @param array_item birthnationality
* @param array_item vat
* @param array_item taxpayernumber
* @param array_item contact
* @param array_item contacttype
* @param array_item address
* @param array_item city
* @param array_item code
* @param array_item country
* @param array_item area
* @param array_item legalform
* @param array_item company_type_id
* @param array_item welcome_mail
* @param array_item parent_id
* @param array_item isreseller
*/
public static function Create($data)
{
$locale = Shineisp_Registry::getInstance()->Zend_Locale;
$customer = new Customers();
$isDisabled = false;
$language_id = Languages::get_language_id_by_code((string) $locale);
// By default, welcome mail is sent
$data['welcome_mail'] = isset($data['welcome_mail']) ? intval($data['welcome_mail']) : true;
// Customer's parameters.
$customer->company = !empty($data['company']) ? $data['company'] : null;
$customer->firstname = !empty($data['firstname']) ? $data['firstname'] : null;
$customer->lastname = !empty($data['lastname']) ? $data['lastname'] : null;
$customer->gender = !empty($data['gender']) ? $data['gender'] : null;
$customer->email = $data['email'] ? $data['email'] : null;
$customer->password = crypt($data['password']);
$customer->birthplace = !empty($data['birthplace']) ? $data['birthplace'] : null;
$customer->birthdate = !empty($data['birthdate']) ? Shineisp_Commons_Utilities::formatDateIn($data['birthdate']) : null;
$customer->birthdistrict = !empty($data['birthdistrict']) ? $data['birthdistrict'] : null;
$customer->birthcountry = !empty($data['birthcountry']) ? $data['birthcountry'] : null;
$customer->birthnationality = !empty($data['birthnationality']) ? $data['birthnationality'] : null;
$customer->note = !empty($data['note']) ? $data['note'] : Null;
$customer->vat = !empty($data['vat']) ? $data['vat'] : Null;
$customer->taxpayernumber = !empty($data['taxpayernumber']) ? $data['taxpayernumber'] : Null;
// Let's try to get status_id from status
if (isset($data['status']) && !empty($data['status'])) {
$customer->status_id = Statuses::id($data['status'], 'Customers');
$isDisabled = isset($data['status']) && strtolower($data['status']) == 'disabled' ? true : false;
} else {
$customer->status_id = !empty($data['status_id']) ? $data['status_id'] : Statuses::id('Active', 'Customers');
}
$customer->legalform_id = !empty($data['legalform']) ? $data['legalform'] : Null;
$customer->type_id = !empty($data['company_type_id']) ? $data['company_type_id'] : Null;
$customer->parent_id = !empty($data['parent_id']) ? $data['parent_id'] : Null;
$customer->isreseller = !empty($data['isreseller']) ? $data['isreseller'] : Null;
$customer->language_id = !empty($language_id) ? intval($language_id) : 1;
$customer->created_at = date('Y-m-d H:i:s');
$customer->updated_at = date('Y-m-d H:i:s');
// Try to get the real isp_id, based on logged user or on request uri
// TODO: this should be done better
$customer->isp_id = Isp::getCurrentId();
// Generate an UUID. Used for API when you need to sync customers between services
// TODO: allow custom uuid coming from api ? If yes, we should check for uniqueness in database
$customer->uuid = Shineisp_Commons_Uuid::generate();
// customer disabled? Disable its password
if ($isDisabled) {
$customer->password = '!' . $customer->password;
}
// Save the data
$customer->save();
if (!empty($data['contact'])) {
$customer->Contacts[0]->contact = !empty($data['contact']) ? $data['contact'] : Null;
$customer->Contacts[0]->type_id = !empty($data['contacttypes']) ? $data['contacttypes'] : Null;
$customer->Contacts[0]->base = 1;
$customer->save();
}
if (!empty($data['address'])) {
$customer->Addresses[0]->address = !empty($data['address']) ? $data['address'] : Null;
$customer->Addresses[0]->city = !empty($data['city']) ? $data['city'] : Null;
$customer->Addresses[0]->code = !empty($data['code']) ? $data['code'] : Null;
$customer->Addresses[0]->country_id = !empty($data['country_id']) ? $data['country_id'] : Null;
$customer->Addresses[0]->area = !empty($data['area']) ? $data['area'] : Null;
$customer->save();
}
$customerID = $customer->getIncremented();
// Add the customer email in the newsletter list
if (!$isDisabled) {
NewslettersSubscribers::customer_optIn($customer['customer_id']);
}
// Send the welcome email
//.........这里部分代码省略.........
示例2: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$force = false;
$registry = Shineisp_Registry::getInstance();
// Check if the config file has been created
$isReady = Shineisp_Main::isReady();
$module = $request->getModuleName();
if ($module == "default") {
// set the right session namespace per module
$module_session = 'Default';
} elseif ($module == "admin") {
$module_session = 'Admin';
} else {
$module_session = 'Default';
}
$ns = new Zend_Session_Namespace($module_session);
try {
$locale = new Zend_Locale(Zend_Locale::BROWSER);
if (!empty($ns->lang)) {
$locale = new Zend_Locale($ns->lang);
}
Shineisp_Commons_Utilities::log("System: Get the browser locale: " . $locale, "debug.log");
} catch (Exception $e) {
Shineisp_Commons_Utilities::log("System: " . $e->getMessage(), "debug.log");
if (!empty($ns->lang)) {
Shineisp_Commons_Utilities::log("System: Get the session var locale", "debug.log");
$locale = new Zend_Locale($ns->lang);
} else {
$locale = new Zend_Locale("en");
Shineisp_Commons_Utilities::log("System: There is not any available locale, set the default one: en_GB", "debug.log");
}
}
// check the user request if it is not set, please get the old prefereces
$lang = $request->getParam('lang');
if (empty($lang)) {
// Get the user preference
if (strlen($locale) == 2) {
// Check if the Browser locale is formed with 2 chars
$lang = $locale;
} elseif (strlen($locale) > 4) {
// Check if the Browser locale is formed with > 4 chars
$lang = substr($locale, 0, 2);
// Get the language code from the browser preference
}
} else {
$force = true;
}
// Get the translate language or the default language: en
if (file_exists(PUBLIC_PATH . "/languages/{$lang}/{$lang}.mo")) {
$translate = new Zend_Translate(array('adapter' => "Shineisp_Translate_Adapter_Gettext", 'content' => PUBLIC_PATH . "/languages/{$lang}/{$lang}.mo", 'locale' => $lang, 'disableNotices' => true));
} else {
$translate = new Zend_Translate(array('adapter' => "Shineisp_Translate_Adapter_Gettext", 'locale' => $lang, 'disableNotices' => true));
}
$registry->set('Zend_Translate', $translate);
$registry->set('Zend_Locale', $locale);
if ($isReady) {
if (empty($ns->langid) || $force) {
$ns->langid = Languages::get_language_id_by_code($lang);
}
} else {
$ns->langid = 1;
}
$ns->lang = $lang;
Shineisp_Commons_Utilities::log("System: Locale set: " . $locale, "debug.log");
Shineisp_Commons_Utilities::log("System: Language selected: " . $ns->lang, "debug.log");
}
示例3: find
/**
* Get a record by ID
*
* @param $id
* @return Doctrine Record
*/
public static function find($id, $fields = "*", $retarray = false, $lang = "en")
{
$language_id = Languages::get_language_id_by_code($lang);
$dq = Doctrine_Query::create()->select($fields)->from('EmailsTemplates et')->leftJoin("et.EmailsTemplatesData etd WITH etd.language_id = " . intval($language_id))->where("et.template_id = ?", $id)->limit(1);
return $retarray ? $dq->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY) : $dq->fetchOne();
}