Go to the documentation of this file.00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 {
00004 header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005 echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006 echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007 exit(1);
00008 }
00015 class sitemap implements module {
00016
00017 public function getHtml($userId, $moduleComponentId, $action) {
00018 $this->userId = $userId;
00019 $this->moduleComponentId = $moduleComponentId;
00020 $this->action = $action;
00021
00022 if($action == "view")
00023 return $this->actionView();
00024 }
00025
00026 public function actionView() {
00027 return $this->generateTree(0, $this->userId, 0, 'view');
00028 }
00029 public function actionCreate() {}
00030
00031 function generateTree($pageId, $userId, $permId, $action = '') {
00032 global $cmsFolder, $urlRequestRoot, $templateFolder;
00033 $imagesFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/images";
00034 $scriptsFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/scripts";
00035
00036 $treeData= '(Click on the folder icon to expand the sitemap)<br ><br ><div id="directorybrowser"><ul class="treeview" id="sitemap">' .
00037 '<script type="text/javascript" language="javascript" src="'.$scriptsFolder.'/treemenu.js"></script>';
00038
00039 if($action != '') {
00040 $treeData .= $this->getNodeHtml($pageId, $userId, '', $action, $urlRequestRoot . '/');
00041 }
00042 else {
00043 $permQuery = 'SELECT `page_module`, `perm_action` FROM `' . MYSQL_DATABASE_PREFIX . 'permissionlist` WHERE `perm_id` = ' . $permId;
00044 $permResult = mysql_query($permQuery);
00045 $permRow = mysql_fetch_row($permResult);
00046 $module = $permRow[0];
00047 $action = $permRow[1];
00048 $treeData .= $this->getNodeHtml($pageId, $userId, $module, $action, $urlRequestRoot . '/');
00049 }
00050 $treeData .= '</ul></div>';
00051
00052 $treeData .= <<<TREEDATA
00053 <script type="text/javascript" language="javascript">
00054 <!--
00055
00056
00057
00058
00059
00060
00061
00062
00063 ddtreemenu = new JSTreeMenu('sitemap', '', '$imagesFolder', false);
00064 -->
00065 </script>
00066
00067 TREEDATA;
00068
00069 return $treeData;
00070 }
00071
00072 function getNodeHtml($pageId, $userId, $module, $action, $parentPath) {
00073 $htmlOut = '';
00074 if(getPermissions($userId, $pageId, $action, $module)) {
00075 $pageInfo = getPageInfo($pageId);
00076 $pagePath = $parentPath;
00077 if($pageInfo['page_name'] != '')
00078 $pagePath .= $pageInfo['page_name'] . '/';
00079
00080 $htmlOut .= "<li><a href=\"$pagePath\">" . getPageTitle($pageId) . "</a>\n";
00081
00082 $childrenQuery = 'SELECT `page_id` FROM `' . MYSQL_DATABASE_PREFIX . 'pages` WHERE `page_parentid` <> `page_id` AND `page_parentid` = ' . $pageId . ' AND `page_displayinsitemap` = 1';
00083 $childrenResult = mysql_query($childrenQuery);
00084
00085 $childrenHtml = '';
00086 while($childrenRow = mysql_fetch_row($childrenResult)) {
00087 $childrenHtml .= $this->getNodeHtml($childrenRow[0], $userId, $module, $action, $pagePath);
00088 }
00089 if($childrenHtml != '') {
00090 $htmlOut .= "<ul>$childrenHtml</ul>\n";
00091 }
00092
00093 $htmlOut .= "</li>\n";
00094 }
00095 return $htmlOut;
00096 }
00097
00098
00099 public function createModule(&$moduleComponentId) {
00100 $idQuery = 'SELECT MAX(`page_modulecomponentid`) FROM `' . MYSQL_DATABASE_PREFIX . 'pages` WHERE `page_module` = \'sitemap\'';
00101 $idResult = mysql_query($idQuery);
00102 $idRow = mysql_fetch_row($idResult);
00103 $moduleComponentId = 1;
00104 if($idRow && !is_null($idRow[0])) {
00105 $moduleComponentId = $idRow[0] + 1;
00106 }
00107 return true;
00108 }
00109 public function deleteModule($moduleComponentId) {}
00110 public function copyModule($moduleComponentId) {}
00111 }
00112