protected function getOptions() { echo '<script type="text/javascript"> var article_content_params = "{article_name} Article name <br>" + "{article_description} Article description"; var event_content_params = "{event_name} Event name <br>" + "{event_description} Event description"; var form_content_params = "{form_name} Form name <br>" + "{form_description} Form description"; var product_content_params = "{product_name} Name of product <br>" + "{product_description} Description of product <br>" + "{product_attribute} Product attribute <br>" + "{product_quantity} Product quantity <br>" + "{addtocart_button} Button Add to cart <br>" + "{product_image} Product image <br>" + "{product_price} Product price <br>"; var article_content_default = "<table>™" + "<tbody>™" + "<tr>™" + "<td>{article_name}</td>™" + "</tr>™" + "<tr>™" + "<td>{article_description}</td>™" + "</tr>™" + "</tbody>™" + "</table>™"; article_content_default = article_content_default.replace(/</g,"<") .replace(/>/g,">") .replace(/™/g, "<br/>"); var event_content_default = "<table>™" + "<tbody>™" + "<tr>™" + "<td>{session_title}</td>™" + "</tr>™" + "<tr>™" + "<td>{session_date}</td>™" + "</tr>™" + "<tr>™" + "<td>{event_title}</td>™" + "</tr>™" + "<tr>™" + "<td>{event_description}</td>™" + "</tr>™" + "<tr>™" + "<td>{event_button}</td>™" + "</tr>™" + "</tbody>™" + "</table>™"; event_content_default = event_content_default.replace(/</g,"<") .replace(/>/g,">") .replace(/™/g, "<br/>"); var form_content_default = "<table>™" + "<tbody>™" + "<tr>™" + "<td colspan=2>{form_title}</td>™" + "</tr>™" + "<tr>™" + "<td>{form_field}</td>™" + "<td>{form_field}</td>™" + "</tr>™" + "<tr>™" + "<td colspan=2>{form_field}</td>™" + "</tr>™" + "<tr>™" + "<td colspan=2>{form_button}</td>™" + "</tr>™" + "</tbody>™" + "</table>™"; form_content_default = form_content_default.replace(/</g,"<") .replace(/>/g,">") .replace(/™/g, "<br/>"); var product_content_default = "<table>™" + "<tbody>™" + "<tr>™" + "<td rowspan=4>{product_image}</td>;" + "<td colspan=2>{product_name}</td>™" + "</tr>™" + "<tr>™" + "<td colspan=2>{product_description}</td>™" + "</tr>™" + "<tr>™" + "<td colspan=2>{product_attribute}</td>™" + "</tr>™" + "<tr>™" + "<td>{product_price}</td>™" + "<td>{product_quantity}</td>™" + "<td>{addtocart_button}</td>™" + "</tr>™" + "</tbody>™" + "</table>™"; product_content_default = product_content_default.replace(/</g,"<") .replace(/>/g,">") .replace(/™/g, "<br/>"); window.onload = function() { var x = document.getElementById("content_params").getElementsByTagName("p"); var y = document.getElementById("content_default").getElementsByTagName("p"); var z = document.getElementById("section"); setContent(x[0], y[0], z); z.onchange = function() { setContent(x[0], y[0], z); }; }; function setContent(content_params_area, content_default_area, section) { if (section.value == "article") { content_params_area.innerHTML = article_content_params; content_default_area.innerHTML = article_content_default; } else if (section.value == "event") { content_params_area.innerHTML = event_content_params; content_default_area.innerHTML = event_content_default; } else if (section.value == "form") { content_params_area.innerHTML = form_content_params; content_default_area.innerHTML = form_content_default; } else if (section.value == "product") { content_params_area.innerHTML = product_content_params; content_default_area.innerHTML = product_content_default; } } </script>'; return parent::getOptions(); }
/** * Method to get the field options. * * @return array The field option objects. */ protected function getOptions() { $options = array(); // Initialize some field attributes. $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value'; $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name']; $translate = $this->element['translate'] ? (string) $this->element['translate'] : false; $applyAccess = $this->element['apply_access'] ? (string) $this->element['apply_access'] : 'false'; $modelName = (string) $this->element['model']; $nonePlaceholder = (string) $this->element['none']; if (!empty($nonePlaceholder)) { $options[] = JHtml::_('select.option', JText::_($nonePlaceholder), null); } // Process field atrtibutes $applyAccess = strtolower($applyAccess); $applyAccess = in_array($applyAccess, array('yes', 'on', 'true', '1')); // Explode model name into model name and prefix $parts = FOFInflector::explode($modelName); $mName = ucfirst(array_pop($parts)); $mPrefix = FOFInflector::implode($parts); // Get the model object $config = array('savestate' => 0); $model = FOFModel::getTmpInstance($mName, $mPrefix, $config); if ($applyAccess) { $model->applyAccessFiltering(); } // Process state variables foreach ($this->element->children() as $stateoption) { // Only add <option /> elements. if ($stateoption->getName() != 'state') { continue; } $stateKey = (string) $stateoption['key']; $stateValue = (string) $stateoption; $model->setState($stateKey, $stateValue); } // Set the query and get the result list. $items = $model->getItemList(true); // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }