Created
March 23, 2011 20:14
-
-
Save tobya/883850 to your computer and use it in GitHub Desktop.
The outline Structure of a PList file used by ContactLoader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plist version="1.0"> | |
<dict> | |
<key>GroupName</key> | |
<string>Name of Your Group</string> | |
<key>Contacts</key> | |
<array> | |
<dict> | |
<key>FirstName</key> | |
<string>Toby</string> | |
<key>LastName</key> | |
<string>Allen</string> | |
<key>Telephone_Mobile</key> | |
<string>00353214646785</string> | |
<key>Telephone_Home</key> | |
<string>00353214646785</string> | |
<key>Email_Home</key> | |
<string>[email protected]</string> | |
<key>Email_Work</key> | |
<string>[email protected]</string> | |
<key>Company</key> | |
<string></string> | |
<key>JobTitle</key> | |
<string></string> | |
<key>Department</key> | |
<string>Kitchen</string> | |
<key>Street</key> | |
<string>A Street</string> | |
<key>City</key> | |
<string></string> | |
<key>State</key> | |
<string>Cork</string> | |
<key>Zip</key> | |
<string></string> | |
<key>Country</key> | |
<string>Ireland</string> | |
<key>YourRefUniqueID</key> | |
<string>21824</string> | |
<key>Notes</key> | |
<string>Any additional Notes you wish to put in the | |
notes field on your contact. | |
Perhaps Address details and info | |
about them.</string> | |
<key>ImageURL</key> | |
<string>http://www.example.com/path/to/image.jpg</string> | |
</dict> | |
<dict> | |
<key>FirstName</key> | |
<string>Shorter</string> | |
<key>LastName</key> | |
<string>Contact</string> | |
<key>Telephone_Mobile</key> | |
<string></string> | |
<key>Telephone_Home</key> | |
<string></string> | |
<key>Email_Home</key> | |
<string></string> | |
<key>Email_Work</key> | |
<string></string> | |
<key>EventContactsUniqueID</key> | |
<string></string> | |
<key>Notes</key> | |
<string></string> | |
<key>ImageURL</key> | |
<string></string> | |
</dict> </array> | |
</dict> | |
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/************************************************************************** | |
Sample php file for ContactLoader Iphone App to create plist file of contacts. | |
Author: Toby Allen. | |
Licence: Public Domains use as you wish. | |
**************************************************************************/ | |
//Create Array with all contact information you wish to use. | |
//This array can be populated manually as in this example, or | |
//by connecting to your local database. | |
$ContactInfo = array('GroupName' => 'Vegetable Contacts', 'Contacts' => array()); | |
$ContactInfo['Contacts'][] = array('FirstName' => 'Tom', | |
'LastName' => 'Tomato', | |
'Telephone_Home' => '003535555555', | |
'Telephone_Mobile' => '00353875555555', | |
'Email_Home' => '[email protected]', | |
'Email_Work' => '', | |
'Street' => 'First Row', | |
'City' => 'Green House St', | |
'State' => 'Green House A', | |
'Zip' => 'GG', | |
'Country' => 'Tomato Land', | |
'YourRefUniqueID' => 'Tomato1', | |
'Notes' => 'Tom Tastes nice and Juicy', | |
'ImageURL' => 'http://iphone.toflidium.com/contactloader/data/test/tomato.png'); | |
$ContactInfo['Contacts'][] = array('FirstName' => 'Anna', | |
'LastName' => 'Aubergine', | |
'Telephone_Home' => '003535555555', | |
'Telephone_Mobile' => '00353875555555', | |
'Email_Home' => '[email protected]', | |
'Email_Work' => '', | |
'Street' => 'Second Row', | |
'City' => 'Green House St', | |
'State' => 'Green House A', | |
'Zip' => 'GG', | |
'Country' => 'Tomato Land', | |
'YourRefUniqueID' => 'Eggplant1', | |
'Notes' => 'Anna Aubergine likes to be rubbed all over with Olive Oil!', | |
'ImageURL' => 'http://iphone.toflidium.com/contactloader/data/test/eggplant.png'); | |
/* | |
This is a useful template for new entries. | |
$ContactInfo[] = array('FirstName' => '', | |
'LastName' => '', | |
'Telephone_Home' => '', | |
'Telephone_Mobile' => '', | |
'Email_Home' => '', | |
'Email_Work' => '', | |
'Street' => '', | |
'City' => '', | |
'State' => '', | |
'Zip' => '', | |
'Country' => '', | |
'YourRefUniqueID' => '', | |
'Notes' => '', | |
'ImageURL' => ''); | |
*/ | |
/* | |
PList Generation | |
*/ | |
//Cycle Through Array and print out Values to a XML string | |
$ContactOutput = ''; | |
foreach($ContactInfo['Contacts'] as $Contact) | |
{ | |
$Values = ''; | |
foreach($Contact as $FieldName => $FieldValue) | |
{ | |
$HTMLValue = htmlentities($FieldValue); | |
//HTML entities such as & and Unicode chars need to be enclosed in <![CDATA[ ]]> tags for | |
//the iphone to recognise them, so just do it for every value to be sure, althoug only ones that | |
//do contain these characters definitely need to . If this doesnt happen ContactLoader will be | |
//unable to read your file. | |
$Values .= " | |
<key>$FieldName</key> | |
<string><![CDATA[$HTMLValue]]></string>"; | |
} | |
//Finish off Contact XML. | |
$ContactOutput .= " | |
<dict> | |
$Values | |
</dict>"; | |
}; | |
//Wrap with necessary XML to complete. | |
$FullPage = "<plist version=\"1.0\"> | |
<dict> | |
<key>GroupName</key> | |
<string>$ContactInfo[GroupName]</string> | |
<key>Contacts</key> | |
<array> | |
$ContactOutput | |
</array> | |
</dict> | |
</plist> "; | |
echo $FullPage; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment