equal
deleted
inserted
replaced
149 $nb_tags = count($tags); |
149 $nb_tags = count($tags); |
150 $found = false; |
150 $found = false; |
151 $i = 0; |
151 $i = 0; |
152 while($i<$nb_tags && $found==false){ |
152 while($i<$nb_tags && $found==false){ |
153 $dt = $tags[$i]; |
153 $dt = $tags[$i]; |
154 if(strtolower($dt->getTag()->getLabel())==strtolower($tag_label)){ |
154 if($dt->getTag()->getLabel()==$tag_label){ |
155 $found = true; |
155 $found = true; |
156 } |
156 } |
157 $i++; |
157 $i++; |
158 } |
158 } |
159 // If the label was found, we sent a bad request |
159 // If the label was found, we sent a bad request |
160 if($found==true){ |
160 if($found==true){ |
161 return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400); |
161 return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400); |
162 } |
162 } |
163 // We create the new tag or get the already existing tag. $tag, $revision_id, $created |
163 // We create the new tag or get the already existing tag. $tag, $revision_id, $created |
164 $ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine());// tag, revision_id, created = get_or_create_tag(tag_label) |
164 $ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine()); |
165 $tag = $ar[0]; |
165 $tag = $ar[0]; |
166 $revision_id = $ar[1]; |
166 $revision_id = $ar[1]; |
167 $created = $ar[2]; |
167 $created = $ar[2]; |
168 |
168 |
169 // We get the DocumentTag and change its tag |
169 // We get the DocumentTag and change its tag |
180 // We set ManualOrder = true for the current document |
180 // We set ManualOrder = true for the current document |
181 $doc = $this->getDoctrine()->getRepository('WikiTagBundle:Document')->findOneBy(array('externalId' => $id_doc)); |
181 $doc = $this->getDoctrine()->getRepository('WikiTagBundle:Document')->findOneBy(array('externalId' => $id_doc)); |
182 $doc->setManualOrder(true); |
182 $doc->setManualOrder(true); |
183 // We save the datas |
183 // We save the datas |
184 $em->flush(); |
184 $em->flush(); |
185 // We render the document's tags |
185 } |
186 return $this->renderDocTags($id_doc); |
186 // We render the document's tags |
187 } |
187 return $this->renderDocTags($id_doc); |
188 |
188 |
189 } |
189 } |
190 |
190 |
191 /** |
191 /** |
192 * |
192 * |