| 1 |
<?php |
| 2 |
|
| 3 |
include_once __DIR__.DIRECTORY_SEPARATOR.'AcymJFormField.php'; |
| 4 |
|
| 5 |
class JFormFieldArticle extends AcymJFormField |
| 6 |
{ |
| 7 |
var $type = 'article'; |
| 8 |
|
| 9 |
public function getInput() |
| 10 |
{ |
| 11 |
$modalId = 'acym_article_'.$this->id; |
| 12 |
$callback = 'jSelectArticle_'.$this->id; |
| 13 |
|
| 14 |
$title = ''; |
| 15 |
$value = intval($this->value); |
| 16 |
if (!empty($value)) { |
| 17 |
$title = acym_CMSArticleTitle($value); |
| 18 |
} |
| 19 |
|
| 20 |
acym_addScript( |
| 21 |
true, |
| 22 |
" |
| 23 |
function $callback(id, title, catid, object, url, language) { |
| 24 |
window.processModalSelect('Article', '".$this->id."', id, title, catid, object, url, language); |
| 25 |
toggle_$callback(id); |
| 26 |
jQuery('#".$modalId."').modal('hide'); |
| 27 |
} |
| 28 |
|
| 29 |
function toggle_$callback(selection) { |
| 30 |
if (selection && selection > 0) { |
| 31 |
jQuery('#button_$modalId').hide(); |
| 32 |
jQuery('#clear_$modalId').show(); |
| 33 |
} else { |
| 34 |
jQuery('#".$this->id."_name').val(''); |
| 35 |
jQuery('#".$this->id."_id').val(''); |
| 36 |
|
| 37 |
jQuery('#button_$modalId').show(); |
| 38 |
jQuery('#clear_$modalId').hide(); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
jQuery(function($){ |
| 43 |
toggle_$callback($value); |
| 44 |
});" |
| 45 |
); |
| 46 |
|
| 47 |
$html = '<span class="input-append">'; |
| 48 |
$html .= '<input class="input-medium" id="'.$this->id.'_name" type="text" value="'.acym_escape($title).'" disabled="disabled" size="35" />'; |
| 49 |
$urlSelect = acym_articleSelectionPage().'&function='.$callback; |
| 50 |
$html .= acym_cmsModal(true, $urlSelect, 'ACYM_SELECT', true, acym_translation('ACYM_SELECT_AN_ARTICLE'), $modalId); |
| 51 |
$html .= '<a id="clear_'.$modalId.'" class="btn hasTooltip" data-toggle="modal" role="button" onclick="toggle_'.$callback.'(0);">'.acym_translation('ACYM_CLEAR').'</a>'; |
| 52 |
$html .= '</span>'; |
| 53 |
|
| 54 |
$html .= '<input type="hidden" id="'.$this->id.'_id" name="'.$this->name.'" value="'.$value.'" />'; |
| 55 |
|
| 56 |
return $html; |
| 57 |
} |
| 58 |
|
| 59 |
public function getLabel() |
| 60 |
{ |
| 61 |
return str_replace($this->id, $this->id.'_id', parent::getLabel()); |
| 62 |
} |
| 63 |
} |
| 64 |
|