/** * Class constructor. * * @param array $data * @return Object_model */ public function __construct($data = array()) { parent::__construct(); $this->load->helper('data'); import_data($this, $data); }
$type = 'palm'; break; case 'VCAL': include "import_vcal.php"; $data = parse_vcal($file['tmp_name']); $type = 'vcal'; break; case 'ICAL': include "import_ical.php"; $data = parse_ical($file['tmp_name']); $type = 'ical'; break; } $count_con = $count_suc = $error_num = 0; if (!empty($data) && empty($errormsg)) { import_data($data, $doOverwrite, $type); echo "<p>" . translate("Import Results") . "</p>\n<br /><br />\n" . translate("Events successfully imported") . ": {$count_suc}<br />\n"; echo translate("Events from prior import marked as deleted") . ": {$numDeleted}<br />\n"; if (empty($allow_conflicts)) { echo translate("Conflicting events") . ": " . $count_con . "<br />\n"; } echo translate("Errors") . ": {$error_num}<br><br>\n"; } elseif ($errormsg) { echo "<br /><br />\n<b>" . translate("Error") . ":</b> {$errormsg}<br />\n"; } else { echo "<br /><br />\n<b>" . translate("Error") . ":</b> " . translate("There was an error parsing the import file or no events were returned") . ".<br />\n"; } } else { echo "<br /><br />\n<b>" . translate("Error") . ":</b> " . translate("The import file contained no data") . ".!<br />\n"; } //echo "<hr />$sqlLog\n";
{ foreach ($GLOBALS as $K => $V) { do_debug("GLOBALS[{$K}] => " . (strlen($V) < 70 ? $V : '(too long)')); } foreach ($GLOBALS['HTTP_POST_VARS'] as $K => $V) { do_debug("GLOBALS[{$_POST[$K]}] => " . (strlen($V) < 70 ? $V : '(too long)')); } } switch ($_SERVER['REQUEST_METHOD']) { case 'PUT': // do_debug ( "Importing updated remote calendar" ); $calUser = $login; $overwrite = true; $type = 'icalclient'; $data = parse_ical('', $type); import_data($data, $overwrite, $type); break; case 'GET': // do_debug ( "Exporting updated remote calendar" ); header('Content-Type: text/calendar'); header('Content-Disposition: attachment; filename="' . $login . '.ics"'); $use_all_dates = true; echo export_ical(); break; case 'OPTIONS': header('Allow: GET, PUT, OPTIONS'); break; default: header('Allow: GET, PUT, OPTIONS'); header('HTTP/1.0 405 Method Not Allowed'); break;
/** * Perform imports for one second or until finished. * * @return * An array indicating the status after doing imports. The first element is * the overall percentage finished. The second element is a status message. */ function import_do_imports() { while (isset($_SESSION['import_remaining']) && ($import = reset($_SESSION['import_remaining']))) { $import_finished = import_data($import['module'], $import['version']); if ($import_finished == 1) { // Dequeue the completed import. unset($_SESSION['import_remaining'][key($_SESSION['import_remaining'])]); $import_finished = 0; // Make sure this step isn't counted double } if (timer_read('page') > 1000) { break; } } if ($_SESSION['import_total']) { $percentage = floor(($_SESSION['import_total'] - count($_SESSION['import_remaining']) + $import_finished) / $_SESSION['import_total'] * 100); } else { $percentage = 100; } // When no imports remain, clear the caches in case the data has been imported. if (!isset($import['module'])) { cache_clear_all('*', 'cache', TRUE); cache_clear_all('*', 'cache_page', TRUE); cache_clear_all('*', 'cache_menu', TRUE); cache_clear_all('*', 'cache_filter', TRUE); drupal_clear_css_cache(); } return array($percentage, isset($import['module']) ? 'Importing ' . $import['module'] . ' module' : 'Importing complete'); }
/** * import_rss * * * * * * */ function import_rss($url, $limit = 10) { if (empty($url)) { return false; } $data = import_data($url); if ($data === false) { return false; } $xml = @simplexml_load_string($data); if ($xml == false || empty($xml) || $xml->error) { return false; } $articles = array(); $total_items = count($xml->channel->item); $limit = $total_items < $limit ? $total_items : $limit; for ($i = 0; $i < $limit; $i++) { $articles[] = array('title' => (string) $xml->channel->item[$i]->title, 'description' => (string) $xml->channel->item[$i]->description, 'link' => (string) $xml->channel->item[$i]->link, 'date' => (string) $xml->channel->item[$i]->pubDate); } /**/ /* foreach ($xml->channel->item as $item) { $articles[] = array( 'title' => (string)$item->title, 'description' => (string)$item->description, 'link' => (string)$item->link, 'date' => (string)$item->pubDate ); } */ if (empty($articles)) { return false; } return $articles; }
/** * get_twitter_userid * * * * */ function get_twitter_userid($username) { if (empty($username)) { return false; } $url = 'http://api.twitter.com/1/statuses/user_timeline.xml'; $url .= '?screen_name=' . $username . '&count=1&trim_user=1'; $data = import_data($url); if ($data === false) { return false; } $xml = @simplexml_load_string($data); if ($xml->error) { return false; } return $xml->status->user->id; }