Viewing 13 replies - 1 through 13 (of 13 total)
  • what version are you using?

    Thread Starter gongtones

    (@karambirsk)

    Should be the latest version. 2.1.9 with extended views 1.1.2

    as i asked in the other thread, can i have the link to the feed?

    Thread Starter gongtones

    (@karambirsk)

    Thread Starter gongtones

    (@karambirsk)

    To be clear, the escape sequence “\n” should be parsed and replaced with a carriage return, line feed combination

    Hi,

    the problem is that the feed export the \n. We just consider the field as a string and we do not process anything, that’s more a problem of exporting than ours.
    You can look at the exported feed by clicking the following link

    https://p28-calendars.icloud.com/published/2/_X0nWxbz4lQ9VKv68TA2CuCpzH4kGAhmxQWKD-F3mAOhdZigDQK_6rWwZpr1DN5XfkhFM3D7FVgWJoAq1n2fxmzRknBQh6GbKiDsfSXG494

    it shows

    LOCATION:Dharma Vibration\n2655B W State Route 89A\nSedona AZ 86336

    We map the Location to the venue field and we accept no formatting for that.

    Thread Starter gongtones

    (@karambirsk)

    I am a former computer programmer. Let me know either a) what module is used to import the feed or b) what module is used to load the event so I can hack the code myself.

    Doing nothing is not an option as it my professional reputation at stake if I use your plugin which is otherwise quite good.

    Hi, file lib/import-export/ics.php ( https://take.ms/hLUgi ), function add_vcalendar_events_to_db. This function is quite terrible as it’s very long.
    At line 372 we do

    // ===================
    			// = Venue & address =
    			// ===================
    			$address = $venue = '';
    			$location = $e->getProperty( 'location' );
    			$matches = array();
    			// This regexp matches a venue / address in the format
    			// "venue @ address" or "venue - address".
    			preg_match( '/\s*(.*\S)\s+[\-@]\s+(.*)\s*/', $location, $matches );
    			// if there is no match, it's not a combined venue + address
    			if ( empty( $matches ) ) {
    				// if there is a comma, probably it's an address
    				if ( false === strpos( $location, ',' ) ) {
    					$venue = $location;
    				} else {
    					$address = $location;
    				}
    			} else {
    				$venue = isset( $matches[1] ) ? $matches[1] : '';
    				$address = isset( $matches[2] ) ? $matches[2] : '';
    			}

    basically we search for a pattern ( the same pattern we us for exporting an ics feed ) and if it doesn’t match the pattern we set it as the “Venue”

    Thread Starter gongtones

    (@karambirsk)

    One question. Is this function emitting HTML or CDATA?

    This function is taking data from the converted ICS feed and adding it to our event object which is later saved to the DB.

    $e->getProperty( 'location' );

    returns a string, in your case the string in question is:

    Dharma Vibration\n2655B W State Route 89A\nSedona AZ 86336

    Thread Starter gongtones

    (@karambirsk)

    Here is my workaround for imports from iCal on Mac OS X:

    // ===================
    			// = Venue & address =
    			// ===================
    			$address = $venue = '';
    			$location = $e->getProperty( 'location' );
    			//$matches = array();
    			// This regexp matches a venue / address in the format
    			// "venue @ address" or "venue - address".
    			//preg_match( '/\s*(.*\S)\s+[\-@]\s+(.*)\s*/', $location, $matches );
    			$matches = explode( '\n', $location );
    			// if there is no match, it's not a combined venue + address
    			if ( empty( $matches ) ) {
    				// if there is a comma, probably it's an address
    				if ( false === strpos( $location, ',' ) ) {
    					$venue = $location ;
    				} else {
    					$address = $location ;
    				}
    			} else {
    				$venue = isset( $matches[0] ) ? $matches[0] : '';
    				$address = isset( $matches[1] ) ? $matches[1]  : '';
    				$address .= isset( $matches[2] ) ? $matches[2] : '';
    			}

    (NOTE: preg_match in your function didn’t work for some reason so I looked around and found that explode did the trick. Also, I had to add a non breaking space and the hex code for a line feed in order to get the address to display properly so it would load the Google map.)

    Thanks for sharing. since upgrading will break this fix, remember not to upgrade unless you really need new functionalities ??

    Thread Starter gongtones

    (@karambirsk)

    The good news is that I have the workaround documented here for safe keeping. ??

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to parse \n Escape Sequence From Imported Calendar Feeds’ is closed to new replies.