<?php
/**
 * Displays Custom Fields Options Page
 * 
 * This file is a template for wp-admin / Classifieds / Options / Custom Fields panel. 
 * 
 * It is being loaded by wpadverts_custom_fields_page_options function.
 * 
 * @see wpadverts_custom_fields_page_options()
 * @since 1.0.0
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;

?>
<div class="wrap">

    <h2 class="">
        <?php _e("Custom Fields", "wpadverts-custom-fields") ?>
    </h2>

    <h2 class="nav-tab-wrapper">
        <a href="<?php echo esc_attr( remove_query_arg( array( 'cfpanel', 'add' ) ) ) ?>" class="nav-tab"><?php _e("Form Schemes", "wpadverts-custom-fields") ?></a>
        <a href="<?php echo esc_attr( add_query_arg( array('cfpanel' => 'data-sources') ) ) ?>" class="nav-tab nav-tab-active"><?php _e("Data Sources", "wpadverts-custom-fields") ?></a>
    </h2>
    
    <h2 class="">
        <a class="add-new-h2" href="<?php echo esc_attr( add_query_arg('add', 'new') ) ?>"><?php _e("+ New Data Source", "wpadverts-custom-fields") ?></a> </h1>
    </h2>
    
    <?php adverts_admin_flash() ?>

    <table cellspacing="0" class="widefat post fixed">
        <?php foreach(array("thead", "tfoot") as $tx): ?>
        <<?php echo $tx; ?>>
            <tr>
                <th style="" class="" scope="col"><?php _e("Title", "wpadverts-custom-fields") ?></th>
                <th style="" class="" scope="col"><?php _e("Name", "wpadverts-custom-fields") ?></th>
                <th style="" class="" scope="col"><?php _e("Type", "wpadverts-custom-fields") ?></th>
            </tr>
        </<?php echo $tx; ?>>
        <?php endforeach; ?>

        <tbody>
            <?php $index = 0 ?>
            <?php foreach($options as $i => $item): ?>
            <tr valign="top" class="<?php if($index++%2==0): ?>alternate <?php endif; ?>  author-self status-publish iedit">
                <td class="">
                    <strong>
                        <a href="<?php echo esc_attr(add_query_arg('edit', $item["name"])) ?>" class=""><?php echo esc_html( $item["title"] ) ?></a>
                    </strong>
                    <div class="row-actions" style="">
                        <span class="edit"><a href="<?php echo esc_attr(add_query_arg('edit', $item["name"])) ?>"><?php _e("Edit Data Source", "wpadverts-custom-fields") ?></a> | </span>
                        <span class=""><a href="<?php esc_attr_e( add_query_arg( array( "delete" => $item["name"],"noheader" => 1 ) ) ) ?>" title="<?php _e("Delete") ?>" class="adverts-delete"><?php _e("Delete") ?></a> | </span>
                    </div>
                </td>
                <td class="">
                    <code><?php echo esc_html( $item["name"] ) ?></code>
                </td>
                <td class="">
                    <?php if( $item["type"] == "options" ): ?>
                    <?php echo __( "Predefined Options", "wpadverts-custom-fields" ) ?>
                    <br/><small><?php echo sprintf( __( "%d options", "wpadverts-custom-fields" ), count( $item["options"] ) ) ?></small>
                    <?php elseif( $item["type"] == "callback" ): ?>
                    <?php echo __( "Callback Function", "wpadverts-custom-fields" ) ?>
                    <br/><small><?php echo $item["callback"] ?></small>
                    <?php elseif( $item["type"] == "taxonomy" ): ?>
                    <?php echo __( "Taxonomy", "wpadverts-custom-fields" ) ?>
                    <br/><small><?php echo $item["taxonomy"] . " " . $item["args"] ?></small>
                    <?php endif; ?>
                </td>


            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>

</div>
