A basepage parameter should work, and incur negligible overhead, but I 
replace the current active page in a number of customization plugins 
(similar to the include function, I believe) and find the functionality to 
be worth a function.

I'll try to test your code during the week, need to configure a better test 
environment for changes to core functions.

On Friday, November 2, 2012 9:00:37 PM UTC+1, Dan wrote:
>
> Yes, I suppose this is a bug. I'm wondering if it would be more efficient 
> to simply add an optional basepage parameter to the pageshortcuts function, 
> and use that within the pageshortcuts function when needed?  Seems it might 
> be handy to have this functionality within the pageshortcuts function down 
> the road. Could you test this out for me:
>
> function BOLTpageshortcuts($link, $basepage='') {
> ## VARIOUS SHORTCUTS THAT CAN BE USED IN MISC WAYS TO MODIFY LINKS (OR 
> PAGES IN COMMANDS).  USE LEADING .'S LIKE ..PAGE TO PRODUCE P1.P2.PAGE. USE 
> + TIMESTAMP, ^ ID, ~ LOGIN, @ GROUP, ! ACTION, .. -> . (FOR OOPS), SPACE -> 
> _ , & ENDING # IS THREAD
>  if (function_exists(myBOLTpageshortcuts)) return 
> myBOLTpageshortcuts($link);
> global $pageLink, $pageArray, $BOLTvar, $BOLTid, $BOLTtime;
>  if ($basepage != '') {
> $myPage = $basepage;
> $myArray = explode('.', $basepage);
>  }
> else {
> $myPage = $pageLink;
> $myArray = $pageArray;
>  }
> $BOLTloginPages = BOLTconfig('BOLTloginPages', 'login');
> $BOLTgroupPages = BOLTconfig('BOLTgroupPages', 'group');
>  if ($link == '') return $myPage;
> $link = str_replace('&', '&', $link);
>  if (strpos($link, "/")) $link = str_replace("/", ".", $link);
> $get = '';
>  if (strpos($link, '&') !== false) {
> $get = substr($link, strpos($link, "&"));
>  $link = substr($link, 0, strpos($link, "&"));
> }
> if (substr($link, -1) == '#') {
>  $thread = true;
> $link = substr($link, 0, -1);
> }
>  if (strpos($link, '#') !== false) {
> $anchor = '#' . BOLTutf2url(substr($link, strpos($link, "#") + 1));
>  $link = substr($link, 0, strpos($link, "#"));
> }
> $link = str_replace(' ', '_', $link);
>  if (BOLTconfig('BOLTutfpages', 'true') == 'true') $link = 
> BOLTutf2url($link);
> else $link = BOLTutf8_strip($link);
>  if (substr($link, 0, 1) == '=') $link = $myPage . '.' . substr($link, 1);
> $link = strtolower(trim($link));
>  if (substr($link, 0, 1) == '.') {
> $tempArray = $myArray;
> $dots = strlen($link) - strlen(ltrim($link, '.'));
>  for ($i=0; $i<$dots; $i++) {
> if (isset($tempArray[$i])) $temp .= $tempArray[$i] . '.';
> }
>  $link = $temp . substr($link, $dots);
> }
> $rr1 = array('+','@','!','..',' ','^','~');
>  $rr2 = 
> array($BOLTtime,"$BOLTgroupPages.",'action','.','_',$BOLTid,"$BOLTloginPages.");
> $link = trim(str_replace($rr1, $rr2, $link), '.');
>  if ($thread) $link = $link . '.' . BOLTthread("$link.0");
> return $link . $anchor . $get; 
>  }
>
> Then of course the index function would be:
>
> // index links
> preg_match_all('/\[\[(.*?)(\&|\#|\||\])/', $content, $links); 
>  foreach($links[1] as $pp) $outlinks[] = BOLTpageshortcuts($pp, $p);
> $linksArray = array_unique($outlinks);
>  $mylinks = implode("<>", $linksArray);
>
> A couple problems I see would be the + and # shortcuts but probably no way 
> around that...
>
> Also looks like there was a glitch in the $rr1 and $rr2 arrays. Supposed 
> to be ~~ goes to viewers login page--but it conflicts with some things so I 
> just deleted that. And I added dots to the action, login and group 
> shortcuts (!,~,@) so now you can just do [[!edit]], [[~id]], [[@admin]] 
> rather than [[!.edit]] [[~.id]] [[@.admin]]. This would be a change from 
> existing systems but seems a better way to go...
>
> Incidentally, I also changed markups.php around 524 to this:
>
> if ($label == '') {
> if (BOLTconfig('BOLTlinkTitles') == 'true') $label = '+';
>  else $label = BOLTpageshortcuts($link);  // slight change here to show 
> proper links in display
> }
>
> Cheers,
> Dan
>
> P.S. Let me know if this works. I've just put into the core and this code 
> on page test.index seems to works:
>
> [[@admin]]
> [[~caveman]]
> [[.]]
>
> {(index test.index)}
>
> <(search link=group.admin)>
> <(search link=login.caveman)>
> <(search link=test)>
>
>
>
>
> On Sun, Oct 28, 2012 at 10:38 AM, DrunkenMonk <[email protected]<javascript:>
> > wrote:
>
>> Hej Dan, everyone
>>
>> I was trying to get some functionality on an old site to work, and I 
>> realised I was having a problem with backlinks that's pretty easilly solved.
>>
>> There is a discrepancy in the way the search function handles links (they 
>> are passed to BOLTpageshortcuts) and the way the indexing function handles 
>> them (they are not).
>>
>> I got much better, more intuitive, results with some minor changes. I've 
>> included my code below, in case you are interested. I would class this as a 
>> bug fix, but I don't know if you would class the issue as a bug in the 
>> first place.
>>
>> I tried to use your coding style as much as possible :/
>>
>> The following is a change to BOLTindex:
>> ---------------------------------------------------
>> // index links 
>>     preg_match_all('/\[\[([^{}:&#|@\/\]]+)(\&|\#|\||\])/', $content, 
>> $links);  
>>     // filter and tidy links 
>>     $linksArray = array_unique($links[1]); 
>>     BOLTsetPageLink($p, $store); 
>>     $linksArray = array_map('BOLTpageshortcuts', $linksArray);
>>     BOLTrevertPageLink($store); 
>>     $linksArray = array_unique($linksArray); // refilter after 
>> pageshortcuts 
>>     // done 
>>     $mylinks = implode("<>", $linksArray); 
>>     $mylinks = BOLTutf2url(str_replace('~', "$loginPages.", $mylinks)); 
>> ----------------------------
>>
>> Where I use the following helper functions to set the "current page":
>> --------------------------------
>> function BOLTsetPageLink($page, &$store) {
>>   global $pageLink, $pageArray;
>>   $store = array($pageLink, $pageArray);
>>   $pageLink = $page;
>>   $pageArray = explode('.', $page);
>>   }
>> function BOLTrevertPageLink($store) {
>>   global $pageLink, $pageArray;
>>   $pageLink = $store[0];
>>   $pageArray = $store[1];
>>   }
>> --------------------------------
>>
>> It was nice to play around with some BW again. Good luck with 4.x!
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "BoltWire" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/boltwire/-/_blHH11U_KoJ.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> [email protected] <javascript:>.
>> For more options, visit this group at 
>> http://groups.google.com/group/boltwire?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"BoltWire" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/boltwire/-/WXsGJKc9QvoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/boltwire?hl=en.

Reply via email to