What are the steps to convert this function to a model/controller in Zend Framework?

Posted by Joel on Stack Overflow See other posts from Stack Overflow or by Joel
Published on 2010-05-23T23:08:05Z Indexed on 2010/05/23 23:10 UTC
Read the original article Hit count: 223

Filed under:
|
|

Hi guys, I'm learning Zend Framework MVC, and I have a website that is mainly static php pages. However one of the pages is using functions, etc, and I'm trying to figure out what the process is for converting this to an OOP setup.

Within the <body> I have this function (and more, but this is the first function):

function filterEventDetails($contentText)  {

$data = array();

  foreach($contentText as $row)  {

    if(strstr($row, 'When: '))  {
     ##cleaning "when" string to get date in the format "May 28, 2009"##
     $data['duration'] = str_replace('When: ','',$row);
     list($when, ) = explode(' to ',$data['duration']);
     $data['when'] = substr($when,4);

      if(strlen($data['when'])>13)
      $data['when'] = trim(str_replace(strrchr($data['when'], ' '),'',$data['when']));
          $data['duration'] = substr($data['duration'], 0, strlen($data['duration'])-4); //trimming time zone identifier (UTC etc.)
    }

    if(strstr($row, 'Where: '))  {
    $data['where'] = str_replace('Where: ','',$row);
      //pr($row);
    //$where = strstr($row, 'Where: ');
     //pr($where);
    }

     if(strstr($row, 'Event Description: '))  {

      $event_desc = str_replace('Event Description: ','',$row);
      //$event_desc = strstr($row, 'Event Description: ');
     ## Filtering event description and extracting venue, ticket urls etc from it.
      //$event_desc = str_replace('Event Description: ','',$contentText[3]);
      $event_desc_array = explode('|',$event_desc);

      array_walk($event_desc_array,'get_desc_second_part');
      //pr($event_desc_array);
      $data['venue_url'] = $event_desc_array[0];
      $data['details'] = $event_desc_array[1];
      $data['tickets_url'] = $event_desc_array[2];
      $data['tickets_button'] = $event_desc_array[3];
      $data['facebook_url'] = $event_desc_array[4];
      $data['facebook_icon'] = $event_desc_array[5];

     }
  }

  return $data;
}

?>

So right now I have this in my example.phtml view page. I understand this needs to be a model and acted on by the controller, but I'm really not sure where to start with this conversion? This is a function tht is taking info from a Google calendar and parsing it for the view.

Thanks for any help!

© Stack Overflow or respective owner

Related posts about php

Related posts about mvc