I was wondering about this... Initially it just cleared the value but
preserved the field when a page didn't exist. I think yours is a
better approach to delete the whole entry...
How about this for code instead. It has the advantage of being able to
clean any info page, and in other directories, etc. Plus you have
indexing and more. Not to mention it is short and simpler!
function BOLTinfoClean($info, $args, $target='') {
$before = count($info);
$exists = implode(',', BOLTsearchPageList(Array()));
foreach ($info as $p => $v) {
$pp = BOLTutf2url($p);
if (strpos(",$exists,", ",$pp,") === false) unset($info[$pp]);
else $out .= "$p: $v\n";
}
$after = count($info);
BOLTsavepage($target, $out);
return "Info fields cleaned.\nBefore: $before, After: $after.";
}
This requires one small change to the core code which will be in the
next release. Line 261 of functions.php needs to start sending the
target value:
if (function_exists($func)) return $func($info, $args, $target);
Let me know if this doesn't work (don't forget to patch your core). I
will upload the new plugin, and put out the new core here shortly.
Still have a few other issues I'm working on.
Cheers,
Dan
On Tue, Apr 20, 2010 at 9:59 PM, Phoenix Wu <[email protected]> wrote:
> THANKS~
> Insert some codes copied from another plugin php to over-wright the
> old info.tags.
> And put this function into a cron page, it works now. :)
>
> function BOLTinfoClean($info, $args) {
> $before = count($info);
> $exists = implode(',', BOLTsearchPageList(Array()));
> foreach ($info as $p => $v) {
> $pp = BOLTutf2url($p);
> if (strpos(",$exists,", ",$pp,") === false) unset($info[$pp]);
> }
> $after = count($info);
> //////////////////////////////
> $myFile = "pages/info.tags";
> $fh = fopen($myFile, 'w') or die("can't open file");
> foreach ($info as $p => $v) $out .= "$p: $v\n";
> fwrite($fh, $out);
> fclose($fh);
> //////////////////////////////
> return "Info fields cleaned.\nBefore: $before, After: $after.";
> }
>
>
> On 4月21日, 上午5時20分, The Editor <[email protected]> wrote:
>> How about changing the code to this. Note the asterisks for the changed
>> lines:
>>
>> function BOLTinfoClean($info, $args) {
>> $before = count($info);
>> $exists = implode(',', BOLTsearchPageList(Array()));
>> foreach ($info as $p => $v) {
>> ** $pp = BOLTutf2url($p);
>> ** if (strpos(",$exists,", ",$pp,") === false) unset($info[$p]);
>> }
>> $after = count($info);
>> return "Info fields cleaned.\nBefore: $before, After: $after.";
>> }
>>
>> If this helps let me know and I will update the plugin. I haven't tested
>> it....
>>
>> Cheers,
>> Dan
>>
>>
>>
>>
>>
>> On Mon, Apr 19, 2010 at 5:28 AM, Phoenix Wu <[email protected]>
>> wrote:
>> > I found a solution in this extension -- infox(info extension)
>> >http://www.boltwire.com/index.php?p=solutions.system.infox
>>
>> > There is a build-in clean function should be working.
>> > function BOLTinfoClean($info, $args) {
>> > $before = count($info);
>> > $exists = implode(',', BOLTsearchPageList(Array()));
>> > foreach ($info as $p => $v) {
>> > if (strpos(",$exists,", ",$p,") === false) unset($info[$p]);
>> > }
>> > $after = count($info);
>> > return "Info fields cleaned.\nBefore: $before, After: $after.";
>> > }
>> > But it seems have the unicode(utf-8) problem?
>> > The return of strpos() will be wrong if the entry in info.tags
>> > contains Chinese or Parentheses ()
>> > Try to use mb_strpos() instead but still not working...
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BoltWire" group.
>> 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
>> athttp://groups.google.com/group/boltwire?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "BoltWire" group.
> 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.
>
>
--
You received this message because you are subscribed to the Google Groups
"BoltWire" group.
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.