Ejemplo n.º 1
0
 /**
  * Retrieve the name of a language
  * @param string $languageCode The language code. If it contails also a terrotory code (eg: 'en-US'), the result will contain also the territory code (eg 'English (United States)')
  * @param string $locale = '' The locale to use. If empty we'll use the default locale set in \Punic\Data
  * @return string Returns the localized language name (returns $languageCode if not found)
  */
 public static function getName($languageCode, $locale = '')
 {
     $result = $languageCode;
     $info = Data::explodeLocale($languageCode);
     if (!is_null($info)) {
         extract($info);
         $lookFor = array();
         if (strlen($script)) {
             if (strlen($territory)) {
                 $lookFor[] = "{$language}-{$script}-{$territory}";
             }
             $lookFor[] = "{$language}-{$script}";
         } elseif (strlen($territory)) {
             $lookFor[] = "{$language}-{$territory}";
         }
         $lookFor[] = $language;
         $data = Data::get('languages', $locale);
         foreach ($lookFor as $key) {
             if (array_key_exists($key, $data)) {
                 $result = $data[$key];
                 break;
             }
         }
         if (strlen($territory)) {
             $territoryName = Territory::getName($territory, $locale);
             if (strlen($territoryName)) {
                 $patternData = Data::get('localeDisplayNames');
                 $pattern = $patternData['localeDisplayPattern']['localePattern'];
                 $result = sprintf($pattern, $result, $territoryName);
             }
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Eloquent::unguard();
        DB::table('companies')->delete();
        DB::table('items')->delete();
        DB::table('categories')->delete();
        $territory = Territory::where('name', 'Stockholms län')->where('county', '01')->first();
        $company1 = Company::create(array('id' => 1, 'name' => '北欧工作室', 'description' => 'chenyipingsheng: 如何设计api,应该先按模块拆分原则进行初步划分。(4) api返回数据文章中所说的对null的看法...
app后端设计(10)--数据增量更新
chenyipingsheng: 文章中update_time的时间粒度选择的是分钟,如果某个时间段内新增的条数/分钟,超过了单页si...', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'address' => '啊发扩大浪费大斗进发觉啦地方', 'established_year' => '2011'));
        $company2 = Company::create(array('id' => 2, 'name' => '阿呆姆斯工作室', 'description' => 'chenyipingsheng: 如何设计api,应该先按模块拆分原则进行初步划分。(4) api返回数据文章中所说的对null的看法...
app后端设计(10)--数据增量更新
chenyipingsheng: 文章中update_time的时间粒度选择的是分钟,如果某个时间段内新增的条数/分钟,超过了单页si...', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'address' => '饿我热哦我iooewpp', 'established_year' => '2013'));
        $item1 = Item::create(array('id' => 1, 'company_id' => 1, 'name' => 'Kayala投资项目', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 20000000));
        $item2 = Item::create(array('id' => 2, 'company_id' => 1, 'name' => '棕熊城堡出售', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 30000000, 'max_investment' => 30000000));
        $item3 = Item::create(array('id' => 3, 'company_id' => 2, 'name' => '布鲁艾尔空气净化器', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 10000000, 'max_investment' => 10000000));
        $item4 = Item::create(array('id' => 4, 'company_id' => 2, 'name' => 'volvo公司转让', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 250000000, 'max_investment' => 250000000));
        Category::create(array('id' => 1, 'name' => '融资项目'));
        Category::create(array('id' => 2, 'name' => '房产出售'));
        Category::create(array('id' => 3, 'name' => '产品推广'));
        Category::create(array('id' => 4, 'name' => '公司转让'));
        Category::create(array('id' => 5, 'name' => '技术出售'));
        Category::create(array('id' => 6, 'name' => '文化, 媒体, 旅游'));
        CompanyCategory::create(array('id' => 1, 'company_id' => 1, 'category_id' => 6));
        CompanyCategory::create(array('id' => 2, 'company_id' => 2, 'category_id' => 6));
        ItemCategory::create(array('id' => 1, 'item_id' => 1, 'category_id' => 1));
        ItemCategory::create(array('id' => 2, 'item_id' => 1, 'category_id' => 2));
        ItemCategory::create(array('id' => 3, 'item_id' => 2, 'category_id' => 2));
        ItemCategory::create(array('id' => 4, 'item_id' => 3, 'category_id' => 4));
        ItemCategory::create(array('id' => 5, 'item_id' => 3, 'category_id' => 5));
        ItemCategory::create(array('id' => 6, 'item_id' => 3, 'category_id' => 6));
        ItemCategory::create(array('id' => 7, 'item_id' => 4, 'category_id' => 3));
        ItemCategory::create(array('id' => 8, 'item_id' => 4, 'category_id' => 5));
        Tag::create(array('id' => 1, 'name' => '回报率高'));
        Tag::create(array('id' => 2, 'name' => '绿色环保'));
        Tag::create(array('id' => 3, 'name' => '市场巨大'));
        Tag::create(array('id' => 4, 'name' => '用途广'));
        Tag::create(array('id' => 5, 'name' => '历史悠久'));
        Tag::create(array('id' => 6, 'name' => '可自雇'));
        Tag::create(array('id' => 7, 'name' => 'PM2.5'));
        ItemTag::create(array('id' => 1, 'tag_id' => 1, 'item_id' => 1));
        ItemTag::create(array('id' => 2, 'tag_id' => 2, 'item_id' => 1));
        ItemTag::create(array('id' => 3, 'tag_id' => 3, 'item_id' => 1));
        ItemTag::create(array('id' => 4, 'tag_id' => 2, 'item_id' => 2));
        ItemTag::create(array('id' => 5, 'tag_id' => 3, 'item_id' => 2));
        ItemTag::create(array('id' => 6, 'tag_id' => 4, 'item_id' => 2));
        ItemTag::create(array('id' => 7, 'tag_id' => 5, 'item_id' => 3));
        ItemTag::create(array('id' => 8, 'tag_id' => 6, 'item_id' => 3));
        ItemTag::create(array('id' => 9, 'tag_id' => 7, 'item_id' => 3));
        ItemTag::create(array('id' => 10, 'tag_id' => 3, 'item_id' => 4));
        ItemTag::create(array('id' => 11, 'tag_id' => 6, 'item_id' => 4));
    }
Ejemplo n.º 3
0
 /**
  * Retrieve the name of a language.
  *
  * @param string $languageCode The language code. If it contails also a terrotory code (eg: 'en-US'), the result will contain also the territory code (eg 'English (United States)')
  * @param string $locale The locale to use. If empty we'll use the default locale set in \Punic\Data
  *
  * @return string Returns the localized language name (returns $languageCode if not found)
  */
 public static function getName($languageCode, $locale = '')
 {
     $result = $languageCode;
     $info = Data::explodeLocale($languageCode);
     if ($info !== null) {
         $language = $info['language'];
         $script = $info['script'];
         $territory = $info['territory'];
         $lookFor = array();
         if (isset($script[0])) {
             if (isset($territory[0])) {
                 $lookFor[] = "{$language}-{$script}-{$territory}";
             }
             $lookFor[] = "{$language}-{$script}";
         } elseif (isset($territory[0])) {
             $lookFor[] = "{$language}-{$territory}";
         }
         $lookFor[] = $language;
         $data = Data::get('languages', $locale);
         foreach ($lookFor as $key) {
             if (isset($data[$key])) {
                 $result = $data[$key];
                 break;
             }
         }
         if (isset($territory[0])) {
             $territoryName = Territory::getName($territory, $locale);
             if (isset($territoryName[0])) {
                 $patternData = Data::get('localeDisplayNames');
                 $pattern = $patternData['localeDisplayPattern']['localePattern'];
                 $result = sprintf($pattern, $result, $territoryName);
             }
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * Returns a list of locale identifiers associated to a locale.
  *
  * @param string $locale The locale for which you want the alternatives
  * @param string $addFallback Set to true to add the fallback locale to the result, false otherwise
  *
  * @return array
  */
 protected static function getLocaleAlternatives($locale, $addFallback = true)
 {
     $result = array();
     $localeInfo = static::explodeLocale($locale);
     if (!is_array($localeInfo)) {
         throw new Exception\InvalidLocale($locale);
     }
     $language = $localeInfo['language'];
     $script = $localeInfo['script'];
     $territory = $localeInfo['territory'];
     $parentLocale = $localeInfo['parentLocale'];
     if (!isset($territory[0])) {
         $fullLocale = static::guessFullLocale($language, $script);
         if (isset($fullLocale[0])) {
             $localeInfo = static::explodeLocale($fullLocale);
             $language = $localeInfo['language'];
             $script = $localeInfo['script'];
             $territory = $localeInfo['territory'];
             $parentLocale = $localeInfo['parentLocale'];
         }
     }
     $territories = array();
     while (isset($territory[0])) {
         $territories[] = $territory;
         $territory = Territory::getParentTerritoryCode($territory);
     }
     if (isset($script[0])) {
         foreach ($territories as $territory) {
             $result[] = "{$language}-{$script}-{$territory}";
         }
     }
     if (isset($script[0])) {
         $result[] = "{$language}-{$script}";
     }
     foreach ($territories as $territory) {
         $result[] = "{$language}-{$territory}";
         if ("{$language}-{$territory}" === 'en-US') {
             $result[] = 'root';
         }
     }
     if (isset($parentLocale[0])) {
         $result = array_merge($result, static::getLocaleAlternatives($parentLocale, false));
     }
     $result[] = $language;
     if ($addFallback && $locale !== static::$fallbackLocale) {
         $result = array_merge($result, static::getLocaleAlternatives(static::$fallbackLocale, false));
     }
     for ($i = count($result) - 1; $i > 1; $i--) {
         for ($j = 0; $j < $i; $j++) {
             if ($result[$i] === $result[$j]) {
                 array_splice($result, $i, 1);
                 break;
             }
         }
     }
     $i = array_search('root', $result, true);
     if ($i !== false) {
         array_splice($result, $i, 1);
         $result[] = 'root';
     }
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Territory::find($id)->delete();
     return redirect('territories');
 }
Ejemplo n.º 6
0
 /**
  * Returns the list of countries that use a specific paper size by default.
  *
  * @param string $paperSize The paper size identifier ('A4' or 'US-Letter')
  *
  * @return array The list of country IDs that use the specified paper size (if $paperSize is invalid you'll get an empty array)
  */
 public static function getCountriesWithPaperSize($paperSize)
 {
     $result = array();
     if (is_string($paperSize) && isset($paperSize[0])) {
         $someGroup = false;
         $data = Data::getGeneric('measurementData');
         foreach ($data['paperSize'] as $territory => $ms) {
             if (strcasecmp($paperSize, $ms) === 0) {
                 $children = Territory::getChildTerritoryCodes($territory, true);
                 if (empty($children)) {
                     $result[] = $territory;
                 } else {
                     $someGroup = true;
                     $result = array_merge($result, $children);
                 }
             }
         }
         if ($someGroup) {
             $otherCountries = array();
             foreach ($data['paperSize'] as $territory => $ms) {
                 if ($territory !== '001' && strcasecmp($paperSize, $ms) !== 0) {
                     $children = Territory::getChildTerritoryCodes($territory, true);
                     if (empty($children)) {
                         $otherCountries[] = $territory;
                     } else {
                         $otherCountries = array_merge($otherCountries, $children);
                     }
                 }
             }
             $result = array_values(array_diff($result, $otherCountries));
         }
     }
     return $result;
 }