Esempio n. 1
0
 public function byMysqlAction($param = null)
 {
     $domain = rtrim($this->config->application->siteUri, '/');
     $sitemapsStorage = rtrim($this->config->application->sitemapsDir, '/');
     $sitemap = new Sitemap($domain);
     $sitemap->setPath($sitemapsStorage . '/');
     /** @var Contents[] $contents */
     $contents = Contents::find(['columns' => "url, content, created_at", 'group' => "url", 'order' => "created_at DESC"]);
     $count = 0;
     foreach ($contents as $content) {
         $count++;
         if ($count % 1000 == 0) {
             $this->log->info("обрабатано {$count} строк");
         }
         $data = json_decode($content->content, true);
         if (isset($param[3]) && $param[3] == 'full') {
             $condition = $data['controller'] == 'books' && ($data['action'] == 'listByClass' || $data['action'] == 'booksBySubject' || $data['action'] == 'listByBoth' || $data['action'] == 'view' || $data['action'] == 'list');
         } else {
             $condition = $data['controller'] == 'books' && ($data['action'] == 'listByClass' || $data['action'] == 'booksBySubject' || $data['action'] == 'listByBoth' || $data['action'] == 'view');
         }
         if ($condition) {
             $sitemap->addItem($content->url, 0.5, null, $content->created_at);
             continue;
         }
         if ($data['controller'] == 'books' && $data['action'] == 'viewTask' && $data['book']['is_single_page'] == false) {
             $sitemap->addItem($content->url, 0.5, null, $content->created_at);
         }
     }
     $sitemap->createSitemapIndex($domain . '/sitemaps/', 'Today');
 }
 /**
  * {@inheritDoc}
  */
 public function register(Container $app)
 {
     $app['sitemap.generator'] = function (Application $app) {
         $generator = new SitemapGenerator($app['sitemap.domain']);
         $generator->setPath(rtrim($app['sitemap.path'], '/') . '/');
         $generator->setFilename(isset($app['sitemap.filename']) ? $app['sitemap.filename'] : 'sitemap');
         return $generator;
     };
     $app['sitemap'] = function (Application $app) {
         return new Sitemap($app['sitemap.generator'], $app['sitemap.loc']);
     };
 }
 public function __construct($host = null)
 {
     $this->host = !is_null($host) ? $host : 'http://' . $_SERVER['SERVER_NAME'];
     if (is_null($this->trackPath)) {
         $this->trackPath = getcwd();
     }
     parent::__construct($this->host);
 }
Esempio n. 4
0
 public function action_create()
 {
     // Include the file needed to create the sitemap.
     include "lib/Sitemap.php";
     $sitemap = new Sitemap(C("esoTalk.baseURL"));
     $sitemap->setPath(PATH_ROOT . "/");
     $sitemap->addItem("", "1.0", "hourly", 'now');
     $result = ET::SQL()->select("ch.channelId")->select("ch.slug")->from("channel ch")->orderBy("ch.channelId ASC")->exec();
     $channels = $result->allRows("channelId");
     foreach ($channels as $channel) {
         if (!in_array($channel["slug"], C("plugin.Sitemap.channels"))) {
             $sitemap->addItem("conversations/" . $channel["slug"], C("plugin.Sitemap.priority3"), C("plugin.Sitemap.frequency3"), 'now');
             $result = ET::SQL()->select("c.conversationId")->select("c.title")->select("c.channelId")->select("c.sticky")->select("lastPostTime")->from("conversation c")->where("c.channelId = :channelId")->where("private", 0)->orderBy("c.conversationId ASC")->bind(":channelId", $channel["channelId"])->exec();
             $conversations = $result->allRows();
             foreach ($conversations as $conversation) {
                 $url = conversationURL($conversation["conversationId"], $conversation["title"]);
                 if ($conversation["sticky"]) {
                     $sitemap->addItem($url, C("plugin.Sitemap.priority2"), C("plugin.Sitemap.frequency2"), $conversation["lastPostTime"]);
                 } else {
                     $sitemap->addItem($url, C("plugin.Sitemap.priority1"), C("plugin.Sitemap.frequency1"), $conversation["lastPostTime"]);
                 }
             }
         }
     }
     $sitemap->createSitemapIndex("http://www.bitcoinclub.nl/", 'now');
 }
Esempio n. 5
0
 /**
  * Generate Site
  */
 public function generate()
 {
     if (doo_csrf()) {
         $sitemap = new Sitemap($this->site_url);
         $sitemap->setPath('app/storage/sitemap/');
         if (\Config::get('show_all_items_in_sitemap') == 'yes') {
             $items = $this->app->item->sitemapItem();
         }
         if (\Config::get('show_all_items_in_sitemap') == 'no') {
             $items = $this->app->item->take(\Config::get('number_of_items_to_show'));
         }
         foreach ($items as $item) {
             //single item url to be show on site map
             $sitemap->addItem('/s/' . $item->id . '/' . $item['seoName'], $this->_item_sitemap_priority(), $this->_item_sitemap_frequency(), 'Today');
         }
         $pages = $this->app->page->getAll();
         foreach ($pages as $page) {
             $sitemap->addItem('/p/' . $page['slug'], $this->_page_sitemap_priority(), $this->_page_sitemap_frequency(), 'Today');
         }
         $sitemap->createSitemapIndex($this->site_url . '/app/storage/sitemap/', 'Today');
         \App::flash('sitemap_generated_msg', 'Sitemap generated.');
         \Response::redirect($this->site_url . '/admin-area/sitemap');
     }
 }
Esempio n. 6
0
 /**
  * Create sitemap.
  */
 public function create()
 {
     $this->generator->createSitemapIndex($this->loc);
 }