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


PHP Tag::newTag方法代码示例

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


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

示例1: advancedImport

 public function advancedImport()
 {
     foreach ($this->prepareData() as $item) {
         $alternative = null;
         if (array_key_exists('id', $item) && !empty($item['id'])) {
             $alternative = AlternativeTable::getInstance()->createQuery('a')->leftJoin('a.Decision d')->leftJoin('d.User u')->leftJoin('u.TeamMember tm')->whereIn('d.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($this->guard_user))->andWhere('a.item_id = ?', $item['id'])->andWhere('d.id = ?', $this->decision->getId())->fetchOne();
         }
         if (!is_object($alternative)) {
             $alternative = new Alternative();
             $alternative->setDecision($this->decision);
             $alternative->setCreatedBy($this->created_and_updated_by);
             $alternative->setUpdatedBy($this->created_and_updated_by);
         }
         $alternative->setName($item['name']);
         foreach (array('status', 'work progress', 'additional info', 'notes', 'due date', 'notify date') as $prop) {
             if (array_key_exists($prop, $item) && !empty($item[$prop])) {
                 $alternative->{str_replace(' ', '_', $prop)} = $item[$prop];
             }
         }
         if (array_key_exists('tags', $item)) {
             // Process tags
             $tags_request = array_map('trim', explode(',', $item['tags']));
             $tags = array();
             foreach ($alternative->getTagAlternative() as $tag) {
                 $tags[] = $tag->Tag->name;
             }
             foreach (array_diff($tags_request, $tags) as $result) {
                 Tag::newTag($this->guard_user, $alternative->getId(), $result, 'alternative');
             }
             foreach (array_diff($tags, $tags_request) as $result) {
                 Tag::removeTag($this->guard_user, $alternative->getId(), $result, 'alternative');
             }
         }
         $alternative->save();
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:36,代码来源:AlternativeImporter.class.php

示例2: executeUpdateRelease

 /**
  * @param sfWebRequest $request
  * @return sfView|string
  */
 public function executeUpdateRelease(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     $this->forward404Unless($object = Doctrine_Core::getTable($this->model)->find(array($request->getParameter('id'))), sprintf('Object decision does not exist (%s).', $request->getParameter('id')));
     $formClass = $this->model . 'Form';
     $this->form = new $formClass($object, array('user' => $this->getUser()));
     $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
     if ($this->form->isValid()) {
         $this->form->save();
         $this->form_valid = true;
         // Process tags
         $tags_request = json_decode($request->getParameter('tags'));
         $tags = array();
         foreach ($object->getTagRelease() as $tag) {
             $tags[] = $tag->Tag->name;
         }
         foreach (array_diff($tags_request, $tags) as $result) {
             Tag::newTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'release');
         }
         foreach (array_diff($tags, $tags_request) as $result) {
             Tag::removeTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'release');
         }
         $object->refresh(true);
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($object, $this->getUser()->getGuardUser(), array('action' => 'edit'));
         return $this->renderText(json_encode(array('id' => $object->id, 'name' => $object->name)));
     }
     return $this->renderPartial('form', array('form' => $this->form));
 }
开发者ID:sensorsix,项目名称:app,代码行数:35,代码来源:actions.class.php

示例3: executeUpdate

 public function executeUpdate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     $this->forward404Unless($alternative = Doctrine_Core::getTable($this->model)->find(array($request->getParameter('id'))), sprintf('Object decision does not exist (%s).', $request->getParameter('id')));
     $form = new AlternativeForm($alternative, array('user' => $this->getUser()));
     $alternative->setUpdatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->save();
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($alternative, $this->getUser()->getGuardUser(), array('action' => 'edit'));
         // Process tags
         $tags_request = json_decode($request->getParameter('tags'));
         $tags = array();
         foreach ($alternative->getTagAlternative() as $tag) {
             $tags[] = $tag->Tag->name;
         }
         foreach (array_diff($tags_request, $tags) as $result) {
             Tag::newTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'alternative');
         }
         foreach (array_diff($tags, $tags_request) as $result) {
             Tag::removeTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'alternative');
         }
         // Process links
         $links = array();
         foreach ($alternative->getAlternativeLink() as $link) {
             $links[$link->id] = $link->link;
         }
         $links_request_new = array();
         $links_request_old = array();
         $links_request = json_decode($request->getParameter('links'), true);
         foreach ($links_request as $link_request) {
             if (is_array($link_request) && array_key_exists('id', $link_request)) {
                 $links_request_old[$link_request['id']] = $link_request['link'];
             } else {
                 $links_request_new[] = $link_request;
             }
         }
         foreach ($links_request_new as $link_request_new) {
             $link = new AlternativeLink();
             $link->link = $link_request_new['link'];
             $link->alternative_id = $request->getParameter('id');
             $link->save();
         }
         foreach (array_diff(array_keys($links), array_keys($links_request_old)) as $result) {
             AlternativeLinkTable::getInstance()->find($result)->delete();
         }
         foreach ($links_request_old as $key => $link) {
             if ($links_request_old[$key] !== $links[$key]) {
                 $alternative_link = AlternativeLinkTable::getInstance()->find($key);
                 $alternative_link->link = $links_request_old[$key];
                 $alternative_link->save();
             }
         }
         // Process related alternatives
         $related_alternatives_request = json_decode($request->getParameter('related_alternatives'), true);
         if (!$related_alternatives_request) {
             $related_alternatives_request = array();
         }
         $related_alternatives = array();
         foreach ($alternative->getAlternativeRelation() as $related_alternative) {
             $related_alternatives[] = $related_alternative->to_id;
         }
         foreach (array_diff($related_alternatives_request, $related_alternatives) as $result) {
             if (AlternativeTable::getInstance()->getOneForUser($this->getUser()->getGuardUser(), $result)) {
                 $alternative_relation = new AlternativeRelation();
                 $alternative_relation->setFromId($alternative->getId());
                 $alternative_relation->setToId($result);
                 $alternative_relation->setCreatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
                 $alternative_relation->save();
             }
         }
         foreach (array_diff($related_alternatives, $related_alternatives_request) as $result) {
             AlternativeRelationTable::getInstance()->findByFromIdAndToId($alternative->getId(), $result)->delete();
         }
         $alternative->refresh(true);
         return $this->renderText(json_encode($alternative->getRowData()));
     } else {
         return $this->renderPartial('form', array('form' => $form));
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:83,代码来源:actions.class.php

示例4: executeImportFromCustomFields

 /**
  * @param sfWebRequest $request
  * @return sfView
  */
 public function executeImportFromCustomFields(sfWebRequest $request)
 {
     $decision_id = $request->getParameter('decision_id', false);
     $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
     $this->forward404Unless(is_object($decision));
     $header = $request->getParameter('header');
     $data = $request->getParameter('data');
     if (array_search('name', $header) === false) {
         return $this->renderText(json_encode(array('status' => 'error', 'text' => 'Please ensure that data field "Name" is mapped to a column in your SpreadSheet.')));
     }
     foreach ($data as $item) {
         $alternative = null;
         if (array_key_exists('id', $item) && !empty($item['id'])) {
             $alternative = AlternativeTable::getInstance()->createQuery('a')->leftJoin('a.Decision d')->leftJoin('d.User u')->leftJoin('u.TeamMember tm')->whereIn('d.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($this->getUser()->getGuardUser()))->andWhere('a.item_id = ?', $item['id'])->andWhere('d.id = ?', $decision->getId())->fetchOne();
         }
         if (!is_object($alternative)) {
             $alternative = new Alternative();
             $alternative->setDecision($decision);
             $alternative->setCreatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
             $alternative->setUpdatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
         }
         $custom_fields = array();
         foreach ($item as $prop => $value) {
             if (array_key_exists($prop, $header)) {
                 if ($header[$prop] == '_new') {
                     $custom_fields[$prop] = $value;
                 } elseif (!in_array($header[$prop], array('id')) && in_array($header[$prop], array('name', 'status', 'work progress', 'additional info', 'notes', 'due date', 'notify date', 'tags'))) {
                     if ($header[$prop] == 'tags') {
                         // Process tags
                         $tags_request = array_map('trim', explode(',', $value));
                         $tags = array();
                         foreach ($alternative->getTagAlternative() as $tag) {
                             $tags[] = $tag->Tag->name;
                         }
                         foreach (array_diff($tags_request, $tags) as $result) {
                             Tag::newTag($this->getUser()->getGuardUser(), $alternative->getId(), $result, 'alternative');
                         }
                         foreach (array_diff($tags, $tags_request) as $result) {
                             Tag::removeTag($this->getUser()->getGuardUser(), $alternative->getId(), $result, 'alternative');
                         }
                     } else {
                         $alternative->{str_replace(' ', '_', $header[$prop])} = $value;
                     }
                 }
             }
         }
         if ($custom_fields) {
             $alternative->setCustomFields(json_encode($custom_fields));
         }
         if (!$alternative->getName()) {
             $alternative->setName('New ' . InterfaceLabelTable::getInstance()->get($this->getUser()->getGuardUser(), InterfaceLabelTable::ITEM_TYPE));
         }
         $alternative->save();
     }
     return $this->renderText(json_encode(array('status' => 'success')));
 }
开发者ID:sensorsix,项目名称:app,代码行数:60,代码来源:actions.class.php

示例5: executeImportFromTrello

 /**
  * @param sfWebRequest $request
  * @return sfView
  */
 public function executeImportFromTrello(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     if (!DecisionTable::getInstance()->verifyAvailableName($this->getUser()->getGuardUser(), $request->getParameter('board_name'))) {
         return $this->renderText(json_encode(array('status' => 'error', 'message' => 'A project with that name already exists')));
     }
     $decision = new Decision();
     $decision->setName($request->getParameter('board_name'));
     $decision->setUserId($this->getUser()->getGuardUser()->getId());
     $decision->setExternalId($request->getParameter('board_id'));
     $decision->setTypeId(2);
     $type_template = TypeTemplate::getInstance()->createQuery('t')->where('t.user_id is NULL')->andWhere('t.type_id = ?', 2)->andWhere('t.name = ?', 'Default')->fetchOne();
     $decision->setTemplateId($type_template->getId());
     // Default template
     $decision->setFolderId(FolderTable::getInstance()->getNotDeletableForUser($this->getUser()->getGuardUser(), Folder::TYPE_PROJECT)->getId());
     $decision->save();
     $dashboard_role = $decision->getDashboardRole();
     foreach (json_decode($request->getParameter('cards', '{}')) as $card) {
         $alternative = new Alternative();
         $alternative->setName($card->name);
         $alternative->setDecisionId($decision->getId());
         $alternative->setAdditionalInfo($card->desc);
         $alternative->setNotes($card->notes);
         $alternative->setExternalId($card->id);
         $alternative->setCreatedBy($request->getParameter('full_name') . ' (via Trello)');
         $alternative->setUpdatedBy($request->getParameter('full_name') . ' (via Trello)');
         if ($card->due) {
             $date = DateTime::createFromFormat('Y-m-d\\TH:i:s.000Z', $card->due);
             $alternative->setDueDate($date->format('Y-m-d H:i:s'));
             $alternative->setNotifyDate($date->format('Y-m-d H:i:s'));
         }
         $alternative->save();
         foreach ($card->labels as $label) {
             Tag::newTag($this->getUser()->getGuardUser(), $alternative->getId(), $label, 'alternative');
         }
         if ($dashboard_role) {
             foreach ($decision->getCriterion() as $criterion) {
                 $planned_alternative_measurement = new PlannedAlternativeMeasurement();
                 $planned_alternative_measurement->setAlternative($alternative);
                 $planned_alternative_measurement->setCriterion($criterion);
                 $dashboard_role->PlannedAlternativeMeasurement->add($planned_alternative_measurement);
             }
         }
     }
     $dashboard_role->PlannedAlternativeMeasurement->save();
     if ($request->getParameter('wizard')) {
         $user = $this->getUser()->getGuardUser();
         $user->setWizard(false);
         $user->save();
     }
     // Create log
     $log = new Log();
     $log->setAction('project_create');
     $log->setUserId($this->getUser()->getGuardUser()->id);
     $log->setInformation(json_encode(array('decision_name' => $decision->getName(), 'decision_type' => $decision->getTypeId(), 'decision_template' => $decision->getTemplateId(), 'imported' => 'Trello')));
     $log->save();
     return $this->renderText(json_encode(array('status' => 'success', 'dashboard_url' => $this->generateUrl('dashboard', array('decision_id' => $decision->getId())))));
 }
开发者ID:sensorsix,项目名称:app,代码行数:62,代码来源:actions.class.php


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