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


PHP Locale::model方法代码示例

本文整理汇总了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();
 }
开发者ID:KEMSolutions,项目名称:Boukem1,代码行数:10,代码来源:ProductRebate.php

示例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();
 }
开发者ID:KEMSolutions,项目名称:Boukem1,代码行数:61,代码来源:SiteController.php


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