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
core = 7.x
dependencies[] = xmlsitemap
dependencies[] = menu
files[] = xmlsitemap_menu.module
files[] = xmlsitemap_menu.install
files[] = xmlsitemap_menu.test
<?php
/**
* @file
* Main file for XML sitemap menu.
*/
/**
* Implements hook_entity_info_alter().
*
......@@ -90,7 +95,7 @@ function xmlsitemap_menu_xmlsitemap_index_links($limit) {
/**
* Process menu sitemap links.
*
* @param $mlids
* @param array $mlids
* An array of menu link IDs.
*/
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) {
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';
//}
//
//function xmlsitemap_menu_menu_overview_form_submit($form, $form_state) {
// $mlids = array();
// foreach (element_children($form) as $mlid) {
// if (isset($form[$mlid]['#item'])) {
// $mlids[] = $form[$mlid]['#item']['mlid'];
// }
// }
// xmlsitemap_menu_xmlsitemap_process_menu_links($mlids);
//}
/**
* Example functions.
*
* Function xmlsitemap_menu_form_menu_overview_form_alter(&$form, $form_state) {
* $form['#submit'][] = 'xmlsitemap_menu_menu_overview_form_submit';
* }
*
* Function xmlsitemap_menu_menu_overview_form_submit($form, $form_state) {
* $mlids = array();
* foreach (element_children($form) as $mlid) {
* if (isset($form[$mlid]['#item'])) {
* $mlids[] = $form[$mlid]['#item']['mlid'];
* }
* }
* xmlsitemap_menu_xmlsitemap_process_menu_links($mlids);
* }
*/
/**
* Implements hook_form_FORM_ID_alter().
......@@ -205,8 +214,9 @@ function xmlsitemap_menu_menu_link_insert(array $link) {
* @see hook_menu_link_alter()
*/
function xmlsitemap_menu_menu_link_update(array $link) {
//$link += array('xmlsitemap' => array());
//xmlsitemap_menu_xmlsitemap_process_menu_links(array($link['mlid']), $link['xmlsitemap']);
// $link += array('xmlsitemap' => array());
// @codingStandardsIgnoreLine
// xmlsitemap_menu_xmlsitemap_process_menu_links(array($link['mlid']), $link['xmlsitemap']);.
}
/**
......@@ -235,7 +245,7 @@ function xmlsitemap_menu_menu_link_delete(array $link) {
/**
* Create a sitemap link from a menu item.
*
* @param $menu_item
* @param array $menu_item
* A loaded menu item.
*/
function xmlsitemap_menu_create_link(array $menu_item) {
......
......@@ -2,13 +2,35 @@
/**
* @file
* Unit tests for the xmlsitemap_menu module.
* Unit tests for the xmlsitemap_menu project..
*/
/**
* Menu Functional Test.
*/
class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
/**
* Normal User.
*
* @var string
*
* @codingStandardsIgnoreStart
*/
protected $normal_user;
/**
* Menu Items.
*
* @var array
*/
protected $menu_items = array();
/**
* Get Info.
*
* @codingStandardsIgnoreEnd
*/
public static function getInfo() {
return array(
'name' => 'XML sitemap menu',
......@@ -17,7 +39,10 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
);
}
function setUp($modules = array()) {
/**
* Setup.
*/
public function setUp($modules = array()) {
$modules[] = 'xmlsitemap_menu';
$modules[] = 'menu';
parent::setUp($modules);
......@@ -26,7 +51,10 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
$this->normal_user = $this->drupalCreateUser(array('access content'));
}
function testMenuSettings() {
/**
* Menu Settings.
*/
public function testMenuSettings() {
$this->drupalLogin($this->admin_user);
$edit = array(
......@@ -36,7 +64,6 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
'xmlsitemap[priority]' => '1.0',
);
$this->drupalPost('admin/structure/menu/add', $edit, 'Save');
$menu = menu_load($edit['menu_name']);
$this->clickLink('Add link');
$edit = array(
......@@ -47,4 +74,5 @@ class XMLSitemapMenuFunctionalTest extends XMLSitemapTestHelper {
);
$this->drupalPost(NULL, $edit, 'Save');
}
}
......@@ -4,5 +4,4 @@ package = XML sitemap
core = 7.x
dependencies[] = xmlsitemap
dependencies[] = ctools
files[] = xmlsitemap_modal.module
hidden = TRUE
<?php
/**
* @file
* Main file for XML sitemap Modal.
*/
/**
* Implements hook_menu_alter().
*/
function xmlsitemap_modal_menu_alter(&$items) {
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"]['page callback'] = 'xmlsitemap_modal_get_form';
$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