public function executeCreate(sfWebRequest $request) { $this->forward404unless($request->isXmlHttpRequest()); $this->html = 'Error ...'; $this->success = false; $this->checkProject($request); $this->checkParentTree($request, $this->ei_project); $view = new EiView(); $view->setProjectId($this->ei_project->getProjectId()); $view->setProjectRef($this->ei_project->getRefId()); $this->form = new EiViewForm($view); $this->processForm($request, $this->form); return $this->renderText(json_encode(array('html' => $this->html, 'success' => $this->success))); return sfView::NONE; }
public function reload($projets, $project_id, $project_ref, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } //Création de la collection d'objet View à ajouter $collection = new Doctrine_Collection("EiView"); $items = $projets->getElementsByTagName("ei_views"); if ($items->length > 0) { //ya t-il des éléments à traiter? $ei_views = $items->item(0)->getElementsByTagName("ei_view"); if ($ei_views->length > 0) { foreach ($ei_views as $ei_view) { $view_id = $ei_view->getAttribute("view_id"); $view_ref = $ei_view->getAttribute("view_ref"); //recherche du profil en base if ($view_id != null && $view_ref != null) { $q = Doctrine_Core::getTable('EiView')->findOneByViewIdAndViewRef($view_id, $view_ref); if ($q && $q != null) { //si l'element existe , on fait une mise à jour $q->setDescription($ei_view->getElementsByTagName("description")->item(0)->nodeValue); $q->setIsActive($ei_view->getElementsByTagName("is_active")->item(0)->nodeValue); $q->save($conn); } else { //l'élément n'existe pas encore, et dans ce cas on le crée $new_ei_view = new EiView(); $new_ei_view->setViewId($view_id); $new_ei_view->setViewRef($view_ref); $new_ei_view->setDescription($ei_view->getElementsByTagName("description")->item(0)->nodeValue); $new_ei_view->setIsActive($ei_view->getElementsByTagName("is_active")->item(0)->nodeValue); $new_ei_view->setProjectId($project_id); $new_ei_view->setProjectRef($project_ref); // $new_ei_view->save($conn); $collection->add($new_ei_view); } } } if ($collection->getFirst()) { $collection->save($conn); } //Sauvegarde de la collection return 1; } return null; //On a retrouvé aucun élément de ce type } }