Example #1
0
 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);
 }
Example #2
0
 function upload()
 {
     global $mainframe;
     // Check for request forgeries
     if (!JRequest::checkToken('request')) {
         // 401 Unauthorized
         return $this->end(401, 'Invalid Token');
     }
     // Check to see if uploading is enabled
     if ($mainframe->isSite() && !LinkrHelper::getParam('frontend_upload', '0')) {
         // 401 Unauthorized
         return $this->end(401, 'Uploading Disabled');
     }
     $this->file = JRequest::getVar('Filedata', '', 'files', 'array');
     $this->json = JRequest::getVar('format', 'html', '', 'cmd') == 'json';
     $this->returnURL = 'index.php?option=com_linkr&view=articles&tmpl=component';
     LinkrHelper::log('File::upload ' . $this->file['name']);
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Make the filename safe
     $this->file['name'] = strtolower(JFile::makeSafe($this->file['name']));
     if (empty($this->file['name'])) {
         LinkrHelper::log('Upload failed: empty filename ');
         return $this->end(400, 'bad request');
     }
     if (!$this->canUpload()) {
         return $this->end(415, 'Unsupported Media Type');
     }
     // Get full filename
     $model =& $this->getModel('articles');
     $paths = $model->fileInfo();
     $name = $paths['path'] . DS . $this->file['name'];
     // Check filename
     $name = JPath::clean($name);
     if (JFile::exists($name)) {
         // 409 Conflict
         LinkrHelper::log("Upload failed: file already exists ({$name})");
         return $this->end(409, 'File already exists');
     }
     // Uplaod
     if (!JFile::upload($this->file['tmp_name'], $name)) {
         // Is this a 400 bad request or 500 internal error?
         LinkrHelper::log("Upload failed: could not upload file ({$name})");
         return $this->end(500, 'Could not upload file');
     }
     // Upload complete
     LinkrHelper::log('File uploaded');
     $this->end(200, 'File uploaded!');
 }
Example #3
0
 function debug()
 {
     static $debug;
     if (is_null($debug)) {
         $debug = JDEBUG || LinkrHelper::getParam('debug', '0');
     }
     return $debug;
 }
Example #4
0
 function folderItems()
 {
     // Get filetypes
     $exts = 'bmp,csv,doc,gif,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls';
     $exts = LinkrHelper::getMediaParam('upload_extensions', $exts);
     // Build regular expression
     $exts = preg_replace('/[^A-Z0-9,]/i', '', $exts);
     $exts = '\\.(' . str_replace(',', '|', $exts) . ')';
     // Get folder from request
     $info = $this->fileInfo();
     $folder = $info['path'];
     // Get folders
     if ($info['parent']) {
         $folders = LinkrHelper::listDirectories($info['path']);
     } else {
         $paths = LinkrHelper::getParam('paths', 'images');
         $regex = LinkrHelper::buildRegex($paths);
         $folders = LinkrHelper::listDirectories($info['base'], $regex);
     }
     // Get files
     $files = LinkrHelper::listFiles($folder, $exts);
     // Create output
     $items = '<div id="filedirlist">' . '<div style="clear:both;"></div>';
     // Parent directory
     $icon = JURI::root() . 'administrator/components/com_media/images/folderup_32.png';
     $icon = JHTML::image($icon, 'Folder', array('width' => 32, 'height' => 32, 'class' => 'big'));
     if ($info['parent']) {
         $click = 'LinkrHelper.fileDir(\'' . $info['parent.64'] . '\')';
         $items .= '<div class="item up">' . '<div class="icon" onclick="' . $click . '">' . '<div align="center" class="border"><a>' . $icon . '</a></div></div>' . '<div class="name">' . JText::_('up') . '</div>' . '</div>';
     }
     // Folders
     $icon = JURI::root() . 'administrator/components/com_media/images/folder.png';
     $icon = JHTML::image($icon, 'Folder', array('width' => 32, 'height' => 32, 'class' => 'big'));
     foreach ($folders as $d) {
         $click = 'LinkrHelper.fileDir(\'' . $d['path.64'] . '\')';
         $items .= '<div class="item">' . '<div class="icon" onclick="' . $click . '">' . '<div align="center" class="border"><a>' . $icon . '</a></div></div>' . '<div class="name">' . $d['name'] . '</div>' . '</div>';
     }
     // Files
     foreach ($files as $f) {
         $icon = array('width' => $f->width, 'height' => $f->height);
         $icon = JHTML::image($f->icon, $f->name, $icon);
         $title = $f->type . ' - ' . $f->name . ' (' . $f->size . ')';
         $name = str_replace('.' . $f->ext, '', $f->name);
         $click = 'LinkrHelper.file(\'' . $f->src . '\')';
         $items .= '<div class="item">' . '<div class="icon"title="' . $title . '"onclick="' . $click . '">' . '<div align="center" class="border"><a>' . $icon . '</a></div></div>' . '<div class="name">' . $name . '</div>' . '</div>';
     }
     return $items . '</div>';
 }
Example #5
0
?>
</a>
	&nbsp;|&nbsp;
	<a href="index.php?option=com_linkr&view=docs&about=related#goto"><?php 
echo JText::_('RELATED_ARTICLES');
?>
</a>
	&nbsp;|&nbsp;
	<a href="index.php?option=com_linkr&view=docs&about=faqs#goto"><?php 
echo JText::_('FAQs');
?>
</a>
	&nbsp;|&nbsp;
<?php 
// Debug
if (LinkrHelper::getParam('debug', 0)) {
    ?>
	<a style="color:#990000;" href="index.php?option=com_linkr&view=docs&about=debug#goto"><?php 
    echo JText::_('PARAM_DEBUG');
    ?>
</a>
	&nbsp;|&nbsp;
<?php 
}
?>
	<a href="http://extensions.joomla.org/extensions/4010/details" target="_blank">JED &#187;</a>
	<!-- http://extensions.joomla.org/index.php?option=com_mtree&task=viewlink&link_id=4010 -->
</div>

<?php 
echo $this->loadTemplate($this->about);
Example #6
0
 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;
 }
Example #7
0
 function _fileInfo()
 {
     if (isset($this->_fi)) {
         return $this->_fi;
     }
     // Paths list
     $i = array('path.list' => array());
     $paths = LinkrHelper::getParam('paths', 'images');
     $paths = $this->getState('path', $paths, 'STRING');
     $list = @explode(',', $paths);
     foreach ($list as $p) {
         $p = trim($p);
         if (!strlen($p)) {
             continue;
         }
         $p = str_replace('/', DS, $p);
         $p = substr($p, 0, 1) == DS ? $p : DS . $p;
         $p = substr($p, -1) == DS ? substr($p, 0, -1) : $p;
         if (is_dir(JPATH_ROOT . $p)) {
             $i['path.list'][] = JPATH_ROOT . $p;
         }
     }
     if (!count($i['path.list'])) {
         $i['path.list'][] = JPATH_ROOT . DS . 'images';
     }
     // Base folder
     if (count($i['path.list']) == 1) {
         $i['base'] = $i['path.list'][0];
         $i['base.regex'] = '.';
         $i['base.folder'] = str_replace(JPATH_ROOT . DS, '', $i['base']);
         $i['base.folder'] = str_replace(DS, '/', $i['base.folder']);
     } else {
         $i['base'] = strlen(JPATH_ROOT) ? JPATH_ROOT : DS;
         $i['base.regex'] = LinkrHelper::buildRegex($paths);
         $i['base.folder'] = '/';
     }
     // Current path
     $i['path'] = $this->getState('current', null);
     $i['path'] = $i['path'] ? base64_decode($i['path']) : $i['base'];
     if (strpos($i['path'], $i['base']) !== 0) {
         $i['path'] = $i['base'];
     }
     $i['path.64'] = base64_encode($i['path']);
     // Collect information
     $i['base.64'] = base64_encode($i['base']);
     if ($i['path'] != $i['base']) {
         $parent = substr($i['path'], 0, strrpos($i['path'], DS));
         $i['parent'] = $parent;
         $i['parent.64'] = base64_encode($parent);
     } else {
         $i['parent'] = false;
         $i['parent.64'] = false;
     }
     // Return information
     $this->_fi = $i;
     return $this->_fi;
 }
Example #8
0
 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!');
 }