Пример #1
0
 /**
  * Cron schedule action - build content sitemap
  * @throws \Ffcms\Core\Exception\NativeException
  * @throws \Ffcms\Core\Exception\SyntaxException
  */
 public static function buildSitemapSchedule()
 {
     // get records from database as activerecord object
     $contents = \Apps\ActiveRecord\Content::where('display', '=', 1);
     if ($contents->count() < 1) {
         return;
     }
     // get languages if multilanguage enabled
     $langs = null;
     if (App::$Properties->get('multiLanguage')) {
         $langs = App::$Properties->get('languages');
     }
     // build sitemap from content items via business model
     $sitemap = new EntityBuildMap($langs);
     foreach ($contents->get() as $content) {
         $category = $content->getCategory();
         $uri = '/content/read/';
         if (!Str::likeEmpty($category->path)) {
             $uri .= $category->path . '/';
         }
         $uri .= $content->path;
         $sitemap->add($uri, $content->created_at, 'weekly', 0.7);
     }
     // add categories
     $categories = ContentCategory::all();
     foreach ($categories as $item) {
         if ((bool) $item->getProperty('showCategory')) {
             $uri = '/content/list/' . $item->path;
             $sitemap->add($uri, date('c'), 'daily', 0.9);
         }
     }
     // save data to xml file
     $sitemap->save('content');
 }
Пример #2
0
 /**
  * Cron schedule - build user profiles sitemap
  */
 public static function buildSitemapSchedule()
 {
     // get not empty user profiles
     $profiles = ProfileRecords::whereNotNull('nick');
     if ($profiles->count() < 1) {
         return;
     }
     // get languages if multilanguage enabled
     $langs = null;
     if (App::$Properties->get('multiLanguage')) {
         $langs = App::$Properties->get('languages');
     }
     // build sitemap from content items via business model
     $sitemap = new EntityBuildMap($langs);
     foreach ($profiles->get() as $user) {
         $sitemap->add('profile/show/' . $user->user_id, $user->updated_at, 'weekly', 0.2);
     }
     $sitemap->save('profile');
 }