Jump to content

mantis

Member
  • Posts

    9
  • Joined

  • Last visited

Posts posted by mantis

  1. As the above does not work that well and is all but elegant I sat down and refactored the code.

     

    Firstly find the lines (of the original code)

    $uri = strtolower($_SERVER['REQUEST_URI']);
    list($pfx, $controllerName,$actionName) = preg_split('/[\/\\\]/',$uri);
    

    and replace with:

    $uri = strtolower($_SERVER['REQUEST_URI']);
    $url = preg_split('/[\/\\\]/', $uri);
    
    //See if you are on target by un commenting the following two lines index should be $url[3]
    //echo '<pre>';
    //print_r($url);
    
    
    //list($pfx, $controllerName,$actionName) = preg_split('/[\/\\\]/',$uri); // this does not work unless you are in the root
    
    
    if ($url[3] === "") {
         $controllerName = "index";
         $actionName = "";
    } else {
         $controllerName = $url[3];
         $actionName = $url[4];
    }
    

     

    Regards

    mantis

  2. For all those that have the same problem as me here is a dirty workaround

     

    In the file /public/index.php find the line

     

    list($pfx, $controllerName,$actionName) = preg_split('/[\/\\\]/',$uri);

     

    and replace with:

     

    //list($pfx, $controllerName,$actionName) = preg_split('/[\/\\\]/',$uri);
    $uri_e = preg_split('/[\/\\\]/', $uri);
    $nrs = count($uri_e);
    
    
    $nrs1 = ($nrs - 2);
    /*
    *    Uncomment the next 4 lines if you are not getting the right result
    *    then adjust the number in the line above
    */
    //echo '<pre>';
    //echo 'The number of the array identifier :' . $nrs1 . '<br />';
    //echo 'The value of the array node: ' . $uri_e[$nrs1] . '<br />';
    //print_r(preg_split('/[\/\\\]/', $uri));
    
    /*
    *  This is where the "magic" happens
    */
    
    
    if ($uri_e[$nrs1] === 'index' && $uri_e[$nrs1 + 1] === '' || $uri_e[$nrs1] === 'public' && $uri_e[$nrs1 + 1] === '') {
         $controllerName = 'index';
         $actionName = '';
    } elseif ($uri_e[$nrs1] != '' && $uri_e[$nrs1 + 1] != '') {
         $controllerName = $uri_e[$nrs1];
         $actionName = $uri_e[$nrs1 + 1];
    } elseif($uri_e[$nrs1] === 'test' && $uri_e[$nrs1 + 1] === '' ){
         $controllerName = 'test';
         $actionName = '';
    }else {
         echo 'Controller can not be found';
    }
    
    /*
    *    Which controller is passed ?
    *    Uncomment the next line to find out
    */
    //echo '<br />Controller Name: ' . $controllerName . '<br />';

     

    Thats all, this way you can at least follow the rest of the tuts

     

    Hope it helps

     

    Regards

    mantis

  3. Your problem is a little more complex than described

    1. Tiny mce changed the architecture quite drastically with the advent of V4 (currently 4.0.5)

    2. Tiny mce now offers inline editing as a standard, although you can still use the method as taught in the video

    3. Should you want to update the editor you need to

    a. change the function calls the best is if you study the examples as found here

    b. adjust the js scripts

     

    It looks harder than you think it is actually quite easy.

     

    Kind regards

    mantis

  4. After the above problem did not give me any peace I played around with the index.php file and came to the conclusion that the problem lies with the URI

     

    I use xampp 1.8.3 (php 5.5.1, Apache 2.4.4)

     

    My File path is:

    F:\xampp\htdocs\killer_php (htdocs is the root for localhost)

     

    If I echo print some of the variables I get:

    echo APPLICATION_PATH .'<br />';

    I get F:\xampp\htdocs\killer_php

     

    so far so good

    The next thing I echoed was the REQUEST_URI on index in the public folder

    echo '<br />Request URI: ' . $uri . '<br />';

    This outputs

    Request URI: /killer_php/public/index/

     

    Also this is still good

    However is I echo the controller Name after:

    list($pfx, $controllerName,$actionName) = preg_split('/[\/\\\]/',$uri);

    but before the switch I get

    Controller Name: killer_php

     

    Obviously this is wrong as it is supposed to be index, I tried to adjust the path but to no avail

     

    I would be glad if someone could help or point me in the right direction

     

    Regards

    mantis

  5. I seem to have a similiar problem I get the error messages

    Notice: Undefined variable: controller in c:\xampp\htdocs\playground\killer_php\public\index.php on line 45

     

    Fatal error: Call to a member function dispatch() on a non-object in c:\xampp\htdocs\playground\killer_php\public\index.php on line 45

     

    Line 45 contains

     

    $controller->dispatch();

    Just to be on the save side I exchanged my code with the download code so I'm sure there is no typo - has anyone got an idea?

     

    Regards

    mantis

×
×
  • Create New...