JHtml::_('behavior.tooltip'); JHtml::_('behavior.formvalidation'); JHtml::_('formbehavior.chosen', 'select'); $params = $this->form->getFieldsets('params'); $articlesid = ""; if ($this->item->articlesid) { $articlesid = explode(",", $this->item->articlesid); } $str = ' //FUNCTION AD LI ========================================= function init_obj(){ '; if (!empty($articlesid)) { foreach ($articlesid as $articleid) { //$str .='alert("'.getTitle($articleid).'");'; $str .= 'var title = "' . fieldsattachHelper::getTitle($articleid) . '" ;'; if (!empty($articleid)) { $str .= 'obj.AddId( ' . $articleid . ', title);'; } } } $str .= ' //alert("init ' . $articlesid . '"); var myArray = String(document.id("jform_articlesid").value).split(\',\'); }'; $document = JFactory::getDocument(); $document->addScriptDeclaration($str); ?>
/** * Method to get content articles * * @return array The field option objects. * @since 1.6 */ protected function getInput() { // Initialize variables. $session = JFactory::getSession(); $options = array(); $attr = ''; // Initialize some field attributes. $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; // To avoid user's confusion, readonly="true" should imply disabled="true". if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') { $attr .= ' disabled="disabled"'; } $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->multiple ? ' multiple="multiple"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; //now get to the business of finding the articles $db =& JFactory::getDBO(); $query = 'SELECT * FROM #__fieldsattach_groups WHERE published=1 ORDER BY title'; $db->setQuery($query); $groups = $db->loadObjectList(); $fields = array(); // set up first element of the array as all articles $fields[0]->id = ''; $fields[0]->title = JText::_("ALLARTICLES"); /*if((int)$this->value>0) { $query = 'SELECT title FROM #__content WHERE id='.$this->value; $db->setQuery( $query ); }*/ //loop through categories foreach ($groups as $group) { $optgroup = JHTML::_('select.optgroup', $group->title, 'id', 'title'); $query = 'SELECT id,title FROM #__fieldsattach WHERE groupid=' . $group->id; $db->setQuery($query); $results = $db->loadObjectList(); if (count($results) > 0) { array_push($fields, $optgroup); foreach ($results as $result) { array_push($fields, $result); } } } if ($this->value) { $query = 'SELECT id,title FROM #__fieldsattach WHERE id=' . $this->value; $db->setQuery($query); $field = $db->loadObject(); } else { $field->title = JText::_('COM_CONTENT_SELECT_AN_ARTICLE'); } $link = 'index.php?option=com_fieldsattach&view=fieldsattachunidades&layout=modal&tmpl=component&function=jSelectFields'; // Output // Build the script. $script = array(); $script[] = ' function jSelectFields(id, title, catid, object) {'; //$script[] = ' document.id("jform_request_fields").value += id + ",";'; //$script[] = ' document.id("fieldsid_name").value = title;'; $script[] = ' SqueezeBox.close(); obj.AddId(id, title);'; $script[] = ' }'; $script[] = ' '; $fieldsid = explode(",", $field->id); echo "DValue:" . $this->value; echo "<br>vID:" . $this->id; $str = ' //FUNCTION AD LI ========================================= function init_obj(){ '; if ($fieldsid) { foreach ($fieldsid as $fieldid) { //$str .='alert("'.getTitle($articleid).'");'; $str .= 'var title = "' . fieldsattachHelper::getTitle($fieldid) . '" ;'; if (!empty($fieldid)) { $str .= 'obj.AddId( ' . $fieldid . ', title);'; } } } $str .= ' //alert("init ' . $articlesid . '"); //var myArray = String(document.id("jform_request_fields").value).split(\',\'); }'; $document = JFactory::getDocument(); $document->addScriptDeclaration($str); $base = JURI::base(); $base = str_replace("administrator/", "", $base); $js = $base . "components" . DS . "com_fieldsattach" . DS . "views" . DS . "advancedsearch" . DS . "fields" . DS . "fields.js"; // Add the script to the document head. JFactory::getDocument()->addScript($js); JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); //$fieldName = $control_name.'['.$name.']'; JHTML::_('behavior.modal', 'a.modal'); // $html = "\n".'<div style="float: left;"><input style="background: #ffffff;" type="text" id="fieldsid_name" value="'.htmlspecialchars($field->title, ENT_QUOTES, 'UTF-8').'" disabled="disabled" /></div>'; // $html .= "\n <input class=\"inputbox modal-button\" type=\"button\" value=\"".JText::_('Select')."\" />"; $html .= '<div class="button2-left"><div class="blank"><a class="modal" title="' . JText::_('Select an Article') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 650, y: 375}}">' . JText::_('Select') . '</a></div></div>' . "\n"; //$html .= "\n".'<input type="text" id="jform[request][fields]" name="jform_request_fields" value="'.$this->value.'" />' ; $html .= "\n" . '<input type="text" id="' . $name . '_id" name="' . $fieldName . '" value="' . (int) $value . '" />'; $html .= '<div style="width:100%; overflow: hidden; background-color:#f00;"> <ul id="fieldslist"> </ul> </div>'; //jform[request][advancedsearchcategories][] return $html; //return JHTML::_('select.genericlist', $articles, $this->name, trim($attr), 'id', 'title', $this->value ); }