How to upload files in Agavi Framework Edit
14:29 < simoncpu> hi... how can i upload files in agavi? 14:29 < simoncpu> $rd->getFile() doesn't seem to work 14:38 -!- benschi [firstname.lastname@example.org] has joined #agavi 14:42 < benschi> simoncpu: If sent via POST executeWrite is ya friend 14:43 < benschi> then in ze Action $rd->getFile('file') 14:44 < benschi> but be sure to validate the file first 14:47 < simoncpu> benschi: $rd->getFile('fieldname') returns null... 14:47 < simoncpu> validation is set to conditional 14:48 < benschi> simoncpu: I remember that there was something special about the form 14:48 < benschi> let me check 14:49 < benschi> enctype="multipart/form-data" 14:49 < benschi> try that 14:50 < simoncpu> <form method="post" enctype="multipart/form-data">
How to move uploaded file to desired location Edit
Agavi Filesize Edit
I hope it's possible to strip down Agavi.
10K ./model 34K ./view 612K ./build 728K ./config 76K ./controller 24K ./core 76K ./database 366K ./date 96K ./exception 106K ./filter 52K ./logging 200K ./validator 56K ./renderer 12K ./action 60K ./response 138K ./routing 72K ./storage 92K ./testing 3.2M ./vendor 7.4M ./translation 24K ./user 84K ./util 122K ./request
vendor/ and translation/ make up 10.6MB out of Agavi's 14MB size. PHPUnit (located inside vendor/) is not needed in production environments, and some projects require only one or two languages.
Manually specifying a template in Agavi Edit
17:11 < simoncpu> houmenta 17:11 < simoncpu> in agavi, how do you guys use the same template in both your Success and Error views? 17:11 < simoncpu> i just want to display a line of error message in my Error view 17:14 < Seldaek> $this->getLayer('content')->setTemplate('BlahSuccess'); 17:14 < Xylakant> $this->getLayer('whateverthenameofyourcontentlayeris')->setTemplate('whateverthenameofyourtemplatefileis');
Manually specifying a view in Agavi Edit
18:53 < simoncpu> how can i manually set the action's view? 18:53 < simoncpu> i.e., if i do return "Success" from IndexAction, 18:53 < simoncpu> IndexSuccessView is used; how can i use SomethingSuccessView instead? 18:56 < Jarda> array('Module', 'SomethingSuccess') could work 18:56 < simoncpu> lemme check 18:58 < simoncpu> Could not find file for View "SomethingSuccess" in module "Module" 18:58 * simoncpu tries specifying the subfolder 18:59 < Jarda> yeah, 'Subfolder/SomethingSuccess 19:01 < simoncpu> cool, it works
Redirecting a page inside a Controller Edit
18:08 < simoncpu> i'm not sure if i'm doing this correctly, but is it advisable to redirect the page from the Controller? 18:08 < simoncpu> i mean, do i need to create a new View just to redirect a page? 18:08 < sth> In other frameworks I do it fromt he controller, I don't see why agavi would be any different. 18:09 < sth> from the* 18:09 < simoncpu> cool, cool 18:09 < simoncpu> btw, i just do a setRedirect(), right? 18:10 < sth> Sounds right, but check with the API 18:10 -!- icyt is now known as IcyT 18:11 -!- fnordfish [n=Adium@188.8.131.52] has joined #agavi 18:11 < simoncpu> $this->getResponse()->setRedirect() works inside a view but inside a controller 18:11 < simoncpu> i guess i need to check with the api 18:13 < _cheerios> in agavi you redirect in ze view 18:13 < sth> Ok Furhurer cheerios 18:14 < simoncpu> mvc purists.... 18:14 < simoncpu> mwahahahaha 18:14 < sth> heh 18:15 < sth> Mind you I guess other frameworks don't have sections for the view like agavi does 18:15 < sth> Zend's version of a view is to allow you to make a .phtml file
Zen of Agavi Edit
17:12 < simoncpu> ei, i have this epiphany a while ago 17:13 < simoncpu> i realized that web app frameworks are simply web apps... there's nothing "magical" about it 17:13 < simoncpu> then you extend the framework by adding modules 17:14 < simoncpu> the project is a subset of the framework, not the other way around 17:14 * simoncpu speaks to the wind to talk to himself 17:14 < sth> No, a app based on a framework by definition is a superset. 17:14 < sth> Since you're adding functionality. 17:15 < simoncpu> hmmmm 17:15 < sth> A subset would be taking a small group of the functionality provided in the framework 17:15 < sth> But with say, an agavi project, you're adding so it makes it a superset 17:16 < simoncpu> i think a framework is a web app that you extend... it's a skeleton web app that forces you to structure your code in a specific way 17:16 < sth> since all the original functionality is there plus more 17:16 < graste^china> agavi's not a web app since you may use it as a console ab etc 17:16 < graste^china> s/ab/app/ 17:16 < sth> Yeah 17:16 < simoncpu> ah... that makes sense 17:17 * graste^china has the epiphany, that everything is just code and can be rewritten, modified, read, deleted, forgotten and rediscovered over the years... =) 17:17 < simoncpu> i have this perspective a while ago, that frameworks are "hidden underneath" the project 17:17 < simoncpu> with agavi, i realized that the framework is a part of the project 17:17 < simoncpu> something like that 17:18 < simoncpu> an action is simply a class that inherits classes from agavi 17:18 < sth> Yeah, without a doubt 17:18 < sth> But that's how MVC should be implemented
17:45 < simoncpu> how do i use sessions in agavi? 17:45 < Jarda> simoncpu: via user 17:46 < simoncpu> $this->getContext()->getUser()->setAttribute()? 17:46 < simoncpu> uhm... why is it called getUser()? 17:46 < simoncpu> it sounds like a specialized login system 17:46 < Xylakant> user is the abstraction for any data that outlives the request 17:47 < Xylakant> because the data is usually tied to a user 17:47 < Xylakant> it could have been called usersession or whatever, it's user because it has always been user
17:05 < simoncpu> how can i pass a parameter to its constructor, like $myclass = new MyClass('param'); ? 17:05 < Jarda> $this->getContext()->getModel('MyClass', null, array('param')) 17:06 < Jarda> and in your MyClass model you create a initialize(AgaviContext $context, array $parameters) and that param will be $parameters 17:07 < simoncpu> ah, so i need to use initialize() instead of __construct()? 17:08 < Jarda> yeah 17:08 < simoncpu> btw, if the 2nd param in getModel() is set to null, will it automatically look for the model inside its own module? 17:08 < Jarda> no 17:08 < Jarda> then it looks in app/models/ 17:08 < simoncpu> ah... 17:09 < Jarda> http://codepad.org/6nzaMc68 (wiki note: copied to http://simoncpu.pastebin.com/f29cf8bec) 17:10 < Jarda> I don't use constructors in my models, as I do all constructing via initialize 17:11 < simoncpu> ah... 17:11 < simoncpu> we need to manually call AgaviModel's initialize() as well? 17:11 < Jarda> yeah, or do all the context-related stuff in you own initialize() 17:17 < simoncpu> btw, how can i get the current module name? 17:19 < graste> $container->getActionName() and $container->getViewName() as well 17:20 < graste> $this->getContainer()->...
Form Population Filter Edit
12:44 < simoncpu> huomenta 12:44 < simoncpu> is it possible to control where fpf would insert its error messages? 12:45 < simoncpu> you see i have an IPv4 address field which consists of a text box and drop down box 12:45 < simoncpu> i need to insert the messages below those two elements 12:45 < simoncpu> instead of below the textbox 13:01 < MugeSo> simoncpu: use error_messages, field_error_messages or multi_field_error_messages parameter 13:06 < simoncpu> thanks 13:07 < MugeSo> multi_field_error_messages is for checkbox or radiobox, filed_error_messages is for other fileds. error_messages is used for errors not related to any field. error_messages is also used if field_error_messages or multi_filed_error_messages is not set.
Validation: Difference between Arguments and Parameters Edit
00:11 < simoncpu> what's the difference between arguments and parameters? 00:15 < _cheerios> same distinction as elsewhere; there's (function) arguments and (query) parameters. 00:15 < Xylakant> parameters are passed to the validator to change how it acts 00:15 < Rayne> arguments are "user input" 00:15 < Xylakant> arguments are the name of the request arguments the validator acts upon 00:16 < simoncpu> ah, i see... 00:16 < simoncpu> i can now see the distinction even though everything can be put into the arguments or parameters.... 00:16 < simoncpu> arguments = what 00:16 < simoncpu> parameters = how 00:17 < Rayne> in some cases you can define an argument's key as parameter (whithout looking up the built in validators it should be possible with the Equals validator) 00:17 < Rayne> but that is a special case
Views/Templates: Adding a Specific Text to a General Template Edit
Can two routes have the same name? Edit
17:52 < simoncpu> huomenta 17:52 < simoncpu> can two routes have the same name? 17:52 < xboy> but event with both checked, it ain't check the title & content validator 17:52 < sth> simoncpu: one will overwrite the other 17:52 < v-dogg> simoncpu: can as in you don't get any errors, but otherwise can't
How to append in <head></head> Edit
18:12 < xboy> I like to have a method in my templates like addScripts or AddStyles, so i can pass styles & scripts to this method, and then it append the files in the header of the Master template 18:13 < xboy> how can i do such a thing? 18:13 < xboy> by header i mean <head></head> 18:13 < v-dogg> usually stuff like that is passed via AgaviRequest 18:14 < v-dogg> $this->getContext()->getRequest()->appendAttribute('js', 'myfoo.js'); 18:14 < v-dogg> in the view 18:15 < v-dogg> and <?php if($rq->hasAttribute('js') foreach($rq->getAttribute('js'): ?> <script.... 18:15 < v-dogg> in Master.php 18:16 < v-dogg> trunk (soon to be 1.1, I think) has responseattributes for this which is better because request attributes can get tricky if you add caching into the mix