<?php
defined('_JEXEC') or die('Restricted access');

/**
* @package OS CCK
* @copyright OrdaSoft.
* @author Andrey Kvasnevskiy(akbet@mail.ru),Roman Akoev (akoevroman@gmail.com)
* @link http://ordasoft.com/cck-content-construction-kit-for-joomla.html
* @description OrdaSoft Content Construction Kit
*/

require_once(JPATH_SITE . "/components/com_os_cck/functions.php");

//JHTML::_('behavior.modal', 'a.modal-button');
$doc = JFactory::getDocument();
includeJavaScriptCCK('components/com_os_cck/assets/js/functions.js');
includeStylesCCK('components/com_os_cck/assets/css/admin_style.css');

if (version_compare(JVERSION, "4.0.0-alpha10", "ge")) {
    includeStylesCCK("components/com_os_cck/assets/css/admin_style-j4.css");
}else{
    includeStylesCCK("components/com_os_cck/assets/css/admin_style-j3.css");
}
 
class JFormFieldPaypalplugin extends JFormField{
  protected function getInput(){
    $db = JFactory::getDBO();
    $query = "SELECT name,enabled,element FROM #__extensions WHERE folder='payment' AND (element='paypal' OR element='paypal2')";
    $db->setQuery($query);
    $plugins = $db->loadObjectList();
    
    $os_cck_configuration = JComponentHelper::getParams('com_os_cck');
    
    $plugins_opt = array();
    $plugins_opt[] = JHTML::_('select.option','0',cck_lang_text('COM_OS_CCK_PARAMS_OPTION_NOT_SELECTED_PAYPAL'));
    if(!empty($plugins)){
        foreach($plugins as $plugin){
            
            if($plugin->enabled != 0){
                $plugins_opt[] = JHTML::_('select.option',$plugin->element,$plugin->name);
            }
        }
    }
    $plugins_list = JHTML::_('select.genericlist',$plugins_opt, $this->name,
                                    'size="1" class="inputbox form-select" ', 'value', 'text', $os_cck_configuration->get('use_paypal', 0));

    return $plugins_list;
  }
}
