Exemple #1
0
 	/**
 	 * Used to create a directory tree of the sitepages in a page
 	 * Recursive function. 
 	 * (copied from sitepage_selector by FK)
 	 * Create a global variable $isFolder if you are moving folders, because there are special rules then.
 	 * @param array array with name-value pairs of the folders
 	 * @param string prefix, which to write in front of all foldernames. Leave blank, is internally used.
 	 * @param integer node where to start indexing
 	 */
 	function createSitepageTree(&$folder, $prefix, $node) {
 		global $db, $c, $oid;
	 	$isFolder = true;
 		$sql = "SELECT MENU_ID, SPM_ID, NAME from sitemap WHERE DELETED = 0 AND PARENT_ID=$node ORDER BY POSITION ASC";
 		$query = new query($db, $sql);
 		while ($query->getrow()) {
 			$name = $query->field("NAME");
 			$id = $query->field("MENU_ID");
 			$spm = $query->field("SPM_ID");
 			$sql = "SELECT SPMTYPE_ID FROM sitepage_master WHERE SPM_ID = $spm";
 			$tquery = new query($db, $sql);
 			$tquery->getrow();
 			$spmType = $tquery->field("SPMTYPE_ID");
 			$tquery->free();
 			
 			$nprefix = $prefix." ".$name." >";
 			
 			$sql = "SELECT SPID FROM sitepage WHERE MENU_ID = $id ORDER BY POSITION";
 			$subquery = new query($db, $sql);
 			while ($subquery->getrow()) {
	 			$nextId = count($folder);
	 			$spid = $subquery->field("SPID");
	 			if ($spmType == 1) {
	 				$folder[$nextId][0] = $nprefix;
 					$folder[$nextId][1] = $spid;
				} else {
					if ($spid != "") {
						$sql = "SELECT NAME FROM sitepage_names WHERE SPID = $spid AND VARIATION_ID = ".$c["stdvariation"];
						$nquery = new query($db, $sql);
						$nquery->getrow();
						$myname = $nquery->field("NAME");
						$nquery->free();
						if ($myname != "") {
							$folder[$nextId][0] = $nprefix.$myname;
 							$folder[$nextId][1] = $spid;
 						}
 					}
				}	
 			} 
 			$folder = createSitepageTree($folder, $nprefix, $id);
  		}
 		$query->free();
 		
 		return $folder;
 	
 	}	
	 *	GNU General Public License for more details.
	 *
	 *	You should have received a copy of the GNU General Public License
	 *	along with N/X; if not, write to the Free Software
	 *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
	 **********************************************************************/

	require_once("../../config.inc.php");
	
	$auth = new auth("ANY");
	$disableMenu = true;
	$sitepages = null;
	$sitepages[0][0]=">";
	$sitepages[0][1]=0;

	$sitepages = createSitepageTree($sitepages, ">", 0);
	
	for ($i=0; $i<count($sitepages); $i++) {
		$spid = $sitepages[$i][1];
		
		$spm = getDBCell("sitepage", "SPM_ID", "SPID = ".$spid);
		if ($spm != "") {
			$template = getDBCell("sitepage_master", "TEMPLATE_PATH", "SPM_ID = ".$spm);
			$sitepages[$i][1] = $c["devdocroot"].$template."?page=".$spid;
		}
	}
	
	$go = 1;
	$page_action = "UPDATE";
	
	$page = new page("Internal Link Selector");