/** * Prints the current memory usage as progress. * * @return void * * @author Sebastian Diel <*****@*****.**> * @since 18.12.2012 */ public function printMemoryProgressInfo() { if (!$this->isInSilentMode()) { $tab = "\t"; $memUsage = 'Current Memory Usage: ' . SilvercartDebugHelper::getCurrentMemoryUsage() . ' (' . SilvercartDebugHelper::getCurrentMemoryUsage(true) . ')'; $infoText = $tab . "[35m" . $memUsage . "[0m" . "\r"; print $infoText; } }
/** * Sets the start time * * @param float $starttime Start time * * @return void */ public static function setStarttime($starttime) { self::$starttime = $starttime; }
/** * builds the tmp files for sitemap * * @return void * * @author Patrick Schneider <*****@*****.**> * @since 11.03.2013 */ protected function buildSitemapXmlFiles() { if (is_null($this->sitemapXml)) { $urlToPrimeCacheFor = $this->getUrlToPrimeCacheFor(); $baseUrlToSitemapXml = $this->buildUrlToSitemapXml($urlToPrimeCacheFor); $tmpFilePathBase = $this->getBaseTmpFilePath() . 'sitemap.xml'; if (empty($urlToPrimeCacheFor)) { $this->printError('Please add a valid URL to prime cache for.'); $this->printUsage(); exit; } $this->printInfo('Priming cache for ' . $urlToPrimeCacheFor); $locale = $this->getCurrentLocale(); $tmpFilePathForLocale = $tmpFilePathBase . "-" . $locale; if (file_exists($tmpFilePathForLocale)) { $this->printInfo('Taking locally stored sitemap.xml for locale ' . $locale . ', no need to request server'); $xmlstring = file_get_contents($tmpFilePathForLocale); } else { $urlToSitemapXml = $baseUrlToSitemapXml . "?locale=" . $locale; $this->printInfo('Requesting ' . $urlToSitemapXml); SilvercartDebugHelper::startTimer(); $xmlstring = $this->mergeSitemaps($urlToSitemapXml, $tmpFilePathForLocale); $this->printInfo('Got sitemap.xml for locale ' . $locale . ' after ' . number_format(SilvercartDebugHelper::getTimeDifference(false), 2) . ' seconds.'); } if ($xmlstring === false) { $this->printError('The target URL ' . $urlToSitemapXml . ' is invalid.'); $this->printError('Please add a valid URL to prime cache for.'); $this->printUsage(); exit; } try { libxml_use_internal_errors(true); $xml = new SimpleXMLElement($xmlstring); libxml_clear_errors(); } catch (Exception $exc) { $this->printError($exc->getMessage()); $this->printError('The target URL ' . $baseUrlToSitemapXml . ' is invalid.'); $this->printError('Please add a valid URL to prime cache for.'); $this->printUsage(); exit; } $this->sitemapXml = $xml; } }