Product | Technical support | Version | Video exhibits | Manuals | Job Search | Contact
English   menu-arrow-gray-horizontal.gif
Home > About the Product > Protection of the projects under Visual PHP™
Related information
Search


Video demonstration
Drag&drop in the Visual PHP™ Environment

Latest video samples:
Job Search
Company
E-VISION International s.r.o.

is looking for PHP 5 and JavaScript programmers for long-term cooperation.




More information ...
Wrote about Visual PHP™
News by e-mail
Your e-mail

Visual PHP Recommends
For Visual PHP™
(for work in both the developer and the administration interface), we recommend using the Mozilla Firefox web browser, on the basis of which the whole software is developed because of stability, complying with the W3C standards and protecting elements of the browser.

Generating a XML sitemap (sitemap.xml)

Soubor sitemap.xml obsahuje souhrn URL na jednotlivé stránky Vaší prezentace. Jedná se o poměrně jednoduchý XML soubor, který specifikuje protokol sitemaps XML format.

Ukázkový soubor se dvěma stránkami může vypadat takto:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
   <loc>http://www.domain.com/site-1/</loc>
   <lastmod>2011-05-14T14:20:29+01:00</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.5</priority>
  </url>
  <url>
   <loc>http://www.domain.com/site-2/</loc>
   <lastmod>2011-05-14T14:20:29+01:00</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.5</priority>
  </url>
</urlset>
Specifikace určuje tyto elementy:

Skript pro generování souboru sitemap.xml

Soubor sitemap.xml by bylo možné generovat jednoduchým skriptem, ale zhledem k tomu, že databáze může obsahovat velké množství tabulek a záznamů, došlo by u běžně psaného skriptu k vypršení povoleného času (max_execution_time), nebo přidělené paměti RAM (memory_limit). Proto jsme v návodu zvolili tvorbu pomocí skriptů běžících na pozadí, které umožňují zpracovávat data po téměř libovolně dlouhou domu s nevzrůstajícími nároky na spotřebovanou paměť.

Základem je tedy skript běžící na pozadí, kterému nadefinujeme vstupní parametry a jednotlivé události onStart, onContinue a onFinish

V nabídce Prezentace -> Skripty na pozadí založíme nový skript, kterému nastavíme tid například sitemap_xml a pro vstup nám stačí jediné vstupní pole, kterému budeme předávat názvy tabulek, ze kterých se mají generovat odkazy. Vstupnímu poli nastavíme:
Název:                tables
Typ komponenty:       TABLES
Parametry komponenty: Multiselect = true
Nyní už stačí pouze zadat jednotlivé události:

Událost onStart:
$this->tables = array();
$this->tableRecordIndex = 0;
$this->allTablesRecordIndex = 0;
$this->tableRecordStep = 20;
$this->fileName = PROJECTPATH."sitemap.xml";
$this->tmpFileName = PROJECTPATH."repository/temp/sitemap.xml";
_file_put_contents($this->tmpFileName, "");

$total = 0;
foreach($this->params["tables"] as $tableName)
{
	$Table = getTable($tableName);
	if ($Table)
	{
		foreach(getObject("Translators")->languages as $language)
		{
			$total += getTable($tableName)->getContentRecordCount();
			$this->tables[] = array("name" => $tableName, "recordCount" => $total, "language" => $language);
		}
	}
}

return($total);
Událost onContinue:
$f = fopen($this->tmpFileName, "a+");

if ($this->allTablesRecordIndex == 0)
{
	fwrite($f, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	fwrite($f, "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
}

while(count($this->tables))
{
	$Table = getTable($this->tables[0]["name"]);
	setLanguage($this->tables[0]["language"]);

	processProgressText("Processing table '".$Table->name."' record ".($this->tableRecordIndex+1)." of ".$this->tables[0]["recordCount"]." for language ".$this->tables[0]["language"]);
	processProgressByIndex($this->allTablesRecordIndex);
	$records = $Table->getContentRecords("begin=".$this->tableRecordIndex.",limit=".$this->tableRecordStep);
	
	foreach($records as $record)
	{
		fwrite($f, "<url>");
		fwrite($f, "<loc>".parseFileLinks($Table->fileName."?id=".$record["id"])."</loc>");
                if ($record["date"])
		    fwrite($f, "<lastmod>".date("c",_strtotime($record["date"]))."</lastmod>");
                fwrite($f, "<changefreq>monthly</changefreq>");
                fwrite($f, "<priority>0.5</priority>");
		fwrite($f, "</url>");
	}
	
	$this->tableRecordIndex += $this->tableRecordStep;
	$this->allTablesRecordIndex += count($records);
	
	processMessage($this->tableRecordIndex." >= ".$this->tables[0]["recordCount"]);
	if ($this->tableRecordIndex >= $this->tables[0]["recordCount"])
	{
		array_shift($this->tables);
		$this->tableRecordIndex = 0;
	}
	
	if ($this->resumeNeeded())
	{
		fclose($f);
		$this->resumeInBackground();
	}
}

fwrite($f, "</urlset>");
fclose($f);

$this->finish();
Událost onFinish:
_file_put_contents($this->fileName, "");
rename($this->tmpFileName, $this->fileName);

// ping Google to say that sitemap has changed
download("http://www.google.com/webmasters/sitemaps/ping?sitemap=".urlencode(PROJECTURL."sitemap.xml"), array(), array(), array("timeout" => 2));

processProgressText("Finished");
Skript generuje odkazy pro všechny nastavené jazyky, lze jej tedy využít i pro vícejazyčné prezentace.

Pravidelné spouštění skriptu

Skript je ideální spouštět 1x denně, ovšem čas spouštení si můžete nastavit dle libosti. Je potřeba pouze vytvořit nový časový skript v nabídce Prezentace -> Časové skripty.

Do tid zadáme například sitemap_xml a budeme chtít spouštět každý den v 1h v noci. Do vlastnosti Minuty tedy zvolíme 00, do vlastnosti Hodiny zvolíme 01 a do Dny, Měsíce a Dny v týdnu vybereme všechny možnosti pomocí tlačítka Vybrat vše.

Zbývá už jen samotný kód skriptu, který je velice jednoduchý:
$tables = array(
    "news",
    "documents",
    "articles",
    "photogalleries",
);

runProcessScript("sitemap_xml", array("tables" => $tables));
Které tabulky budete generovat záleží už jen na rozsáhlosti Vašeho projektu.

Na časový skript nemusíte čekat, ale můžete jej spustit ihned zavoláním této URL:
http://www.domain.com/cron.php?tid=sitemap_xml
Průběh provádění skriptu na pozadí můžete sledovat v Nástroje -> Správce procesů -> Všechny procesy.

Jak sdělit vyhledávačům, kde soubor sitemap.xml naleznou

Zatím pouze Google poskytuje tzv. ping sitemapy, tedy okamžité sdělení, že soubor byl změněn. Provádí se to voláním speciální URL:
http://www.google.com/webmasters/sitemaps/ping?sitemap=URL_SOUBORU_SITEMAP_XML
Volání samo je provedeno ve skriptu v události onFinish. Pro ostatní vyhledávače musíme přidat do souboru robots.txt (nacházející se v rootu webu) cestu, kde je sitemap.xml uložen. Výsledný soubor robots.txt :
User-agent: *
Allow:
Sitemap: http://www.domain.com/sitemap.xml







NOTICE

Some properties published in this article can only be functional with the latest core version. If you have any older core version, we recommend you to update to the latest version.

Login
Free trial

for 30 days
Latest core version
Single Developer 1.7.9.680
january 20, 2012

Professional 1.7.9.680
january 20, 2012

Enterprise 1.7.9.680
january 20, 2012


Latest developer guide
Developer Guide 1.0.5
july 10, 2009 9:36:42 AM

Latest user guide
Administrator Guide 1.0.24
august 27, 2010 11:58:08 AM

Latest install script
install.php 1.9.22
april 12, 2012 6:02:40 PM

Comming up in next version
more ...

rss.gif
Support

Fotogalerie 5/10/2012
Section: Tvorba prezentací
Chyba v hromadné korespondenci, nelze odeslat příloha (nová verze 4/6/2012
Section: Bug reporty
AntiSpam obrázek 4/6/2012
Section: Programování
Chyba při opravách textů 4/4/2012
Section: Bug reporty
Admin může smazat Developera, je to ok? 3/27/2012
Section: Bug reporty
Mapa webu 3/19/2012
Section: Tvorba prezentací


rss.gif
News

Weather Component Update
november 18, 2011
Server weather.com decided to stop providing weather information for free and passed to the paid version (about $ 60 per month). For this reason, we were forced to modify the Weather component to pulling weather information from another data source, namely from the server www.worldweatheronline.com . This site also provides information about weather all around the world, but the amount of information is smaller than the original source.

For proper functionality of the Weather component please update core to version 1.7.9.638.
Added new tutorials
october 4, 2011
He added new instructions Using another HTML editor
Powered by Visual PHP ™
© 2008 - 2010 E-VISION International, s.r.o.
Product | Technical support | Version | Video exhibits | Manuals | Job Search | Contact