Hello,

I am have a problem embedding more than one tag extensions in any given post on 
my wiki. wiki version 1.16
Both tag extensions work fine by them selves but when ever I add the second one 
it causes errors or I just get a white page.
I am using <servers/> and <contact/> to embed the extensions. I am guessing 
that when I add the second extension I am causing some type of problem with
a global variable or some kind of name space issue. I have included all the 
code for the two extensions. any help would make my day!

Thanks!

###ContactTag.php###

<?php

$wgHooks['ParserFirstCallInit'][] = 'ContactTag::setup';

$wgAutoloadClasses['ConatctTag'] = dirname( __FILE__ ) . "/ContactTag_body.php";


###ContactTag_body.php###

<?php


// Create hello tag for the Wiki
class HelloTag {
  const NAME = 'contact';

  static function setup() {
    // The entry point. Associates the tag with a function.
    global $wgParser;
    $wgParser->setHook(self::NAME, array('ContactTag', 'render'));
    return true;
  }
                

  static function render() {
    //required for DB connection
    require "db_mysql.inc";// defined in /etc/php.ini path: 
/usr/lib/php/include/
        require "define_hosts.php"; // defined in /etc/php.ini path: 
/usr/lib/php/include/

                // Connection Parameters
                $em7_g3 = new DB_MySQL;
                $em7_g3->Host = $em7_host;
                $em7_g3->User = $em7_user;
                $em7_g3->Password = $em7_pw;
                $em7_g3->Database = "biz";
                $em7_g3->connect();
                
                
                $ris = new DB_MySQL;
                $ris->Host = $storm_host;
                $ris->Database = "sugarcrm";
                $ris->User = $storm_user;
                $ris->Password = $storm_pw;
                $ris->connect();
        
        
                //Get end of URL remove _ from client name for DB query
                $endURL = $_GET["title"];
                $phrase  = $endURL;
                $healthy = array("_");
                $yummy   = array(" ");
                $newphrase = str_replace($healthy, $yummy, $phrase);
        

                //Run DB query and run though loop to get DB client data
                        if ($newphrase) {
                                $q = "Select v.first_name, v.last_name, 
f.email_address from contacts AS v
        Left join accounts_contacts AS s ON v.id = s.contact_id
        Left join accounts AS a ON a.id = s.account_id
        Left join email_addr_bean_rel AS e ON v.id = e.bean_id
        Left join email_addresses AS f ON f.id = e.email_address_id
        where a.name ='$newphrase'";
                                $ris->query($q);
                                $acnt = "";
                                $table ="<table border='4'>";
                                        while ($ris->next_record()) {
                                                $company = 
$ris->f("first_name");
                                                $device = $ris->f("last_name");
                                                $active = 
$ris->f("email_address");
                                                //$ip = $ris->f("ip");
                                                $acnt = $acnt + 1;
                                                        if ($company) {
                                                                        if 
($acnt){
                                                                                
$addr_list[$acnt] = 
"<tr><td>$company</td><td>$device</td><td>$active</td><td>$ip</td></tr>";
                                                                                
$string = $string.$addr_list[$acnt];
                                                                        }
                                                        }
                        
                                }
                        
                        $tableEnd="</table>";
                        return $table.$string.$tableEnd;
           
                }
    
  }
}


###ServerTag.php###

<?php

# Credits
$wgExtensionCredits['other'][] = array(
  'name' => 'ServerTag',
  'description' => 'Print All Servers Based On Client Page Name.',
  'version' => '1.0');

# Set up the hook, using different logic depending
# on the version of MediaWiki
if (defined('MW_SUPPORTS_PARSERFIRSTCALLINIT')) {
  $wgHooks['ParserFirstCallInit'][] = 'ServerTag::setup';
} else {
  $wgExtensionFunctions[] = 'ServerTag::setup';
}

# Autoload the implementation class
$wgAutoloadClasses['ServerTag']
  = dirname( __FILE__ ) . "/ServerTag_body.php";





###ServerTag_body.php###

<?php



  class ServerTag {
  const NAME = 'servers';

  static function setup() {
    global $wgParser;
    $wgParser->setHook(self::NAME, array('ServerTag', 'render'));
    return true;
  }
                

  static function render() {
    //required for DB connection
    require "db_mysql.inc";
        require "define_hosts.php"; 

                // Connection Parameters
                $em7_g3 = new DB_MySQL;
                $em7_g3->Host = $em7_g3_host;
                $em7_g3->User = $em7_g3_user;
                $em7_g3->Password = $em7_g3_pw;
                $em7_g3->Database = "master_biz";
                $em7_g3->connect();
        
        
                //Get end of URL remove _ from client name for DB query
                $endURL = $_GET["title"];
                $phrase  = $endURL;
                $healthy = array("_");
                $yummy   = array(" ");
                $newphrase = str_replace($healthy, $yummy, $phrase);
        

                //Run DB query and run though loop to get DB client data
                        if ($newphrase) {
                                $q = "SELECT company, 
device,master_dev.legend_device.active, master_dev.device_ip_addr.ip from 
master_biz.`organizations` left join master_dev.legend_device on 
master_biz.`organizations`.roa_id = master_dev.legend_device.roa_id left join 
master_dev.device_ip_addr on master_dev.legend_device.id = 
master_dev.device_ip_addr.did where company = '$newphrase'";
                                $em7_g3->query($q);
                                $acnt = "";
                                $table ="<table border='4'>";
                                        while ($em7_g3->next_record()) {
                                                $company = 
$em7_g3->f("company");
                                                $device = $em7_g3->f("device");
                                                $active = $em7_g3->f("active");
                                                $ip = $em7_g3->f("ip");
                                                $acnt = $acnt + 1;
                                                        if ($company) {
                                                                        if 
($acnt){
                                                                                
$addr_list[$acnt] = 
"<tr><td>$company</td><td>$device</td><td>$active</td><td>$ip</td></tr>";
                                                                                
$string = $string.$addr_list[$acnt];
                                                                        }
                                                        }
                        
                                }
                        
                        $tableEnd="</table>";
                        return $table.$string.$tableEnd;
           
                }
                
                
    
  }
}




Mike Cody
Systems Administrator
RELIAM
(310) 348-9700 x 2  ( Support )
(310) 348-9797 FAX
----
Blog: http://www.reliam.com/news/reliam_blog
Twitter: http://www.twitter.com/reliam
Facebook: http://www.facebook.com/reliam
----



_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to