'url страницы','m'=>'дата последних изменений'],...] */ public function landingpagesSitemapXmlData($callback = true, $priority = '', array $opts = []) { if (empty($opts['subdomains'])) { $opts['subdomains'] = []; } $filter = $opts['filter'] ?? []; if (! isset($filter['enabled'])) { $filter['enabled'] = 1; } $from = ' FROM ' . static::TABLE_LANDING_PAGES . ' P '; if (isset($filter['withListingsItems'])) { $from .= ', ' . Listings::TABLE_ITEMS_COUNTERS . ' C '; $filter[':jcounters'] = [ 'P.joined_module = :module AND P.joined = C.cat_id AND C.region_id = :region', ':module' => 'listings-cats', ':region' => $filter['withListingsItems'], ]; } unset($filter['withListingsItems']); if (! empty($filter['notJoined'])) { $filter[':not_joined'] = 'P.joined_module IS NULL'; } unset($filter['notJoined']); $filter = $this->prepareFilter($filter); if ($callback) { return function ($count = false, callable $callback = null) use ($priority, $from, $filter, $opts) { if ($count) { return $this->db->one_data('SELECT COUNT(*) ' . $from . $filter['where'], $filter['bind']); } else { $languageKey = $this->locale->getDefaultLanguage(); $alt = $this->controller->sitemapXMLAltLangs(static::SITEMAP_LANG_ALL); $filter['bind'][':format'] = '%Y-%m-%d'; $this->db->select_iterator( 'SELECT landing_uri AS l, DATE_FORMAT(modified, :format) as m ' . $from . $filter['where'] . ' ORDER BY modified DESC', $filter['bind'], function (&$row) use ($languageKey, &$callback, $priority, $opts, $alt) { $row['m'] = ''; if ( ! ( mb_stripos($row['l'], 'http:') === 0 || mb_stripos($row['l'], 'https:') === 0 || mb_stripos($row['l'], '//') === 0 ) ) { if (! empty($alt)) { $row['alt'] = []; foreach ($alt as $l) { $row['alt'][$l] = Url::to($row['l'], ['lang' => $l, 'subdomains' => $opts['subdomains']]); } } $row['l'] = Url::to($row['l'], ['lang' => $languageKey, 'subdomains' => $opts['subdomains']]); } if (! empty($priority)) { $row['p'] = $priority; } $callback($row); } ); } return false; }; } $filter['bind'][':format'] = '%Y-%m-%d'; $data = $this->db->select(' SELECT landing_uri AS l, DATE_FORMAT(modified, :format) as m ' . $from . $filter['where'] . ' ORDER BY modified DESC', $filter['bind']); if (empty($data)) { return []; } $languageKey = $this->locale->getDefaultLanguage(); foreach ($data as &$v) { $v['m'] = ''; $v['l'] = Url::to($v['l'], ['lang' => $languageKey, 'subdomains' => $opts['subdomains']]); if (! empty($priority)) { $v['p'] = $priority; } } unset($v); return $data; } }