id.'(id, title, catid, object) {'; $script[] = ' document.id("'.$this->id.'_id").value = id;'; $script[] = ' document.id("'.$this->id.'_name").value = title;'; $script[] = ' SqueezeBox.close();'; $script[] = ' }'; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Setup variables for display. $html = array(); $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&function=jSelectArticle_'.$this->id; if (isset($this->element['language'])) { $link .= '&forcedLanguage='.$this->element['language']; } $db = JFactory::getDbo(); $db->setQuery( 'SELECT title' . ' FROM #__content' . ' WHERE id = '.(int) $this->value ); try { $title = $db->loadResult(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); } if (empty($title)) { $title = 'Select An Article';//JText::_('COM_CONTENT_SELECT_AN_ARTICLE'); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The current user display field. $html[] = ''; $html[] = ' '.JText::_('JSELECT').''; $html[] = ''; // The active article id field. if (0 == (int) $this->value) { $value = ''; } else { $value = (int) $this->value; } // class='required' for client side validation $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = ''; return implode("\n", $html); } } else: class JFormFieldModal_Article extends JFormField{ /** * The form field type. * * @var string * @since 1.6 */ protected $type = 'Modal_Article'; /** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Load the modal behavior script. JHtml::_('behavior.modal', 'a.modal'); // Build the script. $script = array(); $script[] = ' function jSelectArticle_'.$this->id.'(id, title, catid, object) {'; $script[] = ' document.id("'.$this->id.'_id").value = id;'; $script[] = ' document.id("'.$this->id.'_name").value = title;'; $script[] = ' SqueezeBox.close();'; $script[] = ' }'; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Setup variables for display. $html = array(); $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&function=jSelectArticle_'.$this->id; $db = JFactory::getDBO(); $db->setQuery( 'SELECT title' . ' FROM #__content' . ' WHERE id = '.(int) $this->value ); $title = $db->loadResult(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); } if (empty($title)) { $title = 'Select An Article';//JText::_('COM_CONTENT_SELECT_AN_ARTICLE'); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The current user display field. $html[] = '
'; $html[] = ' '; $html[] = '
'; // The user select button. $html[] = '
'; $html[] = '
'; $html[] = ' '.'Select'.''; $html[] = '
'; $html[] = '
'; // The active article id field. if (0 == (int)$this->value) { $value = ''; } else { $value = (int)$this->value; } // class='required' for client side validation $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = ''; return implode("\n", $html); } } endif;