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


PHP Model_Location::gen_seotitle方法代码示例

本文整理汇总了PHP中Model_Location::gen_seotitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Location::gen_seotitle方法的具体用法?PHP Model_Location::gen_seotitle怎么用?PHP Model_Location::gen_seotitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model_Location的用法示例。


在下文中一共展示了Model_Location::gen_seotitle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_create

 /**
  * CRUD controller: CREATE
  */
 public function action_create()
 {
     $this->template->title = __('New') . ' ' . __($this->_orm_model);
     $this->template->scripts['footer'][] = 'js/gmaps.min.js';
     $this->template->scripts['footer'][] = 'js/oc-panel/locations-gmap.js';
     $this->template->scripts['async_defer'][] = '//maps.google.com/maps/api/js?libraries=geometry&v=3&key=' . core::config("advertisement.gm_api_key") . '&callback=initLocationsGMap';
     $location = new Model_Location();
     if ($post = $this->request->post()) {
         //check if the parent is loaded/exists avoiding errors
         $post['id_location_parent'] = $post['id_location_parent'] != '' ? $post['id_location_parent'] : 1;
         $parent_loc = new Model_Location($post['id_location_parent']);
         if (!$parent_loc->loaded()) {
             Alert::set(Alert::INFO, __('You are assigning a parent location that does not exist'));
             $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'create')));
         }
         foreach ($post as $name => $value) {
             //for description we accept the HTML as comes...a bit risky but only admin can
             if ($name == 'description') {
                 $location->description = Kohana::$_POST_ORIG['description'];
             } elseif ($name != 'submit') {
                 $location->{$name} = $value;
             }
         }
         if (!isset($post['seoname'])) {
             $location->seoname = $location->gen_seotitle($post['seoname']);
         } else {
             $location->seoname = $post['seoname'];
         }
         try {
             $location->save();
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         $this->action_deep();
         Core::delete_cache();
         Alert::set(Alert::SUCCESS, __('Location created'));
         $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller())) . (Core::post('id_location_parent') ? '?id_location=' . Core::post('id_location_parent') : NULL));
     }
     $locations = array('' => '');
     foreach (Model_Location::get_as_array() as $location) {
         $locations[$location['id']] = $location['name'];
     }
     return $this->render('oc-panel/pages/locations/create', compact('locations'));
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:47,代码来源:location.php


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