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
|
|
|
{
|
2015-05-10 02:00:14 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
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-10 02:00:14 +02:00
|
|
|
/**
|
|
|
|
* @param array $properties
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
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-10 02:00:14 +02:00
|
|
|
Requirements::css('font-awesome/css/lib/bootstrap.min.css');
|
|
|
|
Requirements::css('font-awesome/css/lib/font-awesome.min.css');
|
|
|
|
Requirements::css('font-awesome/code/vendor/fontawesome-iconpicker-1.0.0/dist/css/fontawesome-iconpicker.min.css');
|
|
|
|
Requirements::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');
|
|
|
|
|
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
|
|
|
|
2015-05-10 02:00:14 +02:00
|
|
|
/**
|
|
|
|
* @param $validator
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
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(
|
2015-05-10 02:00:14 +02:00
|
|
|
$this->name, 'Please enter a valid Font Awesome font name format.', 'validation', false
|
2015-05-09 05:55:15 +02:00
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-09 02:31:32 +02:00
|
|
|
}
|