本文整理汇总了PHP中ca_locales::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_locales::insert方法的具体用法?PHP ca_locales::insert怎么用?PHP ca_locales::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_locales
的用法示例。
在下文中一共展示了ca_locales::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processLocales
public function processLocales()
{
require_once __CA_MODELS_DIR__ . "/ca_locales.php";
$t_locale = new ca_locales();
$t_locale->setMode(ACCESS_WRITE);
// Find any existing locales
$va_locales = $t_locale->getLocaleList(array('index_by_code' => true));
foreach ($va_locales as $vs_code => $va_locale) {
$this->opa_locales[$vs_code] = $va_locale['locale_id'];
}
if ($this->ops_base_name) {
$va_locales = array();
foreach ($this->opo_profile->locales->children() as $vo_locale) {
$va_locales[] = $vo_locale;
}
foreach ($this->opo_base->locales->children() as $vo_locale) {
$va_locales[] = $vo_locale;
}
} else {
$va_locales = $this->opo_profile->locales->children();
}
foreach ($va_locales as $vo_locale) {
$vs_language = self::getAttribute($vo_locale, "lang");
$vs_dialect = self::getAttribute($vo_locale, "dialect");
$vs_country = self::getAttribute($vo_locale, "country");
$vb_dont_use_for_cataloguing = self::getAttribute($vo_locale, "dontUseForCataloguing");
if (isset($this->opa_locales[$vs_language . "_" . $vs_country])) {
// don't insert duplicate locales
continue;
}
$t_locale->set('name', (string) $vo_locale);
$t_locale->set('country', $vs_country);
$t_locale->set('language', $vs_language);
if ($vs_dialect) {
$t_locale->set('dialect', $vs_dialect);
}
$t_locale->set('dont_use_for_cataloguing', (bool) $vb_dont_use_for_cataloguing);
$t_locale->insert();
if ($t_locale->numErrors()) {
$this->addError("There was an error while inserting locale {$vs_language}_{$vs_country}: " . join(" ", $t_locale->getErrors()));
}
$this->opa_locales[$vs_language . "_" . $vs_country] = $t_locale->getPrimaryKey();
}
$va_locales = $t_locale->getAppConfig()->getList('locale_defaults');
$vn_locale_id = $t_locale->localeCodeToID($va_locales[0]);
if (!$vn_locale_id) {
throw new Exception("The locale default is set to a non-existing locale. Try adding '" . $va_locales[0] . "' to your profile.");
}
return true;
}