Esempio n. 1
0
/**
 * parse XML string into iCalcreator components
 *
 * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**>
 * @since 2.16.22 - 2013-06-20
 * @param object $iCal, iCalcreator vcalendar or component object instance
 * @param string $xml
 * @return bool
 */
function XMLgetComps($iCal, $xml)
{
    static $comps = array('vtimezone', 'standard', 'daylight', 'vevent', 'vtodo', 'vjournal', 'vfreebusy', 'valarm');
    $sx = 0;
    while (FALSE !== substr($xml, $sx + 11, 1) && '<properties>' != substr($xml, $sx, 12) && '<components>' != substr($xml, $sx, 12)) {
        $sx += 1;
    }
    if (FALSE === substr($xml, $sx + 11, 1)) {
        return FALSE;
    }
    if ('<properties>' == substr($xml, $sx, 12)) {
        $xml2 = XMLgetTagContent1($xml, 'properties', $endIx);
        XMLgetProps($iCal, $xml2);
        $xml = substr($xml, $endIx);
    }
    if ('<components>' == substr($xml, 0, 12)) {
        $xml = XMLgetTagContent1($xml, 'components', $endIx);
    }
    while (!empty($xml)) {
        $xml2 = XMLgetTagContent2($xml, $tagName, $endIx);
        if (in_array(strtolower($tagName), $comps) && FALSE !== ($subComp = $iCal->newComponent($tagName))) {
            XMLgetComps($subComp, $xml2);
        }
        $xml = substr($xml, $endIx);
    }
    unset($xml);
    return $iCal;
}
Esempio n. 2
0
/**
 * parse XML string into iCalcreator components
 *
 * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**>
 * @since 2.21.11 - 2015-03-21
 * @param object $iCal   iCalcreator vcalendar or component object instance
 * @param string $xml
 * @uses iCalUtilityFunctions::$allComps
 * @uses XMLgetTagContent1()
 * @uses XMLgetProps()
 * @uses XMLgetTagContent2()
 * @uses vcalendar::newComponent()
 * @uses iCalUtilityFunctions::$allComps
 * @uses XMLgetComps()
 * @return object
 */
function XMLgetComps($iCal, $xml)
{
    $sx = 0;
    while (FALSE !== substr($xml, $sx + 11, 1) && '<properties>' != substr($xml, $sx, 12) && '<components>' != substr($xml, $sx, 12)) {
        $sx += 1;
    }
    if (FALSE === substr($xml, $sx + 11, 1)) {
        return FALSE;
    }
    if ('<properties>' == substr($xml, $sx, 12)) {
        $xml2 = XMLgetTagContent1($xml, 'properties', $endIx);
        XMLgetProps($iCal, $xml2);
        $xml = substr($xml, $endIx);
    }
    if ('<components>' == substr($xml, 0, 12)) {
        $xml = XMLgetTagContent1($xml, 'components', $endIx);
    }
    while (!empty($xml)) {
        $xml2 = XMLgetTagContent2($xml, $tagName, $endIx);
        if (in_array(strtolower($tagName), iCalUtilityFunctions::$allComps) && FALSE !== ($subComp = $iCal->newComponent($tagName))) {
            XMLgetComps($subComp, $xml2);
        }
        $xml = substr($xml, $endIx);
    }
    unset($xml);
    return $iCal;
}