Jump to content

stijn0713

Members
  • Posts

    231
  • Joined

  • Last visited

Everything posted by stijn0713

  1. <a> inside <li> makes my list markers float above the <h4>item and <p> that are inside the <li>. Does anybody know why? Update: only in chrome it works (as in the markers are on the correct height)
  2. i want to post a json literal with jquery ajax method. The $_POST array on the server side is empty, thought i see with firebug that the json literal has been send. If i switch to GET method, i do receive the literal but it's not clean formatted. client-side $.ajax({ type: "GET", url: 'ajax/saveInfoAuthenticatedUser.php', data: pic_data, dataType: 'json', success: function (data) { alert(data); } }); server-side $data = $_POST['pic_data']; print_r($_POST); What is the problem? I've read alot of posts on stackexchange where people had the same problem, but nowhere i could find the reason why the post variable is empty. Extra question: What is the clean way to send a json format? should i use stringify(), json_encode or something?
  3. i think you can't post to friends timelines, because you need an access token of the friend, which you cannot obtain via the authenticated person, however i'm not 100% sure
  4. I find contradictory answers when googling. could someone confirm or reject if it is possible to let an authenticated person post to his friend's wall/ timeline without a dialog? If someone know it it's possible, please tell me:
  5. i guess you are right, but i don't understand the solution. I opened the pdf file with notepad, and the problem is that all the html content is included before the actual %PDF-1.3 line. I guess a solution would be to put the intended content with the css in an outputbuffer and write in to a file, and then in that file i make pdf? (is this similiar to what you meant DavidAM?)
  6. Anybody experience with dompdf? i follow the basics to make a pdf from html using $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $dompdf->stream("factuur.pdf"); It seems i can't open a pdf created with dompdf if i echo something or if there is html besides the html contained by $html. anybody know why?
  7. i want to determine for every function or class method in all the core codeigniter functions, libraries and helpers, how many resources (http://php.net/manual/en/language.types.resource.php) these functions or class methods have. Any idea what is a simple way to do it? So far, i've - include all the desired files (core, libraries, helpers) - list down all the user defined classes and their methods and user-defined functions
  8. Thanks ignace, solved!
  9. yes, with 'i think' i wanted to express that i have not full understanding of the navigation and therefore tried to exit or die() at a place maybe irrelevant. So i cannot say i die or exit() is not the way to go, however, for my understanding it's not the way how to get out of it. i tried to place it there: lass User extends CI_Controller { public function __construct() { parent::__construct(); } public function login(){ $this->load->view('pages/login'); $arr['un'] = $this->input->post('naam'); $arr['pw'] = $this->input->post('paswoord'); if(isset($arr)){ $this->session->set_userdata('logged_in' , TRUE); } die(); // here } }
  10. that's not the problem... The real thing is.. if i just echo something in the method of the hook. it will echo it, go out of the hook and proceed with the next thing in codeigniter.php... HOWEVER, if i redirect within the method of the hook.. i don't know how to get back out of it... exit or die() won't work i think
  11. Thanks for the reply. The point is, i cannot var_dump anything since firefox only alerts that there has been a request that will never terminate.. It's because i don't understand the navigation logic when using hooks in codeigniter. say i request: CI/news it will call the news controller and output what's been set in the index() method . but now before getting to the news controller i want to put a hook to verify if one has logged in already, if not let them log in, and redirect back to the news/index
  12. The hook is called here, in codeigniter.php Is there a "post_controller_constructor" hook? * ------------------------------------------------------ */ $EXT->_call_hook('post_controller_constructor'); My hook: class Auth { private $CI; function __construct(){ $this->CI =& get_instance(); } function authenticate(){ $this->CI->session->set_userdata(array('hook' => $_SERVER['php_self'])); if(!$this->CI->session->userdata("logged_in")) { redirect('user/login', 'location'); } } } i try to redirect in hook to user controller, where i try todisplay login form class User extends CI_Controller { public function __construct() { parent::__construct(); } public function login(){ $this->load->view('pages/login'); $arr['un'] = $this->input->post('naam'); $arr['pw'] = $this->input->post('paswoord'); $this->session->set_userdata(array('logged_in' => $arr)); redirect($this->session->userdata('hook'), 'location'); } } after logging in, it should proceed back in the codeigniter.php file with the requested controller and method
  13. I try to use a post_controller_constructor hook point to create a authentication. My problem is that i always get in an infinite loop. So the flow goes basically like this: in the codeigniter.php file the hook is called. The hook has an authentication method that checks if 'logged_in' is set in the session, else redirects to a login controller, which displays the login view form, and sets the session after. Then i tried to redirect back to the hook. I don't know what or where i have to redirect too after filling the session in. It's just for the purpose of learning about hooks, so please don't suggest an alternative method.
  14. Can someone explain me how APC caching works? What exactly is "the cache"? I clarify myself: if i use the $this->output->cache(30) from codeigniter for example, i know the output is saved in the map application/cache. so the cache is harddiskspace... When i use apc_add(), where is it stored then? thanks in advance
  15. stijn0713

    dl()

    i'm wondering how dl() or enabling extentions in php.ini work exactly. If i enable an extention in the php.ini this code becomes available in all scripts. What about making extentions available throught dl() at runtime? What is the scope of this extention then? Can the PHP dl() function be compared with JAVA import package statement?
  16. From the manual: "Static variables can be referred to in trait methods, but cannot be defined by the trait. Traits can, however, define static methods for the exhibiting class." trait Counter { public function inc() { static $c = 0; $c = $c + 1; echo "$c\n"; } } Static variables always have to be defined in methods if i'm right, and considering that the above example works perfectly, i don't see what would be a problem to work with static variables in traits. So my question is: What is meant with "but cannot be defined by the trait"?
  17. Im studying modularity in PHP. Today i read about why defining properties (class variables) as public would be bad, and why it would be bad to read these variables directly without using getters and setters. I think this is bullshit, and has nothing to do with encapsulation. To my understanding, encapsulation enables changes without ripple effects. What i would like to hear is what (anticaped) changes could be made without ripple effects... Here is my thought: if you want to encapsulate a class member, this is because you want to change this variable independ of the calls to this variable, i.e. without needing to make change anywhere in the program. Suppose we are in a strong-typed language, and i have defined a class variable as an integer. If i would change this datatype to string, i will need to change the setter also and therefore the previous method calls to the setter won't work anymore and i will need to make N changes. Moreover, i would probably have assigned object variable to a variable of the type integer so here again i have to make N changes. Clearly combinatorial effects. The only thing you can do by defining getter and setters is to change the name of the class variable without combinatorial effects, on the condition that you don't change the getters and setters. But then again, why would i do this, i don't see a point in that. Please comment if you disagree
  18. A very open question : How would you guys judge/ assess applications or code snippets on modularity / evolvability . How would you assess the application design? the design of a framework etc....
  19. Hello, i'm trying to see what properties and methods $this references when used in a codeIgniter model, but i can't print it out or var_dump it. Any suggestions? thanks
  20. stijn0713

    OO

    Thanks all for the replies! KevinM1, this is a very interesting question! Actually, i have a sort of "framework" which i doubt, anyone is going to know. It's called NORMALISED SYSTEM FRAMEWORK. Why do i say sort of framework: because actually it prescribes how applications should be build and encapsulated in higher level modular constructs, the so-called 'elements') The elements are: - action elements (performing tasks), - data elements (for going to the database), - user-connector element (uses MVC architecture and provides CRUD functionality) - workflow elements (defining flow of actions on data-elements) - trigger element (defines triggers for starting the workflow) The elements all contain classes. Example: an action element contains an Agent, an InterfaceClass, Argument, Parameter and 1 or more implementation classes containing the actual implementation of a task (say calculating VAT). All other classes must be added to provide stability/ modularity/ no ripple effects. Now this framework is mainly writtin with one purpose: avoid combinatorial effects (= avoid change to the application growing along with the size of the system), i.e. achieve stability. I have a simple application writtin with the "laws" of NORMALISED SYSTEMS, i went through it in 7 days. As far as i can see it, the promise of stability seems to hold. Anybody heard of the framework by accident ?
  21. stijn0713

    OO

    Hello, I'm a self-directed programmer (haven't studied informatics or something simular) which, i guess, has some benefits, but also some disadvantages. let's say that i can look at programming with an open mind. And bad side, i'd sometimes feel disoriented and the way that i would tacle a coding problem seems not to match the "general mainstream way of doing coding". In a attempt to code more at a 'scientifically / educational' level, i delved myself into OO-programming and frameworks. I was wondering if: , - is it better to code OO? - are frameworks usefull? necessary? - all big applications, should they be OO? - what's the speed at what you guys are learning? I'm reading about PHP for 1 year now, a good time to start OO?
  22. i went through these tutorials XML, XSLT, XPath, XML Schema, and after doing that I really wonder why these 'languages' exist? in what case would i prefer to work with xml? untill now, i worked always with php retrieve data and make html, and css. XSLT is for example sort of like the equivalent of CSS, but especially designed for XML. But, say i retrieve DB information with PHP, i'm able to make alot formatting with PHP, the logic of CSS is pure layout. with XSLT i get the feeling that logic and layout is more combined?
  23. Dear all, I got an CL error when using the PEAR library. As far as my understanding reaches, i succesfully installed pear following this tutorial: After that, i installed the following packages: - DB_DataObjects - MDB2. I wanted to use the autobuilder function of the DB_DataObject package, as described here in the PEAR documentation. in the text they tell me to go to the pear/DB/DataObject/ directory: "To start the auto builder simply go to the pear/DB/DataObject/ directory". I noticed i didn't have that directory. Thinking something went wrong in the installations, i tried pear config-help in the CL. Now i get the error: Not a valid Win32 application and Access is Denied. The pear.bat files resides in the directory, but i cannot execute it ?! Did somebody succesfully install PEAR, and especially DB_DataObjects and MDB2, in combo with WAMP? Anybody that used the autobuilder? Anybody knows why i get the Not a valid Win32 application and Access is Denied error while executing the pear.bat file? PS: i don't dare to uninstall PEAR by manually selecting all pear files and delete them as i cannot distinglish anymore with 100% certainty which files where installed by WAMP and which by PEAR. :S Any thoughts greatly appreciated!!
  24. probably a messy solution, but ill share it if someone might find it usefull: <?php $id = $_SESSION['user_id']; $sql = "SELECT training_id, naam FROM trainingen WHERE user_id = $id"; $rs = mysql_query($sql); while ($row = mysql_fetch_assoc($rs)){ $t_id = $row['training_id']; $trainingen[$row['training_id']]['t_naam'] = $row['naam']; $sql2 = "SELECT o.naam AS o_naam, GROUP_CONCAT(reps) AS reps FROM oefeningen o WHERE training_id = $t_id GROUP BY training_id, o.naam"; $rs2 = mysql_query($sql2); while ($row2 = mysql_fetch_assoc($rs2)){ $trainingen[$row['training_id']]['oefeningen'][$row2['o_naam']] = $row2['reps']; } } ?> <?php $content = '<ul>'; foreach ($trainingen as $training_id => $arr){ $t_naam = $trainingen[$training_id]['t_naam']; $content .= '<li>'; $content .= "$t_naam"; $content .= '</li>'; foreach($trainingen[$training_id]['oefeningen'] as $o_naam => $reps){ $content .= '<ul>'; $content .= '<li>'; $content .= "$o_naam" . "($reps)"; $content .= '</li>'; $content .= '</ul>'; } } $content .= '<ul>'; echo $content; ?>
  25. thanks for the GROUP BY advice. i looked a bit further to that statement what it does and it seems logic that now i get arrays where the reps are comma-seperated and grouped for each combination of a training name and excercice name. the thing is that i now have a but duplicate values in my result set arrays, like this: Array ( [training_id] => 1 [training_naam] => TRAINING 1 [naam] => deadlift [excercices] => 10,8,6 ) Array ( [training_id] => 1 [training_naam] => TRAINING 1 [naam] => squat [excercices] => 12,12,10,10,6,5,5 ) It would be nicer if it where possible to make the excercice another layer deeper with the name of the excercice and the reps as values, like: Array ( [training_id] => 1 [training_naam] => TRAINING 1 [excercices] => Array ( [deadlift] => 10, 8, 6 [squat] => 5, 5, 5 ) ) Is that possible, or do i better do this with php after having retrieved all the different record sets? thanks already for the help
×
×
  • 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.