/** * Add an item of type BaseField to the field collection * * @param BaseField $objItem */ public function addItem(BaseField $objItem) { $this->items[] = $objItem; end($this->items); $key = key($this->items); $this->index[$key] = $objItem->get('colName'); }
public function headline() { if (!$this->readonly) { /* $fieldName = $this->name; $blueprint = $this->page()->blueprint(); $fieldsets = $blueprint->fields($this)->$fieldName->fieldsets;*/ $fieldsets = $this->fieldsets(); $add = new Brick('a'); $add->html('<i class="icon icon-left fa fa-chevron-circle-down"></i>' . l('fields.structure.add')); $add->addClass('structure-add-button label-option'); $add->data('modal', true); $dropDown = new Brick("div"); $dropDown->addClass('builder-drop-down'); $addList = new Brick('ul'); $addList->addClass('builder-add-list'); foreach ($fieldsets as $fieldsetName => $fieldsetFields) { $addListItem = new Brick('li'); $addListItemLink = new Brick('a'); $addListItemLink->html('<i class="icon icon-left fa fa-plus-circle"></i>' . $fieldsetFields['label']); $addListItemLink->addClass('builder-add-button'); $addListItemLink->data('modal', true); $addListItemLink->attr('href', purl($this->page, 'field/' . $this->name . '/builder/add?fieldset=' . $fieldsetName)); $addListItem->append($addListItemLink); $addList->append($addListItem); } $dropDown->append($addList); } else { $addList = null; $add = null; } $label = BaseField::label(); $label->append($add); $label->append($dropDown); return $label; }
public function headline() { if (!$this->readonly) { $fieldName = $this->name; $blueprint = blueprint::find($this->page()); $fieldsets = $blueprint->fields()->{$fieldName}->fieldsets; $addDropdownHtml = '<div class="drop-down">'; $addDropdownHtml .= '<a class="drop-down-toggle label-option"><i class="icon icon-left fa fa-chevron-circle-down"></i>' . l('fields.structure.add') . '</a>'; $addDropdownHtml .= '<ul>'; foreach ($fieldsets as $fieldsetName => $fieldsetFields) { $addDropdownHtml .= '<li>'; $addDropdownHtml .= '<a href="#0" class="builder-add-button" data-fieldset="' . $fieldsetName . '"><i class="icon icon-left fa fa-plus-circle"></i>' . $fieldsetFields['label'] . '</a>'; $addDropdownHtml .= '</li>'; } $addDropdownHtml .= '</ul>'; $addDropdownHtml .= '</div>'; } else { $addButtons[] = null; } $label = parent::label(); $label->addClass('builder-label'); // foreach ($addButtons as $key => $value) { // $label->append($add[$key]); // } $label->append($addDropdownHtml); return $label; }
public function element() { $element = parent::element(); $script = new Brick('script', false); $script->append('previewImagesFromSidebar()'); $element->append($script); return $element; }
protected function getExtProperties() { $aPropriedades = parent::getExtProperties(); $aNovasProp = $this->TypeField->getCustomProperties(); foreach ($aNovasProp as $sCustomKey => $xValue) { $aPropriedades[$sCustomKey] = $xValue; } return $aPropriedades; }
public function result() { $yaml_result = parent::result(); $array_result = yaml($yaml_result); if ($this->fieldposition()) { return $array_result; } else { return $yaml_result; } }
public function headline() { $add = new Brick('a'); $add->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('fields.structure.add')); $add->addClass('structure-add-button label-option'); $add->attr('#'); $label = parent::label(); $label->addClass('structure-label'); $label->append($add); return $label; }
public function rules() { $rules = parent::rules(); $rules[] = [$this->getAttribute(), 'string', 'min' => strlen($this->min) ? (int) $this->min : null, 'max' => strlen($this->max) ? (int) $this->max : null, 'length' => strlen($this->length) ? (int) $this->length : null]; if (isset($this->required)) { $rules[] = [$this->getAttribute(), 'required']; } if (isset($this->pattern)) { $rules[] = [$this->getAttribute(), 'match', 'pattern' => $this->pattern]; } if (isset($this->email)) { $rules[] = [$this->getAttribute(), 'email']; } return $rules; }
public function result() { $result = parent::result(); $raw = (array) json_decode($result); $data = array(); foreach ($raw as $key => $row) { unset($row->_id); unset($row->_csfr); $data[$key] = (array) $row; } return yaml::encode($data); }
/** * Add a childnode to this node. * @param string $name property name * @param BaseField $node content (must be of type BaseField) */ public function addChildNode($name, $node) { $this->internalChildnodes[$name] = $node; $node->setParentNode($this); }
/** * parse model and config xml to object model using types in FieldTypes * @param SimpleXMLElement $xml model xml data (from items section) * @param SimpleXMLElement $config_data (current) config data * @param BaseField $internal_data output structure using FieldTypes,rootnode is internalData * @throws ModelException parse error */ private function parseXml($xml, &$config_data, &$internal_data) { // copy xml tag attributes to Field if ($config_data != null) { foreach ($config_data->attributes() as $AttrKey => $AttrValue) { $internal_data->setAttributeValue($AttrKey, $AttrValue->__toString()); } } // iterate model children foreach ($xml->children() as $xmlNode) { $tagName = $xmlNode->getName(); // every item results in a Field type object, the first step is to determine which object to create // based on the input model spec $fieldObject = null; $classname = "OPNsense\\Base\\FieldTypes\\" . $xmlNode->attributes()["type"]; if (class_exists($classname)) { // construct field type object $field_rfcls = new \ReflectionClass($classname); if (!$field_rfcls->getParentClass()->name == 'OPNsense\\Base\\FieldTypes\\BaseField') { // class found, but of wrong type. raise an exception. throw new ModelException("class " . $field_rfcls->name . " of wrong type in model definition"); } } else { // no type defined, so this must be a standard container (without content) $field_rfcls = new \ReflectionClass('OPNsense\\Base\\FieldTypes\\ContainerField'); } // generate full object name ( section.section.field syntax ) and create new Field if ($internal_data->__reference == "") { $new_ref = $tagName; } else { $new_ref = $internal_data->__reference . "." . $tagName; } $fieldObject = $field_rfcls->newInstance($new_ref, $tagName); // now add content to this model (recursive) if ($fieldObject->isContainer() == false) { $internal_data->addChildNode($tagName, $fieldObject); if ($xmlNode->count() > 0) { // if fieldtype contains properties, try to call the setters foreach ($xmlNode->children() as $fieldMethod) { $method_name = "set" . $fieldMethod->getName(); if ($field_rfcls->hasMethod($method_name)) { $fieldObject->{$method_name}($this->parseOptionData($fieldMethod)); } } } if ($config_data != null && isset($config_data->{$tagName})) { // set field content from config (if available) $fieldObject->setValue($config_data->{$tagName}->__toString()); } } else { // add new child node container, always try to pass config data if ($config_data != null && isset($config_data->{$tagName})) { $config_section_data = $config_data->{$tagName}; } else { $config_section_data = null; } if ($fieldObject instanceof ArrayField) { // handle Array types, recurring items if ($config_section_data != null) { foreach ($config_section_data as $conf_section) { // Array items are identified by a UUID, read from attribute or create a new one if (isset($conf_section->attributes()->uuid)) { $tagUUID = $conf_section->attributes()['uuid']->__toString(); } else { $tagUUID = $internal_data->generateUUID(); } // iterate array items from config data $child_node = new ContainerField($fieldObject->__reference . "." . $tagUUID, $tagName); $this->parseXml($xmlNode, $conf_section, $child_node); if (!isset($conf_section->attributes()->uuid)) { // if the node misses a uuid, copy it to this nodes attributes $child_node->setAttributeValue('uuid', $tagUUID); } $fieldObject->addChildNode($tagUUID, $child_node); } } else { // There's no content in config.xml for this array node. $tagUUID = $internal_data->generateUUID(); $child_node = new ContainerField($fieldObject->__reference . "." . $tagUUID, $tagName); $child_node->setInternalIsVirtual(); $this->parseXml($xmlNode, $config_section_data, $child_node); $fieldObject->addChildNode($tagUUID, $child_node); } } else { // All other node types (Text,Email,...) $this->parseXml($xmlNode, $config_section_data, $fieldObject); } // add object as child to this node $internal_data->addChildNode($xmlNode->getName(), $fieldObject); } } }
public function __construct($type, $name, $title = 'Field', $size = null) { parent::__construct($type, $name, $title); $this->setSize($size); }
public function element() { $element = parent::element(); $element->addClass('field-with-headline'); return $element; }
public function detailQueryField(&$dbhandle) { return array(parent::detailQueryField($dbhandle), $this->fieldname . '_' . $this->refname); }
public function label() { return parent::label(); }
public function element() { $element = parent::element(); $element->addClass('field-with-tab-title'); return $element; }
public function headline() { if (!$this->readonly) { $add = new Brick('a'); $add->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('fields.structure.add')); $add->addClass('structure-add-button label-option'); $add->data('modal', true); $add->attr('href', purl($this->model, 'field/' . $this->name . '/structure/add')); } else { $add = null; } // make sure there's at least an empty label if (!$this->label) { $this->label = ' '; } $label = parent::label(); $label->addClass('structure-label'); $label->append($add); return $label; }
/** * Generate label markup. * * @since 1.0.0 * * @return string */ public function label() { /* Edit button */ $edit = new Brick('a'); $edit->addClass('file-edit-button label-option'); $edit->html('<i class="icon icon-left fa fa-pencil"></i>' . l('pages.show.files.edit')); $edit->attr('href', $this->page()->url('files')); /* Add button */ $add = new Brick('a'); $add->addClass('file-add-button label-option'); $add->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('pages.show.files.add')); /** * FIX: With Kirby 2.2 the structure of the "Add file" actions changed. * Let's make sure we handle both the old >2.1 and the new 2.2+ ways. * * @since 1.5.0 */ if (version_compare(Kirby::version(), '2.2', '>=')) { $add->attr('href', '#upload'); $add->data('upload', 'true'); } else { $add->attr('href', purl($this->page(), 'upload')); } /* Actions container */ $actions = new Brick('span'); $actions->addClass('hgroup-option-right selector-hgroup-option-right'); $actions->append($edit); $actions->append($add); /* Label */ $label = parent::label(); /** * FIX: Fields don't have to have a label assigned. * With this, we deal with missing label information. * * @since 1.3.0 */ if (!is_null($label)) { $label->addClass('figure-label'); $label->append($actions); return $label; } return; }
function __construct($name = '--missing--', $label = '', $options = array()) { if (!isset($options['static_instance'])) { $options['static_instance'] = false; } parent::__construct($name, $label, $options); if (!isset($options['action_url']) && !$options['static_instance']) { throw new Exception('action_url option is required'); } }
public function value() { $value = parent::value(); return yaml::decode($value); }
/** * Convert result to markdown * * (1) This converts the HTML we get from the <textarea> to markdown * before it get's stored in the content file. * (2) Strip all wild <span> tags from the content as they might be inserted * by the JS editor. * * @since 1.0.0 * * @return string */ public function result() { /* (1) Convert to markdown */ $result = $this->convertToMarkdown(parent::result()); /* (2) Strip <span> elements */ return preg_replace(self::SPAN_REMOVAL_REGEX, '', $result); }
public function headline() { // get entries $entries = $this->entries(); // check if limit is either null or the number of entries less than limit if (!$this->readonly && (is_null($this->limit) || is_int($this->limit) && $entries->count() < $this->limit)) { $add = new Brick('a'); $add->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('fields.structure.add')); $add->addClass('structure-add-button label-option'); $add->data('modal', true); $add->attr('href', purl($this->model, 'field/' . $this->name . '/structure/add')); } else { $add = null; } // make sure there's at least an empty label if (!$this->label) { $this->label = ' '; } $label = parent::label(); $label->addClass('structure-label'); $label->append($add); return $label; }
/** * Generate label markup * * @since 1.0.0 * * @return string */ public function label() { /* Action button */ $action = new Brick('a'); $action->addClass('file-add-button label-option'); $action->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('pages.show.files.add')); $action->attr('href', purl($this->page(), 'upload')); /* Label */ $label = parent::label(); $label->addClass('figure-label'); $label->append($action); return $label; }
public function headline() { $label = BaseField::label(); return $label; }
/** * Generate label markup * * @since 1.0.0 * * @return string */ public function label() { /* Action button */ $action = new Brick('a'); $action->addClass('file-add-button label-option'); $action->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('pages.show.files.add')); $action->attr('href', purl($this->page(), 'upload')); /* Label */ $label = parent::label(); /** * Fields don't have to have a label assigned. * With this, we deal with missing label information. * * @since 1.3.0 */ if (!is_null($label)) { $label->addClass('figure-label'); $label->append($action); return $label; } return; }
/** * Generate label markup * * @return string */ public function label() { $label = parent::label(); $label->addClass('hgroup-title'); return $label; }