/** * Construct the field * * @param string $name * @param null|string $title * @param string $sourceFolder **/ public function __construct($name, $title = null, $sourceFolder = '/site/icons/') { parent::__construct($name, $title, null); $sourcePath = BASE_PATH . $sourceFolder; // image extensions $extensions = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg'); // init result $icons = array(); // directory to scan $directory = new DirectoryIterator($sourcePath); // iterate foreach ($directory as $fileinfo) { // must be a file if ($fileinfo->isFile()) { // file extension $extension = strtolower(pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION)); // check if extension match if (in_array($extension, $extensions)) { $icons[$sourceFolder . $fileinfo->getFilename()] = $fileinfo->getFilename(); } } } $this->source = $icons; Requirements::css(DEVTOOLS_DIR . '/css/IconSelectField.css'); Requirements::javascript(DEVTOOLS_DIR . '/js/IconSelectField.js'); }
public function __construct($name, $title = null, $source = array(), $value = '', $form = null, $emptyString = null) { if (empty($source)) { $source = array(self::VALUE_YES => _t('YesNoOptionsetField.YES', 'Yes'), self::VALUE_NO => _t('YesNoOptionsetField.NO', 'No')); } parent::__construct($name, $title, $source, $value, $form, $emptyString); }
function __construct($name, $title = '', $options = array(), $value = '', $folderID) { $this->setOptions($options); $this->setFolderID($folderID); $this->createObjects(); parent::__construct($name, $title, $options, $value); }
/** * Creates a new optionset field. * @param name The field name * @param title The field title * @param source DataObjectSet * @param value The current value * @param form The parent form */ function __construct($name, $title = "", $addresses = null, $value = "", $form = null) { $this->addresses = $addresses; $source = array(); if ($this->addresses) { $source = $this->addresses->map("ID", "FullString"); } parent::__construct($name, $title, $source, $value, $form); }
function __construct($name, $title = '', $value = '', $objects, $imageFieldName = "Image", $width = 32, $height = 16) { $array = array(); if ($objects) { $array = $objects->toDropDownMap(); $this->objects = $objects; } $this->imageFieldName = $imageFieldName; $this->width = $width; $this->height = $height; parent::__construct($name, $title, $array, $value); }
/** * Creates a new optionset field. * @param String $name The field name * @param String $title The field title * @param ArrayList $addresses * @param String $value The current value * @param Form $form - The parent form */ function __construct($name, $title = "", $addresses = null, $value = "", Form $form = null) { $this->addresses = $addresses; $source = array(); if ($this->addresses && $this->addresses instanceof ArrayList) { $source = array(); foreach ($this->addresses as $address) { $source[$address->ID] = $address->FullString(); } } parent::__construct($name, $title, $source, $value, $form); }
public function __construct(DataObject $controller, $name, $title = null, $className = null, $source = array(), $addTitle = null, $defaultsProperties = array(), $form = null) { $hasOne = false; if (!$title) { $this->title = self::name_to_label($name); } if (!$className) { if (substr($name, -2) == 'ID') { $name = substr($name, 0, -2); } if (!($hasOne = $className = $controller->has_one($name)) && !($className = $controller->belongs_to($name)) && (($settings = $controller->has_many($name)) || ($settings = $controller->many_many($name)))) { if (is_array($settings)) { $className = $settings[1]; } else { $className = $settings; } $this->fieldType = 'CheckboxSetField'; } if (!$className) { trigger_error('Couldn\'t determine class type from field name "' . $name . '". Please define the class name.'); } if ($hasOne) { $name .= 'ID'; } } else { if ($rels = $controller->has_many() + $controller->many_many()) { foreach ($rels as $rel => $class) { if ($class == $className || ClassInfo::is_subclass_of($class, $className)) { $this->fieldType = 'CheckboxSetField'; break; } } } } if (!class_exists($className)) { trigger_error($className . ' class doesn\'t exist'); } $this->setDefaults($defaultsProperties); $this->className = $className; $this->controller = $controller; parent::__construct($name, $title, $source, null, $form); }
/** * Constructor * * @param string $name The field name * @param string $title The field title * @param array $source An map of the dropdown items * @param string $value The current value * @param Form $form The parent form */ public function __construct($name, $title = null, $source = array(), $value = '', $form = null) { parent::__construct($name, $title, $source, $value, $form); $this->addExtraClass('optionset'); }
function __construct($name, $title = "", $source = array(), $value = "", $form = null) { parent::__construct($name, $title, $source, $value, $form); Requirements::css('sapphire/css/CheckboxSetField.css'); }
public function __construct($name, $title = null, $source = array(), $value = '', $form = null, $emptyString = null, IMultiValueQuestionTemplate $question) { parent::__construct($name, $title, $source, $value, $form, $emptyString); $this->question = $question; }
/** * ImageOptionsetField constructor. * @param string $name * @param null|string $title * @param array|ArrayAccess $source * @param string $value * @param Form|null $form * @param null $emptyString */ public function __construct($name, $title = null, $source = array(), $value = '', $form = null, $emptyString = null) { $this->imageWidth = $this->config()->default_image_width; $this->imageHeight = $this->config()->default_image_height; parent::__construct($name, $title, $source, $value, $form, $emptyString); }