Click here to Skip to main content
15,885,546 members
Articles / Web Development / HTML

Mambo CMS Article Control

Rate me:
Please Sign up or sign in to vote.
4.60/5 (5 votes)
23 Oct 2011CPOL13 min read 26.5K   1.7K   9  
The code implements a system to create articles using MS-Word for use in the Mambo CMS. The majority of the code is a C# project that reads and parses HTML text created using MS Word. The support projects are a VBA macro for creating the needed HTML and an export/import system for getting localhost
//
// Text2Mambo - convert HTML to mambo CMS
// Copyright (C) 2009-2011 John Janssen
// http://www.travelisfun.org 
//
// This program is free software; you can redistribute it and/or modify
// it any way you want as long as the above copyright statement is maintained.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.Win32;
using Text2Mambo;

namespace Text2Mambo.Tools
{
  /// <summary>
  /// Structure to hold an content item, with a list of paragraphs.
  /// </summary>
  class ContentsItem : Collection<String>
  {
    public String userId;
    public String sectionId;
    public String categoryId;
    public String userAlias;
    public DateTime dateTime;
    public String title;
    public bool publish;
    public bool frontpage;
    public bool staticContent;
    public bool dateItem;
    
    /// <summary>
    /// Default constructor
    /// </summary>
    public ContentsItem()
    {
      publish = true;
      frontpage = false;
      staticContent = false;
      dateItem = false;
    }
    /// <summary>
    /// Adding a paragraph to the content item.
    /// </summary>
    /// <param name="paragraph"></param>
    public void AddParagraph(String paragraph)
    {
      AddParagraph(paragraph, true, false);
    }
    /// <summary>
    /// Adding a paragraph to the content item.
    /// </summary>
    /// <param name="paragraph"></param>
    /// <param name="wrapInParagraph"></param>
    public void AddParagraph(String paragraph, bool wrapInParagraph)
    {
      AddParagraph(paragraph, wrapInParagraph, false);
    }
    /// <summary>
    /// Adding a paragraph to the content item.
    /// </summary>
    /// <param name="paragraph">The paragraph text.</param>
    /// <param name="wrapInParagraph"></param>
    /// <param name="addEmpty"></param>
    public void AddParagraph(String paragraph, bool wrapInParagraph, bool addEmpty)
    {
      // Check for zero length paragraph's
      if (paragraph.Length == 0 && !addEmpty)
        return;
      if (paragraph[0] != '<')
      {
        if (wrapInParagraph)
          paragraph = "<p class=MsoNormal>" + paragraph + "</p>";
      }
      base.Add(paragraph);
    }
    /// <summary>
    /// Returns the number of paragraphs in the content item.
    /// </summary>
    /// <returns></returns>
    public int ParagraphCount()
    {
      return base.Count;
    }
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
South Africa South Africa
Started in 1988 programming in Pascal, making a 68000 emulator on a DOS platform. Then from Pascal to Clipper, to C++ and now using C#. I've been programming for all walks of businesses; opticians, opthomologist, carbage collectors, reinforcement steel producers, retail chains, and more.
I'm now travelling through Africa with a home-build expedition truck.

Comments and Discussions