What do you think of that?
function BOLTXrename($value, $field, $args='') {
global $BOLTindexPages, $BOLTid, $systemPath;
$from = BOLTpageshortcuts($args['from']);
if (BOLTexists($from) == false) return BOLTabort(
"rename_fail_nofile::$from");
$to = BOLTpageshortcuts($args['to']);
if (BOLTexists($to) != false) return BOLTabort(
"rename_fail_exists::$from::$to");
if (!BOLTauth($to, $BOLTid, 'write')) return BOLTabort(
"rename_fail_auth::$to");
$to2 = BOLTfolders($to);
$from2 = BOLTfolders($from);
if ((file_exists("$systemPath/$from")) && (! file_exists("pages/$from2")))
$success = copy("$systemPath/$from", "pages/$to2");
else $success = rename("pages/$from2", "pages/$to2"); // change back to
rename
if ($success) {
BOLTmessage("rename_success::$from", $args);
if ($args['renamestamps'] == 'true') {//NEW LINE
BOLTXrenamestamps($value,$field,$args);//NEW LINE
}//NEW LINE
$BOLTindexPages[] = $to;
$BOLTindexPages[] = $from;
}
else BOLTmessage("rename_fail::$from", $args);
return $success;//NEW LINE
}
function BOLTXrenamestamps($value, $field, $args='') {
$from = BOLTpageshortcuts($args['from']);
$to = BOLTpageshortcuts($args['to']);
$pat = "/^" . str_replace(".", "\.", $from) . "\.\d{10}$/";
$stamps = BOLTlistpages($pat,"stamps");
foreach($stamps as $stampfile) {
$args['from']=$stampfile;
$args['to']=str_replace($from,$to,$stampfile);
if(!BOLTXrename($stampfile,$field,$args)) {//don't pollute by assessing
success for all well-renamed stamps (that may be a lot of files!)
BOLTmessage("rename_fail::$stampfile", $args);
}
}
}
I derived this piece of code from my "treename" function that also rename
children of a given page. It is, however, untested at the moment. It would
allow to rename manually old stamps with the renamestamps command, and one
could also create a webhook only for renaming the stamps (in case the stamp
format name had been changed through a webhook of stamp and unstamp, for
example).
I could also create a webhook of the rename command to include that as a
plugin, but since you were interested in having this functionality in the
core...
Cheers,
Tiffany
Le vendredi 5 décembre 2014 16:17:01 UTC+1, Dan a écrit :
>
> This is a good idea--to make it an optional parameter in the rename
> command to also do the stamps. I'll add it to the todo list.
>
> Cheers,
> Dan
>
> On Fri Dec 05 2014 at 7:44:04 AM Tiffany Grenier <[email protected]
> <javascript:>> wrote:
>
>> Hi again,
>>
>> I was just wondering: when a page is renamed, via the "rename" action, it
>> looses its history. Should we also rename the stamps files? Should it be an
>> option (like "copy data too" on the "copy" action page), so we can choose
>> the behaviour we want? Should it be a
>> plugin/webhook/toolmapping/what-ever-other-way-we-have-not-to-generalize-this-feature?
>>
>> What do you think?
>>
>> Cheers,
>> Tiffany
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BoltWire" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/boltwire.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
You received this message because you are subscribed to the Google Groups
"BoltWire" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/boltwire.
For more options, visit https://groups.google.com/d/optout.