public string cleanTinyCode(string text)
        {
            bool has = text.IndexOf("tinyImgHolder") >= 0;

            //<img class="tinyImgHolder" title="#Inline_Iamge(210 434 180 336 ' fLeft')" src="../media/download.castle?id=210&aplaceid=434&m=crop&w=180&h=336&pre=TMP" alt="imagingIt|210" width="180" height="336" />
            if (has)
            {
                string       strRegex       = @"<img(.*?)class=\""infotabTemplate(.*?)title=\""(.*?)\""(.*?)\/\>";
                RegexOptions myRegexOptions = RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace;
                Regex        myRegex        = new Regex(strRegex, myRegexOptions);
                text = myRegex.Replace(text, "${3}");
            }

            has = text.IndexOf("infotabTemplate") >= 0;
            //<img src="../Content/images/tinyMCE/template_whats_inside.png" rel="'+result[i].id+'" alt="'+result[i].alias+'" class="infotabTemplate" width="150" height="55" />
            if (has)
            {
                string       wholeStrRegex  = @".*?<img.*?class=\""infotabTemplate\"".*?alt=\""(.*?)\"".*?\/\>.*?$";
                RegexOptions myRegexOptions = RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace;
                Regex        myRegex        = new Regex(wholeStrRegex, myRegexOptions);
                int          id             = 0;
                int.TryParse(myRegex.Replace(text, "${1}"), out id);
                if (id > 0)
                {
                    infotabs_templates tmp = ActiveRecordBase <infotabs_templates> .Find(id);

                    string strRegex = @"<img.*?class=\""infotabTemplate\"".*?alt=\""(.*?)\"".*?\/\>";
                    myRegex = new Regex(strRegex, myRegexOptions);
                    text    = myRegex.Replace(text, tmp.content);
                }
            }
            return(text);
        }
예제 #2
0
        public void _edit_settings(int id)
        {
            users user = ActiveRecordBase <users> .Find(id);

            /* give access by group or ownership */
            if (user.id == userService.getUserFull().id || userService.getUserFull().groups.id == 2)
            {
                var values = new Dictionary <string, object>();
                if (!String.IsNullOrWhiteSpace(user.settings.attr) && user.settings.attr != "{}")
                {
                    var jss      = new JavaScriptSerializer();
                    var settings = jss.Deserialize <Dictionary <string, dynamic> >(user.settings.attr);
                    settings.ToList <KeyValuePair <string, dynamic> >();
                    foreach (KeyValuePair <string, dynamic> setting in settings)
                    {
                        values.Add(setting.Key, setting.Value);
                    }
                }
                PropertyBag["settings"] = values;
                PropertyBag["user"]     = user;
                RenderView("../admin/settings/_edit");
            }
            else
            {
                Flash["message"] = "You don't have access to this user's settings";
                RedirectToAction("_list_siteSettings");
            }
        }
예제 #3
0
        public void RemoveRecipe(int id)
        {
            RecipeVO recipeVo = ActiveRecordBase <RecipeVO> .Find(id);

            recipeVo.Delete();
            eventMessenger.Publish(new RecipesUpdatedEvent());
        }
예제 #4
0
        /// <summary> </summary>
        public void edit_user(int id, int page)
        {
            appuser user = ActiveRecordBase <appuser> .Find(id);

            if (!userService.checkPrivleage("edit_users") && user != userService.getUser())
            {
                Flash["error"] = "Sorry you are not able to edit this user.";
                RedirectToAction("list");
                return;
            }

            PropertyBag["history"] = PaginationHelper.CreatePagination((IList)ActiveRecordBase <logs> .FindAll(Order.Desc("date"),
                                                                                                               new List <AbstractCriterion>()
            {
                Expression.Eq("nid", user.nid)
            }.ToArray()
                                                                                                               ).ToList(), 15, page);
            //media_types imgtype = ActiveRecordBase<media_types>.Find(1); //TODO restore
            //PropertyBag["images"] = imgtype.media_typed; //Flash["images"] != null ? Flash["images"] :
            //PropertyBag["userimages"] = user.media; //TODO restore
            PropertyBag["user"]   = user;
            PropertyBag["groups"] = ActiveRecordBase <user_group> .FindAll();

            RenderView("edit");
        }
예제 #5
0
        //note that the xxxxxxmass arg should be a switch
        /// <summary> </summary>
        public new void massaction(int[] mass, String deletemass, String publishmass)
        {
            foreach (int id in mass)
            {
                if (!String.IsNullOrWhiteSpace(publishmass))
                {
                    dynamic item = ActiveRecordBase <_base> .Find(id);

                    if (item.owner.baseid == userService.getUser().baseid)
                    {
                        versionService.publish_post(item);
                    }
                }
                else if (!String.IsNullOrWhiteSpace(deletemass))
                {
                    dynamic item = ActiveRecordBase <_base> .Find(id);

                    if (item.owner.baseid == userService.getUser().baseid)
                    {
                        item.deleted = true;
                        ActiveRecordMediator <posting> .Save(item);
                    }
                }
            }
            RedirectToReferrer();
        }
        virtual public IList <place> getUserPlaces(int statusId, int limit)
        {
            IList <place> temp       = new List <place>();
            users         user       = userService.getUserFull();
            IList <place> userplaces = user.Places;

            if (statusId > 0)
            {
                object[] obj = new object[userplaces.Count];
                int      i   = 0;
                foreach (place p in userplaces)
                {
                    obj[i] = p.id;
                    i++;
                }
                List <AbstractCriterion> baseEx = new List <AbstractCriterion>();
                baseEx.Add(Expression.In("id", obj));
                List <AbstractCriterion> statusEx = new List <AbstractCriterion>();
                statusEx.AddRange(baseEx);
                statusEx.Add(Expression.Eq("status", ActiveRecordBase <status> .Find(statusId)));
                if (limit == 0)
                {
                    limit = 99999;
                }
                Order[] ord = new Order[1];
                ord[0] = Order.Asc("prime_name");
                temp   = ActiveRecordBase <place> .SlicedFindAll(0, limit, ord, statusEx.ToArray());
            }
            else
            {
                temp = userplaces;
            }
            return(temp);
        }
예제 #7
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);
        }
예제 #8
0
        /// <summary> </summary>
        public void applyMediaToObject(posting media, int id, string type)
        {
            switch (type)
            {
            case "events":
                posting events = ActiveRecordBase <posting> .Find(id);

                //events.images.Add(media);//FIX IT

                ActiveRecordMediator <posting> .Save(events);


                //events.Save();

                // So this should be abstracted to the bottom where the events is a var and same with the id
                String cachePath = file_info.root_path();
                cachePath += @"uploads\";
                cachePath += @"events\cache\";

                string file      = events.id + "_centralevents" + ".ext";
                String file_path = cachePath + file;
                if (File.Exists(file_path))
                {
                    File.Delete(file_path);
                }

                break;
            }
        }
        public void Edit(int id)
        {
            comments comment = ActiveRecordBase <comments> .Find(id);

            PropertyBag["comment"] = comment;
            RenderView("new");
        }
        public void adminViewed(int id)
        {
            comments comment = ActiveRecordBase <comments> .Find(id);

            comment.adminRead = true;
            ActiveRecordMediator <comments> .Save(comment);
        }
예제 #11
0
        /// <summary> </summary>
        public void edit_field(int id)
        {
            field_types field = ActiveRecordBase <field_types> .Find(id);

            PropertyBag["field"] = field;

            PropertyBag["p_models"] = ActiveRecordBase <posting_type> .FindAll();

            string ele_str = fieldsService.getfieldmodel_dynamic(field);

            PropertyBag["nat_html_ele"] = ele_str;


            //string json = "{\"Items\":[{ \"Name\":\"Apple\", \"Price\":12.3 },{ \"Name\":\"Grape\", \"Price\":3.21 }],\"Date\":\"21/11/2010\"}";
            var jss = new JavaScriptSerializer();
            var ele = jss.Deserialize <Dictionary <string, dynamic> >(field.attr.ToString());

            //elementSet ele = (elementSet)JsonConvert.DeserializeObject(field.attr.ToString(), typeof(elementSet));
            //string ele_str = FieldsService.getfieldmodel(ele);
            PropertyBag["groups"] = ActiveRecordBase <user_group> .FindAll();

            PropertyBag["users"] = ActiveRecordBase <appuser> .FindAll();

            PropertyBag["html_ele"] = ele_str;
            PropertyBag["ele"]      = ele;

            RenderView("../admin/fields/new");
        }
        public void Edit(int id)
        {
            advertisement advertisement = ActiveRecordBase <advertisement> .Find(id);

            PropertyBag["advertisementimages"] = advertisement.Images;
            PropertyBag["tags"] = ActiveRecordBase <tags> .FindAll();

            PropertyBag["advertisement"] = ActiveRecordBase <advertisement> .Find(id);

            media_types imgtype = ActiveRecordBase <media_types> .Find(2);

            PropertyBag["images"] = imgtype.media_typed;
            //PropertyBag["images"] = ActiveRecordBase<media_repo>.FindAll();
            PropertyBag["authors"] = ActiveRecordBase <users> .FindAll();

            //PropertyBag["classifiedtype"] = ActiveRecordBase<ClassifiedType>.FindAll();
            //PropertyBag["location"] = ActiveRecordBase<LocationType>.FindAll();
            List <tags> tags = new List <tags>();

            tags.AddRange(ActiveRecordBase <advertisement> .Find(id).Tags);
            int tagscounts = 0;

            if (ActiveRecordBase <advertisement> .Find(id).Tags != null)
            {
                tagscounts = ActiveRecordBase <advertisement> .Find(id).Tags.Count;
            }

            for (int i = tagscounts; i < 2; i++)
            {
                tags.Add(new tags());
            }
            PropertyBag["advertisementtags"] = tags;
            RenderView("new");
        }
예제 #13
0
        /// <summary> </summary>
        public void massaction(int[] mass, String deletemass, String restoremass)
        {
            foreach (int id in mass)
            {
                if (!String.IsNullOrWhiteSpace(restoremass))
                {
                    dynamic item = ActiveRecordBase <_base> .Find(id);

                    // if (item.owner.baseid == userService.getUser().baseid) {
                    item.deleted = false;
                    ActiveRecordMediator <_base> .Save(item);

                    //}
                }
                else if (!String.IsNullOrWhiteSpace(deletemass))
                {
                    dynamic item = ActiveRecordBase <_base> .Find(id);

                    // if (item.owner.baseid == userService.getUser().baseid) {
                    postingService.delete_item_forever(item);
                    //}
                }
            }
            if (!String.IsNullOrWhiteSpace(restoremass))
            {
                Flash["message"] = "Items " + mass.ToString() + ", has been <strong>restored</strong>.";
                logger.writelog("Removed Items " + mass.ToString() + ",  from the trash", getView(), getAction());
            }
            else if (!String.IsNullOrWhiteSpace(deletemass))
            {
                Flash["message"] = "Items " + mass.ToString() + ", has been <strong>deleted</strong>.";
                logger.writelog("Removed  Items " + mass.ToString() + " from the trash", getView(), getAction());
            }
            RedirectToAction("trashbin");
        }
예제 #14
0
        /// <summary> </summary>
        public void show_diff(int parent, int rev1id, int rev2id, Boolean ajxed)
        {
            if (ajxed)
            {
                CancelLayout();
            }
            posting parent_post = ActiveRecordBase <posting> .Find(parent);

            posting rev1 = ActiveRecordBase <posting> .FindFirst(new Order("revision", false),
                                                                 new List <AbstractCriterion>() {
                Expression.Eq("revision", rev1id),
                Expression.Eq("parent", parent_post)
            }.ToArray()
                                                                 );

            posting rev2 = ActiveRecordBase <posting> .FindFirst(new Order("revision", false),
                                                                 new List <AbstractCriterion>() {
                Expression.Eq("revision", rev2id),
                Expression.Eq("parent", parent_post)
            }.ToArray()
                                                                 );

            String text1 = rev1.content;
            String text2 = rev2.content;

            PropertyBag["rev1"]        = rev1;
            PropertyBag["rev2"]        = rev2;
            PropertyBag["parent_post"] = parent_post;
            PropertyBag["rev1text"]    = text1;
            PropertyBag["rev2text"]    = text2;
            PropertyBag["diff"]        = cms.utils.Diff.PrintItems(cms.utils.Diff.DiffText(text1, text2, true, true, true));
            RenderView("/admin/diff/show_diff.vm");
        }
예제 #15
0
        /// <summary> </summary>
        public void edit_master_connection(int id)
        {
            connections_master item = ActiveRecordBase <connections_master> .Find(id);

            PropertyBag["item"] = item;
            RenderView("../admin/master_con");
        }
예제 #16
0
        /// <summary> </summary>
        public void edit_slave_connection(int id)
        {
            connections_slave item = ActiveRecordBase <connections_slave> .Find(id);

            PropertyBag["item"] = item;
            RenderView("../admin/slave_con");
        }
예제 #17
0
        /// <summary> </summary>
        public void configuration(int siteid)
        {
            PropertyBag["frontend_themelist"] = themeService.list_themes();

            PropertyBag["posting_types"] = ActiveRecordBase <posting_type> .FindAll();

            PropertyBag["posting_type_actions"] = ActiveRecordBase <posting_type_action> .FindAll();

            site site_obj = new site();

            if (siteid > 0)
            {
                site_obj = ActiveRecordBase <site> .Find(siteid);
            }
            else
            {
                List <AbstractCriterion> filtering = new List <AbstractCriterion>();
                filtering.Add(Expression.Eq("is_default", true));
                site_obj = ActiveRecordBase <site> .FindFirst(filtering.ToArray());
            }
            PropertyBag["site"] = site_obj;

            foreach (options option in site_obj.options)
            {
                if (!String.IsNullOrWhiteSpace(option.option_key))
                {
                    PropertyBag[option.option_key.ToUpper()] = option.value;//ie: post.get_meta("title");
                }
            }

            RenderView("../admin/configuration");
        }
예제 #18
0
        /// <summary> </summary>
        internal void delete_post <t>(int id)
        {
            dynamic post = ActiveRecordBase <t> .Find(id);

            post.deleted = true;
            ActiveRecordMediator <dynamic> .SaveAndFlush(post);
        }
예제 #19
0
        public void _edit_privilege(int id)
        {
            privileges privilege = ActiveRecordBase <privileges> .Find(id);

            PropertyBag["privilege"] = privilege;
            RenderView("_edit_privilege");
        }
        public IList <place> searchPlaces(String str)
        {
            // Container IList, all searched places will be saved
            IList <place> allPlaces = new List <place>();

            ICriterion expression           = Expression.Like("Title", str, MatchMode.Anywhere);
            List <AbstractCriterion> baseEx = new List <AbstractCriterion>();

            baseEx.Add(Expression.Eq("Status", ActiveRecordBase <status> .Find(3)));
            baseEx.Add(Expression.Lt("PublishTime", DateTime.Now));


            // Search by Title
            List <AbstractCriterion> titleEx = new List <AbstractCriterion>();

            titleEx.AddRange(baseEx);
            titleEx.Add(Expression.Like("Title", str, MatchMode.Anywhere));
            place[] places = ActiveRecordBase <place> .FindAll(Order.Asc("Order"), titleEx.ToArray());

            allPlaces = AddList(places, allPlaces);

            // Search by BodyText
            List <AbstractCriterion> BodyTextEx = new List <AbstractCriterion>();

            BodyTextEx.AddRange(baseEx);
            BodyTextEx.Add(Expression.Like("BodyText", str, MatchMode.Anywhere));
            places = ActiveRecordBase <place> .FindAll(Order.Asc("Order"), BodyTextEx.ToArray());

            allPlaces = AddList(places, allPlaces);

            //Search By HotTopics
            List <AbstractCriterion> HotTopicsEx = new List <AbstractCriterion>();

            HotTopicsEx.AddRange(baseEx);
            HotTopicsEx.Add(Expression.Like("HotTopics", str, MatchMode.Anywhere));
            places = ActiveRecordBase <place> .FindAll(Order.Asc("Order"), HotTopicsEx.ToArray());

            allPlaces = AddList(places, allPlaces);

            // Search By Teaser
            List <AbstractCriterion> TeaserEx = new List <AbstractCriterion>();

            TeaserEx.AddRange(baseEx);
            TeaserEx.Add(Expression.Like("Teaser", str, MatchMode.Anywhere));
            places = ActiveRecordBase <place> .FindAll(Order.Asc("Order"), TeaserEx.ToArray());

            allPlaces = AddList(places, allPlaces);

            // Search By subHead
            List <AbstractCriterion> subHeadEx = new List <AbstractCriterion>();

            subHeadEx.AddRange(baseEx);
            subHeadEx.Add(Expression.Like("subHead", str, MatchMode.Anywhere));
            places = ActiveRecordBase <place> .FindAll(Order.Asc("Order"), subHeadEx.ToArray());

            allPlaces = AddList(places, allPlaces);

            return(allPlaces);
        }
예제 #21
0
        /// <summary> </summary>
        public void delete_user(int id)
        {
            appuser auth = ActiveRecordBase <appuser> .Find(id);

            ActiveRecordMediator <appuser> .Delete(auth);

            RedirectToReferrer();
        }
예제 #22
0
        public void delete(int id)
        {
            users auth = ActiveRecordBase <users> .Find(id);

            ActiveRecordMediator <users> .Delete(auth);

            RedirectToReferrer();
        }
예제 #23
0
        /// <summary> </summary>
        public void view_ContactProfile(int id)
        {
            CancelLayout();
            CancelView();
            PropertyBag["profile"] = ActiveRecordBase <contact_profile> .Find(id);

            RenderView("view_profile");
        }
예제 #24
0
        public void delete_usertags(int id)
        {
            usertags tag = ActiveRecordBase <usertags> .Find(id);

            ActiveRecordMediator <usertags> .Delete(tag);

            RedirectToReferrer();
        }
예제 #25
0
 virtual public bool isPublished()
 {
     if (this.status == ActiveRecordBase <status> .Find(3) && this.publish_time != null && this.publish_time.Value.CompareTo(DateTime.Now) <= 0)
     {
         return(true);
     }
     return(false);
 }
        public void delete(int id)
        {
            person person = ActiveRecordBase <person> .Find(id);

            ActiveRecordMediator <person> .Delete(person);

            RedirectToAction("list");
        }
예제 #27
0
        /// <summary> </summary>
        public void edit_privilege(int id)
        {
            privilege privilege = ActiveRecordBase <privilege> .Find(id);

            logger.writelog("Editing privilege", getView(), getAction(), privilege.baseid);
            PropertyBag["privilege"] = privilege;
            RenderView("_edit_privilege");
        }
예제 #28
0
        /// <summary> </summary>
        public void delete(int id)
        {
            taxonomy tag = ActiveRecordBase <taxonomy> .Find(id);

            ActiveRecordMediator <taxonomy> .Delete(tag);

            RedirectToReferrer();
        }
        public void edit_nav(int id)
        {
            HelperService.writelog("Editing nav categories", id);
            categories nav = ActiveRecordBase <categories> .Find(id);

            PropertyBag["nav"] = nav;
            RenderView("../admin/nav/_editor");
        }
        public void DeleteTag(int id, int advertisementId)
        {
            tags tag = ActiveRecordBase <tags> .Find(id);

            advertisement advertisement = ActiveRecordBase <advertisement> .Find(advertisementId);

            advertisement.Tags.Remove(tag);
            ActiveRecordMediator <advertisement> .Save(advertisement);
        }