setQuery( $query );
$options = $database->loadObjectList();
$r = '
| name | id | type | position |
';
foreach ($options as $o) {
$r .= "\n";
$r .= "| ".$o->title.' | '.$o->id.' | '.$o->module.' | '.$o->position.' | ';
$r .= "
\n";
}
$r .= "
";
return $r;
}
function _form_help( $name, $value, &$node, $control_name ) {
return 'Create some PHP code to determine which module should be used. Once the script has decided which module or modules to display, return the module id, a comma-separated list of module ids as a string, or an array of module ids. For more help and recipes, see the MetaMod home page. e.g.
if (time() >= strtotime("1 Oct 2007") && time() < strtotime("30 Oct 2007")) return 74;
if (time() < strtotime("1 Nov 2008")) return 75;
if ($fromCountryId == "US") return 55;
if ($fromCountryId == "GB") return "55,56,57";
if ($fromCountryId == "NL") return array(58,59,73);
if ($fromCountryName == "New Zealand") return 21;
You have access to the following PHP variables:
- $fromCountryId - the upper-case 2-letter ISO country code (e.g. GB, US, FR, DE)
- $fromCountryName - the official ISO country name
- $geoip - if you have enabled GeoLiteCity or GeoIPCity, a record containing the following items:
- $geoip->country_name - full country name, as above
- $geoip->country_code - 2-letter ISO country code, as above
- $geoip->country_code3 - 3-letter ISO country code (e.g. GBR, USA, FRA, DEU)
- $geoip->region - 2-letter code. For US/Canada, ISO-3166-2 code for the state/province name, e.g. "GA" (Georgia, USA). Outside of the US and Canada, FIPS 10-4 code., e.g. "M9" (Staffordshire, UK)
- $geoip->city - full city name
- $geoip->postal_code - For US, Zipcodes, for Canada, postal codes. Available for about 56% of US GeoIP Records. More info.
- $geoip->latitude
- $geoip->longitude
- $geoip->dma_code - 3-digit DMA/Metro code (US only)
- $geoip->area_code - 3-digit telephone prefix (US Only)
- $Itemid - the Itemid of the main component on the page
- $option - the option of the main component on the page (e.g. com_content)
- $task - the task of the main component on the page (e.g. "view" or "category")
- $id - the id of the item in the main component on the page (e.g. "24:content-layouts")
- $database - in case you want to query the database for anything (for experts!)
- $language - a lower-case language code. By default this returns the default language of the web visitor’s browser, but can alternatively return the language code of the Joomla front-end, or intelligently find the best match between a user’s browser languages and a list of languages that you provide. Typical language strings returned include: en, en-gb, en-us, fr, de and many others.
- $language_code - the 2-letter language code without region (lower case) e.g. "en"
- $language_region - if it exists, the 2-letter region code (lower case). e.g. if $language == "en-us", $language_code == "en" and $language_region == "us". Having them in separate variables like this makes it easier to put into MetaMod rules.
- $my - information about the user, if they are logged in. e.g.
- $my->id
- $my->name
- $my->username
- $my->email
- $my->usertype e.g. "" or "Public Frontend"=not logged in (test for both), otherwise "Registered", "Author", "Editor", "Publisher", "Manager", "Administrator" or "Super Administrator"
- $my->gid (group id: 0=Public, 1=Registered, 2=Special)
- $user->registerDate e.g. "2007-05-17
01:25:52"
- $user->lastvisitDate e.g. "2007-11-02
18:51:29"
Note: $fromCountryName and $fromCountryId will only be available if you have one of the "Enable GeoIP" options selected above, and if you have one of the GeoLite Country, GeoIP Country, GeoLiteCity or GeoIPCity databases installed (see Maxmind, direct GeoLite Country download, or direct GeoLite City download)';
}
function _form_geoipcheck( $name, $value, &$node, $control_name ) {
global $mosConfig_absolute_path;
$files = $this->geoIPFolders();
foreach ($files as $file) {
$country = file_exists($mosConfig_absolute_path.$file.'/GeoIP.dat');
$litecity = file_exists($mosConfig_absolute_path.$file.'/GeoLiteCity.dat');
$city = file_exists($mosConfig_absolute_path.$file.'/GeoIPCity.dat');
$messages = array();
if ($country) {
$age = intval((time() - filemtime($mosConfig_absolute_path.$file.'/GeoIP.dat'))/(24*60*60));
if ($age > 30) $age = "File is $age days old. Please update your database from MaxMind.";
else $age = "";
$messages[] = $file."/GeoIP.dat found. All GeoIP Country features enabled. $age";
}
if ($litecity) {
$age = intval((time() - filemtime($mosConfig_absolute_path.$file.'/GeoLiteCity.dat'))/(24*60*60));
if ($age > 30) $age = "File is $age days old. Please update your database from MaxMind.";
else $age = "";
$messages[] = $file."/GeoLiteCity.dat found. All GeoIP City/region features enabled. $age";
}
if ($city) {
$age = intval((time() - filemtime($mosConfig_absolute_path.$file.'/GeoIPCity.dat'))/(24*60*60));
if ($age > 30) $age = "File is $age days old. Please update your database from MaxMind.";
else $age = "";
$messages[] = $file."/GeoIPCity.dat found. All GeoIP City/region features enabled. $age";
}
if ($country || $litecity || $city) {
return "".implode("
",$messages).'
Keep your GeoIP databases up to date from
MaxMind';
}
}
return 'I couldn\'t find any GeoIP database at jooma_root/geoip/GeoIP.dat or GeoFreeCity.dat or GeoIPCity.dat.
If you want to use the GeoIP Country features, please obtain the GeoLite Country or GeoIP Country database
at MaxMind
(direct download),
uncompress it, and install it as jooma_root/geoip/GeoIP.dat. For full City and
location features, please obtain the GeoLite City or GeoIP City database
at MaxMind,
uncompress it, and install it as jooma_root/geoip/GeoLiteCity.dat';
}
function geoIPFolders() {
return array(
"/geoip",
"/GeoIP",
"/geoIP",
"/GEOIP",
"/GEO IP",
"/",
"/geo_ip",
"/geo_IP",
"/Geo_IP"
);
}
}