Merge branch 'master' of https://github.com/tainacan/tainacan
This commit is contained in:
commit
364b30cff6
|
@ -4,6 +4,7 @@ namespace Tainacan\Field_Types;
|
||||||
|
|
||||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
|
|
||||||
|
use Tainacan\Helpers;
|
||||||
/**
|
/**
|
||||||
* Class TainacanFieldType
|
* Class TainacanFieldType
|
||||||
*/
|
*/
|
||||||
|
@ -23,4 +24,22 @@ class Date extends Field_Type {
|
||||||
public function render( $metadata ){
|
public function render( $metadata ){
|
||||||
return '<tainacan-date name="'.$metadata->get_name().'"></tainacan-date>';
|
return '<tainacan-date name="'.$metadata->get_name().'"></tainacan-date>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate the fields for this field type
|
||||||
|
*/
|
||||||
|
public function form(){
|
||||||
|
$approx_date = ( $this->options['approximate_date'] ) ? $this->options['approximate_date'] : '';
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label><?php echo __('Approximate Date','tainacan'); ?></label><br/>
|
||||||
|
<small><?php echo __('Allow format approximate date','tainacan'); ?></small>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php Helpers\HtmlHelpers::radio_field( $approx_date, 'field_type_date[approximate_date]' ) ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -43,6 +43,7 @@ class Relationship extends Field_Type {
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><?php echo __('Metadata for search','tainacan'); ?></label><br/>
|
<label><?php echo __('Metadata for search','tainacan'); ?></label><br/>
|
||||||
|
<small><?php echo __('Selected metadata to help in the search','tainacan'); ?></small>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php Helpers\HtmlHelpers::metadata_checkbox_list(
|
<?php Helpers\HtmlHelpers::metadata_checkbox_list(
|
||||||
|
@ -59,7 +60,7 @@ class Relationship extends Field_Type {
|
||||||
<small><?php echo __('Allow/Block selected items in this relationship','tainacan'); ?></small>
|
<small><?php echo __('Allow/Block selected items in this relationship','tainacan'); ?></small>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea name="field_type_relationship[repeated]"><?php echo ( isset( $this->options['repeated'] ) ) ? $this->options['repeated'] : 'yes'; ?></textarea>
|
<?php Helpers\HtmlHelpers::radio_field( ( isset( $this->options['repeated'] ) ) ? $this->options['repeated'] : 'yes', 'field_type_relationship[repeated]' ) ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if( isset( $this->options['collection_id'] ) ): ?>
|
<?php if( isset( $this->options['collection_id'] ) ): ?>
|
||||||
|
|
|
@ -23,4 +23,11 @@ class Textarea extends Field_Type {
|
||||||
public function render( $metadata ){
|
public function render( $metadata ){
|
||||||
return '<tainacan-textarea name="'.$metadata->get_name().'"></tainacan-textarea>';
|
return '<tainacan-textarea name="'.$metadata->get_name().'"></tainacan-textarea>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate the fields for this field type
|
||||||
|
*/
|
||||||
|
public function form(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -56,7 +56,7 @@ use Tainacan\Entities;
|
||||||
$metadata = $Tainacan_Metadatas->fetch_by_collection( $collection, $args, 'OBJECT');
|
$metadata = $Tainacan_Metadatas->fetch_by_collection( $collection, $args, 'OBJECT');
|
||||||
?>
|
?>
|
||||||
<select name="<?php echo $name_field ?>">
|
<select name="<?php echo $name_field ?>">
|
||||||
<option value=""><?php echo __('Select','tainacan') ?></option>
|
<option value=""><?php echo __('Select an option','tainacan') ?>...</option>
|
||||||
<?php foreach ($metadata as $col): ?>
|
<?php foreach ($metadata as $col): ?>
|
||||||
<option value="<?php echo $col->get_id(); ?>" <?php selected($col->get_id(), $selected) ?>><?php echo $col->get_name(); ?></option>
|
<option value="<?php echo $col->get_id(); ?>" <?php selected($col->get_id(), $selected) ?>><?php echo $col->get_name(); ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
@ -88,5 +88,19 @@ use Tainacan\Entities;
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generates the radio button with options
|
||||||
|
*
|
||||||
|
* @param string $selected The value to be selectred
|
||||||
|
* @param string $name_field (optional) the radio field name
|
||||||
|
* @param array $options (optional) Associative array, indexes are the radio values and the values are the labels. Default yes and no
|
||||||
|
*/
|
||||||
|
public static function radio_field( $selected, $name_field = 'radio_field', $options = [ 'yes' => 'Yes', 'no' => 'No' ]){
|
||||||
|
foreach ($options as $value => $option): ?>
|
||||||
|
<input type="radio" name="<?php echo $name_field ?>" value="<?php echo $value; ?>" <?php checked($value == $selected); ?> style="width: 15px;">
|
||||||
|
<?php echo $option; ?>
|
||||||
|
<br/>
|
||||||
|
<?php endforeach;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue