Beispiel #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();
     $lingo =& JFactory::getLanguage();
     $doc =& JFactory::getDocument();
     // Include styles
     $doc->addStyleSheet(LINKR_ASSETS . 'css/modal.css?' . LINKR_VERSION_INC);
     // 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::getPluginParam('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);
 }
Beispiel #2
0
 /**
  * Method to display the related links layout
  *
  * @return string HTML code for layout
  */
 function layoutRelated()
 {
     // Check to see if plugin is installed
     if (!LinkrHelper::getPluginParam()) {
         return '<div style="padding:20px;text-align:center;">' . JText::_('NOTICE_INSTALL') . '</div>';
     }
     // Check to see if related links are added by default
     $msg = '';
     if (LinkrHelper::getPluginParam('def_rel', '0')) {
         $msg = $this->notice('NOTICE_RELATED');
     }
     $settings = $this->getAnchorSettings('related');
     $keywords = empty($settings['keywords']) ? '' : $settings['keywords'];
     $content = empty($settings) ? '' : $this->contentRelated($settings);
     return $msg . '<h2 class="linkrh2">' . JText::_('Related Article Links') . '</h2>' . '<p style="text-align:center;">' . JText::_('Type in some keywords') . sp . '<input type="text"id="words" ' . 'value="' . $keywords . '"/>' . sp . '<input type="button"onclick="' . 'LinkrHelper.previewRelated()"value="' . JText::_('preview') . '"/>' . '</p>' . '<input type="hidden"id="excluded" />' . '<div id="preview"class="content">' . $content . '</div>';
 }
Beispiel #3
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;
 }
Beispiel #4
0
 function getRelatedPreview($txt)
 {
     // Check text
     $txt = JString::trim($txt);
     if (JString::strlen($txt) < 3) {
         return JText::sprintf('TYPEMIN', 3);
     }
     // Keywords
     $where = array();
     $txt = JString::str_ireplace(',', ';', $txt);
     $txt = @explode(';', $txt);
     foreach ($txt as $t) {
         $t = $this->_db->getEscaped($t, true);
         $t = $this->_db->Quote('%' . $t . '%', false);
         $w = array('LOWER(title) LIKE ' . $t, 'LOWER(introtext) LIKE ' . $t, 'LOWER(' . $this->_nQ('fulltext') . ') LIKE ' . $t, 'LOWER(metakey) LIKE ' . $t, 'LOWER(metadesc) LIKE ' . $t);
         $where[] = '(' . implode(') OR (', $w) . ')';
     }
     // Publish dates
     $dbo =& JFactory::getDBO();
     $date =& JFactory::getDate();
     $now = $dbo->Quote($date->toMySQL());
     $nulld = $dbo->Quote($dbo->getNullDate());
     // User access
     $user =& JFactory::getUser();
     $aid = (int) $user->get('aid', 0);
     // Order
     switch (LinkrHelper::getPluginParam('rel_sort', 'random')) {
         case 'title':
             $order = 'title ASC, alias ASC';
             break;
         case 'date_asc':
             $order = 'publish_up ASC, created ASC, modified ASC';
             break;
         case 'date_desc':
             $order = 'publish_up DESC, created DESC, modified DESC';
             break;
         case 'modified':
             $order = 'modified ASC, publish_up ASC, created ASC';
             break;
         case 'popular':
             $order = 'hits DESC, publish_up ASC, created ASC';
             break;
         default:
             $order = 'rand()';
     }
     // SQL Query
     $q = ' SELECT id, title FROM #__content ' . ' WHERE state = 1 AND access <= ' . $aid . ' AND ( publish_up = ' . $nulld . ' OR publish_up <= ' . $now . ' ) ' . ' AND ( publish_down = ' . $nulld . ' OR publish_down >= ' . $now . ' ) ' . ' AND (' . implode(') OR (', $where) . ') ' . ' ORDER BY ' . $order;
     // Query database
     $list = $this->_getList($q);
     if ($this->_db->getErrorNum()) {
         return 'Database Error: ' . $this->_db->getErrorMsg();
     } elseif (empty($list) || empty($list[0])) {
         return JText::_('NORESULTS');
     }
     // Return article list
     return $list;
 }