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


PHP F::map方法代码示例

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


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

示例1: savePreferences

 /**
  * saves user preferences
  *
  * @return Illuminate\View\View
  */
 public function savePreferences()
 {
     $section_ids = function ($input) {
         $input_data = Input::get($input, '');
         if (strlen($input_data) == 0) {
             return "";
         }
         $arr = explode(',', $input_data);
         return implode(',', array_unique(F::map($this->section->getByTitle($arr), function ($m) {
             return $m->id;
         })));
     };
     $show_nsfw = Input::get('show_nsfw', 0);
     $show_nsfl = Input::get('show_nsfl', 0);
     $frontpage_show_sections = $section_ids('frontpage_show_sections');
     $frontpage_ignore_sections = $section_ids('frontpage_ignore_sections');
     if ($frontpage_show_sections == "0") {
         $frontpage_show_sections = "";
     }
     if ($frontpage_ignore_sections == "0") {
         $frontpage_ignore_sections = "";
     }
     $this->user->savePreferences(Auth::id(), ['show_nsfw' => $show_nsfw, 'show_nsfl' => $show_nsfl, 'frontpage_show_sections' => $frontpage_show_sections, 'frontpage_ignore_sections' => $frontpage_ignore_sections]);
     $sections = $this->section->get();
     $section = $this->section->sectionFromEmptySection();
     return View::make('page.user.prefs.savedpreferences', ['sections' => $sections, 'section' => $section]);
 }
开发者ID:hrenos,项目名称:spreadit,代码行数:32,代码来源:PreferencesController.php

示例2: generate

 /**
  * generate xss/atom from spreadit
  *
  * @param string $section_title
  * @return Roumen\Feed
  */
 protected function generate($section_title)
 {
     $sections = $this->section->getByTitle(Utility::splitByTitle($section_title));
     if (empty($sections)) {
         App::abort(404);
     }
     $section = $this->section->sectionFromSections($sections);
     $posts = $this->post->getHotList(F::map($sections, function ($m) {
         return $m->id;
     }), $this->vote);
     $feed = Feed::make();
     $feed->title = $section_title;
     $feed->description = "read hot posts from {$section_title}";
     $feed->link = URL::to("/s/{$section_title}");
     $feed->lang = 'en';
     $created_at_counter = 0;
     foreach ($posts as $post) {
         $feed->add($post->title, $post->username, URL::to($post->url), date(DATE_ATOM, $post->created_at), $post->markdown);
         if ($post->created_at > $created_at_counter) {
             $created_at_counter = $post->created_at;
         }
     }
     $feed->pubdate = date(DATE_ATOM, $created_at_counter);
     return $feed;
 }
开发者ID:hrenos,项目名称:spreadit,代码行数:31,代码来源:FeedController.php

示例3: render

 public function render($branch = null, $first = false)
 {
     if ($branch == null) {
         $branch = $this;
     }
     $rval = $first ? View::make('comment.piece', ['comment' => $branch]) : '';
     if (count($branch->children) > 0) {
         $result = F::reduce_left(F::map($branch->children, function ($v) {
             $tresult = $this->render($v, true);
             return "<div class='child'>{$tresult}<div class='clearleft'></div></div>";
         }), function ($v, $i, $c, $r) {
             return $r . $v;
         });
         $rval .= $result;
     }
     $rval .= "<div class='clearleft'></div>";
     return $rval;
 }
开发者ID:hrenos,项目名称:spreadit,代码行数:18,代码来源:CommentBranch.php

示例4: getMatchingVotes

 public function getMatchingVotes($type, $items)
 {
     //requires to be logged in
     if (!Auth::check()) {
         return array();
     }
     $items_to_check = F::map($items, function ($m) {
         return $m->id;
     });
     if (count($items_to_check) == 0) {
         $items_to_check = array(0);
     }
     $votes = DB::table('votes')->select('item_id', 'updown')->where('user_id', '=', Auth::user()->id)->where('type', '=', $type)->whereIn('item_id', $items_to_check)->get();
     $rval = array();
     foreach ($votes as $i) {
         $rval[$i->item_id] = $i->updown;
     }
     return $rval;
 }
开发者ID:hrenos,项目名称:spreadit,代码行数:19,代码来源:Vote.php

示例5: sectionFromSections

 public function sectionFromSections(array $sections)
 {
     if (count($sections) == 0) {
         $section = new stdClass();
         $section->id = -1;
         $section->multi_spreadit = false;
         $section->title = "";
     } else {
         if (count($sections) == 1) {
             $section = $sections[0];
         } else {
             if (count($sections) > 1) {
                 $section = new stdClass();
                 $section->id = -1;
                 $section->multi_spreadit = true;
                 $section->title = implode('+', F::map($sections, function ($m) {
                     return $m->title;
                 }));
             }
         }
     }
     return $section;
 }
开发者ID:hrenos,项目名称:spreadit,代码行数:23,代码来源:Section.php

示例6: get

 /**
  * renders a section page
  *
  * @param string  $section_title
  * @param string  $sort_mode
  * @param string  $timeframe_mode
  * @param bool    $no_view
  * @return mixed
  */
 protected function get($section_title, $sort_mode, $timeframe_mode, $no_view)
 {
     $sections = $this->section->getByTitle(Utility::splitByTitle($section_title));
     if (empty($sections)) {
         App::abort(404);
     }
     $sections = $this->vote->getSelectedList(Constant::SECTION_TYPE, $sections);
     $section = $this->section->sectionFromSections($sections);
     $section->selected = $this->vote->getSelected(Constant::SECTION_TYPE, $section);
     if (is_null($sort_mode)) {
         $sort_mode = Utility::getSortMode();
     }
     if (is_null($timeframe_mode)) {
         $timeframe_mode = Utility::getSortTimeframe();
     }
     $section_ids = F::map($sections, function ($m) {
         return $m->id;
     });
     $posts = $this->getPosts($sort_mode, $section_ids, $this->getSecondsFromTimeframe($timeframe_mode));
     if ($no_view) {
         return $posts;
     }
     return Response::make(View::make('page.section', ['sections' => $this->section->get(), 'posts' => $posts, 'section' => $section, 'sort_highlight' => $sort_mode, 'sort_timeframe_highlight' => $timeframe_mode]))->withCookie(Cookie::make('posts_sort_mode', $sort_mode))->withCookie(Cookie::make('posts_sort_timeframe', $timeframe_mode));
 }
开发者ID:hrenos,项目名称:spreadit,代码行数:33,代码来源:SectionController.php


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