Cleaned up code in some of my extensions
Removed function testImage in ext/chatbox/test.php because it no longer applies (there is a cache now)
This commit is contained in:
parent
a55c5efc4f
commit
7155804505
@ -11,23 +11,18 @@
|
|||||||
class google_analytics extends Extension {
|
class google_analytics extends Extension {
|
||||||
# Add analytics to config
|
# Add analytics to config
|
||||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
global $config;
|
|
||||||
|
|
||||||
$sb = new SetupBlock("Google Analytics");
|
$sb = new SetupBlock("Google Analytics");
|
||||||
$sb->add_text_option("google_analytics_id", "Analytics ID: ");
|
$sb->add_text_option("google_analytics_id", "Analytics ID: ");
|
||||||
$sb->add_label("<br>(eg. UA-xxxxxxxx-x)");
|
$sb->add_label("<br>(eg. UA-xxxxxxxx-x)");
|
||||||
|
|
||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load Analytics tracking code on page request
|
# Load Analytics tracking code on page request
|
||||||
public function onPageRequest(PageRequestEvent $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $config;
|
global $config, $page;
|
||||||
global $page;
|
|
||||||
|
|
||||||
$google_analytics_id = $config->get_string('google_analytics_id','');
|
$google_analytics_id = $config->get_string('google_analytics_id','');
|
||||||
if (stristr($google_analytics_id, "UA-"))
|
if (stristr($google_analytics_id, "UA-")) {
|
||||||
{
|
|
||||||
$page->add_html_header("<script type='text/javascript'>
|
$page->add_html_header("<script type='text/javascript'>
|
||||||
var _gaq = _gaq || [];
|
var _gaq = _gaq || [];
|
||||||
_gaq.push(['_setAccount', '$google_analytics_id']);
|
_gaq.push(['_setAccount', '$google_analytics_id']);
|
||||||
|
@ -42,6 +42,8 @@ class SCoreWebReporter extends HtmlReporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function paintGroupEnd($name) {
|
function paintGroupEnd($name) {
|
||||||
|
global $page;
|
||||||
|
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if(preg_match("#ext/(.*)/test.php#", $name, $matches)) {
|
if(preg_match("#ext/(.*)/test.php#", $name, $matches)) {
|
||||||
$name = $matches[1];
|
$name = $matches[1];
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
* Name: XML Sitemap
|
* Name: XML Sitemap
|
||||||
* Author: Sein Kraft <mail@seinkraft.info>
|
* Author: Sein Kraft <mail@seinkraft.info>
|
||||||
* Author: Drudex Software <support@drudexsoftware.com>
|
* Author: Drudex Software <support@drudexsoftware.com>
|
||||||
|
* Link: http://drudexsoftware.com
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Sitemap with caching & advanced priorities
|
* Description: Sitemap with caching & advanced priorities
|
||||||
* Documentation:
|
* Documentation:
|
||||||
@ -118,21 +119,20 @@ class XMLSitemap extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets sitemap with entries in the queue
|
// sets sitemap with entries in sitemap_queue
|
||||||
private function generate_display_sitemap()
|
private function generate_display_sitemap()
|
||||||
{
|
{
|
||||||
global $page;
|
global $page;
|
||||||
|
|
||||||
$page->set_mode("data");
|
|
||||||
$page->set_type("application/xml");
|
|
||||||
|
|
||||||
$xml = "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">
|
$xml = "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">
|
||||||
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
|
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
|
||||||
$this->sitemap_queue
|
$this->sitemap_queue
|
||||||
</urlset>";
|
</urlset>";
|
||||||
|
|
||||||
// Generate new sitemap & display
|
// Generate new sitemap
|
||||||
file_put_contents($this->sitemap_filepath, $xml);
|
file_put_contents($this->sitemap_filepath, $xml);
|
||||||
|
$page->set_mode("data");
|
||||||
|
$page->set_type("application/xml");
|
||||||
$page->set_data($xml);
|
$page->set_data($xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,10 +155,10 @@ class XMLSitemap extends Extension {
|
|||||||
{
|
{
|
||||||
global $page;
|
global $page;
|
||||||
|
|
||||||
|
$xml = file_get_contents($this->sitemap_filepath);
|
||||||
|
|
||||||
$page->set_mode("data");
|
$page->set_mode("data");
|
||||||
$page->set_type("application/xml");
|
$page->set_type("application/xml");
|
||||||
|
|
||||||
$xml = file_get_contents($this->sitemap_filepath);
|
|
||||||
$page->set_data($xml);
|
$page->set_data($xml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,5 @@ class XMLSitemapTest extends ShimmieWebTestCase {
|
|||||||
# PHP-level error messages
|
# PHP-level error messages
|
||||||
$this->get_page('sitemap.xml');
|
$this->get_page('sitemap.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testImage() {
|
|
||||||
$this->log_in_as_user();
|
|
||||||
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx");
|
|
||||||
$this->log_out();
|
|
||||||
|
|
||||||
$this->get_page('sitemap.xml');
|
|
||||||
|
|
||||||
$this->log_in_as_admin();
|
|
||||||
$this->delete_image($image_id);
|
|
||||||
$this->log_out();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user