Esempio n. 1
0
        /// <summary> </summary>
        virtual public int getLastRevision()
        {
            posting lastversion = this.latest_copy();
            int     rev         = lastversion != null ? lastversion.revision : 0;

            return(rev);
        }
Esempio n. 2
0
        /// <summary> </summary>
        virtual public List <string> get_post_feilds(posting post)
        {
            List <AbstractCriterion> typeEx = new List <AbstractCriterion>();

            typeEx.Add(Expression.Eq("set", post.post_type.baseid));
            field_types[] ft = ActiveRecordBase <field_types> .FindAll(typeEx.ToArray());

            List <string> fields = new List <string>();

            List <string> user_fields = new List <string>();

            if (ft != null)
            {
                foreach (field_types ft_ in ft)
                {
                    if ((ft_.users.Count > 0) || (ft_.users.Count > 0))
                    {
                        if (ft_.users.Contains(userService.getUser()))
                        {
                            user_fields.Add(fieldsService.get_field(ft_, post));
                        }
                        else
                        {
                            fields.Add(fieldsService.get_field(ft_, post));
                        }
                    }
                    else
                    {
                        user_fields.Add(fieldsService.get_field(ft_, post));
                    }
                }
            }
            return(fields);
        }
Esempio n. 3
0
        /// <summary> </summary>
        virtual public String get_template(String type)
        {
            if (!this.post_type.is_templatable)
            {
                return("");
            }

            posting post_obj = ActiveRecordBase <posting> .Find(this.baseid);

            posting template = post_obj.get_template_obj(type);
            site    site     = siteService.getCurrentSite();
            String  theme    = site.get_option("current_site_theme"); // Controllers.BaseController.theme;//

            String result = "";

            if (template != null)
            {
                if (template.loads_file)
                {
                    String template_file = themeService.theme_path(site, theme, this.is_admin ? "admin" : "frontend", type).Trim('/') + '/' + template.static_file.Trim('/');
                    if (file_info.file_exists(template_file))
                    {
                        result = file_handler.read_from_file(template_file);
                    }
                }
                else
                {
                    result = template.content;
                }
            }
            return(result);
        }
Esempio n. 4
0
        /// <summary> </summary>
        virtual public string title()
        {
            String title = this.get_meta("title");

            if (String.IsNullOrWhiteSpace(title))
            {
                posting post_obj = ActiveRecordBase <posting> .Find(this.baseid);

                title = post_obj.name.Replace("&", "&amp;").Replace("&&amp;", "&amp;");
            }
            return(title);
        }
Esempio n. 5
0
        //this = posting
        /// <summary> </summary>
        virtual public posting get_template_obj(String type)
        {
            if (!this.is_templatable)
            {
                return(null);
            }

            posting post_obj = ActiveRecordBase <posting> .Find(this.baseid);

            posting[] templatelist = ActiveRecordBase <posting> .FindAll(new Order[] { Order.Asc("baseid") },
                                                                         new List <AbstractCriterion>() {
                Expression.Eq("deleted", false),
                Expression.IsNull("parent"),                        // the  parent null makes it the working copy
                Expression.Eq("post_type", ActiveRecordBase <posting_type> .FindFirst(
                                  new List <AbstractCriterion>()
                {
                    Expression.Eq("alias", type)
                }.ToArray()
                                  )
                              )
            }.ToArray()
                                                                         );

            if (templatelist.Length > 0)
            {
                templatelist = templatelist.Where(
                    x => (x.postchildren.Contains(post_obj) && post_obj.postparents.Contains(x) ||
                          (post_obj.postparents.Count == 0 && x.is_default)
                          )).ToArray();
                if (templatelist.Length > 0)
                {
                    posting template = templatelist.First();
                    return(template);
                }
            }
            return(null);
        }
Esempio n. 6
0
 /// <summary> </summary>
 virtual public Boolean is_overwriteable(posting post)
 {
     return((post.tmp) ? false : this.overwriteable);
 }
Esempio n. 7
0
        /// <summary> </summary>
        virtual public Boolean this_is_templatable()
        {
            posting post_obj = ActiveRecordBase <posting> .Find(this.baseid);

            return((!post_obj.post_type.is_overwriteable(post_obj)) ? post_obj.post_type.is_templatable : post_obj.is_templatable);
        }
Esempio n. 8
0
        /// <summary> </summary>
        virtual public Boolean this_gets_metadata()
        {
            posting post_obj = ActiveRecordBase <posting> .Find(this.baseid);

            return((!post_obj.post_type.is_overwriteable(post_obj)) ? post_obj.post_type.gets_metadata : post_obj.gets_metadata);
        }