2015-05-09 02:31:32 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class FontAwesomeField
|
|
|
|
*/
|
2015-05-09 04:58:24 +02:00
|
|
|
class FontAwesomeField extends TextField
|
2015-05-09 02:31:32 +02:00
|
|
|
{
|
|
|
|
public function Type()
|
|
|
|
{
|
2015-05-09 04:58:24 +02:00
|
|
|
return 'text';
|
2015-05-09 02:31:32 +02:00
|
|
|
}
|
|
|
|
|
2015-05-09 04:58:24 +02:00
|
|
|
public function Field($properties = array())
|
2015-05-09 02:31:32 +02:00
|
|
|
{
|
2015-05-09 04:58:24 +02:00
|
|
|
$this->addExtraClass('form-control icp icp-auto');
|
|
|
|
|
2015-05-09 05:55:15 +02:00
|
|
|
Requirements::combine_files('font-awesome-module.css', array(
|
|
|
|
'font-awesome/code/vendor/bootstrap-3.3.4/css/bootstrap.min.css',
|
|
|
|
'font-awesome/css/font-awesome.min.css',
|
|
|
|
'font-awesome/code/vendor/fontawesome-iconpicker-1.0.0/dist/css/fontawesome-iconpicker.min.css',
|
|
|
|
'font-awesome/css/font-awesome-module.css',
|
|
|
|
));
|
2015-05-09 04:58:24 +02:00
|
|
|
|
|
|
|
Requirements::set_force_js_to_bottom(true);
|
|
|
|
Requirements::javascript('font-awesome/code/vendor/fontawesome-iconpicker-1.0.0/dist/js/fontawesome-iconpicker.min.js');
|
2015-05-09 05:55:15 +02:00
|
|
|
Requirements::javascript('font-awesome/js/font-awesome-module.js');
|
|
|
|
|
|
|
|
Requirements::set_combined_files_folder(ASSETS_DIR . '/_combinedfiles/font-awesome');
|
2015-05-09 04:58:24 +02:00
|
|
|
|
|
|
|
return parent::Field($properties);
|
2015-05-09 02:31:32 +02:00
|
|
|
}
|
2015-05-09 05:55:15 +02:00
|
|
|
|
|
|
|
public function validate($validator)
|
|
|
|
{
|
|
|
|
if(!empty ($this->value) && !preg_match('/^fa-[a-z]+/', $this->value))
|
|
|
|
{
|
|
|
|
$validator->validationError(
|
|
|
|
$this->name,
|
|
|
|
_t('FontAwesomeIconPickerField.VALIDFONT', 'Please enter a valid Font Awesome font name format.'),
|
|
|
|
'validation',
|
|
|
|
false
|
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-09 02:31:32 +02:00
|
|
|
}
|