///
" ); htmlBuilder.Append( HttpUtility.HtmlEncode( baseFileName ) ); htmlBuilder.Append( "" ); } else if ( sourceUrl != null ) { htmlBuilder.Append( HtmlTools.FixRelativeLinks( text, sourceUrl ) ); htmlBuilder.Append( "
" );
htmlBuilder.Append( sourceUrl );
htmlBuilder.Append( "" );
}
else
{
htmlBuilder.Append( text );
}
htmlBuilder.Append( "" );
clipping.SetProp( Core.Props.LongBody, htmlBuilder.ToString() );
clipping.SetProp( Core.Props.LongBodyIsHTML, true );
}
else if ( textFormat == TextFormat.Rtf )
{
clipping.SetProp( Core.Props.LongBody, text );
clipping.SetProp( Core.Props.LongBodyIsRTF, true );
}
clipping.SetProp( Core.Props.Subject, subject );
clipping.SetProp( "IsClippingFakeProp", true );
clipping.SetProp( Core.Props.Date, DateTime.Now );
if ( baseResource != null )
{
clipping.SetProp( "ContentType", baseResource.Type );
int[] linkTypeIds = baseResource.GetLinkTypeIds();
foreach( int propId in linkTypeIds )
{
if ( Core.ResourceStore.PropTypes [propId].HasFlag( PropTypeFlags.SourceLink ) )
{
clipping.SetProp( "ContentLinks", Core.ResourceStore.PropTypes [propId].Name );
break;
}
}
clipping.AddLink( "Fragment", baseResource );
}
else if ( sourceUrl != null )
{
clipping.SetProp( "ContentType", "Weblink" );
clipping.SetProp( "Url", sourceUrl );
}
return clipping;
}
private static void OnFragmentSaved( IResource res, object tag )
{
Core.WorkspaceManager.AddToActiveWorkspace( res );
Core.TextIndexManager.QueryIndexing( res.Id );
Core.FilterEngine.ExecRules( StandardEvents.ResourceReceived, res );
FragmentEditPane editPane = (FragmentEditPane) tag;
if ( editPane != null && editPane.OpenAfterSave )
{
Core.ResourceBrowser.DisplayResource( res );
if ( !Core.ResourceBrowser.LinksPaneExpanded )
{
Core.ResourceBrowser.ContentChanged += OnResorceBrowserContentChanged;
}
Core.ResourceBrowser.LinksPaneExpanded = true;
}
}
private static void OnResorceBrowserContentChanged( object sender, EventArgs e )
{
IResourceBrowser resourceBrowser = ICore.Instance.ResourceBrowser;
resourceBrowser.LinksPaneExpanded = false;
resourceBrowser.ContentChanged -= OnResorceBrowserContentChanged;
}
public void Update( IActionContext context, ref ActionPresentation presentation )
{
bool hasSelectedText = ( context.SelectedText != null &&
context.SelectedPlainText != null && context.SelectedPlainText.Length > 0 );
if ( !hasSelectedText )
{
if ( context.Kind == ActionContextKind.ContextMenu )
presentation.Visible = false;
else
presentation.Enabled = false;
}
}
}
/**
* Action for editing the properties of a fragment.
*/
public class EditFragmentAction: IAction
{
public void Execute( IActionContext context )
{
IResource fragment = context.SelectedResources [0];
ICore.Instance.UIManager.OpenResourceEditWindow(
new FragmentEditPane(), fragment, false );
}
public void Update( IActionContext context, ref ActionPresentation presentation )
{
if ( context.SelectedResources.Count != 1 )
{
presentation.Visible = false;
}
}
}
public class FragmentTextProvider: IResourceTextProvider
{
private readonly JetRichTextBox _converterTextBox;
public FragmentTextProvider()
{
_converterTextBox = new JetRichTextBox();
}
public bool ProcessResourceText( IResource res, IResourceTextConsumer consumer )
{
if ( res.HasProp( Core.Props.LongBodyIsRTF ) )
{
ProcessRTFFragment( res, consumer );
}
else
{
ProcessHTMLFragment( res, consumer );
}
return true;
}
private void ProcessRTFFragment( IResource res, IResourceTextConsumer consumer )
{
string body = res.GetPropText( Core.Props.LongBody );
lock( this )
{
_converterTextBox.RichText = body;
consumer.AddDocumentFragment( res.Id, _converterTextBox.PlainText );
}
}
private static void ProcessHTMLFragment( IResource res, IResourceTextConsumer consumer )
{
HtmlIndexer.IndexHtml( res, res.GetPropText( Core.Props.LongBody ), consumer, null );
}
}
/**
* Action for sending a fragment by e-mail.
*/
public class EmailFragmentAction: ActionOnSingleResource
{
public override void Execute( IActionContext context )
{
IResource fragment = context.SelectedResources [0];
IEmailService emailService = (IEmailService) Core.PluginLoader.GetPluginService( typeof(IEmailService) );
if ( emailService != null )
{
emailService.CreateEmail( fragment.GetPropText( Core.Props.Subject ),
fragment.GetPropText( Core.Props.LongBody ),
fragment.HasProp( Core.Props.LongBodyIsHTML ) ? EmailBodyFormat.Html : EmailBodyFormat.PlainText,
Core.ResourceStore.EmptyResourceList, new string[] {}, true );
}
}
public override void Update( IActionContext context, ref ActionPresentation presentation )
{
base.Update( context, ref presentation );
if ( context.SelectedResources.Count > 0 &&
context.SelectedResources [0].HasProp( Core.Props.LongBodyIsRTF ) )
{
presentation.Enabled = false;
}
}
}
///
{0}", HttpUtility.HtmlEncode( item.GetPropText( Core.Props.LongBody ) ) ); if(item.HasProp( "Url" )) writer.WriteLine( "