Facebook Twitter Gplus LinkedIn YouTube Google Maps RSS
Home 2012 February
formats

Sharepoint Thesaurus

For the search service to provide results on synonyms of a site name, we need to add the synonyms to the ‘Thesaurus’ file.

The Thesaurus files are located in 2 locations on APP server (sp-app1). A total of 4 files need to be changed for the search to function properly.

Here are the file names and their locations.

File Names: tsenu.xml, tsneu.xml
Files Location: c:\program files\Microsoft Office Servers\14.0\Data\config
Files Location: C:\Program Files\Microsoft Office Servers\14.0\Data\Office Server\Applications\[GUID of search application]\Config

Open the xml file and you will see an example of how the synonyms should be formatted. Here is an example of a complete file:

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Checking if a site exists

protected internal static bool DoesSiteExist(string URL)
{
try
{
using (SPSite site = new SPSite(URL))
{
using (SPWeb web = site.AllWebs[GetServerRelUrlFromFullUrl(URL)])
{
return web.Exists;
}
}
}
catch (FileNotFoundException)
{
return false;
}
}

protected internal static string GetServerRelUrlFromFullUrl(string url)
{
int index = url.IndexOf(“//”);
if ((index < 0) || (index == url.Length - 2))
{
throw new ArgumentException();
}
int startIndex = url.IndexOf('/', index + 2);
if (startIndex < 0)
{
return "/";
}
string str = url.Substring(startIndex);
if (str.IndexOf("?") >= 0)
str = str.Substring(0, str.IndexOf(‘?’));
if (str.IndexOf(“.aspx”) > 0)
str = str.Substring(0, str.LastIndexOf(“/”));
if ((str.Length > 1) && (str[str.Length - 1] == ‘/’))
{
return str.Substring(0, str.Length – 1);
}
return str;
}

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

ECB Menu Items

Hiding Menu Items in the ECB from SharePoint List Items


Edit Control Block (ECB)  is the context menu that is displayed for all items in Lists and Document Libraries. This post focus on editing or hiding existing ECB menu items.
If you want to add new custom actions or menu items to the ECB menu, You can do it by:
1) Using  the element <CustomAction Location=”EditControlBlock” > in a Feature [recommended way].
2) Create a javascript function named Custom_AddListMenuItems and add it to a page or master page. For e.g.
//This function is called automatically from core.js in-built functions like AddListMenuItems(), AddDocLibMenuItems() etc…
function Custom_AddListMenuItems(m, ctx) {  �
//This function creates a new ECB item.
CAMOpt(m, “Test ECB item”, “alert(I am created from script!!’);”, “/_layouts/images/testECB.GIF”);
//This function creates a seperator line.
CAMSep(m);
}
If you want to hide or delete an existing menu item which is provided out-of-box by SharePoint, we cannot do it by using a feature. The out-of-box actions or menu items inECB are rendered by using a JavaScript file, which is core.js [Note : Modifying the core.js file is not supported or recommended]. So there are two ways we can hide existing menu items :
Create a copy of core.js and edit it to remove the ECB menu items we don’t want.
Use JQuery to hide the ECB menu items without editing core.js
We will discuss both the ways below ( I personally prefer no:2 as it is much easier )
Copy and Edit Core.js
Important:Please do not edit existing core.js
Following below steps  to create a customcore.js file and refer it in the master page.
Copy the core.js file from its default location ( For SP2010 : %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS\1033; For SP2007:%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033)  place it in the same folder, and rename as customcore.js file.
Remove unwanted ECB menu items by editing the appropriate functions like CreateMenuEx()(for SP2007 core.js), BuildMenu()(for SP2010 core.js),AddVersionMenuItems(), AddDocLibMenuItems() etc. For more details on the functions please see the section ”ECB menu items in core.js” below.
In the  master page, add the following line to render the customcore.js file [Note: core.jsis also required]:
<!–It is important to refer core.js even if you create and refer customcore.js–>
<SharePoint:ScriptLink language=”javascript” name=”core.js” Defer=”true” runat=”server”/>
<SharePoint:ScriptLink language=”javascript” name=”customcore.js” Defer=”true” runat=”server”/>
Save and publish the master page.
The  JavaScript function CreateMenu() (for SP2007) or BuildMenu() (for SP2010)  in core.js creates the menu items when you hover or click to edit a list item.
//This function is used to create ECB menu in SP2010
function BuildMenu(a) {
ULSrLq: ; var b = CMenu(currentItemID + “_menu”);
if (!b) return; else if (a.isVersions)
//Add ECB menu item if versioning is enabled in a list or document library(For eg. “Check Out”,”Version History”)
AddVersionMenuItems(b, a);
else if (a.listTemplate == 121)
//Add ECB menu item for solution catalog
AddSolutionsCatalogMenuItems(b, a);
else if (a.listBaseType == 1)
//Add menu item for items in document library (For eg. “Edit Document”)
AddDocLibMenuItems(b, a);
else if (a.listTemplate == 200)
//Add menu item for items in meetings
AddMeetingMenuItems(b, a);
else
//Add menu item for items in standard List (For eg. “View Item”,”Edit Item”)
AddListMenuItems(b, a);
InsertFeatureMenuItems(b, a);
return b
}
//This function is used to create ECB menu in SP2007
function CreateMenu(e)
{
if (!IsContextSet())
return;
var ctx=currentCtx;
if (e==null)
e=window.event;
var srcElement=e.srcElement ? e.srcElement : e.target;
if (itemTable==null || imageCell==null ||
(onKeyPress==false &&
(srcElement.tagName==”A” ||
srcElement.parentNode.tagName==”A”)))
return;
return CreateMenuEx(ctx, itemTable, e);
}
The  CreateMenu() function in SP2007 core .js calls CreateMenuEx() which calls respective functions to create ECB menu items for list items in a library, meeting or custom list.
function CreateMenuEx(ctx, container, e)
{
if (container==null)
return;
IsMenuShown=true;
document.body.onclick=”";
var m;
m=CMenu(currentItemID+”_menu”);
if (!m)
return;
else if (ctx.isVersions)
//Add menu item if versioning is enabled in a list or document library(For eg. “Check Out”,”Version History”)
AddVersionMenuItems(m, ctx);
else if (ctx.listBaseType==1)
//Add menu item for items in document library (For eg. “Edit Document”)
AddDocLibMenuItems(m, ctx);
else if (ctx.listTemplate==200)
//Add menu item for items in meetings
AddMeetingMenuItems(m, ctx);
else
//Add menu item for items in standard List (For eg. “View Item”,”Edit Item”)
AddListMenuItems(m, ctx);
InsertFeatureMenuItems(m, ctx);
currentEditMenu=m;
container.onmouseout=null;
OMenu(m, container, null, null, -1);
itemTable=GetSelectedElement(container, “TABLE”);
m._onDestroy=OutItem;
e.cancelBubble=true;
return false;
}
We can edit the JS functions(and inner functions) called above to remove the ECB menu items.We can comment the lines of code  which create menu items. These lines are  :
menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 700);
menuOption.id=”ID_[**action**]“;
The CAMOpt() function creates a new ECB menu item.We can comment the lines which call it to create a specific ECB menu item. Below are few examples. To remove “Check Out” ECB menu item, we can comment the below lines in AddCheckinCheckoutMenuItem() function:
// menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 700);
// menuOption.id=”ID_Checkout”;
To remove “Delete” ECB menu item from a list item, we can comment the below lines in AddListMenuItems() function:
//menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 300);
//menuOption.id=”ID_DeleteItem”;
Use JQuery to hide the ECB menu items
The ECB menu html which is created on fly by CreateMenu() looks like below. This can be manipulated by JQuery as well.
<!–the menu id is formed by Item Id + “_menu” –>
<menu id=”268_menu”>
<span type=”option” text=”View Properties” onmenuclick=”STSNavigate(‘/Documents/Forms/DispForm.aspx?ID=268′)” sequence=”200″ id=”ID_ViewProperties”></span>
<span type=”option” text=”Edit Properties” onmenuclick=”STSNavigateWithCheckoutAlert(‘/Documents/Forms/EditForm.aspx?ID=268′,1,’0′,’\u002fDocuments\test.pdf’,'http://sp2007site’)” iconsrc=”/_layouts/images/edititem.gif” iconalttext=”" sequence=”220″ id=”ID_EditProperties”></span>
<span type=”option” text=”Manage Permissions” onmenuclick=”NavigateToManagePermsPage(‘http://sp2007site’, ‘{A8073644-42BB-46C2-9CEC-33371585C51C}’,’268′)” iconsrc=”/_layouts/images/manageperm.gif” iconalttext=”" sequence=”250″ id=”ID_MngPerms”></span>
<span type=”option” text=”Delete” onmenuclick=”DeleteDocLibItem(‘/_vti_bin/owssvr.dll?CS=65001&amp;Cmd=Deletesequence=”310″ id=”ID_DeleteDocItem”></span>
<span type=”submenu” text=”Send To” iconalttext=”" sequence=”400″ id=”ID_Send”><span type=”option” text=”Other Location” onmenuclick=”STSNavigate(‘http://sp2007site/_layouts/copy.aspx?SourceUrl=%2FDocuments%2F090505%2Dtest%2Epdf&amp;’)” iconsrc=”/_layouts/images/sendOtherLoc.gif” iconalttext=”" id=”ID_OtherLocation”></span>
<span type=”separator”></span>
<span type=”option” text=”E-mail a Link” onmenuclick=”javascript:navigateMailToLinkNew(‘http://sp2007site/Documents/090505-test.pdf’)” iconsrc=”/_layouts/images/gmailnew.gif” iconalttext=”" id=”ID_SendToEmail”></span>
<span type=”option” text=”Create Document Workspace” onmenuclick=”STSNavigate(‘http://sp2007site/_layouts/createws.aspx?list={A8073644-42BB-46C2-9CEC-33371585C51C}&amp;item=268&amp;RootFolder=%2FDocuments’)” iconalttext=”" sequence=”1140″ id=”ID_CreateDWS”></span>
<span type=”option” text=”Download a Copy” onmenuclick=”STSNavigate(‘http://sp2007site/_layouts/download.aspx?SourceUrl=%2FDocuments%2F090505%2Dtest%2Epdf&amp;’) iconalttext=”" id=”ID_DownloadACopy”></span>
</span>
<span type=”separator”></span>
<span type=”option” text=”Check Out” onmenuclick=”CheckoutDocument(‘http://sp2007site’, ‘%2FDocuments%2F090505%2Dtest%2Epdf’, ‘.3′)” iconsrc=”/_layouts/images/checkout.gif” iconalttext=”" sequence=”700″ id=”ID_Checkout”></span>
<span type=”option” text=”Version History” onmenuclick=”NavigateToVersionsAspx(‘http://sp2007site’, ‘list={A8073644-42BB-46C2-9CEC-33371585C51C}&amp;ID=268&amp;FileName=%2FDocuments%2F090505%2Dtest%2Epdf’)” iconsrc=”/_layouts/images/versions.gif” iconalttext=”" sequence=”800″ id=”ID_Versions”></span>
<span type=”option” text=”Workflows” onmenuclick=”STSNavigate(‘http://sp2007site/_layouts/Workflow.aspx?ID=268&amp;List={A8073644-42BB-46C2-9CEC-33371585C51C}&amp;Source=http%3A%2F%2Fsp2007site%2FDocuments%2FForms%2FAllItems%2Easpx’)” iconsrc=”/_layouts/images/workflows.gif” iconalttext=”" sequence=”900″ id=”ID_Workflows”></span>
<span type=”separator”></span>
<span type=”option” text=”Alert Me” onmenuclick=”NavigateToSubNewAspx(‘http://sp2007site’, ‘List={A8073644-42BB-46C2-9CEC-33371585C51C}&amp;ID=268′)” iconalttext=”" sequence=”1100″ id=”ID_Subscribe”></span>
<span type=”separator”></span>
</menu>
The below jquery snippet hides the “Check Out” ECB menu item at mouseover on the div(class=ms-MenuUIPopupBody) that is created on fly everytime a ECB menu is constructed.
$(document).ready(function(){
$(‘.ms-MenuUIPopupBody’).live(‘mouseover’, function() {
$(‘#ID_Checkout’).parent().hide();
$(‘#ID_Checkout’).remove();
});
});
From: extreme Shaporint

Hiding Menu Items in the ECB from SharePoint List Items

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
© All rights reserved to Cyberbrutus. 2012
credit

Switch to our mobile site