Commit 327ccba3 authored by RenatoG's avatar RenatoG Committed by RenatoG

Issue #2906615 by RenatoG: Resolved items of Best practices for XML sitemap...

Issue #2906615 by RenatoG: Resolved items of Best practices for XML sitemap Modal and  XML sitemap Menu
parent 0ad514cb
...@@ -4,6 +4,4 @@ package = XML sitemap ...@@ -4,6 +4,4 @@ package = XML sitemap
core = 7.x core = 7.x
dependencies[] = xmlsitemap dependencies[] = xmlsitemap
dependencies[] = menu dependencies[] = menu
files[] = xmlsitemap_menu.module
files[] = xmlsitemap_menu.install
files[] = xmlsitemap_menu.test files[] = xmlsitemap_menu.test
<?php <?php
/**
* @file
* Main file for XML sitemap menu.
*/
/** /**
* Implements hook_entity_info_alter(). * Implements hook_entity_info_alter().
* *
...@@ -90,7 +95,7 @@ function xmlsitemap_menu_xmlsitemap_index_links($limit) { ...@@ -90,7 +95,7 @@ function xmlsitemap_menu_xmlsitemap_index_links($limit) {
/** /**
* Process menu sitemap links. * Process menu sitemap links.
* *
* @param $mlids * @param array $mlids
* An array of menu link IDs. * An array of menu link IDs.
*/ */
function xmlsitemap_menu_xmlsitemap_process_menu_links(array $mlids, array $xmlsitemap = array()) { function xmlsitemap_menu_xmlsitemap_process_menu_links(array $mlids, array $xmlsitemap = array()) {
...@@ -125,19 +130,23 @@ function xmlsitemap_menu_form_menu_edit_menu_alter(&$form, $form_state) { ...@@ -125,19 +130,23 @@ function xmlsitemap_menu_form_menu_edit_menu_alter(&$form, $form_state) {
xmlsitemap_add_link_bundle_settings($form, $form_state, 'menu_link', $menu); xmlsitemap_add_link_bundle_settings($form, $form_state, 'menu_link', $menu);
} }
//function xmlsitemap_menu_form_menu_overview_form_alter(&$form, $form_state) { /**
// $form['#submit'][] = 'xmlsitemap_menu_menu_overview_form_submit'; * Example functions.
//} *
// * Function xmlsitemap_menu_form_menu_overview_form_alter(&$form, $form_state) {
//function xmlsitemap_menu_menu_overview_form_submit($form, $form_state) { * $form['#submit'][] = 'xmlsitemap_menu_menu_overview_form_submit';
// $mlids = array(); * }
// foreach (element_children($form) as $mlid) { *
// if (isset($form[$mlid]['#item'])) { * Function xmlsitemap_menu_menu_overview_form_submit($form, $form_state) {
// $mlids[] = $form[$mlid]['#item']['mlid']; * $mlids = array();
// } * foreach (element_children($form) as $mlid) {
// } * if (isset($form[$mlid]['#item'])) {
// xmlsitemap_menu_xmlsitemap_process_menu_links($mlids); * $mlids[] = $form[$mlid]['#item']['mlid'];
//} * }
* }
* xmlsitemap_menu_xmlsitemap_process_menu_links($mlids);
* }
*/
/** /**
* Implements hook_form_FORM_ID_alter(). * Implements hook_form_FORM_ID_alter().
...@@ -205,8 +214,9 @@ function xmlsitemap_menu_menu_link_insert(array $link) { ...@@ -205,8 +214,9 @@ function xmlsitemap_menu_menu_link_insert(array $link) {
* @see hook_menu_link_alter() * @see hook_menu_link_alter()
*/ */
function xmlsitemap_menu_menu_link_update(array $link) { function xmlsitemap_menu_menu_link_update(array $link) {
//$link += array('xmlsitemap' => array()); // $link += array('xmlsitemap' => array());
//xmlsitemap_menu_xmlsitemap_process_menu_links(array($link['mlid']), $link['xmlsitemap']); // @codingStandardsIgnoreLine
// xmlsitemap_menu_xmlsitemap_process_menu_links(array($link['mlid']), $link['xmlsitemap']);.
} }
/** /**
...@@ -235,7 +245,7 @@ function xmlsitemap_menu_menu_link_delete(array $link) { ...@@ -235,7 +245,7 @@ function xmlsitemap_menu_menu_link_delete(array $link) {
/** /**
* Create a sitemap link from a menu item. * Create a sitemap link from a menu item.
* *
* @param $menu_item * @param array $menu_item
* A loaded menu item. * A loaded menu item.
*/ */
function xmlsitemap_menu_create_link(array $menu_item) { function xmlsitemap_menu_create_link(array $menu_item) {
......
...@@ -2,13 +2,35 @@ ...@@ -2,13 +2,35 @@
/** /**
* @file * @file
* Unit tests for the xmlsitemap_menu module. * Unit tests for the xmlsitemap_menu project..
*/ */
/**
* Menu Functional Test.
*/
class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper { class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
/**
* Normal User.
*
* @var string
*
* @codingStandardsIgnoreStart
*/
protected $normal_user; protected $normal_user;
/**
* Menu Items.
*
* @var array
*/
protected $menu_items = array(); protected $menu_items = array();
/**
* Get Info.
*
* @codingStandardsIgnoreEnd
*/
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'XML sitemap menu', 'name' => 'XML sitemap menu',
...@@ -17,7 +39,10 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper { ...@@ -17,7 +39,10 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
); );
} }
function setUp($modules = array()) { /**
* Setup.
*/
public function setUp($modules = array()) {
$modules[] = 'xmlsitemap_menu'; $modules[] = 'xmlsitemap_menu';
$modules[] = 'menu'; $modules[] = 'menu';
parent::setUp($modules); parent::setUp($modules);
...@@ -26,7 +51,10 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper { ...@@ -26,7 +51,10 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
$this->normal_user = $this->drupalCreateUser(array('access content')); $this->normal_user = $this->drupalCreateUser(array('access content'));
} }
function testMenuSettings() { /**
* Menu Settings.
*/
public function testMenuSettings() {
$this->drupalLogin($this->admin_user); $this->drupalLogin($this->admin_user);
$edit = array( $edit = array(
...@@ -36,7 +64,6 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper { ...@@ -36,7 +64,6 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
'xmlsitemap[priority]' => '1.0', 'xmlsitemap[priority]' => '1.0',
); );
$this->drupalPost('admin/structure/menu/add', $edit, 'Save'); $this->drupalPost('admin/structure/menu/add', $edit, 'Save');
$menu = menu_load($edit['menu_name']);
$this->clickLink('Add link'); $this->clickLink('Add link');
$edit = array( $edit = array(
...@@ -47,4 +74,5 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper { ...@@ -47,4 +74,5 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
); );
$this->drupalPost(NULL, $edit, 'Save'); $this->drupalPost(NULL, $edit, 'Save');
} }
} }
...@@ -4,5 +4,4 @@ package = XML sitemap ...@@ -4,5 +4,4 @@ package = XML sitemap
core = 7.x core = 7.x
dependencies[] = xmlsitemap dependencies[] = xmlsitemap
dependencies[] = ctools dependencies[] = ctools
files[] = xmlsitemap_modal.module
hidden = TRUE hidden = TRUE
<?php <?php
/**
* @file
* Main file for XML sitemap Modal.
*/
/** /**
* Implements hook_menu_alter(). * Implements hook_menu_alter().
*/ */
function xmlsitemap_modal_menu_alter(&$items) { function xmlsitemap_modal_menu_alter(&$items) {
foreach ($items as $path => $item) { foreach ($items as $path => $item) {
if (!empty($item['modal']) && strpos($path, '%ctools_js') === FALSE && $item['page callback'] ==='drupal_get_form') { if (!empty($item['modal']) && strpos($path, '%ctools_js') === FALSE && $item['page callback'] === 'drupal_get_form') {
$items["$path/%ctools_js"] = $item; $items["$path/%ctools_js"] = $item;
$items["$path/%ctools_js"]['page callback'] = 'xmlsitemap_modal_get_form'; $items["$path/%ctools_js"]['page callback'] = 'xmlsitemap_modal_get_form';
$items["$path/%ctools_js"]['page arguments'][] = substr_count($path, '/') + 1; $items["$path/%ctools_js"]['page arguments'][] = substr_count($path, '/') + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment