gyro/modules/gsitemap/start.inc.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * @defgroup GSitemap 00004 * @ingroup Modules 00005 * 00006 * Creates XML sitemaps for search engines 00007 * 00008 * You can add content to the sitemap by catching the events "gsitemap_site" and "gsitemap_index" 00009 * 00010 * When building the index, the event gsitemap_index is fired. You may add new sites to the index 00011 * by just adding them to the result array. A sitemap site is defined by a unique name and you are 00012 * responsible for processing request to this site later on. You should also take care the sites 00013 * don't get to large. 00014 * 00015 * For example you may decide to create a page for your photos. A possible names may be "photos". 00016 * 00017 * When a sitemap site gets invoked, the content, that is a list of urls, must be build. Catch 00018 * the event "gsitemap_site" to do this. Here you must 00019 * 00020 * - check if a specific site is invoked by checking the event $params 00021 * - Add URLs to the result in form of an associative array with two parameters: 'url' and 'lastmod', 00022 * which is the last mdification date as PHP timestamp. 'lastmod' is optional. 00023 * 00024 * For the photo example the code may look like this: 00025 * 00026 * @code 00027 * public function on_event($name, $params, &$result) { 00028 * switch ($name) { 00029 * case 'gsitemap_index': 00030 * $result[] = 'photos'; 00031 * break; 00032 * case 'gsitemap_site': 00033 * if ($params == 'photos') { 00034 * foreach (get_photo_urls() as $url) { 00035 * $result[] = array('url' => $url); 00036 * } 00037 * } 00038 * break; 00039 * } 00040 * } 00041 * @endcode 00042 * 00043 * In case you want all detail pages of a given model to be part of the sitemap, there are 00044 * two convenience functions to create index and sites, respecting a maxium of items per site. 00045 * 00046 * @attention The functions assume there is an action "view" defined for the given model. 00047 * 00048 * @code 00049 * public function on_event($name, $params, &$result) { 00050 * switch ($name) { 00051 * case 'gsitemap_index': 00052 * $result = array_merge($result, GsitemapController::build_sitemap_index('photos')); 00053 * break; 00054 * case 'gsitemap_site': 00055 * $result = array_merge( 00056 * $result, 00057 * GsitemapController::build_sitemap('photos', $params, GsitemapController::ITEMS_PER_FILE, GsitemapController::NO_TIMESTAMP) 00058 * ); 00059 * break; 00060 * } 00061 * } 00062 * @endcode 00063 * 00064 * This can be even more simplified by adding your model on the gsitemap_models event. 00065 * 00066 * @attention The module assume there is an action "view" defined for the given model. 00067 * 00068 * @code 00069 * public function on_event($name, $params, &$result) { 00070 * switch ($name) { 00071 * case 'gsitemap_models': 00072 * $result[] = 'photos'; 00073 * break; 00074 * } 00075 * } 00076 * @endcode 00077 * 00078 * Instead of passing a string, you may also pass an IDataObject: 00079 * 00080 * @code 00081 * public function on_event($name, $params, &$result) { 00082 * switch ($name) { 00083 * case 'gsitemap_models': 00084 * $adapter = new DAOPhotos(); 00085 * $adapter->status = Stati::ACTIVE; 00086 * $result[] = $adapter; 00087 * break; 00088 * } 00089 * } 00090 * @endcode 00091 */ 00092 00093 /** 00094 * GSitemap config options 00095 * 00096 * @author Gerd Riesselmann 00097 * @ingroup GSitemap 00098 */ 00099 class ConfigGSitemap { 00100 /** 00101 * Generate HTML sitemaps, too 00102 */ 00103 const GSITEMAP_HTML_SITEMAP = 'GSITEMAP_HTML_SITEMAP'; 00104 } 00105 00106 Config::set_feature_from_constant(ConfigGSitemap::GSITEMAP_HTML_SITEMAP, 'APP_GSITEMAP_HTML_SITEMAP', false); 00107