=====Category Update Action Documentation===== //Not included in Wikka// >>**See also** Development: UpdateCategoryAction.>>This is the documentation page for the category update action.::c:: ====Documentation==== ===Short description=== This action is for converting categorizations to the scheme used in PageAndCategoryDivisioninACategory ===Parameters=== This action takes no parameters ===Long description=== Wikka has a very flexible category system -- with one major drawback: You cannot link to a category without putting the linking page into this category. Besides some other issues, PageAndCategoryDivisioninACategory solves this problem by an explicit categorization of pages using the linking pattern ##""[[(cat)NameOfCategoryPage]]""##. Just typing ##""NameOfCategoryPage""## just links to this page. The problem now is that any Wikka already in use for some time might have a more or less complete categorization of all pages -- so how do we get this new category system? Search and replace is the answer. The great thing about it is: I need SQL queries and regular expressions -- two topics of programming I never had any chance to develop some skills, so this might be buggy after all. ==Step 1: Acquire list of categories== First, we need a list of all categories. This is because we need to know which links to convert. Currently, we know every link to a category is a categorization. **Done** ==Step 2: Process each page== Second, we need to acquire a list of all pages. Every page will be loaded single (""LoadSingle"") and processed by its own to keep memory usage low. **Done** ==Step 3: Ensuring not to convert new syntax to newnew syntax== After extending Wikka with PageAndCategoryDivisioninACategory, there might already be some new categorizations. These have to be preserved. I think, the code for this step might be dropped as soon as the action works fully and is linked by PageAndCategoryDivisioninACategory so that anyone extending an existing Wikka with it immediately uses this action. **This might be better as part of step 4. Or I need a regex which does exclude any links like ##""[[(cat)...""##** ~&As there won't be any page, where original and new syntax is used at the same time, this doesn't really matter. I only check, if the new syntax is used and convert only if this is not the case. **Done** --MasinAlDujaili, 2007-06-06, 18:50 ==Step 4: Conversion from original syntax to new syntax== I guess, preg_replace_callback will be my friend. ~&It wasn't, it was preg_match_all and preg_replace. **Done** --MasinAlDujaili, 2007-06-06, 18:50 ==Step 5: Storing page== I hope, there's a function to simply store any page. ~&There is: ##SavePage($tag,$body$note)## -- works great. **Done** --MasinAlDujaili, 2007-06-06, 18:50 ==Usage== %%{{updatecategory}}%% **Because of some unknown limitations, the action might time out. On my installation it did about 40 to 60 pages per run, so I had to run it about ten times to get all my pages converted -- I am thankful that not all pages were categorized, because any one run of this action took about 5 minutes.** ===Author=== MasinAlDujaili ::c::---- CategoryUsercontributions