本文整理匯總了PHP中Locale::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Locale::model方法的具體用法?PHP Locale::model怎麽用?PHP Locale::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Locale
的用法示例。
在下文中一共展示了Locale::model方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeSave
public function beforeSave()
{
// Clean the public home page cache when we save a promotion, so the old price doesn't stay up many hours after a rebate ended
$locales = Locale::model()->findAll();
foreach ($locales as $locale) {
$cache_id = Yii::app()->request->hostInfo . " SiteController:[indexForLanguage] " . $locale->id;
Yii::app()->cache->delete($cache_id);
}
return parent::beforeSave();
}
示例2: actionSitemap
public function actionSitemap()
{
header('Content-type: application/xml');
$cache_id = "Sitemap";
$output_string = Yii::app()->cache->get($cache_id);
if (!$output_string) {
ini_set('memory_limit', '512000000');
set_time_limit(300);
$output_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n";
// Add the home page
$locales = Locale::model()->findAll();
$localizedHomepages = "";
foreach ($locales as $locale) {
$localizedHomepages .= "<xhtml:link rel=\"alternate\" hreflang=\"" . $locale->id . "\" href=\"" . $this->createAbsoluteUrl("site/index", array('language' => $locale->id)) . "\"/>";
}
foreach ($locales as $locale) {
$output_string .= "<url>";
$output_string .= "<loc>" . $this->createAbsoluteUrl("site/index", array('language' => $locale->id)) . "</loc>";
$output_string .= $localizedHomepages;
$output_string .= "</url>";
}
// Add all categories
$all_categories = Category::model()->findAll(array("limit" => 10000));
foreach ($all_categories as $category) {
$localizedLinks = "";
foreach ($category->categoryLocalizations as $localization) {
$localizedLinks .= "<xhtml:link rel=\"alternate\" hreflang=\"" . $localization->locale_id . "\" href=\"" . $this->createAbsoluteUrl("category/view", array('slug' => $localization->slug, 'language' => $localization->locale_id)) . "\"/>";
}
foreach ($category->categoryLocalizations as $localization) {
$output_string .= "<url>";
$output_string .= "<loc>" . $this->createAbsoluteUrl("category/view", array('slug' => $localization->slug, 'language' => $localization->locale_id)) . "</loc>";
$output_string .= $localizedLinks;
$output_string .= "</url>";
}
}
// Same for products
$all_products = Product::model()->findAll(array("limit" => 10000, "offset" => 0));
foreach ($all_products as $product) {
$localizedLinks = "";
foreach ($product->productLocalizations as $localization) {
$localizedLinks .= "<xhtml:link rel=\"alternate\" hreflang=\"" . $localization->locale_id . "\" href=\"" . $this->createAbsoluteUrl("product/view", array('slug' => $localization->slug, 'language' => $localization->locale_id)) . "\"/>";
}
foreach ($product->productLocalizations as $localization) {
$output_string .= "<url>";
$output_string .= "<loc>" . $this->createAbsoluteUrl("product/view", array('slug' => $localization->slug, 'language' => $localization->locale_id)) . "</loc>";
$output_string .= $localizedLinks;
$output_string .= "</url>";
}
}
$output_string .= "</urlset>";
Yii::app()->cache->set($cache_id, $output_string, 604800);
}
echo $output_string;
foreach (Yii::app()->log->routes as $route) {
if ($route instanceof CWebLogRoute) {
$route->enabled = false;
// disable any weblogroutes
}
}
Yii::app()->end();
}