示例#1
0
 static function tag_anwloop($sMatch, $sContentClass, $asLangs, $nLimit, $sSortUser, $sOrder, $asFilters)
 {
     AnwDebug::startBench("anwloop", true);
     $oContentClass = AnwContentClasses::getContentClass($sContentClass);
     $aoPages = AnwStorage::fetchPagesByClass(array($sMatch), $oContentClass, $asLangs, $nLimit, $sSortUser, $sOrder, $asFilters);
     AnwDebug::stopBench("anwloop");
     return $aoPages;
 }
示例#2
0
 /**
  * @throws AnwUserNotFoundException
  */
 static function getUser($nUserId)
 {
     if (!isset(self::$asCachedUsers[$nUserId])) {
         self::debug("Getting an user : "******"getUser");
         try {
             self::$asCachedUsers[$nUserId] = self::getDriver()->getUser($nUserId);
         } catch (AnwUserNotFoundException $e) {
             self::$asCachedUsers[$nUserId] = -1;
             throw new AnwUserNotFoundException();
         }
         AnwDebug::stopBench("getUser");
     } else {
         if (!is_int(self::$asCachedUsers[$nUserId])) {
             self::debug("Getting an user : "******" - Already in cache");
         } else {
             self::debug("Getting an user : "******" - Already in cache / AnwUserNotFoundException");
             throw new AnwUserNotFoundException();
         }
     }
     return self::$asCachedUsers[$nUserId];
 }
示例#3
0
 function query($sQuery)
 {
     AnwDebug::startBench("mysql query", true);
     //add tables prefix
     $sQuery = str_replace("#PFX#", $this->sPrefix, $sQuery);
     if ($this->nTransactionDeep == 0) {
         $this->debug("query : " . htmlentities($sQuery));
     } else {
         $this->debug("[TRANSACTION " . $this->nTransactionDeep . "] query : " . htmlentities($sQuery));
     }
     //$this->oLastRessource = @mysql_query($sQuery, $this->oLink);
     $oRessource = @mysql_query($sQuery, $this->oLink);
     AnwDebug::stopBench("mysql query");
     if ($oRessource == false && mysql_error($this->oLink) != "") {
         throw new AnwUnexpectedException("A database query failed - Query: " . $sQuery . " : " . mysql_error($this->oLink));
     }
     return $oRessource;
 }
示例#4
0
anwdefine('ANWDIR_CSS', 'css/');
anwdefine('ANWDIR_IMG', 'img/');
anwdefine('ANWDIR_JS', 'js/');
anwdefine('ANWDIR_DRIVERS', 'drivers/');
anwdefine('ANWDIR_ACLSDRIVERS', ANWDIR_DRIVERS . 'aclsdrivers/');
anwdefine('ANWDIR_SESSIONSDRIVERS', ANWDIR_DRIVERS . 'sessionsdrivers/');
anwdefine('ANWDIR_STORAGEDRIVERS', ANWDIR_DRIVERS . 'storagedrivers/');
anwdefine('ANWDIR_USERSDRIVERS', ANWDIR_DRIVERS . 'usersdrivers/');
anwdefine('ANWIKI_WEBSITE', 'http://www.anwiki.com/');
anwdefine('ANWIKI_WEBPING', 'http://ping.anwiki.com/');
anwdefine('ANWIKI_INSTALL_LOCK', ANWPATH_STATUS . 'install.lock.php');
anwdefine('ANWIKI_INSTALL_STATUS', ANWPATH_STATUS . 'install.status.php');
spl_autoload_register('anwiki__autoload');
loadAppSafe(ANWPATH_CLASSES . "class_debug.php");
AnwDebug::startBench("GLOBAL", true);
AnwDebug::startBench("loading files", true);
loadAppSafe(ANWPATH_CLASSES . "class_env.php");
loadAppSafe(ANWPATH_CLASSES . "class_utils.php");
loadAppSafe(ANWPATH_CLASSES . "class_exception.php");
loadApp(ANWPATH_CLASSES . "class_cache.php");
loadApp(ANWPATH_CLASSES . "class_component.php");
loadApp(ANWPATH_CLASSES . "class_i18n.php");
loadApp(ANWPATH_CLASSES . "_drivers.php");
loadApp(ANWPATH_CLASSES . "class_acls.php");
loadApp(ANWPATH_CLASSES . "plugin/class_plugin.php");
loadApp(ANWPATH_CLASSES . "plugin/class_plugins.php");
loadApp(ANWPATH_CLASSES . "session/class_session.php");
loadApp(ANWPATH_CLASSES . "session/class_sessions.php");
loadApp(ANWPATH_CLASSES . "class_storage.php");
loadApp(ANWPATH_CLASSES . "user/class_user.php");
loadApp(ANWPATH_CLASSES . "user/class_users.php");
示例#5
0
 private function xmlDiff($node1, $node2, $bFindMovedEdited)
 {
     $aoDiffs = self::xmlDiffBasic($node1, $node2);
     if ($bFindMovedEdited) {
         /*print "************1. BEFORE MOVED**************".'<ul style="font-size:12px; font-family:verdana">';
         		foreach ($aoDiffs as $oDiff){
         			print $oDiff->debugHtml();
         		}
         		print '</ul>';*/
         //must wait to have the whole diffs tree to search for moved nodes
         AnwDebug::startBench("findMovedNodes", true);
         $aoDiffs = self::findMovedNodes($aoDiffs);
         //find moved nodes
         AnwDebug::stopBench("findMovedNodes");
         /*print "************2. BEFORE EDITED**************".'<ul style="font-size:12px; font-family:verdana">';
         		foreach ($aoDiffs as $oDiff){
         			print $oDiff->debugHtml();
         		}
         		print '</ul>';*/
         AnwDebug::startBench("findEditedNodes", true);
         $aoDiffs = self::findEditedNodes($aoDiffs);
         //now find edited nodes
         AnwDebug::stopBench("findEditedNodes");
         /*print "************3. AFTER EDITED**************".'<ul style="font-size:12px; font-family:verdana">';
         		foreach ($aoDiffs as $oDiff){
         			print $oDiff->debugHtml();
         		}
         		print '</ul>';*/
     }
     return $aoDiffs;
 }
示例#6
0
 function isValidContent($sContent)
 {
     if (trim($sContent) == "" || strstr($sContent, '<translate><translate>')) {
         return false;
     }
     AnwDebug::startBench("isValidContent");
     //prepare for validation test
     try {
         AnwXml::xmlIsValid($sContentTmp);
         $bTest = true;
     } catch (AnwUnexpectedException $e) {
         $bTest = false;
     }
     if ($this->bExists) {
         try {
             $this->getPageGroup()->getContentClass()->testContent($sContent);
         } catch (AnwInvalidContentException $e) {
             $bTest = false;
         }
     }
     AnwDebug::stopBench("isValidContent");
     return $bTest;
 }
示例#7
0
 private static function applyDiffs($oDiffs, $oContentXml, $oContentField)
 {
     AnwDebug::startBench("applyDiffs");
     //calculate diffs if not already done
     AnwDebug::log("#####applyDiffs() : step 1/3 - calc diffs#####");
     AnwDebug::startBench("applyDiffs-1", true);
     $oDiffs->getAllDiffs();
     AnwDebug::stopBench("applyDiffs-1");
     //associate deleted values to moved nodes
     AnwDebug::log("#####applyDiffs() : step 2/3 - prepare#####");
     AnwDebug::startBench("applyDiffs-2", true);
     self::prepareDiffsToTranslation($oDiffs, $oContentXml);
     //update oDiffs
     AnwDebug::stopBench("applyDiffs-2");
     //print $oDiffs->debugHtml();
     //apply diffs
     AnwDebug::log("#####applyDiffs() : step 3/3 - apply#####");
     AnwDebug::startBench("applyDiffs-3", true);
     $oContentXml = self::applyDiffsToTranslation($oContentXml, $oDiffs, $oContentField);
     AnwDebug::stopBench("applyDiffs-3");
     //AnwDebug::logdetail("! applyDiffs result : ".htmlentities(AnwUtils::xmlDumpNode($oContentXml)));
     AnwDebug::stopBench("applyDiffs");
     return $oContentXml;
 }