php-general Digest 22 May 2009 08:07:18 -0000 Issue 6134
Topics (messages 292908 through 292918):
Re: PHP class question
292908 by: Peter van der Does
292911 by: Shawn McKenzie
292912 by: Shawn McKenzie
292914 by: Nathan Rixham
Re: CSS & tables
292909 by: Jessi Berkelhammer
292910 by: Ashley Sheridan
292915 by: Al
Re: SECURITY PRECAUTION BEFORE SUBMITTING DATA IN DATABASE
292913 by: Michael A. Peters
Re: Parse ini file problem
292916 by: Jim Lucas
Re: Forms validation and creation- easier solution?
292917 by: Manuel Lemos
Re: <table>-less layouts; Ideas welcome
292918 by: Manuel Lemos
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 ---
On Thu, 21 May 2009 14:08:11 -0500
Shawn McKenzie <[email protected]> wrote:
>
> This doesn't make sense. You say "class A needs to be extended with
> another class", however what you show below is "class A extending
> framework_class".
>
I worded it wrong, I apologize.
Class A needs to be an extension of the framework class.
--
Peter van der Does
GPG key: E77E8E98
IRC: Ganseki on irc.freenode.net
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Jabber ID: [email protected]
GetDeb Package Builder
http://www.getdeb.net - Software you want for Ubuntu
--- End Message ---
--- Begin Message ---
Peter van der Does wrote:
> On Thu, 21 May 2009 14:08:11 -0500
> Shawn McKenzie <[email protected]> wrote:
>
>
>> This doesn't make sense. You say "class A needs to be extended with
>> another class", however what you show below is "class A extending
>> framework_class".
>>
>
> I worded it wrong, I apologize.
> Class A needs to be an extension of the framework class.
>
Well I guess from my point of view there are several ways depending upon
the requirements. Others that are better with OOP will chime in I'm sure.
This I'll get flamed for, but you can use one instance of core as a global:
class A extends framework_class {
var $core;
function A() {
$this->core =& $GLOBALS['core'];
$this->core->go();
}
}
//in global scope in bootstrap or whatever
$core = new core();
Along the same lines but more OOP and without globals, maybe use a
registry class and store core in the registry. This also uses one
instance of core:
class Registry {
protected $_objects = array();
function set($name, &$object) {
$this->_objects[$name] =& $object;
}
function &get($name) {
return $this->_objects[$name];
}
}
class A extends framework_class {
var $core;
function A(&$registry) { //dunno if you need a reference here or not
$this->core = $registry->get('core');
$this->core->go();
}
//i guess you could also pass in core, but registry will give you all
objects in the registry
//function A(&core) {
//$this->core = $core;
//$this->core->go();
//}
}
//this is in your bootstrap or whatever
$core = new core();
$registry = new registry();
$registry->set('core', $core);
Or, if you don't need an object, call it statically:
class A extends framework_class {
function A() {
core::go();
}
}
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
> Peter van der Does wrote:
>> On Thu, 21 May 2009 14:08:11 -0500
>> Shawn McKenzie <[email protected]> wrote:
>>
>>
>>> This doesn't make sense. You say "class A needs to be extended with
>>> another class", however what you show below is "class A extending
>>> framework_class".
>>>
>> I worded it wrong, I apologize.
>> Class A needs to be an extension of the framework class.
>>
>
> Well I guess from my point of view there are several ways depending upon
> the requirements. Others that are better with OOP will chime in I'm sure.
>
> This I'll get flamed for, but you can use one instance of core as a global:
>
> class A extends framework_class {
> var $core;
>
> function A() {
> $this->core =& $GLOBALS['core'];
> $this->core->go();
> }
> }
>
> //in global scope in bootstrap or whatever
> $core = new core();
>
> Along the same lines but more OOP and without globals, maybe use a
> registry class and store core in the registry. This also uses one
> instance of core:
>
> class Registry {
> protected $_objects = array();
>
> function set($name, &$object) {
> $this->_objects[$name] =& $object;
> }
>
> function &get($name) {
> return $this->_objects[$name];
> }
> }
>
> class A extends framework_class {
> var $core;
>
> function A(&$registry) { //dunno if you need a reference here or not
> $this->core = $registry->get('core');
> $this->core->go();
> }
> //i guess you could also pass in core, but registry will give you all
> objects in the registry
> //function A(&core) {
> //$this->core = $core;
> //$this->core->go();
> //}
> }
>
> //this is in your bootstrap or whatever
> $core = new core();
> $registry = new registry();
> $registry->set('core', $core);
>
> Or, if you don't need an object, call it statically:
>
> class A extends framework_class {
>
> function A() {
> core::go();
> }
> }
>
I guess you could always do a singleton so that you always have the same
instance. Add something like this to the core class (not tested):
static $_instance;
function getInstance() {
if(self::$_instance === null) {
self::$_instance = new self();
}
return self::$_instance;
}
Then you can do:
class A extends framework_class {
var $core;
function A() {
$this->core = core::getInstance();
$this->core->go();
}
}
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
Shawn McKenzie wrote:
Peter van der Does wrote:
On Thu, 21 May 2009 14:08:11 -0500
Shawn McKenzie <[email protected]> wrote:
This doesn't make sense. You say "class A needs to be extended with
another class", however what you show below is "class A extending
framework_class".
I worded it wrong, I apologize.
Class A needs to be an extension of the framework class.
Well I guess from my point of view there are several ways depending upon
the requirements. Others that are better with OOP will chime in I'm sure.
This I'll get flamed for, but you can use one instance of core as a global:
class A extends framework_class {
var $core;
function A() {
$this->core =& $GLOBALS['core'];
$this->core->go();
}
}
//in global scope in bootstrap or whatever
$core = new core();
Along the same lines but more OOP and without globals, maybe use a
registry class and store core in the registry. This also uses one
instance of core:
class Registry {
protected $_objects = array();
function set($name, &$object) {
$this->_objects[$name] =& $object;
}
function &get($name) {
return $this->_objects[$name];
}
}
class A extends framework_class {
var $core;
function A(&$registry) { //dunno if you need a reference here or not
$this->core = $registry->get('core');
$this->core->go();
}
//i guess you could also pass in core, but registry will give you all
objects in the registry
//function A(&core) {
//$this->core = $core;
//$this->core->go();
//}
}
//this is in your bootstrap or whatever
$core = new core();
$registry = new registry();
$registry->set('core', $core);
Or, if you don't need an object, call it statically:
class A extends framework_class {
function A() {
core::go();
}
}
I guess you could always do a singleton so that you always have the same
instance. Add something like this to the core class (not tested):
static $_instance;
function getInstance() {
if(self::$_instance === null) {
self::$_instance = new self();
}
return self::$_instance;
}
Then you can do:
class A extends framework_class {
var $core;
function A() {
$this->core = core::getInstance();
$this->core->go();
}
}
bullseye, static is the way to approach when you only need a single instance
however you don't always need to include a referent to the instance
inside your class.. you can easily
core::getInstance()->go()
or
core::go()
and have class core store an instance of itself
class core {
var $instance;
function getInstance()
..etc - been so long since i touched php4
--- End Message ---
--- Begin Message ---
Hi,
This post is another one that might be better asked on a CSS-list, but
it is relevant to this thread.
The calendar at http://php1.net/my-php-calendar/ seems to have a similar
issue to a problem I am having----cell borders (sometimes) disappear in
Firefox when you zoom out. In both this calendar and mine, the behavior
is unpredictable---sometimes a border will be there, and other times
not. In my case, I have a javascript mouseover, and the mouseover
changes the border behavior below it.
Does anybody have any experience with this?
Thanks!
-jessi
tedd wrote:
At 11:28 PM +0100 5/15/09, Nathan Rixham wrote:
tedd wrote:
However, there are occasions such as in a calendar where not using a
table would be more than difficult. I haven't received a decree yet
as to IF that would be considered column data or not.
I'm gonna differ on this one, when you simply float each calender item
to the left you're pretty much done, in many cases i find it easier
than tables.
Okay -- so you find them easier to use for this purpose.
This is my little php calendar (not all the code is mine):
http://php1.net/my-php-calendar/
and I use tables.
I would not want to redo this script using pure css, but I probably will
do it at some point. We all have investments into our code.
Do you have a css calendar to show?
Cheers,
tedd
--
Jessi Berkelhammer
Downtown Emergency Service Center
Computer Programming Specialist
--- End Message ---
--- Begin Message ---
On Thu, 2009-05-21 at 13:05 -0700, Jessi Berkelhammer wrote:
> Hi,
> This post is another one that might be better asked on a CSS-list, but
> it is relevant to this thread.
>
> The calendar at http://php1.net/my-php-calendar/ seems to have a similar
> issue to a problem I am having----cell borders (sometimes) disappear in
> Firefox when you zoom out. In both this calendar and mine, the behavior
> is unpredictable---sometimes a border will be there, and other times
> not. In my case, I have a javascript mouseover, and the mouseover
> changes the border behavior below it.
>
> Does anybody have any experience with this?
>
> Thanks!
> -jessi
>
> tedd wrote:
> > At 11:28 PM +0100 5/15/09, Nathan Rixham wrote:
> >> tedd wrote:
> >>> However, there are occasions such as in a calendar where not using a
> >>> table would be more than difficult. I haven't received a decree yet
> >>> as to IF that would be considered column data or not.
> >>
> >> I'm gonna differ on this one, when you simply float each calender item
> >> to the left you're pretty much done, in many cases i find it easier
> >> than tables.
> >
> > Okay -- so you find them easier to use for this purpose.
> >
> > This is my little php calendar (not all the code is mine):
> >
> > http://php1.net/my-php-calendar/
> >
> > and I use tables.
> >
> > I would not want to redo this script using pure css, but I probably will
> > do it at some point. We all have investments into our code.
> >
> > Do you have a css calendar to show?
> >
> > Cheers,
> >
> > tedd
>
> --
> Jessi Berkelhammer
> Downtown Emergency Service Center
> Computer Programming Specialist
>
I've just zoomed out to the maximum Fx allows me, and the borders remain
all the way through. Using Fx 2 on Linux. It could be a known issue,
have the you checked Bugzilla?
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
There appears to be a bug in the FF3x cell line generating code. border-collapse
is a mess, it doubles up some cell lines and drops others when drawing and
redrawing tables.
I had to make a nice lines between cells by assigning tds with bottom and right
sides only.
Al.......
Jessi Berkelhammer wrote:
Hi,
This post is another one that might be better asked on a CSS-list, but
it is relevant to this thread.
The calendar at http://php1.net/my-php-calendar/ seems to have a similar
issue to a problem I am having----cell borders (sometimes) disappear in
Firefox when you zoom out. In both this calendar and mine, the behavior
is unpredictable---sometimes a border will be there, and other times
not. In my case, I have a javascript mouseover, and the mouseover
changes the border behavior below it.
Does anybody have any experience with this?
Thanks!
-jessi
tedd wrote:
At 11:28 PM +0100 5/15/09, Nathan Rixham wrote:
tedd wrote:
However, there are occasions such as in a calendar where not using a
table would be more than difficult. I haven't received a decree yet
as to IF that would be considered column data or not.
I'm gonna differ on this one, when you simply float each calender
item to the left you're pretty much done, in many cases i find it
easier than tables.
Okay -- so you find them easier to use for this purpose.
This is my little php calendar (not all the code is mine):
http://php1.net/my-php-calendar/
and I use tables.
I would not want to redo this script using pure css, but I probably
will do it at some point. We all have investments into our code.
Do you have a css calendar to show?
Cheers,
tedd
--- End Message ---
--- Begin Message ---
Eddie Drapkin wrote:
Suhosin is completely not-related to SQL, though, I don't know why you'd
bring it up...
I brought it up because suhosin catches many exploits that otherwise get
through, including exploits that allow inclusion of remote files that
can then be used to run arbitrary commands on the server, send include
files (such as the db authentication script) as plain text, all kinds of
nasty can result.
--- End Message ---
--- Begin Message ---
Thodoris wrote:
I am trying to parse an ini conf file using parse_ini_file but fails
without returning something. I found this which is probably the reason:
http://bugs.php.net/bug.php?id=44544
(the $ in the values)
The problem is that this file has more than 7500 lines so it's kind of
difficult to use quotes in all fields and there are several other
reasons that I want to avoid quoting the values. In addition to that PHP
5.3 (which fixes this) is not stable yet and thus I can't install it in
a production machine.
So does anybody know any workarounds??
well, looks that the 3rd argument has always been a part of parse_ini_string()
So, you could do this...
$ini_data = parse_ini_string(file_get_contents($filename), FALSE,
INI_SCANNER_RAW);
I think this will work for you.
Jim Lucas
--- End Message ---
--- Begin Message ---
Hello,
on 05/20/2009 11:09 AM Paul M Foster said the following:
> Both this class and Manuel Lemos' form generation class (from
> phpclasses.org) will create beautiful forms for you. However, you may
> find that the amount of [repetitive] typing you do will be equivalent or
> greater than simply creating the form by hand.
>
> The best solution would probably be a form you fill out which asks you
> about all the fields you want, and then generates the code to paint the
> form. There are commercial solutions which do this, and some (not that
> great) free solutions. I'm working on one myself, which will eventually
> be a sourceforge/freshmeat project.
Thank you for mentioning my package, but I am not sure what you mean.
The Forms Generation and Validation package seems to do exactly what you
describe and more.
IMHO, creating forms by hand is by no means simpler, especially if you
want to include browser side (Javascript) validation.
I mean, I am not masochist to create something that will give me more
work in the end to develop PHP forms based applications than if I would
type HTML manually.
Furthermore, the plug-ins that come with the package dramatically reduce
the amount of code you need to type to achieve the same generating
common HTML inputs manually.
Anyone can judge by yourself by going here and see several example forms
and the actual code that it takes to generate them:
http://www.meta-language.net/forms-examples.html
For instance this scaffolding plug-in generates CRUD forms that you
often need to manage data stored for instance in databases.
http://www.meta-language.net/forms-examples.html?example=test_scaffolding_input
For those interested to check it out, the actual class package can be
downloaded from here:
http://www.phpclasses.org/formsgeneration
Here you may watch an extensive tutorial video that covers practically
all features:
http://www.phpclasses.org/browse/video/1/package/1.html
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Hello,
Jim Lucas wrote:
> Since this has been a topic of dicussion, I figured I would add my
> thoughts.
>
> I have been toying with the idea of doing a <table>-less layouts
> involving tabular data, calendars, etc...
>
> Recent threads have finally made me do it. Let me know what you think.
>
> http://www.cmsws.com/examples/templates/div_tables.php
> http://www.cmsws.com/examples/templates/div_tables.phps (source for above)
> http://www.cmsws.com/examples/templates/div_cal.php
>
> When you turn off the styles, the calendar becomes pretty rough on the
> eyes, but still "accessible".
>
> Same thing with the tabular data structure.
>
> But, not knowing how the various types of accessibility applications
> work, I am guessing that the layout to an application trying to read it
> should work fairly well. Let me know if I am way off the mark with my
> thoughts.
Excuse me for maybe not so nice opinion, but honestely I find it silly
to use not use plain HTML tables precisely for the purpose that they
should be used for: displaying data that should be aligned both
vertically and horizontally.
Using HTML tables is not a sin. You will not go to hell if you use HTML
tables.
Avoiding using HTML tables has nothing to do with accessibility. You
non-HTML table based tables are not more accessible to blind people than
using real HTML tables.
HTML tables are part of the Web standards. Who told you otherwise lied
to you. Look W3C that define the Web standards documented it here.
http://www.w3.org/TR/html401/struct/tables.html
Your hack to avoid using HTML tables is not the same as using tables
because you need to define styles that fix the width of the columns to
make sure all cells in a column have the same width. You loose the
functionality of HTML table to auto-adjust the width according to their
content.
In the end you will have much more HTML tags and attributes than if you
used simple HTML tables.
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---