SitePoint Sponsor

User Tag List

Page 2 of 7 FirstFirst 123456 ... LastLast
Results 26 to 50 of 175
  1. #26
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  2. #27
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    arkinstall - the dump function calls var_dump wrapped with PRE tags, so yes unfortunately it outputs them.

    If it's a community project, though, I'm sure at some point someone would love to replace that.
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  3. #28
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Waiting to be added to the project, but heres a suggestion for the returning a variable:
    PHP Code:
    function _dump()
    {
        
    $args func_get_args();
        
    ob_start();
        
    var_dump($args);
        return 
    sprintf('<pre>%s</pre>'ob_get_clean());

    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  4. #29
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Haha, obviously. I'll add it right now.
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  5. #30
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Working demo:
    PHP Code:
    class Posts extends Controller
    {
        public function 
    index($request)
        {
            
    $posts find('posts');
            
    // Add a relationship and get all the corresponding records
            // The neat thing is that every record you get is not read-only
            // you can set new values and save() it.
            
    $posts relate($posts'id''comments''post_id');
            
    $data['posts'] = $posts;
            
    render('posts.index'$data);
        }
        
        public function 
    update($request)
        {
            
    // Find a single comment based on filters and update it
            
    $c single('comments', array('post_id' => 2));
            
    $c->text 'the only comment for this post';
            
    $c->save();
        }
        
        public function 
    add($request)
        {
            
    // Was the form sent?
            
    if($request->isPostBack)
            {
                
    // Create a new comment
                
    $post record('comments');
                
    $post->post_id post('post_id');
                
    $post->text post('subject');
                
    $post->save();
            }
            
    render('posts.add');
        }

    Show posts template:

    PHP Code:
    <? foreach($posts->loop() as $post):  ?>

    <h1><?=html($post->subject)?> at <?=dt2d($post->date'd/m/y')?></h1>

        <? foreach($post['comments']->loop() as $comment):  ?>
        <p><?=html($comment->text)?></p>
        <? endforeach; ?>

    <? endforeach; ?>
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  6. #31
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Cool.

    Just wondering, you have a few functions which do similar things, such as:
    PHP Code:
    function redirect($url)
    {
        if(!
    preg_match('~^http://~'$url))
        {
            
    $url $GLOBALS['rooturi'].$url;
        }

        
    header('Location: '.$url);
    }

    /* reload the current page */
    function reload()
    {
        
    $url 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        
    header('Location: '.$url);

    Surely it would be better:
    PHP Code:
    function redirect($url)
    {
        if(!
    preg_match('~^http://~'$url))
        {
            
    $url $GLOBALS['rooturi'].$url;
        }

        
    header('Location: '.$url);
    }

    /* reload the current page */
    function reload()
    {
        
    $url 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        
    redirect($url);

    (ooh, and before I forget - put exit; after using header('location....') to stop page processing afterwards).
    Edit:

    Update to redirect():
    PHP Code:
    function redirect($url)
    {
        if(!
    preg_match('~^https?://~'$url))
        {
            
    $url $GLOBALS['rooturi'].$url;
        }
        
    header('Location: '.$url);
        exit;

    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #32
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah of course. I kind of rushed through a lot of it so it's good you let me know about these small errors in design.

    I also made a video... Uploading now, will post when it's done.

    BTW Jake, I PMed you.
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  8. #33
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok the video is just a tad annoying because the noise removal feature had some funny side-effects and the frame rate is 4 but those are just minor things, it's a good video introduction to the framework.

    It shows how to work with the database and views and you can see the results "live".

    http://serialize.us/retro/retro.html
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  9. #34
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Everything is so much simpler like that...

    Round of applause!
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  10. #35
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, thank you. I actually came up with the idea last week.. And I don't need to tell you how it is when you think you have a good idea, right? Haha... Yeah, couldn't wait to get it to work.

    Jake, if you didn't still get my PM - add me to MSN - yam.marc@hotmail.com so we can work on this more closely.

    All the rest - again - feel free to add me if you want to help out!
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  11. #36
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice video... is there a way to turn off the phoney keyboard typing sounds when you're recording?

  12. #37
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, should I next time?
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  13. #38
    SitePoint Enthusiast snajt's Avatar
    Join Date
    May 2008
    Location
    Kalmar, Sweden
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm definitely interesting in helping you out with development on this, just watched your video and it looks great from what I've seen. I'm going to test it more thoroughly wen i get home from work, keep up the good work man!

  14. #39
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just looked at the project upload times - 14 minutes between builds. You guys are really jamming! I'm going to have a look at the code and see if I have any ideas to contribute.

  15. #40
    SitePoint Member Renard Urbain's Avatar
    Join Date
    Jul 2008
    Location
    Montréal, Canada
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sent you a mail Marc this sounds really interesting !

  16. #41
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Latest build out.

    Seriously, this thing is getting great!
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  17. #42
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://code.google.com/p/retrophpmvc/downloads/list

    Jake also covered up the functions we had in build 2 so far, thanks much! Me and Jake are working well together and just think if we could all get into a group (Jake suggested a sitepoint one, perhaps?) or MSN convos and brain storm until we get exactly what we want!
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  18. #43
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I also think the secret of this framework is:

    We're not looking for ways to make it too clever or complex or flexible.

    We're admitting that we are lazy programmers, and lazy development is what we want! And I think most people are like that, and just didn't want to be the first to put it out there.
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  19. #44
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    Latest build out.

    Seriously, this thing is getting great!
    Whoa! I haven't even had a chance to open the Zip file for build 3 yet - I'm still watching the video!

  20. #45
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I noticed that there are a lot of places, where you're embedding strings in HTML, without escaping properly. Attributes needs to be escaped with htmlspecialchars.

    Eg. instead of this:
    PHP Code:
    return '<img src="'.$link.'" alt="'.$link.'" />'
    You should do this:
    PHP Code:
    return '<img src="'.htmlspecialchars($link).'" alt="'.htmlspecialchars($link).'" />'

  21. #46
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you guys not working in SVN? I don't see anything in the trunk and the changelog is empty. You guys really need to get this thing in Google's SVN repository so that changes can be tracked and viewed online without downloading the package.

  22. #47
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yeah - we will do.

    The current isn't exactly a version yet. He just posted it so that people could see the files at the moment - it still has alot to go before being ready for versioning
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  23. #48
    SitePoint Addict webaddictz's Avatar
    Join Date
    Feb 2006
    Location
    Netherlands
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    Yeah - we will do.

    The current isn't exactly a version yet. He just posted it so that people could see the files at the moment - it still has alot to go before being ready for versioning
    As I just said to Yam: versioning is really usefull for development, not only for releasing. It makes for a good platform for collaboration. Now, the way I see it there are more people who are willing to contribute, so I'd recommend reconsidering that choice.
    Last edited by webaddictz; Sep 28, 2008 at 06:40. Reason: (some name confusion)

  24. #49
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Cool - we will do after this next stage then.

    We're just making some, well, nothing better than kickass! form handling, so after this stage we'll go ahead with the versioning.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  25. #50
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken View Post
    I noticed that there are a lot of places, where you're embedding strings in HTML, without escaping properly. Attributes needs to be escaped with htmlspecialchars.

    Eg. instead of this:
    PHP Code:
    return '<img src="'.$link.'" alt="'.$link.'" />'
    You should do this:
    PHP Code:
    return '<img src="'.htmlspecialchars($link).'" alt="'.htmlspecialchars($link).'" />'
    Good point. I'll fix that tomorrow, probably.

    Anyway people - form validation is officially completed.

    Story:

    Me and Jake were chatting about how to go through with it... we came up with a pretty nice but vague idea - I went for a walk outside for an hour, came back with motivation... result:

    PHP Code:
    if($request->isPostBack)
            {
                
    post('username')->min_chars(4)->max_chars(6);
                
    post('email')->email();
                
    post('author')->min_words(2);
                
    post('anything')->match('^pattern$');
                
    post('age')->ints();
                
                if(
    post_valid())
                    echo 
    'yay';
                else
                    echo 
    'boo';
                    
                
    // or
                
    if(post('email')->email()->is_valid())
                    echo 
    'yay';
                else
                    echo 
    'boo';
            } 
    It also works with array posts such as <input type="text" name="names[]" />

    Build 5 is up in http://code.google.com/p/retrophpmvc/downloads/list - go ahead and beta test it.
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •