php-general Digest 1 Dec 2008 02:12:12 -0000 Issue 5819

Topics (messages 283925 through 283937):

Re: Text To Speech Update
        283925 by: Nathan Rixham
        283935 by: tedd

PHP attaching css and JS files to current page
        283926 by: Alain Roger
        283927 by: Ashley Sheridan
        283928 by: Alain Roger
        283929 by: Ashley Sheridan
        283930 by: Alain Roger
        283931 by: Ashley Sheridan
        283932 by: Alain Roger
        283933 by: Alex Chamberlain
        283934 by: Eric Butera

Re: operators as callbacks?
        283936 by: Nathan Nobbe

Re: getStatic
        283937 by: Craige Leeder

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Michael Kubler wrote:
Works ok for me on FFox v2 and v3 on my Windows XP machines, but when trying it on IE v6.0 the speech is played back REALLY fast. Like super chipmunk style.

sounds like the double speed playback flash bug; upgrade you're flash player and should work
--- End Message ---
--- Begin Message ---
At 7:21 PM -0500 11/29/08, Daniel P. Brown wrote:
    Any/All:

    For those of you who were asking about the PHP Text-To-Speech
system I had running, it's back online now.  If you have a few free
seconds, please take a look at http://www.pilotpig.net/txt2wav.php and
let me know if it's working for sure in your browser and on your OS.

My old page:

http://www.php1.net/b/speech/index.php

now works.

Thanks!

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Hi,

is there a way how a PHP class can attach JS (javascript) and CSS documents
to current web page in which the class is instanced ?
till now i used an "echo" which "write" a <script></script> code into
current document.
in this javascript, i used to have a createElement function to attache
C\other CSS or JS file.

it's not so clean and maybe a better possibility exists. Thanks to let me
know.

-- 
Alain
-----------------------------------------------------------
Windows XP x64 SP2
PostgreSQL 8.3.5 / MS SQL server 2005
Apache 2.2.10
PHP 5.2.6
C# 2005-2008

--- End Message ---
--- Begin Message ---
On Sun, 2008-11-30 at 14:23 +0100, Alain Roger wrote:
> Hi,
> 
> is there a way how a PHP class can attach JS (javascript) and CSS documents
> to current web page in which the class is instanced ?
> till now i used an "echo" which "write" a <script></script> code into
> current document.
> in this javascript, i used to have a createElement function to attache
> C\other CSS or JS file.
> 
> it's not so clean and maybe a better possibility exists. Thanks to let me
> know.
> 
Can you not just write all of the CSS/Javascript that you need right
from the get-go in the same place you're writing out your Javascript
now?


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
In fact my class has for purpose to be used in several projects and
therefore, to write the css/js files from the web page using the class would
be a mistake in the way that could not be redistributed without missing
those files.

On Sun, Nov 30, 2008 at 2:55 PM, Ashley Sheridan
<[EMAIL PROTECTED]>wrote:

> On Sun, 2008-11-30 at 14:23 +0100, Alain Roger wrote:
> > Hi,
> >
> > is there a way how a PHP class can attach JS (javascript) and CSS
> documents
> > to current web page in which the class is instanced ?
> > till now i used an "echo" which "write" a <script></script> code into
> > current document.
> > in this javascript, i used to have a createElement function to attache
> > C\other CSS or JS file.
> >
> > it's not so clean and maybe a better possibility exists. Thanks to let me
> > know.
> >
> Can you not just write all of the CSS/Javascript that you need right
> from the get-go in the same place you're writing out your Javascript
> now?
>
>
> Ash
> www.ashleysheridan.co.uk
>
>


-- 
Alain
-----------------------------------------------------------
Windows XP x64 SP2
PostgreSQL 8.3.5 / MS SQL server 2005
Apache 2.2.10
PHP 5.2.6
C# 2005-2008

--- End Message ---
--- Begin Message ---
On Sun, 2008-11-30 at 14:55 +0100, Alain Roger wrote:
> In fact my class has for purpose to be used in several projects and
> therefore, to write the css/js files from the web page using the class
> would be a mistake in the way that could not be redistributed without
> missing those files.
> 
> On Sun, Nov 30, 2008 at 2:55 PM, Ashley Sheridan
> <[EMAIL PROTECTED]> wrote:
>         On Sun, 2008-11-30 at 14:23 +0100, Alain Roger wrote:
>         > Hi,
>         >
>         > is there a way how a PHP class can attach JS (javascript)
>         and CSS documents
>         > to current web page in which the class is instanced ?
>         > till now i used an "echo" which "write" a <script></script>
>         code into
>         > current document.
>         > in this javascript, i used to have a createElement function
>         to attache
>         > C\other CSS or JS file.
>         >
>         > it's not so clean and maybe a better possibility exists.
>         Thanks to let me
>         > know.
>         >
>         
>         Can you not just write all of the CSS/Javascript that you need
>         right
>         from the get-go in the same place you're writing out your
>         Javascript
>         now?
>         
>         
>         Ash
>         www.ashleysheridan.co.uk
>         
> 
> 
> 
> -- 
> Alain
> -----------------------------------------------------------
> Windows XP x64 SP2
> PostgreSQL 8.3.5 / MS SQL server 2005
> Apache 2.2.10
> PHP 5.2.6
> C# 2005-2008
I'm not sure I follow you then. You say you want your class to be able
to include those files, then you say that you don't want to.

Have you considered having PHP check for the existence of the files
you're trying to include before outputting the HTML that includes them?

Also, if you are outputting Javascript code that then uses a
createElement to include more code, how does the Javascript know it can
include the files if they don't exist for every installation?


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
>
> >
> >         Can you not just write all of the CSS/Javascript that you need
> >         right
> >         from the get-go in the same place you're writing out your
> >         Javascript
> >         now?
> >
> >
> I'm not sure I follow you then. You say you want your class to be able
> to include those files, then you say that you don't want to.
>
> Have you considered having PHP check for the existence of the files
> you're trying to include before outputting the HTML that includes them?
>
> Also, if you are outputting Javascript code that then uses a
> createElement to include more code, how does the Javascript know it can
> include the files if they don't exist for every installation?
>
>
so we for sure misunderstood eachother :-)
let's say i have an index.php page in which i create an instance of my class
CTable.
to do that i need to include the CTable.php file into my index.php (till now
no problem)
for that : include_once 'Class/CTable.php';

in the CTable.php file i have my class definition and implementation as
following:
class CTable
{
  blah blah...
}

my CTable class has a Render function which will write html code into the
current index.php page.
within this code should be written some javascript command as also some css
classnames.

till now no problem.

the problem is that in this code (that write my class) into index.php there
are some javascrip command and css classnames, which are linked to external
(in the Class directory) files "CTable.js" and "CTable.css".
those 2 files should be loaded by the class CTable itself...and this is what
i do using echo and createElement.
it works well but it is not clean from my point of view...that's why i was
looking for another solution...more... let say "professional".

A.

--- End Message ---
--- Begin Message ---
On Sun, 2008-11-30 at 15:08 +0100, Alain Roger wrote:
> >
> > >
> > >         Can you not just write all of the CSS/Javascript that you need
> > >         right
> > >         from the get-go in the same place you're writing out your
> > >         Javascript
> > >         now?
> > >
> > >
> > I'm not sure I follow you then. You say you want your class to be able
> > to include those files, then you say that you don't want to.
> >
> > Have you considered having PHP check for the existence of the files
> > you're trying to include before outputting the HTML that includes them?
> >
> > Also, if you are outputting Javascript code that then uses a
> > createElement to include more code, how does the Javascript know it can
> > include the files if they don't exist for every installation?
> >
> >
> so we for sure misunderstood eachother :-)
> let's say i have an index.php page in which i create an instance of my class
> CTable.
> to do that i need to include the CTable.php file into my index.php (till now
> no problem)
> for that : include_once 'Class/CTable.php';
> 
> in the CTable.php file i have my class definition and implementation as
> following:
> class CTable
> {
>   blah blah...
> }
> 
> my CTable class has a Render function which will write html code into the
> current index.php page.
> within this code should be written some javascript command as also some css
> classnames.
> 
> till now no problem.
> 
> the problem is that in this code (that write my class) into index.php there
> are some javascrip command and css classnames, which are linked to external
> (in the Class directory) files "CTable.js" and "CTable.css".
> those 2 files should be loaded by the class CTable itself...and this is what
> i do using echo and createElement.
> it works well but it is not clean from my point of view...that's why i was
> looking for another solution...more... let say "professional".
> 
> A.
I still don't see the problem then with having some output that looks
like this:

print <<<EOS
<script language="javascript" type="text/javascript"
href="CTable.js"></script>
<link rel="stylesheet" type="text/css" href="CTable.css"/>
EOS;

(there should be 4 lines of code there, but line-breaks crept in!)


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
you're right if you want to write them directly in the index.php.
but in my case i want the class to do it by itself.

On Sun, Nov 30, 2008 at 3:49 PM, Ashley Sheridan
<[EMAIL PROTECTED]>wrote:

> On Sun, 2008-11-30 at 15:08 +0100, Alain Roger wrote:
> > >
> > > >
> > > >         Can you not just write all of the CSS/Javascript that you
> need
> > > >         right
> > > >         from the get-go in the same place you're writing out your
> > > >         Javascript
> > > >         now?
> > > >
> > > >
> > > I'm not sure I follow you then. You say you want your class to be able
> > > to include those files, then you say that you don't want to.
> > >
> > > Have you considered having PHP check for the existence of the files
> > > you're trying to include before outputting the HTML that includes them?
> > >
> > > Also, if you are outputting Javascript code that then uses a
> > > createElement to include more code, how does the Javascript know it can
> > > include the files if they don't exist for every installation?
> > >
> > >
> > so we for sure misunderstood eachother :-)
> > let's say i have an index.php page in which i create an instance of my
> class
> > CTable.
> > to do that i need to include the CTable.php file into my index.php (till
> now
> > no problem)
> > for that : include_once 'Class/CTable.php';
> >
> > in the CTable.php file i have my class definition and implementation as
> > following:
> > class CTable
> > {
> >   blah blah...
> > }
> >
> > my CTable class has a Render function which will write html code into the
> > current index.php page.
> > within this code should be written some javascript command as also some
> css
> > classnames.
> >
> > till now no problem.
> >
> > the problem is that in this code (that write my class) into index.php
> there
> > are some javascrip command and css classnames, which are linked to
> external
> > (in the Class directory) files "CTable.js" and "CTable.css".
> > those 2 files should be loaded by the class CTable itself...and this is
> what
> > i do using echo and createElement.
> > it works well but it is not clean from my point of view...that's why i
> was
> > looking for another solution...more... let say "professional".
> >
> > A.
> I still don't see the problem then with having some output that looks
> like this:
>
> print <<<EOS
> <script language="javascript" type="text/javascript"
> href="CTable.js"></script>
> <link rel="stylesheet" type="text/css" href="CTable.css"/>
> EOS;
>
> (there should be 4 lines of code there, but line-breaks crept in!)
>
>
> Ash
> www.ashleysheridan.co.uk
>
>


-- 
Alain
-----------------------------------------------------------
Windows XP x64 SP2
PostgreSQL 8.3.5 / MS SQL server 2005
Apache 2.2.10
PHP 5.2.6
C# 2005-2008

--- End Message ---
--- Begin Message ---
Have you considered using some type of templating system, which can use
class_exists??

Alex

No virus found in this outgoing message. Scanned by AVG Free 8.0
Checked by AVG - http://www.avg.com 
Version: 8.0.176 / Virus Database: 270.9.11/1820 - Release Date: 29/11/2008
18:52


--- End Message ---
--- Begin Message ---
On Sun, Nov 30, 2008 at 8:23 AM, Alain Roger <[EMAIL PROTECTED]> wrote:
> Hi,
>
> is there a way how a PHP class can attach JS (javascript) and CSS documents
> to current web page in which the class is instanced ?
> till now i used an "echo" which "write" a <script></script> code into
> current document.
> in this javascript, i used to have a createElement function to attache
> C\other CSS or JS file.
>
> it's not so clean and maybe a better possibility exists. Thanks to let me
> know.
>
> --
> Alain
> -----------------------------------------------------------
> Windows XP x64 SP2
> PostgreSQL 8.3.5 / MS SQL server 2005
> Apache 2.2.10
> PHP 5.2.6
> C# 2005-2008
>

I've created a few helper classes that I use on projects for this
"problem."  What I do is have a directory that I put css and js files
into.  Then I have a main "page" class that has various sub-classes
for things like css & javascript.  Inside of a controller or view if I
have some code that needs to include a js/css file all they have to do
is something like this:

$page = page::getInstance();
$page->css->add('css.css')->add('css2.css');
$page->js->add('file.js')->add('file2.js')

By calling the add() methods page maps to that the specific js and css
directories.

Then in my main site wrapper template I call upon page again to render
out any css/js files that had been "included."  This way my design has
no idea of what js/css that needs to be included and anywhere along
the execution path of my code I can add css/js.

This also allows for some speed increases in page load since you can
get your css included in the header while delaying script includes
until way down in the body.  This prevents browsers from blocking
while compiling your scripts and the user sees something a lot faster.

--- End Message ---
--- Begin Message ---
On Sat, Nov 29, 2008 at 5:59 PM, Martin ZvarĂ­k <[EMAIL PROTECTED]> wrote:

> Joe napsal(a):
>
>> Is it possible to use a PHP operator as a callback? Suppose I want to add
>> two
>> arrays elementwise, I want to be able to do something like this:
>>  array_map('+', $array1, $array2)
>> but this doesn't work as "+" is an operator and not a function.
>>
>> I can use the BC library's math functions instead:
>>  array_map('bcadd', $array1, $array2)
>> but that is an ugly hack that might break if the library is not available.
>>
>> I can create an anonymous function:
>>  array_map(create_function('$a, $b', 'return $a + $b;'), $array1, $array2)
>> but that seems really unnecessarily verbose.
>>
>> Is there any simple clean way to do it? Thanks,
>>
>>
>>
> array_sum() ?


no, if you bother to read OPs examples, it should be clear that he is not
trying to sum the arrays in this manor.  i thought to try array_sum() at
first, but then actually re-read the post, to realize that any use of
array_sum() to solve this problem would be rather convoluted.  at least i
couldnt contrive an array_sum() solution worth posting...

-nathan

--- End Message ---
--- Begin Message ---
Yeti wrote:
I think PHP's string functions are pretty fast and even with large
documents we are talking about a couple of extra microseconds on a
modern machine. I once saw someone do pretty much the same as you are
trying to do with strtr() [1], but I don't know if that function is
faster than str_replace(). You should also consider that if you
framework is going to manage someone's site one day then it could
possibly be on a server with an older PHP version. I disagree with
those on the list saying one should just stick to an existing
templating framework, since it can be quite exciting to think some
neat thingy out. Of course, most people (including me) hardly have any
time at all to spend 1000s of hours on a more or less private project.

[1] http://in.php.net/manual/en/function.strtr.php



Hey Yeti,

Sorry I took so long to respond. Been a busy week or so.

I've decided, for ease of production, to go another route. I am for the time being, using Smarty's engine. This will likely change down the road to a custom template engine, but I believe at this time this is the best option in regards to time/ease.

Thanks for the help anyways. It was valuable information.

- Craige

--- End Message ---

Reply via email to