Re: [pmwiki-users] Using variable in skin template
Friday, October 23, 2009, 11:14:24 PM, Sandy wrote: Thinking further, can this go in skin.php? $color1 = '#00cc00'; That keeps all the skin stuff in the skin, and avoids $HTMLStylesFmt[]. why don't you just set the color attributes in the skin's css file? after all, the purpose of the css file is to have one location for changing atributes site-wide. There is realy no need to set a color attribute via a php variable, unles one wants to dynamically manipulate it, say by using value sset in a wiki page. ~Hans ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] editing pmwiki.org
On Friday 23 October 2009 20:06:29 adam overton wrote: hi pmwiki.org isn't permitting editing right now - it just times out. Thanks, it should work now. A misconfuguration of an antispam filter caused this. Sorry, my fault. Petko ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
Saturday, October 24, 2009, 3:54:43 AM, DaveG wrote: Sandy wrote: I'm not (yet) comfortable with $HTMLStylesFmt[]. It's an array, which can contain arrays :) I thought not. I understand $HTMLStylesFmt to list css attributes, which get injected into styles.../styles tags in the page's HTML head section (to put it briefly). So an admin or developer can use $HTMLStylesFmt[] = some HTML selectors with css attributes; to add these attributes to the $HTMLStylesFmt array and thus inject them into the styles tags. It just means adding a new element to the array. If you give it a name, like $HTMLStylesFmt['mycss'], then it will be added to the array with that key name, instead of a numerical key. This is useful for situations where otherwise it may be added several times with the same css atributes, to avoid such repetitions. I used that in markup functions, where the same markup may be used several times in a page. ~Hans ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
Friday, October 23, 2009, 11:56:25 PM, DaveG wrote: Parse error: syntax error, unexpected T_STRING in /path/pmwiki.php(762) : eval()'d code on line 1 That's because the PageVar needed to be quoted, as Hans showed. Thus, $FmtPV['$myvar'] = 'PageVar($pagename,\'$:myvar\')' There were in fact several things wrong with your code: 1. missing quotes 2. wrong function: PageTextVar() is used to exctract a PTV 3. use of $pagename: use $pn rather than $pagename as $ pagename may have a different value. 4. PTV name: if the PTV is named in the page 'myvar', then that should be used a parameter in the PageTextVar() call. PageVar($pn, myvar) {$:myvar} is the syntax to refer to th ePTV in a wiki page. ~Hans ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] PHP 5.3 woes.
Vince Admin Account (2009-10-23 16:01): On Oct 19, 2009, at 5:13 PM, rogu...@googlemail.com wrote: The problem with pagelists lies in GlobToPCRE() function in pmwiki.php and is tracked at http://pmwiki.org/wiki/PITS/01149 . It concerns exclusion patterns (name=-Page) only. The suggested workaround for exclusion patterns (at least in my case) allows the pagelist to work, but does not exclude anything. A workaround for this is to use $SearchPatterns in the config.php file. This worked well for me. For example, to exclude all groups having a - in their name: $SearchPatterns['default'][] = '!^[A-Za-z]*-[A-Za-z]\.!; I know this will not work if the group names have special or international characters in their name, but it should be easy to adapt. Thanks for pointing out the PITS entry. Vince (:pagelist group=-PmWiki*,-Site*:) works fine here. Doesn't it work for you? Are you sure you've made the right changes to GlobToPCRE()? The line with str_replace call looks like this after changing: $pat = str_replace(array('\\*', '\\?', '\\[', '\\]', '\\^', '\\-'), array('.*', '.', '[', ']', '^', '-'), $pat); -- -- Rogutės Sparnuotos ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] PHP 5.3 woes.
On Oct 24, 2009, at 5:34 AM, rogu...@googlemail.com wrote: Vince Admin Account (2009-10-23 16:01): On Oct 19, 2009, at 5:13 PM, rogu...@googlemail.com wrote: The problem with pagelists lies in GlobToPCRE() function in pmwiki.php and is tracked at http://pmwiki.org/wiki/PITS/01149 . It concerns exclusion patterns (name=-Page) only. (:pagelist group=-PmWiki*,-Site*:) works fine here. Doesn't it work for you? Are you sure you've made the right changes to GlobToPCRE()? The line with str_replace call looks like this after changing: $pat = str_replace(array('\\*', '\\?', '\\[', '\\]', '\\^', '\\-'), array('.*', '.', '[', ']', '^', '-'), $pat); Well, I think I am sure. I can cut and paste, in case my eyes are too tired. Here is the entire function. function GlobToPCRE($pat) { $pat = preg_quote($pat, '/'); $pat = str_replace(array('\\*', '\\?', '\\[', '\\]', '\\^', '\\-'), array('.*', '.', '[', ']', '^', '-'), $pat); $excl = array(); $incl = array(); foreach(preg_split('/,+\s?/', $pat, -1, PREG_SPLIT_NO_EMPTY) as $p) { if ($p{0} == '-' ) $excl[] = '^'.substr($p, 0).'$'; else $incl[] = ^$p$; } return array(implode('|', $incl), implode('|', $excl)); } Some other interesting things I found here. We are running Apple Snow Leopard, PHP 5.3.0 and Apache 2.2.11. When I tried to test pieces of this code on my web page, the line $pat = preg_quote($pat,'\'); gave a syntax error. It worked as in the manual with a few other characters instead of \. I did get it to work as advertised with $pat = preg_quote($pat,'\\'); I tried that in GlobToPCRE, but it didn't help. So I am confused. But at least I do have the workaround. Vince ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
Hans wrote: Friday, October 23, 2009, 11:56:25 PM, DaveG wrote: Parse error: syntax error, unexpected T_STRING in /path/pmwiki.php(762) : eval()'d code on line 1 That's because the PageVar needed to be quoted, as Hans showed. Thus, $FmtPV['$myvar'] = 'PageVar($pagename,\'$:myvar\')' There were in fact several things wrong with your code: 1. missing quotes Yep. 2. wrong function: PageTextVar() is used to exctract a PTV Actually, either function works, as PageVar calls PageTextVar. It is probably mildly faster to call PageTextVar directly though. 3. use of $pagename: use $pn rather than $pagename as $ pagename may have a different value. Not sure about this. Is $pn globally available? Not sure, but it doesn't look like it. I'd always thought $pagename referred to the current page from within skin/config files. 4. PTV name: if the PTV is named in the page 'myvar', then that should be used a parameter in the PageTextVar() call. PageVar($pn, myvar) {$:myvar} is the syntax to refer to th ePTV in a wiki page. That's correct when calling PageTextVar. But called from PageVar, then the $:myvar format is used. ~ ~ David ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
DaveG wrote: Sandy wrote: I'm not (yet) comfortable with $HTMLStylesFmt[]. It's an array, which can contain arrays :) Usually you index the array with the name of the skin, but any name (or even no name) will work fine. The content of the array is output at the point in the .tmpl file where the !--HTMLHeader-- tag appears. That makes sense. The more I look beneath the hood, the more I'm impressed with how well things are laid out. No $500 labour bills to reach one faulty wire. For that matter, arrays in php still confuse me. Perfectly clear while I'm reading the tutorials,... A matter of practice. Easiest way to learn is to print the content of the array. it's not clean and might cause some errors, so only do this on a dev environment, but simply add this to a skin.php file: print_r($HTMLStylesFmt); Then view the source of the web page to see the content of the array. Good idea. I remember doing that in a tutorial, way back when. (I'm a binge user. A week or two intense, then forget everything over the next six months.) Doesn't help that I've dabbled in 6 very different languages over the last 25 years. Let me count the different print formats,... Thinking further, can this go in skin.php? $color1 = '#00cc00'; That keeps all the skin stuff in the skin, and avoids $HTMLStylesFmt[]. Well in order to use the variable from within the template you'd need use $FmtPV: $FmtPV['$color1']='#00cc00'; So then you could use it in .tmpl (not in .css files though). Personally I prefer to use $HTMLStylesFmt. What's up with the two quotation marks? I remember something about not being the same as ', something about one being literal and the other interpretting the variable names, but google is being dense. Sandy ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
Saturday, October 24, 2009, 4:04:34 PM, DaveG wrote: 3. use of $pagename: use $pn rather than $pagename as $ pagename may have a different value. Not sure about this. Is $pn globally available? Not sure, but it doesn't look like it. I'd always thought $pagename referred to the current page from within skin/config files. If you use $pagename in a $FmtPV[...] setting, it will use whatever the value of $pagename is at that point in config.php. This may be what you need, but it may also be different, depending on what page the page variable markup is encountered, and how $EnableRelativePageVars is set. If you use $pn, then it will only be filled when the $FmtPV item is evaluated, and will be correct as for that circumstance. You can see in pmwiki.php that the $FmtPV items use $pn throughout. ~Hans ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
Hans wrote: Friday, October 23, 2009, 11:14:24 PM, Sandy wrote: Thinking further, can this go in skin.php? $color1 = '#00cc00'; That keeps all the skin stuff in the skin, and avoids $HTMLStylesFmt[]. why don't you just set the color attributes in the skin's css file? after all, the purpose of the css file is to have one location for changing atributes site-wide. There is realy no need to set a color attribute via a php variable, unles one wants to dynamically manipulate it, say by using value sset in a wiki page. ~Hans The current site uses only one set of colours, so it's easier to keep them in the style tag and only deal with one file. I've used separate css files before, but it's overkill for this one. The reason I want a variable is if I use #006600 for several different elements (H#, A, HR, various borders) then want to try #007700, I have to change each and every occurence. Yes, I can use the editor's search-and-replace, but a variable seems more elegant. Separating it into a separate css file wouldn't change that. I could do the style as H1, H2, ... A.hover {color:#006600;} so the color number occurs only once, but I suspect there's a reason I've never seen a file done that way. Now to stop chatting and start experimenting. Thanks, Sandy ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] PHP 5.3 woes.
Vince Administration (2009-10-24 10:42): On Oct 24, 2009, at 5:34 AM, rogu...@googlemail.com wrote: Vince Admin Account (2009-10-23 16:01): On Oct 19, 2009, at 5:13 PM, rogu...@googlemail.com wrote: The problem with pagelists lies in GlobToPCRE() function in pmwiki.php and is tracked at http://pmwiki.org/wiki/PITS/01149 . It concerns exclusion patterns (name=-Page) only. (:pagelist group=-PmWiki*,-Site*:) works fine here. Doesn't it work for you? Are you sure you've made the right changes to GlobToPCRE()? The line with str_replace call looks like this after changing: $pat = str_replace(array('\\*', '\\?', '\\[', '\\]', '\\^', '\\-'), array('.*', '.', '[', ']', '^', '-'), $pat); Well, I think I am sure. I can cut and paste, in case my eyes are too tired. Here is the entire function. function GlobToPCRE($pat) { $pat = preg_quote($pat, '/'); $pat = str_replace(array('\\*', '\\?', '\\[', '\\]', '\\^', '\\-'), array('.*', '.', '[', ']', '^', '-'), $pat); $excl = array(); $incl = array(); foreach(preg_split('/,+\s?/', $pat, -1, PREG_SPLIT_NO_EMPTY) as $p) { if ($p{0} == '-' ) $excl[] = '^'.substr($p, 0).'$'; else $incl[] = ^$p$; } return array(implode('|', $incl), implode('|', $excl)); } You didn't answer my first question. Does the following work for you? (:pagelist group=-PmWiki*,-Site*:) There's no point pasting the entire function, because you should've changed only the two lines beginning with $pat = str_replace (which look good above)... If you did more, I you've changed more than those, I'd suggest starting with a new pmwiki.php. Some other interesting things I found here. We are running Apple Snow Leopard, PHP 5.3.0 and Apache 2.2.11. When I tried to test pieces of this code on my web page, the line $pat = preg_quote($pat,'\'); gave a syntax error. It worked as in the manual with a few other characters instead of \. I did get it to work as advertised with $pat = preg_quote($pat,'\\'); I tried that in GlobToPCRE, but it didn't help. So I am confused. But at least I do have the workaround. Vince Compare $pat = preg_quote($pat, '/'); to $pat = preg_quote($pat, '\'); -- -- Rogutės Sparnuotos ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
Sandy wrote: Well in order to use the variable from within the template you'd need use $FmtPV: $FmtPV['$color1']='#00cc00'; So then you could use it in .tmpl (not in .css files though). Personally I prefer to use $HTMLStylesFmt. What's up with the two quotation marks? I remember something about not being the same as ', something about one being literal and the other interpretting the variable names, but google is being dense. Because anything assigned to $FmtPV needs to be executable. Refer to PmWiki/PageVariables. ~ ~ Dave ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] PHP 5.3 woes. Finally fixed
On Oct 24, 2009, at 1:04 PM, rogu...@googlemail.com wrote: Vince Administration (2009-10-24 10:42): On Oct 24, 2009, at 5:34 AM, rogu...@googlemail.com wrote: Vince Admin Account (2009-10-23 16:01): On Oct 19, 2009, at 5:13 PM, rogu...@googlemail.com wrote: The problem with pagelists lies in GlobToPCRE() function in pmwiki.php and is tracked at http://pmwiki.org/wiki/PITS/01149 . It concerns exclusion patterns (name=-Page) only. (:pagelist group=-PmWiki*,-Site*:) works fine here. Doesn't it work for you? Are you sure you've made the right changes to GlobToPCRE()? The line with str_replace call looks like this after changing: $pat = str_replace(array('\\*', '\\?', '\\[', '\\]', '\\^', '\\-'), array('.*', '.', '[', ']', '^', '-'), $pat); } You didn't answer my first question. Does the following work for you? (:pagelist group=-PmWiki*,-Site*:) There's no point pasting the entire function, because you should've changed only the two lines beginning with $pat = str_replace (which look good above)... If you did more, I you've changed more than those, I'd suggest starting with a new pmwiki.php. Well, first, it didn't work then. I had made two changes to the GlobToPCRE function, the two lines i the str_replace function, and the change to the ! entry as described in the PITS entry. When I undid the second change, things started working. Thanks again for all your help. I will be more careful with my tests in the future. Vince ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
DaveG wrote: Sandy wrote: Well in order to use the variable from within the template you'd need use $FmtPV: $FmtPV['$color1']='#00cc00'; So then you could use it in .tmpl (not in .css files though). Personally I prefer to use $HTMLStylesFmt. What's up with the two quotation marks? I remember something about not being the same as ', something about one being literal and the other interpretting the variable names, but google is being dense. Because anything assigned to $FmtPV needs to be executable. Refer to PmWiki/PageVariables. ~ ~ Dave Experiments done for now. Several things work in group.php but not testskin.php. I'd like to start with all the skin code in the skin folder so it can easily be moved between farms. Further customizing can then be done in either php file, depending on the setup of the new farm. Result of experiments: Very confused, especially the last result. Must learn more about skin.php files and experiment more, and re-read the php tutorials. Trying to learn too many things at once. Thanks for the help. Sandy Results of experiments: - $color1 = '#00cc00'; $HTMLStylesFmt['my_skin'] = h1 {color:$color1;} ; works in the group.php, but not in testskin.php . - in group.php: $FmtPV['$color1']='#00cc00'; then in .tmpl style h1 {color:$color1;} /style works. Same thing in testskin.php gives this html: h1 {color:gold1;} Suspect $FmtPV['$color1'] is being over-ridden by a recipe. No clue which one. Try testskin.php again, with different variable name. Resulting .html is: h1 {color:$Sandy1;} One has $ and one doesn't. Probably means something to someone who finished the php tutorials. --- - add to each php file: print_r($HTMLStylesFmt); Works in group.php. Doesn't work in testskin.php. add line of garbage to testskin.php yes, the file is being called. in group.php: $FmtPV['$sandy1']='#00cc00'; in testskin.tmpl style h1 {color:$FmtPV['$sandy1'];} /style Resulting html: h1 {color:$FmtPV['#00cc00'];} Rechecked that one with different variable names three times. Offically confused. ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
Aha! Googling the right terms helps. A way to use php to create a css file. http://www.barelyfitz.com/projects/csscolor/ Probably old news to many, but new and intriguing to me. Just checked the PmWiki docs, and yes I can have more than one php file in the skin folder. Something for me to play with next weekend. Sandy Key lines: + To use PHP in your CSS file: 1. Rename your style.css file to style.php, then add the following to the top of the file: ?php header(Content-type: text/css); ? This line tells the browser that the file is CSS instead of HTML. 2. In your HTML files, change the stylesheet references from style.css to style.php. For example: link rel=stylesheet type=text/css media=screen ref=style.php ++ ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] Using variable in skin template
Sandy wrote: Aha! Googling the right terms helps. A way to use php to create a css file. http://www.barelyfitz.com/projects/csscolor/ You could do this, but I can't help thinking you're way over complicating things... ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
[pmwiki-users] ANN: New Skin -- Enlighten
This skin provides a 2-column fixed or fluid width interface, a number of color variations, and full support for the BlogIt blogging engine. http://www.pmwiki.org/wiki/Cookbook/Enlighten Hope you like it. ~ ~ Dave ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
[pmwiki-users] RandomQuote Quote File Format
I have done everything for RandomQuote to work except create the quote file. I have tried a couple of different formats and nothing seems to work. The sample code in the php file looks like quotes with xml tags surrounding. The program appears to strip all of the xml tags out and seems to be looking for other characters, but I can't read php well enough to tell what. Does anybody have a sample quote file? I can copy any format, I just need to know what the format is. Ivan Mann___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users
Re: [pmwiki-users] RandomQuote Quote File Format
Ivan Mann wrote: I have done everything for RandomQuote to work except create the quote file. I have tried a couple of different formats and nothing seems to work. The sample code in the php file looks like quotes with xml tags surrounding. The program appears to strip all of the xml tags out and seems to be looking for other characters, but I can't read php well enough to tell what. Does anybody have a sample quote file? I can copy any format, I just need to know what the format is. Uses a wiki page (so create the page from PmWiki) -- for example MyGroup.Quotes. The format of the page is: [[#quote1]] Here's quote 1 [[#quote2]] Here's quote 2 [[#quote3]] Here's quote 3 Then use a pagelist to include the quote: (:include {MyGroup.Quotes$RandomSection}:) ~ ~ Dave ___ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users