/** * Generate XML sitemap links * * @return void */ public function generateXMLSitemapLinks() { $iterator = new \XLite\Module\CDev\XMLSitemap\Logic\SitemapIterator(); $i = 0; $options = xmlsitemap_get_changefreq_options(); $hash = array_flip($options); foreach ($iterator as $record) { $target = $record['loc']['target']; unset($record['loc']['target']); $record['loc'] = \XLite\Core\Converter::buildDrupalPath($target, '', $record['loc']); $i++; $record['type'] = 'lc_connector'; $record['subtype'] = ''; $record['id'] = $i; if (isset($hash[$record['changefreq']])) { $record['changefreq'] = $hash[$record['changefreq']]; } else { unset($record['changefreq']); } xmlsitemap_link_save($record); } }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $query = db_select('xmlsitemap', 'x'); $query->addExpression('MAX(id)'); $id = $query->execute()->fetchField(); $link = array(); $link += array('id' => $id + 1, 'loc' => '', 'priority' => XMLSITEMAP_PRIORITY_DEFAULT, 'lastmod' => 0, 'changefreq' => 0, 'changecount' => 0, 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED); $form['type'] = array('#type' => 'value', '#value' => 'custom'); $form['id'] = array('#type' => 'value', '#value' => $link['id']); $form['loc'] = array('#type' => 'textfield', '#title' => t('Path to link'), '#field_prefix' => Url::fromRoute('<front>', [], array('absolute' => TRUE)), '#default_value' => $link['loc'] ? drupal_get_path_alias($link['loc'], $link['language']) : '', '#required' => TRUE, '#size' => 30); $form['priority'] = array('#type' => 'select', '#title' => t('Priority'), '#options' => xmlsitemap_get_priority_options(), '#default_value' => number_format($link['priority'], 1), '#description' => t('The priority of this URL relative to other URLs on your site.')); $form['changefreq'] = array('#type' => 'select', '#title' => t('Change frequency'), '#options' => array(0 => t('None')) + xmlsitemap_get_changefreq_options(), '#default_value' => $link['changefreq'], '#description' => t('How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page.')); $languages = $this->languageManager->getLanguages(); $languages_list = array(); foreach ($languages as $key => $value) { $languages_list[$key] = $value->getName(); } $form['language'] = array('#type' => 'select', '#title' => t('Language'), '#default_value' => $link['language'], '#options' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => t('Language neutral')) + $languages_list, '#access' => $languages_list); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#weight' => 5); $cancel_link = Url::fromRoute('xmlsitemap_custom.list'); $form['actions']['cancel'] = array('#markup' => $this->l(t('Cancel'), $cancel_link), '#weight' => 10); return $form; }