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


PHP Alias::save方法代码示例

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


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

示例1: postProcess

 public function postProcess()
 {
     if (isset($_POST['submitAdd' . $this->table])) {
         $search = strval(Tools::getValue('search'));
         $string = strval(Tools::getValue('alias'));
         $aliases = explode(',', $string);
         if (empty($search) or empty($string)) {
             $this->_errors[] = $this->l('aliases and result are both required');
         }
         if (!Validate::isValidSearch($search)) {
             $this->_errors[] = $search . ' ' . $this->l('is not a valid result');
         }
         foreach ($aliases as $alias) {
             if (!Validate::isValidSearch($alias)) {
                 $this->_errors[] = $alias . ' ' . $this->l('is not a valid alias');
             }
         }
         if (!sizeof($this->_errors)) {
             foreach ($aliases as $alias) {
                 $obj = new Alias(NULL, trim($alias), trim($search));
                 $obj->save();
             }
         }
     } else {
         parent::postProcess();
     }
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:27,代码来源:AdminAliases.php

示例2: execute

 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $db = Doctrine_Manager::connection();
     $q = LsDoctrineQuery::create()->from('Entity e')->leftJoin('e.Alias a')->where('NOT EXISTS( SELECT id FROM alias a WHERE a.entity_id = e.id AND a.context IS NULL AND a.name = e.name)')->limit($options['limit']);
     foreach ($q->execute() as $entity) {
         try {
             $db->beginTransaction();
             $primary = $entity->primary_ext;
             if ($primary == 'Person') {
                 $name = $entity->getExtensionObject('Person')->getFullName(false, $filterSuffix = true);
                 //change entity name
                 $entity->setEntityField('name', $name);
                 $entity->save();
             } else {
                 $name = $entity->rawGet('name');
             }
             //create primary Alias
             $a = new Alias();
             $a->Entity = $entity;
             $a->name = $name;
             $a->is_primary = true;
             $a->save();
             //create another Alias if there's a nickname
             if ($primary == 'Person' && $entity->name_nick) {
                 $a = new Alias();
                 $a->Entity = $entity;
                 $a->name = $primary == 'Person' ? $entity->name_nick . ' ' . $entity->name_last : $entity->name_nick;
                 $a->is_primary = false;
                 $a->save();
             }
             $db->commit();
         } catch (Exception $e) {
             $db->rollback();
             throw $e;
         }
     }
     LsCli::beep();
 }
开发者ID:silky,项目名称:littlesis,代码行数:41,代码来源:GenerateNamesTask.class.php

示例3: import

 public function import($school)
 {
     if (EntityTable::getByExtensionQuery('Org')->addWhere('LOWER(org.name) LIKE ?', '%' . strtolower($school->instnm) . "%")->fetchOne()) {
         $this->printDebug("School exists in database: " . $school->instnm);
     } else {
         $address = new Address();
         $address->street1 = isset($school->addr) ? $school->addr : null;
         $address->street2 = isset($school->street2) ? $school->street2 : null;
         $address->city = $school->city;
         if ($state = AddressStateTable::retrieveByText($school->stabbr)) {
             $address->State = $state;
         }
         $address->postal = $school->zip;
         $aliases = explode("|", $school->ialias);
         $website = null;
         if (!preg_match('/^http\\:\\/\\//i', trim($school->webaddr))) {
             $website = "http://" . strtolower($school->webaddr);
         }
         $this->printDebug($website);
         $newschool = new Entity();
         $newschool->addExtension('Org');
         $newschool->addExtension('School');
         $newschool->name = $school->instnm;
         $newschool->website = $website;
         $newschool->addAddress($address);
         $newschool->save();
         foreach ($aliases as $alias) {
             try {
                 $newalias = new Alias();
                 $newalias->Entity = $newschool;
                 $newalias->name = $alias;
                 $newalias->save();
             } catch (Exception $e) {
                 $this->printDebug("An alias exception. No biggie. It's most likely that the name already exists. so we ignore it and move on: " . $e);
             }
         }
         $this->printDebug("Adding new school: " . $school->instnm);
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:39,代码来源:SchoolScraper.class.php

示例4: execute

 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $db = Doctrine_Manager::connection();
     //CREATE NEW PRIMARY ALIASES
     $q = Doctrine_Query::create()->from('Entity e')->where('NOT EXISTS (SELECT id FROM Alias a WHERE a.entity_id = e.id AND a.is_primary = ?)', true)->limit($options['limit']);
     foreach ($q->fetchArray() as $entity) {
         $a = new Alias();
         $a->name = $entity['name'];
         $a->is_primary = true;
         $a->entity_id = $entity['id'];
         $a->save(false);
     }
     //REMOVE DUPLIATE PRIMARY ALIASES
     $q = Doctrine_Query::create()->from('Alias a1')->where('a1.is_primary = ?', true)->andWhere('EXISTS (SELECT a2.id FROM Alias a2 WHERE a1.entity_id = a2.entity_id AND a2.is_primary = ? AND a1.id > a2.id)', true);
     foreach ($q->execute() as $alias) {
         $alias->delete();
     }
     //DONE
     LsCli::beep();
 }
开发者ID:silky,项目名称:littlesis,代码行数:23,代码来源:CleanupPrimaryAliasesTask.class.php

示例5: import


//.........这里部分代码省略.........
                                 }
                             }
                             if (isset($info_box['faculty']) && preg_match('/([\\d\\,]{2,})/isu', $info_box['faculty']['clean'], $match)) {
                                 $new_school->faculty = LsNumber::clean($match[1]);
                             }
                             if (isset($info_box['type'])) {
                                 if (stristr($info_box['type']['clean'], 'public')) {
                                     $new_school->is_private = 0;
                                 } else {
                                     if (stristr($info_box['type']['clean'], 'private')) {
                                         $new_school->is_private = 1;
                                     }
                                 }
                             }
                             if (isset($info_box['endowment'])) {
                                 if (preg_match('/(\\$[\\d\\,\\.\\s]+)(million|billion)/isu', $info_box['endowment']['clean'], $match)) {
                                     if (strtolower($match[2]) == 'billion') {
                                         $factor = 1000000000;
                                     } else {
                                         $factor = 1000000;
                                     }
                                     $new_school->endowment = LsNumber::formatDollarAmountAsNumber($match[1], $factor);
                                 }
                             }
                             if (isset($info_box['established'])) {
                                 $year = null;
                                 if ($date = LsDate::convertDate($info_box['established']['clean'])) {
                                     $new_school->start_date = $date;
                                 } else {
                                     if (preg_match('/\\b(\\d\\d\\d\\d)\\b/isu', $info_box['established']['clean'], $match)) {
                                         $new_school->start_date = $match[1];
                                     }
                                 }
                             }
                             $summary = trim($wikipedia->getIntroduction());
                             $summary = preg_replace('/\\n\\s*\\n/isu', '', $summary);
                             if (strlen($summary) > 10) {
                                 $new_school->summary = $summary;
                             }
                             $new_school->save();
                             $new_school->addReference($source = $wikipedia->getUrl(), $excerpt = null, $fields = array('summary'), $name = 'Wikipedia');
                         } else {
                             $new_school->save();
                         }
                         $current_school = $new_school;
                         $this->printDebug('Adding new school');
                     }
                     $alias = new Alias();
                     $alias->name = $school->institution;
                     $alias->context = 'bw_school';
                     $alias->Entity = $current_school;
                     $alias->save();
                 }
                 //find degree
                 $degree = null;
                 if (!($degree = DegreeTable::getByText($school->degree))) {
                     $degree = DegreeTable::addDegree($school->degree);
                     $this->printDebug('Adding new degree');
                 }
                 //find relationship
                 $relationship = null;
                 $relationships = $person->getRelationshipsWithQuery($current_school, RelationshipTable::EDUCATION_CATEGORY)->execute();
                 foreach ($relationships as $existing_relationship) {
                     if ($existing_relationship->degree_id == $degree->id) {
                         $relationship = $existing_relationship;
                         break;
                     }
                 }
                 if ($relationship) {
                     $this->printDebug('Relationship between person and school exists');
                 } else {
                     $relationship = new Relationship();
                     $relationship->Entity1 = $person;
                     $relationship->Entity2 = $current_school;
                     $relationship->description1 = 'student';
                     $relationship->is_current = 0;
                     if ($school->year) {
                         $relationship->end_date = $school->year;
                     }
                     $relationship->setCategory('Education');
                     $this->printDebug('Creating new relationship between person and school');
                 }
                 //save
                 $relationship->save();
                 //add degree and reference
                 if ($relationship->degree_id == null) {
                     $reference_name = strstr($school->source, 'wikipedia') ? "Wikipedia" : "BusinessWeek";
                     $relationship->Degree = $degree;
                     $relationship->save();
                     $relationship->addReference($source = $school->source, $excerpt = null, $fields = array('degree_id'), $name = $reference_name, $detail = null, $date = null);
                     $this->printDebug('Adding degree and reference');
                 }
             }
         } else {
             $this->printDebug('No organization matches');
             return false;
         }
     }
     return true;
 }
开发者ID:silky,项目名称:littlesis,代码行数:101,代码来源:EducationScraper.class.php

示例6: editAction

 /**
  * Edit a mailbox.
  */
 public function editAction()
 {
     if (!$this->_mailbox) {
         $this->_mailbox = new Mailbox();
     }
     $this->view->mailboxModel = $this->_mailbox;
     $domainList = DomainTable::getDomains($this->getAdmin());
     $editForm = new ViMbAdmin_Form_Mailbox_Edit(null, $domainList);
     $editForm->setDefaults($this->_mailbox->toArray());
     if ($this->_mailbox['id']) {
         $editForm->removeElement('password');
         $editForm->getElement('local_part')->setAttrib('disabled', 'disabled')->setRequired(false);
         $editForm->getElement('domain')->setAttrib('disabled', 'disabled')->setRequired(false);
     } else {
         $editForm->getElement('domain')->setValue($this->_domain->id);
     }
     if ($this->getRequest()->isPost() && $editForm->isValid($_POST)) {
         do {
             // do we have a domain
             if (!$this->_domain) {
                 $this->_domain = Doctrine::getTable('Domain')->find($editForm->getElement('domain')->getValue());
                 if (!$this->_domain || !$this->authorise(false, $this->_domain, false)) {
                     $this->addMessage(_("Invalid, unauthorised or non-existent domain."), ViMbAdmin_Message::ERROR);
                     $this->_redirect('domain/list');
                 }
             }
             if ($this->_mailbox['id']) {
                 $this->_domain = $this->_mailbox->Domain;
                 $editForm->removeElement('local_part');
                 $editForm->removeElement('domain');
                 $editForm->removeElement('password');
                 $this->_mailbox->fromArray($editForm->getValues());
                 $op = 'edit';
             } else {
                 // do we have available mailboxes?
                 if (!$this->getAdmin()->isSuper() && $this->_domain['mailboxes'] != 0 && $this->_domain->countMailboxes() >= $this->_domain['mailboxes']) {
                     $this->_helper->viewRenderer->setNoRender(true);
                     $this->addMessage(_('You have used all of your allocated mailboxes.'), ViMbAdmin_Message::ERROR);
                     break;
                 }
                 $this->_mailbox->fromArray($editForm->getValues());
                 $this->_mailbox['domain'] = $this->_domain['domain'];
                 $this->_mailbox['username'] = "{$this->_mailbox['local_part']}@{$this->_mailbox['domain']}";
                 $this->_mailbox['homedir'] = $this->_options['defaults']['mailbox']['homedir'];
                 $this->_mailbox['uid'] = $this->_options['defaults']['mailbox']['uid'];
                 $this->_mailbox['gid'] = $this->_options['defaults']['mailbox']['gid'];
                 $this->_mailbox->formatMaildir($this->_options['defaults']['mailbox']['maildir']);
                 $plainPassword = $this->_mailbox['password'];
                 $this->_mailbox->hashPassword($this->_options['defaults']['mailbox']['password_scheme'], $this->_mailbox['password'], $this->_options['defaults']['mailbox']['password_hash']);
                 // is the mailbox address valid?
                 if (!Zend_Validate::is("{$this->_mailbox['local_part']}@{$this->_mailbox['domain']}", 'EmailAddress', array(1, null))) {
                     $editForm->getElement('local_part')->addError(_('Invalid email address.'));
                     break;
                 }
                 // does a mailbox of the same name exist?
                 $dup = Doctrine_Query::create()->from('Mailbox m')->where('m.local_part = ?', $this->_mailbox['local_part'])->andWhere('m.domain = ?', $this->_mailbox['domain'])->execute(null, Doctrine_Core::HYDRATE_ARRAY);
                 if (count($dup)) {
                     $this->addMessage(_('Mailbox already exists for') . " {$this->_mailbox['local_part']}@{$this->_mailbox['domain']}", ViMbAdmin_Message::ERROR);
                     break;
                 }
                 if ($this->_options['mailboxAliases'] == 1) {
                     $aliasModel = new Alias();
                     $aliasModel->address = $this->_mailbox['username'];
                     $aliasModel->goto = $this->_mailbox['username'];
                     $aliasModel->domain = $this->_domain['domain'];
                     $aliasModel->active = 1;
                     $aliasModel->save();
                 }
                 $op = 'add';
             }
             // check quota
             if ($this->_domain['quota'] != 0) {
                 if ($this->_mailbox['quota'] <= 0 || $this->_mailbox['quota'] > $this->_domain['quota']) {
                     $this->_mailbox['quota'] = $this->_domain['quota'];
                     $this->addMessage(_("Mailbox quota set to ") . $this->_domain['quota'], ViMbAdmin_Message::ALERT);
                 }
             }
             $this->_mailbox->save();
             if ($editForm->getValue('welcome_email')) {
                 if (!$this->_sendSettingsEmail($editForm->getValue('cc_welcome_email') ? $editForm->getValue('cc_welcome_email') : false, $plainPassword, true)) {
                     $this->addMessage(_('Could not sent welcome email'), ViMbAdmin_Message::ALERT);
                 }
             }
             LogTable::log('MAILBOX_' . ($op == 'add' ? 'ADD' : 'EDIT'), print_r($this->_mailbox->toArray(), true), $this->getAdmin(), $this->_mailbox['domain']);
             $this->_helper->viewRenderer->setNoRender(true);
             $this->addMessage(_('You have successfully added/edited the mailbox record.'), ViMbAdmin_Message::SUCCESS);
             return print $this->view->render('close_colorbox_reload_parent.phtml');
         } while (false);
         // break-able clause
     }
     if ($this->_domain) {
         $editForm->getElement('domain')->setValue($this->_domain['id']);
     }
     $this->view->editForm = $editForm;
 }
开发者ID:nereliz,项目名称:ViMbAdmin,代码行数:98,代码来源:MailboxController.php

示例7: executeAddAlias

 public function executeAddAlias($request)
 {
     if (!$request->isMethod('post')) {
         $this->forward('error', 'invalid');
     }
     $this->checkEntity($request, false, false);
     if (!($name = $request->getParameter('alias'))) {
         $request->setError('alias', 'Alias is required');
         $this->setTemplate('editAliases');
         return sfView::SUCCESS;
     }
     $alias = new Alias();
     $alias->entity_id = $this->entity->id;
     $alias->name = $name;
     if ($context = $request->getParameter('context')) {
         $alias->context = $context;
     }
     $alias->save();
     $this->clearCache($this->entity);
     $this->redirect($this->entity->getInternalUrl('editAliases'));
 }
开发者ID:silky,项目名称:littlesis,代码行数:21,代码来源:actions.class.php

示例8: disable_alias

 public static function disable_alias($aliasId)
 {
     if (!Validate::isUnsignedId($aliasId)) {
         echo "Error, {$aliasId} is not a valid alias ID\n";
         return false;
     }
     $alias = new Alias($aliasId);
     if (!$alias->active) {
         echo "alias {$aliasId} is already disabled\n";
         return true;
     }
     $alias->active = false;
     if ($alias->save()) {
         echo "Sucessfully disabled alias {$aliasId}\n";
         return true;
     } else {
         echo "Could not disable alias {$aliasId}\n";
         return false;
     }
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:20,代码来源:search.php

示例9: Alias

//next, delete and then re-insert the aliases
$alias = new Alias();
foreach ($resource->getAliases() as $alias) {
    $alias->delete();
}
$aliasTypeArray = array();
$aliasTypeArray = explode(':::', $_POST['aliasTypes']);
$aliasNameArray = array();
$aliasNameArray = explode(':::', $_POST['aliasNames']);
foreach ($aliasTypeArray as $key => $value) {
    if ($value && $aliasNameArray[$key]) {
        $alias = new Alias();
        $alias->resourceID = $resourceID;
        $alias->aliasTypeID = $value;
        $alias->shortName = $aliasNameArray[$key];
        $alias->save();
    }
}
//now delete and then re-insert the organizations
$resource->removeResourceOrganizations();
$organizationRoleArray = array();
$organizationRoleArray = explode(':::', $_POST['organizationRoles']);
$organizationArray = array();
$organizationArray = explode(':::', $_POST['organizations']);
foreach ($organizationRoleArray as $key => $value) {
    if ($value && $organizationArray[$key]) {
        $resourceOrganizationLink = new ResourceOrganizationLink();
        $resourceOrganizationLink->resourceID = $resourceID;
        $resourceOrganizationLink->organizationRoleID = $value;
        $resourceOrganizationLink->organizationID = $organizationArray[$key];
        $resourceOrganizationLink->save();
开发者ID:billdueber,项目名称:resources,代码行数:31,代码来源:submitProductUpdate.php

示例10: importIn


//.........这里部分代码省略.........
                 }
             }
         }
     }
     if ($validTemplateStructure || !$validate) {
         //*** Import elements
         foreach ($objDoc->childNodes as $rootNode) {
             foreach ($rootNode->childNodes as $logicNode) {
                 if ($logicNode->nodeName == "logic") {
                     foreach ($logicNode->childNodes as $childNode) {
                         switch ($childNode->nodeName) {
                             case "languages":
                                 // Get all languages
                                 $arrCurrentLangs = array();
                                 $objContentLangs = ContentLanguage::select();
                                 $objDefaultLang = NULL;
                                 foreach ($objContentLangs as $objContentLang) {
                                     $arrCurrentLangs[$objContentLang->getAbbr()] = $objContentLang->getId();
                                     if ($objContentLang->default == 1) {
                                         $objDefaultLang = $objContentLang;
                                     }
                                 }
                                 $arrLanguageIds[0] = 0;
                                 // loop trough languages from export
                                 foreach ($childNode->childNodes as $languageNode) {
                                     // if abbreviations match, use that language ID
                                     if (array_key_exists($languageNode->getAttribute('abbr'), $arrCurrentLangs)) {
                                         $arrLanguageIds[$languageNode->getAttribute("id")] = $arrCurrentLangs[$languageNode->getAttribute('abbr')];
                                     } else {
                                         // if no match, use default current language
                                         $arrLanguageIds[$languageNode->getAttribute("id")] = $arrCurrentLangs[$objDefaultLang->getAbbr()];
                                     }
                                 }
                                 break;
                             case "templates":
                                 if ($importTemplates) {
                                     //*** Add templates to the account.
                                     self::importTemplates($childNode, $_CONF['app']['account']->getId(), $arrTemplateIds, $arrTemplateFieldIds, $arrLinkFieldIds, $intTemplateId);
                                 }
                                 break;
                             case "elements":
                                 if ($importElements) {
                                     if ($intElementId == NULL) {
                                         $strSql = sprintf("SELECT * FROM pcms_element WHERE templateId = '%s' AND accountId = '%s' ORDER BY sort LIMIT 1", $intTemplateId, $intAccountId);
                                         $objElements = Element::select($strSql);
                                         foreach ($objElements as $objElement) {
                                             self::importElements($childNode, $intAccountId, $arrTemplateIds, $arrTemplateFieldIds, $arrElementIds, $arrElementFieldIds, $arrLinkFieldIds, $arrLanguageIds, $arrUserIds, $arrGroupIds, $arrStorageIds, $arrFeedIds, $objElement->getId());
                                         }
                                     } else {
                                         self::importElements($childNode, $intAccountId, $arrTemplateIds, $arrTemplateFieldIds, $arrElementIds, $arrElementFieldIds, $arrLinkFieldIds, $arrLanguageIds, $arrUserIds, $arrGroupIds, $arrStorageIds, $arrFeedIds, $intElementId);
                                     }
                                 }
                                 break;
                             case "aliases":
                                 if ($importElements) {
                                     //*** Add aliases to the account.
                                     foreach ($childNode->childNodes as $aliasNode) {
                                         if (in_array($aliasNode->getAttribute("url"), $arrElementIds)) {
                                             $objAlias = new Alias();
                                             $objAlias->setAccountId($_CONF['app']['account']->getId());
                                             $objAlias->setAlias($aliasNode->getAttribute("alias"));
                                             $objAlias->setUrl($arrElementIds[$aliasNode->getAttribute("url")]);
                                             $objAlias->setLanguageId($arrLanguageIds[$aliasNode->getAttribute("language")]);
                                             // check for existence of alias
                                             $objTmpAliases = Alias::selectByAlias($aliasNode->getAttribute("alias"));
                                             $objTmpAlias = $objTmpAliases->current();
                                             if (!is_object($objTmpAlias)) {
                                                 $objAlias->setCascade($aliasNode->getAttribute("cascade"));
                                                 $objAlias->setActive($aliasNode->getAttribute("active"));
                                                 $objAlias->setSort($aliasNode->getAttribute("sort"));
                                                 $objAlias->setCreated($aliasNode->getAttribute("created"));
                                                 $objAlias->setModified($aliasNode->getAttribute("modified"));
                                                 $objAlias->save();
                                             }
                                         }
                                     }
                                 }
                                 break;
                         }
                         if ($importElements) {
                             //*** Adjust the links for deeplink fields.
                             self::adjustDeeplinks($arrElementFieldIds["link"], $arrElementIds, $arrLanguageIds);
                             //*** Adjust the links in large text fields.
                             self::adjustTextlinks($arrElementFieldIds["largeText"], $arrElementIds, $arrLanguageIds, array(0));
                         }
                     }
                 }
             }
         }
         //*** Import files
         $objAccount = Account::selectByPK($_CONF['app']['account']->getId());
         if ($blnZip && is_object($objAccount) && $importElements) {
             self::importFiles($objZip, $objAccount);
             //*** Move files to remote server.
             self::moveImportedFiles($objAccount);
         }
         return true;
     }
     return false;
 }
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:class.impex.php

示例11: importFiling

 private function importFiling($org, $lda_filing)
 {
     try {
         $this->printTimeSince();
         $this->printDebug('Starting import...');
         $excerpt = array();
         //$time = microtime(1);
         $this->db->beginTransaction();
         $date = null;
         $excerpt['Federal Filing Id'] = $lda_filing->federal_filing_id;
         $excerpt['Year'] = $lda_filing->year;
         $excerpt['Type'] = $lda_filing->LdaType->description;
         if (preg_match('/^[^T]*/su', $lda_filing->received, $match)) {
             $date = $match[0];
             $date = str_replace('/', '-', $date);
         }
         $lda_registrant = Doctrine::getTable('LdaRegistrant')->find($lda_filing->registrant_id);
         $excerpt['Registrant'] = $lda_registrant->name;
         if ($lda_filing->client_id) {
             $lda_client = Doctrine::getTable('LdaClient')->find($lda_filing->client_id);
             $excerpt['Client'] = $lda_client->name;
         } else {
             $this->db->rollback();
             return null;
         }
         $lobbying_entity = null;
         //DETERMINE (& CREATE) LOBBYING ENTITY
         //$this->printTimeSince();
         //$this->printDebug('determine/create...');
         if (strtolower(OrgTable::stripNamePunctuation($lda_client->name)) == strtolower(OrgTable::stripNamePunctuation($lda_registrant->name))) {
             $lobbying_entity = $org;
             $client_entity = null;
             if (!$lobbying_entity->lda_registrant_id) {
                 $lobbying_entity->lda_registrant_id = $lda_registrant->federal_registrant_id;
                 $lobbying_entity->save();
                 $lobbying_entity->addReference(self::$filing_url . $lda_filing->federal_filing_id, null, $lobbying_entity->getAllModifiedFields(), 'LDA Filing', null, $date, false);
             } else {
                 if ($lobbying_entity->lda_registrant_id != $lda_registrant->federal_registrant_id) {
                     $this->printDebug("LDA registrant ids did not match up for {$lobbying_entity->name} and {$lda_registrant->name} even though names matched {$lda_client->name}\n");
                     $this->db->rollback();
                     return null;
                 }
             }
             $this->printDebug($lobbying_entity->name . ' noted (same as client ' . $lda_client->name . ')');
         } else {
             $client_entity = $org;
             if ($lda_client->description) {
                 $description = trim($lda_client->description);
                 if ($description != '' && preg_match('/[\\/\\-]\\d+[\\/\\-]/isu', $description) == 0) {
                     if (strlen($description) < 200) {
                         if (!$org->blurb || $org->blurb == '') {
                             $org->blurb = $description;
                         }
                     } else {
                         if (!$org->summary || $org->summary == '') {
                             $org->summary = $description;
                         }
                     }
                 }
             }
             $org->save();
             $this->printDebug($lda_client->name . ' is distinct from ' . $lda_registrant->name);
         }
         $lda_lobbyists = $lda_filing->LdaLobbyists;
         $excerpt['Lobbyists'] = array();
         foreach ($lda_lobbyists as $lda_lobbyist) {
             $excerpt['Lobbyists'][] = $lda_lobbyist->name;
         }
         $excerpt['Lobbyists'] = implode('; ', $excerpt['Lobbyists']);
         if (!$lobbying_entity) {
             $lobbyist_name = null;
             if (count($lda_lobbyists)) {
                 $lobbyist_parts = explode(',', $lda_lobbyists[0]->name);
                 if (count($lobbyist_parts) > 1) {
                     $lobbyist_last = trim($lobbyist_parts[0]);
                     $arr = LsString::split($lobbyist_parts[1]);
                     $lens = array_map('strlen', $arr);
                     arsort($lens);
                     $keys = array_keys($lens);
                     $lobbyist_longest = $arr[$keys[0]];
                     $lobbyist_name = trim($lobbyist_parts[1]) . ' ' . trim($lobbyist_parts[0]);
                     $existing_lobbyist_registrant = null;
                 } else {
                     $lobbyist_name = preg_replace('/^(Mr|MR|MS|Dr|DR|MRS|Mrs|Ms)\\b\\.?/su', '', $lda_lobbyists[0]->name);
                     $arr = LsString::split(trim($lobbyist_name));
                     $arr = LsArray::strlenSort($arr);
                     $lobbyist_last = array_pop($arr);
                     if (count($arr)) {
                         $lobbyist_longest = array_shift(LsArray::strlenSort($arr));
                     } else {
                         $lobbyist_longest = '';
                     }
                 }
             }
             //check to see if registrant and lobbyist are same
             if (count($lda_lobbyists) == 1 && (strtoupper($lda_lobbyists[0]->name) == strtoupper($lda_registrant->name) || $lobbyist_last && stripos($lda_registrant->name, $lobbyist_last) == strlen($lda_registrant->name) - strlen($lobbyist_last) && stristr($lda_registrant->name, $lobbyist_longest))) {
                 $existing_lobbyist_registrant = EntityTable::getByExtensionQuery('Lobbyist')->addWhere('lobbyist.lda_registrant_id = ?', $lda_registrant->federal_registrant_id)->execute()->getFirst();
                 if ($existing_lobbyist_registrant) {
                     $lobbying_entity = $existing_lobbyist_registrant;
                     $this->printDebug('Existing lobbyist is lobbying entity: ' . $lobbying_entity->name);
//.........这里部分代码省略.........
开发者ID:silky,项目名称:littlesis,代码行数:101,代码来源:LobbyingScraper.class.php

示例12: getParentAlias

 public function getParentAlias()
 {
     if ($this->ival('category_parent_id') > 0) {
         $p = new Category($this->db, $this->ival('category_parent_id'));
         $pa = new Alias($this->db, $p->ival('category_alias_id'));
         if (!$pa->is_loaded) {
             $pa->setUrl($p->getAliasUrl());
             $pa->data['alias_path'] = $p->getAliasPath();
             $pa->save();
             $p->data['category_alias_id'] = $pa->val('alias_id');
             $p->save();
         }
         return $pa;
     }
 }
开发者ID:lotcz,项目名称:zshop,代码行数:15,代码来源:category.m.php

示例13: addAliasesToEntityById

 public function addAliasesToEntityById($id, array $aliases)
 {
     Doctrine_Manager::getInstance()->setCurrentConnection('main');
     $existingAliases = array_map('strtolower', EntityTable::getAliasNamesById($id, $includePrimary = true, $excludeContext = true));
     foreach ($aliases as $alias) {
         if (!in_array(strtolower($alias), $existingAliases)) {
             $a = new Alias();
             $a->entity_id = $id;
             $a->name = $alias;
             $a->is_primary = false;
             $a->save();
             if ($this->debugMode) {
                 print "+ Added alias " . $alias . " to entity " . $id . "\n";
             }
         }
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:17,代码来源:OsProcessMatchesTask.class.php

示例14: addGovernmentBodyEntity

 private function addGovernmentBodyEntity($name, $fedspending_name, $parent_id = null)
 {
     $new_gov_body = new Entity();
     $new_gov_body->addExtension('Org');
     $new_gov_body->addExtension('GovernmentBody');
     $new_gov_body->name = $name;
     $new_gov_body->is_federal = 1;
     if ($parent_id) {
         $new_gov_body->parent_id = $parent_id;
     }
     $new_gov_body->save();
     $alias = new Alias();
     $alias->context = 'fedspending_government_body';
     $alias->name = $fedspending_name;
     $alias->entity_id = $new_gov_body->id;
     $alias->save();
     return $new_gov_body;
 }
开发者ID:silky,项目名称:littlesis,代码行数:18,代码来源:FedSpendingScraper.class.php

示例15: parseAlias

function parseAlias($intAliasId, $strCommand)
{
    global $_PATHS, $_CLEAN_POST, $_CONF, $objLang, $objLiveUser;
    $objTpl = new HTML_Template_IT($_PATHS['templates']);
    $objTpl->loadTemplatefile("alias.tpl.htm");
    $blnError = false;
    switch ($strCommand) {
        case CMD_LIST:
        case CMD_ADD:
        case CMD_EDIT:
            //*** Post the profile form if submitted.
            if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "editAlias") {
                //*** The element form has been posted.
                //*** Check sanitized input.
                if (is_null($_CLEAN_POST["frm_active"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_alias"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_language"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["frm_element"])) {
                    $blnError = true;
                }
                if (is_null($_CLEAN_POST["dispatch"])) {
                    $blnError = true;
                }
                if ($blnError === true) {
                    //*** Display global error.
                    $objTpl->setVariable("FORM_ACTIVE_VALUE", $_POST["frm_active"] == "on" ? "checked=\"checked\"" : "");
                    $objTpl->setVariable("FORM_ALIAS_VALUE", $_POST["frm_alias"]);
                    $objTpl->setVariable("ERROR_ALIAS_MAIN", $objLang->get("main", "formerror"));
                } else {
                    //*** Input is valid. Save the alias.
                    if ($strCommand == CMD_EDIT) {
                        $objAlias = Alias::selectByPK($intAliasId);
                    } else {
                        $objAlias = new Alias();
                    }
                    $objAlias->setAccountId($_CONF['app']['account']->getId());
                    $objAlias->setActive($_POST["frm_active"] == "on" ? 1 : 0);
                    $objAlias->setLanguageId(empty($_CLEAN_POST["frm_language"]) ? 0 : $_CLEAN_POST["frm_language"]);
                    $objAlias->setAlias($_CLEAN_POST["frm_alias"]);
                    $objAlias->setUrl($_CLEAN_POST["frm_element"]);
                    $objAlias->save();
                    header("Location: " . Request::getURI() . "/?cid=" . NAV_PCMS_ALIASES);
                    exit;
                }
            }
            //*** Initiate child element loop.
            $objAliases = Alias::selectSorted();
            $totalCount = 0;
            $listCount = 0;
            $intPosition = request("pos");
            $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0;
            $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"];
            //*** Find total count.
            foreach ($objAliases as $objAlias) {
                $strAlias = $objAlias->getAlias();
                if (!empty($strAlias)) {
                    $totalCount++;
                }
            }
            $objAliases->seek($intPosition);
            $objLanguages = ContentLanguage::select();
            foreach ($objAliases as $objAlias) {
                $strAlias = $objAlias->getAlias();
                if (!empty($strAlias)) {
                    $strUrl = $objAlias->getUrl();
                    if (is_numeric($strUrl)) {
                        $objElement = Element::selectByPk($strUrl);
                        if (is_object($objElement)) {
                            $strUrlHref = "?eid={$strUrl}&amp;cmd=" . CMD_EDIT . "&amp;cid=" . NAV_PCMS_ELEMENTS;
                            $strUrl = Element::recursivePath($strUrl);
                        } else {
                            $strUrlHref = "?cid=" . NAV_PCMS_ALIASES;
                            $strUrl = "<b>" . $objLang->get("aliasUnavailable", "label") . "</b>";
                        }
                    }
                    $objTpl->setCurrentBlock("multiview-item");
                    $objTpl->setVariable("MULTIITEM_VALUE", $objAlias->getId());
                    $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:Alias.remove({$objAlias->getId()});");
                    $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button"));
                    $objTpl->setVariable("MULTIITEM_HREF", "?cid=" . NAV_PCMS_ALIASES . "&amp;eid={$objAlias->getId()}&amp;cmd=" . CMD_EDIT);
                    $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "alias");
                    $objTpl->setVariable("MULTIITEM_ALIAS", $objAlias->getAlias());
                    $objTpl->setVariable("MULTIITEM_POINTS_TO", $objLang->get("pointsTo", "label"));
                    $objTpl->setVariable("MULTIITEM_URL", $strUrl);
                    $objTpl->setVariable("MULTIITEM_URL_HREF", $strUrlHref);
                    if ($objLanguages->count() > 1) {
                        if ($objAlias->getLanguageId() > 0) {
                            $strLanguage = ContentLanguage::selectByPK($objAlias->getLanguageId())->getName();
                            $objTpl->setVariable("MULTIITEM_LANGUAGE", sprintf($objLang->get("forLanguage", "label"), $strLanguage));
                        } else {
                            $objTpl->setVariable("MULTIITEM_LANGUAGE", $objLang->get("forAllLanguages", "label"));
                        }
                    } else {
                        $objTpl->setVariable("MULTIITEM_LANGUAGE", "");
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:inc.tplparse_alias.php


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