/// <summary> </summary>
        public void help(int iid)
        {
            //if (!usedev) filtering.Add(Expression.Eq("revision", 0));
            posting post = null;

            if (iid > 0)
            {
                post = ActiveRecordBase <posting> .Find(iid).get_published();
            }
            else
            {
                List <AbstractCriterion> filtering = new List <AbstractCriterion>();
                filtering.Add(Expression.Eq("is_default", true));
                filtering.Add(Expression.Eq("deleted", false));
                filtering.Add(Expression.Eq("post_type", ActiveRecordBase <posting_type> .FindFirst(
                                                new List <AbstractCriterion>()
                {
                    Expression.Eq("alias", "documentation")
                }.ToArray())
                                            ));
                post = ActiveRecordBase <posting> .FindFirst(filtering.ToArray());

                if (post != null)
                {
                    post = post.get_published();
                }
            }
            if (post == null)
            {
                post = postingService.get_posting_by_url("/404.html", usedev);
                Response.StatusCode = 404;
            }
            /* Items that should be globaly accessed */
            //PropertyBag["campus"] = ActiveRecordBase<campus>.FindAllByProperty("name", "Pullman")[0];

            site site = siteService.getCurrentSite();

            PropertyBag["site"] = site;

            PropertyBag["baseurl"]     = "admin/help.castle";
            PropertyBag["htmlService"] = new htmlService();

            /* add site options */
            if (site.options != null && site.options.Count > 0)
            {
                foreach (options item in site.options)
                {
                    PropertyBag[item.option_key.ToUpper()] = item.value;    //ie: post.get_meta("title");
                }
            }

            /* add meta */
            if (post.meta_data != null && post.meta_data.Count > 0)
            {
                foreach (meta_data item in post.meta_data)
                {
                    PropertyBag[item.meta_key.ToUpper()] = item.value;    //ie: post.get_meta("title");
                }
            }

            String urlQueries = "";

            PropertyBag["urlQueries"] = String.IsNullOrWhiteSpace(urlQueries) ? "" : "iid[]=" + urlQueries.TrimStart(',');
            if (iid > 0)
            {
                PropertyBag["urlQueries"] += (String.IsNullOrWhiteSpace(urlQueries) ? "" : "&") + "iid=" + iid.ToString();
            }

            PropertyBag["siteroot"]   = httpService.getRootUrl().TrimEnd('/');
            PropertyBag["Controller"] = base.MemberwiseClone();
            Hashtable content_params = objectService.marge_params(PropertyBag, new Hashtable());
            String    output         = new renderService().render(post, content_params);



            // bool ActiveRecordBase<site_base>.FindFirst(new List<AbstractCriterion>() { Expression.Eq("name", "minhtml") }.ToArray())
            Boolean tmpB = false;

            if (tmpB)
            {
                output = htmlService.stripNonSenseContent(output, false);
            }

            //RenderText(output);
            PropertyBag["content"] = output;
            RenderView("../admin/default/actions/help");
        }
        /// <summary> </summary>
        public void posting(int iid, string[] cat, int activeitem, Boolean eb, Boolean hasUrl, string sm_url, Boolean dev)
        {
            List <AbstractCriterion> filtering = new List <AbstractCriterion>();

            editing            = true;
            PropertyBag["dev"] = dev;

            //if (!usedev) filtering.Add(Expression.Eq("revision", 0));
            if (iid > 0)
            {
                posting tmp = ActiveRecordBase <posting> .Find(iid);

                if (tmp.children.Count > 0)
                {
                    filtering.Add(Expression.Eq("parent", tmp));
                }
                else
                {
                    filtering.Add(Expression.Eq("baseid", iid));
                }
            }
            else
            {
                filtering.Add(Expression.Eq("is_default", true));
                //parent
                filtering.Add(Expression.Eq("deleted", false));
                filtering.Add(Expression.In("post_type", ActiveRecordBase <posting_type> .FindAll(
                                                new List <AbstractCriterion>()
                {
                    Expression.Eq("root", true)
                }.ToArray())
                                            ));
            }



            posting post = ActiveRecordBase <posting> .FindFirst(new Order[] { Order.Desc("revision"), Order.Desc("version") }, filtering.ToArray());

            PropertyBag["post"] = post;

            //posting post = ActiveRecordBase<posting>.Find(iid);
            posting[] lastversions = ActiveRecordBase <posting> .FindAll(Order.Asc("revision"),
                                                                         new List <AbstractCriterion>() { Expression.Eq("parent", post), Expression.Gt("revision", 0) }.ToArray()
                                                                         );

            PropertyBag["lastversions"] = lastversions;
            /* Items that should be globaly accessed */
            PropertyBag["url"] = sm_url;
            //PropertyBag["campus"] = ActiveRecordBase<campus>.FindAllByProperty("name", "Pullman")[0];

            PropertyBag["selected_taxanony"] = cat;
            PropertyBag["activeitem"]        = activeitem;
            PropertyBag["embeded"]           = eb;

            site site = siteService.getCurrentSite();

            PropertyBag["site"]        = site;
            PropertyBag["siteroot"]    = httpService.getRootUrl().TrimEnd('/');
            PropertyBag["baseurl"]     = "visible_editor/posting.castle";
            PropertyBag["htmlService"] = HtmlService; // maybe get rid of this?
            PropertyBag["Controller"]  = base.MemberwiseClone();


            /* add site options */
            foreach (options item in site.options)
            {
                PropertyBag[item.option_key.ToUpper()] = item.value;//ie: post.get_meta("title");
            }

            /* add meta */
            if (post.meta_data != null)
            {
                foreach (meta_data item in post.meta_data)
                {
                    PropertyBag[item.meta_key.ToUpper()] = item.value;//ie: post.get_meta("title");
                }
            }

            String urlQueries = "";

            PropertyBag["urlQueries"] = String.IsNullOrWhiteSpace(urlQueries) ? "" : "iid[]=" + urlQueries.TrimStart(',');
            if (iid > 0)
            {
                PropertyBag["urlQueries"] += (String.IsNullOrWhiteSpace(urlQueries) ? "" : "&") + "iid=" + iid.ToString();
            }

            PropertyBag["siteroot"] = httpService.getRootUrl().TrimEnd('/');

            PropertyBag["mode"] = "published";

            Hashtable content_params = objectService.marge_params(PropertyBag, new Hashtable());
            String    output         = new renderService().render(post, content_params);

            output = editingService.ini_editor(output, post, PropertyBag);

            RenderText(output);
        }
        /// <summary> </summary>
        public void posting(int iid, string[] cat, int activeitem, Boolean eb, Boolean hasUrl, string sm_url, Boolean dev) {
            //posting post = ActiveRecordBase<posting>.Find(iid);
            List<AbstractCriterion> filtering = new List<AbstractCriterion>();
            editing = false;
            PropertyBag["dev"] = dev;
            //if (!usedev) filtering.Add(Expression.Eq("revision", 0));
            posting post = null;
            if (iid > 0) {
                post = ActiveRecordBase<posting>.Find(iid).get_published();
            } else {
                filtering.Add(Expression.Eq("is_default", true));
                filtering.Add(Expression.Eq("deleted", false));
                filtering.Add(Expression.IsNull("parent")); // the  parent null makes it the working copy to first look too
                filtering.Add(Expression.Eq("post_type", ActiveRecordBase<posting_type>.FindFirst(
                            new List<AbstractCriterion>() { 
                                Expression.Eq("alias", "page")
                            }.ToArray())
                        ));
                post = ActiveRecordBase<posting>.FindFirst(new Order[] { Order.Desc("revision"), Order.Desc("version") }, filtering.ToArray());
                if (post != null) post = post.get_published();
            }

            if(post == null){
                post = postingService.get_posting_by_url("/404.html", usedev).get_published();
                Response.StatusCode = 404;
            }




            /* Items that should be globaly accessed */
            PropertyBag["url"] = sm_url;
            //PropertyBag["campus"] = ActiveRecordBase<campus>.FindAllByProperty("name", "Pullman")[0];

            PropertyBag["selected_taxanony"] = cat;
            PropertyBag["activeitem"] = activeitem;

            PropertyBag["embeded"] = eb;

            site site = siteService.getCurrentSite();
            PropertyBag["site"] = site;

            PropertyBag["baseurl"] = "public/posting.castle";
            PropertyBag["htmlService"] = HtmlService;

            /* add site options */
            if (site.options != null && site.options.Count > 0) {
                foreach (options item in site.options) {
                    PropertyBag[item.option_key.ToUpper()] = item.value.ToString();//ie: post.get_meta("title");
                }
            }

            /* add meta */
            if (post.meta_data != null && post.meta_data.Count > 0) {
                foreach (meta_data item in post.meta_data) {
                    PropertyBag[item.meta_key.ToUpper()] = item.value;//ie: post.get_meta("title");
                }
            }

            String urlQueries = "";
            PropertyBag["urlQueries"] = String.IsNullOrWhiteSpace(urlQueries) ? "" : "iid[]=" + urlQueries.TrimStart(',');
            if (iid > 0) {
                PropertyBag["urlQueries"] += (String.IsNullOrWhiteSpace(urlQueries) ? "" : "&") + "iid=" + iid.ToString();
            }

            PropertyBag["siteroot"] = httpService.getRootUrl().TrimEnd('/');
            PropertyBag["Controller"] = base.MemberwiseClone();
            PropertyBag["mode"] = "published";

            posting pub_post = post.get_published();
            PropertyBag["post"] = pub_post;

            Hashtable content_params = objectService.marge_params(PropertyBag, new Hashtable());


            String output = new renderService().render(post, content_params);



            // bool ActiveRecordBase<site_base>.FindFirst(new List<AbstractCriterion>() { Expression.Eq("name", "minhtml") }.ToArray())
            Boolean tmpB = false;
            if (tmpB) output = htmlService.stripNonSenseContent(output, false);

            RenderText(output);
        }