<?php

require_once 'classes/ImportPlugin.php';

class PluginDomains_registrar extends ImportPlugin
{
    var $name = /*T*/'Imports Domains From Registrars'/*/T*/;  
    
    function getForm()
    {
        $this->tpl->define(array('view'  => '../../plugins/import/domains_registrar/PluginDomainsregistrar.tpl'));
        
        if (!isset($this->configuration['modules']['domains']['installedVersion'])) {
            $this->tpl->parse('view', 'noDomainsModule');
            return $this->tpl->subst('PluginDomainsregistrar_out', 'view');
        }
        $this->tpl->assign('CE_VERSION', $this->settings->get('ClientExec Version'));
        
        $count = 0;
        $query = "SELECT DISTINCT `plugin` FROM `tld` WHERE `plugin`!=''";
        $result = $this->db->query($query);
        while ($row = $result->fetch()) {
            if (strpos($this->settings->get('plugin_'.$row['plugin'].'_Actions'), 'FetchDomains') !== false) {
                $this->tpl->setKey(array('REGISTRAR' => $row['plugin']));
                $this->tpl->parse('view', '.registrar');
                $count++;
            }
        }
        if ($count > 0) {
            $this->tpl->parse('view', 'registrarDropdown');
        } else {
            $this->tpl->assign('noRegistrarsText', $this->user->lang('You must first %sconfigure a registrar plugin%s and %sassign a TLD to use a domain registrar%s in order to fetch domains.', '<a href="index.php?fuse=admin&amp;view=Registrars">','</a>','<a href="index.php?fuse=admin&amp;view=ShowTldOverview">','</a>'));
            $this->tpl->parse('view', 'noRegistrars');
        }
        $this->tpl->parse('view', 'hasDomainsModule');
        return $this->tpl->subst('PluginDomainsregistrar_out', 'view');
    }
    
}
?>
