Re: [fw-general] disable magic_quotes_gpc
Mantasgl wrote: > > Hi, > > I found that in my hosting company magic_quotes_gpc is on by default. > > I can't turn them off in my .htaccess file, I get internal sever error. I > used both: > php_flag magic_quotes_gpc Off > php_value magic_quotes_gpc Off > > I solved this problem by adding this code in my bootstrap: > if (get_magic_quotes_gpc()) > { > function stripMagicQuotes(&$value) > { > $value = (is_array($value)) > ? array_map('stripMagicQuotes', $value) > : stripslashes($value); > return $value; > } > stripMagicQuotes($_GET); > stripMagicQuotes($_POST); > stripMagicQuotes($_COOKIE); > } > > Is this a good tecnique? Maybe there is other solutions? > That's pretty much what the php manual has for the situation. A note - your stripMagicQuotes() returns a value, so you need: $_GET = stripMagicQuotes($_GET); and so on. -Mark - Mark Garrett DNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/disable-magic_quotes_gpc-tp24081713p24082229.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Autoloader confusion
lightflowmark wrote: > > Hi, > I feel I'm missing something with Zend_Loader_Autoload, as I can't make it > do what I want! > > I think the relevant points are: > 1) my models are are in a models directory and are not prefixed - > models/SomeTable.php contains class SomeTable extends > Zend_Db_Table_Abstract, etc. > > 2) I'm using a 3rd-party library which has it's own autoloader, and also > does not use prefixes (DOMPDF), living in /library/DOMPDF > > [SNIP] > > Cheers, > Mark > This is a shot in the dark, but have you put /library/DOMPDF into your include path and tried to use the ZF autoloader to load everything? ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . 'library/DOMPDF'); require_once('Zend/Loader/Autoloader.php'); $autoloader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true); I don't think pushAutoLoader would work if DOMPDF isn't namespaced. Just make sure you have your models names different from any DOMPDF class. I tend to create wrapper classes for that very reason. Just a suggestion, I'm pretty new with the 1.8 autoloader myself! -Mark - Mark Garrett DNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Autoloader-confusion-tp24030297p24082158.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] should i user Zend_Validate in a class to validate data
mnaveed wrote: > > Hi, > Should I user Zend_Validator in my class to validate data? I will be using > it in setter methods to verify that the values passed are valid or not. Is > it the right thing to do? > This depends on how you are getting the info to your action. If this data is the result of a Zend_Form, then you can use the form itself to validate the data: public function getMainEditForm() { $mainForm = new Zend_Form(); . } $form = $this->getMainEditForm(); if (!$form->isValid($_POST)) { // failed validation } http://framework.zend.com/manual/en/zend.form.forms.html#zend.form.forms.validation Manual entry on form Validation You will need to http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.validators add validators to the form elements. I like to use addValidator() in a fluent interface: $mainForm->createElement('TextBox',"contactEmail",array("label" => 'Email Address', "trim"=>true, 'lowercase'=>true,))->setRequired(false)->addValidator("EmailAddress"); HTH, Mark - Mark Garrett DNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/should-i-user-Zend_Validate-in-a-class-to-validate-data-tp24070773p24081164.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Dijit elements and xhrPost
mapes911 wrote: > > HI, > > Question about not reusing a variable name. You're talking about the name > you give the actual dijit element right? Like for example. > > $this->addElement('ValidationTextBox', 'name', array( > 'validators' => array( > array('StringLength', false, array(0, 255)), > ), > 'label' => 'Name:', > 'required' => true, > 'invalidMessage' => 'ERROR MESSAGE HERE', > 'trim' => true, > )); > Actually, in this case I'm creating the elements in the view script. I have several line items to loop through, so I'm creating a form for each. I guess I could create that in the controller file, but I'm not sure how, and this works too. When I'm talking about adding microtime, I'm talking about when there are multiple (identical) forms on the same page and you create the elements like the following: validationTextBox("lineItemQuantity-".$item["lineItemID"].microtime(true), $item["lineItemQuantity"], array( "required"=>"true", 'regExp'=>'[\d]+','style'=>'width: 50px'))?> That may seem to be obvious in hindsight, but I hadn't realized at the time that this style of dijit creation used the "name" attribute for the "id" attribute too. Since you can't have more than one element with the same id in an XHTML doc, this workaround is needed. I scrape off the microtime in the action the data is posted to. In my xhr action, I set the following when I return the new list of line items: $this->_helper->layout->disableLayout(); Zend_Dojo::enableView($this->view); Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); $this->render('editLineItemsPartial'); HTH, --Mark G. - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Dijit-elements-and-xhrPost-tp20276334p22331420.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Dojo_Form - XHR-Post
mapes911 wrote: > > Hi Matthew, > > If you use this method to attach the javascript routine to the submit > button, then in the foobar routine setup an xhrPost to process the form, > should I still have an action and a method setup in my controller when I > instantiate my form? > > Any help would be appreciated. > > Thanks > I'm doing this exact thing, so let me see if giving an example would help your understanding. Sorry if this is a bit long folks. I've used ellipses to try and make it shorter. Controller File: (clients/controllers/IndexController.php) public function getContactEditForm($clientContactID = null){ ... $contactForm = new Zend_Dojo_Form(); ... $elements[] = $contactForm->createElement('button', 'ajaxActionContact', array( 'onclick' => "ajaxAdd('clientContacts','clientContactForm')", 'label' => 'Add Client Contact')); $contactForm->addElements($elements); return $contactForm; } public function editAction(){ ... [I've already set $this->view->info["contacts"]] $contactForm = $this->getContactEditForm(); $this->view->contactForm = $contactForm; } public function editajaxAction(){ ... [Do what logic is needed (add in this case), pull back new list of contacts] ... $this->view->contactList = $contactList; $this->_helper->layout->disableLayout(); $this->render('editClientContactPartial'); break; } View File:(clients/views/scripts/index/edit.phtml) dojo()->javascriptCaptureStart() ?> var ajaxAdd = function(divID, formName) { var kw = { url: "", handleAs:"text", load: function(response){ dojo.byId(divID).innerHTML = response; }, error: function(data){ alert("An error occurred: " + data); }, timeout: 2000, form: formName }; dojo.xhrPost(kw); //Servlet get argement with doPost } dojo()->javascriptCaptureEnd() ?> ... partial('index/edit-client-contact-partial.phtml', array("contactList" =>$this->info["contacts"]))?> So what we have here is a controller file with several actions. Included are ones to create the Dojo form (getContactEditForm), the edit action that fires when we first get to the page (editAction), and what I want to happen when the form is submitted via the XHR call (editajaxAction). When the page is first called, the form is created with a button that has an onclick action pointing to a simple js function that captures the form info and posts it to the editajaxAction function. The response is then loaded into the clientContacts div. Of note here, if you are using layouts and are updating a partial (like I am doing), you will need to disable layout rending in your ajax action, or the entire layout will render inside the partial! ($this->_helper->layout->disableLayout();) -Mark G. - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Zend_Dojo_Form---XHR-Post-tp19360770p22320137.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Dijit elements and xhrPost
Thank you. That works. One thing that others should be aware of when returning a container with dijit elements is the fact that dojo does NOT like to reuse the IDs. i.e., if your variable name is lineItemSize, you will need to set the ID/name of the element to something that is unique every time you return that container - including the first time the page is rendered. In my inline -editing example, I am adding the microtime to the end of every element name. This guarantees that when they edit that line and click the edit button to set off the xhrPost, the returned form has IDs that are different from the first time the page rendered. If you don't do this, you will get something like following error: An error occurred: Error: Tried to register widget with id==lineItemSize but that id is already registered -Mark Matthew Weier O'Phinney-3 wrote: > > Second, for XHR requests, I always have my view use declarative Dojo > syntax: > > Zend_Dojo_View_Helper_Dojo::setUseDeclarative(); > > This ensures that you can run the dojo parser over the returned markup. > Returning and executing Javascript from XHR is often considered a > security issue, and can additionally be difficult to get to work > correctly. > > This leads to my third point: you'll need to run the dojo parser again > *after* you've inserted the new HTML into your DOM. This is done with > the following call: > > dojo.parser.parse(); > > You can actually run the parser on a containing node as well. So, if > you did something like the following with the response payload: > > var formContainer = dojo.byId('form-container'); > formContainer.innerHTML = data; > > then you'd call this immediately following: > > dojo.parser.parse(formContainer); > > Hope that helps answer your question! > > -- > Matthew Weier O'Phinney > Software Architect | [EMAIL PROTECTED] > Zend Framework | http://framework.zend.com/ > - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Dijit-elements-and-xhrPost-tp20276334p20296178.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Dijit elements and xhrPost
I am attempting to do an "in-line editing" solution that has dijit elements declared in a form that then have an xhrPost action that updates the data and returns the form again. The problem that I'm encountering is that when the div is returned, the form elements are no longer "Dojo-ized" - they are plain html form elements. When I first hit the page, the elements are created and display properly, it's just after the xhrPost that I am having issues. The end of my xhrPost action is like this: $this->view->lineItems = $lineItems->toArray(); $this->view->info = $invoice->toArray(); $this->_helper->layout->disableLayout(); $this->view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); Zend_Dojo::enableView($this->view); $this->render('editLineItemsPartial'); I've tried various variations, and I can't seem to get the partial to render correctly after it hits this action. I've also tried to activate dojo in the partial, but that doesn't seem to work either. Any suggestions? -Mark - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Dijit-elements-and-xhrPost-tp20276334p20276334.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Minor annoyance - Using an object member with another object member
I have a sneaking suspicion that I'm missing an obvious fix here. I'm trying to construct something like this: $GLOBALS["format"]->contactType->$contact->contactType Where $contact is a Zend_Db_Row object and $GLOBALS["format"] is a Zend_Config object. Now I KNOW that the above construction will never work because $contact is an object and the interpreter is looking for a string. What I'm wondering is if there is a language construction or simple function to get $contact->contactType to evaluate first? Creating little toss-off vars to take care of this is getting annoying :-) -Mark - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Minor-annoyance---Using-an-object-member-with-another-object-member-tp20248055p20248055.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Dojo forms and XHTML
Thanks. I guess I was declaring the doctype too late in the stack (in the layout.phtml file). The view is already Dojo enabled as I used Zend_Dojo_Form to create the form. As all my layouts are the same doctype, I just had to add this in the bootstrap: $layout = Zend_Layout::startMvc(); $layout->getView()->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper')->doctype('XHTML1_TRANSITIONAL'); Fluent interfaces are great :-) -Mark gerardroche wrote: > > > sorry, > > $layout = Zend_Layout::startMvc(); > $view = $layout->getView(); > $view->doctype('XHTML1_STRICT'); //doctype > Zend_Dojo::enableView($view); //You'll need to load the Zend_Dojo class. > - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Dojo-forms-and-XHTML-tp19922428p19924950.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Dojo forms and XHTML
I'm missing something simple here, but can't find it. Basically, my dojo elements are getting rendered as html4, not xhtml. The form performs correctly, it's just a validation issue. The manual indicates that it should output xhtml as the default, so I'm a bit stumped. --- Snip from Bootstrap: //Set View info Zend_Loader::loadClass('Zend_Layout'); $layout = Zend_Layout::startMvc(); $layout->getView()->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper'); Snip from layout.phtml: docType('XHTML1_TRANSITIONAL')."\n"; ?> http://www.w3.org/1999/xhtml"; xml:lang="en"> headTitle()."\n" ?> headMeta()."\n" ?> headLink()."\n" ?> headScript()."\n" ?> dojo()->isEnabled()){ $this->dojo()->setLocalPath(BASEURL.'js/dojo/dojo.js') ->addStyleSheetModule('dijit.themes.tundra'); echo $this->dojo(); } ?> Simple function to create form: public function getMainEditForm($clientID = null){ Zend_Loader::loadClass('Zend_Dojo_Form'); //Create all the forms needed for this page $mainForm = new Zend_Dojo_Form(); //Do we want an edit form, or an add form? if($clientID){ $mainForm->setAttribs(array('name' => 'clientEditForm', 'action' => BASEURL."clients/index/edit/clientID/".$clientID)); $elements[] = $mainForm->createElement('SubmitButton', 'submit',array('label'=>"Submit Changes"))->setOrder(99); } else { $mainForm->setAttribs(array('name' => 'clientAddForm', 'action' => BASEURL."clients/index/add/")); $elements[] = $mainForm->createElement('SubmitButton', 'submit',array('label'=>"Add Client"))->setOrder(99); } $mainForm->setMethod('POST'); $elements[] = $mainForm->createElement('TextBox', 'clientCompany', array('label'=>"Name", 'trim'=>true))->setRequired(true); $elements[] = $mainForm->createElement('RadioButton', 'clientStatus', array( 'label'=>"Client Status", 'multiOptions' => $GLOBALS["format"]->clientStatus->toArray() )); $elements[] = $mainForm->createElement('TextBox', 'clientStatusReason', array('label'=>"Status Reasion", 'trim'=>true))->setRequired(false); $elements[] = $mainForm->createElement('RadioButton', 'applyTax', array( 'label'=>"Apply Tax to Client?", 'multiOptions' => $GLOBALS["format"]->yesNo->toArray() )); $elements[] = $mainForm->createElement('TextBox', 'taxIDNumber', array('label'=>"Tax Number", 'trim'=>true))->setRequired(false); $mainForm->addElements($elements); return $mainForm; } Output: Name [SNIP] - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Dojo-forms-and-XHTML-tp19922428p19922428.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] DojoComboBox and large data set.
Well, someone might have a better way, but I would take this a s a two step process. FIrst, have a three-character wide filed (maxlength=3) thath you have an onchange JS trigger associated with. When the three are entered, set of an xhrGet request to pull back the FiltertingSelect or ComboBox field with it's associated list of possible responses. JM2C -Mark Paweł Chuchmała wrote: > > Hi. > > How is the best method to use DojoComboBox with large data set? For > example i want to do suggest for users. > I have about 10 records. I want for example query server with 3 > first letters filled in combobox. > How can i do that? It is possible to use DojoData with this method? > > regards, > > -- > Paweł Chuchmała > pawel.chuchmala at gmail dot com > > - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/DojoComboBox-and-large-data-set.-tp19625601p19628026.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Layout
I have something similar to that, but I'm not using the layout paths - I'm just dropping the layout into the views/scripts/ dir for each module, and for the main site (login screen in my case). You might just have to give it a try to see what your results are. You can set layouts in the controllers with: $this->_helper->layout->setLayout('foobaz'); Looking at the names for your layouts, I hope you aren't confusing layouts with views. A view for your browse action and one for your edit action can use the same layout if you want. In a layout file you use $this->layout()->content to display the view for your controller action. So if you have an editAction() in you controller, $this->layout()->content will display edit.phtml where you place it in the layout. You use the views to include headers, navs, and footers mostly. Sorry if I'm off-base and you know this already! -Mark dele454 wrote: > > Hi Mark, > > Thanks for the response. So what you are saying is that as long as i keep > the startMvc() empty and specify my module paths, ZF will always look > for the layout.phtml files within the specified module directories? > > In my scenario, i just have one module:admin module - where the cms apps > reside. But the main site just resides on the app root folder. For better > understanding here is my folder structure: > > - webapp > --> public_html > ---> images > ---> bla blah > > --->controllers > --->views >--->layouts > --->layout.phtml > --->layout-browse.phtml > -->modules >--->admin >--->controllers >--->views >--->layouts > --->layout.phtml > --->layout-edit-mode.phtml > > Like i said before i simply want to keep the layout of my CMS separate > from that of the main site. The main site isnt a module. So what would my > startMvc() look like then with my folder structure in mind. > > In my bootstrap i have something like this at the moment: > > Zend_Layout::startMvc(array( > 'layoutPath' => $config->paths->data > . '/module/admin/views/layouts'); > > I need to include that path layout path for the main site. > > Thanks > - Mark Garrett DailyDNA Arkadelphia, AR (Telecommuting to: Rogue River, OR) -- View this message in context: http://www.nabble.com/Zend_Layout-tp19608818p19627567.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] ZF 1.6 + Dojo xhrPost
Jason Webster wrote: > > You know what? Ignore that.. I'm severely under slept and over, erm, > drank. > > You'll want to call this: > $this->_helper->layout->disableLayout(); > Perfect. Thank you! I knew it was a one-liner. I've reached the top of the pass and the valleys are arrayed in emerald splendor below me... Umm, perhaps I should be off to bed too. -Mark -- View this message in context: http://www.nabble.com/ZF-1.6-%2B-Dojo-xhrPost-tp19620432p19620725.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Layout
dele454 wrote: > > I just want to know if one can specify more than one layout path in the > startMvc function? having something like this: > > Zend_Layout::startMvc(array( > 'layoutPath1' => $config->paths->data > . '/module1/admin/views/layouts') > 'layoutPath2' => > $config2->paths->data . '/module2/admin/views/layouts') > ); > > Am asking because since layout.phtml is the default layout to be used > except if specified otherwise. What if i have the default rendering > layout.phtml in both folders how then can i let the Front Controller know > which layout i am referring to in what folder? > Not sure if this is what you are asking, but if you have modules set up with something like: $front->addModuleDirectory('application/modules'); where your module1/, module2/, etc directories are in the modules/ dir, then ZF uses the layout.phtml file within the views/scripts/ dir for each module. I.e. module1/views/scripts/layout.phtml will be used for the controllers within module1; module2/views/scripts/layout.phtml will be used for the controllers within module2; etc. Looks like you're using different paths, but if you have that worked out, it shouldn't be a problem. I'm doing that myself right now. I am passing no params to Zend_Layout::startMvc(). -Mark -- View this message in context: http://www.nabble.com/Zend_Layout-tp19608818p19620597.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] ZF 1.6 + Dojo xhrPost
Hi there to all first post, so go easy on the newbie :-) I've done PHP for several years, and a bit of AJAX, though a while ago (cpaint anyone?). New to ZF and Dojo. Trying to get a simple xhrPost to work right and having issues - not sure if it's ZF or Dojo. When my ajax cal lis returned - it adds in the entire layout to the response div instead of just the partial. Is there a way to just render the partial and have that inserted? I think this is something I need to do in the controller so that the entire layout is not rendered - just the view. Perhaps something with named segments? MVC Application Controller: public function editajaxAction(){ switch($this->_getParam('formType')){ case "addPlantUse": //Insert use data for the plant into the rel table Zend_Loader::loadClass('PlantsPlantUses'); $useObject = new PlantsPlantUses(); $data = array( "plantID" => $this->_getParam('plantID'), "useAbbreviation" => $this->_getParam('plantUse')); $useObject->insert($data); //Get new list of uses for this plant $plant = new Plants(); $plantRowSet = $plant->find($this->_getParam('plantID')); $plantRow = $plantRowSet->current(); $plantUses = $plantRow->findManyToManyRowset('PlantUses', 'PlantsPlantUses'); //Add data to the view $this->view->useList = $plantUses->toArray(); $this->render('editPlantUsePartial'); break; } } layout.phtml [SNIP] dojo()->isEnabled()){ $this->dojo()->setLocalPath(BASEURL.'js/dojo/dojo.js') ->addStyleSheetModule('dijit.themes.tundra'); echo $this->dojo(); } ?> partial('header.phtml') ?> layout()->content ?> partial('footer.phtml') ?> edit.phtml dojo()->javascriptCaptureStart() ?> var ajaxAdd = function(divID, formName) { var kw = { url: "", handleAs:"text", load: function(response){ dojo.byId(divID).innerHTML = response; }, error: function(data){ alert("An error occurred: " + data); }, timeout: 2000, form: formName }; dojo.xhrPost(kw); //Servlet get argement with doPost } dojo()->javascriptCaptureEnd() ?> (I'm being generic so I can use this for multiple forms on the page) //The partial is displayed properly on load, but whole layout displayed after AJAX call partial('index/edit-plant-use-partial.phtml', array("useList" =>$this->info["uses"]))?> edit-plant-use-partial.phtml useList as $use) { echo " \"".BASEURL."plants/use/detail/useAbbreviation/".$use["useAbbreviation"]."\" ".$use["useAbbreviation"]." - ".$use["useName"]." "; } ?> -Mark G. -- View this message in context: http://www.nabble.com/ZF-1.6-%2B-Dojo-xhrPost-tp19620432p19620432.html Sent from the Zend Framework mailing list archive at Nabble.com.