/** * dbCheckBox::dbCheckBox() * * Public constructor: create a new db CheckBox object * * @param object &$oForm: the form where the datefield is located on * @param string $sName: the name of the datefield * @param object $oDb: object of the database handler * @param string $sTable: the table to get the fields from * @param mixed $mFields: array of string with the names of the fields which data we should get * @param string $sExtraSQL: extra SQL statements * @return dbCheckBox * @access public * @author Johan Wiegel */ function dbCheckBox(&$oForm, $sName, &$oDb, $sTable, $mFields, $sExtraSQL = null, $sMask = null) { // call the constructor of the selectfield parent::CheckBox($oForm, $sName, array()); // make sure that the fields are set in an array $aFields = !is_array($mFields) ? array($mFields) : $mFields; $this->useArrayKeyAsValue(sizeof($aFields) == 2); // generate the query to retrieve the records $sQuery = 'SELECT ' . implode(', ', $aFields) . ' FROM ' . $oDb->quote($sTable) . ' ' . $sExtraSQL; // get the records and load the options //$this->_aOptions = is_array($aMergeArray) ? $aMergeArray : array(); // execute the query $sql = $oDb->query($sQuery); // query succeeded if ($sql) { while ($row = $oDb->getRecord($sql)) { if (sizeof($row) == 1) { $this->_aOptions[] = array_shift($row); } else { $this->_aOptions[array_shift($row)] = array_shift($row); } } } else { trigger_error("Error, could not retrieve records.<br '. FH_XHTML_CLOSE .'>\n" . "Error message: " . $oDb->getError() . "<br '. FH_XHTML_CLOSE .'>\n" . "Query: " . $sQuery, E_USER_WARNING); } }
/** * Disable mandatory validation for inherited attributes */ public function validate() { parent::validate(); if (is_array($this->varValue) && count($this->varValue)) { foreach ($this->varValue as $field) { $GLOBALS['TL_DCA']['tl_iso_products']['fields'][$field]['eval']['mandatory'] = false; } } }
protected function renderContent() { $name = $this->getAttribute('name'); $value = $this->getAttribute('value'); $flags = $this->getAttribute('flags'); $content = ''; if ($flags & \Nethgui\Renderer\WidgetFactoryInterface::FIELDSETSWITCH_CHECKBOX) { $chooser = new CheckBox($this->view); if ($this->hasAttribute('uncheckedValue')) { $chooser->setAttribute('uncheckedValue', $this->getAttribute('uncheckedValue')); } } else { $chooser = new RadioButton($this->view); } $chooser->setAttribute('name', $name)->setAttribute('value', $value)->setAttribute('flags', $flags); if ($this->hasAttribute('label')) { $chooser->setAttribute('label', $this->getAttribute('label')); } if ($this->hasAttribute('labelSource')) { $chooser->setAttribute('labelSource', $this->getAttribute('labelSource')); } $className = 'FieldsetSwitch'; if ($flags & \Nethgui\Renderer\WidgetFactoryInterface::FIELDSETSWITCH_EXPANDABLE) { $className .= ' expandable'; } if ($this->hasAttribute('class')) { $className .= ' ' . trim($this->getAttribute('class')); } $content .= $this->openTag('div', array('class' => $className)); $content .= $chooser->renderContent(); $content .= $this->openTag('fieldset', array('class' => 'FieldsetSwitchPanel')); $content .= $this->renderChildren(); $content .= $this->closeTag('fieldset'); $content .= $this->closeTag('div'); return $content; }
protected function AddInsertColumns(Grid $grid) { // // Edit column for id_tipo_accion field // $editor = new ComboBox('id_tipo_accion_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_tipo_accion"'); $field = new IntegerField('id_tipo_accion', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_tipo_accion'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('id_tipo_accion_padre'); $lookupDataset->AddField($field, false); $field = new StringField('ds_referencia'); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('ds_referencia', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Tipo Accion', 'id_tipo_accion', $editor, $this->dataset, 'id_tipo_accion', 'ds_referencia', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_tipo_espacio field // $editor = new ComboBox('id_tipo_espacio_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_tipo_espacio"'); $field = new IntegerField('id_tipo_espacio', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_tipo_espacio'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('id_tipo_espacio_padre'); $lookupDataset->AddField($field, false); $field = new StringField('ds_referencia'); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('ds_referencia', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Tipo Espacio', 'id_tipo_espacio', $editor, $this->dataset, 'id_tipo_espacio', 'ds_referencia', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_sector field // $editor = new ComboBox('id_sector_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_sector"'); $field = new IntegerField('id_sector', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_sector'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('no_sector', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Sector', 'id_sector', $editor, $this->dataset, 'id_sector', 'no_sector', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_origen field // $editor = new ComboBox('id_origen_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_origen"'); $field = new IntegerField('id_origen', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_origen'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('no_origen', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Origen', 'id_origen', $editor, $this->dataset, 'id_origen', 'no_origen', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_metodologia field // $editor = new ComboBox('id_metodologia_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_metodologia"'); $field = new IntegerField('id_metodologia', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_metodologia'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new StringField('ds_metodologia'); $lookupDataset->AddField($field, false); $field = new IntegerField('id_origen'); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('no_metodologia', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Metodología', 'id_metodologia', $editor, $this->dataset, 'id_metodologia', 'no_metodologia', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_periodicidad field // $editor = new ComboBox('id_periodicidad_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_periodicidad"'); $field = new IntegerField('id_periodicidad', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_periodicidad'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('va_frecuencia'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('no_periodicidad', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Periodicidad', 'id_periodicidad', $editor, $this->dataset, 'id_periodicidad', 'no_periodicidad', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for fl_a_demanda field // $editor = new CheckBox('fl_a_demanda_edit'); $editColumn = new CustomEditColumn('A Demanda', 'fl_a_demanda', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for nu_personas field // $editor = new TextEdit('nu_personas_edit'); $editColumn = new CustomEditColumn('Personas', 'nu_personas', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for tm_carga_horaria field // $editor = new TimeEdit('tm_carga_horaria_edit'); $editColumn = new CustomEditColumn('Carga Horária', 'tm_carga_horaria', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for fe_horas field // $editor = new MultiValueSelect('fe_horas_edit'); $editor->AddValue('00:00', $this->RenderText('00:00')); $editor->AddValue('00:15', $this->RenderText('00:15')); $editor->AddValue('00:30', $this->RenderText('00:30')); $editor->AddValue('00:45', $this->RenderText('00:45')); $editor->AddValue('01:00', $this->RenderText('01:00')); $editor->AddValue('01:15', $this->RenderText('01:15')); $editor->AddValue('01:30', $this->RenderText('01:30')); $editor->AddValue('01:45', $this->RenderText('01:45')); $editor->AddValue('02:00', $this->RenderText('02:00')); $editor->AddValue('02:15', $this->RenderText('02:15')); $editor->AddValue('02:30', $this->RenderText('02:30')); $editor->AddValue('02:45', $this->RenderText('02:45')); $editor->AddValue('03:00', $this->RenderText('03:00')); $editor->AddValue('03:15', $this->RenderText('03:15')); $editor->AddValue('03:30', $this->RenderText('03:30')); $editor->AddValue('03:45', $this->RenderText('03:45')); $editor->AddValue('04:00', $this->RenderText('04:00')); $editor->AddValue('04:15', $this->RenderText('04:15')); $editor->AddValue('04:30', $this->RenderText('04:30')); $editor->AddValue('04:45', $this->RenderText('04:45')); $editor->AddValue('05:00', $this->RenderText('05:00')); $editor->AddValue('05:15', $this->RenderText('05:15')); $editor->AddValue('05:30', $this->RenderText('05:30')); $editor->AddValue('05:45', $this->RenderText('05:45')); $editor->AddValue('06:00', $this->RenderText('06:00')); $editor->AddValue('06:15', $this->RenderText('06:15')); $editor->AddValue('06:30', $this->RenderText('06:30')); $editor->AddValue('06:45', $this->RenderText('06:45')); $editor->AddValue('07:00', $this->RenderText('07:00')); $editor->AddValue('07:15', $this->RenderText('07:15')); $editor->AddValue('07:30', $this->RenderText('07:30')); $editor->AddValue('07:45', $this->RenderText('07:45')); $editor->AddValue('08:00', $this->RenderText('08:00')); $editor->AddValue('08:15', $this->RenderText('08:15')); $editor->AddValue('08:30', $this->RenderText('08:30')); $editor->AddValue('08:45', $this->RenderText('08:45')); $editor->AddValue('09:00', $this->RenderText('09:00')); $editor->AddValue('09:15', $this->RenderText('09:15')); $editor->AddValue('09:30', $this->RenderText('09:30')); $editor->AddValue('09:45', $this->RenderText('09:45')); $editor->AddValue('10:00', $this->RenderText('10:00')); $editor->AddValue('10:15', $this->RenderText('10:15')); $editor->AddValue('10:30', $this->RenderText('10:30')); $editor->AddValue('10:45', $this->RenderText('10:45')); $editor->AddValue('11:00', $this->RenderText('11:00')); $editor->AddValue('11:15', $this->RenderText('11:15')); $editor->AddValue('11:30', $this->RenderText('11:30')); $editor->AddValue('11:45', $this->RenderText('11:45')); $editor->AddValue('12:00', $this->RenderText('12:00')); $editor->AddValue('12:15', $this->RenderText('12:15')); $editor->AddValue('12:30', $this->RenderText('12:30')); $editor->AddValue('12:45', $this->RenderText('12:45')); $editor->AddValue('13:00', $this->RenderText('13:00')); $editor->AddValue('13:15', $this->RenderText('13:15')); $editor->AddValue('13:30', $this->RenderText('13:30')); $editor->AddValue('13:45', $this->RenderText('13:45')); $editor->AddValue('14:00', $this->RenderText('14:00')); $editor->AddValue('14:15', $this->RenderText('14:15')); $editor->AddValue('14:30', $this->RenderText('14:30')); $editor->AddValue('14:45', $this->RenderText('14:45')); $editor->AddValue('15:00', $this->RenderText('15:00')); $editor->AddValue('15:15', $this->RenderText('15:15')); $editor->AddValue('15:30', $this->RenderText('15:30')); $editor->AddValue('15:45', $this->RenderText('15:45')); $editor->AddValue('16:00', $this->RenderText('16:00')); $editor->AddValue('16:15', $this->RenderText('16:15')); $editor->AddValue('16:30', $this->RenderText('16:30')); $editor->AddValue('16:45', $this->RenderText('16:45')); $editor->AddValue('17:00', $this->RenderText('17:00')); $editor->AddValue('17:15', $this->RenderText('17:15')); $editor->AddValue('17:30', $this->RenderText('17:30')); $editor->AddValue('17:45', $this->RenderText('17:45')); $editor->AddValue('18:00', $this->RenderText('18:00')); $editor->AddValue('18:15', $this->RenderText('18:15')); $editor->AddValue('18:30', $this->RenderText('18:30')); $editor->AddValue('18:45', $this->RenderText('18:45')); $editor->AddValue('19:00', $this->RenderText('19:00')); $editor->AddValue('19:15', $this->RenderText('19:15')); $editor->AddValue('19:30', $this->RenderText('19:30')); $editor->AddValue('19:45', $this->RenderText('19:45')); $editor->AddValue('20:00', $this->RenderText('20:00')); $editor->AddValue('20:15', $this->RenderText('20:15')); $editor->AddValue('20:30', $this->RenderText('20:30')); $editor->AddValue('20:45', $this->RenderText('20:45')); $editor->AddValue('21:00', $this->RenderText('21:00')); $editor->AddValue('21:15', $this->RenderText('21:15')); $editor->AddValue('21:30', $this->RenderText('21:30')); $editor->AddValue('21:45', $this->RenderText('21:45')); $editor->AddValue('22:00', $this->RenderText('22:00')); $editor->AddValue('22:15', $this->RenderText('22:15')); $editor->AddValue('22:30', $this->RenderText('22:30')); $editor->AddValue('22:45', $this->RenderText('22:45')); $editor->AddValue('23:00', $this->RenderText('23:00')); $editor->AddValue('23:15', $this->RenderText('23:15')); $editor->AddValue('23:30', $this->RenderText('23:30')); $editor->AddValue('23:45', $this->RenderText('23:45')); $editor->setMaxSelectionSize(0); $editColumn = new CustomEditColumn('Horas Ejecución', 'fe_horas', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
/** * Generate all combination of product attributes * @param object * @return string */ public function generateVariants($dc) { $objProduct = $this->Database->prepare("SELECT id, pid, language, type, (SELECT attributes FROM tl_iso_producttypes WHERE id=tl_iso_products.type) AS attributes, (SELECT variant_attributes FROM tl_iso_producttypes WHERE id=tl_iso_products.type) AS variant_attributes FROM tl_iso_products WHERE id=?")->limit(1)->execute($dc->id); $doNotSubmit = false; $strBuffer = ''; $arrOptions = array(); $arrAttributes = deserialize($objProduct->attributes); if (is_array($arrAttributes)) { foreach ($arrAttributes as $attribute => $arrConfig) { // Skip disabled attributes if (!$arrConfig['enabled']) { continue; } if ($GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['attributes']['variant_option']) { $GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['eval']['mandatory'] = true; $GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['eval']['multiple'] = true; $arrField = $this->prepareForWidget($GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute], $attribute); foreach ($arrField['options'] as $k => $option) { if ($option['value'] == '') { unset($arrField['options'][$k]); } } $objWidget = new CheckBox($arrField); if ($this->Input->post('FORM_SUBMIT') == 'tl_product_generate') { $objWidget->validate(); if ($objWidget->hasErrors()) { $doNotSubmit = true; } else { $arrOptions[$attribute] = $objWidget->value; } } $strBuffer .= $objWidget->parse(); } } if ($this->Input->post('FORM_SUBMIT') == 'tl_product_generate' && !$doNotSubmit) { $time = time(); $arrCombinations = array(); foreach ($arrOptions as $name => $options) { $arrTemp = $arrCombinations; $arrCombinations = array(); foreach ($options as $option) { if (!count($arrTemp)) { $arrCombinations[][$name] = $option; continue; } foreach ($arrTemp as $temp) { $temp[$name] = $option; $arrCombinations[] = $temp; } } } foreach ($arrCombinations as $combination) { $objVariant = $this->Database->prepare("SELECT * FROM tl_iso_products WHERE pid=? AND " . implode('=? AND ', array_keys($combination)) . "=?")->execute(array_merge(array($objProduct->id), $combination)); if (!$objVariant->numRows) { $this->Database->prepare("INSERT INTO tl_iso_products (tstamp,pid,inherit,type," . implode(',', array_keys($combination)) . ") VALUES (?,?,?,?" . str_repeat(',?', count($combination)) . ")")->execute(array_merge(array($time, $objProduct->id, array_diff((array) $objProduct->variant_attributes, array('sku', 'price', 'shipping_weight', 'published')), $objProduct->type), $combination)); } } $this->redirect(str_replace('&key=generate', '&key=quick_edit', $this->Environment->request)); } } // Return form return ' <div id="tl_buttons"> <a href="' . ampersand(str_replace('&key=generate', '', $this->Environment->request)) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBT']) . '">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a> </div> <h2 class="sub_headline">' . sprintf($GLOBALS['TL_LANG']['tl_iso_products']['generate'][1], $dc->id) . '</h2>' . $this->getMessages() . ' <form action="' . ampersand($this->Environment->request, true) . '" id="tl_product_generate" class="tl_form" method="post"> <div class="tl_formbody_edit"> <input type="hidden" name="FORM_SUBMIT" value="tl_product_generate"> <input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '"> <div class="tl_tbox block"> ' . $strBuffer . ' </div> </div> <div class="tl_formbody_submit"> <div class="tl_submit_container"> <input type="submit" name="save" id="save" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['tl_iso_products']['generate'][0]) . '"> </div> </div> </form>'; }
function &create_node_box(&$root, &$pipeline) { // Determine CSS proerty value for current child $css_state =& $pipeline->get_current_css_state(); $css_state->pushDefaultState(); $default_css = $pipeline->get_default_css(); $default_css->apply($root, $css_state, $pipeline); // Store the default 'display' value; we'll need it later when checking for impossible tag/display combination $handler =& CSS::get_handler(CSS_DISPLAY); $default_display = $handler->get($css_state->getState()); // Initially generated boxes do not require block wrappers // Block wrappers are required in following cases: // - float property is specified for non-block box which cannot be directly converted to block box // (a button, for example) // - display set to block for such box $need_block_wrapper = false; // TODO: some inheritance magic // Order is important. Items with most priority should be applied last // Tag attributes execute_attrs_before($root, $pipeline); // CSS stylesheet $css =& $pipeline->get_current_css(); $css->apply($root, $css_state, $pipeline); // values from 'style' attribute if ($root->has_attribute("style")) { parse_style_attr($root, $css_state, $pipeline); } _fix_tag_display($default_display, $css_state, $pipeline); execute_attrs_after_styles($root, $pipeline); // CSS 2.1: // 9.7 Relationships between 'display', 'position', and 'float' // The three properties that affect box generation and layout // 'display', 'position', and 'float' interact as follows: // 1. If 'display' has the value 'none', then 'position' and 'float' do not apply. // In this case, the element generates no box. $position_handler =& CSS::get_handler(CSS_POSITION); $float_handler =& CSS::get_handler(CSS_FLOAT); // 2. Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned, // the computed value of 'float' is 'none', and display is set according to the table below. // The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and // the box's containing block. $position = $css_state->get_property(CSS_POSITION); if ($position === CSS_PROPERTY_INHERIT) { $position = $css_state->getInheritedProperty(CSS_POSITION); } if ($position === POSITION_ABSOLUTE || $position === POSITION_FIXED) { $float_handler->replace(FLOAT_NONE, $css_state); $need_block_wrapper |= _fix_display_position_float($css_state); } // 3. Otherwise, if 'float' has a value other than 'none', the box is floated and 'display' is set // according to the table below. $float = $css_state->get_property(CSS_FLOAT); if ($float != FLOAT_NONE) { $need_block_wrapper |= _fix_display_position_float($css_state); } // Process some special nodes, which should not get their 'display' values overwritten (unless // current display value is 'none' $current_display = $css_state->get_property(CSS_DISPLAY); if ($current_display != 'none') { switch ($root->tagname()) { case 'body': $handler =& CSS::get_handler(CSS_DISPLAY); $handler->css('-body', $pipeline); break; case 'br': $handler =& CSS::get_handler(CSS_DISPLAY); $handler->css('-break', $pipeline); break; case 'img': $handler =& CSS::get_handler(CSS_DISPLAY); $need_block_wrapper |= $handler->get($css_state->getState()) == 'block'; $handler->css('-image', $pipeline); break; } } // 4. Otherwise, if the element is the root element, 'display' is set according to the table below. // 5. Otherwise, the remaining 'display' property values apply as specified. (see _fix_display_position_float) switch ($css_state->get_property(CSS_DISPLAY)) { case 'block': $box =& BlockBox::create($root, $pipeline); break; case '-break': $box =& BRBox::create($pipeline); break; case '-body': $box =& BodyBox::create($root, $pipeline); break; case '-button': $box =& ButtonBox::create($root, $pipeline); break; case '-button-reset': $box =& ButtonResetBox::create($root, $pipeline); break; case '-button-submit': $box =& ButtonSubmitBox::create($root, $pipeline); break; case '-button-image': $box =& ButtonImageBox::create($root, $pipeline); break; case '-checkbox': $box =& CheckBox::create($root, $pipeline); break; case '-form': $box =& FormBox::create($root, $pipeline); break; case '-frame': inc_frame_level(); $box =& FrameBox::create($root, $pipeline); dec_frame_level(); break; case '-frameset': inc_frame_level(); $box =& FramesetBox::create($root, $pipeline); dec_frame_level(); break; case '-iframe': inc_frame_level(); $box =& IFrameBox::create($root, $pipeline); dec_frame_level(); break; case '-textarea': $box =& TextAreaInputBox::create($root, $pipeline); break; case '-image': $box =& IMGBox::create($root, $pipeline); break; case 'inline': $box =& InlineBox::create($root, $pipeline); break; case 'inline-block': $box =& InlineBlockBox::create($root, $pipeline); break; case '-legend': $box =& LegendBox::create($root, $pipeline); break; case 'list-item': $box =& ListItemBox::create($root, $pipeline); break; case 'none': $box =& NullBox::create(); break; case '-radio': $box =& RadioBox::create($root, $pipeline); break; case '-select': $box =& SelectBox::create($root, $pipeline); break; case 'table': $box =& TableBox::create($root, $pipeline); break; case 'table-cell': $box =& TableCellBox::create($root, $pipeline); break; case 'table-row': $box =& TableRowBox::create($root, $pipeline); break; case 'table-row-group': case 'table-header-group': case 'table-footer-group': $box =& TableSectionBox::create($root, $pipeline); break; case '-text': $box =& TextInputBox::create($root, $pipeline); break; case '-password': $box =& PasswordInputBox::create($root, $pipeline); break; default: /** * If 'display' value is invalid or unsupported, fall back to 'block' mode */ error_log("Unsupported 'display' value: " . $css_state->get_property(CSS_DISPLAY)); $box =& BlockBox::create($root, $pipeline); break; } // Now check if pseudoelement should be created; in this case we'll use the "inline wrapper" box // containing both generated box and pseudoelements // $pseudoelements = $box->get_css_property(CSS_HTML2PS_PSEUDOELEMENTS); if ($pseudoelements & CSS_HTML2PS_PSEUDOELEMENTS_BEFORE) { // Check if :before preudoelement exists $before =& create_pdf_pseudoelement($root, SELECTOR_PSEUDOELEMENT_BEFORE, $pipeline); if (!is_null($before)) { $box->insert_child(0, $before); } } if ($pseudoelements & CSS_HTML2PS_PSEUDOELEMENTS_AFTER) { // Check if :after pseudoelement exists $after =& create_pdf_pseudoelement($root, SELECTOR_PSEUDOELEMENT_AFTER, $pipeline); if (!is_null($after)) { $box->add_child($after); } } // Check if this box needs a block wrapper (for example, floating button) // Note that to keep float/position information, we clear the CSS stack only // AFTER the wrapper box have been created; BUT we should clear the following CSS properties // to avoid the fake wrapper box actually affect the layout: // - margin // - border // - padding // - background // if ($need_block_wrapper) { /** * Clear POSITION/FLOAT properties on wrapped boxes */ $box->setCSSProperty(CSS_POSITION, POSITION_STATIC); $box->setCSSProperty(CSS_POSITION, FLOAT_NONE); $wc = $box->get_css_property(CSS_WIDTH); // Note that if element width have been set as a percentage constraint and we're adding a block wrapper, // then we need to: // 1. set the same percentage width constraint to the wrapper element (will be done implicilty if we will not // modify the 'width' CSS handler stack // 2. set the wrapped element's width constraint to 100%, otherwise it will be narrower than expected if ($wc->isFraction()) { $box->setCSSProperty(CSS_WIDTH, new WCFraction(1)); } $handler =& CSS::get_handler(CSS_MARGIN); $box->setCSSProperty(CSS_MARGIN, $handler->default_value()); /** * Note: default border does not contain any fontsize-dependent * values, so we may safely use zero as a base font size */ $border_handler =& CSS::get_handler(CSS_BORDER); $value = $border_handler->default_value(); $value->units2pt(0); $box->setCSSProperty(CSS_BORDER, $value); $handler =& CSS::get_handler(CSS_PADDING); $box->setCSSProperty(CSS_PADDING, $handler->default_value()); $handler =& CSS::get_handler(CSS_BACKGROUND); $box->setCSSProperty(CSS_BACKGROUND, $handler->default_value()); // Create "clean" block box $wrapper =& new BlockBox(); $wrapper->readCSS($pipeline->get_current_css_state()); $wrapper->add_child($box); // Remove CSS propery values from stack execute_attrs_after($root, $pipeline); $css_state->popState(); return $wrapper; } else { // Remove CSS propery values from stack execute_attrs_after($root, $pipeline); $css_state->popState(); $box->set_tagname($root->tagname()); return $box; } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for id_tipo_accion field // $editor = new ComboBox('id_tipo_accion_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_tipo_accion"'); $field = new IntegerField('id_tipo_accion', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_tipo_accion'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('id_tipo_accion_padre'); $lookupDataset->AddField($field, false); $field = new StringField('ds_referencia'); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('ds_referencia', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Tipo Accion', 'id_tipo_accion', $editor, $this->dataset, 'id_tipo_accion', 'ds_referencia', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_tipo_espacio field // $editor = new ComboBox('id_tipo_espacio_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_tipo_espacio"'); $field = new IntegerField('id_tipo_espacio', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_tipo_espacio'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('id_tipo_espacio_padre'); $lookupDataset->AddField($field, false); $field = new StringField('ds_referencia'); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('ds_referencia', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Tipo Espacio', 'id_tipo_espacio', $editor, $this->dataset, 'id_tipo_espacio', 'ds_referencia', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_tipo_bien field // $editor = new ComboBox('id_tipo_bien_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_tipo_bien"'); $field = new IntegerField('id_tipo_bien', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_tipo_bien'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('id_tipo_bien_padre'); $lookupDataset->AddField($field, false); $field = new StringField('ds_referencia'); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('ds_referencia', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Tipo Bien', 'id_tipo_bien', $editor, $this->dataset, 'id_tipo_bien', 'ds_referencia', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_origen field // $editor = new ComboBox('id_origen_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_origen"'); $field = new IntegerField('id_origen', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_origen'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('no_origen', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Origen', 'id_origen', $editor, $this->dataset, 'id_origen', 'no_origen', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_metodologia field // $editor = new ComboBox('id_metodologia_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_metodologia"'); $field = new IntegerField('id_metodologia', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_metodologia'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new StringField('ds_metodologia'); $lookupDataset->AddField($field, false); $field = new IntegerField('id_origen'); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('no_metodologia', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Metodología', 'id_metodologia', $editor, $this->dataset, 'id_metodologia', 'no_metodologia', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for id_periodicidad field // $editor = new ComboBox('id_periodicidad_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset( new PgConnectionFactory(), GetConnectionOptions(), '"public"."sga_periodicidad"'); $field = new IntegerField('id_periodicidad', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('no_periodicidad'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('va_frecuencia'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $lookupDataset->setOrderByField('no_periodicidad', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn( 'Periodicidad', 'id_periodicidad', $editor, $this->dataset, 'id_periodicidad', 'no_periodicidad', $lookupDataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for fl_a_demanda field // $editor = new CheckBox('fl_a_demanda_edit'); $editColumn = new CustomEditColumn('A Demanda', 'fl_a_demanda', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
/** * FormHandler::checkBox() * * Create a checkBox on the form * * @param string $title: The title of the field * @param string $name: The name of the field * @param array|string $value: The option(s) used for the field * @param string $validator: The validator which should be used to validate the value of the field * @param boolean $useArrayKeyAsValue: If the array key's are the values for the options in the field * @param string $extra: CSS, Javascript or other which are inserted into the HTML tag * @param string $mask: if more the 1 options are given, glue the fields together with this mask * @return void * @access public * @author Teye Heimans */ function checkBox($title, $name, $value = 'on', $validator = null, $useArrayKeyAsValue = null, $extra = null, $mask = null) { require_once FH_INCLUDE_DIR . 'fields/class.CheckBox.php'; // create a new checkbox $fld = new CheckBox($this, $name, $value); if (!empty($validator)) { $fld->setValidator($validator); } if (!is_null($useArrayKeyAsValue)) { $fld->useArrayKeyAsValue($useArrayKeyAsValue); } if (!empty($extra)) { $fld->setExtra($extra); } if (!empty($mask)) { $fld->setMask($mask); } // register the field $this->_registerField($name, $fld, $title); }
/** * {@inheritdoc} */ public function handle(\Input $input) { /** @var RootPackage $rootPackage */ $rootPackage = $this->composer->getPackage(); /** @var Config $config */ $config = $this->composer->getConfig(); $minimumStability = new \SelectMenu(array('id' => 'minimum-stability', 'name' => 'minimum-stability', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_minimum_stability'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_minimum_stability'][1], 'options' => array(array('value' => 'stable', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_stable']), array('value' => 'RC', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_rc']), array('value' => 'beta', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_beta']), array('value' => 'alpha', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_alpha']), array('value' => 'dev', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_dev'])), 'value' => $rootPackage->getMinimumStability(), 'class' => 'minimum-stability', 'required' => true)); $preferStable = new \CheckBox(array('id' => 'prefer-stable', 'name' => 'prefer-stable', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][1], 'options' => array(array('value' => '1', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][0])), 'value' => $rootPackage->getPreferStable(), 'class' => 'prefer-stable', 'required' => true)); $preferredInstall = new \SelectMenu(array('id' => 'preferred-install', 'name' => 'preferred-install', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_preferred_install'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_preferred_install'][1], 'options' => array(array('value' => 'source', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_source']), array('value' => 'dist', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_dist']), array('value' => 'auto', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_auto'])), 'value' => $config->get('preferred-install'), 'class' => 'preferred-install', 'required' => true)); $configGithubOauth = $config->get('github-oauth'); $githubOauth = new \TextField(array('id' => 'github-oauth', 'name' => 'github-oauth', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_github_oauth'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_github_oauth'][1], 'value' => $configGithubOauth['github.com'], 'class' => 'github-oauth')); $discardChanges = new \SelectMenu(array('id' => 'discard-changes', 'name' => 'discard-changes', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_discard_changes'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_discard_changes'][1], 'options' => array(array('value' => '', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_no']), array('value' => '1', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_yes']), array('value' => 'stash', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_stash'])), 'value' => (string) $config->get('discard-changes'), 'class' => 'github-oauth')); if ($input->post('FORM_SUBMIT') == 'tl_composer_settings') { $doSave = false; $json = new JsonFile(TL_ROOT . '/' . $this->configPathname); $config = $json->read(); $minimumStability->validate(); $preferStable->validate(); $preferredInstall->validate(); $githubOauth->validate(); $discardChanges->validate(); if (!$minimumStability->hasErrors()) { $config['minimum-stability'] = $minimumStability->value; $doSave = true; } if (!$preferStable->hasErrors()) { $config['prefer-stable'] = (bool) $preferStable->value; $doSave = true; } if (!$preferredInstall->hasErrors()) { $config['config']['preferred-install'] = $preferredInstall->value; $doSave = true; } if (!$githubOauth->hasErrors()) { if ($githubOauth->value) { $config['config']['github-oauth']['github.com'] = $githubOauth->value; } else { unset($config['config']['github-oauth']['github.com']); if (empty($config['config']['github-oauth'])) { unset($config['config']['github-oauth']); } } $doSave = true; } if (!$discardChanges->hasErrors()) { if ($discardChanges->value) { $config['config']['discard-changes'] = $discardChanges->value == 'stash' ? 'stash' : (bool) $discardChanges->value; } else { unset($config['config']['discard-changes']); } $doSave = true; } if ($doSave) { // make a backup copy(TL_ROOT . '/' . $this->configPathname, TL_ROOT . '/' . $this->configPathname . '~'); // update config file $json->write($config); } $this->redirect('contao/main.php?do=composer&settings=dialog'); } $template = new \BackendTemplate('be_composer_client_settings'); $template->composer = $this->composer; $template->minimumStability = $minimumStability; $template->preferStable = $preferStable; $template->preferredInstall = $preferredInstall; $template->githubOauth = $githubOauth; $template->discardChanges = $discardChanges; return $template->parse(); }
function &create_pdf_box(&$root, &$pipeline) { switch ($root->node_type()) { case XML_DOCUMENT_NODE: // TODO: some magic from traverse_dom_tree $box =& BlockBox::create($root, $pipeline); break; case XML_ELEMENT_NODE: // Determine CSS proerty value for current child push_css_defaults(); global $g_css_defaults_obj; $g_css_defaults_obj->apply($root, $pipeline); // Store the default 'display' value; we'll need it later when checking for impossible tag/display combination $handler =& get_css_handler('display'); $default_display = $handler->get(); // Initially generated boxes do not require block wrappers // Block wrappers are required in following cases: // - float property is specified for non-block box which cannot be directly converted to block box // (a button, for example) // - display set to block for such box $need_block_wrapper = false; // TODO: some inheritance magic // Order is important. Items with most priority should be applied last // Tag attributes execute_attrs_before($root, $pipeline); // CSS stylesheet global $g_css_obj; $g_css_obj->apply($root, $pipeline); // values from 'style' attribute if ($root->has_attribute("style")) { parse_style_attr(null, $root, $pipeline); } _fix_tag_display($default_display, $pipeline); // TODO: do_tag_specials // TODO: execute_attrs_after_styles // CSS 2.1: // 9.7 Relationships between 'display', 'position', and 'float' // The three properties that affect box generation and layout — // 'display', 'position', and 'float' — interact as follows: // 1. If 'display' has the value 'none', then 'position' and 'float' do not apply. // In this case, the element generates no box. $position_handler =& get_css_handler('position'); $float_handler =& get_css_handler('float'); // 2. Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned, // the computed value of 'float' is 'none', and display is set according to the table below. // The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and // the box's containing block. $position = $position_handler->get(); if ($position === POSITION_ABSOLUTE || $position === POSITION_FIXED) { $float_handler->replace(FLOAT_NONE); $need_block_wrapper |= _fix_display_position_float(); } // 3. Otherwise, if 'float' has a value other than 'none', the box is floated and 'display' is set // according to the table below. $float = $float_handler->get(); if ($float != FLOAT_NONE) { $need_block_wrapper |= _fix_display_position_float(); } // Process some special nodes // BR if ($root->tagname() == "br") { $handler =& get_css_handler('display'); $handler->css('-break', $pipeline); } if ($root->tagname() == "img") { $handler =& get_css_handler('display'); $need_block_wrapper |= $handler->get() == "block"; $handler->css('-image', $pipeline); } // 4. Otherwise, if the element is the root element, 'display' is set according to the table below. // 5. Otherwise, the remaining 'display' property values apply as specified. (see _fix_display_position_float) $display_handler =& get_css_handler('display'); switch (trim($display_handler->get())) { case "block": $box =& BlockBox::create($root, $pipeline); break; case "-break": $box =& BRBox::create($pipeline); break; case "-button": $box =& ButtonBox::create($root, $pipeline); break; case "-button-reset": $box =& ButtonResetBox::create($root, $pipeline); break; case "-button-submit": $box =& ButtonSubmitBox::create($root, $pipeline); break; case "-button-image": $box =& ButtonImageBox::create($root, $pipeline); break; case "-checkbox": $box =& CheckBox::create($root, $pipeline); break; case "-form": $box =& FormBox::create($root, $pipeline); break; case "-frame": inc_frame_level(); $box =& FrameBox::create($root, $pipeline); dec_frame_level(); break; case "-frameset": inc_frame_level(); $box =& FramesetBox::create($root, $pipeline); dec_frame_level(); break; case "-iframe": inc_frame_level(); $box =& IFrameBox::create($root, $pipeline); dec_frame_level(); break; case "-textarea": $box =& TextAreaInputBox::create($root, $pipeline); break; case "-image": $box =& IMGBox::create($root, $pipeline); break; case "inline": $box =& InlineBox::create($root, $pipeline); break; case "inline-block": $box =& InlineBlockBox::create($root, $pipeline); break; case "-legend": $box =& LegendBox::create($root, $pipeline); break; case "list-item": $box =& ListItemBox::create($root, $pipeline); break; case "none": $box =& NullBox::create($root, $pipeline); break; case "-radio": $box =& RadioBox::create($root, $pipeline); break; case "-select": $box =& SelectBox::create($root, $pipeline); break; case "table": $box =& TableBox::create($root, $pipeline); break; case "table-cell": $box =& TableCellBox::create($root, $pipeline); break; case "table-row": $box =& TableRowBox::create($root, $pipeline); break; case "-table-section": $box =& TableSectionBox::create($root, $pipeline); break; case "-text": $box =& TextInputBox::create($root, $pipeline); break; case "-password": $box =& PasswordInputBox::create($root, $pipeline); break; default: die("Unsupported 'display' value: " . $display_handler->get()); } // Now check if pseudoelement should be created; in this case we'll use the "inline wrapper" box // containing both generated box and pseudoelements // if ($box->content_pseudoelement !== "") { $content_handler =& get_css_handler('content'); // Check if :before preudoelement exists $before = create_pdf_pseudoelement($root, SELECTOR_PSEUDOELEMENT_BEFORE, $pipeline); if ($before) { $box->insert_child(0, $before); } // Check if :after pseudoelement exists $after = create_pdf_pseudoelement($root, SELECTOR_PSEUDOELEMENT_AFTER, $pipeline); if ($after) { $box->add_child($after); } } // Check if this box needs a block wrapper (for example, floating button) // Note that to keep float/position information, we clear the CSS stack only // AFTER the wrapper box have been created; BUT we should clear the following CSS properties // to avoid the fake wrapper box actually affect the layout: // - margin // - border // - padding // - background // if ($need_block_wrapper) { // Note that if element width have been set as a percentage constraint and we're adding a block wrapper, // then we need to: // 1. set the same percentage width constraint to the wrapper element (will be done implicilty if we will not // modify the 'width' CSS handler stack // 2. set the wrapped element's width constraint to 100%, otherwise it will be narrower than expected if (is_a($box->_width_constraint, "WCFraction")) { $box->_width_constraint = new WCFraction(1); } $handler =& get_css_handler('margin'); $box->margin = $handler->default_value(); $box->border = new BorderPDF(default_border()); $handler =& get_css_handler('padding'); $box->padding = $handler->default_value(); $handler =& get_css_handler('background'); $box->background = $handler->default_value(); // $handler =& get_css_handler('margin'); // $box->margin = $handler->parse("0"); // // Clear CSS properties // pop_border(); // push_border(default_border()); // $handler =& get_css_handler('padding'); // $handler->css('0'); // $handler =& get_css_handler('background'); // $handler->css('transparent'); // Create "clean" block box $wrapper =& new BlockBox(); $wrapper->add_child($box); // Remove CSS propery values from stack execute_attrs_after($root, $pipeline); pop_css_defaults(); // Clear CSS properties handled by wrapper $box->float = FLOAT_NONE; $box->position = POSITION_STATIC; return $wrapper; } else { // Remove CSS propery values from stack execute_attrs_after($root, $pipeline); pop_css_defaults(); return $box; } break; case XML_TEXT_NODE: // Determine CSS property value for current child push_css_text_defaults(); // No text boxes generated by empty text nodes // if (trim($root->content) !== "") { if ($root->content !== "") { $box =& InlineBox::create($root, $pipeline); } else { $box = null; } // Remove CSS property values from stack pop_css_defaults(); return $box; break; default: die("Unsupported node type:" . $root->node_type()); } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for IP field // $editor = new TextEdit('ip_edit'); $editor->SetSize(25); $editor->SetMaxLength(25); $editColumn = new CustomEditColumn('IP', 'IP', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for NomMachine field // $editor = new TextEdit('nommachine_edit'); $editor->SetSize(50); $editor->SetMaxLength(50); $editColumn = new CustomEditColumn('NomMachine', 'NomMachine', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for EtatMachine field // $editor = new CheckBox('etatmachine_edit'); $editColumn = new CustomEditColumn('EtatMachine', 'EtatMachine', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for Service1 field // $editor = new CheckBox('service1_edit'); $editColumn = new CustomEditColumn('Service1', 'Service1', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for Service2 field // $editor = new CheckBox('service2_edit'); $editColumn = new CustomEditColumn('Service2', 'Service2', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for Service3 field // $editor = new CheckBox('service3_edit'); $editColumn = new CustomEditColumn('Service3', 'Service3', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
function CreateControls() { $match = $this->GetDataObject(); /* @var $match Match */ $this->b_user_is_match_owner = ($match->GetAddedBy() instanceof User and AuthenticationManager::GetUser()->GetId() == $match->GetAddedBy()->GetId()); $this->AddCssClass('legacy-form'); if ($this->b_user_is_match_admin) { # Add match title editing $b_new = !$match->GetId(); $title = new TextBox('title', $b_new ? '' : $match->GetTitle()); $title->SetMaxLength(100); $this->AddControl(new FormPart('Match title', $title)); $o_generate = new CheckBox('defaultTitle', 'Use default title', 1); if ($b_new) { $o_generate->SetChecked(true); } else { $o_generate->SetChecked(!$match->GetUseCustomTitle()); } $this->AddControl($o_generate); # Add match type if ($match->GetMatchType() != MatchType::TOURNAMENT_MATCH) { $o_type_list = new XhtmlSelect('type'); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::LEAGUE), MatchType::LEAGUE)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::PRACTICE), MatchType::PRACTICE)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::FRIENDLY), MatchType::FRIENDLY)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::CUP), MatchType::CUP)); $o_type_list->SelectOption($match->GetMatchType()); $this->AddControl(new FormPart('Type of match', $o_type_list)); } } if ($this->b_user_is_match_owner or $this->b_user_is_match_admin) { $this->EnsureAggregatedEditors(); $this->fixture_editor->SetDataObject($match); $this->AddControl($this->fixture_editor); } if ($this->b_user_is_match_admin) { # add season if (!$this->IsPostback()) { $this->season_editor->DataObjects()->SetItems($match->Seasons()->GetItems()); } $this->AddControl($this->season_editor); # Hidden data on teams, for use by match-fixture-edit-control.js to re-sort teams when the season is changed # Format is 1,2,3,4,5;2,3,4,5,6 # where ; separates each team, and for each team the first number identifies the team and subsequent numbers identify the season /* @var $o_team Team */ /* @var $o_comp Competition */ $s_team_season = ''; # Build a list of all seasons, so that the "Not known yet" option can be added to all seasons $all_seasons = array(); foreach ($this->fixture_editor->GetTeams() as $group) { foreach ($group as $o_team) { if (!$o_team instanceof Team) { continue; } # Add team id if ($s_team_season) { $s_team_season .= ';'; } $s_team_season .= $o_team->GetId(); # add team seasons foreach ($o_team->Seasons() as $team_in_season) { $s_team_season .= ',' . $team_in_season->GetSeasonId(); $all_seasons[] = $team_in_season->GetSeasonId(); } } } # Add the "Don't know yet" option with all seasons $all_seasons = array_unique($all_seasons); $s_team_season = "0," . implode(",", $all_seasons) . ";{$s_team_season}"; # Put it in a hidden field accessible to JavaScript. $o_ts = new TextBox($this->GetNamingPrefix() . 'TeamSeason', $s_team_season); $o_ts->SetMode(TextBoxMode::Hidden()); $this->AddControl($o_ts); } $got_home_team = !is_null($match->GetHomeTeam()); $got_away_team = !is_null($match->GetAwayTeam()); $b_got_teams = ($got_home_team and $got_away_team); $b_future = ($match->GetId() and $match->GetStartTime() > gmdate('U')); // Move CSS class to div element $match_outer_1 = new XhtmlElement('div'); $match_outer_1->SetCssClass('matchResultEdit panel'); $match_outer_2 = new XhtmlElement('div'); $match_box = new XhtmlElement('div'); $this->AddControl($match_outer_1); $match_outer_1->AddControl($match_outer_2); $match_outer_2->AddControl($match_box); $o_title_inner_1 = new XhtmlElement('span', "Result of this match"); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $o_heading = new XhtmlElement('h2', $o_title_inner_3); $match_box->AddControl($o_heading); # Who batted first? if (!$b_future) { $match_box->AddControl('<h3>If the match went ahead:</h3>'); $toss = $this->SelectOneOfTwoTeams($this->GetNamingPrefix() . 'Toss', $match, $match->Result()->GetTossWonBy() === TeamRole::Home(), $match->Result()->GetTossWonBy() === TeamRole::Away()); $toss_part = new FormPart('Who won the toss?', $toss); $match_box->AddControl($toss_part); $bat_first = $this->SelectOneOfTwoTeams($this->GetNamingPrefix() . 'BatFirst', $match, $match->Result()->GetHomeBattedFirst() === true, $match->Result()->GetHomeBattedFirst() === false); $bat_part = new FormPart('Who batted first?', $bat_first); $match_box->AddControl($bat_part); } # Who won? $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result'); if ($b_future) { $o_winner->AddControl(new XhtmlOption('The match will go ahead', '')); } else { # This option means "no change", therefore it has to have the current value for the match result even though that's # a different value from match to match. If it's not there the submitted match doesn't have result info, so when admin # saves fixture it regenerates its title as "Team A v Team B", which doesn't match the existing title so gets saved to db. # Can't be exactly the current value though, because otherwise a cancelled match has two options with the same value, # so re-selecting the option doesn't work. Instead change it to a negative number, which can be converted back when submitted. $o_winner->AddControl(new XhtmlOption('Not applicable – match went ahead', $match->Result()->GetResultType() * -1)); } $result_types = array(MatchResult::HOME_WIN_BY_FORFEIT, MatchResult::AWAY_WIN_BY_FORFEIT, MatchResult::POSTPONED, MatchResult::CANCELLED, MatchResult::ABANDONED); foreach ($result_types as $result_type) { if (!$b_future or MatchResult::PossibleInAdvance($result_type)) { if ($b_got_teams) { $o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $match->GetHomeTeam(), $match->GetAwayTeam()), $result_type)); } else { $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type)); } } } $o_winner->SelectOption($match->Result()->GetResultType()); if (!$b_future) { $match_box->AddControl('<h3 class="ifNotPlayed">Or, if the match was not played:</h3>'); } $o_win_part = new FormPart($b_future ? 'Will it happen?' : 'Why not?', $o_winner); $match_box->AddControl($o_win_part); # Show audit data if ($match->GetLastAudit() != null) { require_once "data/audit-control.class.php"; $match_box->AddControl(new AuditControl($match->GetLastAudit(), "match")); } # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $match->GetShortUrl()); if ($this->b_user_is_match_admin) { $o_url_part = new FormPart('Short URL', $o_short_url); $this->AddControl($o_url_part); $this->AddControl(new CheckBox($this->GetNamingPrefix() . 'RegenerateUrl', 'Regenerate short URL', 1, !$match->GetUseCustomShortUrl(), $this->IsValidSubmit())); } else { $o_short_url->SetMode(TextBoxMode::Hidden()); $this->AddControl($o_short_url); } if ($b_future and !$this->b_user_is_match_admin and !$this->b_user_is_match_owner) { $this->SetButtonText("Save result"); } }
/** * Generate all combination of product attributes * @param object * @return string */ public function generate($dc) { $table = Product::getTable(); $objProduct = Product::findByPk($dc->id); $doNotSubmit = false; $strBuffer = ''; $arrOptions = array(); foreach ($objProduct->getRelated('type')->getVariantAttributes() as $attribute) { if ($GLOBALS['TL_DCA'][$table]['fields'][$attribute]['attributes']['variant_option']) { $GLOBALS['TL_DCA'][$table]['fields'][$attribute]['eval']['mandatory'] = true; $GLOBALS['TL_DCA'][$table]['fields'][$attribute]['eval']['multiple'] = true; $arrField = \CheckBox::getAttributesFromDca($GLOBALS['TL_DCA'][$table]['fields'][$attribute], $attribute); foreach ($arrField['options'] as $k => $option) { if ($option['value'] == '') { unset($arrField['options'][$k]); } } $objWidget = new \CheckBox($arrField); if (\Input::post('FORM_SUBMIT') == $table . '_generate') { $objWidget->validate(); if ($objWidget->hasErrors()) { $doNotSubmit = true; } else { $arrOptions[$attribute] = $objWidget->value; } } $strBuffer .= $objWidget->parse(); } } if (\Input::post('FORM_SUBMIT') == $table . '_generate' && !$doNotSubmit) { $time = time(); $arrCombinations = array(); foreach ($arrOptions as $name => $options) { $arrTemp = $arrCombinations; $arrCombinations = array(); foreach ($options as $option) { if (empty($arrTemp)) { $arrCombinations[][$name] = $option; continue; } foreach ($arrTemp as $temp) { $temp[$name] = $option; $arrCombinations[] = $temp; } } } foreach ($arrCombinations as $combination) { $objVariant = \Database::getInstance()->prepare("\n SELECT * FROM {$table} WHERE pid=? AND " . implode('=? AND ', array_keys($combination)) . "=?")->execute(array_merge(array($objProduct->id), $combination)); if (!$objVariant->numRows) { $arrInherit = array_diff($objProduct->getRelated('type')->getVariantAttributes(), Attribute::getVariantOptionFields(), Attribute::getCustomerDefinedFields(), Attribute::getSystemColumnsFields()); $arrSet = array_merge($combination, array('tstamp' => $time, 'pid' => $objProduct->id, 'inherit' => $arrInherit ?: null)); \Database::getInstance()->prepare("INSERT INTO {$table} %s")->set($arrSet)->execute(); } } \Controller::redirect(str_replace('&key=generate', '', \Environment::get('request'))); } // Return form return ' <div id="tl_buttons"> <a href="' . ampersand(str_replace('&key=generate', '', \Environment::get('request'))) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBT']) . '">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a> </div> <h2 class="sub_headline">' . sprintf($GLOBALS['TL_LANG'][$table]['generate'][1], $dc->id) . '</h2>' . \Message::generate() . ' <form action="' . ampersand(\Environment::get('request'), true) . '" id="' . $table . '_generate" class="tl_form" method="post"> <div class="tl_formbody_edit"> <input type="hidden" name="FORM_SUBMIT" value="' . $table . '_generate"> <input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '"> <div class="tl_tbox block"> ' . $strBuffer . ' </div> </div> <div class="tl_formbody_submit"> <div class="tl_submit_container"> <input type="submit" name="save" id="save" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['tl_iso_product']['generate'][0]) . '"> </div> </div> </form>'; }
/** * Creates, and re-populates on postback, a checkbox to manage one property of a related data item * * @param bool $b_validated_value * @param string $s_name * @param int $i_row_count * @param int $i_total_rows * @return TextBox */ protected function CreateCheckbox($b_validated_value, $s_name, $i_row_count, $i_total_rows) { require_once 'xhtml/forms/checkbox.class.php'; # Establish current status $b_is_add_row = is_null($i_row_count); $b_repopulate_add_row = (!$this->IsValid() or $this->DeleteClicked() or $this->IsUnrelatedInternalPostback()); # Create checkbox $checkbox = new CheckBox($this->GetNamingPrefix() . $s_name . $i_row_count, '', 1); # Repopulate the previous value # If this is the row used to add a new related item... if ($b_is_add_row) { # ...if we repopulate, it's because validation has either failed or not occurred if ($b_repopulate_add_row) { $checkbox->SetChecked(isset($_POST[$checkbox->GetXhtmlId()])); } } else { if ($this->IsValid()) { if ($this->AddClicked() and $i_row_count == $this->i_row_added) { # If a new row was posted, is valid, and is now displayed here, need to get the posted value from the add row $s_checkbox_in_add_row = substr($checkbox->GetXhtmlId(), 0, strlen($checkbox->GetXhtmlId()) - strlen($i_row_count)); $checkbox->SetChecked(isset($_POST[$s_checkbox_in_add_row])); } else { # Even though the editor as a whole is valid, this row wasn't validated # so just restore the previous value if ($this->IsPostback()) { $checkbox->SetChecked(isset($_POST[$checkbox->GetXhtmlId()])); } else { # Won't be in $_POST when page is first loaded $checkbox->SetChecked($b_validated_value); } } } else { # Repopulate with the exact value posted, as validation has failed $checkbox->SetChecked(isset($_POST[$checkbox->GetXhtmlId()])); } } # Return checkbox so that other things can be done to it - eg add a CSS class return $checkbox; }