Jump to content

ajlisowski

Members
  • Posts

    114
  • Joined

  • Last visited

    Never

Everything posted by ajlisowski

  1. I figure view_helpers would be the best way. I am having a bit of trouble with them using modules. For example, I have a projectplan module, and inside it, one of my views is trying to use a img view helper. I have a class in applications/views/helpers/img.php that is named Zend_View_Helper_Img. When I call it in my view I simply call $this->img() (the view_helper_img class has a function img()) I get the following error Exception information: Message: Plugin by name 'Img' was not found in the registry; used paths: Projectplan_View_Helper_: /var/www/html/appldev/luna/application/modules/projectplan/views/helpers/ Zend_View_Helper_: Zend/View/Helper/ I tried putting the helper in the applications/modules/projectplan/views/helpers directory but that did not work either. I would like it to be in the default module so all modules can use it, but I am unsure of what I am doing wrong. Any ideas?
  2. So should I create a view helper for each object? Like a project_view_helper, a task_view_helper, milestone_view_helper, etc? I already plan on having controllers for most of those things, so would my idea of giving those controllers an display_as_child action and then using action_view_helpers to display them from the parent controllers work well within the MVC framework? Or should I make view_helpers for each? I feel like im close to finally clicking with MVC, which would be nice...
  3. So, I am still struggling to really nail down good design patterns for larger projects. Right now I am trying to convert a project management system I wrote to MVC using ZF. The question is this: I have a project object which can contain many tasks and milestone objects. All of these can contain discussions, documents, members etc. The way I would normally write the code (and did in the original version) is to have each of these elements be their own class. And then have a project->draw function which would cycle through and draw the various parts of the projects. Most other elements would have both a draw() function and a draw_as_child() function. In ZF I have made a project controller with an index action which would handle the viewing of a specific project. I have made a project_obj model as well as a project_db model. project_db handles all the database specific stuff for the project. Project_obj basically handles everything else and acts as an intermediate between the controller and project_db. So in my controller I would simply call project_obj->load(id) and it would load all the data in, and then I could do stuff like project_obj->get_members() etc. So far, I feel confident Im doing things well, but my issue is when it comes to drawing. To me it makes the most sense to do what I did in the old version which is to have draw() and draw_as_child() functions for my various models, but it seems like this would violate MVC as I should likely do all html formatting and what not within the view. However it seems redundent to me not to have a function which simply draws a task as a child since both Projects and Milestons will be using this. On a similar note, discussions, documents, members etc will all be displayed the same in various different areas. What is the best way for me to handle this in MVC? Would I create a task controller with a view_as_child action, and then simply use an action view helper to display the child where needed? Is that how MVC would handle such situations? And do the same with members, documents, discussions, milestones etc?
  4. Hey all, I am trying to get my module to properly auto-load my resources. Right now I have two modules- login and projectplan. login uses a form that is located in: applications/modules/login/forms/Login.php And the class is login_Form_Login. This gets loaded fine. Projectplan has a model and it is located in: applications/modules/projectplan/models/DbTable/project.php. And its class name is: projectplan_Model_DbTable_project It is giving the following error: Class 'projectplan_Model_DbTable_project' not found Any idea why its not finding this model? In my config I have: resources.modules[] = "" Which should initiate the autoloader for each of my modules.
  5. Yeah...I couldnt edit the original post anymore, so I had to edit the reply. Didnt expect such quick responses
  6. Oops, sorry, I copied my post after typing it out and left a bit out... Hi all, I am trying to port a class I made to zend framework and use zend_db_table. The class basically allowed to quickly generate a table html object with correct data and pagination based on mysql information by passing tables, rows and filters to it. add_table($prefix, $table, $joined='') **joined would be the ON portion of the join, so if table a.id left joined table b.id the joined input would be 'a.`id`=b.`id` public function add_column($prefix, $column, $label) public function add_filter($item1, $relationship, $item2, $conjunction=" AND ") The class would then go through and create a string representing a select statement based on the data. So first it would loop through the columns and add the selected columns to the string. It would then loop through the table array to add froms and joins. it would then loop through the filter array to create the filter statements, WHERE, AND, OR etc. Then depending on the page set and the total values per page it would create a limit statement at the end of the query. It would run the query and then create a table based on the resulting data. How would I go about creating and executing the query in zend_db_table? Im not even sure where to begin, so a general idea would help. Would I need to extend zend_db_table_abstract for each table in my database first? Or is it possible for me to dynamically create a new zend_db_table object then create the query through ->from, ->where, ->join etc? Any help would be extremely nice, as if I could get this class converted it would save me a lot of time and I would learn a lot about zend_db_table in the process.
  7. Hi all, I am trying to port a class I made to zend framework and use zend_db_table. The class basically allowed to quickly generate a table html object with correct data and pagination based on mysql information by passing tables, rows and filters to it. add_table($prefix, $table, $joined='') **joined would be the ON portion of the join, so if table a.id left joined table b.id the joined input would be 'a.`id`=b.`id` public function add_column($prefix, $column, $label) public function add_filter($item1, $relationship, $item2, $conjunction=" AND ") The class would then go through and create a string representing a select statement based on the data. So first it would loop through the columns and add the selected columns to the string.
  8. My problem with onchange is that it requires...a change of value. So the "current" selection is no longer an option for the trigger, which sort of sucks. I do not know of a good alternative or solution.
  9. I dont understand...why not have the link open the popup? Why open a new page which opens a popup?
  10. Hey, thanks! I was having the view object have a data array and throwing needed objects in there. using __set() will take out that middleman. I constantly see your name answering my questions, I'll buy you a coke some day.
  11. This is more a general MVC question in regards to how ZF actually works. How does the view object render the phtml files? Like, lets say one was building their own framework. You have a controller object which has a view object as a member. That view object would call index.phtml which would be able to access $this-> to have access to the view object. But how does the code in that phtml file get rendered? How does the view object call that file and manage to output its contents. Does the object simply include the file? How can the controller pass variables to the view class for use? Like, if I were to say $this->view->obj=$this->obj, and my view class doesnt have a obj object, I will get the error: Undefined property: basic_view::$obj How does ZF do the things it does?
  12. Hey all, I have a quick question about decorators. I basically want to add a class to the decorator but it doesnt appear to be working: $input_dec=array( 'ViewHelper', 'Description', 'Errors', array(array('data'=>'HtmlTag'), array('tag' => 'div'), array('class'=>'blue_box') ); The div appears but it does not have a class. How do I get it to have a class? Also, my form in general seems a bit off due to decorators... public function init() { $input_dec=array( 'ViewHelper', 'Description', 'Errors', array(array('data'=>'HtmlTag'), array('tag' => 'div'), array('class'=>'blue_box'), array('id', 'boom_bap')), ); $texarea_dec=array( 'ViewHelper', 'Description', 'Errors', ); ini_set('display_errors',1);error_reporting(E_ALL); $this->setName('rsvp_form'); $name = new Zend_Form_Element_Text('guest_name'); $name->setAttrib('class', 'rsvp_input click_clear') ->setValue('Name') ->setDecorators($input_dec); $guests = new Zend_Form_Element_Text('number_of_guests'); $guests->setAttrib('class', 'rsvp_input click_clear') ->setValue('# of Guests (including you)') ->setDecorators($input_dec); $accept=new Zend_Form_Element_Checkbox('accept'); $options = array( 'checkedValue' => '1', 'uncheckedValue' => '0', ); $accept->setOptions($options) ->setLabel('Delightfully Accepts') ->setAttrib('onclick', 'rsvp_form.attending();'); $decline=new Zend_Form_Element_Checkbox('decline'); $options = array( 'checkedValue' => '1', 'uncheckedValue' => '0', ); $decline->setOptions($options) ->setLabel('Regretfully Declines') ->setAttrib('onclick', 'rsvp_form.attending();'); $message = new Zend_Form_Element_Textarea('message'); $message->setValue('Regardless of your attendence, feel free to wish us well! Amy will need it!') ->setDecorators($texarea_dec); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitrsvp'); $this->addElements(array($name,$guests,$accept,$decline,$message,$submit)); } Whats happening there is the textarea element is somehow being dispaly in the dd id="decline_element" in IE7. I have no idea why. It works fine in IE8 and FF. When I view source, the html itself seems good, so I dont know why the text area is somehow within the DD <form id="rsvp_form" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form"> <div> <input type="text" name="guest_name" id="guest_name" value="Name" class="rsvp_input click_clear"></div> <div> <input type="text" name="number_of_guests" id="number_of_guests" value="# of Guests (including you)" class="rsvp_input click_clear"></div> <dt id="accept-label"><label for="accept" class="optional">Delightfully Accepts</label></dt> <dd id="accept-element"> <input type="hidden" name="accept" value="0"><input type="checkbox" name="accept" id="accept" value="1" onclick="rsvp_form.attending();"></dd> <dt id="decline-label"><label for="decline" class="optional">Regretfully Declines</label></dt> <dd id="decline-element"> <input type="hidden" name="decline" value="0"><input type="checkbox" name="decline" id="decline" value="1" onclick="rsvp_form.attending();"></dd> <div> <textarea name="message" id="message" rows="24" cols="80">Regardless of your attendence, feel free to wish us well! Amy will need it!</textarea></div> <dt id="submit-label"> </dt><dd id="submit-element"> <input type="submit" name="submit" id="submitrsvp" value="Add"></dd></dl></form> Any ideas as to what is causing it? Amy loves Tony in IE 7 Also, how would I go about getting forms into my header? In my layout.phtml I have a header and footer and content sections. I want to be able to draw a form in the header. How would I go about doing this? How does zend framework tackle such a basic issue? Im using this project to learn the concepts behind MVC and zend framework, so sorry if I suck. Would I create a header and footer controller, and then include them somehow by the layout.phtml file?
  13. I didnt think to use a join simply because I wasnt actually getting any data from vendor_to_product, I just wanted to make sure it existed. SELECT DISTINCT vtp.`vendor_number`,v.`vendor_number` AS `value`,CONCAT_WS(' - ', v.`manufacturer`, v.`division_dist`) AS `label` FROM `lunapr_c1vendor` AS `v`, `lunapr_vendor_to_product` AS `vtp` WHERE vtp.`vendor_number`=v.`vendor_number` ORDER BY v.`manufacturer` That query does the job well. Thanks for the advice!
  14. SELECT `name`, IF(`ParentID`=0,`ID`,`ParentID`) AS `SortBy` ORDER BY `SortBy`, `ParentID` Parent was showing up twice because you joined. We didnt need to join. We simply want to sort by the parent ID, or the ID if the parent itself. This will likely not work as smoothly if you have multiple layers Grandparent->Parent->Child but it should work for a single layer, Parent->Child.
  15. SELECT IF((`price`>`discount_price` AND `discount_price`>0),`discount_price`,`price`) AS `actual_price` FROM `prices`;
  16. I decided to grab the subquery results first, put then in a string of (1,2,3,4,5) and just plug that variable in for the subquery so mysql didnt have to run that query on every vendor. Made things go a lot quicker. That being said, is there a way to do it all at once and not have it run like poop?
  17. Hey all, I am having issues with a rather simple query. Basically I want to select all vendors that have a product. I have a vendor table, a product table and a vendor to product table (since products can be part of multiple vendors depending on region, and obviously vendors can have multiple products) It takes about 6 seconds, which is way too long. I have a few hundred vendors and like 25 thousannd vendor-to-product entries. This is the query SELECT `vendor_number` AS `value`,CONCAT_WS(' - ', `manufacturer`, `division_dist`) AS `label` FROM `lunapr_c1vendor` WHERE `vendor_number` IN (SELECT `vendor_number` FROM `lunapr_vendor_to_product`) ORDER BY `manufacturer` This is the result from explain. 1 PRIMARY lunapr_c1vendor ALL NULL NULL NULL NULL 1258 Using where; Using filesort 2 DEPENDENT SUBQUERY lunapr_vendor_to_product index vendor_to_product,vendor_number,vendor_to_product_... vendor_number 7 NULL 23360 Using where; Using index Any idea what might be going wrong here?
  18. I think part of my issue is I am trying to turn a very much non- MVC design that I created over a year ago into an MVC design, and its confusing me, and though I have cleaned up the design and make it more and more OO friendly over time, I am still no where near where a true OO design should be. I should probably learn the basics of MVC before I try to shoe-horn stuff into what my understanding of it is. Everything I read generalizes the concepts a bit too much and I end up with a half understanding. Im not even sure what role the model even plays in the whole thing. Like, lets have a use case where a user deletes a photo from a photo gallery. First the user browses the photos determining which one to delete. In this case, the gallery controller would have a browse case, which it contacts the database and gets the photos for the current page and category or what not. It would then call the browse view which would display the photos however. What "logic" should be done by the control view? Should it loop through the array of images, parsing the data and displaying it as needed? So now the user sees all the photos and they click the delete button on one. That gallery controller would have a function for the delete case. It would then access the database and delete the row. It would then call the gallery delete view which would show a message about the successful deletion. Or perhaps it would call the browse view again and show the message there with the newly updated gallery?? Thats the type of stuff I dont get. Also, I would assume I would want to have a photo object which itself handles the deletion, updating, adding of images to a photo. And perhaps even the display of said photo. How does this fit into the MVC design? How does ajax fit in? The controller gets an ajax call and then passes the data back to the javascript in JSON for it to manipulate the dom? Or could you have the controller get an ajax call, then contact the view, serialize the html and pass that back to javascript?
  19. I appreciate the help, and everything you said is helping me learn a lot about using frameworks and MVC in php. However, I think I accidently made things confusing by using words I shouldnt have. In fact, I probably have a much broader question about my entire design. WARNING: This is going to be long and possibly show how bad of a programmer I am! Basically, at this point, I need to know if my system is absolutely fubar or if I can continue with it as such. I have developed a number of systems for my company in PHP. Pretty much as I develop, I learn more and more, so each system has probably gotten better as time has gone on. I sort of created my own framework which I have expanded upon as I went on. At the time, I had no idea I was making a framework, I didnt even know what one was really. I simply developed a nice way for individual components of a system to be called and organized. Basically it works like this: There is a public/index.php file which loads a config file and an application top and bottom file. It then calls the indexController.php which looks for a model in the GET and then fetches the correct controller/module/modulename.php file. These php files call whatever classes they need. And then do any data handling and then call a views/module/modulename.phtml file to do any sort of displaying. These files themselves are not objects, thus they do not extend any base controller or view class. This is probably very bad and I should likely rework that. Now, I utilize a lot of ajax in my systems and as time has grown on I have developed a way to keep things organized for myself. Basically for any object that would be maniuplated by the user I have a number of components. obj_handler.js (a js object which handles all the javascript) obj.php and obj_ajax.php. obj.php handles all the data handling and what not for the object. obj_ajax.php pretty much acts as a mediator between the js and the php object, tossing data between the two. From your post I believe I should likely change this obj_ajax to a more broad obj_handler.php and check for whether or not its a httprequest or not, and return the data as needed. The thing I do absolutely horrendous right now is I do not use json or xml and I simply serialize my data as needed and code the returning js functions as needed. Most my calls follow the same logic, a success or error code, followed by a number of variables seperated by **. I realizing JSON or XML would likely be more accepted. But so far this works fine for me... What my previous question was is as follows: Each system Ive made so far has followed the same approach as described above. Now I am combining each system into one intranet. I have a portal system which allows an admin to add or remove these systems, and provide security groups access to them. This will change the landing page and navigation bar. My general OO question was whether i should create an object to handle displaying these systems (i said modules before) on the landing page, and in the nav bar etc. Or if I should just grab the data from the object and display the modules manually on the phtml page. Does this design seem decent? Or am I coding in a terrible, messy and ineffecient way? Ive begun looking into zend framework, but id likely have to recode a lot of my systems to do so. Which, would take a lot of time to be honest, and I doubt my company would want me backtracking so much and spending time "fixing" stuff they dont see as broken.
  20. Hi everyone, I have a quick question about how to design part of my system. I have a intranet system I am developing. I have developed a number of systems already and now we are making a portal to tie them all together under one interface. I have a module class which handles all activity regarding an individual module. Adding, removing, editing, adding/removing security groups. Now, basically, I want to develop a class that handles actions not related to individual modules, but all modules. So, basically displaying modules to the portal page, determining what modules it should display based on security group etc. What functionality should this class have and what should it be called? Should the class that grabs the modules from the DB and the class that displays them be the same? or should I seperate data handling from view handling? I also have a module_ajax class which handles any and all requests that may be made via ajax. It usually simply calls the module class to do any execution. Perhaps I should remove the ajax class and instead have a controller or handler class which does a combination of the ajax calls and the newer calls I am going to implement? As an aside: I always get confused in regards to MVC and objects such as this. Do I need to worry about MVC when it comes to individual objects such as this, or is that more something I should worry about when rendering pages specifically?
  21. Look into tinyMCE and the paste from word plugin for it. Otherwise I think youd have to do some fancy reg-ex stuff to take out the tags and code you dont want and leave the ones you do. I am super weak in reg-ex so, I cant help you specifically.
  22. Hey all, the code in action can be found here: http://www.ghostjesus.com/multi-select/index.html The odd part is, is in this demo example I can not get the same error to occur. The live version is behind an intranet and what not, so...I cant really show you that one. Basically whats happening is if you were to clikc off of "breakfast" in the top menu and select "lunch" then click back on "pancakes" it would not have the scroll bar. Then if you clicked back on lunch then breakfast it would return. Only in IE 7... I can not reproduce with the demo version I set up, so...it must be something else in my code. Still, any ideas would be wonderful.
  23. Hey all, I recently wrote a custom select menu using jquery. Basically it acts just like a normal select except you can have multiple columns which act as parents. So for example, if you were having someone select a state to dynamically populate another select of city, this dropdown would have state as a second column to the left of city and run ajax calls to populate the children. It also allows you to select multiple entries from the child, so you can technically grab Chicago, IL; Rockford, IL; Houston, Texas and Miami,Florida all at once. Its pretty cool, im pretty proud of it. The issue is... if the dropdown menu is bigger then a given height (customizable through the options) the div uses overflow to create a scroll to select the hidden results. However in IE 7 this scroll bar only appears half the time. It doesnt make any sense. If I inspect the element, I can see that all the data is there and that the overflow data is simply hidden. SO basically the overflow value of the div is no longer set to auto. If I click away then click back to re-display the selection the scroll bar appears. If I click away and return again, it will be gone. This continues without fail, every other time it seems to lose the overflow property. Any ideas?
  24. I dont believe you need to actually write to the session for it to lock up. I could be wrong there though. I think that when you open a session it grabs write permission until you either close the session or let go of write permission. Thus, even if you arent writing, the ajax call could nab the permission, never technically let it go and then when your next page tries to get it as well, it locks up. Your issue may very well be something else entirely. I just beat my head against a wall a few months ago with the same sympthoms as your problem and thats what it turned out to be.
  25. I think what I should do is UNION the two queries and then do my sorting and LIMITs on the unioned result set. so, (SELECT id from A) UNION (SELECT id from B) ORDER BY id LIMIT 0, though I cant imagine this is the most effecient way.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.