/** * Draws the control, or the default text area if a setup file is not found * * @param string $tag_path The XML path to the params (by default 'params') * @param string $grand_parent_path [optional] First find as grand-parent that node (if exists) * @param string $parent_tag [optional] Then find as parent that node (if exists) * @param string $parent_attr [optional] but parent with that attribute having * @param string $parent_attrvalue [optional] that value * @param string $control_name The control name (by default 'params') * @param boolean $paramstextarea If there are no params XML descriptor should params be represented just as a textarea of the raw params (to avoid loosing them) ? * @param string $viewType View type ( 'view', 'param', 'depends': means: <param> tag => param, <field> tag => view ) * @param string $htmlFormatting HTML formatting type for params ( 'table', 'td', 'none', 'fieldsListArray' ) * @return string|array HTML or values if $htmlFormatting = 'fieldsListArray' */ function draw($tag_path = 'params', $grand_parent_path = null, $parent_tag = null, $parent_attr = null, $parent_attrvalue = null, $control_name = 'params', $paramstextarea = true, $viewType = 'depends', $htmlFormatting = 'table') { if ($this->_xml) { $element = $this->_xml; if ($element && $element->getName() == $this->_maintagname && $element->attributes($this->_attrname) == $this->_attrvalue) { if ($grand_parent_path != null) { $element = $element->getElementByPath($grand_parent_path); if (!$element) { return null; } } if ($parent_tag != null && $parent_attr != null && $parent_attrvalue != null) { $element = $element->getChildByNameAttr($parent_tag, $parent_attr, $parent_attrvalue); if ($element) { if ($tag_path) { /** @var SimpleXMLElement $element */ $element = $element->getElementByPath($tag_path); } if ($element !== false) { $this->_xmlElem =& $element; } } } else { $element = $element->getElementByPath($tag_path); if ($element !== false) { $this->_xmlElem = $element; } } } elseif (!$tag_path) { $this->_xmlElem = $element; } } if ($this->_xmlElem !== null) { $controllerView = new DrawController($this->input, $this->_xmlElem, $this->_actions, $this->_options); $controllerView->setControl_name($control_name); $editRowView = new RegistryEditView($this->input, $this->_db, $this->_pluginParams, $this->_types, $this->_actions, $this->_views, $this->_pluginObject, $this->_tabId); $modelOfDataRows = $this->registry->getStorage(); $editRowView->setModelOfDataRows($modelOfDataRows); if ($this->_extendViewParser) { $editRowView->setExtendedViewParser($this->_extendViewParser); } return $editRowView->renderEditRowView($this->_xmlElem, $this->registry, $controllerView, $this->_options, $viewType, $htmlFormatting); } else { if ($paramstextarea) { return "<textarea name=\"{$control_name}\" cols=\"40\" rows=\"10\" class=\"text_area\">" . htmlspecialchars($this->registry->asJson()) . "</textarea>"; } else { return null; } } }
/** * Returns the currently loaded mode type and prepares data * Used by Backend XML only * * @param string $value * @param RegistryInterface $pluginParams * @return int */ public function getModelType($value, $pluginParams) { $categories = cbblogsClass::getModel()->class->getCategoriesList(true); if ($categories) { $pregCategories = array(); foreach ($categories as $category) { $pregCategories[] = preg_quote($category); } $pluginParams->set('catids', '^' . implode('|', $pregCategories) . '$'); } else { $pluginParams->set('catids', '^.+$'); } return cbblogsClass::getModel()->type; }
/** * adds field values array to xml data * Used by Backend XML only * @deprecated Do not use directly, only for XML tabs backend * * @param string $value * @param RegistryInterface $pluginParams * @param string $name * @param \SimpleXMLElement $node * @param string $control_name * @param string $control_name_name * @param boolean $view * @param RegistryInterface $data */ public function fetchFieldValues( /** @noinspection PhpUnusedParameterInspection */ $value, $pluginParams, $name, $node, $control_name, $control_name_name, $view, $data ) { if ( $this->fieldid > 0 ) { $fieldValuesTable = new FieldValueTable( $this->_db ); $fieldValues = $fieldValuesTable->getFieldValuesOfField( (int) $this->fieldid ); } else { $fieldValues = array(); } $data->set( '_fieldvalues', $fieldValues ); }
/** * Creates the column references for the userlist query * @static * * @param array $columns * @param FieldTable[] $fields * @param array $tables * @param array $searchableFields * @param RegistryInterface $params * @return string */ public static function getFieldsSQL(&$columns, &$fields, &$tables, &$searchableFields, &$params) { $colRefs = array(); $newTableIndex = 0; $listSearch = (int) $params->get('list_search', 1); foreach ($columns as $i => $column) { foreach ($column->fields as $k => $colField) { $fieldId = isset($colField['fieldid']) ? $colField['fieldid'] : null; if ($fieldId && isset($fields[$fieldId])) { $field = $fields[$fieldId]; if (!array_key_exists($field->table, $tables)) { $newTableIndex++; $tables[$field->table] = 't' . $newTableIndex; } if ($tables[$field->table][0] != 'u' && $field->name != 'NA') { // CB 1.1 table compatibility : TBD: remove after CB 1.2 foreach ($field->getTableColumns() as $col) { $colRefs[$col] = $tables[$field->table] . '.' . $field->getDbo()->NameQuote($col); } } if ($field->searchable && $listSearch == 1) { $searchableFields[] = $fields[$fieldId]; } $fields[$fieldId]->_listed = true; } else { // field unpublished or deleted but still in list: remove field from columns, so that we don't handle it: unset($columns[$i]->fields[$k]); } } } if ($listSearch == 2) { foreach ($fields as $fieldId => $field) { if ($field->searchable) { $searchableFields[] = $fields[$fieldId]; } } } if ($listSearch == 3) { $listSearchFields = explode('|*|', $params->get('list_search_fields', null)); if ($listSearchFields) { foreach ($fields as $fieldId => $field) { if ($field->searchable && in_array($field->fieldid, $listSearchFields)) { $searchableFields[] = $fields[$fieldId]; } } } } return implode(', ', $colRefs); }
/** * Implements a form params-type field for showing a given plugin param * * @param string $name The name of the form element * @param string $value The value of the element * @param SimpleXMLElement $node The xml element for the parameter * @param string $control_name The control name * @return string The html for the element */ function _form_param( /** @noinspection PhpUnusedParameterInspection */ $name, $value, &$node, $control_name ) { $content = $this->_pluginParams->get( $node->attributes( 'value' ) ); return $content; }
/** * Implements a form params-type field for showing a given plugin param * * @param string $name The name of the form element * @param string $value The value of the element * @param SimpleXMLElement $node The xml element for the parameter * @param string $control_name The control name * @return string The html for the element */ function _form_param($name, $value, &$node, $control_name) { $content = $this->_pluginParams->get($node->attributes('value')); return $content; }