name : dearflips.php
<?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' );

/**
 * DearflipsList Model
 *
 * @since  0.0.1
 */
class DearflipModelDearflips extends JModelList {
  
  /**
   * Constructor.
   *
   * @param array $config An optional associative array of configuration settings.
   *
   * @see     JController
   * @since   1.6
   */


  public function __construct( $config = array() ) {
    if ( empty( $config['filter_fields'] ) ) {
      $config['filter_fields'] = array(
          'id',
          'book_title',
          'df_cat',
          
          'published',
          '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',
          
      );
    }
    
    parent::__construct( $config );
  }
  
  /**
   * Method to build an SQL query to load the list data.
   *
   * @return      string  An SQL query
   */
  protected function getListQuery() {
    // Initialize variables.
    $db    = JFactory::getDbo();
    $query = $db->getQuery( true );
    
    // Create the base select statement.
    $query->select( '*' )
        ->from( $db->quoteName( '#__dearflip' ) )
        ->order( $db->quoteName( 'id' ) . ' DESC' );
    
    
    // Filter: like / search
    $search = $this->getState( 'filter.search' );
    
    if ( !empty( $search ) ) {
      $like = $db->quote( '%' . $search . '%' );
      $query->where( 'book_title LIKE ' . $like );
    }
    
    // Filter by published state
    $published = $this->getState( 'filter.published' );
    
    if ( is_numeric( $published ) ) {
      $query->where( 'published = ' . (int)$published );
    } elseif ( $published === '' ) {
      $query->where( '(published IN (0, 1))' );
    }
    
    // Add the list ordering clause.
    $orderCol  = $this->state->get( 'list.ordering', 'book_title' );
    $orderDirn = $this->state->get( 'list.direction', 'ASC' );
    
    
    $query->order( $db->escape( $orderCol ) . ' ' . $db->escape( $orderDirn ) );
    
    return $query;
  }
}

© 2025 Cubjrnet7