Exemple #1
0
        private void PublishAlias(AutoroutePart part)
        {
            ProcessAlias(part);

            // Should it become the home page?
            if (part.PromoteToHomePage)
            {
                // Get the current homepage an unmark it as the homepage.
                var currentHomePage = _homeAliasService.GetHomePage(VersionOptions.Latest);
                if (currentHomePage != null && currentHomePage.Id != part.Id)
                {
                    var autoroutePart = currentHomePage.As <AutoroutePart>();

                    if (autoroutePart != null)
                    {
                        autoroutePart.PromoteToHomePage = false;
                        if (autoroutePart.IsPublished())
                        {
                            _tomeltServices.ContentManager.Publish(autoroutePart.ContentItem);
                        }
                    }
                }

                // Update the home alias to point to this item being published.
                _homeAliasService.PublishHomeAlias(part);
            }

            _autorouteService.Value.PublishAlias(part);
        }
Exemple #2
0
        public override void Execute(RecipeExecutionContext context)
        {
            var root = context.RecipeStep.Step;
            var routeValueDictionary = root.Elements().ToDictionary(x => x.Name.LocalName.ToLower(), x => (object)x.Value);
            var homePageIdentifier   = root.Attr("Id");
            var homePageIdentity     = new ContentIdentity(homePageIdentifier);
            var homePage             = !String.IsNullOrEmpty(homePageIdentifier) ? _contentManager.ResolveIdentity(homePageIdentity) : default(ContentItem);

            if (homePage != null)
            {
                _homeAliasService.PublishHomeAlias(homePage);
            }
            else
            {
                _homeAliasService.PublishHomeAlias(new RouteValueDictionary(routeValueDictionary));
            }
        }
Exemple #3
0
        public void Create()
        {
            if (String.IsNullOrEmpty(Owner))
            {
                Owner = _siteService.GetSiteSettings().SuperUser;
            }

            var owner = _membershipService.GetUser(Owner);

            _authenticationService.SetAuthenticatedUserForRequest(owner);

            var page = _contentManager.Create("Page", VersionOptions.Draft);

            page.As <TitlePart>().Title   = Title;
            page.As <ICommonPart>().Owner = owner;

            if (!String.IsNullOrWhiteSpace(MenuText))
            {
                var menu = _menuService.GetMenu(MenuName);

                if (menu != null)
                {
                    var menuItem = _contentManager.Create <ContentMenuItemPart>("ContentMenuItem");
                    menuItem.Content = page;
                    menuItem.As <MenuPart>().MenuPosition = Position.GetNext(_navigationManager.BuildMenu(menu));
                    menuItem.As <MenuPart>().MenuText     = MenuText;
                    menuItem.As <MenuPart>().Menu         = menu;
                }
            }

            var layout = default(string);

            if (UseWelcomeText)
            {
                var text = T(
                    @"<p>You've successfully setup your Orchard Site and this is the homepage of your new site.
Here are a few things you can look at to get familiar with the application.
Once you feel confident you don't need this anymore, you can
<a href=""Admin/Contents/Edit/{0}"">remove it by going into editing mode</a>
and replacing it with whatever you want.</p>
<p>First things first - You'll probably want to <a href=""Admin/Settings"">manage your settings</a>
and configure Orchard to your liking. After that, you can head over to
<a href=""Admin/Themes"">manage themes to change or install new themes</a>
and really make it your own. Once you're happy with a look and feel, it's time for some content.
You can start creating new custom content types or start from the built-in ones by
<a href=""Admin/Contents/Create/Page"">adding a page</a>, or <a href=""Admin/Navigation"">managing your menus.</a></p>
<p>Finally, Orchard has been designed to be extended. It comes with a few built-in
modules such as pages and blogs or themes. If you're looking to add additional functionality,
you can do so by creating your own module or by installing one that somebody else built.
Modules are created by other users of Orchard just like you so if you feel up to it,
<a href=""http://orchardproject.net/contribution"">please consider participating</a>.</p>
<p>Thanks for using Orchard – The Orchard Team </p>", page.Id).Text;

                var asideFirstText = T(
                    @"<h2>First Leader Aside</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum.
Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>").Text;

                var asideSecondText = T(
                    @"<h2>Second Leader Aside</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum.
Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>").Text;

                var asideThirdText = T(
                    @"<h2>Third Leader Aside</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum.
Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>").Text;

                layout =
                    "{\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Canvas\"," +
                    "\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Grid\"," +
                    "\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Row\"," +
                    "\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Column\"," +
                    "\"data\": \"Width=12\"," +
                    "\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Html\"," +
                    "\"data\": \"Content=" + Encode(text) + "\"" +
                    "}]" +
                    "}]" +
                    "},{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Row\"," +
                    "\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Column\"," +
                    "\"data\": \"Width=4\"," +
                    "\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Html\"," +
                    "\"data\": \"Content=" + Encode(asideFirstText) + "\"" +
                    "}]" +
                    "},{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Column\"," +
                    "\"data\": \"Width=4\"," +
                    "\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Html\"," +
                    "\"data\": \"Content=" + Encode(asideSecondText) + "\"" +
                    "}]" +
                    "},{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Column\"," +
                    "\"data\": \"Width=4\"," +
                    "\"elements\": [{" +
                    "\"typeName\": \"Orchard.Layouts.Elements.Html\"," +
                    "\"data\": \"Content=" + Encode(asideThirdText) + "\"" +
                    "}]" +
                    "}]" +
                    "}]" +
                    "}]}]}";
            }
            else
            {
                if (!String.IsNullOrEmpty(Text))
                {
                    layout = @"{
    'elements': [{
        'typeName': 'Orchard.Layouts.Elements.Canvas',
        'elements': [{
            'typeName': 'Orchard.Layouts.Elements.Html',
            'data': 'Content=" + Encode(Text) + @"'
        }]
    }]
}";
                }
            }

            // (Layout) Hackish way to access the LayoutPart on the page without having to declare a dependency on Orchard.Layouts.
            var layoutPart = ((dynamic)page).LayoutPart;
            var bodyPart   = page.As <BodyPart>();

            if (bodyPart != null)
            {
                bodyPart.Text = Text;
            }

            // Check if we have a LayoutPart attached of type "LayoutPart". If Layouts is disabled, then the type would be "ContentPart".
            // This happens when the user executed the Core recipe, which does not enable the Layouts feature.
            if (layoutPart != null && layoutPart.GetType().Name == "LayoutPart")
            {
                layoutPart.LayoutData = layout;
            }

            if (Publish)
            {
                _contentManager.Publish(page);

                if (Homepage)
                {
                    _homeAliasService.PublishHomeAlias(page);
                }
            }

            Context.Output.WriteLine(T("Page created successfully.").Text);
        }