home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (fckplugin.js)

This example Drupal source code file (fckplugin.js) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

binsidelink, bisanchor, cut, directory, fck_tristate_disabled, file, getstate, if, linktonode, null, shref, true, unlink, var

The fckplugin.js Drupal example source code

/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
*  - GNU General Public License Version 2 or later (the "GPL")
*    http://www.gnu.org/licenses/gpl.html
*
*  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
*    http://www.gnu.org/licenses/lgpl.html
*
*  - Mozilla Public License Version 1.1 or later (the "MPL")
*    http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* Plugin to insert "Placeholders" in the editor.
*/

// The object used for all Placeholder operations.


// Register the Drupal tag commands.
FCKCommands.RegisterCommand( 'LinkToNode', new FCKDialogCommand( 'LinkToNode', FCKLang.DlgLinkToNode, FCKConfig.PluginsPath + 'linktonode/fck_linktonode.html', 400, 330 ) ) ;

// Create the Drupal tag buttons.
var oLinkNodeItem = new FCKToolbarButton( 'LinkToNode', 'LinkToNode', null, null, true, true ) ;
oLinkNodeItem.IconPath = FCKConfig.PluginsPath + 'linktonode/images/linktonode.gif';
FCKToolbarItems.RegisterItem( 'LinkToNode', oLinkNodeItem ) ;

FCK.ContextMenu.RegisterListener({
	AddItems : function( menu, tag, tagName )
	{
		var bInsideLink = ( tagName == 'A' || FCKSelection.HasAncestorNode( 'A' ) ) ;

		if ( bInsideLink || FCK.GetNamedCommandState( 'Unlink' ) != FCK_TRISTATE_DISABLED )
		{
			// Go up to the anchor to test its properties
			var oLink = FCKSelection.MoveToAncestorNode( 'A' ) ;
			var bIsAnchor = ( oLink && oLink.name.length > 0 && oLink.href.length == 0 ) ;
			// If it isn't a link then don't add the Link context menu
			if ( bIsAnchor )
			return ;

			// Get the actual Link href.
			var sHRef = oLink.getAttribute( '_fcksavedurl' ) ;
			if ( sHRef == null )
				sHRef = oLink.getAttribute( 'href' , 2 ) || '' ;
			
			if (sHRef.indexOf(FCKConfig.DrupalPath)==0 || sHRef.indexOf("internal:")==0) 
			{
				menu.RemoveAllItems() ;
				
				menu.AddItem( 'Cut'		, FCKLang.Cut	, 7, FCKCommands.GetCommand( 'Cut' ).GetState() == FCK_TRISTATE_DISABLED ) ;
				menu.AddItem( 'Copy'	, FCKLang.Copy	, 8, FCKCommands.GetCommand( 'Copy' ).GetState() == FCK_TRISTATE_DISABLED ) ;
				menu.AddItem( 'Paste'	, FCKLang.Paste	, 9, FCKCommands.GetCommand( 'Paste' ).GetState() == FCK_TRISTATE_DISABLED ) ;				
				menu.AddSeparator() ;
				if ( bInsideLink )
					menu.AddItem( 'LinkToNode', FCKLang.EditLink		, FCKConfig.PluginsPath + 'linktonode/images/linktonode.gif' ) ;
				menu.AddItem( 'Unlink'	, FCKLang.RemoveLink	, FCKConfig.PluginsPath + 'linktonode/images/linktonode.gif' ) ;
			}
		}
	}
});

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal fckplugin.js source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.