public function importUsers()
 {
     try {
         $raw = fRequest::get('content');
         $this->db = fORMDatabase::retrieve();
         $this->db->query('BEGIN');
         foreach (explode("\n", $raw) as $i) {
             $j = preg_split('/\\s+/', $i);
             if (count($j) < 2) {
                 continue;
             }
             $x = $j[0];
             $y = $j[1];
             $user = new Name();
             $user->setRealname($x);
             $user->setStudentNumber($y);
             $user->store();
         }
         $this->db->query('COMMIT');
         $this->ajaxReturn(array('result' => 'success'));
     } catch (fException $e) {
         if (isset($this->db)) {
             $this->db->query('ROLLBACK');
         }
         $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
     }
 }
Beispiel #2
0
 public function getPeople($ids, $profileDetails)
 {
     $ret = array();
     $query = "select * from user_profile where user_id in (" . implode(',', $ids) . ")";
     $res = mysql_query($query);
     if ($res) {
         while ($row = @mysql_fetch_assoc($res)) {
             $person_id = $row['user_id'];
             $name = new Name($row['first_name'] . ' ' . $row['last_name']);
             $name->setGivenName($row['first_name']);
             $name->setFamilyName($row['last_name']);
             $person = new Person($row['user_id'], $name);
             $person->setProfileUrl($row['profile_url']);
             $date = date($row['date_of_birth']);
             $person->setDateOfBirth($date);
             $address = new Address($row['city']);
             $address->setLocality($row['city']);
             $person->setAddresses($address);
             $interests = $row['interests'];
             $interests = explode(',', $interests);
             $person->setInterests($interests);
             $person->setThumbnailUrl(!empty($row['user_image']) ? $this->url_prefix . $row['user_image'] : '');
             if (!empty($row['Gender'])) {
                 if ($row['Gender'] == 'f') {
                     $person->setGender('FEMALE');
                 } else {
                     $person->setGender('MALE');
                 }
             }
             $ret[$person_id] = $person;
         }
     }
     return $ret;
 }
Beispiel #3
0
 public function addVote($id)
 {
     // INSTANCIATE NAMES CLASS
     $name = new Name();
     // GET THE DATA
     $result = $name->addVote();
     // RETURN RESULT
     return $result;
 }
Beispiel #4
0
/**
 * Callback function to validate data
 * @return bool must return true or other hooks don't get called
 */
function validateName($editPage, $textBox1, $section, &$hookError)
{
    $ns = $editPage->mTitle->getNamespace();
    if ($ns == NS_GIVEN_NAME || $ns == NS_SURNAME) {
        $name = new Name($ns, $editPage->mTitle->getText());
        $name->validate($textBox1, $section, $hookError);
    }
    return true;
}
 public function delete($id)
 {
     try {
         $users = new Name($id);
         if (!UserHelper::isEditor()) {
             throw new fValidationException('not allowed');
         }
         $users->delete();
         $this->ajaxReturn(array('result' => 'success'));
     } catch (fException $e) {
         $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
     }
 }
 public function post(NameRequest $request)
 {
     $name = new Name();
     $name->name = input::get('name');
     $name->email = input::get('email');
     $name->image = input::file('image')->getClientOriginalName();
     $name->created_at = date("y-m-d h:i:s");
     $name->save();
     return Redirect::to('name');
     if (Input::hasFile('image')) {
         $file = Input::file('image');
         $file->move(storage_path() . '/uploads', $file->getClientOriginalName());
     } else {
         return Redirect::to('name');
     }
 }
Beispiel #7
0
 function lookup_names($start, $limit, &$taxon_concept_ids = array())
 {
     debug("querying names");
     $query = "SELECT n.id, n.string FROM names n WHERE n.id ";
     if ($taxon_concept_ids) {
         $query .= "IN (" . implode(",", $taxon_concept_ids) . ")";
     } else {
         $query .= "BETWEEN {$start} AND " . ($start + $limit);
     }
     static $i = 0;
     foreach ($this->mysqli_slave->iterate_file($query) as $row_num => $row) {
         if ($i % 100000 == 0) {
             echo "   ===> {$i} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n";
         }
         $i++;
         $name_id = $row[0];
         $name_string = $row[1];
         if (preg_match("/[0-9]\\/[0-9]/", $name_string, $arr)) {
             if (Name::is_surrogate($name_string)) {
                 continue;
             }
             $canonical_form = trim($this->name_parser->lookup_string($name_string));
             echo "{$name_id}\t{$name_string}\t{$canonical_form}\n";
         }
     }
 }
Beispiel #8
0
 public function filter($value)
 {
     $value = parent::filter($value);
     $value = str_replace('&', 'and', $value);
     $value = \App\Translit\Translit::url($value);
     return trim(preg_replace('#[\\-\\_\\s]+#u', '-', $value), ' -');
 }
 private function lookup_block($start, $limit)
 {
     $query = "SELECT tc.id, n.string, cf.string, he_parent.taxon_concept_id, tr.label FROM taxon_concepts tc JOIN taxon_concept_preferred_entries tcpe ON (tc.id=tcpe.taxon_concept_id) JOIN hierarchy_entries he ON (tcpe.hierarchy_entry_id=he.id) JOIN names n ON (he.name_id=n.id) LEFT JOIN canonical_forms cf ON (n.ranked_canonical_form_id=cf.id) LEFT JOIN hierarchy_entries he_parent ON (he.parent_id=he_parent.id) LEFT JOIN (ranks r JOIN translated_ranks tr ON (r.id = tr.rank_id AND tr.language_id=152)) ON (he.rank_id=r.id) WHERE tc.id BETWEEN {$start} AND " . ($start + $limit) . " AND he.published=1 AND he.visibility_id=1";
     static $j = 0;
     foreach ($this->mysqli->iterate_file($query) as $row_num => $row) {
         if ($j % 50000 == 0) {
             echo "{$start} : {$j} : " . time_elapsed() . " : " . memory_get_usage() . "\n";
         }
         $j++;
         $taxon_concept_id = $row[0];
         $string = trim($row[1]);
         $ranked_canonical_form = trim($row[2]);
         $parent_page_id = $row[3];
         $rank_label = $row[4];
         if (!$parent_page_id || $parent_page_id == "NULL") {
             $parent_page_id = 0;
         }
         if (!$rank_label || $rank_label == "NULL") {
             $rank_label = '';
         }
         $name = null;
         if ($ranked_canonical_form != 'NULL' && !Name::is_surrogate($ranked_canonical_form)) {
             $name = $ranked_canonical_form;
         } elseif ($string != 'NULL') {
             $name = $string;
         }
         if (!$name) {
             continue;
         }
         // echo "$taxon_concept_id : $name : $parent_page_id : $rank_label\n";
         fwrite($this->NAMES_OUT, "{$taxon_concept_id}\t{$name}\t{$parent_page_id}\t{$rank_label}\n");
     }
 }
Beispiel #10
0
 public function DuplicatedName($newName)
 {
     $Name = new Name();
     if (!empty($newName)) {
         $names = $Name->select("id")->where("Name", "like", $newName)->get();
         if (empty($names[0])) {
             // NEWNAME DOESNT EXIST
             return 0;
         } else {
             //NEWNAME ALREADY EXISTS
             echo $Names[0];
             return 1;
         }
     } else {
         //NEWNAME IS EMPTY
         return 0;
     }
 }
 /**
  * Formats a name.
  *
  * @param \Libreworks\Microformats\Name $name The name to format
  * @return string The HTML markup
  */
 public function format(Name $name)
 {
     $names = ['p-honorific-prefix' => $name->getPrefix(), 'p-nickname' => $name->getNick(), 'p-given-name' => $name->getGiven(), 'p-additional-name' => $name->getMiddle(), 'p-family-name' => $name->getSurname(), 'p-honorific-suffix' => $name->getSuffix(), 'p-maiden-name' => $name->getMaiden()];
     $tags = [];
     foreach ($names as $k => $v) {
         if (strlen($v) > 0) {
             $tags[] = '<span class="' . $k . '">' . htmlspecialchars($v) . '</span>';
         }
     }
     $maiden = $name->getMaiden();
     if (strlen($maiden) > 0) {
         $tags[] = '(née <span class="p-maiden-name">' . htmlspecialchars($names['p-maiden-name']) . '</span>)';
     }
     return '<span class="p-name">' . implode(' ', $tags) . '</span>';
 }
Beispiel #12
0
 public function filter($value)
 {
     $value = parent::filter($value);
     $value = preg_replace('~&#x*([0-9a-f]+);~ei', ' ', $value);
     $value = preg_replace('~&#*([0-9]+);~e', ' ', $value);
     $value = preg_replace('#\\(.*?\\)#usi', '', $value);
     $value = str_replace(array('\\', '\\/'), '', $value);
     $value = preg_replace('#[^\\-\\/0-9a-zA-ZА-Яа-яЕЁеёЫы\\&\'\\"]+#usi', ' ', $value);
     $value = preg_replace('#\\s+#usi', ' ', $value);
     return trim(mb_strtolower($value, 'UTF-8'));
 }
Beispiel #13
0
 public function testInNamespace()
 {
     $name = new Name('name\\SPACE\\ClassName');
     $this->assertTrue($name->inNamespace(new Name('name')));
     $this->assertTrue($name->inNamespace(new Name('\\name')));
     $this->assertTrue($name->inNamespace(new Name('NAME')));
     $this->assertTrue($name->inNamespace(new Name('NAME\\sPace')));
     $this->assertFalse($name->inNamespace(new Name('space')));
     $this->assertFalse($name->inNamespace(new Name('NAME\\space\\class')));
 }
 function add_taxon($t)
 {
     $hierarchy_entry = HierarchyEntry::create_entries_for_taxon($t, $this->resource->hierarchy_id);
     if (@(!$hierarchy_entry->id)) {
         return false;
     }
     $this->resource->harvest_event->add_hierarchy_entry($hierarchy_entry, 'inserted');
     $hierarchy_entry->delete_common_names();
     if (@$t['common_names']) {
         foreach ($t['common_names'] as &$c) {
             $name = Name::find_or_create_by_string($c['name']);
             $hierarchy_entry->add_synonym($name->id, SynonymRelation::find_or_create_by_translated_label('common name')->id, @$c['language']->id ?: 0, 0);
         }
     }
     $hierarchy_entry->delete_synonyms();
     if (@$t['synonyms']) {
         foreach ($t['synonyms'] as &$s) {
             $hierarchy_entry->add_synonym($s['name']->id, @$s['synonym_relation']->id ?: 0, 0, 0);
         }
     }
     $hierarchy_entry->delete_agents();
     if (@$t['agents']) {
         $i = 0;
         foreach ($t['agents'] as &$a) {
             $agent = Agent::find_or_create($a);
             if ($agent->logo_url && !$agent->logo_cache_url) {
                 if ($logo_cache_url = $this->content_manager->grab_file($agent->logo_url, "partner")) {
                     $agent->logo_cache_url = $logo_cache_url;
                     $agent->save();
                 }
             }
             $hierarchy_entry->add_agent($agent->id, @$a['agent_role']->id ?: 0, $i);
             unset($a);
             $i++;
         }
     }
     $hierarchy_entry->delete_refs();
     if (@$t['refs']) {
         foreach ($t['refs'] as &$r) {
             if (@$r->id) {
                 $hierarchy_entry->add_reference($r->id);
                 $r->publish();
             }
             unset($r);
         }
     }
     foreach ($t['data_objects'] as &$d) {
         $this->add_data_object($hierarchy_entry, $d);
         unset($d);
     }
     return $hierarchy_entry;
 }
Beispiel #15
0
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('atom') . ':' . 'name':
             $name = new Name();
             $name->transferFromDOM($child);
             $this->_name = $name;
             break;
         case $this->lookupNamespace('atom') . ':' . 'email':
             $email = new Email();
             $email->transferFromDOM($child);
             $this->_email = $email;
             break;
         case $this->lookupNamespace('atom') . ':' . 'uri':
             $uri = new Uri();
             $uri->transferFromDOM($child);
             $this->_uri = $uri;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
Beispiel #16
0
 /**
  * Return a fake username.
  *
  * @param string $name
  * @return string
  */
 public static function userName($name = null)
 {
     if ($name === null) {
         if (rand(1, 10) > 5) {
             $name = Name::firstName() . ' ' . Name::lastName();
         } else {
             $name = Name::firstName();
         }
     }
     $glue = array('.', '_');
     shuffle($glue);
     $nameParts = explode(' ', $name);
     shuffle($nameParts);
     $userName = implode($glue[0], $nameParts);
     return strtolower($userName);
 }
 public function update()
 {
     $pseudos = Name::all();
     $name = Input::get('pseudo');
     $db_name = Name::where('screen_name', '=', $name)->first();
     if (isset($db_name->screen_name) && strtolower($name) == strtolower($db_name->screen_name)) {
         // Le pseudo existe déjà dans la BDD, on affiche directement
         $twitter = Tweet::where('name_id', '=', $db_name->id)->paginate(20);
         return View::make('twitter', compact('twitter', 'pseudos'))->with(['name' => $name]);
     } else {
         $author = Twitter::getUserTimeline(array('screen_name' => $name, 'count' => 1));
         if (isset($author->errors)) {
             $erreur = 'Il n\'existe pas d\'utilisateur au nom de ' . $name;
             return View::make('twitter')->with(['name' => $name, 'erreur' => $erreur]);
         } else {
             // Le pseudo n'existe pas dans la base de donnée, on créé une entrée et on récupère ses tweets favoris
             TwitterFav::createUser($author);
             $name_id = Name::where('screen_name', '=', $author[0]->user->screen_name)->first();
             $req_twitter = Twitter::getFavorites(array('screen_name' => $name, 'count' => 200, 'format' => 'object'));
             if (isset($req_twitter->errors)) {
                 echo 'Trop de requetes, veuillez patienter.';
                 exit;
             }
             while ($req_twitter != 0) {
                 // On ajoute les tweets favoris en BDD
                 $max_id = TwitterFav::addFavoris($req_twitter, $name_id);
                 $req_twitter = Twitter::getFavorites(array('max_id' => $max_id, 'screen_name' => $name, 'count' => 200, 'format' => 'object'));
                 if (isset($req_twitter->errors)) {
                     echo 'Trop de requetes, veuillez patienter.';
                     exit;
                 }
                 sleep(10);
             }
             $twitter = Tweet::where('name_id', '=', $name_id->id)->paginate(25);
             $pseudos = Name::all();
             return View::make('twitter', compact('twitter', 'pseudos'))->with(['name' => $name]);
         }
     }
 }
 /**
  * Extracts attribute contents FROM a parent tree object
  *
  * @param array  $tree an array containing an array FROM which the
  *                     object data should be extracted
  * @param string $ver  represents the version of the GEDCOM standard
  *                     data is being extracted from
  *
  * @return void
  *
  * @access public
  * @since Method available since Release 0.0.1
  */
 public function parse_tree($tree, $ver)
 {
     $this->ver = $ver;
     $this->rp_name->parse_tree($tree, $ver);
     if (isset($tree[0][1])) {
         $sub2 = $tree[0][1];
         $off = 0;
         while (($i1 = parent::find_tag($sub2, Rp_Tags::PHONETIC, $off)) !== false) {
             $name = new RP_Name();
             $name->parse_tree(array($sub2[$i1]), $ver);
             $this->phonetic_names[] = $name;
             $off = $i1 + 1;
         }
         $off = 0;
         while (($i1 = parent::find_tag($sub2, Rp_Tags::ROMANIZED, $off)) !== false) {
             $name = new RP_Name();
             $name->parse_tree(array($sub2[$i1]), $ver);
             $this->romanized_names[] = $name;
             $off = $i1 + 1;
         }
     }
 }
 public static function createUser($author)
 {
     $retour = Name::create(array('id_str' => $author[0]->user->id_str, 'screen_name' => $author[0]->user->screen_name, 'name' => $author[0]->user->name, 'profile_image_url' => $author[0]->user->profile_image_url));
     return $retour;
 }
    $targetUrl = "projects.php";
    header("Location: " . $targetUrl);
}
Data::$queries[1] = array("request" => "getProperty", "constantArgs" => array("propertyName", "/projects/{$projectName}/ec_versioning_artifact"), "result" => "property");
$response = QueryManager::handleQueryNow(1);
$artifactKey = $response->get('value');
Data::$queries["getPickerVersions"] = array("request" => "findObjects", 'searchName' => 'getArtifactVersions', "numObjects" => 10000, "constantArgs" => array("sort", array("propertyName", "version", "order", "descending")), 'constantFilters' => array(array("operator", "and", "filter", array(array('propertyName' => 'groupId', 'operator' => 'equals', "operand1" => 'VersionedProjects'), array('propertyName' => 'artifactKey', 'operator' => 'equals', 'operand1' => $artifactKey)))), "queryClass" => "searchQuery", "result" => 'artifactVersion', "dataIn" => 'searchDataIn');
$response = QueryManager::handleQueryNow('getPickerVersions');
$options = array();
$i = 0;
foreach ($response->getSiblings() as $object) {
    if ($i > 0) {
        $version = $object->get("version");
        $comment = $object->get("description");
        $createTime = DateTimeRenderer::formatText($object->get("createTime"));
        if ($comment == "") {
            $comment = "No commit comment";
        }
        $options[] = $version;
        $options[] = "v{$version} [{$createTime}] - {$comment}";
    }
    $i++;
}
$versionPicker = new Selector($options);
$name = new Name(null, true);
$name->setInitialValue($projectName);
$formElements = array(ecgettext("Name:"), "projectName", $name, ecgettext("Version:"), "version", $versionPicker, ecgettext("Comment:"), "comment", new Entry());
$formArgs = array("id" => "rollbackVersionedProject", "modifyName" => "projectName", "postArgs" => array(), "elements" => $formElements);
$navigation = new NavInfo(array("section" => ecgettext("Projects"), "subsection" => ecgettext("Versioning")));
$page = new Page(ecgettext("Rollback Versioned Project"), new StdFrame($navigation), new Header(array("id" => "pageHeader", "class" => "pageHeader", "title" => ecgettext("Rollback Versioned Project"), "actions" => array(new ShortcutLink()), "actionStyle" => 3)), new SubSection(new Form($formArgs)), new SetFocus("version"), new StdFrameEnd());
$page->show();
Beispiel #21
0
 /**
  * Generate a fake company name.
  *
  * @access public
  * @static
  * @return string Company name
  */
 public static function name()
 {
     return sprintf(self::pickOne(array('%1$s %4$s', '%1$s-%2$s', '%1$s, %2$s and %3$s')), Name::lastName(), Name::lastName(), Name::lastName(), self::suffix());
 }
 public function isEqual(Name $name)
 {
     return $this->name == $name->__toString();
 }
 public static function fromName(Name $name)
 {
     return preg_replace('~\\P{Xan}++~u', '', sprintf($name->toShortFormat()));
 }
 /**
  * Tests Name->setUnstructured()
  */
 public function testSetUnstructured()
 {
     $this->Name->setUnstructured($this->unstructured);
     $this->assertEquals($this->Name->unstructured, $this->unstructured);
 }
Beispiel #25
0
 /**
  * @expectedException        \InvalidArgumentException
  * @expectedExceptionMessage When changing a name you need to pass either a string, an array or a Name node
  */
 public function testInvalidArg()
 {
     $name = new Name('foo');
     $name->set(new \stdClass());
 }
Beispiel #26
0
 public static function isRealStu($realname, $stuid)
 {
     return Name::existid($realname, $stuid);
 }
 public function getPeople($ids, $fields, $options, $token)
 {
     $first = $options->getStartIndex();
     $max = $options->getCount();
     $this->checkDb();
     $ret = array();
     $filterQuery = '';
     $options->setFilterBy(null);
     //DateOfBirth
     $query = "\n\t\tSELECT * FROM `Profiles` WHERE `ID` IN (" . implode(',', $ids) . ") {$filterQuery} ORDER BY `ID`\n\t";
     /*
     		`ID` AS 'id',
     		`NickName` AS 'first_name',
     		`NickName` AS 'last_name',
     		`DescriptionMe` AS 'about_me',
     		20 AS 'age',
     		`DateOfBirth` AS 'date_of_birth',
     		1 AS 'children',
     		'' AS 'ethnicity',
     		'' AS 'fashion',
     		'' AS 'happiest_when',
     		'' AS 'humor',
     		'' AS 'job_interests' 
     */
     $res = mysqli_query($this->db, $query);
     if ($res) {
         while ($row = @mysqli_fetch_array($res, MYSQLI_ASSOC)) {
             $person_id = $row['ID'];
             $sFirstName = isset($row['FirstName']) ? $row['FirstName'] : $row['NickName'];
             $sLastName = isset($row['LastName']) ? $row['LastName'] : '';
             $name = new Name($sFirstName . ' ' . $sLastName);
             $name->setGivenName($sFirstName);
             $name->setFamilyName($sLastName);
             $person = new Person($person_id, $name);
             $person->setDisplayName($name->getFormatted());
             $sAboutMe = isset($row['DescriptionMe']) ? $row['DescriptionMe'] : '';
             $person->setAboutMe($sAboutMe);
             $sDateOfBirth = isset($row['DateOfBirth']) ? date('Y-m-d', $row['DateOfBirth']) : '';
             $sAge = $sDateOfBirth != '' ? $this->bx_getAge($sDateOfBirth) : '';
             $person->setAge($sAge);
             $sChildren = isset($row['Children']) ? $row['Children'] : '';
             $person->setChildren($sChildren);
             $person->setBirthday($sDateOfBirth);
             $sEthnicity = isset($row['Ethnicity']) ? $row['Ethnicity'] : '';
             $person->setEthnicity($sEthnicity);
             $sFashion = isset($row['Fashion']) ? $row['Fashion'] : '';
             $person->setFashion($sFashion);
             $sHappiestWhen = isset($row['HappiestWhen']) ? $row['HappiestWhen'] : '';
             $person->setHappiestWhen($sHappiestWhen);
             $sHumor = isset($row['Humor']) ? $row['Humor'] : '';
             $person->setHumor($sHumor);
             $sJobInterests = isset($row['JobInterests']) ? $row['JobInterests'] : '';
             $person->setJobInterests($sJobInterests);
             $sLivingArrangement = isset($row['LivingArrangement']) ? $row['LivingArrangement'] : '';
             $person->setLivingArrangement($sLivingArrangement);
             $sLookingFor = isset($row['LookingFor']) ? $row['LookingFor'] : '';
             $person->setLookingFor($sLookingFor);
             $sNickName = isset($row['NickName']) ? $row['NickName'] : '';
             $person->setNickname($sNickName);
             $sPets = isset($row['Pets']) ? $row['Pets'] : '';
             $person->setPets($sPets);
             $sPoliticalViews = isset($row['PoliticalViews']) ? $row['PoliticalViews'] : '';
             $person->setPoliticalViews($sPoliticalViews);
             $sProfileSong = isset($row['ProfileSong']) ? $row['ProfileSong'] : '';
             $person->setProfileSong($sProfileSong);
             $person->setProfileUrl($this->url_prefix . '/profile/' . $person_id);
             //'A' TODO
             $sProfileVideo = isset($row['ProfileVideo']) ? $row['ProfileVideo'] : '';
             $person->setProfileVideo($sProfileVideo);
             $sRelationshipStatus = isset($row['RelationshipStatus']) ? $row['RelationshipStatus'] : '';
             $person->setRelationshipStatus($sRelationshipStatus);
             $sReligion = isset($row['Religion']) ? $row['Religion'] : '';
             $person->setReligion($sReligion);
             $sRomance = isset($row['Romance']) ? $row['Romance'] : '';
             $person->setRomance($sRomance);
             $sScaredOf = isset($row['ScaredOf']) ? $row['ScaredOf'] : '';
             $person->setScaredOf($sScaredOf);
             $sSexualOrientation = isset($row['SexualOrientation']) ? $row['SexualOrientation'] : '';
             $person->setSexualOrientation($sSexualOrientation);
             $person->setStatus($row['UserStatus']);
             $person->setThumbnailUrl(!empty($row['thumbnail_url']) ? $this->url_prefix . $row['thumbnail_url'] : '');
             //'A' TODO
             if (!empty($row['thumbnail_url'])) {
                 // also report thumbnail_url in standard photos field (this is the only photo supported by partuza)
                 $person->setPhotos(array(new Photo($this->url_prefix . $row['thumbnail_url'], 'thumbnail', true)));
             }
             $sUtcOffset = isset($row['TimeZone']) ? $row['TimeZone'] : "-00:00";
             $person->setUtcOffset(sprintf('%+03d:00', $sUtcOffset));
             // force "-00:00" utc-offset format
             if (!empty($row['Drinker'])) {
                 $person->setDrinker($row['Drinker']);
             }
             if (!empty($row['Sex'])) {
                 $person->setGender(strtolower($row['Sex']));
             }
             if (!empty($row['Smoker'])) {
                 $person->setSmoker($row['Smoker']);
             }
             /* the following fields require additional queries so are only executed if requested */
             if (isset($fields['activities']) || in_array('@all', $fields)) {
                 $activities = array();
                 //'A' we haven`t activities yet
                 /*$res2 = mysqli_query($this->db, "select activity from person_activities where person_id = " . $person_id);
                   while (list($activity) = @mysqli_fetch_row($res2)) {
                     $activities[] = $activity;
                   }*/
                 $person->setActivities($activities);
             }
             if (isset($fields['addresses']) || in_array('@all', $fields)) {
                 $addresses = array();
                 $sCountry = isset($row['Country']) ? $row['Country'] : '';
                 $sRegion = isset($row['City']) ? $row['City'] : '';
                 //'A'  region -> city
                 $sZip = isset($row['zip']) ? $row['zip'] : '';
                 if (empty($row['unstructured_address'])) {
                     $row['unstructured_address'] = trim($row['street_address'] . " " . $sRegion . " " . $sCountry);
                 }
                 $addres = new Address($row['unstructured_address']);
                 $addres->setCountry($sCountry);
                 if (!empty($row['latitude'])) {
                     $addres->setLatitude($row['latitude']);
                 }
                 if (!empty($row['longitude'])) {
                     $addres->setLongitude($row['longitude']);
                 }
                 if (!empty($row['locality'])) {
                     $addres->setLocality($row['locality']);
                 }
                 $addres->setPostalCode($sZip);
                 $addres->setRegion($sRegion);
                 if (!empty($row['street_address'])) {
                     $addres->setStreetAddress($row['street_address']);
                 }
                 if (!empty($row['street_address'])) {
                     $addres->setType($row['street_address']);
                 }
                 //FIXME quick and dirty hack to demo PC
                 $addres->setPrimary(true);
                 $addresses[] = $addres;
                 $person->setAddresses($addresses);
             }
             if (isset($fields['bodyType']) || in_array('@all', $fields)) {
                 //'A' we haven`t bodyType at all
                 /*$res2 = mysqli_query($this->db, "select * from person_body_type where person_id = " . $person_id);
                   if (@mysqli_num_rows($res2)) {
                     $row = @mysql_fetch_array($res2, MYSQLI_ASSOC);
                     $bodyType = new BodyType();
                     $bodyType->setBuild($row['build']);
                     $bodyType->setEyeColor($row['eye_color']);
                     $bodyType->setHairColor($row['hair_color']);
                     $bodyType->setHeight($row['height']);
                     $bodyType->setWeight($row['weight']);
                     $person->setBodyType($bodyType);
                   }*/
             }
             if (isset($fields['books']) || in_array('@all', $fields)) {
                 //'A' we haven`t books at all
                 /*$books = array();
                   $res2 = mysqli_query($this->db, "select book from person_books where person_id = " . $person_id);
                   while (list($book) = @mysqli_fetch_row($res2)) {
                     $books[] = $book;
                   }
                   $person->setBooks($books);*/
             }
             if (isset($fields['cars']) || in_array('@all', $fields)) {
                 //'A' we haven`t cars at all
                 /*$cars = array();
                   $res2 = mysqli_query($this->db, "select car from person_cars where person_id = " . $person_id);
                   while (list($car) = @mysqli_fetch_row($res2)) {
                     $cars[] = $car;
                   }
                   $person->setCars($cars);*/
             }
             if (isset($fields['currentLocation']) || in_array('@all', $fields)) {
                 //'A' we haven`t currentLocation at all
                 /*$addresses = array();
                   $res2 = mysqli_query($this->db, "select addresses.* from person_current_location, person_addresses, addresses where addresses.id = person_current_location.address_id and person_addresses.person_id = " . $person_id);
                   if (@mysqli_num_rows($res2)) {
                     $row = mysqli_fetch_array($res2, MYSQLI_ASSOC);
                     if (empty($row['unstructured_address'])) {
                       $row['unstructured_address'] = trim($row['street_address'] . " " . $row['region'] . " " . $row['country']);
                     }
                     $addres = new Address($row['unstructured_address']);
                     $addres->setCountry($row['country']);
                     $addres->setLatitude($row['latitude']);
                     $addres->setLongitude($row['longitude']);
                     $addres->setLocality($row['locality']);
                     $addres->setPostalCode($row['postal_code']);
                     $addres->setRegion($row['region']);
                     $addres->setStreetAddress($row['street_address']);
                     $addres->setType($row['address_type']);
                     $person->setCurrentLocation($addres);
                   }*/
             }
             if (isset($fields['emails']) || in_array('@all', $fields)) {
                 $emails = array();
                 //'A' we haven`t multi emails, only single
                 /*$res2 = mysqli_query($this->db, "select address, email_type from person_emails where person_id = " . $person_id);
                   while (list($address, $type) = @mysqli_fetch_row($res2)) {
                     $emails[] = new Email(strtolower($address), $type); // TODO: better email canonicalization; remove dups
                   }
                   $person->setEmails($emails);*/
                 $sEmail = isset($row['Email']) ? $row['Email'] : '';
                 $emails[] = new Email(strtolower($sEmail), 'main');
                 $person->setEmails($emails);
             }
             if (isset($fields['food']) || in_array('@all', $fields)) {
                 //'A' we haven`t food at all
                 /*$foods = array();
                   $res2 = mysqli_query($this->db, "select food from person_foods where person_id = " . $person_id);
                   while (list($food) = @mysqli_fetch_row($res2)) {
                     $foods[] = $food;
                   }
                   $person->setFood($foods);*/
             }
             if (isset($fields['heroes']) || in_array('@all', $fields)) {
                 //'A' we haven`t heroes at all
                 /*$strings = array();
                   $res2 = mysqli_query($this->db, "select hero from person_heroes where person_id = " . $person_id);
                   while (list($data) = @mysqli_fetch_row($res2)) {
                     $strings[] = $data;
                   }
                   $person->setHeroes($strings);*/
             }
             if (isset($fields['interests']) || in_array('@all', $fields)) {
                 //'A' we haven`t interests at all
                 /* $strings = array();
                    $res2 = mysqli_query($this->db, "select interest from person_interests where person_id = " . $person_id);
                    while (list($data) = @mysqli_fetch_row($res2)) {
                      $strings[] = $data;
                    }
                    $person->setInterests($strings);*/
             }
             $organizations = array();
             $fetchedOrg = false;
             if (isset($fields['jobs']) || in_array('@all', $fields)) {
                 //'A' we haven`t jobs at all
                 /*$res2 = mysqli_query($this->db, "select organizations.* from person_jobs, organizations where organizations.id = person_jobs.organization_id and person_jobs.person_id = " . $person_id);
                   while ($row = mysqli_fetch_array($res2, MYSQLI_ASSOC)) {
                     $organization = new Organization();
                     $organization->setDescription($row['description']);
                     $organization->setEndDate($row['end_date']);
                     $organization->setField($row['field']);
                     $organization->setName($row['name']);
                     $organization->setSalary($row['salary']);
                     $organization->setStartDate($row['start_date']);
                     $organization->setSubField($row['sub_field']);
                     $organization->setTitle($row['title']);
                     $organization->setWebpage($row['webpage']);
                     $organization->setType('job');
                     if ($row['address_id']) {
                       $res3 = mysqli_query($this->db, "select * from addresses where id = " . $row['address_id']);
                       if (mysqli_num_rows($res3)) {
                         $row = mysqli_fetch_array($res3, MYSQLI_ASSOC);
                         if (empty($row['unstructured_address'])) {
                           $row['unstructured_address'] = trim($row['street_address'] . " " . $row['region'] . " " . $row['country']);
                         }
                         $addres = new Address($row['unstructured_address']);
                         $addres->setCountry($row['country']);
                         $addres->setLatitude($row['latitude']);
                         $addres->setLongitude($row['longitude']);
                         $addres->setLocality($row['locality']);
                         $addres->setPostalCode($row['postal_code']);
                         $addres->setRegion($row['region']);
                         $addres->setStreetAddress($row['street_address']);
                         $addres->setType($row['address_type']);
                         $organization->setAddress($address);
                       }
                     }
                     $organizations[] = $organization;
                   }
                   $fetchedOrg = true;*/
             }
             if (isset($fields['schools']) || in_array('@all', $fields)) {
                 //'A' we haven`t schools at all
                 /*$res2 = mysqli_query($this->db, "select organizations.* from person_schools, organizations where organizations.id = person_schools.organization_id and person_schools.person_id = " . $person_id);
                   while ($row = mysqli_fetch_array($res2, MYSQLI_ASSOC)) {
                     $organization = new Organization();
                     $organization->setDescription($row['description']);
                     $organization->setEndDate($row['end_date']);
                     $organization->setField($row['field']);
                     $organization->setName($row['name']);
                     $organization->setSalary($row['salary']);
                     $organization->setStartDate($row['start_date']);
                     $organization->setSubField($row['sub_field']);
                     $organization->setTitle($row['title']);
                     $organization->setWebpage($row['webpage']);
                     $organization->setType($row['school']);
                     if ($row['address_id']) {
                       $res3 = mysqli_query($this->db, "select * from addresses where id = " . $row['address_id']);
                       if (mysqli_num_rows($res3)) {
                         $row = mysqli_fetch_array($res3, MYSQLI_ASSOC);
                         if (empty($row['unstructured_address'])) {
                           $row['unstructured_address'] = trim($row['street_address'] . " " . $row['region'] . " " . $row['country']);
                         }
                         $addres = new Address($row['unstructured_address']);
                         $addres->setCountry($row['country']);
                         $addres->setLatitude($row['latitude']);
                         $addres->setLongitude($row['longitude']);
                         $addres->setLocality($row['locality']);
                         $addres->setPostalCode($row['postal_code']);
                         $addres->setRegion($row['region']);
                         $addres->setStreetAddress($row['street_address']);
                         $addres->setType($row['address_type']);
                         $organization->setAddress($address);
                       }
                     }
                     $organizations[] = $organization;
                   }
                   $fetchedOrg = true;*/
             }
             if ($fetchedOrg) {
                 $person->setOrganizations($organizations);
             }
             //TODO languagesSpoken, currently missing the languages / countries tables so can't do this yet
             if (isset($fields['movies']) || in_array('@all', $fields)) {
                 //'A' possible after
                 /*$strings = array();
                   $res2 = mysqli_query($this->db, "select movie from person_movies where person_id = " . $person_id);
                   while (list($data) = @mysqli_fetch_row($res2)) {
                     $strings[] = $data;
                   }
                   $person->setMovies($strings);*/
             }
             if (isset($fields['music']) || in_array('@all', $fields)) {
                 //'A' possible after
                 /*$strings = array();
                   $res2 = mysqli_query($this->db, "select music from person_music where person_id = " . $person_id);
                   while (list($data) = @mysqli_fetch_row($res2)) {
                     $strings[] = $data;
                   }
                   $person->setMusic($strings);*/
             }
             if (isset($fields['phoneNumbers']) || in_array('@all', $fields)) {
                 //'A' we haven`t phoneNumbers at all
                 /*$numbers = array();
                   $res2 = mysqli_query($this->db, "select number, number_type from person_phone_numbers where person_id = " . $person_id);
                   while (list($number, $type) = @mysqli_fetch_row($res2)) {
                     $numbers[] = new Phone($number, $type);
                   }
                   $person->setPhoneNumbers($numbers);*/
             }
             if (isset($fields['ims']) || in_array('@all', $fields)) {
                 //'A' we haven`t ims at all
                 /*$ims = array();
                   $res2 = mysqli_query($this->db, "select value, value_type from person_ims where person_id = " . $person_id);
                   while (list($value, $type) = @mysqli_fetch_row($res2)) {
                     $ims[] = new Im($value, $type);
                   }
                   $person->setIms($ims);*/
             }
             if (isset($fields['accounts']) || in_array('@all', $fields)) {
                 //'A' we haven`t accounts at all
                 /*$accounts = array();
                   $res2 = mysqli_query($this->db, "select domain, userid, username from person_accounts where person_id = " . $person_id);
                   while (list($domain, $userid, $username) = @mysqli_fetch_row($res2)) {
                     $accounts[] = new Account($domain, $userid, $username);
                   }
                   $person->setAccounts($accounts);*/
             }
             if (isset($fields['quotes']) || in_array('@all', $fields)) {
                 //'A' we haven`t quotes at all
                 /*$strings = array();
                   $res2 = mysqli_query($this->db, "select quote from person_quotes where person_id = " . $person_id);
                   while (list($data) = @mysqli_fetch_row($res2)) {
                     $strings[] = $data;
                   }
                   $person->setQuotes($strings);*/
             }
             if (isset($fields['sports']) || in_array('@all', $fields)) {
                 //'A' we haven`t sports at all
                 /*$strings = array();
                   $res2 = mysqli_query($this->db, "select sport from person_sports where person_id = " . $person_id);
                   while (list($data) = @mysqli_fetch_row($res2)) {
                     $strings[] = $data;
                   }
                   $person->setSports($strings);*/
             }
             if (isset($fields['tags']) || in_array('@all', $fields)) {
                 $strings = array();
                 if (!empty($row['latitude'])) {
                     $aProfileTags = preg_split("/[;,\\s]/", $_REQUEST['tags']);
                     foreach ($aProfileTags as $sTag) {
                         $strings[] = $sTag;
                     }
                     /*$res2 = mysqli_query($this->db, "select tag from person_tags where person_id = " . $person_id);
                       while (list($data) = @mysqli_fetch_row($res2)) {
                         $strings[] = $data;
                       }*/
                     $person->setTags($strings);
                 }
             }
             if (isset($fields['turnOns']) || in_array('@all', $fields)) {
                 //'A' we haven`t turnOns at all
                 /*$strings = array();
                   $res2 = mysqli_query($this->db, "select turn_on from person_turn_ons where person_id = " . $person_id);
                   while (list($data) = @mysqli_fetch_row($res2)) {
                     $strings[] = $data;
                   }
                   $person->setTurnOns($strings);*/
             }
             if (isset($fields['turnOffs']) || in_array('@all', $fields)) {
                 //'A' we haven`t turnOffs at all
                 /*$strings = array();
                   $res2 = mysqli_query($this->db, "select turn_off from person_turn_offs where person_id = " . $person_id);
                   while (list($data) = @mysqli_fetch_row($res2)) {
                     $strings[] = $data;
                   }
                   $person->setTurnOffs($strings);*/
             }
             if (isset($fields['urls']) || in_array('@all', $fields)) {
                 //'A' we haven`t urls at all
                 /*$strings = array();
                   $res2 = mysqli_query($this->db, "select url from person_urls where person_id = " . $person_id);
                   while (list($data) = @mysqli_fetch_row($res2)) {
                     $strings[] = new Url($data, null, null);
                   }
                   $strings[] = new Url($this->url_prefix . '/profile/' . $person_id, null, 'profile'); // always include profile URL
                   $person->setUrls($strings);*/
             }
             $ret[$person_id] = $person;
         }
     }
     try {
         $ret = $this->filterResults($ret, $options);
         $ret['totalSize'] = count($ret);
     } catch (Exception $e) {
         $ret['totalSize'] = count($ret) - 1;
         $ret['filtered'] = 'false';
     }
     if ($first !== false && $max !== false && is_numeric($first) && is_numeric($max) && $first >= 0 && $max > 0) {
         $count = 0;
         $result = array();
         foreach ($ret as $id => $person) {
             if ($id == 'totalSize' || $id == 'filtered') {
                 $result[$id] = $person;
                 continue;
             }
             if ($count >= $first && $count < $first + $max) {
                 $result[$id] = $person;
             }
             ++$count;
         }
         return $result;
     } else {
         return $ret;
     }
 }
Beispiel #28
0
 /**
  * Generate a random city name.
  *
  * @access public
  * @static
  * @return string City name
  */
 public static function city()
 {
     return sprintf(self::pickOne(array('%1$s %2$s%4$s', '%1$s %2$s', '%2$s%4$s', '%3$s%4$s')), self::cityPrefix(), Name::firstName(), Name::lastName(), self::citySuffix());
 }

<html>
  <head>
    <title>Costume</title>
  </head>
  <body>
    <?php 
require_once 'CostumeModel.php';
require_once 'CostumeView.php';
if (isset($_POST['costume']) && $_POST['costume'] != '') {
    $myCostume = new Costume();
    $myCostume->setCostume($_POST['costume']);
}
if (isset($_POST['name']) && $_POST['name'] != '') {
    $myName = new Name();
    $myName->setName($_POST['name']);
}
echo $_POST["costume"];
echo " is an awesome costume, ";
echo $_POST["name"];
?>

 </body>
 </html>
 public function insert_vernacular_names($row, $parameters)
 {
     self::debug_iterations("Inserting VernacularName");
     $this->commit_iterations("VernacularName", 500);
     if ($this->archive_validator->has_error_by_line('http://rs.gbif.org/terms/1.0/vernacularname', $parameters['archive_table_definition']->location, $parameters['archive_line_number'])) {
         write_to_resource_harvesting_log("ERROR: insert_vernacular_names: has_error_by_line" . ",file_location:" . $parameters['archive_table_definition']->location . ",line_number:" . $parameters['archive_line_number']);
         return false;
     }
     $taxon_ids = self::get_foreign_keys_from_row($row, 'http://rs.tdwg.org/dwc/terms/taxonID');
     $taxon_info = array();
     if ($taxon_ids) {
         foreach ($taxon_ids as $taxon_id) {
             if ($taxon_info = @$this->taxon_ids_inserted[$taxon_id]) {
                 self::uncompress_array($taxon_info);
                 $taxon_info[] = $taxon_info;
             }
         }
     }
     if (!$taxon_info) {
         return false;
     }
     $vernacularName = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/vernacularName']);
     $source = @self::field_decode($row['http://purl.org/dc/terms/source']);
     $languageString = @self::field_decode($row['http://purl.org/dc/terms/language']);
     $locality = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/locality']);
     $countryCode = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/countryCode']);
     $isPreferredName = @self::field_decode($row['http://rs.gbif.org/terms/1.0/isPreferredName']);
     $taxonRemarks = @self::field_decode($row['http://rs.tdwg.org/dwc/terms/taxonRemarks']);
     $name = Name::find_or_create_by_string($vernacularName);
     $language = Language::find_or_create_for_parser($languageString);
     if (!$name) {
         return false;
     }
     foreach ($taxon_info as $info) {
         $he_id = $taxon_info['hierarchy_entry_id'];
         $tc_id = $taxon_info['taxon_concept_id'];
         $common_name_relation = SynonymRelation::find_or_create_by_translated_label('common name');
         $result = $this->mysqli->query("SELECT SQL_NO_CACHE id FROM synonyms" . " WHERE name_id = " . $name->id . " AND synonym_relation_id = " . $common_name_relation->id . " AND hierarchy_entry_id = " . $he_id . " AND hierarchy_id = " . $this->harvest_event->resource->hierarchy_id . " AND identifier = " . $taxon_ids[0]);
         if ($result && $result->fetch_assoc()) {
             $l_id = @$language->id ?: 0;
             $GLOBALS['db_connection']->update("UPDATE synonyms SET" . " language_id = " . $l_id . ", published = 0" . ", taxon_remarks = '" . $taxonRemarks . "' WHERE name_id = " . $name->id . " AND synonym_relation_id = " . $common_name_relation->id . " AND hierarchy_entry_id = " . $he_id . " AND hierarchy_id = " . $this->harvest_event->resource->hierarchy_id . "AND identifier = " . $taxon_ids[0]);
             break;
         } else {
             Synonym::find_or_create(array('name_id' => $name->id, 'synonym_relation_id' => $common_name_relation->id, 'language_id' => @$language->id ?: 0, 'hierarchy_entry_id' => $he_id, 'preferred' => $isPreferredName != '', 'hierarchy_id' => $this->harvest_event->resource->hierarchy_id, 'vetted_id' => 0, 'published' => 0, 'taxonRemarks' => $taxonRemarks, 'identifier' => $taxon_ids[0]));
             break;
         }
     }
 }