xmlsitemap_menu.install in XML sitemap 5.2
Same filename and directory in other branches
Install file for XML sitemap menu
File
xmlsitemap_menu/xmlsitemap_menu.installView source
<?php
/**
* @file
* Install file for XML sitemap menu
*/
/*****************************************************************************
* Drupal hooks.
****************************************************************************/
/**
* Implementation of hook_enable().
*/
function xmlsitemap_menu_enable() {
xmlsitemap_flag_sitemap();
}
/**
* Implementation of hook_disable().
*/
function xmlsitemap_menu_disable() {
xmlsitemap_flag_sitemap();
}
/**
* Implementation of hook_install().
*/
function xmlsitemap_menu_install() {
$mid = db_result(db_query("SELECT mid FROM {menu} WHERE pid = 0 AND title = '%s'", t('XML sitemap')));
if ($mid === FALSE) {
$mid = db_next_id('{menu}_mid');
db_query("INSERT INTO {menu} (mid, title, description, type) VALUES (%d, '%s', '%s', %d)", $mid, t('XML sitemap'), t('Menu items to include in the sitemap.'), MENU_CUSTOM_MENU | MENU_MODIFIED_BY_ADMIN);
menu_rebuild();
}
variable_set('xmlsitemap_menu_custom_menu', $mid);
}
/**
* Implementation of hook_update_N().
*/
function xmlsitemap_menu_update_1() {
$ret = array();
$mid = db_result(db_query("SELECT mid FROM {menu} WHERE pid = 0 AND title = '%s'", t('XML sitemap')));
if (($mid = db_result(db_query("SELECT mid FROM {menu} WHERE pid = 0 AND title = '%s'", t('XML sitemap')))) !== FALSE) {
$result = db_query("SELECT * FROM {xmlsitemap_additional}");
while ($link = db_fetch_object($result)) {
$link->priority = isset($link->priority) ? $link->priority : variable_get('xmlsitemap_additional_links_priority', 0.5);
$item = array(
'mid' => db_next_id('{menu}_mid'),
'pid' => $mid,
'path' => $link->path,
'title' => $link->path,
'weight' => $link->priority * 20 - 10,
'type' => MENU_CUSTOM_ITEM | MENU_MODIFIED_BY_ADMIN,
);
db_query("INSERT INTO {menu} (mid, pid, path, title, weight, type) VALUES (%d, %d, '%s', '%s', %d, %d)", $item);
}
variable_set('xmlsitemap_menu_custom_menu', $mid);
$ret[] = array(
'success' => TRUE,
'query' => 'ADD MODULE VARIABLE xmlsitemap_menu_custom_menu',
);
}
$ret[] = update_sql("DROP TABLE {xmlsitemap_additional}");
return $ret;
}
/**
* Implementation of hook_update_N().
*/
function xmlsitemap_menu_update_2() {
return xmlsitemap_menu_update_1();
}
/**
* Implementation of hook_uninstall().
*/
function xmlsitemap_menu_uninstall() {
$xid = db_result(db_query("SELECT mid FROM {menu} WHERE pid = 0 AND title = '%s'", t('XML sitemap')));
if ($xid !== FALSE) {
db_query('DELETE FROM {menu} WHERE pid = %d', $xid);
db_query('DELETE FROM {menu} WHERE mid = %d', $xid);
menu_rebuild();
}
db_query("DELETE FROM {variable} WHERE name LIKE 'xmlsitemap\\_menu\\_%'");
}
Functions
Name | Description |
---|---|
xmlsitemap_menu_disable | Implementation of hook_disable(). |
xmlsitemap_menu_enable | Implementation of hook_enable(). |
xmlsitemap_menu_install | Implementation of hook_install(). |
xmlsitemap_menu_uninstall | Implementation of hook_uninstall(). |
xmlsitemap_menu_update_1 | Implementation of hook_update_N(). |
xmlsitemap_menu_update_2 | Implementation of hook_update_N(). |