本文整理汇总了PHP中Tag::removeTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::removeTag方法的具体用法?PHP Tag::removeTag怎么用?PHP Tag::removeTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::removeTag方法的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();
}
}
示例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));
}
示例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));
}
}
示例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')));
}
示例5: executeUpdate
public function executeUpdate(sfWebRequest $request)
{
$this->forward404Unless($request->isXmlHttpRequest());
$this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
$this->forward404Unless($decision = Doctrine_Core::getTable('Decision')->find(array($request->getParameter('id'))), sprintf('Object decision does not exist (%s).', $request->getParameter('id')));
$form = new DecisionForm($decision, array('type' => 'edit'));
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$form->save();
$tags_request = json_decode($request->getParameter('tags'));
$tags = array();
foreach ($form->getObject()->getTagDecision() as $tag) {
$tags[] = $tag->Tag->name;
}
foreach (array_diff($tags_request, $tags) as $result) {
Tag::newTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'decision');
}
foreach (array_diff($tags, $tags_request) as $result) {
Tag::removeTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'decision');
}
return $this->renderText(json_encode(array('status' => 'success', 'data' => $form->getObject()->getRowData())));
}
return $this->renderText(json_encode(array('status' => 'error', 'html' => $this->getPartial('form', array('form' => $form)))));
}