private function contributor_form($form_args, $contributor, $action)
 {
     $general_fields = ['realname' => ['field_type' => 'string', 'field_options' => array('label' => __('Real name', 'podlove'), 'html' => array('class' => 'podlove-check-input required podlove-contributor-field'))], 'publicname' => ['field_type' => 'string', 'field_options' => array('label' => __('Public name', 'podlove'), 'description' => 'The Public Name will be used for public mentions. E.g. the Web Player. If left blank, it defaults to the "real name".', 'html' => array('class' => 'podlove-check-input podlove-contributor-field'))], 'nickname' => ['field_type' => 'string', 'field_options' => array('label' => __('Nickname', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field'))], 'gender' => ['field_type' => 'select', 'field_options' => array('label' => __('Gender', 'podlove'), 'options' => array('female' => 'Female', 'male' => 'Male', 'none' => 'Not attributed'))], 'privateemail' => ['field_type' => 'string', 'field_options' => array('label' => __('Contact email', 'podlove'), 'description' => 'The provided email will be used for internal purposes only.', 'html' => array('class' => 'podlove-contributor-field podlove-check-input', 'data-podlove-input-type' => 'email'))], 'avatar' => ['field_type' => 'avatar', 'field_options' => array('label' => __('Avatar', 'podlove'), 'description' => 'Either a Gravatar email adress or a URL.', 'html' => array('class' => 'podlove-contributor-field podlove-check-input', 'data-podlove-input-type' => 'avatar'))], 'slug' => ['field_type' => 'string', 'field_options' => array('label' => __('ID', 'podlove'), 'description' => 'The ID will be used as in internal identifier for e.g. shortcodes.', 'html' => array('class' => 'podlove-check-input required podlove-contributor-field'))], 'guid' => ['field_type' => 'string', 'field_options' => array('label' => __('URI', 'podlove'), 'description' => __('An URI acts as a globally unique ID to identify contributors across podcasts on the internet.', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field'))], 'visibility' => ['field_type' => 'radio', 'field_options' => array('label' => __('Visibility', 'podlove'), 'options' => array('1' => 'Yes, the contributor’s information will be visible for the public (e.g. displayed in the Contributor Table).<br />', '0' => 'No, the contributor’s information will be private and not visible for anybody.'), 'default' => '1')]];
     $general_fields = apply_filters('podlove_contributors_general_fields', $general_fields);
     $affiliation_fields = ['organisation' => ['field_type' => 'string', 'field_options' => ['label' => __('Organisation', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field')]], 'department' => ['field_type' => 'string', 'field_options' => ['label' => __('Department', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field')]], 'jobtitle' => ['field_type' => 'string', 'field_options' => ['label' => __('Job Title', 'podlove'), 'html' => array('class' => 'podlove-check-input podlove-contributor-field')]]];
     $affiliation_fields = apply_filters('podlove_contributors_affiliation_fields', $affiliation_fields);
     $form_sections = ['general' => ['title' => __('General', 'podlove'), 'fields' => $general_fields], 'affiliation' => ['title' => __('Affiliation', 'podlove'), 'fields' => $affiliation_fields]];
     $form_sections = apply_filters('podlove_contributor_settings_sections', $form_sections);
     $contributor = \Podlove\Modules\Contributors\Model\Contributor::find_by_id($_REQUEST['contributor']);
     switch ($_GET["action"]) {
         case 'new':
             $action = 'create';
             break;
         case 'edit':
             $action = 'save';
             break;
         default:
             $action = 'delete';
             break;
     }
     \Podlove\Form\build_for($contributor, $form_args, function ($form) use($form_sections) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $contributor = $form->object;
         foreach ($form_sections as $form_section) {
             $wrapper->subheader($form_section['title']);
             foreach ($form_section['fields'] as $field_name => $field) {
                 call_user_func_array([$wrapper, $field['field_type']], [$field_name, $field['field_options']]);
             }
         }
     });
 }
예제 #2
0
 private function form_template($feed, $action, $button_text = NULL)
 {
     $form_args = array('context' => 'podlove_feed', 'hidden' => array('feed' => $feed->id, 'action' => $action), 'submit_button' => false, 'form_end' => function () {
         echo "<p>";
         submit_button(__('Save Changes'), 'primary', 'submit', false);
         echo " ";
         submit_button(__('Save Changes and Continue Editing', 'podlove'), 'secondary', 'submit_and_stay', false);
         echo "</p>";
     });
     \Podlove\Form\build_for($feed, $form_args, function ($form) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $feed = $form->object;
         $podcast = \Podlove\Model\Podcast::get();
         $episode_assets = \Podlove\Model\EpisodeAsset::all();
         $assets = array();
         foreach ($episode_assets as $asset) {
             $assets[$asset->id] = $asset->title;
         }
         $wrapper->subheader(__('Basic Settings', 'podlove'));
         $wrapper->select('episode_asset_id', array('label' => __('Episode Media File', 'podlove') . \Podlove\get_help_link('podlove_help_feed_asset'), 'options' => $assets, 'html' => array('class' => 'required')));
         $wrapper->string('name', array('label' => __('Feed Name', 'podlove'), 'description' => __('Some podcast clients may display this title to describe the feed content.', 'podlove'), 'html' => array('class' => 'regular-text required podlove-check-input')));
         $wrapper->checkbox('append_name_to_podcast_title', array('label' => __('Append Feed Name to Podcast title', 'podlove'), 'description' => sprintf(__('Structure of the feed title. Preview: %s', 'podlove'), $podcast->title . '<span id="feed_title_preview_append"></span>'), 'default' => false));
         $wrapper->string('slug', array('label' => __('Slug', 'podlove') . \Podlove\get_help_link('podlove_help_feed_slug'), 'description' => $feed ? sprintf(__('Feed identifier. URL Preview: %s', 'podlove'), '<span id="feed_subscribe_url_preview">' . $feed->get_subscribe_url() . '</span>') : '', 'html' => array('class' => 'regular-text required podlove-check-input')));
         $wrapper->checkbox('discoverable', array('label' => __('Discoverable?', 'podlove'), 'description' => __('Embed a meta tag into the head of your site so browsers and feed readers will find the link to the feed.', 'podlove'), 'default' => true));
         $wrapper->checkbox('embed_content_encoded', array('label' => __('Include HTML Content', 'podlove'), 'description' => __('Include episode show notes in the feed.', 'podlove'), 'default' => false));
         $wrapper->subheader(__('Directory Settings', 'podlove'));
         $wrapper->checkbox('enable', array('label' => __('Allow Submission to Directories', 'podlove'), 'description' => __('Allow this feed to appear in podcast directories.', 'podlove'), 'default' => true));
         do_action('podlove_feeds_directories', $wrapper);
         $wrapper->string('itunes_feed_id', array('label' => __('iTunes Feed ID', 'podlove'), 'description' => __('Is used to generate a link to the iTunes directory.', 'podlove') . ($feed->itunes_feed_id ? ' <a href="http://itunes.apple.com/podcast/id' . $feed->itunes_feed_id . '" target="_blank">' . __('Open in iTunes directory') . '</a>' : ''), 'html' => array('class' => 'regular-text podlove-check-input')));
         $wrapper->subheader(__('Advanced Settings', 'podlove'));
         $wrapper->select('redirect_http_status', array('label' => __('Redirect Method', 'podlove'), 'description' => __('', 'podlove'), 'options' => array('0' => 'Don\'t redirect', '307' => 'Temporary Redirect (HTTP Status 307)', '301' => 'Permanent Redirect (HTTP Status 301)'), 'default' => 0, 'please_choose' => false));
         $wrapper->string('redirect_url', array('label' => __('Redirect Url', 'podlove'), 'description' => __('e.g. Feedburner URL', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'url')));
         $podcast_settings = get_option('podlove_podcast');
         if ($podcast_settings['limit_items'] < 0) {
             $limit_default = 'No limit';
         } else {
             $limit_default = $podcast_settings['limit_items'];
         }
         $limit_options = array('-2' => __("Use Podlove default (" . $limit_default . ")", 'podlove'), '-1' => __("No limit. Include all items.", 'podlove'), '0' => __('Use WordPress Default', 'podlove') . ' (' . get_option('posts_per_rss') . ')');
         for ($i = 1; $i * 5 <= 100; $i++) {
             $limit_options[$i * 5] = $i * 5;
         }
         $wrapper->select('limit_items', array('label' => __('Limit Items', 'podlove'), 'description' => __('If you have a lot of episodes, you might want to restrict the feed size.', 'podlove'), 'options' => $limit_options, 'please_choose' => false, 'default' => '-2'));
         $wrapper->subheader(__('Protection', 'podlove'));
         $wrapper->checkbox('protected', array('label' => __('Protect feed ', 'podlove'), 'description' => __('The feed will be protected by HTTP Basic Authentication.', 'podlove'), 'default' => false));
         $wrapper->select('protection_type', array('label' => __('Method', 'podlove'), 'description' => __('', 'podlove'), 'options' => array('0' => 'Custom Login', '1' => 'WordPress User database'), 'default' => -1, 'please_choose' => true));
         $wrapper->string('protection_user', array('label' => __('Username', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text required')));
         $wrapper->string('protection_password', array('label' => __('Password', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text required')));
         do_action('podlove_feed_settings_bottom', $wrapper);
     });
 }