本文整理汇总了PHP中OptionsetField::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsetField::__construct方法的具体用法?PHP OptionsetField::__construct怎么用?PHP OptionsetField::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionsetField
的用法示例。
在下文中一共展示了OptionsetField::__construct方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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');
}
示例2: __construct
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);
}
示例3: array
function __construct($name, $title = '', $options = array(), $value = '', $folderID)
{
$this->setOptions($options);
$this->setFolderID($folderID);
$this->createObjects();
parent::__construct($name, $title, $options, $value);
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-product-questions,代码行数:7,代码来源:ProductQuestionImageSelectorField.php
示例4: array
/**
* 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);
}
示例5: array
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);
}
示例6: array
/**
* 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);
}
示例7: __construct
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);
}
示例8: __construct
/**
* 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');
}
示例9: array
function __construct($name, $title = "", $source = array(), $value = "", $form = null)
{
parent::__construct($name, $title, $source, $value, $form);
Requirements::css('sapphire/css/CheckboxSetField.css');
}
示例10: __construct
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;
}
示例11: __construct
/**
* 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);
}