/** * Display the button. * * @param string $name field name * @return JObject button settings */ function onDisplay($name) { $doc = JFactory::getDocument(); /* @var $doc JDocumentHTML */ $script[] = '//<![CDATA['; $script[] = 'function jSelectJoomdocDocument(id, title, url) {'; $script[] = ' var tag = \'<a href="\' + url + \'" title="">\' + title + \'</a>\';'; $script[] = ' jInsertEditorText(tag, \'' . addslashes($name) . '\');'; $script[] = ' SqueezeBox.close();'; $script[] = '}'; $script[] = '//]]>'; $script = implode(PHP_EOL, $script); $doc->addScriptDeclaration($script); $button = new JObject(); $button->set('modal', true); $button->set('link', str_replace('&', '&', JoomDOCRoute::modalDocuments(null, true))); $button->set('text', JText::_('PLG_EDITORS-XTD_JOOMDOC_BTN')); $button->set('name', 'file-add'); $button->set('options', "{handler: 'iframe', size: {x: 770, y: 400}}"); $button->set('class', 'btn'); return $button; }
$i = 0; while ($this->root->hasNext()) { $item = $this->root->getNext(); $access = new JoomDOCAccessHelper($item); echo '<tr class="row' . $i % 2 . '">'; echo '<td>'; // backspashes doing bad in js pass $id = str_replace(DIRECTORY_SEPARATOR, '/', $this->escape($access->relativePath)); $title = $this->escape($access->docid ? $item->document->title : str_replace(DIRECTORY_SEPARATOR, '/', $access->relativePath)); $url = JRoute::_($linkType == JOOMDOC_LINK_TYPE_DOWNLOAD && $access->isFile ? JoomDOCRoute::download(str_replace(DIRECTORY_SEPARATOR, '/', $access->relativePath), $access->alias) : JoomDOCRoute::viewDocuments(str_replace(DIRECTORY_SEPARATOR, '/', $access->relativePath), $access->alias)); if (JString::strpos($url, $prefix) === 0) { $url = JString::substr($url, $prefixLength); } echo '<a href="javascript:window.parent.jSelectJoomdocDocument(\'' . addslashes(JoomDOCString::dsEncode($id)) . '\', \'' . addslashes($title) . '\', \'' . addslashes($url) . '\')" class="hasTip addDocument" title="' . $this->getTooltip('JOOMDOC_SET_DOCUMENT') . '"></a>'; if ($access->isFolder) { echo '<a class="hasTip folder" href="' . JRoute::_(JoomDOCRoute::modalDocuments($access->relativePath, $useLinkType, $addSymLink, $symLinkSource)) . '" title="' . $this->getTooltip($access->relativePath, 'JOOMDOC_DOCUMENTS_OPEN_FOLDER') . '">' . $this->escape($access->name) . '</a>'; } else { echo '<span class="file">' . $this->escape($access->name) . '</span>'; } echo '</td>'; echo '<td>' . ($access->docid ? $this->escape($item->document->title) : '-') . '</td>'; echo '</tr>'; $i++; } if ($i === 0) { echo '<tr><td>This folder contains no items.</td></tr>'; } else { echo ''; } echo '</tbody>'; echo '</table>';