public function test_takes_select_options_from_the_model()
 {
     // Having
     Form::model(new \App\User());
     // Expect
     $this->assertTemplate('fields/select_model', Field::select('gender'));
 }
Example #2
0
 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM company_info WHERE company_id = :company_id LIMIT 1;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company_id', $id, PDO::PARAM_INT);
         $query->execute();
         if ($query->rowCount() < 1) {
             return null;
         }
         $row = $query->fetch(PDO::FETCH_ASSOC);
         $companyInfo = new CompanyInfo();
         $companyInfo->Id = (int) $row['id'];
         $companyInfo->Logo = $row['info_logo'];
         $companyInfo->Alert = (int) $row['info_alert'];
         $companyInfo->Notify = (int) $row['info_noti'];
         $companyInfo->Theme = (int) $row['info_theme'];
         $companyInfo->Field = Field::select($row['e_field_id']);
         $companyInfo->Company = Company::select($row['company_id']);
         return $companyInfo;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Example #3
0
<?php

/*-----------------------------------------------------------------------*/
// Match Custom Post
/*-----------------------------------------------------------------------*/
$match = PostType::make('slhb_match', 'Les matchs', 'match')->set(array('public' => true, 'menu_position' => 20, 'supports' => false, 'rewrite' => false, 'query_var' => false, 'labels' => ['add_new' => 'Ajouter un nouveau match', 'add_item' => 'Ajouter un match', 'all_items' => 'Tous les matchs', 'edit_item' => 'Modifier un match']));
/*-----------------------------------------------------------------------*/
// Match informations
/*-----------------------------------------------------------------------*/
$infos = Metabox::make('Informations du match', $match->get('name'))->set(array(Field::date('match_date', ['title' => 'Date du match']), Field::select('match_team_dom', TeamModel::getTeamsArray()), Field::text('match_team_ext', ['title' => 'Equipe à l\'exterieur']), Field::number('score_dom', ['title' => 'Score de l\'équipe à domicile']), Field::number('score_ext', ['title' => 'Score de l\'équipe extérieur'])));
/*-----------------------------------------------------------------------*/
// Match Defaults Values
/*-----------------------------------------------------------------------*/
function slhb_set_title($post_id, $post, $update)
{
    $dateStr = Meta::get($post_id, 'match_date');
    $title = $dateStr . ' - ' . Meta::get($post_id, 'match_team_dom') . ' - ' . Meta::get($post_id, 'match_team_ext');
    $date = date($dateStr);
    //This temporarily removes filter to prevent infinite loops
    remove_action('save_post_slhb_match', __FUNCTION__);
    wp_update_post(array('ID' => $post_id, 'post_title' => $title, 'match_date' => $date));
    //redo filter
    add_action('save_post_slhb_match', __FUNCTION__, 10, 3);
}
add_action('save_post_slhb_match', 'slhb_set_title', 10, 3);
Example #4
0
<?php

$page = Page::make('theme-option', 'Option du theme')->set();
$sections = [Section::make('theme-option-general', __('General', THEME_TEXT_DOMAIN)), Section::make('theme-option-info', __("Society Information", THEME_TEXT_DOMAIN)), Section::make('theme-option-social', __("Social Network", THEME_TEXT_DOMAIN)), Section::make('theme-option-custom-code', __('Code', THEME_TEXT_DOMAIN)), Section::make('theme-option-analytic', __('Analytics', THEME_TEXT_DOMAIN)), Section::make('theme-option-image', __('Default Images', THEME_TEXT_DOMAIN))];
$settings = ['theme-option-general' => [Field::text('name', ['title' => __('Name', THEME_TEXT_DOMAIN)]), Field::text('separator', ['title' => __('Title separator', THEME_TEXT_DOMAIN), 'default' => '-']), Field::select('seplocation', [['right' => __("Right", THEME_TEXT_DOMAIN), 'left' => __("Left", THEME_TEXT_DOMAIN)]], ['title' => __("Title separator emplacement", THEME_TEXT_DOMAIN), 'default' => 'right']), Field::checkbox('showAuthor', ['activate' => 'Afficher l\'auteur'])], 'theme-option-custom-code' => [Field::textarea('javascript', ['title' => __('Javascript', THEME_TEXT_DOMAIN)], ['id' => 'javascript-editor', "class" => "hidden"]), Field::textarea('style', ['title' => __('Style', THEME_TEXT_DOMAIN)], ['id' => 'style-editor', "class" => "hidden"])], 'theme-option-info' => [Field::text('name', ['title' => __('Name', THEME_TEXT_DOMAIN)]), Field::textarea('biography', ['title' => __('Biography', THEME_TEXT_DOMAIN)]), Field::text('address', ['title' => __('Address', THEME_TEXT_DOMAIN)]), Field::text('phoneNumberPrimary', ['title' => __('Phone Number', THEME_TEXT_DOMAIN)], ['type' => 'tel']), Field::text('phoneNumberSecondary', ['title' => __('Phone Number', THEME_TEXT_DOMAIN)], ['type' => 'tel']), Field::text('emailPrimary', ['title' => __('Phone Number', THEME_TEXT_DOMAIN)], ['type' => 'email']), Field::text('emailSecondary', ['title' => __('Phone Number', THEME_TEXT_DOMAIN)], ['type' => 'email'])], 'theme-option-analytic' => [], 'theme-option-social' => [Field::text('facebook', ['title' => 'Facebook'], ['type' => 'url']), Field::text('twitter', ['title' => 'Twitter'], ['type' => 'url']), Field::text('google-plus', ['title' => 'Google plus'], ['type' => 'url']), Field::text('linkedin', ['title' => 'linkedIn'], ['type' => 'url']), Field::text('youtube', ['title' => 'YouTube'], ['type' => 'url']), Field::text('vkontakte', ['title' => 'Vkontakte'], ['type' => 'url']), Field::text('instagram', ['title' => 'Instagram'], ['type' => 'url']), Field::text('rss', ['title' => 'Feed'])], 'theme-option-image' => [Field::media('favicon', ['title' => __("Favicon", THEME_TEXT_DOMAIN)]), Field::media('logo', ['title' => __("Logo", THEME_TEXT_DOMAIN)])]];
$validation = ['name' => ['min:3', 'textfield'], 'facebook' => ['url'], 'twitter' => ['url'], 'google-plus' => ['url'], 'linkedin' => ['url'], 'youtube' => ['url'], 'vkontakte' => ['url'], 'Instagram' => ['url'], 'rss' => ['url']];
$page->addSections($sections);
$page->addSettings($settings);
$page->validate($validation);
Example #5
0
    }
});
//=============================================================================
//Field
//=============================================================================
Flight::route('GET /v1/main/field', function () {
    try {
        $array = Field::selectAll();
        Flight::ok($array);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('GET /v1/main/field/@id', function ($id) {
    try {
        $object = Field::select($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/field', function () {
    try {
        $object = Field::insert();
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/field/@id', function ($id) {
    try {
Example #6
0
 /**
  * Set up timeslot custom post type
  *
  * @private
  */
 private static function _set_up_timeslot()
 {
     PostType::make('timeslot', 'Time Slots', 'Time Slot')->set();
     $fields = array(Field::select('timeslot_venue', array(array('none' => __('- None -')) + VenueModel::venueSelection()), array('title' => __('Venue'))), Field::select('timeslot_user', array(array('none' => __('- None -')) + UserModel::userSelection()), array('title' => __('User'))), Field::date('date', array('title' => 'Date')), Field::select('time_from', array(Config::get('application.timeslots')), array('title' => __('Start at'))), Field::select('time_to', array(Config::get('application.timeslots')), array('title' => __('Finish at'))));
     Metabox::make('Options', 'timeslot')->set($fields);
 }
Example #7
0
<?php

/*-----------------------------------------------------------------------*/
// Home/Front page.
/*-----------------------------------------------------------------------*/
$home = (int) get_option('page_on_front');
if (themosis_is_post($home)) {
    $books = new Books();
    // Metabox for the front page.
    Metabox::make('Book promo', 'page')->set(array(Field::select('book-promo', array($books->published()), false, array('title' => 'Book', 'info' => 'Choose a book to promote on the home page.'))));
}
/*-----------------------------------------------------------------------*/
// Remove editor from home page.
/*-----------------------------------------------------------------------*/
add_action('init', function () use($home) {
    if (themosis_is_post($home)) {
        remove_post_type_support('page', 'editor');
    }
});
Example #8
0
<?php

$team = PostType::make('slhb_team', 'Les équipes', 'équipe')->set(array('public' => true, 'menu_position' => 20, 'supports' => array('title', 'editor'), 'rewrite' => false, 'query_var' => false, 'labels' => ['add_new_item' => 'Ajouter une nouvelle équipe', 'add_new' => 'Ajouter une équipe', 'add_item' => 'Ajouter une équipe', 'all_items' => 'Toutes les équipes', 'edit_item' => 'Modifier une équipe']));
/*-----------------------------------------------------------------------*/
// Team informations
/*-----------------------------------------------------------------------*/
$infos = Metabox::make('Informations sur l\'équipe', $team->get('name'))->set(array(Field::media('profile', ['title' => 'Photo de groupe de l\'équipe ']), Field::select('Niveau', [['Excellence Région', 'Honneur Région', 'Pré-Région', 'Deuxième division']], ['title' => 'Quelle division? ']), Field::collection('gallery')));