public function executeGBlogs(sfWebRequest $request) { $this->setLayout('gestio'); $this->IDS = $this->getUser()->getSessionPar('idS'); //Add,Edit,Delete Multimedia //Add,Edit,Delete Page //Add,Edit,Delete Entry //Principal view -> Blogs //You Select a blog -> Choice Menus - Pages //Edit Page - Menu $this->APP_BLOG = $request->getParameter('APP_BLOG', -1); $this->APP_PAGE = $request->getParameter('APP_PAGE', -1); $this->APP_ENTRY = $request->getParameter('APP_ENTRY', -1); $this->APP_MENU = $request->getParameter('APP_MENU', -1); $this->APP_MULTIMEDIA = $request->getParameter('APP_MULTIMEDIA', -1); $this->APP_FORM = $request->getParameter('APP_FORM', 1); $this->APP_FORM_ENTRY = $request->getParameter('APP_FORM_ENTRY', 0); $this->accio = $request->getParameter('accio', 'VB'); // $this->APP_BLOG = $this->getUser()->ParReqSesForm($request,'APP_BLOG',-1); // $this->APP_PAGE = $this->getUser()->ParReqSesForm($request,'APP_PAGE',-1); // $this->APP_ENTRY = $this->getUser()->ParReqSesForm($request,'APP_ENTRY',-1); // $this->APP_MENU = $this->getUser()->ParReqSesForm($request,'APP_MENU',-1); // $this->APP_MULTIMEDIA = $this->getUser()->ParReqSesForm($request,'APP_MULTIMEDIA',-1); // $this->APP_FORM = $this->getUser()->ParReqSesForm($request,'APP_FORM',1); // $this->APP_FORM_ENTRY = $this->getUser()->ParReqSesForm($request,'APP_FORM_ENTRY',0); $accio = $request->getParameter('accio', 'GP'); $this->MODE = 'CERCA'; if ($request->isMethod('POST')) { if ($request->hasParameter('B_NEW_MENU')) { $accio = 'NEW_MENU'; } elseif ($request->hasParameter('B_EDIT_MENU')) { $accio = 'EDIT_MENU'; } elseif ($request->hasParameter('B_DELETE_MENU')) { $accio = 'DELETE_MENU'; } elseif ($request->hasParameter('B_SAVE_MENU')) { $accio = 'SAVE_MENU'; } elseif ($request->hasParameter('B_NEW_PAGE')) { $accio = 'NEW_PAGE'; } elseif ($request->hasParameter('B_EDIT_PAGE')) { $accio = 'EDIT_PAGE'; } elseif ($request->hasParameter('B_DELETE_PAGE')) { $accio = 'DELETE_PAGE'; } elseif ($request->hasParameter('B_SAVE_PAGE')) { $accio = 'SAVE_PAGE'; } elseif ($request->hasParameter('B_NEW_ENTRY')) { $accio = 'NEW_ENTRY'; } elseif ($request->hasParameter('B_EDIT_ENTRY')) { $accio = 'EDIT_ENTRY'; } elseif ($request->hasParameter('B_DELETE_ENTRY')) { $accio = 'DELETE_ENTRY'; } elseif ($request->hasParameter('B_SAVE_ENTRY')) { $accio = 'SAVE_ENTRY'; } elseif ($request->hasParameter('B_NEW_BLOG')) { $accio = 'NEW_BLOG'; } elseif ($request->hasParameter('B_EDIT_BLOG')) { $accio = 'EDIT_BLOG'; } elseif ($request->hasParameter('B_DELETE_BLOG')) { $accio = 'DELETE_BLOG'; } elseif ($request->hasParameter('B_SAVE_BLOG')) { $accio = 'SAVE_BLOG'; } elseif ($request->hasParameter('B_VIEW_CONTENT')) { $accio = 'VIEW_CONTENT'; } elseif ($request->hasParameter('B_VIEW_STADISTICS')) { $accio = 'VIEW_STADISTICS'; } elseif ($request->hasParameter('B_VIEW_FORM')) { $accio = 'VIEW_FORM'; } } switch ($accio) { case 'NEW_MENU': $this->FORM_MENU = AppBlogsMenuPeer::initialize(0, $this->APP_BLOG, $this->IDS); break; case 'EDIT_MENU': $this->FORM_MENU = AppBlogsMenuPeer::initialize($this->APP_MENU, $this->APP_BLOG, $this->IDS); break; case 'DELETE_MENU': $this->FORM_MENU = AppBlogsMenuPeer::initialize($this->APP_MENU, $this->APP_BLOG, $this->IDS); $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_MENU->getObject()); $this->FORM_MENU->getObject()->setInactiu(); $this->redirect('gestio/gBlogs?accio=VIEW_CONTENT'); break; case 'SAVE_MENU': $RP = $request->getParameter('app_blogs_menu'); $this->APP_MENU = $RP['id']; $this->APP_BLOG = $RP['blog_id']; $this->FORM_MENU = AppBlogsMenuPeer::initialize($this->APP_MENU, $this->APP_BLOG, $this->IDS); $this->FORM_MENU->bind($RP); if ($this->FORM_MENU->isValid()) { try { $this->FORM_MENU->save(); $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_MENU->getObject()); $this->APP_MENU = $this->FORM_MENU->getObject()->getId(); unset($this->APP_MENU); $this->reloadBlog(); } catch (Exception $e) { echo $e->getMessage(); } } break; case 'NEW_PAGE': $this->FORM_PAGE = AppBlogsPagesPeer::initialize(0, $this->APP_BLOG, $this->IDS); break; case 'EDIT_PAGE': $this->FORM_PAGE = AppBlogsPagesPeer::initialize($this->APP_PAGE, $this->APP_BLOG, $this->IDS); break; case 'DELETE_PAGE': try { $RP = $request->getParameter('app_blogs_pages'); $this->APP_PAGE = $RP['id']; $this->APP_BLOG = $RP['blog_id']; $this->FORM_PAGE = AppBlogsPagesPeer::initialize($this->APP_PAGE, $this->APP_BLOG, $this->IDS); $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_PAGE->getObject()); $this->FORM_PAGE->getObject()->setInactiu(); unset($this->FORM_PAGE); $this->reloadBlog(); } catch (Exception $e) { echo $e->getMessage(); } break; case 'SAVE_PAGE': $RP = $request->getParameter('app_blogs_pages'); $this->APP_PAGE = $RP['id']; $this->APP_BLOG = $RP['blog_id']; $this->FORM_PAGE = AppBlogsPagesPeer::initialize($this->APP_PAGE, $this->APP_BLOG, $this->IDS); $this->FORM_PAGE->bind($RP); if ($this->FORM_PAGE->isValid()) { try { $this->FORM_PAGE->save(); $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_PAGE->getObject()); $this->APP_PAGE = $this->FORM_PAGE->getObject()->getId(); //Ara assignem també aquesta pàgina al menú que tenim seleccionat. Si no n'hi ha cap, no fem res. if ($this->APP_MENU > 0) { $FM = AppBlogsMenuPeer::initialize($this->APP_MENU, $this->APP_BLOG, $this->IDS); $FM->getObject()->setPageId($this->APP_PAGE)->save(); } unset($this->FORM_PAGE); $this->reloadBlog(); } catch (Exception $e) { echo $e->getMessage(); } } break; case 'NEW_ENTRY': $this->FORM_ENTRY = AppBlogsEntriesPeer::initialize($this->APP_ENTRY, 'CA', $this->APP_PAGE, $this->APP_BLOG, $this->IDS); $this->GALLERY = array(); break; case 'EDIT_ENTRY': $this->FORM_ENTRY = AppBlogsEntriesPeer::initialize($this->APP_ENTRY, 'CA', $this->APP_PAGE, $this->APP_BLOG, $this->IDS); $this->GALLERY = AppBlogsEntriesPeer::getFiles($this->APP_ENTRY, 'CA'); break; case 'DELETE_ENTRY': $RS = $request->getParameter('app_blogs_entries'); $this->APP_ENTRY = $RS['id']; $this->APP_PAGE = $RS['page_id']; $this->FORM_ENTRY = AppBlogsEntriesPeer::initialize($this->APP_ENTRY, 'CA', $this->APP_PAGE, $this->APP_BLOG, $this->IDS); $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_ENTRY->getObject()); $this->FORM_ENTRY->getObject()->setInactiu(); $this->reloadBlog(); break; case 'SAVE_ENTRY': $RS = $request->getParameter('app_blogs_entries'); $this->APP_ENTRY = $RS['id']; $this->APP_PAGE = $RS['page_id']; $this->FORM_ENTRY = AppBlogsEntriesPeer::initialize($this->APP_ENTRY, 'CA', $this->APP_PAGE, $this->APP_BLOG, $this->IDS); $this->FORM_ENTRY->bind($RS); if ($this->FORM_ENTRY->isValid()) { try { $this->FORM_ENTRY->save(); $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_ENTRY->getObject()); $this->APP_ENTRY = $this->FORM_ENTRY->getObject()->getId(); $this->GUARDA_IMATGES($request->getFiles('arxiu'), $request->getParameter('desc'), $this->APP_ENTRY); unset($this->FORM_ENTRY); $this->reloadBlog(); } catch (Exception $e) { echo $e->getMessage(); } } $this->GALLERY = AppBlogsEntriesPeer::getFiles($this->APP_ENTRY, 'CA'); break; case 'NEW_BLOG': $this->FORM_BLOG = AppBlogsBlogsPeer::initialize(0, $this->IDS); break; case 'EDIT_BLOG': $this->FORM_BLOG = AppBlogsBlogsPeer::initialize($this->APP_BLOG, $this->IDS); break; case 'DELETE_BLOG': $RS = $request->getParameter('app_blogs_blogs'); $this->APP_BLOG = $RS['id']; $this->FORM_BLOG = AppBlogsBlogsPeer::initialize($this->APP_BLOG, $this->IDS); $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_BLOG->getObject()); $this->FORM_BLOG->getObject()->setInactiu(); unset($this->FORM_BLOG); break; case 'DELETE_IMAGE': AppBlogsMultimediaPeer::initialize($this->APP_MULTIMEDIA, $this->IDS)->getObject()->setInactiu(); $this->getUser()->addLogAction($accio, 'gBlogs', $this->APP_MULTIMEDIA); break; case 'SAVE_BLOG': $RS = $request->getParameter('app_blogs_blogs'); $this->APP_BLOG = $RS['id']; $this->FORM_BLOG = AppBlogsBlogsPeer::initialize($this->APP_BLOG, $this->IDS); $this->FORM_BLOG->bind($RS); if ($this->FORM_BLOG->isValid()) { try { $this->FORM_BLOG->save(); $this->getUser()->addLogAction($accio, 'gBlogs', $this->FORM_BLOG->getObject()); $this->APP_BLOG = $this->FORM_BLOG->getObject()->getId(); unset($this->FORM_BLOG); $this->reloadBlog(); } catch (Exception $e) { echo $e->getMessage(); } } break; case 'VIEW_CONTENT': $this->reloadBlog($this->APP_BLOG); break; case 'AJAX_PAGE': $APP_PAGE = $request->getParameter('APP_PAGE'); $APP_ENTRY = $request->getParameter('APP_ENTRY'); $HTML = AppBlogsEntriesPeer::getOptionsEntries($APP_PAGE, $APP_ENTRY, $this->IDS); return $this->renderText($HTML); break; case 'AJAX_MENU': $APP_BLOG = $request->getParameter('APP_BLOG'); $APP_MENU = $request->getParameter('APP_MENU') > 0 ? $request->getParameter('APP_MENU') : 0; $APP_PAGE = $request->getParameter('APP_PAGE') > 0 ? $request->getParameter('APP_PAGE') : 0; $HTML = AppBlogsPagesPeer::getOptionsPages($APP_BLOG, $APP_MENU, $APP_PAGE, $this->IDS); return $this->renderText($HTML); break; case 'AJAX_ESTAT_FORM': $APP_FORM_ENTRY = $request->getParameter('APP_FORM_ENTRY'); $ESTAT = $request->getParameter('ESTAT'); $OO = AppBlogsFormsEntriesPeer::initialize($APP_FORM_ENTRY, $this->IDS)->getObject(); $OO->setEstat($ESTAT); $OO->save(); return $this->renderText('Canvi fet correctament'); break; case 'AJAX_SAVE_OBJECCIONS': $APP_FORM_ENTRY = $request->getParameter('APP_FORM_ENTRY'); $OO = AppBlogsFormsEntriesPeer::initialize($APP_FORM_ENTRY, $this->IDS); $OO->setObjeccions($request->getParameter('OBJECCIONS')); $OO->save(); return $this->renderText('Canvi fet correctament'); break; case 'VB': $this->APP_BLOG = -1; $this->APP_PAGE = -1; $this->APP_ENTRY = -1; $this->APP_MENU = -1; $this->APP_MULTIMEDIA = -1; $this->APP_FORM = -1; $this->getUser()->addLogAction('inside', 'gBlogs'); break; case 'VIEW_STADISTICS': //Veure estructura d'arbre $this->PAGES_WITHOUT_CONTENT = AppBlogsPagesPeer::getPagesWithoutContent($this->APP_BLOG, $this->IDS); $this->MENUS_WITHOUT_PAGES = AppBlogsMenuPeer::getMenusWithoutPages($this->APP_BLOG, $this->IDS); $this->TREE = AppBlogsMenuPeer::getOptionsMenus($this->APP_BLOG, null, false, $this->IDS); break; case 'VIEW_FORM': $datai = mktime(0, 0, 0, date('m', time()) - 2, date('d', time()), date('Y', time())); $this->VIEW_FORM_ENTRIES = AppBlogsFormsEntriesPeer::getEntries($this->APP_FORM, date('Y-m-d', $datai), $this->IDS); $this->VIEW_FIELDS = AppBlogsFormsEntriesPeer::getFields($this->APP_FORM, $this->IDS); break; } $this->BLOGS_ARRAY = AppBlogsBlogsPeer::getOptionsBlogs($this->APP_BLOG, $this->IDS); }