コード例 #1
0
	/**
	* Returns an array of Id's for all pages
	*
	* @return array Array of page Id's
	*/
	private function getPageIds()
	{
		$nested = new ISC_NESTEDSET_PAGES();
		$pages = $nested->getTree(
			array('pageid')
		);
		$pageIds = array();
		foreach ($pages as $page) {
			$pageIds[] = $page['pageid'];
		}

		return $pageIds;
	}
コード例 #2
0
ファイル: class.pages.php プロジェクト: hungnv0789/vhtm
		private function EditPageStep2()
		{
			// Get the information from the form and add it to the database
			$pageId = (int)$_POST['pageId'];
			$arrData = array();
			$err = "";

			$existingPage = array();
			$this->_GetPageData($pageId, $existingPage);

			// Does this user have permission to edit this product?
			if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $existingPage['pagevendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
				FlashMessage(GetLang('Unauthorized'), MSG_ERROR, 'index.php?ToDo=viewPages');
			}

			$this->_GetPageData(0, $arrData);
			$arrData['pageid'] = $pageId;

			$currentTab = '0';
			if(isset($_POST['currentTab']) && $_POST['currentTab'] != ''){
				$currentTab = '&currentTab='.$_POST['currentTab'];
			}
			if(isset($_POST['addAnother']) || isset($_POST['addAnother2'])) {
				$url = 'index.php?ToDo=editPage&pageId='.$pageId.$currentTab;
			}
			else {
				$url = 'index.php?ToDo=viewPages';
			}

			if($this->_IsDuplicateTitle($arrData['pagetitle'], $pageId, $arrData['pagevendorid'])) {
				$this->EditPageStep1(GetLang('DuplicatePageTitle'), MSG_ERROR, true);
				die();
			}

			// Get a formatted list of all of the pages in the system
			$nested = new ISC_NESTEDSET_PAGES();
			$pages = $nested->getTree(
				array('pageid', 'pagetitle', 'pagevendorid'),
				$pageId,
				ISC_NESTEDSET_DEPTH_ALL,
				null,
				null,
				true,
				array('pagevendorid = ' . $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId())
			);

			$childList = array();
			foreach ($pages as $page) {
				if ($page['pageid'] != $pageId) {
					$childList[] = $page['pageid'];
				}
			}

			// don't let the current page assign itself or any decendants as it's parent page
			if($pageId == $arrData['pageparentid'] || in_array($arrData['pageparentid'], $childList)) {
				$this->EditPageStep1(GetLang('InvalidParentPage'), MSG_ERROR, true);
				die();
			}

			//Validate Google Website Optimizer form
			if(isset($arrData['page_enable_optimizer']) && $arrData['page_enable_optimizer']==1) {
				$optimizer = getClass('ISC_ADMIN_OPTIMIZER');
				$error = $optimizer->validateConfigForm();
				if($error!='') {
					$this->EditPageStep1($error, MSG_ERROR, true);
				}
			}

			// Commit the values to the database
			if ($this->_CommitPage($pageId, $arrData, $err)) {

				if($existingPage['pageparentid'] != $arrData['pageparentid']) {
					// Rebuild the parent list
					$parentList = $this->_BuildPageParentList($pageId);

					$updatedPage = array(
						"pageparentlist" => $parentList
					);
					$GLOBALS['ISC_CLASS_DB']->UpdateQuery("pages", $updatedPage, "pageid='".$GLOBALS['ISC_CLASS_DB']->Quote((int)$pageId)."'");

					// Now we also need to update the parent list of all child pages for this page
					$query = sprintf("SELECT pageid FROM [|PREFIX|]pages WHERE CONCAT(',', pageparentlist, ',') LIKE '%%,%s,%%'", $pageId);
					$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
					while($child = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
						$parentList = $this->_BuildPageParentList($child['pageid']);
						// Update the parent list for this child
						$updatedPage = array(
							"pageparentlist" => $parentList
						);
						$GLOBALS['ISC_CLASS_DB']->UpdateQuery("pages", $updatedPage, "pageid='".$GLOBALS['ISC_CLASS_DB']->Quote($child['pageid'])."'");
					}
				}

				// Log this action
				$GLOBALS['ISC_CLASS_LOG']->LogAdminAction($pageId, $arrData['pagetitle']);
				FlashMessage(GetLang('PageUpdatedSuccessfully'), MSG_SUCCESS, $url);
			} else {
				FlashMessage(sprintf(GetLang('ErrPageNotUpdated'), $err), MSG_ERROR, $url);
			}
		}