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


PHP Tool::slugSubst方法代码示例

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


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

示例1: onSaveSettings

 /**
  * [onSaveSettings description]
  * @param  [type] $model [description]
  * @param  [type] $home  [description]
  * @return [type]        [description]
  */
 public function onSaveSettings($model, $home, $page, $slug)
 {
     // Reset home Page if checked
     if ($home == 1) {
         $model->resetHomePage($page->id);
     }
     $new_slug = \Tool::slugSubst($page->seo->first()->slug, $slug);
     // Update the new slug
     $page->seo()->update(array('slug' => $new_slug));
 }
开发者ID:pongocms,项目名称:cms,代码行数:16,代码来源:PageSubscriber.php

示例2: copyPage

 /**
  * Copy a page to a new location
  * @return [type] [description]
  */
 public function copyPage()
 {
     if ($check = $this->canEdit()) {
         if ($this->input) {
             $page_id = $this->input['page_id'];
             $copy_lang = $this->input['copy_lang'];
             $file_all = isset($this->input['file_all']) ? true : false;
             $blocks = isset($this->input['blocks']) ? $this->input['blocks'] : null;
             $self_blocks = isset($this->input['self_block']) ? $this->input['self_block'] : null;
             // Duplicate page
             $page = $this->model->find($page_id);
             $new_page_arr = $page->getAttributes();
             // Clean some unwanted attributes
             unset($new_page_arr['id'], $new_page_arr['created_at'], $new_page_arr['updated_at']);
             $new_page_name = t('label.page.settings.copy_of') . ' ' . $page->name;
             $new_page_slug = '/' . \Tool::slugSubst($page->slug, \Str::slug($new_page_name));
             // Overriding with new values
             $new_page_arr['parent_id'] = $copy_lang != $page->lang ? 0 : $page->parent_id;
             $new_page_arr['name'] = $new_page_name;
             $new_page_arr['lang'] = $copy_lang;
             $new_page_arr['author_id'] = USERID;
             $new_page_arr['edit_level'] = LEVEL;
             $new_page_arr['is_home'] = 0;
             $new_page_arr['is_active'] = 0;
             // Create the new page
             $new_page = $this->model->create($new_page_arr);
             // Copy all related tags
             foreach ($page->tags as $tag) {
                 $new_page->tags()->attach($tag->id);
             }
             // Proceed with blocks
             if ($blocks) {
                 // Get Block model
                 $block_model = \App::make('Pongo\\Cms\\Repositories\\BlockRepositoryInterface');
                 foreach ($blocks as $block_id) {
                     // Get the block to copy
                     $block = $block_model->find($block_id);
                     // Get pivot info
                     foreach ($block->pages as $search_page) {
                         if ($search_page->pivot->page_id == $page_id) {
                             $zone = $search_page->pivot->zone;
                             $order_id = $search_page->pivot->order_id;
                         }
                     }
                     // If block is independent or not in the same language
                     if (isset($self_blocks[$block_id]) or $copy_lang != $page->lang) {
                         // Duplicate block
                         $new_block_arr = $block->getAttributes();
                         // Remove unwanted items
                         unset($new_block_arr['id'], $new_block_arr['created_at'], $new_block_arr['updated_at']);
                         // Create new block
                         $new_block = $block_model->create($new_block_arr);
                         // Attach to pivot
                         $new_page->blocks()->save($new_block, array('zone' => $zone, 'order_id' => DEFORDER, 'is_active' => 0));
                     } else {
                         // Check if not already present in pivot
                         if (!$block->pages->contains($new_page->id)) {
                             // Attach block to page in pivot
                             $block->pages()->attach($new_page->id, array('zone' => $zone, 'order_id' => $order_id, 'is_active' => 0));
                         }
                     }
                 }
             }
             // Proceed with files
             if ($file_all) {
                 foreach ($page->files as $file) {
                     $new_page->files()->attach($file->id, array('is_active' => $file->pivot->is_active));
                 }
             }
             $this->events->fire('page.copied', array($page, $new_page, $new_page_slug));
             return $this->redirect = array('redirect' => true, 'status' => 'success', 'msg' => t('alert.success.page_created'), 'route' => route('page.edit', array('page_id' => $new_page->id)));
         }
     } else {
         return $check;
     }
 }
开发者ID:pongocms,项目名称:cms,代码行数:80,代码来源:PageManager.php


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