« first day (258 days earlier)      last day (4683 days later) » 
04:00 - 11:0011:00 - 22:00

Tek
4:54 AM
Does anyone know why $db->query(); Only returns the query string?
It used to return results...
Now I have to do $db->query('sql')->fetch(mode);
wishes backticks would work on the above code grr
 
and what exactly is $db ?
 
Tek
PDO Object
I wonder if it has to do with the fact that it's returning multiple results
rather than one...
 
 
1 hour later…
5:59 AM
hey guys , an offtopic question ( kinda ... i need it for IDE )
where can i get a 32bit JRE , without installing it ?
( i already have 64bit JRE )
 
6:43 AM
@teresko on the oracle/java site?
 
already found one
 
I don't fully understand your question though, you have to install it if you want to use it.
@teresko - Now, a question for you:
How would you define a setter/getter for a property?
The "problem" I'm facing is that I'm passing an object, but depending on the object I'm calling, the object goes somewhere specific. Example:

class Field {
    public function set_form($form){
        $this->form = $form;
...
class Label {
    public function set_form($form){
        $this->field->form = $form;
 
right below __construct() , without extremely minimal phpDoc , without any unit tests by default , using name set_{variable name} and get+{variable name} and avoiding magic methods
emm ... the object graph seems a bit backward
 
what do you mean? I showed two different classes to show why I need this.
 
the child elements should not be aware of the parent ( respectively : field and form )
 
6:48 AM
There's no child so far
 
$this->field->form = $form; << this is really really bad design
 
@teresko - Aha, actually I can $this->field->set_form($form); Better?
 
that doesn't change the core of the problem
because as it is now , your Label class is indirectly responsible for setting up Field instances
 
Ah, but that's intended.
 
but that's wrong
 
6:51 AM
Well, ok. You know of a better idea? Right now, this is what I had in the label's constructor:
			$arg1->form = $this;
			if(isset($arg1->field)) $arg1->field->form = $this; // FIXME: HACK!!!
 
answer this : what Lable::set_form does for Label instances ?
 
(lol)
Oh
Well, it sets the label's container (form)
 
no, it doesn't
it changes some staff in the Field instance , but what does it do for Labels ?
 
You've got a point there, but the setter/getter's task is to store the instance and get it back, no matter what.
 
there is no justification for having such method in lable class
 
6:54 AM
@teresko ok, let's say instead of ->field->form=$form I do ->form=$form
 
do you need $form for the Labels ?
 
The problem I have is that this set_form() is called by the form the item is appended to.
Yes
 
or do you need it for Fields ?
 
Both
class Form {
    function append($element){
        $element->set_form($this); // DI
 
or , does that Form need Fields and Labels ?
 
6:56 AM
That is correct, but the question is, how does Field/Label know which Form it is in?
 
they don't , and the shouldn't care
 
Exactly.
So if, say a specific Field had to modify the Form's action URL (for example), it can't.
 
@ChristianSciberras , you "child" elements of object graph should not be able to affect parent
 
And in the case above, what would you suggest?
Passing the URL through "filters" of each child (sounds far-fetched imho)?
 
you will elaborate on that one, because i dont see a legitimate example where one would need it
 
7:01 AM
Let's say a Form has an ID.
 
ok
 
In javascript, I would jQuery('#FormID .field-5').val()...
Of course, I suppose I could have a global static counter, and do jQuery('#field-5'), where 5 is unique among all forms.
But, well. Doesn't sound good to me.
 
i still don't see what you are getting at
a bit sick today
 
oh.
Well, I don't want to bother you then.
 
why would you even use $('#form .field-5').val() ?
 
7:06 AM
To get the value of a field.
 
usually you would use $(this).val()
 
That whole expression ensures it is compatible among multiple forms.
ok, forget the val part.
you just can't $(this) when you don't have a context yet.
To get the context, you need to know about the parent form.
 
you attach events to the form, or even document.body , and not to each element separately
 
But that's not an option.
 
it really really should be
 
7:09 AM
Sure, I guess you could do $(this).find('.field-5'), but isn't that over-complicating stuff?
 
just checking (no offense intended ) .. but , do you know what event delegation is ?
 
woah! did the sickness actually make you less abrasive @teresko :P
 
Handling events at a parent level instead of element level?
 
because if you have elements like .. emm .. dunno .. custom calendar-thing , then you do not care in which form it exists
 
7:15 AM
@teresko Do you know some text/article on why a child shouldn't be aware of its parent?
Perhaps @Gordon might have some advice.
 
.. i saw it somewhere , but it will take some time for me to find the source
 
@teresko - You try get back on track, I'm sure @Gordon or @KamilTomšík could find it easy.
 
well , they will tell you the same thing
 
7:40 AM
it depends
if you need to traverse the object graph the nodes have to be linked
think DOMDocument
 
ah, sorta like .parent() <- could be anything
 
for instance. but in the case of a form it could also be the formRoot
 
But that's for multi-level objects. What if the components are always one level deep?
 
imo thats irrelevant
 
Now that I think about it
 
7:44 AM
the question should be: do the children have to be aware of their parent
 
I did have an issue
 
or more specifically: do the form elements have to know the form
 
When a Label had a Field in it, the Field couldn't traceback to Label (by unintended design).
About that. I'm kind of the opinion that it should.
 
then you should have an explanation for it
 
I like the parentNode() concept. I could still have a formNode() method which finds the topmost container.
What do you mean by "explanation for it"?
 
7:48 AM
an explanation, you know.. being able to explain why you think it should have that
versus just saying that it should
 
Aha
ok
well I'm used to writing stuff in delphi.
Each visual control could easily trace back to the containing Form
Even when the control was actually in some deep parent hierarchy
But the point is, when I needed something, there was always Form.
Similar to JS's Window.
procedure onButton1Click(event: TEvent);
begin
  Form2.Edit1.Caption:='Hi';
 
the main problem with being able to traverse up and down is digging into object graphs and then doing work is a violation of law of demeter
 
The concept is that a component could actually interact with others.
Let's forget for a second that you can link multiple radiobuttons to work as a single option and wanted to do this manually
The Delphi way would be to drop a RadioGroup component with radios "inside" it.
So basically, it's a component who's job is to interact with other components.
5. a global variable, accessible by O, in the scope of M
Isn't the Form akin to that?
With the exception that it isn't exactly global
 
sorry, but i dont understand what you are saying
 
@Gordon - A component that modifies the form it is on is very common in UI
For example, Delphi had a Win32 Theme component which simply made components take up the style of newer Windows.
In reality it didn't modify the components (programmatically) but it's a clear case of a component that is aware of the form and its components.
 
8:04 AM
is it aware of the form and the components or is it just an observer listening for events?
 
The earlier one.
 
i still dont understand why you are telling me this though
 
Well, you asked for an example on why I think a component should be aware of the form it's on.
 
so the example is because it is in delphi?!
e.g. a language used in desktop environment that is not generally applicable to the way the web works
 
@Gordon , this is the code fragment we talked about :
class Field {
    public function set_form($form){
        $this->form = $form;
...
class Label {
    public function set_form($form){
        $this->field->form = $form;
 
8:08 AM
@Gordon - It's an enterprise-level language, which follows many OO principles.
@teresko is correct. In hindsight, I did see several different flaws with that code.
Which, thanks to your suggestion of ->parent() seems to make it work better.
 
@ChristianSciberras bingo!
 
I'd do a top-level getForm() method:

function getForm(){
    $buf=$this;
    while($par=$buf->getParent());
    return $buf instanceof Form ? $buf : null;
}
I'm not sure I need a getter/setter for g/setParent, since it's always modifying the same property.
 
@teresko i dont see why i should have a method set_form on these. either the parent is required, then it should be passed in as a ctor argument and be immutable or its not required and then it shouldnt be there. also doing set_form on the label that then sets the form on field makes me wonder why the method is on Label
 
Wouldn't be "nice" to have:

function duplicate(){ // or __clone()?
    $tmp = clone $this;
    $this->getForm()->append($tmp);
    return $tmp;
}
 
i never said that you need set_form()
i said that lower order objects should not be able to affet higher level objects
 
8:16 AM
@ChristianSciberras no. why?
 
@Gordon In the form I had a ->append which automatically called ->set_form() - to fix a mess really.
 
@teresko in general, yes. like i said, it depends.
 
well , you are thinking in the terms of DOM here , and other tree-like structures
that is a somewhat different case
 
@teresko - Well, this is a Form I'm talking about, with several Inputs and all :-P
 
that does not make it a tree-like structure
 
8:24 AM
Form > Label > Field
     > Field
     > Group > Field
             > Label > Field
 
Fields have ( sometimes ) a Label
well .. here is a hint what you will discover soon : form generation is just an exercise
 
I need help on my project. It is about Google Map.
is anyone here been working with google map's api? :)
 
@teresko I know. Don't confuse the HTML with the form structure.
By label I mean some text on the left of the field.
 
my problem looks like this one regeltante.nl/pages/2009/134/loadid/116671/functie/0 I have started reviewing google maps docs
 
A checkbox is surrounded by a label, but to the structure, it is just a checkbox.
 
8:29 AM
which is a <label> .. if you want to put in some other tag then you just suck at html
and no
you so not surround the tags with <label>
you use <label for="something">blah blah</label>
 
@teresko afaik its valid to put the input into a label
 
@Gordon is right.
Doing so ensures the space around the checkbox/radio is clickable.
 
yes , it is valid , but it makes for really poor css
 
e.g. <label><input/></label> is fine.. you might want to doublecheck on it though (i never use them like this and prefer the sibling approach)
 
@ChristianSciberras , if you use for attribute you get the same effect , but without the drawbacks
 
8:33 AM
I use for as well!
And it ain't the same effect.
The area around the checkbox is not clickable.
 
lol
 
You can't do a margin/padding around the checkbox, for example
 
do you know what you have to put IN the for ?
 
The only clickable area is the label
@teresko You know what? Sounds like you're not sick anymore. :)
But this is completely past the point. The form structure doesn't reflect the HTML structure. Just because there's a class named Label doesn't mean it must do a <label/>, but that it simply servers as a label to a field. Coincidentally, it does generate a label tag, but again that's past the point.
 
the point was, that "label" is just a property of a field
 
8:37 AM
back on topic, why exactly does a form element need to know about the form root again? what functionality can a Label or a Checkbox do that requires manipulation of the Form Element?
 
It is not.
 
form non-HTML point of view
 
Label encapsulates a field.
 
@Gordon , because he wants to generate javascript too
 
@Gordon it could be a checkbox that populates form data, for example.
<label for="name">Name:</label> <input type="text" id="name" name="name"/>

Is different from:

<input type="checkbox" id="rem" name="rem"/> <label for="rem">Remember Me</label>
 
8:38 AM
@ChristianSciberras i dont understand that. isnt the form by itself the form data?
 
@Gordon - Form structure is separate from form data.
Data as in "content"
(you now know I have a GB keyboard lol)
 
@ChristianSciberras i'd argue unless you are representing the HTML DOM tree the above doesnt map 1:1 to a possible form implementation PHP
 
No it doesn't.
 
if a field element has a label, then label is a property of that field. how that is rendered in the transformation to HTML is a different story.
both outputs could be represented with field->label
 
a field element has a property "label" , which , when rendered, can be either encapsulating or external
 
8:41 AM
It's not a property so that it could be swapped with other components.
 
@ChristianSciberras answer this : Which can exist without the other ? Field or Label ?
 
then why does the Label contain a Field ?
 
then it should be obvious that label belongs to field
 
For the sake of a conversation, it could be swapped with a RequiredLabel, which simply checks if Field is required and adds a star to the field label.
 
8:44 AM
that could be a decorator $field->setLabel(new Required(new Label)) or a subtype then $field->setLabel(new RequiredLabel)
 
Then again, it's difficult to represent my way from a UI designer tool. Or not.
 
and i'd argue that the label should not check if the field is required at all
 
why would you even require an object for labels ?
the field is either required or not
not the label
 
@teresko to be able to compute
Yes that is true, a Field has a bool property required
 
which might ( or not ) affect how you render the label for that field
 
8:47 AM
why is being required a field property and not one of the validators in a validator chain attached to that form element?
 
Ah, yes. It complements Validators.
 
well , yeah
the point was that label itself does not have any responsibilities
 
@Gordon You see, a field may require validation, but it is not actually "required" - the value can be left unchanged.
 
@ChristianSciberras validating that it's present in the submitted form data is a validation
 
form generation is a dead-end
you either get something useless for anything but the most simple cases , or something extremely complicated ( and thus - useless )
 
8:50 AM
Well, it's not overly complicated. So far.
That's a working concept. I'm still changing(replacing even) most of the code to be better OOP.
Scroll to the bottom of the code and see the form generator
Campare to the form.
 
sidenote @param string|Field|array $element Either raw HTML, a Field object or a list of such objects. means it should be three methods
sidenote stuff like ### PUBLIC PROPERTIES ### is superfluous clutter
 
another sidenote : javascript should be in external file
 
/**
* Do not override.
*/

means design flaw
 
public function renderHtml(){
		echo '<input type="hidden" name="'.$this->name.'" id="'.$this->name.'" value="'.$this->default.'"/>';
	}
 
Agreed :P but that's not the point.
 
8:56 AM
there is very little cohesion in those classes, which should make you wonder why those methods are on those classes
which should make you question what you are modelling
 
offtopic
> anyone use a good jQuery powered framework?
am i only one who thinks that this is oxymoron
 
@Gordon nope
@Gordon - Though I appreciate scrutiny of the actual code, I'd prefer if you didn't focus on it at this point.
 
public function __construct($name, $default=null, $validator=null, $required=false){
isnt $validator one responsible for checking if field is require or not ?
 
@teresko That's what I was discussing with @Gordon
My idea is a bit different, though it ain't implemented as of yet.
The idea is to have an "observer" that ensures the data you enter is correct, aka validator
 
i have a feeling that ever php developer at some point tries to make a form generation thing .. lets call it growing-pains
 
9:01 AM
But you may keep it empty (if required is false) otherwise you have to enter something (required is true)
@teresko - It's my 3rd time. 4th actually.
 
@ChristianSciberras nope what?
 
Oh, sorry, meant @teresko
But again, forget the actual code and look at the final form generation code, I'd like to know your thoughts about it.
 
well, my thought is I dont understand what that Form library does
 
@Gordon NB: The "superfluous clutter" will be gone in actual code. I've been testing extensively on notepad, hence leaving big marks here and there.
 
compare it with Zend_Form. Yes, it's akward to use if you need to customize it, but then again, it's pretty obvious if you dont deviate from standard use-cases.
 
9:07 AM
@Gordon - The form library eventually will be incorporated in a form designer (both a backend plugin and a general-purpose standalone app). It will be able to map PHP objects easily with form.
 
oh .. you want to hook it up with an ORM too i guess
=D
 
    Eventually, I'll have something like:

    // load user id 5
    $user = new User(5);
    $user->load();

    // load form named "profile" from file "profile.frm.php" and bind to user object
    $form = new Form('profile', 'forms/profile.frm.php', $user);

    // if form should be saved, call handle method,
    // which automatically updates $user and saves it.
    if(isset($_POST['save']))
        echo $form->handle(); // also show messages here

    // show the form
    $form->render();
 
.. while you are at it , you might develop a solution for world peace too
 
@ChristianSciberras If it maps PHP Objects, then it's a DataMapper. That doesnt say anything about what your Form represents.
 
@teresko - That's easy. Make me the leader!
@Gordon That's the basic idea, but of course, classes change, methods change as well.
 
9:13 AM
@ChristianSciberras what does your Form represent? what's it's purpose? It's responsibility?
 
@Gordon - I'm a bit confused by that question, honestly.
The form represents an html form.
 
what form? HTML form?
 
You can provide an object for it to mess with, or you could provide callbacks (eg, for login forms).
 
so it will have methods provideObject() and provideCallback()
 
Probably.
 
9:16 AM
hi all
 
not probably. if that is what your form is going to do then that is your public API
@nikic hi
 
Morning all
 
@Gordon - "Probably" in how it is named, but that is it's purpose.
 
when i think about a Form, I definitely dont think about provideObject() nor provideCallback
 
9:16 AM
Hi @robik
 
my though concept of a form simply doesnt include that
 
@Gordon - When I think about database, I don't think about schema, stored procedures et al :P
 
then your concept is wrong
 
@Gordon You can use it to make a simple form, but that's missing out the fun ;)
 
what is a simple form?
 
9:18 AM
@Gordon - No it's not necessarily wrong.
Ah, I was going to ask you what a database was.
But let me answer first.
A simple form is just HTML code (which floats around the form tag, of course).
 
alright, so you are building a tool to generate HTML
 
Yes.
With some added features.
 
which means you should be using DOM or XMLWriter for it
 
That's a good point actually.
 
and if you are not going to use those, then your objects in the Form generator should be modeled after actual HTML form elements
 
9:20 AM
The only thing in my defense is that I may want to go to the lowest level possible, to do things normally restricted by dom/xmlwriter
 
what could that be?
 
I was going to say "maybe even swap the ml type"
But I realize that I can swap the classes completely and still support the same structure (those constructors).
 
for the record: you are not building a Mapper, you are building an HTMLFormRenderer
you see the difference, do you? its completely different responsibilities
its different problem domains
 
Yes I do.
Question, how would you connect them together?
$form->mapTo($object) ?
or $object->mapWith($form)
 
of course not
$mapper->map($user, $userForm) but that means $user and $userForm will have to expose their internals to the outside (or the Mapper has to use Reflection).
so we will eventually get back to @KamilTomšík and come to the conclusion that it should be $user->renderTo($formRenderer)
@ChristianSciberras which would be the second thing you suggested
 
9:32 AM
Talk about being distasteful of oop :P
 
class User …
    public function renderToForm($formRenderer)
    {
        $formRenderer->render(array(
            'username' => $this->username,
            …
        ));
    }
}
that in turn means your formRenderer cannot be generic, but knows how to render a username
 
Might as well $formRenderer->render((array)$this); sigh
 
@Gordon ha, got you :-P
 
if you want it to be generic with this approach, the User will have to know how to use the interface of the Form renderer
 
@Gordon Oh, that's not a problem.
 
9:35 AM
cheers :)
 
and since @KamilTomšík is here now he can reiterate all the things he probably already told before
 
ignores evil @KamilTomšík
 
hi @KamilTomšík
 
well, I don't want to :-D @ChristianSciberras is mixing multiple things together
 
@KamilTomšík definitely
 
9:36 AM
function render($stuff){
    foreach($this->elements as $element)
        if(isset($stuff[$element->name]))
            // a match!
}
 
it's imho better to let him do it, explanation will be easier then...
 
@KamilTomšík There's something new about you today.
Oh, you changed the picture? But I liked the older one! >:(
 
class User …
    public function renderToForm(Zend_Form $userForm)
    {
        $userForm->populate(array(
            'username' => $this->username,
            …
        ));
    }
}
 
I've deleted facebook acc, so I had to register to stackexchange and add that OpenID to my SO account.
2
 
Ah, for deleting the facebook account, I forgive you! :P (starred; more people should do this more often)
 
9:41 AM
I wish there was something like fb/twitter without all that social stuff - just for login and available everywhere :)
 
@KamilTomšík linkedin.com?
It's great, only an hour or so each week.
 
@ChristianSciberras I'd vote for opera link :-P
 
You opera addict, you :P
Can't blame you though.
 
I already have account, would be cool if they published it as at least OpenID or maybe even OAuth
 
It ain't listed.
 
9:44 AM
@Gordon seems like you've changed opinion to some things - like renderers, is it just for examples or even for production code?
 
@KamilTomšík for evaluation :)
 
@KamilTomšík You hate smalltalk, right?
 
@ChristianSciberras sure :-P
 
@KamilTomšík basically, im a simpleton in those things. if i believe something and you tell me different, i will deny you. if you provide enough information to make me doubt, i will do research to reaffirm my position. if that fails (like in the case of Tell Dont Ask but not in the case of East Principle), I will change my believe.
so all you gotta do is raise my threshold from denial mode to doubt mode :)
 
9:54 AM
Low and behold the Scientific Theory. :P
 
@Gordon fair :)
 
@Robik YASN
 
Yup, Google starts competition to everyone...
 
the only convincing argument I heard so far from moving to G+ is that you are moving your data to the company that knows all about it already anyways.
 
10:00 AM
@Gordon - Wait, that makes it a plus?
 
decide for yourself.. i sure wont be moving to G+ just because it's there now and everyone does it
 
What about that?
YAGC
 
microsoft.com+1
lol
 
@ChristianSciberras its online in case you still wanna go phpconference.com/?l=_en
that'll be 998€ if you book now, incl. workshop day
not including 4 days accomodation
and dinner
 
10:17 AM
@Gordon excluding plain tickets, of course?
 
yeah, that as well and travel to Mainz (afaik they dont have an airport)
 
Oh :(
You're not organizing any of it by any chance? (just curious)
 
you'll likely go to FRA then and take the train from there
im not sure i will attend
half of those talks i already know
 
I'd like to give talk too :-P
 
@KamilTomšík yeah, you're to late. CfP is closed :)
 
10:20 AM
Well, that sucks.
 
:-/
yeah, would be fun to talk about other languages on PHP conference :-D
 
@KamilTomšík IPC is usually together with WebTech, so that wouldnt be uncommon
 
10:50 AM
Anyone knows how I can construct an object with a variable number of constructor arguments?
Similar to call_user_func_array() for functions.
Hmm, reflection does it. Fixed.
Thanks @salathe
 
@ChristianSciberras hmm, what did I do?
 
6
Q: Call a constructor from variable arguments with PHP

zneakI have a function that takes variadic arguments, that I obtain from func_get_args(). This function needs to call a constructor with those arguments. However, I don't know how to do it. With call_user_func, you can call functions with an array of arguments, but how would you call a constructor f...

 
@Gordon noticed the summer sale on steam? :D
 
@JohnP not yet
 
@ChristianSciberras ahh :)
 
10:57 AM
it's huuuge!
 
You guys on steam?
 
oh. witcher 2 33% off.. i knew it was good to wait
 
What do you play?
Say, any of you a fan of minecraft? :P
 
nah. I played around on single player a bit. but then stopped. not much time
 
04:00 - 11:0011:00 - 22:00

« first day (258 days earlier)      last day (4683 days later) »