<?php


/**
 
 * @package     pkg_dearflip
 * @subpackage  com_dearflip
 * @since       1.0.0
 * @copyright   Copyright © 2007 Free Software Foundation, Inc. All rights reserved.
 * @license   GNU General Public License version 3 or later; see https://www.gnu.org/licenses/gpl-3.0.en.html
 
 */

// No direct access to this file
defined( '_JEXEC' ) or die( 'Restricted access' );

JFormHelper::loadFieldClass( 'list' );

/**
 * Dearflip Form Field class for the Dearflip component
 *
 * @since  0.0.1
 */
class JFormFieldDearflip extends JFormFieldList {
  /**
   * The field type.
   *
   * @var         string
   */
  protected $type = 'Dearflip';
  
  /**
   * Method to get a list of options for a list input.
   *
   * @return  array  An array of JHtml options.
   */
  protected function getOptions() {
    $db    = JFactory::getDBO();
    $query = $db->getQuery( true );
    $query->select([ 'id,book_title',
        'df_cat',
        'dfx_book_type_list',
        'dfx_pdf',
        'dfx_images_source',
        'dfx_images_sort_by',
       
        'dfx_view_mode',
        'dfx_thumb',
        'dfx_button_text',
        'dfx_custom_text',
        
    
        'dfx_3d_2d',
        'dfx_hardpages',
        'dfx_bgColor',
        'dfx_bgImage',
        'dfx_flipduration',
        'dfx_containerHeight',
        'dfx_pdfPagerenderSize',
        'dfx_autoEnableSound',
        'dfx_enableDownload',
        'dfx_pageMode',
        'dfx_singlePageMode',
        'dfx_controlsPosition',
        'dfx_hide_controls',
        'dfx_direction',
        'dfx_forcePageFit',
        'dfx_enableAutoPlay',
        'dfx_autoPlayDuration',
        'dfx_enableAutoPlayAutomatically',
        'dfx_pageSize',
    
        'dfx_autoEnableOutline',
        'dfx_autoEnableThumbnail']);
    
    $query->from( '#__dearflip' );
    $db->setQuery( (string)$query );
    $messages = $db->loadObjectList();
    $options  = array();
    
    if ( $messages ) {
      foreach ( $messages as $message ) {
        $options[] = JHtml::_( 'select.option', $message->id, $message->book_title, $message-> dfx_pdf);
      }
    }
    
    $options = array_merge( parent::getOptions(), $options );
    
    return $options;
  }
}