|
From: Verdon V. <ve...@us...> - 2008-07-16 19:07:35
|
Update of /cvsroot/phpwebsite-comm/modules/sitemap/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32471/class Modified Files: SM_Forms.php Sitemap.php Log Message: 0.6.0 updates Index: Sitemap.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/sitemap/class/Sitemap.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Sitemap.php 7 Jul 2008 21:01:35 -0000 1.3 --- Sitemap.php 16 Jul 2008 19:07:11 -0000 1.4 *************** *** 183,190 **** PHPWS_Settings::set('sitemap', 'addkeys', 0); ! isset($_POST['include_fc']) ? ! PHPWS_Settings::set('sitemap', 'include_fc', 1) : ! PHPWS_Settings::set('sitemap', 'include_fc', 0); ! $cache_timeout = (int)$_POST['cache_timeout']; if ((int)$cache_timeout <= 7200) { --- 183,190 ---- PHPWS_Settings::set('sitemap', 'addkeys', 0); ! if (isset($_POST['exclude_keys'])) { ! PHPWS_Settings::set('sitemap', 'exclude_keys', $_POST['exclude_keys']); ! } ! $cache_timeout = (int)$_POST['cache_timeout']; if ((int)$cache_timeout <= 7200) { *************** *** 270,273 **** --- 270,322 ---- + function getKeyMods($match=null, $select_name='keys', $multiple=true, $count=true) + { + + PHPWS_Core::initCoreClass('Key.php'); + $db = new PHPWS_DB('phpws_key'); + $db->addOrder('module asc'); + + $result = $db->getObjects('Key'); + + if ($result) { + foreach ($result as $item) { + if ($count) { + $db = new PHPWS_DB('phpws_key'); + $db->addWhere('module', $item->module); + $qty = $db->count(); + if ($qty == 1) { + $qty_label = dgettext('sitemap', 'item'); + } else { + $qty_label = dgettext('sitemap', 'items'); + } + $items[$item->module] = $item->module . ' ('.$qty.' '.$qty_label.')'; + } else { + $items[$item->module] = $item->module; + } + } + } + + if ($items) { + if ($multiple) { + $form = new PHPWS_Form; + $form->addMultiple($select_name, $items); + if (!empty($match) && is_array($match)) { + $form->setMatch($select_name, $match); + } + return $form->get($select_name); + } else { + $form = new PHPWS_Form; + $form->addSelect($select_name, $items); + if (!empty($match) && is_string($match)) { + $form->setMatch($select_name, $match); + } + return $form->get($select_name); + } + } else { + return dgettext('sitemap', 'No keyed items.'); + } + + } + function mapIt() { *************** *** 276,279 **** --- 325,331 ---- $menus = $this->getMenuIds(); + /* the default exclude_keys list */ + $exclude_keys = unserialize(PHPWS_Settings::get('sitemap', 'exclude_keys')); + /* what to do about lastmod, nothing except for keyed items */ $lastmod = null; *************** *** 289,293 **** } ! $content = $this->buildXML($menus, $lastmod, PHPWS_Settings::get('sitemap', 'addkeys')); if (PHPWS_Settings::get('sitemap', 'cache_timeout') > 0) { PHPWS_Cache::save($cache_key, $content); --- 341,345 ---- } ! $content = $this->buildXML($menus, $exclude_keys, $lastmod, PHPWS_Settings::get('sitemap', 'addkeys')); if (PHPWS_Settings::get('sitemap', 'cache_timeout') > 0) { PHPWS_Cache::save($cache_key, $content); *************** *** 316,320 **** $addkeys = null; } ! $content = $this->buildXML($menus, $lastmod, $addkeys); if ($_REQUEST['build_type']) { /* save to server */ --- 368,377 ---- $addkeys = null; } ! if (isset($_REQUEST['exclude_keys'])) { ! $exclude_keys = $_REQUEST['exclude_keys']; ! } else { ! $exclude_keys = null; ! } ! $content = $this->buildXML($menus, $exclude_keys, $lastmod, $addkeys); if ($_REQUEST['build_type']) { /* save to server */ *************** *** 334,338 **** } ! function buildXML($menus, $lastmod=null, $addkeys=null) { $menuitems = array(); --- 391,395 ---- } ! function buildXML($menus, $exclude_keys=null, $lastmod=null, $addkeys=null) { $menuitems = array(); *************** *** 348,352 **** /* get other keyed items */ if ($addkeys) { ! $otheritems = $this->getOtherItems(); // print_r($otheritems); //exit; /* compare the arrays for dupes and return the cleaned array */ --- 405,409 ---- /* get other keyed items */ if ($addkeys) { ! $otheritems = $this->getOtherItems($exclude_keys); // print_r($otheritems); //exit; /* compare the arrays for dupes and return the cleaned array */ *************** *** 466,470 **** if (PHPWS_Settings::get('sitemap', 'local_only')) { if (!$link['local']) { - // $link = null; $tidy = null; } --- 523,526 ---- *************** *** 474,482 **** if (PHPWS_Settings::get('sitemap', 'respect_privs')) { if ($link['key_id'] && !$link['active']) { - // $link = null; $tidy = null; } if ($link['key_id'] && $link['restricted']) { - // $link = null; $tidy = null; } --- 530,536 ---- *************** *** 512,523 **** ! function getOtherItems() { $final = null; $db = new PHPWS_DB('phpws_key'); ! if (!PHPWS_Settings::get('sitemap', 'include_fc')) { ! $db->addWhere('module', 'filecabinet', '!='); } $db->addOrder('id'); $db->setIndexBy('id'); --- 566,580 ---- ! function getOtherItems($exclude_keys=null) { $final = null; $db = new PHPWS_DB('phpws_key'); ! if ($exclude_keys) { ! foreach ($exclude_keys as $module) { ! $db->addWhere('module', $module, '!='); ! } } + $db->addOrder('id'); $db->setIndexBy('id'); *************** *** 552,556 **** if (PHPWS_Settings::get('sitemap', 'local_only')) { if (!$link['local']) { - // $link = null; $tidy = null; } --- 609,612 ---- *************** *** 560,568 **** if (PHPWS_Settings::get('sitemap', 'respect_privs')) { if (!$link['active']) { - // $link = null; $tidy = null; } if ($link['restricted']) { - // $link = null; $tidy = null; } --- 616,622 ---- *************** *** 622,624 **** } ! ?> --- 676,678 ---- } ! ?> \ No newline at end of file Index: SM_Forms.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/sitemap/class/SM_Forms.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SM_Forms.php 7 Jul 2008 21:01:35 -0000 1.3 --- SM_Forms.php 16 Jul 2008 19:07:11 -0000 1.4 *************** *** 66,69 **** --- 66,74 ---- $mMatch = null; } + if ($_REQUEST['exclude_keys']) { + $kMatch = $_REQUEST['exclude_keys']; + } else { + $kMatch = unserialize(PHPWS_Settings::get('sitemap', 'exclude_keys')); + } if ($_REQUEST['lastmod_default']) { $dMatch = $_REQUEST['lastmod_default']; *************** *** 74,78 **** $form->addCheckbox('addkeys', 1); $form->setMatch('addkeys', PHPWS_Settings::get('sitemap', 'addkeys')); ! $form->setLabel('addkeys', dgettext('sitemap', 'Include keyed items not in menus in your sitemap')); $form->addRadio('build_type', array(0, 1)); --- 79,83 ---- $form->addCheckbox('addkeys', 1); $form->setMatch('addkeys', PHPWS_Settings::get('sitemap', 'addkeys')); ! $form->setLabel('addkeys', dgettext('sitemap', 'Include keyed module items not in menus in your sitemap')); $form->addRadio('build_type', array(0, 1)); *************** *** 90,93 **** --- 95,100 ---- $tpl['MENU_SELECT'] = $this->sitemap->getMenus($mMatch, 'menus'); $tpl['MENU_SELECT_LABEL'] = dgettext('sitemap', 'Select one or more menus to include in your sitemap.'); + $tpl['KEY_SELECT'] = $this->sitemap->getKeyMods($kMatch, 'exclude_keys'); + $tpl['KEY_SELECT_LABEL'] = dgettext('sitemap', 'Select any modules you wish to exclude from your sitemap.'); $this->sitemap->title = dgettext('sitemap', 'Create sitemap file'); *************** *** 136,143 **** $form->setLabel('addkeys', dgettext('sitemap', 'Include keyed items not in menus in your sitemap')); - $form->addCheckbox('include_fc', 1); - $form->setMatch('include_fc', PHPWS_Settings::get('sitemap', 'include_fc')); - $form->setLabel('include_fc', dgettext('sitemap', 'Include file cabinet items within keyed items')); - $form->addText('cache_timeout', PHPWS_Settings::get('sitemap', 'cache_timeout')); $form->setSize('cache_timeout', 4, 4); --- 143,146 ---- *************** *** 148,151 **** --- 151,156 ---- $tpl = $form->getTemplate(); $tpl['SETTINGS_LABEL'] = dgettext('sitemap', 'General Settings'); + $tpl['KEY_SELECT'] = $this->sitemap->getKeyMods(unserialize(PHPWS_Settings::get('sitemap', 'exclude_keys')), 'exclude_keys'); + $tpl['KEY_SELECT_LABEL'] = dgettext('sitemap', 'Select any modules you wish to exclude by default from your sitemap.'); $tpl['FOOTNOTE_1'] = sprintf(dgettext('sitemap', '* More information on the Sitemap protocal is available %s'), '<a href="http://www.sitemaps.org/protocol.php" target="new">'. dgettext('sitemap', 'here') .'</a>'); $tpl['FOOTNOTE_2'] = dgettext('sitemap', '** I do a rough calculation to achieve this. Everything starts as the average 0.5. I add 0.5 to top-level itmes. I then subtract 0.1 for each step down the menu order. Nothing is scored above 1.0 or below 0.1.'); *************** *** 162,168 **** $tpl['TITLE'] = dgettext('sitemap', 'Important Information'); $tpl['INFO_1_LABEL'] = dgettext('sitemap', 'About this module:'); ! $tpl['INFO_1'] = dgettext('sitemap', 'This is the first release of sitemap for the new 1.x series phpwebsite. I wrote this for a specific need I had and thought it may be of use to others also.'); $tpl['INFO_2_LABEL'] = dgettext('sitemap', 'What it does:'); ! $tpl['INFO_2'] = sprintf(dgettext('sitemap', 'Sitemap is used to generate a sitmap.xml file, following the standards at %s. These sitemap files are used by google and other popular search engines to help them index your website. Sitemap does this by gathering all the links from one or more of your menus, filtering and preparing according to your settings, and then writing the xml for you.'), '<a href="http://www.sitemaps.org/protocol.php" target="new">sitemaps.org</a>'); $tpl['INFO_3_LABEL'] = dgettext('sitemap', 'How to use it:'); if (MOD_REWRITE_ENABLED) { --- 167,173 ---- $tpl['TITLE'] = dgettext('sitemap', 'Important Information'); $tpl['INFO_1_LABEL'] = dgettext('sitemap', 'About this module:'); ! $tpl['INFO_1'] = dgettext('sitemap', 'This is the third release of sitemap for the new 1.x series phpwebsite. I wrote this for a specific need I had and thought it may be of use to others also.'); $tpl['INFO_2_LABEL'] = dgettext('sitemap', 'What it does:'); ! $tpl['INFO_2'] = sprintf(dgettext('sitemap', 'Sitemap is used to generate a sitmap.xml file, following the standards at %s. These sitemap files are used by google and other popular search engines to help them index your website. Sitemap does this by gathering all the links from one or more of your menus, as well as other keyed module items (such as blog posts) that may not be in a menu, filtering and preparing according to your settings, and then writing the xml for you.'), '<a href="http://www.sitemaps.org/protocol.php" target="new">sitemaps.org</a>'); $tpl['INFO_3_LABEL'] = dgettext('sitemap', 'How to use it:'); if (MOD_REWRITE_ENABLED) { |