当前位置: 首页>>代码示例>>PHP>>正文


PHP Encoding::toUTF8方法代码示例

本文整理汇总了PHP中Encoding::toUTF8方法的典型用法代码示例。如果您正苦于以下问题:PHP Encoding::toUTF8方法的具体用法?PHP Encoding::toUTF8怎么用?PHP Encoding::toUTF8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Encoding的用法示例。


在下文中一共展示了Encoding::toUTF8方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: encoding

 public function encoding($text)
 {
     // encoding para ISO 8859-1
     return $text;
     if (strrpos(Run::ENCODING, "utf") != "") {
         return Encoding::toUTF8($text);
     } else {
         return Encoding::toLatin1($text);
     }
 }
开发者ID:obscurun,项目名称:run-dev,代码行数:10,代码来源:string.php

示例2: toSlug

 static function toSlug($string, $space = "-")
 {
     $string = Encoding::fixUTF8(Encoding::toUTF8($string));
     $string = self::mb_strtolower(self::mb_trim($string));
     $string = self::cleanTextHtml($string);
     if (function_exists('iconv')) {
         $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
     }
     $string = preg_replace('/[^a-z0-9 _.-]/', '', $string);
     $string = preg_replace('/[\\s\\-_]+/', $space, $string);
     $string = str_replace(' ', $space, $string);
     return $string;
 }
开发者ID:sostenesgomes,项目名称:middleware-vtex,代码行数:13,代码来源:Strings_UTF8.php

示例3: cumulus_update

 function cumulus_update($file)
 {
     $infile = fopen($file, 'r');
     $firstLine = fgetcsv($infile);
     $csvArray = array();
     while (!feof($infile)) {
         $assoc = array();
         $line = fgetcsv($infile);
         if ($line[0]) {
             foreach ($line as $index => $value) {
                 $assoc[$firstLine[$index]] = $value ? Encoding::toUTF8($value) : NULL;
             }
             $csvArray[] = $assoc;
         }
     }
     fclose($infile);
     print_r($csvArray);
 }
开发者ID:rbgvictoria,项目名称:vicflora,代码行数:18,代码来源:roboflow_helper.php

示例4: DBNaryInterface

/**
 * @see https://github.com/FerreroJeremy/DBNary-PHP-Interface
 */
require_once 'DBNaryInterface.php';
/**
 * @see https://github.com/neitanod/forceutf8
 */
require_once 'Encoding.php';
$db = new DBNaryInterface();
$encode = new Encoding();
$db->setLanguageFrom('french');
$db->setLanguageTo('english');
$db->connect();
$words = extractLinesFromFile('dicos/dico_295065.txt');
foreach ($words as $word) {
    $word = $encode->toUTF8(trim($word));
    $word = getFirstWord(trim($word));
    $db->getTranslations(trim($word));
    $availableTranslations = $db->getResultInList();
    if (!empty($availableTranslations)) {
        foreach ($availableTranslations as $translation) {
            writeInFile('dico_from_dbnary.txt', trim($word) . ' @ ' . trim($translation) . chr(10));
        }
    }
}
/* * ***********************
 *      FUNCTIONS
 * *********************** */
/**
 * Return the first token of a string.
 * @param   string  $text   Text.
开发者ID:leloulight,项目名称:Cross-Language-Dataset,代码行数:31,代码来源:enrich_dico_with_dbnary.php

示例5: parseDelimitedText

 private function parseDelimitedText()
 {
     $array = array();
     $handle = fopen($this->filename, 'r');
     while (!feof($handle)) {
         if ($this->delimiter == 'tab') {
             $line = fgetcsv($handle, 0, "\t");
         } elseif ($this->delimiter == 'comma') {
             $line = fgetcsv($handle);
         }
         $array[] = array('fromNode' => trim(str_replace(array(':', '.'), '', $line[0])), 'leadText' => Encoding::toUTF8(trim($line[1])), 'toNode' => Encoding::toUTF8(trim($line[2])));
     }
     // Get the items
     foreach ($array as $row) {
         $goto = $row['toNode'];
         if ($row && !is_numeric($row['toNode'])) {
             $this->items[] = array('id' => $goto, 'name' => $goto, 'icon' => NULL, 'url' => NULL);
             $this->itemIDs[] = $goto;
         }
     }
     // Id of the first step
     $this->firstStepID = $array[0]['fromNode'];
     // Get all the leads
     foreach ($array as $index => $row) {
         $goto = $row['toNode'];
         $this->stepIDs[] = $row['fromNode'];
         $this->leads[] = array('stepid' => $row['fromNode'], 'leadid' => $index + 1, 'goto' => $goto, 'icon' => NULL, 'leadtext' => $row['leadText']);
     }
 }
开发者ID:rbgvictoria,项目名称:keybase,代码行数:29,代码来源:KeyUploadService.php

示例6: createImageRecord

 private function createImageRecord($row)
 {
     $rec = new ImageRecord();
     $rec->CumulusRecordID = $row['CumulusRecordID'];
     $rec->CumulusRecordName = $row['CumulusRecordName'];
     $rec->CumulusCatalogue = $row['CumulusCatalog'];
     $rec->Title = $row['dcterms:title'];
     $rec->Source = $row['dc:source'];
     $rec->Modified = $row['dcterms:modified'];
     $rec->DCType = $row['dcterms:type'];
     $rec->Subtype = $row['ac:subtype'] == 'Illustration' ? 'Illustration' : 'Photograph';
     $rec->Caption = substr($row['ac:caption'], -1) == '.' ? $row['ac:caption'] : $row['ac:caption'] . '.';
     $rec->SubjectCategory = $row['iptc:CVTerm'];
     $rec->SubjectPart = $row['ac:subjectPart'];
     $rec->SubjectOrientation = $row['ac:subjectOrientation'];
     $rec->CreateDate = $row['xmp:CreateDate'];
     $rec->DigitizationDate = $row['ac:digitizationDate'];
     $rec->Creator = $row['dcterms:creator'];
     $rec->RightsHolder = $row['dcterms:rightsHolder'];
     $rec->License = $row['dcterms:license'];
     $rec->Rights = $row['dc:rights'];
     $rec->ScientificName = Encoding::toUTF8($row['dwc:scientificName']);
     $rec->CatalogNumber = $row['dwc:catalogNumber'];
     $rec->RecordedBy = $row['dwc:recordedBy'];
     $rec->RecordNumber = $row['dwc:recordNumber'];
     $rec->Country = $row['dwc:country'];
     $rec->CountryCode = $row['dwc:countryCode'];
     $rec->StateProvince = $row['dwc:stateProvince'];
     $rec->Locality = $row['dwc:locality'];
     $rec->Latitude = $row['dwc:decimalLatitude'];
     $rec->Longitude = $row['dwc:decimalLongitude'];
     $rec->PixelXDimension = $row['exif:PixelXDimension'];
     $rec->PixelYDimension = $row['exif:PixelYDimension'];
     $rec->HeroImage = $row['HeroImage'];
     $rec->Rating = $row['xmp:Rating'];
     $rec->ThumbnailUrlEnabled = isset($row['ThumbnailUrlEnabled']) && strtolower($row['ThumbnailUrlEnabled']) == 'true' ? TRUE : FALSE;
     $rec->PreviewUrlEnabled = isset($row['PreviewUrlEnabled']) && strtolower($row['PreviewUrlEnabled']) == 'true' ? TRUE : FALSE;
     $tax = $this->findTaxon(Encoding::toUTF8($row['dwc:scientificName']));
     if ($tax) {
         $rec->TaxonID = $tax->TaxonID;
         $rec->AcceptedID = $tax->AcceptedID;
     }
     return $rec;
 }
开发者ID:rbgvictoria,项目名称:vicflora,代码行数:44,代码来源:RoboFlow.php

示例7: nvweb_content_date_format

function nvweb_content_date_format($format = "", $ts)
{
    global $website;
    global $session;
    $out = '';
    setlocale(LC_ALL, $website->languages[$session['lang']]['system_locale']);
    if (empty($format)) {
        $out = date($website->date_format, $ts);
    } else {
        if (strpos($format, '%day') !== false || strpos($format, '%month') !== false || strpos($format, '%year4')) {
            // deprecated: used until Navigate CMS 1.6.7; to be removed in Navigate CMS 2.0
            $out = str_replace('%br', '<br />', $format);
            $out = str_replace('%day', date("d", $ts), $out);
            $out = str_replace('%month_abr', Encoding::toUTF8(strtoupper(strftime("%b", $ts))), $out);
            $out = str_replace('%month', date("m", $ts), $out);
            $out = str_replace('%year4', date("Y", $ts), $out);
        } else {
            if (!empty($ts)) {
                $out = Encoding::toUTF8(strftime($format, intval($ts)));
            }
        }
    }
    return $out;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:24,代码来源:content.php

示例8: caEncodeUTF8Deep

/**
 * Recursively encode array (or string) as UTF8 text
 *
 * @param mixed $pm_input Array or string to encode
 * @return mixed Encoded array or string
 */
function caEncodeUTF8Deep(&$pm_input)
{
    if (is_string($pm_input)) {
        $pm_input = Encoding::toUTF8($pm_input);
    } else {
        if (is_array($pm_input)) {
            foreach ($pm_input as &$vm_value) {
                caEncodeUTF8Deep($vm_value);
            }
            unset($vm_value);
        } else {
            if (is_object($pm_input)) {
                $va_keys = array_keys(get_object_vars($pm_input));
                foreach ($va_keys as $vs_key) {
                    caEncodeUTF8Deep($pm_input->{$vs_key});
                }
            }
        }
    }
    return $pm_input;
}
开发者ID:samrahman,项目名称:providence,代码行数:27,代码来源:utilityHelpers.php

示例9: encodeData

 function encodeData()
 {
     $encoding = mb_detect_encoding($this->data, "ISO-8859-15, ISO-8859-1, UTF-8, ASCII, auto");
     if ($encoding && $encoding != 'UTF-8') {
         $this->data = Encoding::toUTF8($this->data);
     }
 }
开发者ID:dereckson,项目名称:source-templates-generator,代码行数:7,代码来源:page.php

示例10: actualitza

 public function actualitza($courseYear, $date = NULL)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->courseYear = $courseYear;
     $this->sessions = array();
     $timetableDOM = new simple_html_dom();
     //echo $this->courseYear."<br>";
     //echo $timetableDOM->load_file($courseYear->getUrlHorari())."<br>";
     $timetableDOM = file_get_html($courseYear->getUrlHorari());
     if (!($timetableDOM && is_object($timetableDOM) && isset($timetableDOM->nodes))) {
         $this->logger->debug("La pàgina HTML és invàlida: " . $this->courseYear);
         return -1;
     }
     // Date of first week is in the first table, second row, second cell.
     $firstWeek = $timetableDOM->find('table', 0)->find('tr', 1)->find('td', 1)->plaintext;
     $currWeekNum = $this->calculateCurrentWeek($firstWeek, $date);
     $this->logger->info('Current week number is ' . $currWeekNum);
     $currWeekDOM = $timetableDOM->find('table', $currWeekNum);
     if ($date) {
         $currWeekStartDate = $this->weekStartDate(new DateTime($date));
     } else {
         $currWeekStartDate = $this->weekStartDate(new DateTime());
     }
     $this->deleteWeekSessions($currWeekStartDate->format('d.m.Y H:i:s'));
     $this->logger->info("Current week start date is " . $currWeekStartDate->format('d.m.Y H:i:s'));
     //echo "////// /////// /////// Current week start date is ". $currWeekStartDate->format('d.m.Y H:i:s');
     // Create sessions for each period in the timetable and save them to the database.
     $rows = $currWeekDOM->find('tr');
     for ($row = 0; $row < sizeof($rows); $row++) {
         if ($row > 1) {
             $cells = $rows[$row]->find('div');
             $period = new Period($cells[0]->plaintext);
             $period->setCourseYear($this->courseYear);
             $this->logger->info("Start time is " . $period->getStart()->format("H:i:s") . ". End time is " . $period->getEnd()->format("H:i:s"));
             for ($cell = 0; $cell < sizeof($cells); $cell++) {
                 if ($cell > 0) {
                     // Parse the start/end times for this row's period.
                     if (trim($cells[$cell]->plaintext) === '') {
                         $this->logger->debug("Skipping cell [" . $row . "][" . $cell . "], it's empty.");
                         continue;
                     }
                     // Session start date is the week's start date + current day of week. Time is provided in the first cell of each row
                     $sessionStartDateTime = new DateTime($currWeekStartDate->format('d.m.Y'));
                     $sessionStartDateTime->add(new DateInterval('P' . strval($cell - 1) . 'D'));
                     $sessionStartDateTime->setTime($period->getStart()->format('H'), $period->getStart()->format('i'));
                     $period->setStart($sessionStartDateTime);
                     $this->logger->debug('SessionStartDateTime is: ' . $sessionStartDateTime->format('d.m.Y H:i:s'));
                     // Agafem el timestamp de l'hora que acaba la classe i la guardem a la variable period
                     $sessionEndDateTime = new DateTime($currWeekStartDate->format('d.m.Y'));
                     $sessionEndDateTime->add(new DateInterval('P' . strval($cell - 1) . 'D'));
                     $sessionEndDateTime = $sessionEndDateTime->setTime($period->getEnd()->format('H'), $period->getEnd()->format('i'));
                     $period->setEnd($sessionEndDateTime);
                     $this->logger->debug('SessionEndDateTime is: ' . $sessionEndDateTime->format('d.m.Y H:i:s'));
                     //echo "*******LA PRUEBA DEL DELITO: ".$cells[$cell]->plaintext."**********<br>";
                     // Get the plaintext for the period and insert each line into an array.
                     $this->logger->debug("Periodinfoarray is: " . var_export($cells[$cell]->plaintext, true), 'err');
                     $periodInfo = html_entity_decode($cells[$cell]->plaintext, ENT_QUOTES, 'UTF-8');
                     $periodInfo = Encoding::toUTF8($periodInfo);
                     $periodInfoArray = explode("\n", $periodInfo);
                     foreach ($periodInfoArray as $i => $value) {
                         unset($periodInfoArray[$i]);
                         $periodInfoArray[] = trim($value);
                     }
                     // Re-index the array starting from zero.
                     $period->setDetails(array_values($periodInfoArray));
                     $this->logger->debug("Trimmed periodinfoarray is: " . var_export($period->getDetails(), true));
                     //echo "parsejant<br />";
                     $this->parseSession($period);
                 }
             }
             unset($period);
         }
     }
 }
开发者ID:vmorant,项目名称:ttupf,代码行数:74,代码来源:SessioTable.class.php

示例11: nvweb_properties_render

function nvweb_properties_render($property, $vars)
{
    global $website;
    global $current;
    global $DB;
    global $session;
    global $theme;
    global $structure;
    $out = '';
    setlocale(LC_ALL, $website->languages[$session['lang']]['system_locale']);
    // if this property is null (no value assigned (null), (empty) is a value!)
    // get the default value
    if (!isset($property->value)) {
        $property->value = $property->dvalue;
    }
    // check multilanguage properties, where the value can be saved in a language but may be (null) in another language
    if (in_array($property->type, array("text", "textarea", "rich_textarea", "link")) || $property->multilanguage == 'true') {
        // cast variable as array
        if (is_object($property->value)) {
            $property->value = (array) $property->value;
        }
        if (!isset($property->value) || !isset($property->value[$current['lang']])) {
            if (isset($property->dvalue->{$current['lang']})) {
                $property->value[$current['lang']] = $property->dvalue->{$current['lang']};
            } else {
                if (!is_array($property->value)) {
                    $property->value = array();
                }
                $property->value[$current['lang']] = $property->dvalue;
            }
        }
    }
    switch ($property->type) {
        case 'value':
            $out = $property->value;
            break;
        case 'decimal':
            $out = $property->value;
            if (isset($vars['precision'])) {
                $out = number_format($property->value, $vars['precision']);
            }
            break;
        case 'boolean':
            $out = $property->value;
            break;
        case 'option':
            $options = mb_unserialize($property->options);
            $options = (array) $options;
            switch (@$vars['return']) {
                case 'value':
                    $out = $property->value;
                    break;
                default:
                    $out = $theme->t($options[$property->value]);
            }
            break;
        case 'moption':
            $options = mb_unserialize($property->options);
            $selected = explode(",", $property->value);
            switch (@$vars['return']) {
                case 'value':
                case 'values':
                    $out = $property->value;
                    break;
                default:
                    $buffer = array();
                    foreach ($selected as $seloption) {
                        $buffer[] = '<span>' . $theme->t($options[$seloption]) . '</span>';
                    }
                    $out .= implode(', ', $buffer);
            }
            break;
        case 'text':
            $out = htmlspecialchars($property->value[$current['lang']]);
            break;
        case 'textarea':
            $out = nl2br(htmlspecialchars($property->value[$current['lang']]));
            break;
        case 'rich_textarea':
            $out = $property->value[$current['lang']];
            break;
        case 'source_code':
            if (@$property->multilanguage == 'true' || $property->multilanguage == '1') {
                $out = $property->value[$current['lang']];
            } else {
                $out = $property->value;
            }
            break;
        case 'date':
            if (!empty($vars['format'])) {
                $out = Encoding::toUTF8(strftime($vars['format'], $property->value));
            } else {
                $out = date($website->date_format, $property->value);
            }
            break;
        case 'datetime':
            if (!empty($vars['format'])) {
                $out = Encoding::toUTF8(strftime($vars['format'], $property->value));
            } else {
                $out = date($website->date_format . ' H:i', $property->value);
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:properties.php

示例12: nvweb_comments


//.........这里部分代码省略.........
						<div><div class="comments-reply-info">' . $webgets[$webget]['translations']['post_a_comment'] . '</div></div>
						<br />
						<form action="' . NVWEB_ABSOLUTE . '/' . $current['route'] . '" method="post">
							<input type="hidden" name="form-type" value="comment-reply" />
							<div class="comments-reply-field"><label>' . $webgets[$webget]['translations']['name'] . '</label> <input type="text" name="reply-name" value="" /></div>
							<div class="comments-reply-field"><label>' . $webgets[$webget]['translations']['email'] . ' *</label> <input type="text" name="reply-email" value="" /></div>
							<div class="comments-reply-field"><label>' . $webgets[$webget]['translations']['message'] . '</label> <textarea name="reply-message"></textarea></div>
							<!-- {{navigate-comments-reply-extra-fields-placeholder}} -->
							<div class="comments-reply-field comments-reply-field-info-email"><label>&nbsp;</label> * ' . $webgets[$webget]['translations']['email_will_not_be_published'] . '</div>
							<div class="comments-reply-field comments-reply-field-submit"><input class="comments-reply-submit" type="submit" value="' . $webgets[$webget]['translations']['submit'] . '" /></div>
						</form>
					</div>
				';
                $extensions_messages = $events->trigger('comment', 'reply_extra_fields', array('html' => &$out));
                // add any extra field generated
                if (!empty($extensions_messages)) {
                    $extra_fields = array_map(function ($v) {
                        return $v;
                    }, array_values($extensions_messages));
                    $out = str_replace('<!-- {{navigate-comments-reply-extra-fields-placeholder}} -->', implode("\n", $extra_fields), $out);
                }
            } else {
                if ($element->comments_enabled_to > 0 && !empty($webuser->id)) {
                    // Post a comment form (signed in users)
                    if (empty($vars['avatar_size'])) {
                        $vars['avatar_size'] = 32;
                    }
                    $avatar_url = NVWEB_OBJECT . '?type=blank';
                    if (!empty($webuser->avatar)) {
                        $avatar_url = NVWEB_OBJECT . '?wid=' . $website->id . '&id=' . $webuser->avatar . '&amp;disposition=inline&width=' . $vars['avatar_size'] . '&height=' . $vars['avatar_size'];
                    }
                    $out = '
					<div class="comments-reply">
						<div><div class="comments-reply-info">' . $webgets[$webget]['translations']['post_a_comment'] . '</div></div>
						<br />
						<form action="' . NVWEB_ABSOLUTE . '/' . $current['route'] . '" method="post">
							<input type="hidden" name="form-type" value="comment-reply" />
							<div class="comments-reply-field"><label style="display: none;">&nbsp;</label> <img src="' . $avatar_url . '" width="' . $vars['avatar_size'] . '" height="' . $vars['avatar_size'] . '" align="absmiddle" /> <span class="comments-reply-username">' . $webuser->username . '</span><a class="comments-reply-signout" href="?webuser_signout">(x)</a></div>
							<br />
							<div class="comments-reply-field"><label>' . $webgets[$webget]['translations']['message'] . '</label> <textarea name="reply-message"></textarea></div>
							<!-- {{navigate-comments-reply-extra-fields-placeholder}} -->
							<div class="comments-reply-field-submit"><input class="comments-reply-submit" type="submit" value="' . $webgets[$webget]['translations']['submit'] . '" /></div>
						</form>
					</div>
				';
                    $extensions_messages = $events->trigger('comment', 'reply_extra_fields', array('html' => $out));
                    // add any extra field generated
                    if (!empty($extensions_messages)) {
                        $extra_fields = array_map(function ($v) {
                            return $v;
                        }, array_values($extensions_messages));
                        $out = str_replace('<!-- {{navigate-comments-reply-extra-fields-placeholder}} -->', implode("\n", $extra_fields), $out);
                    }
                } else {
                    if ($element->comments_enabled_to == 1) {
                        $out = '<div class="comments-reply">
                            <div class="comments-reply-info">' . $webgets[$webget]['translations']['sign_in_or_sign_up_to_post_a_comment'] . '</div>
                        </div>';
                    } else {
                        $out = '<div class="comments-reply">
                            <div class="comments-reply-info">' . $webgets[$webget]['translations']['comments_on_this_entry_are_closed'] . '</div>
                        </div>';
                    }
                }
            }
            break;
        case 'comments':
            setlocale(LC_ALL, $website->languages[$session['lang']]['system_locale']);
            list($comments, $comments_total) = nvweb_comments_list(0, NULL, NULL, $vars['order']);
            // get all comments of the current entry
            if (empty($vars['avatar_size'])) {
                $vars['avatar_size'] = '48';
            }
            if (empty($vars['date_format'])) {
                $vars['date_format'] = '%d %B %Y %H:%M';
            }
            for ($c = 0; $c < $comments_total; $c++) {
                $avatar = $comments[$c]->avatar;
                if (!empty($avatar)) {
                    $avatar = '<img src="' . NVWEB_OBJECT . '?type=image&id=' . $avatar . '" width="' . $vars['avatar_size'] . 'px" height="' . $vars['avatar_size'] . 'px"/>';
                } else {
                    $avatar = '<img src="data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" width="' . $vars['avatar_size'] . 'px" height="' . $vars['avatar_size'] . 'px"/>';
                }
                $comment = new comment();
                $comment->load_from_resultset(array($comments[$c]));
                $depth = 'data-depth="' . $comment->depth() . '"';
                $out .= '
					<div class="comment"' . $depth . '>
						<div class="comment-avatar">' . $avatar . '</div>
						<div class="comment-username">' . (!empty($comments[$c]->username) ? $comments[$c]->username : $comments[$c]->name) . '</div>
						<div class="comment-date">' . Encoding::toUTF8(strftime($vars['date_format'], $comments[$c]->date_created)) . '</div>
						<div class="comment-message">' . nl2br($comments[$c]->message) . '</div>
						<div style="clear:both"></div>
					</div>
				';
            }
            break;
    }
    return $out;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:comments.php

示例13: retrieveContent

 public function retrieveContent()
 {
     // convert page to utf-8
     $this->setOriginal(Encoding::toUTF8(Utils::get_external_file($this->getUrl(), 15)));
     return $this->getOriginal() != null and strlen($this->getOriginal()) > 0;
 }
开发者ID:Scorry,项目名称:readityourself,代码行数:6,代码来源:Article.php

示例14: parseEntriesCSV

 public function parseEntriesCSV($fp)
 {
     //$lines = explode("\r\n", $txt);
     // assumes that the first line is the header
     //$lines[0] = trim($lines[0], ',');
     try {
         $headers = fgetcsv($fp);
         //$this->parseCSVLine($lines[0]);
     } catch (Exception $err) {
         throw new Exception(str_replace('xx', '0', $err->getMessage()));
     }
     $vals = array();
     $ents = array();
     $fields = array_keys($this->fields);
     $x = 0;
     while ($vals = fgetcsv($fp)) {
         $entry = new EcEntry($this);
         $vars = array_keys(get_object_vars($entry));
         $varLen = count($vars);
         $ent = array_combine($headers, $vals);
         for ($v = 0; $v < $varLen; ++$v) {
             if (array_key_exists($vars[$v], $ent)) {
                 $entry->{$vars}[$v] = $ent[$vars[$v]];
             }
         }
         $ttl = count($fields);
         for ($f = 0; $f < $ttl; ++$f) {
             if ($this->fields[$fields[$f]]->type == 'location' || $this->fields[$fields[$f]]->type == 'gps') {
                 $lat = sprintf('%s_lattitude', $fields[$f]);
                 $lon = sprintf('%s_longitude', $fields[$f]);
                 $alt = sprintf('%s_alttitude', $fields[$f]);
                 $acc = sprintf('%s_accuarcy', $fields[$f]);
                 $src = sprintf('%s_provider', $fields[$f]);
                 $bearing = sprintf('%s_bearing', $fields[$f]);
                 $entry->values[$fields[$f]] = array('latitude' => getValIfExists($ent, $lat), 'longitude' => getValIfExists($ent, $lon), 'altitude' => getValIfExists($ent, $alt), 'accuracy' => getValIfExists($ent, $acc), 'provider' => getValIfExists($ent, $src), 'bearing' => getValIfExists($ent, $bearing));
             } elseif (($this->fields[$fields[$f]]->type == "photo" || $this->fields[$fields[$f]]->type == "video" || $this->fields[$fields[$f]]->type == "audio") && preg_match('/^https?:\\/\\//', $ent[$fields[$f]])) {
                 $newfn = sprintf('%s_%s_%s', $this->projectName, $this->name, $ent[$this->key]);
                 $entry->values[$fields[$f]] = str_replace('~tn', '', $newfn);
                 /*$mqueue->writeMessage('getFile', array($ent[$fields[$f]], $newfn));*/
             } else {
                 if (array_key_exists($fields[$f], $ent)) {
                     $entry->values[$fields[$f]] = Encoding::toUTF8($ent[$fields[$f]]);
                 }
             }
         }
         if (!preg_match('/^[0-9]+$/', $entry->created)) {
             $date = false;
             try {
                 $date = new DateTime($entry->created, new DateTimeZone('UTC'));
             } catch (Exception $ex) {
                 $date = new DateTime('now', new DateTimeZone('UTC'));
             }
             $entry->created = $date->getTimestamp();
         }
         $entry->deviceId = 'web upload';
         array_push($ents, $entry);
         if (++$x % 100 == 0) {
             $entry->postEntries($ents);
             unset($ents);
             $ents = array();
         }
     }
     if (count($ents) > 0) {
         $entry->postEntries($ents);
     }
     return true;
 }
开发者ID:rohantakhar,项目名称:EpiCollectplus,代码行数:67,代码来源:EcTable.php

示例15: fixEncoding

 public function fixEncoding($string = '')
 {
     if (class_exists("Encoding")) {
         try {
             $string1 = Encoding::toUTF8($string);
             return Encoding::fixUTF8($string1);
         } catch (Exception $e) {
             return $string;
         }
     } else {
         return $string;
     }
 }
开发者ID:rafaelurrutia,项目名称:bmonitor-y-bi,代码行数:13,代码来源:libs.basic.php


注:本文中的Encoding::toUTF8方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。