function display($tpl = null) { // Frontpage hack $this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'link' . DS . 'tmpl'); // Only allow "component" template JRequest::setVar('tmpl', 'component'); // JFactory $user =& JFactory::getUser(); $config =& JFactory::getConfig(); $doc =& JFactory::getDocument(); $lingo =& JFactory::getLanguage(); // Include styles $doc->addStyleSheet(LINKR_ASSETS . 'css/modal.css?' . LINKR_VERSION_INC); // Template override global $mainframe; $tmpl = $mainframe->getTemplate(); if (file_exists(JPATH_BASE . DS . 'templates' . DS . $tmpl . DS . 'linkr.css')) { $doc->addStyleSheet(JURI::base() . 'templates/' . $tmpl . '/linkr.css'); } elseif (file_exists(JPATH_BASE . DS . 'templates' . DS . $tmpl . DS . 'css' . DS . 'linkr.css')) { $doc->addStyleSheet(JURI::base() . 'templates/' . $tmpl . '/css/linkr.css'); } // Editor name, request endpoint, document base $editor = JRequest::getString('e_name', 'text'); $rUrl = JURI::base() . 'index.php?option=com_linkr&view=request&' . JUtility::getToken() . '=1'; // Include scripts JHTML::_('behavior.mootools'); $unc = LinkrHelper::getParam('compress', 1) ? '.js' : '-UCP.js'; $doc->addScript(LINKR_ASSETS . 'js/helper' . $unc . '?' . LINKR_VERSION_INC); $doc->addScriptDeclaration('var Linkr=new LinkrAPI(' . '[' . implode(',', explode('.', LINKR_VERSION_READ)) . '],' . '"' . $rUrl . '",' . '"' . $editor . '",' . '"' . JURI::root() . '",' . '[' . '"' . JRequest::getWord('mode', 'squeezebox') . '",' . '"' . $lingo->getTag() . '",' . '"' . LinkrHelper::UTF8Encode(JText::_('MISSING_TEXT', true)) . '",' . '"' . LinkrHelper::UTF8Encode(JText::_('IMG_ANCHOR', true)) . '",' . '"' . LINKR_ASSETS . 'img/",' . $user->get('aid') . ']' . ');' . 'var LinkrHelper=Linkr;'); // Frontend fix if (LinkrHelper::isSite()) { //$doc->setBase(LinkrHelper::getLinkrUrl($editor)); } // References $this->assign('links', $this->get('Links')); $this->assign('tools', $this->get('ToolLinks')); // Localize text if ($text = $this->get('L18N')) { $l18n = array(); foreach ($text as $k => $v) { $l18n[] = '["' . $k . '","' . $v . '"]'; } $doc->addScriptDeclaration('Linkr.setL18N([' . implode(',', $l18n) . ']);'); } // 3rd party javascript if ($js = $this->get('Scripts')) { $doc->addScriptDeclaration($js); } // Load single link $load = ''; $inc = $this->get('IncludedLinks'); if (!$this->tools['count'] && $this->links['count'] == 1) { $load = 'Linkr.__fr=function(){' . $inc[$this->links['name'][0]] . '};'; } elseif (!$this->links['count'] && $this->tools['count'] == 1) { $load = 'Linkr.__fr=function(){' . $inc[$this->tools['name'][0]] . '};'; } // Fire "onLoad" event $doc->addScriptDeclaration('window.addEvent("domready",function(){' . $load . 'Linkr.fireEvent("onLoad");' . '});'); parent::display($tpl); }
/** * Method to display the contact layout * * @return string HTML code for layout */ function layoutFiles() { $layout = '<h2 class="linkrh2">' . JText::_('LINK_FILE') . '</h2>' . $this->fileConfig() . $this->folderItems() . $this->fileDirectories(); // Add upload form if (!LinkrHelper::isSite()) { $layout .= $this->fileUploadForm(); } elseif (LinkrHelper::getParam('frontend_upload', 0)) { $layout .= $this->fileUploadForm(); } // Use flash uploader //if (LinkrHelper::getMediaParam( 'enable_flash', 1 )) { // JHTML::_( 'behavior.uploader', 'file-upload', array( 'onAllComplete' => 'function(){ LinkrHelper.layout(\'file\'); }' ) ); //} return $layout . '<br/>'; }
function onLinkrLoadJS($version, $inc = array()) { // File append $append = $this->cp('compress', 1) ? '.js' : '-UCP.js'; $append .= '?' . LINKR_VERSION_INC; // Initialize variables $js = ''; $d =& JFactory::getDocument(); $r = JURI::root() . 'components/com_linkr/assets/js/'; // Base files $d->addScript($r . 'tree' . $append); $d->addScript($r . 'object' . $append); $js .= 'LinkrObject.options.defaultItemid=' . LinkrHelper::getParam('itemid', 0) . ';'; // Plugin check // ToDo: use some other check $p = LinkrHelper::getPluginParam() ? 'true' : 'false'; // Bookmarks if ($inc['bookmarks']) { $d->addScript($r . 'bookmarks' . $append); $bm = $this->cp('def_bm', 0) ? 'true' : 'false'; $js .= 'LinkrBookmarks.loadedByDefault=' . $bm . ';' . 'LinkrBookmarks.isPluginInstalled=' . $p . ';'; } // Related articles if ($inc['related']) { $d->addScript($r . 'related' . $append); $rl = $this->cp('def_rel', 0) ? 'true' : 'false'; $js .= 'LinkrRelated.loadedByDefault=' . $rl . ';' . 'LinkrRelated.isPluginInstalled=' . $p . ';'; } // Files if ($this->cp('link_file', 1) && $inc['file']) { $d->addScript($r . 'file' . $append); $u = (bool) $this->cp('frontend_upload', 0); $u = $u ? true : !LinkrHelper::isSite(); $u = $u ? JURI::base() . 'index.php?option=com_linkr&controller=file&task=upload&e_name=' . JRequest::getString('e_name', 'text') . '&' . JUtility::getToken() . '=1' : false; // Upload $js .= 'LinkrFile.uploadURL=' . ($u ? '"' . $u . '"' : 'false') . ';'; // Message if ($msg = JRequest::getString('msg', null)) { $js .= 'LinkrFile.msg="' . LinkrHelper::UTF8Encode($msg) . '";'; } // Paths global $mainframe; $path = JRequest::getString('path', '', 'REQUEST'); if (strlen($path)) { $mainframe->setUserState('linkr.path', $path); } else { $mainframe->setUserState('linkr.path', null); } // Simple list $simple = JRequest::getInt('simplelist', -1, 'REQUEST'); if ($simple != -1) { $mainframe->setUserState('linkr.simplelist', $simple); } else { $mainframe->setUserState('linkr.simplelist', null); } } // Articles if ($this->cp('link_article', 1) && $inc['article']) { $d->addScript($r . 'article' . $append); $s = (bool) $this->cp('use_slug', 1); $js .= 'ArtOpts.slug=' . ($s ? 'true' : 'false') . ';' . 'var LinkrArticle=LinkrObject.getInstance(ArtOpts, ArtSrch, ArtLay, ArtTmpl);'; } // Menu links if ($this->cp('link_menu', 1) && $inc['menu']) { $d->addScript($r . 'menu' . $append); // Get menus $db =& JFactory::getDBO(); $db->setQuery('SELECT * FROM #__menu_types'); $ml = (array) $db->loadObjectList(); foreach ($ml as $m) { $ti = LinkrHelper::UTF8Encode($m->title); $de = LinkrHelper::UTF8Encode($m->description); $js .= 'MITree.include({' . 'id:"' . $m->menutype . '",' . 'name:"' . urlencode($ti) . '",' . 'description:"' . urlencode($de) . '"' . '});'; } $js .= 'var LinkrMenu=LinkrTree.getInstance(MIOpts,MITree,MISrch,MITmpl);'; } // Contacts if ($this->cp('link_contact', 1) && $inc['contact']) { $d->addScript($r . 'contact' . $append); $js .= 'var LinkrContact = LinkrObject.getInstance(ConOpts,ConSrch,ConLay,ConTmpl);'; } // Automatic links /*if ($inc['auto']) { $d->addScript($r .'auto'. $append); // Get extensions $db = & JFactory::getDBO(); $db->setQuery( 'SELECT c.id, c.name, c.option '. 'FROM #__components AS c '. 'WHERE c.link <> "" AND c.parent = 0 '. 'AND c.enabled = 1'); $ex = (array) $db->loadObjectList(); foreach ($ex as $e) { $js .= '_xr.include({'. 'id:'. $e->id .','. 'option:"'. $e->option .'",'. 'name:"'. urlencode(LinkrHelper::UTF8Encode($e->name)) .'"'. '});'; } $js .= 'var LinkrX=LinkrTree.getInstance(_xo,_xr,_xs,_xt);'; }*/ // Debug $user =& JFactory::getUser(); if ($this->cp('debug', 0) && $user->gid >= 23) { $d->addScript($r . 'debug.js?' . LINKR_VERSION_INC); } return $js; }
function delete() { $this->returnURL .= '&delete=1'; if (!JRequest::checkToken('request')) { return $this->end(401, 'Invalid Token'); } elseif (LinkrHelper::isSite() && !LinkrHelper::getParam('frontend_upload', '0')) { return $this->end(401, 'Uploading Disabled'); } // Get file name $file = trim(JRequest::getVar('file', '', 'REQUEST', 'base64')); if (!strlen($file)) { return $this->end(400, JText::_('bad request')); } elseif (!($file = base64_decode($file))) { return $this->end(400, JText::_('bad request')); } // Get full file path $filepath = $this->uploadFolder . DS . JFile::makeSafe($file); if (!JFile::exists($filepath)) { return $this->end(400, JText::_('bad request')); } // Delete if (!JFile::delete($filepath)) { return $this->end(400, 'Could not delete file'); } $this->end(200, 'File deleted!'); }