Hi Tiffany!

Have been doing a lot of traveling lately and not had a chance to get back
to you on these. My apologies.

I'm open to creating a utility along these lines if it will save some code,
but the examples you gave actually do very different things.

In some places I want to make sure the we don't have \r or \r\n in pages
and only use \n for line breaks. There's about 3-4 places in the code that
filters input to take care of this. They could be probably merged into a
utility, but I'm not sure it will help us that much as it would only be a
one line function anyway.

The other cases are for templating and similar things where you can do this:

[command create content='some text\nnext line' lines=true ...]

And it will substitute the \n of a real line break. Or

[command create content={=field} lines=false ...]

And it will convert all the line breaks in the input field into literal
\n's allowing you to save the value as a single line. These both have
specialized uses and nothing to do with the carriage return problem on
different os's.

Granted I could generate one utility to deal with both types of situations
but it seems counterintuitive to use one function to solve two very
different issues. I'm more inclined to keep each section handcoded as they
all vary to some extent and are only a line or two of code in each place.

Let me know if I'm overlooking something or missed your point.

Cheers,
Dan



On Thu Nov 20 2014 at 1:23:53 AM Tiffany Grenier <[email protected]>
wrote:

> Hi,
>
> I saw in the code a couple of times things like
> if ($args['lines'] != '') {
>         if ( $args['lines'] == 'false' ) $content = str_replace("\n",
> '\n', $content); // condense
>         if ( $args['lines'] == 'true' ) $content = str_replace('\n', "\n",
> $content); // expand
>         }
> or like         if ( $args['lines'] !== 'false' ) $content =
> str_replace('\n', "\n", $content);
>
> Also, the return carriage \r is only taken care of in the log function.
>
> I was wondering if this was really the desired behaviour...
> Why not write in engine.php a BOLTdealwithlines function like the
> following and do        $content = BOLTedalwithlines($content,$args); or
>        $content = BOLTdealwithlines($content,$args,array('!false')); when
> necessary?
>
> function BOLTdealwithlines($content,$args,$checkedValues='') {
>     if($checkedValues == '') $checkedValues = array('true','false');
>     $content = str_replace(array('\r\n', '\r'), '\n', $content);
>     $content = str_replace(array("\r\n", "\r"), "\n", $content);
>     if ($args['lines'] != '') {
>         if (($args['lines'] === 'false' &&
> in_array('false',$checkedValues)) || ($args['lines'] !== true &&
> in_array('!true',$checkedValues)))
>             $content = str_replace("\n", '\n', $content); // condense
>         if (($args['lines'] === 'true' && in_array('true',$checkedValues))
> || ($args['lines'] !== 'false' && in_array('!false',$checkedValues)))
>             $content = str_replace('\n', "\n", $content); // expand
>         }
>     return $content;
>     }
>
> 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].
> 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.
>

-- 
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.

Reply via email to