<?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 JFormFieldPaypalStatus extends JFormField{
  protected function getInput(){
    $db = JFactory::getDBO();
    $query = "SELECT name,enabled FROM #__extensions WHERE folder='payment' AND (element='paypal' OR element='paypal2')";
    $db->setQuery($query);
    $status = $db->loadObjectList();
    $status_str = '';
    if(!isset($status[0])){
      $status_str = '<b style="color:red;">'.cck_lang_text("COM_OS_CCK_PARAMS_PAYPAL_NOT_INSTALL").'</b>';
    }
    if(is_array($status)){
        foreach($status as $st){
            if($st->enabled == 0){
              $status_str .= '<b style="color:red;">' . cck_lang_text("COM_OS_CCK_PARAMS_PAYPAL_PLUGIN") . $st->name . cck_lang_text("COM_OS_CCK_PARAMS_PAYPAL_PLUGIN_NOT_ENABLE"). '</b>, ';
            }else{
              $status_str .= '<b style="color:green;">'.cck_lang_text("COM_OS_CCK_PARAMS_PAYPAL_PLUGIN_ENABLE").' [ '.$st->name.' ]</b>, ';
            }
        }
    }
    $status_str = trim($status_str, ', ');
    return $status_str;
  }
}
