Esempio n. 1
0
 public static function initialize($id, $idS)
 {
     $OO = AppBlogsBlogsPeer::retrieveByPK($id);
     if (!$OO instanceof AppBlogsBlogs) {
         $OO = new AppBlogsBlogs();
         $OO->setName('Nom per defecte');
         $OO->setDate(date('Y-m-d', time()));
         $OO->setSiteId($idS);
         $OO->setActiu(true);
     }
     return new AppBlogsBlogsForm($OO, array('IDS' => $idS));
 }
 /**
  * Selects a collection of AppBlogsPages objects pre-filled with all related objects.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of AppBlogsPages objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     AppBlogsPagesPeer::addSelectColumns($criteria);
     $startcol2 = AppBlogsPagesPeer::NUM_COLUMNS - AppBlogsPagesPeer::NUM_LAZY_LOAD_COLUMNS;
     AppBlogsBlogsPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (AppBlogsBlogsPeer::NUM_COLUMNS - AppBlogsBlogsPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(AppBlogsPagesPeer::BLOG_ID, AppBlogsBlogsPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseAppBlogsPagesPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = AppBlogsPagesPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = AppBlogsPagesPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = AppBlogsPagesPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             AppBlogsPagesPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined AppBlogsBlogs rows
         $key2 = AppBlogsBlogsPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = AppBlogsBlogsPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = AppBlogsBlogsPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 AppBlogsBlogsPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (AppBlogsPages) to the collection in $obj2 (AppBlogsBlogs)
             $obj2->addAppBlogsPages($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
 /**
  * Get the associated AppBlogsBlogs object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     AppBlogsBlogs The associated AppBlogsBlogs object.
  * @throws     PropelException
  */
 public function getAppBlogsBlogs(PropelPDO $con = null)
 {
     if ($this->aAppBlogsBlogs === null && $this->blog_id !== null) {
         $this->aAppBlogsBlogs = AppBlogsBlogsPeer::retrieveByPk($this->blog_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aAppBlogsBlogs->addAppBlogsPagess($this);
         		 */
     }
     return $this->aAppBlogsBlogs;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(AppBlogsBlogsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(AppBlogsBlogsPeer::DATABASE_NAME);
         $criteria->add(AppBlogsBlogsPeer::ID, $pks, Criteria::IN);
         $objs = AppBlogsBlogsPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 5
0
 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);
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = AppBlogsBlogsPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDate($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setSiteId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setActiu($arr[$keys[4]]);
     }
 }