예제 #1
0
 public function feedItems(\Closure $consumer, $limit = 0)
 {
     $last = 0;
     $items = PageUpdate::diff()->orderBy('created_at', 'desc');
     if ($limit) {
         $items = $items->take($limit);
     }
     foreach ($items->get() as $item) {
         if ($this->filter($item)) {
             $page = $item->relatedPage();
             $author = $item->relatedAuthor();
             $feed = new FeedItem();
             $feed->title = $page->title;
             $feed->author = $author->fio;
             $feed->created = $item->created_at;
             $feed->url = route('pages.updates.index', $page) . '?highlite=' . $item->version()->encode();
             $feed->description = view('rss.diff-item', ['update' => $item, 'feed' => $feed]);
             $consumer($feed);
             if ($feed->created->timestamp > $last) {
                 $last = $feed->created->timestamp;
             }
         }
     }
     return $last ? Date::createFromTimestamp($last) : Date::now();
 }
예제 #2
0
 /**
  * Display the specified page entity.
  *
  * @param  Page $page
  * @return Response
  */
 public function show()
 {
     list($author, $group, $page) = pick_arg(Author::class, Group::class, Page::class);
     $exclude = view_excludes(['author' => $author, 'group' => $group]);
     $updates = \Ankh\PageUpdate::where('entity_id', $page->id)->diff()->orderBy('created_at', 'desc')->get()->all();
     $groupper = new UpdatesGroupper($updates);
     $versions = $groupper->flow();
     return $this->viewVersions(compact('page', 'updates', 'versions', 'exclude'));
 }
예제 #3
0
 public function clean()
 {
     $pages = Page::onlyTrashed();
     $pageIds = $pages->get(['id'])->pluck('id', 'id');
     $trough = PageUpdate::withTrashed()->get(['id', 'entity_id'])->all();
     $same = array_filter(array_map(function ($e) use($pageIds) {
         return isset($pageIds[$e->entity_id]) ? $e->id : false;
     }, $trough));
     $updates = Update::withTrashed()->whereIn('id', $same);
     $updateIds = $updates->get(['id'])->pluck('id');
     $updates->forceDelete();
     $pages->forceDelete();
     $this->stats = ['pages' => $pageIds->toArray(), 'updates' => $updateIds->toArray()];
     return $this->stats;
 }
예제 #4
0
파일: CheckPage.php 프로젝트: ankhzet/Ankh
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $update = PageUpdate::withTrashed()->find($this->update);
     $page = $update->relatedPage();
     $version = $page->version($update->created_at);
     Log::info("Checking page " . $page->id . "...");
     $compare = with(new Comparator())->compareLast($version);
     if ($compare === false) {
         throw new \Exception("Page {$page->id} check failed");
     }
     if ($compare->equals()) {
         Log::info("Page {$page->id} check found no differences");
     } else {
         $update->restore();
     }
 }