Exemple #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;
 }
Exemple #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];
 }
Exemple #3
0
 protected function printOutput()
 {
     header("Content-type: text/html; charset=UTF-8");
     /*AnwDebug::startbench("parseTranslations",true);
     		$sOutput = Anwi18n::parseTranslations($this->out);
     		AnwDebug::stopBench("parseTranslations");*/
     $sOutput = $this->out;
     //full execution time benchmark
     $sElapsedTime = AnwDebug::stopBench("GLOBAL");
     //show execution time ?
     if (self::globalCfgShowExecTime()) {
         $fMemoryUsage = AnwDebug::getMemoryUsage();
         $sOutput = str_replace('%ANWEXECTIME%', ' • ' . $sElapsedTime . ' sec • ' . $fMemoryUsage . ' MB', $sOutput);
     } else {
         $sOutput = str_replace('%ANWEXECTIME%', '', $sOutput);
     }
     //show full debug ?
     if (AnwUtils::isViewDebugAuthorized()) {
         $sLog = AnwDebug::getLog();
         if ($sLog) {
             $sOutput = str_replace('</body>', '<div id="debug">' . $sLog . '</div></body>', $sOutput);
         }
     }
     print $sOutput;
     exit;
 }
Exemple #4
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;
 }
Exemple #5
0
//require global template
loadApp(ANWPATH_DEFAULT . AnwComponent::getGlobalComponentFullDir() . "global.tpl.php");
loadApp(ANWPATH_OVERRIDE . AnwComponent::getGlobalComponentFullDir() . "global.tpl.php");
//are we in minimal/batch/standard mode?
if (ANWIKI_MODE_BATCH) {
    loadApp(ANWPATH_CLASSES . "session/class_currentsession-batch.php");
} else {
    if (ANWIKI_MODE_MINIMAL) {
        loadApp(ANWPATH_CLASSES . "session/class_currentsession-minimal.php");
    } else {
        loadApp(ANWPATH_CLASSES . "session/class_currentsession.php");
    }
}
AnwDebug::setTraceEnabled(AnwComponent::globalCfgTraceEnabled());
AnwEnv::init();
AnwDebug::stopBench("loading files");
/**
 * We use it for more flexibility.
 * That way, you can previously define some constants for your needs depending on your hosting strategy.
 */
function anwdefine($sConstant, $sValue)
{
    if (!defined($sConstant)) {
        define($sConstant, $sValue);
    }
}
function anwInitErrorReporting()
{
    if (ANWIKI_DEVEL) {
        error_reporting(E_ALL | E_STRICT);
    } else {
Exemple #6
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;
 }
Exemple #7
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;
 }
 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;
 }