1: <?php
2:
3: namespace Thelia\Model\om;
4:
5: use \BaseObject;
6: use \BasePeer;
7: use \Criteria;
8: use \DateTime;
9: use \Exception;
10: use \PDO;
11: use \Persistent;
12: use \Propel;
13: use \PropelCollection;
14: use \PropelDateTime;
15: use \PropelException;
16: use \PropelObjectCollection;
17: use \PropelPDO;
18: use Thelia\Model\Content;
19: use Thelia\Model\ContentAssoc;
20: use Thelia\Model\ContentAssocQuery;
21: use Thelia\Model\ContentFolder;
22: use Thelia\Model\ContentFolderQuery;
23: use Thelia\Model\ContentI18n;
24: use Thelia\Model\ContentI18nQuery;
25: use Thelia\Model\ContentPeer;
26: use Thelia\Model\ContentQuery;
27: use Thelia\Model\ContentVersion;
28: use Thelia\Model\ContentVersionPeer;
29: use Thelia\Model\ContentVersionQuery;
30: use Thelia\Model\Document;
31: use Thelia\Model\DocumentQuery;
32: use Thelia\Model\Image;
33: use Thelia\Model\ImageQuery;
34: use Thelia\Model\Rewriting;
35: use Thelia\Model\RewritingQuery;
36:
37: 38: 39: 40: 41: 42: 43:
44: abstract class BaseContent extends BaseObject implements Persistent
45: {
46: 47: 48:
49: const PEER = 'Thelia\\Model\\ContentPeer';
50:
51: 52: 53: 54: 55: 56:
57: protected static $peer;
58:
59: 60: 61: 62:
63: protected $startCopy = false;
64:
65: 66: 67: 68:
69: protected $id;
70:
71: 72: 73: 74:
75: protected $visible;
76:
77: 78: 79: 80:
81: protected $position;
82:
83: 84: 85: 86:
87: protected $created_at;
88:
89: 90: 91: 92:
93: protected $updated_at;
94:
95: 96: 97: 98: 99:
100: protected $version;
101:
102: 103: 104: 105:
106: protected $version_created_at;
107:
108: 109: 110: 111:
112: protected $version_created_by;
113:
114: 115: 116:
117: protected $collContentAssocs;
118: protected $collContentAssocsPartial;
119:
120: 121: 122:
123: protected $collImages;
124: protected $collImagesPartial;
125:
126: 127: 128:
129: protected $collDocuments;
130: protected $collDocumentsPartial;
131:
132: 133: 134:
135: protected $collRewritings;
136: protected $collRewritingsPartial;
137:
138: 139: 140:
141: protected $collContentFolders;
142: protected $collContentFoldersPartial;
143:
144: 145: 146:
147: protected $collContentI18ns;
148: protected $collContentI18nsPartial;
149:
150: 151: 152:
153: protected $collContentVersions;
154: protected $collContentVersionsPartial;
155:
156: 157: 158: 159: 160:
161: protected $alreadyInSave = false;
162:
163: 164: 165: 166: 167:
168: protected $alreadyInValidation = false;
169:
170: 171: 172: 173:
174: protected $alreadyInClearAllReferencesDeep = false;
175:
176:
177:
178: 179: 180: 181:
182: protected $currentLocale = 'en_US';
183:
184: 185: 186: 187:
188: protected $currentTranslations;
189:
190:
191:
192:
193: 194: 195:
196: protected $enforceVersion = false;
197:
198: 199: 200: 201:
202: protected $contentAssocsScheduledForDeletion = null;
203:
204: 205: 206: 207:
208: protected $imagesScheduledForDeletion = null;
209:
210: 211: 212: 213:
214: protected $documentsScheduledForDeletion = null;
215:
216: 217: 218: 219:
220: protected $rewritingsScheduledForDeletion = null;
221:
222: 223: 224: 225:
226: protected = null;
227:
228: 229: 230: 231:
232: protected $contentI18nsScheduledForDeletion = null;
233:
234: 235: 236: 237:
238: protected $contentVersionsScheduledForDeletion = null;
239:
240: 241: 242: 243: 244: 245:
246: public function applyDefaultValues()
247: {
248: $this->version = 0;
249: }
250:
251: 252: 253: 254:
255: public function __construct()
256: {
257: parent::__construct();
258: $this->applyDefaultValues();
259: }
260:
261: 262: 263: 264: 265:
266: public function getId()
267: {
268: return $this->id;
269: }
270:
271: 272: 273: 274: 275:
276: public function getVisible()
277: {
278: return $this->visible;
279: }
280:
281: 282: 283: 284: 285:
286: public function getPosition()
287: {
288: return $this->position;
289: }
290:
291: 292: 293: 294: 295: 296: 297: 298: 299:
300: public function getCreatedAt($format = 'Y-m-d H:i:s')
301: {
302: if ($this->created_at === null) {
303: return null;
304: }
305:
306: if ($this->created_at === '0000-00-00 00:00:00') {
307:
308:
309: return null;
310: }
311:
312: try {
313: $dt = new DateTime($this->created_at);
314: } catch (Exception $x) {
315: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
316: }
317:
318: if ($format === null) {
319:
320: return $dt;
321: }
322:
323: if (strpos($format, '%') !== false) {
324: return strftime($format, $dt->format('U'));
325: }
326:
327: return $dt->format($format);
328:
329: }
330:
331: 332: 333: 334: 335: 336: 337: 338: 339:
340: public function getUpdatedAt($format = 'Y-m-d H:i:s')
341: {
342: if ($this->updated_at === null) {
343: return null;
344: }
345:
346: if ($this->updated_at === '0000-00-00 00:00:00') {
347:
348:
349: return null;
350: }
351:
352: try {
353: $dt = new DateTime($this->updated_at);
354: } catch (Exception $x) {
355: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
356: }
357:
358: if ($format === null) {
359:
360: return $dt;
361: }
362:
363: if (strpos($format, '%') !== false) {
364: return strftime($format, $dt->format('U'));
365: }
366:
367: return $dt->format($format);
368:
369: }
370:
371: 372: 373: 374: 375:
376: public function getVersion()
377: {
378: return $this->version;
379: }
380:
381: 382: 383: 384: 385: 386: 387: 388: 389:
390: public function getVersionCreatedAt($format = 'Y-m-d H:i:s')
391: {
392: if ($this->version_created_at === null) {
393: return null;
394: }
395:
396: if ($this->version_created_at === '0000-00-00 00:00:00') {
397:
398:
399: return null;
400: }
401:
402: try {
403: $dt = new DateTime($this->version_created_at);
404: } catch (Exception $x) {
405: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
406: }
407:
408: if ($format === null) {
409:
410: return $dt;
411: }
412:
413: if (strpos($format, '%') !== false) {
414: return strftime($format, $dt->format('U'));
415: }
416:
417: return $dt->format($format);
418:
419: }
420:
421: 422: 423: 424: 425:
426: public function getVersionCreatedBy()
427: {
428: return $this->version_created_by;
429: }
430:
431: 432: 433: 434: 435: 436:
437: public function setId($v)
438: {
439: if ($v !== null && is_numeric($v)) {
440: $v = (int) $v;
441: }
442:
443: if ($this->id !== $v) {
444: $this->id = $v;
445: $this->modifiedColumns[] = ContentPeer::ID;
446: }
447:
448:
449: return $this;
450: }
451:
452: 453: 454: 455: 456: 457:
458: public function setVisible($v)
459: {
460: if ($v !== null && is_numeric($v)) {
461: $v = (int) $v;
462: }
463:
464: if ($this->visible !== $v) {
465: $this->visible = $v;
466: $this->modifiedColumns[] = ContentPeer::VISIBLE;
467: }
468:
469:
470: return $this;
471: }
472:
473: 474: 475: 476: 477: 478:
479: public function setPosition($v)
480: {
481: if ($v !== null && is_numeric($v)) {
482: $v = (int) $v;
483: }
484:
485: if ($this->position !== $v) {
486: $this->position = $v;
487: $this->modifiedColumns[] = ContentPeer::POSITION;
488: }
489:
490:
491: return $this;
492: }
493:
494: 495: 496: 497: 498: 499: 500:
501: public function setCreatedAt($v)
502: {
503: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
504: if ($this->created_at !== null || $dt !== null) {
505: $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
506: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
507: if ($currentDateAsString !== $newDateAsString) {
508: $this->created_at = $newDateAsString;
509: $this->modifiedColumns[] = ContentPeer::CREATED_AT;
510: }
511: }
512:
513:
514: return $this;
515: }
516:
517: 518: 519: 520: 521: 522: 523:
524: public function setUpdatedAt($v)
525: {
526: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
527: if ($this->updated_at !== null || $dt !== null) {
528: $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
529: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
530: if ($currentDateAsString !== $newDateAsString) {
531: $this->updated_at = $newDateAsString;
532: $this->modifiedColumns[] = ContentPeer::UPDATED_AT;
533: }
534: }
535:
536:
537: return $this;
538: }
539:
540: 541: 542: 543: 544: 545:
546: public function setVersion($v)
547: {
548: if ($v !== null && is_numeric($v)) {
549: $v = (int) $v;
550: }
551:
552: if ($this->version !== $v) {
553: $this->version = $v;
554: $this->modifiedColumns[] = ContentPeer::VERSION;
555: }
556:
557:
558: return $this;
559: }
560:
561: 562: 563: 564: 565: 566: 567:
568: public function setVersionCreatedAt($v)
569: {
570: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
571: if ($this->version_created_at !== null || $dt !== null) {
572: $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
573: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
574: if ($currentDateAsString !== $newDateAsString) {
575: $this->version_created_at = $newDateAsString;
576: $this->modifiedColumns[] = ContentPeer::VERSION_CREATED_AT;
577: }
578: }
579:
580:
581: return $this;
582: }
583:
584: 585: 586: 587: 588: 589:
590: public function setVersionCreatedBy($v)
591: {
592: if ($v !== null && is_numeric($v)) {
593: $v = (string) $v;
594: }
595:
596: if ($this->version_created_by !== $v) {
597: $this->version_created_by = $v;
598: $this->modifiedColumns[] = ContentPeer::VERSION_CREATED_BY;
599: }
600:
601:
602: return $this;
603: }
604:
605: 606: 607: 608: 609: 610: 611: 612:
613: public function hasOnlyDefaultValues()
614: {
615: if ($this->version !== 0) {
616: return false;
617: }
618:
619:
620: return true;
621: }
622:
623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636:
637: public function hydrate($row, $startcol = 0, $rehydrate = false)
638: {
639: try {
640:
641: $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
642: $this->visible = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
643: $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
644: $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
645: $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
646: $this->version = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
647: $this->version_created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
648: $this->version_created_by = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
649: $this->resetModified();
650:
651: $this->setNew(false);
652:
653: if ($rehydrate) {
654: $this->ensureConsistency();
655: }
656: $this->postHydrate($row, $startcol, $rehydrate);
657: return $startcol + 8;
658:
659: } catch (Exception $e) {
660: throw new PropelException("Error populating Content object", $e);
661: }
662: }
663:
664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676:
677: public function ensureConsistency()
678: {
679:
680: }
681:
682: 683: 684: 685: 686: 687: 688: 689: 690: 691:
692: public function reload($deep = false, PropelPDO $con = null)
693: {
694: if ($this->isDeleted()) {
695: throw new PropelException("Cannot reload a deleted object.");
696: }
697:
698: if ($this->isNew()) {
699: throw new PropelException("Cannot reload an unsaved object.");
700: }
701:
702: if ($con === null) {
703: $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
704: }
705:
706:
707:
708:
709: $stmt = ContentPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
710: $row = $stmt->fetch(PDO::FETCH_NUM);
711: $stmt->closeCursor();
712: if (!$row) {
713: throw new PropelException('Cannot find matching row in the database to reload object values.');
714: }
715: $this->hydrate($row, 0, true);
716:
717: if ($deep) {
718:
719: $this->collContentAssocs = null;
720:
721: $this->collImages = null;
722:
723: $this->collDocuments = null;
724:
725: $this->collRewritings = null;
726:
727: $this->collContentFolders = null;
728:
729: $this->collContentI18ns = null;
730:
731: $this->collContentVersions = null;
732:
733: }
734: }
735:
736: 737: 738: 739: 740: 741: 742: 743: 744: 745:
746: public function delete(PropelPDO $con = null)
747: {
748: if ($this->isDeleted()) {
749: throw new PropelException("This object has already been deleted.");
750: }
751:
752: if ($con === null) {
753: $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
754: }
755:
756: $con->beginTransaction();
757: try {
758: $deleteQuery = ContentQuery::create()
759: ->filterByPrimaryKey($this->getPrimaryKey());
760: $ret = $this->preDelete($con);
761: if ($ret) {
762: $deleteQuery->delete($con);
763: $this->postDelete($con);
764: $con->commit();
765: $this->setDeleted(true);
766: } else {
767: $con->commit();
768: }
769: } catch (Exception $e) {
770: $con->rollBack();
771: throw $e;
772: }
773: }
774:
775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788:
789: public function save(PropelPDO $con = null)
790: {
791: if ($this->isDeleted()) {
792: throw new PropelException("You cannot save an object that has been deleted.");
793: }
794:
795: if ($con === null) {
796: $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
797: }
798:
799: $con->beginTransaction();
800: $isInsert = $this->isNew();
801: try {
802: $ret = $this->preSave($con);
803:
804: if ($this->isVersioningNecessary()) {
805: $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
806: if (!$this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) {
807: $this->setVersionCreatedAt(time());
808: }
809: $createVersion = true;
810: }
811: if ($isInsert) {
812: $ret = $ret && $this->preInsert($con);
813:
814: if (!$this->isColumnModified(ContentPeer::CREATED_AT)) {
815: $this->setCreatedAt(time());
816: }
817: if (!$this->isColumnModified(ContentPeer::UPDATED_AT)) {
818: $this->setUpdatedAt(time());
819: }
820: } else {
821: $ret = $ret && $this->preUpdate($con);
822:
823: if ($this->isModified() && !$this->isColumnModified(ContentPeer::UPDATED_AT)) {
824: $this->setUpdatedAt(time());
825: }
826: }
827: if ($ret) {
828: $affectedRows = $this->doSave($con);
829: if ($isInsert) {
830: $this->postInsert($con);
831: } else {
832: $this->postUpdate($con);
833: }
834: $this->postSave($con);
835:
836: if (isset($createVersion)) {
837: $this->addVersion($con);
838: }
839: ContentPeer::addInstanceToPool($this);
840: } else {
841: $affectedRows = 0;
842: }
843: $con->commit();
844:
845: return $affectedRows;
846: } catch (Exception $e) {
847: $con->rollBack();
848: throw $e;
849: }
850: }
851:
852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862:
863: protected function doSave(PropelPDO $con)
864: {
865: $affectedRows = 0;
866: if (!$this->alreadyInSave) {
867: $this->alreadyInSave = true;
868:
869: if ($this->isNew() || $this->isModified()) {
870:
871: if ($this->isNew()) {
872: $this->doInsert($con);
873: } else {
874: $this->doUpdate($con);
875: }
876: $affectedRows += 1;
877: $this->resetModified();
878: }
879:
880: if ($this->contentAssocsScheduledForDeletion !== null) {
881: if (!$this->contentAssocsScheduledForDeletion->isEmpty()) {
882: foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) {
883:
884: $contentAssoc->save($con);
885: }
886: $this->contentAssocsScheduledForDeletion = null;
887: }
888: }
889:
890: if ($this->collContentAssocs !== null) {
891: foreach ($this->collContentAssocs as $referrerFK) {
892: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
893: $affectedRows += $referrerFK->save($con);
894: }
895: }
896: }
897:
898: if ($this->imagesScheduledForDeletion !== null) {
899: if (!$this->imagesScheduledForDeletion->isEmpty()) {
900: foreach ($this->imagesScheduledForDeletion as $image) {
901:
902: $image->save($con);
903: }
904: $this->imagesScheduledForDeletion = null;
905: }
906: }
907:
908: if ($this->collImages !== null) {
909: foreach ($this->collImages as $referrerFK) {
910: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
911: $affectedRows += $referrerFK->save($con);
912: }
913: }
914: }
915:
916: if ($this->documentsScheduledForDeletion !== null) {
917: if (!$this->documentsScheduledForDeletion->isEmpty()) {
918: foreach ($this->documentsScheduledForDeletion as $document) {
919:
920: $document->save($con);
921: }
922: $this->documentsScheduledForDeletion = null;
923: }
924: }
925:
926: if ($this->collDocuments !== null) {
927: foreach ($this->collDocuments as $referrerFK) {
928: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
929: $affectedRows += $referrerFK->save($con);
930: }
931: }
932: }
933:
934: if ($this->rewritingsScheduledForDeletion !== null) {
935: if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
936: foreach ($this->rewritingsScheduledForDeletion as $rewriting) {
937:
938: $rewriting->save($con);
939: }
940: $this->rewritingsScheduledForDeletion = null;
941: }
942: }
943:
944: if ($this->collRewritings !== null) {
945: foreach ($this->collRewritings as $referrerFK) {
946: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
947: $affectedRows += $referrerFK->save($con);
948: }
949: }
950: }
951:
952: if ($this->contentFoldersScheduledForDeletion !== null) {
953: if (!$this->contentFoldersScheduledForDeletion->isEmpty()) {
954: ContentFolderQuery::create()
955: ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false))
956: ->delete($con);
957: $this->contentFoldersScheduledForDeletion = null;
958: }
959: }
960:
961: if ($this->collContentFolders !== null) {
962: foreach ($this->collContentFolders as $referrerFK) {
963: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
964: $affectedRows += $referrerFK->save($con);
965: }
966: }
967: }
968:
969: if ($this->contentI18nsScheduledForDeletion !== null) {
970: if (!$this->contentI18nsScheduledForDeletion->isEmpty()) {
971: ContentI18nQuery::create()
972: ->filterByPrimaryKeys($this->contentI18nsScheduledForDeletion->getPrimaryKeys(false))
973: ->delete($con);
974: $this->contentI18nsScheduledForDeletion = null;
975: }
976: }
977:
978: if ($this->collContentI18ns !== null) {
979: foreach ($this->collContentI18ns as $referrerFK) {
980: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
981: $affectedRows += $referrerFK->save($con);
982: }
983: }
984: }
985:
986: if ($this->contentVersionsScheduledForDeletion !== null) {
987: if (!$this->contentVersionsScheduledForDeletion->isEmpty()) {
988: ContentVersionQuery::create()
989: ->filterByPrimaryKeys($this->contentVersionsScheduledForDeletion->getPrimaryKeys(false))
990: ->delete($con);
991: $this->contentVersionsScheduledForDeletion = null;
992: }
993: }
994:
995: if ($this->collContentVersions !== null) {
996: foreach ($this->collContentVersions as $referrerFK) {
997: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
998: $affectedRows += $referrerFK->save($con);
999: }
1000: }
1001: }
1002:
1003: $this->alreadyInSave = false;
1004:
1005: }
1006:
1007: return $affectedRows;
1008: }
1009:
1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017:
1018: protected function doInsert(PropelPDO $con)
1019: {
1020: $modifiedColumns = array();
1021: $index = 0;
1022:
1023: $this->modifiedColumns[] = ContentPeer::ID;
1024: if (null !== $this->id) {
1025: throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentPeer::ID . ')');
1026: }
1027:
1028:
1029: if ($this->isColumnModified(ContentPeer::ID)) {
1030: $modifiedColumns[':p' . $index++] = '`id`';
1031: }
1032: if ($this->isColumnModified(ContentPeer::VISIBLE)) {
1033: $modifiedColumns[':p' . $index++] = '`visible`';
1034: }
1035: if ($this->isColumnModified(ContentPeer::POSITION)) {
1036: $modifiedColumns[':p' . $index++] = '`position`';
1037: }
1038: if ($this->isColumnModified(ContentPeer::CREATED_AT)) {
1039: $modifiedColumns[':p' . $index++] = '`created_at`';
1040: }
1041: if ($this->isColumnModified(ContentPeer::UPDATED_AT)) {
1042: $modifiedColumns[':p' . $index++] = '`updated_at`';
1043: }
1044: if ($this->isColumnModified(ContentPeer::VERSION)) {
1045: $modifiedColumns[':p' . $index++] = '`version`';
1046: }
1047: if ($this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) {
1048: $modifiedColumns[':p' . $index++] = '`version_created_at`';
1049: }
1050: if ($this->isColumnModified(ContentPeer::VERSION_CREATED_BY)) {
1051: $modifiedColumns[':p' . $index++] = '`version_created_by`';
1052: }
1053:
1054: $sql = sprintf(
1055: 'INSERT INTO `content` (%s) VALUES (%s)',
1056: implode(', ', $modifiedColumns),
1057: implode(', ', array_keys($modifiedColumns))
1058: );
1059:
1060: try {
1061: $stmt = $con->prepare($sql);
1062: foreach ($modifiedColumns as $identifier => $columnName) {
1063: switch ($columnName) {
1064: case '`id`':
1065: $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
1066: break;
1067: case '`visible`':
1068: $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
1069: break;
1070: case '`position`':
1071: $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
1072: break;
1073: case '`created_at`':
1074: $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
1075: break;
1076: case '`updated_at`':
1077: $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
1078: break;
1079: case '`version`':
1080: $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
1081: break;
1082: case '`version_created_at`':
1083: $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
1084: break;
1085: case '`version_created_by`':
1086: $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
1087: break;
1088: }
1089: }
1090: $stmt->execute();
1091: } catch (Exception $e) {
1092: Propel::log($e->getMessage(), Propel::LOG_ERR);
1093: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
1094: }
1095:
1096: try {
1097: $pk = $con->lastInsertId();
1098: } catch (Exception $e) {
1099: throw new PropelException('Unable to get autoincrement id.', $e);
1100: }
1101: $this->setId($pk);
1102:
1103: $this->setNew(false);
1104: }
1105:
1106: 1107: 1108: 1109: 1110: 1111: 1112:
1113: protected function doUpdate(PropelPDO $con)
1114: {
1115: $selectCriteria = $this->buildPkeyCriteria();
1116: $valuesCriteria = $this->buildCriteria();
1117: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
1118: }
1119:
1120: 1121: 1122: 1123:
1124: protected $validationFailures = array();
1125:
1126: 1127: 1128: 1129: 1130: 1131: 1132:
1133: public function getValidationFailures()
1134: {
1135: return $this->validationFailures;
1136: }
1137:
1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148:
1149: public function validate($columns = null)
1150: {
1151: $res = $this->doValidate($columns);
1152: if ($res === true) {
1153: $this->validationFailures = array();
1154:
1155: return true;
1156: }
1157:
1158: $this->validationFailures = $res;
1159:
1160: return false;
1161: }
1162:
1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172:
1173: protected function doValidate($columns = null)
1174: {
1175: if (!$this->alreadyInValidation) {
1176: $this->alreadyInValidation = true;
1177: $retval = null;
1178:
1179: $failureMap = array();
1180:
1181:
1182: if (($retval = ContentPeer::doValidate($this, $columns)) !== true) {
1183: $failureMap = array_merge($failureMap, $retval);
1184: }
1185:
1186:
1187: if ($this->collContentAssocs !== null) {
1188: foreach ($this->collContentAssocs as $referrerFK) {
1189: if (!$referrerFK->validate($columns)) {
1190: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1191: }
1192: }
1193: }
1194:
1195: if ($this->collImages !== null) {
1196: foreach ($this->collImages as $referrerFK) {
1197: if (!$referrerFK->validate($columns)) {
1198: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1199: }
1200: }
1201: }
1202:
1203: if ($this->collDocuments !== null) {
1204: foreach ($this->collDocuments as $referrerFK) {
1205: if (!$referrerFK->validate($columns)) {
1206: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1207: }
1208: }
1209: }
1210:
1211: if ($this->collRewritings !== null) {
1212: foreach ($this->collRewritings as $referrerFK) {
1213: if (!$referrerFK->validate($columns)) {
1214: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1215: }
1216: }
1217: }
1218:
1219: if ($this->collContentFolders !== null) {
1220: foreach ($this->collContentFolders as $referrerFK) {
1221: if (!$referrerFK->validate($columns)) {
1222: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1223: }
1224: }
1225: }
1226:
1227: if ($this->collContentI18ns !== null) {
1228: foreach ($this->collContentI18ns as $referrerFK) {
1229: if (!$referrerFK->validate($columns)) {
1230: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1231: }
1232: }
1233: }
1234:
1235: if ($this->collContentVersions !== null) {
1236: foreach ($this->collContentVersions as $referrerFK) {
1237: if (!$referrerFK->validate($columns)) {
1238: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1239: }
1240: }
1241: }
1242:
1243:
1244: $this->alreadyInValidation = false;
1245: }
1246:
1247: return (!empty($failureMap) ? $failureMap : true);
1248: }
1249:
1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259:
1260: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1261: {
1262: $pos = ContentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1263: $field = $this->getByPosition($pos);
1264:
1265: return $field;
1266: }
1267:
1268: 1269: 1270: 1271: 1272: 1273: 1274:
1275: public function getByPosition($pos)
1276: {
1277: switch ($pos) {
1278: case 0:
1279: return $this->getId();
1280: break;
1281: case 1:
1282: return $this->getVisible();
1283: break;
1284: case 2:
1285: return $this->getPosition();
1286: break;
1287: case 3:
1288: return $this->getCreatedAt();
1289: break;
1290: case 4:
1291: return $this->getUpdatedAt();
1292: break;
1293: case 5:
1294: return $this->getVersion();
1295: break;
1296: case 6:
1297: return $this->getVersionCreatedAt();
1298: break;
1299: case 7:
1300: return $this->getVersionCreatedBy();
1301: break;
1302: default:
1303: return null;
1304: break;
1305: }
1306: }
1307:
1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322:
1323: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1324: {
1325: if (isset($alreadyDumpedObjects['Content'][$this->getPrimaryKey()])) {
1326: return '*RECURSION*';
1327: }
1328: $alreadyDumpedObjects['Content'][$this->getPrimaryKey()] = true;
1329: $keys = ContentPeer::getFieldNames($keyType);
1330: $result = array(
1331: $keys[0] => $this->getId(),
1332: $keys[1] => $this->getVisible(),
1333: $keys[2] => $this->getPosition(),
1334: $keys[3] => $this->getCreatedAt(),
1335: $keys[4] => $this->getUpdatedAt(),
1336: $keys[5] => $this->getVersion(),
1337: $keys[6] => $this->getVersionCreatedAt(),
1338: $keys[7] => $this->getVersionCreatedBy(),
1339: );
1340: if ($includeForeignObjects) {
1341: if (null !== $this->collContentAssocs) {
1342: $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1343: }
1344: if (null !== $this->collImages) {
1345: $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1346: }
1347: if (null !== $this->collDocuments) {
1348: $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1349: }
1350: if (null !== $this->collRewritings) {
1351: $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1352: }
1353: if (null !== $this->collContentFolders) {
1354: $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1355: }
1356: if (null !== $this->collContentI18ns) {
1357: $result['ContentI18ns'] = $this->collContentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1358: }
1359: if (null !== $this->collContentVersions) {
1360: $result['ContentVersions'] = $this->collContentVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1361: }
1362: }
1363:
1364: return $result;
1365: }
1366:
1367: 1368: 1369: 1370: 1371: 1372: 1373: 1374: 1375: 1376: 1377:
1378: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1379: {
1380: $pos = ContentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1381:
1382: $this->setByPosition($pos, $value);
1383: }
1384:
1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392:
1393: public function setByPosition($pos, $value)
1394: {
1395: switch ($pos) {
1396: case 0:
1397: $this->setId($value);
1398: break;
1399: case 1:
1400: $this->setVisible($value);
1401: break;
1402: case 2:
1403: $this->setPosition($value);
1404: break;
1405: case 3:
1406: $this->setCreatedAt($value);
1407: break;
1408: case 4:
1409: $this->setUpdatedAt($value);
1410: break;
1411: case 5:
1412: $this->setVersion($value);
1413: break;
1414: case 6:
1415: $this->setVersionCreatedAt($value);
1416: break;
1417: case 7:
1418: $this->setVersionCreatedBy($value);
1419: break;
1420: }
1421: }
1422:
1423: 1424: 1425: 1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439:
1440: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1441: {
1442: $keys = ContentPeer::getFieldNames($keyType);
1443:
1444: if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1445: if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]);
1446: if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
1447: if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
1448: if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
1449: if (array_key_exists($keys[5], $arr)) $this->setVersion($arr[$keys[5]]);
1450: if (array_key_exists($keys[6], $arr)) $this->setVersionCreatedAt($arr[$keys[6]]);
1451: if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedBy($arr[$keys[7]]);
1452: }
1453:
1454: 1455: 1456: 1457: 1458:
1459: public function buildCriteria()
1460: {
1461: $criteria = new Criteria(ContentPeer::DATABASE_NAME);
1462:
1463: if ($this->isColumnModified(ContentPeer::ID)) $criteria->add(ContentPeer::ID, $this->id);
1464: if ($this->isColumnModified(ContentPeer::VISIBLE)) $criteria->add(ContentPeer::VISIBLE, $this->visible);
1465: if ($this->isColumnModified(ContentPeer::POSITION)) $criteria->add(ContentPeer::POSITION, $this->position);
1466: if ($this->isColumnModified(ContentPeer::CREATED_AT)) $criteria->add(ContentPeer::CREATED_AT, $this->created_at);
1467: if ($this->isColumnModified(ContentPeer::UPDATED_AT)) $criteria->add(ContentPeer::UPDATED_AT, $this->updated_at);
1468: if ($this->isColumnModified(ContentPeer::VERSION)) $criteria->add(ContentPeer::VERSION, $this->version);
1469: if ($this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) $criteria->add(ContentPeer::VERSION_CREATED_AT, $this->version_created_at);
1470: if ($this->isColumnModified(ContentPeer::VERSION_CREATED_BY)) $criteria->add(ContentPeer::VERSION_CREATED_BY, $this->version_created_by);
1471:
1472: return $criteria;
1473: }
1474:
1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482:
1483: public function buildPkeyCriteria()
1484: {
1485: $criteria = new Criteria(ContentPeer::DATABASE_NAME);
1486: $criteria->add(ContentPeer::ID, $this->id);
1487:
1488: return $criteria;
1489: }
1490:
1491: 1492: 1493: 1494:
1495: public function getPrimaryKey()
1496: {
1497: return $this->getId();
1498: }
1499:
1500: 1501: 1502: 1503: 1504: 1505:
1506: public function setPrimaryKey($key)
1507: {
1508: $this->setId($key);
1509: }
1510:
1511: 1512: 1513: 1514:
1515: public function isPrimaryKeyNull()
1516: {
1517:
1518: return null === $this->getId();
1519: }
1520:
1521: 1522: 1523: 1524: 1525: 1526: 1527: 1528: 1529: 1530: 1531:
1532: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1533: {
1534: $copyObj->setVisible($this->getVisible());
1535: $copyObj->setPosition($this->getPosition());
1536: $copyObj->setCreatedAt($this->getCreatedAt());
1537: $copyObj->setUpdatedAt($this->getUpdatedAt());
1538: $copyObj->setVersion($this->getVersion());
1539: $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
1540: $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
1541:
1542: if ($deepCopy && !$this->startCopy) {
1543:
1544:
1545: $copyObj->setNew(false);
1546:
1547: $this->startCopy = true;
1548:
1549: foreach ($this->getContentAssocs() as $relObj) {
1550: if ($relObj !== $this) {
1551: $copyObj->addContentAssoc($relObj->copy($deepCopy));
1552: }
1553: }
1554:
1555: foreach ($this->getImages() as $relObj) {
1556: if ($relObj !== $this) {
1557: $copyObj->addImage($relObj->copy($deepCopy));
1558: }
1559: }
1560:
1561: foreach ($this->getDocuments() as $relObj) {
1562: if ($relObj !== $this) {
1563: $copyObj->addDocument($relObj->copy($deepCopy));
1564: }
1565: }
1566:
1567: foreach ($this->getRewritings() as $relObj) {
1568: if ($relObj !== $this) {
1569: $copyObj->addRewriting($relObj->copy($deepCopy));
1570: }
1571: }
1572:
1573: foreach ($this->getContentFolders() as $relObj) {
1574: if ($relObj !== $this) {
1575: $copyObj->addContentFolder($relObj->copy($deepCopy));
1576: }
1577: }
1578:
1579: foreach ($this->getContentI18ns() as $relObj) {
1580: if ($relObj !== $this) {
1581: $copyObj->addContentI18n($relObj->copy($deepCopy));
1582: }
1583: }
1584:
1585: foreach ($this->getContentVersions() as $relObj) {
1586: if ($relObj !== $this) {
1587: $copyObj->addContentVersion($relObj->copy($deepCopy));
1588: }
1589: }
1590:
1591:
1592: $this->startCopy = false;
1593: }
1594:
1595: if ($makeNew) {
1596: $copyObj->setNew(true);
1597: $copyObj->setId(NULL);
1598: }
1599: }
1600:
1601: 1602: 1603: 1604: 1605: 1606: 1607: 1608: 1609: 1610: 1611: 1612:
1613: public function copy($deepCopy = false)
1614: {
1615:
1616: $clazz = get_class($this);
1617: $copyObj = new $clazz();
1618: $this->copyInto($copyObj, $deepCopy);
1619:
1620: return $copyObj;
1621: }
1622:
1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631:
1632: public function getPeer()
1633: {
1634: if (self::$peer === null) {
1635: self::$peer = new ContentPeer();
1636: }
1637:
1638: return self::$peer;
1639: }
1640:
1641:
1642: 1643: 1644: 1645: 1646: 1647: 1648: 1649:
1650: public function initRelation($relationName)
1651: {
1652: if ('ContentAssoc' == $relationName) {
1653: $this->initContentAssocs();
1654: }
1655: if ('Image' == $relationName) {
1656: $this->initImages();
1657: }
1658: if ('Document' == $relationName) {
1659: $this->initDocuments();
1660: }
1661: if ('Rewriting' == $relationName) {
1662: $this->initRewritings();
1663: }
1664: if ('ContentFolder' == $relationName) {
1665: $this->initContentFolders();
1666: }
1667: if ('ContentI18n' == $relationName) {
1668: $this->initContentI18ns();
1669: }
1670: if ('ContentVersion' == $relationName) {
1671: $this->initContentVersions();
1672: }
1673: }
1674:
1675: 1676: 1677: 1678: 1679: 1680: 1681: 1682: 1683:
1684: public function clearContentAssocs()
1685: {
1686: $this->collContentAssocs = null;
1687: $this->collContentAssocsPartial = null;
1688:
1689: return $this;
1690: }
1691:
1692: 1693: 1694: 1695: 1696:
1697: public function resetPartialContentAssocs($v = true)
1698: {
1699: $this->collContentAssocsPartial = $v;
1700: }
1701:
1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710: 1711: 1712: 1713:
1714: public function initContentAssocs($overrideExisting = true)
1715: {
1716: if (null !== $this->collContentAssocs && !$overrideExisting) {
1717: return;
1718: }
1719: $this->collContentAssocs = new PropelObjectCollection();
1720: $this->collContentAssocs->setModel('ContentAssoc');
1721: }
1722:
1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734: 1735: 1736:
1737: public function getContentAssocs($criteria = null, PropelPDO $con = null)
1738: {
1739: $partial = $this->collContentAssocsPartial && !$this->isNew();
1740: if (null === $this->collContentAssocs || null !== $criteria || $partial) {
1741: if ($this->isNew() && null === $this->collContentAssocs) {
1742:
1743: $this->initContentAssocs();
1744: } else {
1745: $collContentAssocs = ContentAssocQuery::create(null, $criteria)
1746: ->filterByContent($this)
1747: ->find($con);
1748: if (null !== $criteria) {
1749: if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) {
1750: $this->initContentAssocs(false);
1751:
1752: foreach($collContentAssocs as $obj) {
1753: if (false == $this->collContentAssocs->contains($obj)) {
1754: $this->collContentAssocs->append($obj);
1755: }
1756: }
1757:
1758: $this->collContentAssocsPartial = true;
1759: }
1760:
1761: $collContentAssocs->getInternalIterator()->rewind();
1762: return $collContentAssocs;
1763: }
1764:
1765: if($partial && $this->collContentAssocs) {
1766: foreach($this->collContentAssocs as $obj) {
1767: if($obj->isNew()) {
1768: $collContentAssocs[] = $obj;
1769: }
1770: }
1771: }
1772:
1773: $this->collContentAssocs = $collContentAssocs;
1774: $this->collContentAssocsPartial = false;
1775: }
1776: }
1777:
1778: return $this->collContentAssocs;
1779: }
1780:
1781: 1782: 1783: 1784: 1785: 1786: 1787: 1788: 1789: 1790:
1791: public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null)
1792: {
1793: $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs);
1794:
1795: $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete));
1796:
1797: foreach ($contentAssocsToDelete as $contentAssocRemoved) {
1798: $contentAssocRemoved->setContent(null);
1799: }
1800:
1801: $this->collContentAssocs = null;
1802: foreach ($contentAssocs as $contentAssoc) {
1803: $this->addContentAssoc($contentAssoc);
1804: }
1805:
1806: $this->collContentAssocs = $contentAssocs;
1807: $this->collContentAssocsPartial = false;
1808:
1809: return $this;
1810: }
1811:
1812: 1813: 1814: 1815: 1816: 1817: 1818: 1819: 1820:
1821: public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1822: {
1823: $partial = $this->collContentAssocsPartial && !$this->isNew();
1824: if (null === $this->collContentAssocs || null !== $criteria || $partial) {
1825: if ($this->isNew() && null === $this->collContentAssocs) {
1826: return 0;
1827: }
1828:
1829: if($partial && !$criteria) {
1830: return count($this->getContentAssocs());
1831: }
1832: $query = ContentAssocQuery::create(null, $criteria);
1833: if ($distinct) {
1834: $query->distinct();
1835: }
1836:
1837: return $query
1838: ->filterByContent($this)
1839: ->count($con);
1840: }
1841:
1842: return count($this->collContentAssocs);
1843: }
1844:
1845: 1846: 1847: 1848: 1849: 1850: 1851:
1852: public function addContentAssoc(ContentAssoc $l)
1853: {
1854: if ($this->collContentAssocs === null) {
1855: $this->initContentAssocs();
1856: $this->collContentAssocsPartial = true;
1857: }
1858: if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) {
1859: $this->doAddContentAssoc($l);
1860: }
1861:
1862: return $this;
1863: }
1864:
1865: 1866: 1867:
1868: protected function doAddContentAssoc($contentAssoc)
1869: {
1870: $this->collContentAssocs[]= $contentAssoc;
1871: $contentAssoc->setContent($this);
1872: }
1873:
1874: 1875: 1876: 1877:
1878: public function removeContentAssoc($contentAssoc)
1879: {
1880: if ($this->getContentAssocs()->contains($contentAssoc)) {
1881: $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc));
1882: if (null === $this->contentAssocsScheduledForDeletion) {
1883: $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs;
1884: $this->contentAssocsScheduledForDeletion->clear();
1885: }
1886: $this->contentAssocsScheduledForDeletion[]= $contentAssoc;
1887: $contentAssoc->setContent(null);
1888: }
1889:
1890: return $this;
1891: }
1892:
1893:
1894: 1895: 1896: 1897: 1898: 1899: 1900: 1901: 1902: 1903: 1904: 1905: 1906: 1907: 1908: 1909:
1910: public function getContentAssocsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1911: {
1912: $query = ContentAssocQuery::create(null, $criteria);
1913: $query->joinWith('Category', $join_behavior);
1914:
1915: return $this->getContentAssocs($query, $con);
1916: }
1917:
1918:
1919: 1920: 1921: 1922: 1923: 1924: 1925: 1926: 1927: 1928: 1929: 1930: 1931: 1932: 1933: 1934:
1935: public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1936: {
1937: $query = ContentAssocQuery::create(null, $criteria);
1938: $query->joinWith('Product', $join_behavior);
1939:
1940: return $this->getContentAssocs($query, $con);
1941: }
1942:
1943: 1944: 1945: 1946: 1947: 1948: 1949: 1950: 1951:
1952: public function clearImages()
1953: {
1954: $this->collImages = null;
1955: $this->collImagesPartial = null;
1956:
1957: return $this;
1958: }
1959:
1960: 1961: 1962: 1963: 1964:
1965: public function resetPartialImages($v = true)
1966: {
1967: $this->collImagesPartial = $v;
1968: }
1969:
1970: 1971: 1972: 1973: 1974: 1975: 1976: 1977: 1978: 1979: 1980: 1981:
1982: public function initImages($overrideExisting = true)
1983: {
1984: if (null !== $this->collImages && !$overrideExisting) {
1985: return;
1986: }
1987: $this->collImages = new PropelObjectCollection();
1988: $this->collImages->setModel('Image');
1989: }
1990:
1991: 1992: 1993: 1994: 1995: 1996: 1997: 1998: 1999: 2000: 2001: 2002: 2003: 2004:
2005: public function getImages($criteria = null, PropelPDO $con = null)
2006: {
2007: $partial = $this->collImagesPartial && !$this->isNew();
2008: if (null === $this->collImages || null !== $criteria || $partial) {
2009: if ($this->isNew() && null === $this->collImages) {
2010:
2011: $this->initImages();
2012: } else {
2013: $collImages = ImageQuery::create(null, $criteria)
2014: ->filterByContent($this)
2015: ->find($con);
2016: if (null !== $criteria) {
2017: if (false !== $this->collImagesPartial && count($collImages)) {
2018: $this->initImages(false);
2019:
2020: foreach($collImages as $obj) {
2021: if (false == $this->collImages->contains($obj)) {
2022: $this->collImages->append($obj);
2023: }
2024: }
2025:
2026: $this->collImagesPartial = true;
2027: }
2028:
2029: $collImages->getInternalIterator()->rewind();
2030: return $collImages;
2031: }
2032:
2033: if($partial && $this->collImages) {
2034: foreach($this->collImages as $obj) {
2035: if($obj->isNew()) {
2036: $collImages[] = $obj;
2037: }
2038: }
2039: }
2040:
2041: $this->collImages = $collImages;
2042: $this->collImagesPartial = false;
2043: }
2044: }
2045:
2046: return $this->collImages;
2047: }
2048:
2049: 2050: 2051: 2052: 2053: 2054: 2055: 2056: 2057: 2058:
2059: public function setImages(PropelCollection $images, PropelPDO $con = null)
2060: {
2061: $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images);
2062:
2063: $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete));
2064:
2065: foreach ($imagesToDelete as $imageRemoved) {
2066: $imageRemoved->setContent(null);
2067: }
2068:
2069: $this->collImages = null;
2070: foreach ($images as $image) {
2071: $this->addImage($image);
2072: }
2073:
2074: $this->collImages = $images;
2075: $this->collImagesPartial = false;
2076:
2077: return $this;
2078: }
2079:
2080: 2081: 2082: 2083: 2084: 2085: 2086: 2087: 2088:
2089: public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2090: {
2091: $partial = $this->collImagesPartial && !$this->isNew();
2092: if (null === $this->collImages || null !== $criteria || $partial) {
2093: if ($this->isNew() && null === $this->collImages) {
2094: return 0;
2095: }
2096:
2097: if($partial && !$criteria) {
2098: return count($this->getImages());
2099: }
2100: $query = ImageQuery::create(null, $criteria);
2101: if ($distinct) {
2102: $query->distinct();
2103: }
2104:
2105: return $query
2106: ->filterByContent($this)
2107: ->count($con);
2108: }
2109:
2110: return count($this->collImages);
2111: }
2112:
2113: 2114: 2115: 2116: 2117: 2118: 2119:
2120: public function addImage(Image $l)
2121: {
2122: if ($this->collImages === null) {
2123: $this->initImages();
2124: $this->collImagesPartial = true;
2125: }
2126: if (!in_array($l, $this->collImages->getArrayCopy(), true)) {
2127: $this->doAddImage($l);
2128: }
2129:
2130: return $this;
2131: }
2132:
2133: 2134: 2135:
2136: protected function doAddImage($image)
2137: {
2138: $this->collImages[]= $image;
2139: $image->setContent($this);
2140: }
2141:
2142: 2143: 2144: 2145:
2146: public function removeImage($image)
2147: {
2148: if ($this->getImages()->contains($image)) {
2149: $this->collImages->remove($this->collImages->search($image));
2150: if (null === $this->imagesScheduledForDeletion) {
2151: $this->imagesScheduledForDeletion = clone $this->collImages;
2152: $this->imagesScheduledForDeletion->clear();
2153: }
2154: $this->imagesScheduledForDeletion[]= $image;
2155: $image->setContent(null);
2156: }
2157:
2158: return $this;
2159: }
2160:
2161:
2162: 2163: 2164: 2165: 2166: 2167: 2168: 2169: 2170: 2171: 2172: 2173: 2174: 2175: 2176: 2177:
2178: public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2179: {
2180: $query = ImageQuery::create(null, $criteria);
2181: $query->joinWith('Product', $join_behavior);
2182:
2183: return $this->getImages($query, $con);
2184: }
2185:
2186:
2187: 2188: 2189: 2190: 2191: 2192: 2193: 2194: 2195: 2196: 2197: 2198: 2199: 2200: 2201: 2202:
2203: public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2204: {
2205: $query = ImageQuery::create(null, $criteria);
2206: $query->joinWith('Category', $join_behavior);
2207:
2208: return $this->getImages($query, $con);
2209: }
2210:
2211:
2212: 2213: 2214: 2215: 2216: 2217: 2218: 2219: 2220: 2221: 2222: 2223: 2224: 2225: 2226: 2227:
2228: public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2229: {
2230: $query = ImageQuery::create(null, $criteria);
2231: $query->joinWith('Folder', $join_behavior);
2232:
2233: return $this->getImages($query, $con);
2234: }
2235:
2236: 2237: 2238: 2239: 2240: 2241: 2242: 2243: 2244:
2245: public function clearDocuments()
2246: {
2247: $this->collDocuments = null;
2248: $this->collDocumentsPartial = null;
2249:
2250: return $this;
2251: }
2252:
2253: 2254: 2255: 2256: 2257:
2258: public function resetPartialDocuments($v = true)
2259: {
2260: $this->collDocumentsPartial = $v;
2261: }
2262:
2263: 2264: 2265: 2266: 2267: 2268: 2269: 2270: 2271: 2272: 2273: 2274:
2275: public function initDocuments($overrideExisting = true)
2276: {
2277: if (null !== $this->collDocuments && !$overrideExisting) {
2278: return;
2279: }
2280: $this->collDocuments = new PropelObjectCollection();
2281: $this->collDocuments->setModel('Document');
2282: }
2283:
2284: 2285: 2286: 2287: 2288: 2289: 2290: 2291: 2292: 2293: 2294: 2295: 2296: 2297:
2298: public function getDocuments($criteria = null, PropelPDO $con = null)
2299: {
2300: $partial = $this->collDocumentsPartial && !$this->isNew();
2301: if (null === $this->collDocuments || null !== $criteria || $partial) {
2302: if ($this->isNew() && null === $this->collDocuments) {
2303:
2304: $this->initDocuments();
2305: } else {
2306: $collDocuments = DocumentQuery::create(null, $criteria)
2307: ->filterByContent($this)
2308: ->find($con);
2309: if (null !== $criteria) {
2310: if (false !== $this->collDocumentsPartial && count($collDocuments)) {
2311: $this->initDocuments(false);
2312:
2313: foreach($collDocuments as $obj) {
2314: if (false == $this->collDocuments->contains($obj)) {
2315: $this->collDocuments->append($obj);
2316: }
2317: }
2318:
2319: $this->collDocumentsPartial = true;
2320: }
2321:
2322: $collDocuments->getInternalIterator()->rewind();
2323: return $collDocuments;
2324: }
2325:
2326: if($partial && $this->collDocuments) {
2327: foreach($this->collDocuments as $obj) {
2328: if($obj->isNew()) {
2329: $collDocuments[] = $obj;
2330: }
2331: }
2332: }
2333:
2334: $this->collDocuments = $collDocuments;
2335: $this->collDocumentsPartial = false;
2336: }
2337: }
2338:
2339: return $this->collDocuments;
2340: }
2341:
2342: 2343: 2344: 2345: 2346: 2347: 2348: 2349: 2350: 2351:
2352: public function setDocuments(PropelCollection $documents, PropelPDO $con = null)
2353: {
2354: $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents);
2355:
2356: $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete));
2357:
2358: foreach ($documentsToDelete as $documentRemoved) {
2359: $documentRemoved->setContent(null);
2360: }
2361:
2362: $this->collDocuments = null;
2363: foreach ($documents as $document) {
2364: $this->addDocument($document);
2365: }
2366:
2367: $this->collDocuments = $documents;
2368: $this->collDocumentsPartial = false;
2369:
2370: return $this;
2371: }
2372:
2373: 2374: 2375: 2376: 2377: 2378: 2379: 2380: 2381:
2382: public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2383: {
2384: $partial = $this->collDocumentsPartial && !$this->isNew();
2385: if (null === $this->collDocuments || null !== $criteria || $partial) {
2386: if ($this->isNew() && null === $this->collDocuments) {
2387: return 0;
2388: }
2389:
2390: if($partial && !$criteria) {
2391: return count($this->getDocuments());
2392: }
2393: $query = DocumentQuery::create(null, $criteria);
2394: if ($distinct) {
2395: $query->distinct();
2396: }
2397:
2398: return $query
2399: ->filterByContent($this)
2400: ->count($con);
2401: }
2402:
2403: return count($this->collDocuments);
2404: }
2405:
2406: 2407: 2408: 2409: 2410: 2411: 2412:
2413: public function addDocument(Document $l)
2414: {
2415: if ($this->collDocuments === null) {
2416: $this->initDocuments();
2417: $this->collDocumentsPartial = true;
2418: }
2419: if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) {
2420: $this->doAddDocument($l);
2421: }
2422:
2423: return $this;
2424: }
2425:
2426: 2427: 2428:
2429: protected function doAddDocument($document)
2430: {
2431: $this->collDocuments[]= $document;
2432: $document->setContent($this);
2433: }
2434:
2435: 2436: 2437: 2438:
2439: public function removeDocument($document)
2440: {
2441: if ($this->getDocuments()->contains($document)) {
2442: $this->collDocuments->remove($this->collDocuments->search($document));
2443: if (null === $this->documentsScheduledForDeletion) {
2444: $this->documentsScheduledForDeletion = clone $this->collDocuments;
2445: $this->documentsScheduledForDeletion->clear();
2446: }
2447: $this->documentsScheduledForDeletion[]= $document;
2448: $document->setContent(null);
2449: }
2450:
2451: return $this;
2452: }
2453:
2454:
2455: 2456: 2457: 2458: 2459: 2460: 2461: 2462: 2463: 2464: 2465: 2466: 2467: 2468: 2469: 2470:
2471: public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2472: {
2473: $query = DocumentQuery::create(null, $criteria);
2474: $query->joinWith('Product', $join_behavior);
2475:
2476: return $this->getDocuments($query, $con);
2477: }
2478:
2479:
2480: 2481: 2482: 2483: 2484: 2485: 2486: 2487: 2488: 2489: 2490: 2491: 2492: 2493: 2494: 2495:
2496: public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2497: {
2498: $query = DocumentQuery::create(null, $criteria);
2499: $query->joinWith('Category', $join_behavior);
2500:
2501: return $this->getDocuments($query, $con);
2502: }
2503:
2504:
2505: 2506: 2507: 2508: 2509: 2510: 2511: 2512: 2513: 2514: 2515: 2516: 2517: 2518: 2519: 2520:
2521: public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2522: {
2523: $query = DocumentQuery::create(null, $criteria);
2524: $query->joinWith('Folder', $join_behavior);
2525:
2526: return $this->getDocuments($query, $con);
2527: }
2528:
2529: 2530: 2531: 2532: 2533: 2534: 2535: 2536: 2537:
2538: public function clearRewritings()
2539: {
2540: $this->collRewritings = null;
2541: $this->collRewritingsPartial = null;
2542:
2543: return $this;
2544: }
2545:
2546: 2547: 2548: 2549: 2550:
2551: public function resetPartialRewritings($v = true)
2552: {
2553: $this->collRewritingsPartial = $v;
2554: }
2555:
2556: 2557: 2558: 2559: 2560: 2561: 2562: 2563: 2564: 2565: 2566: 2567:
2568: public function initRewritings($overrideExisting = true)
2569: {
2570: if (null !== $this->collRewritings && !$overrideExisting) {
2571: return;
2572: }
2573: $this->collRewritings = new PropelObjectCollection();
2574: $this->collRewritings->setModel('Rewriting');
2575: }
2576:
2577: 2578: 2579: 2580: 2581: 2582: 2583: 2584: 2585: 2586: 2587: 2588: 2589: 2590:
2591: public function getRewritings($criteria = null, PropelPDO $con = null)
2592: {
2593: $partial = $this->collRewritingsPartial && !$this->isNew();
2594: if (null === $this->collRewritings || null !== $criteria || $partial) {
2595: if ($this->isNew() && null === $this->collRewritings) {
2596:
2597: $this->initRewritings();
2598: } else {
2599: $collRewritings = RewritingQuery::create(null, $criteria)
2600: ->filterByContent($this)
2601: ->find($con);
2602: if (null !== $criteria) {
2603: if (false !== $this->collRewritingsPartial && count($collRewritings)) {
2604: $this->initRewritings(false);
2605:
2606: foreach($collRewritings as $obj) {
2607: if (false == $this->collRewritings->contains($obj)) {
2608: $this->collRewritings->append($obj);
2609: }
2610: }
2611:
2612: $this->collRewritingsPartial = true;
2613: }
2614:
2615: $collRewritings->getInternalIterator()->rewind();
2616: return $collRewritings;
2617: }
2618:
2619: if($partial && $this->collRewritings) {
2620: foreach($this->collRewritings as $obj) {
2621: if($obj->isNew()) {
2622: $collRewritings[] = $obj;
2623: }
2624: }
2625: }
2626:
2627: $this->collRewritings = $collRewritings;
2628: $this->collRewritingsPartial = false;
2629: }
2630: }
2631:
2632: return $this->collRewritings;
2633: }
2634:
2635: 2636: 2637: 2638: 2639: 2640: 2641: 2642: 2643: 2644:
2645: public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
2646: {
2647: $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
2648:
2649: $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete));
2650:
2651: foreach ($rewritingsToDelete as $rewritingRemoved) {
2652: $rewritingRemoved->setContent(null);
2653: }
2654:
2655: $this->collRewritings = null;
2656: foreach ($rewritings as $rewriting) {
2657: $this->addRewriting($rewriting);
2658: }
2659:
2660: $this->collRewritings = $rewritings;
2661: $this->collRewritingsPartial = false;
2662:
2663: return $this;
2664: }
2665:
2666: 2667: 2668: 2669: 2670: 2671: 2672: 2673: 2674:
2675: public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2676: {
2677: $partial = $this->collRewritingsPartial && !$this->isNew();
2678: if (null === $this->collRewritings || null !== $criteria || $partial) {
2679: if ($this->isNew() && null === $this->collRewritings) {
2680: return 0;
2681: }
2682:
2683: if($partial && !$criteria) {
2684: return count($this->getRewritings());
2685: }
2686: $query = RewritingQuery::create(null, $criteria);
2687: if ($distinct) {
2688: $query->distinct();
2689: }
2690:
2691: return $query
2692: ->filterByContent($this)
2693: ->count($con);
2694: }
2695:
2696: return count($this->collRewritings);
2697: }
2698:
2699: 2700: 2701: 2702: 2703: 2704: 2705:
2706: public function addRewriting(Rewriting $l)
2707: {
2708: if ($this->collRewritings === null) {
2709: $this->initRewritings();
2710: $this->collRewritingsPartial = true;
2711: }
2712: if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) {
2713: $this->doAddRewriting($l);
2714: }
2715:
2716: return $this;
2717: }
2718:
2719: 2720: 2721:
2722: protected function doAddRewriting($rewriting)
2723: {
2724: $this->collRewritings[]= $rewriting;
2725: $rewriting->setContent($this);
2726: }
2727:
2728: 2729: 2730: 2731:
2732: public function removeRewriting($rewriting)
2733: {
2734: if ($this->getRewritings()->contains($rewriting)) {
2735: $this->collRewritings->remove($this->collRewritings->search($rewriting));
2736: if (null === $this->rewritingsScheduledForDeletion) {
2737: $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
2738: $this->rewritingsScheduledForDeletion->clear();
2739: }
2740: $this->rewritingsScheduledForDeletion[]= $rewriting;
2741: $rewriting->setContent(null);
2742: }
2743:
2744: return $this;
2745: }
2746:
2747:
2748: 2749: 2750: 2751: 2752: 2753: 2754: 2755: 2756: 2757: 2758: 2759: 2760: 2761: 2762: 2763:
2764: public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2765: {
2766: $query = RewritingQuery::create(null, $criteria);
2767: $query->joinWith('Product', $join_behavior);
2768:
2769: return $this->getRewritings($query, $con);
2770: }
2771:
2772:
2773: 2774: 2775: 2776: 2777: 2778: 2779: 2780: 2781: 2782: 2783: 2784: 2785: 2786: 2787: 2788:
2789: public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2790: {
2791: $query = RewritingQuery::create(null, $criteria);
2792: $query->joinWith('Category', $join_behavior);
2793:
2794: return $this->getRewritings($query, $con);
2795: }
2796:
2797:
2798: 2799: 2800: 2801: 2802: 2803: 2804: 2805: 2806: 2807: 2808: 2809: 2810: 2811: 2812: 2813:
2814: public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2815: {
2816: $query = RewritingQuery::create(null, $criteria);
2817: $query->joinWith('Folder', $join_behavior);
2818:
2819: return $this->getRewritings($query, $con);
2820: }
2821:
2822: 2823: 2824: 2825: 2826: 2827: 2828: 2829: 2830:
2831: public function clearContentFolders()
2832: {
2833: $this->collContentFolders = null;
2834: $this->collContentFoldersPartial = null;
2835:
2836: return $this;
2837: }
2838:
2839: 2840: 2841: 2842: 2843:
2844: public function resetPartialContentFolders($v = true)
2845: {
2846: $this->collContentFoldersPartial = $v;
2847: }
2848:
2849: 2850: 2851: 2852: 2853: 2854: 2855: 2856: 2857: 2858: 2859: 2860:
2861: public function initContentFolders($overrideExisting = true)
2862: {
2863: if (null !== $this->collContentFolders && !$overrideExisting) {
2864: return;
2865: }
2866: $this->collContentFolders = new PropelObjectCollection();
2867: $this->collContentFolders->setModel('ContentFolder');
2868: }
2869:
2870: 2871: 2872: 2873: 2874: 2875: 2876: 2877: 2878: 2879: 2880: 2881: 2882: 2883:
2884: public function getContentFolders($criteria = null, PropelPDO $con = null)
2885: {
2886: $partial = $this->collContentFoldersPartial && !$this->isNew();
2887: if (null === $this->collContentFolders || null !== $criteria || $partial) {
2888: if ($this->isNew() && null === $this->collContentFolders) {
2889:
2890: $this->initContentFolders();
2891: } else {
2892: $collContentFolders = ContentFolderQuery::create(null, $criteria)
2893: ->filterByContent($this)
2894: ->find($con);
2895: if (null !== $criteria) {
2896: if (false !== $this->collContentFoldersPartial && count($collContentFolders)) {
2897: $this->initContentFolders(false);
2898:
2899: foreach($collContentFolders as $obj) {
2900: if (false == $this->collContentFolders->contains($obj)) {
2901: $this->collContentFolders->append($obj);
2902: }
2903: }
2904:
2905: $this->collContentFoldersPartial = true;
2906: }
2907:
2908: $collContentFolders->getInternalIterator()->rewind();
2909: return $collContentFolders;
2910: }
2911:
2912: if($partial && $this->collContentFolders) {
2913: foreach($this->collContentFolders as $obj) {
2914: if($obj->isNew()) {
2915: $collContentFolders[] = $obj;
2916: }
2917: }
2918: }
2919:
2920: $this->collContentFolders = $collContentFolders;
2921: $this->collContentFoldersPartial = false;
2922: }
2923: }
2924:
2925: return $this->collContentFolders;
2926: }
2927:
2928: 2929: 2930: 2931: 2932: 2933: 2934: 2935: 2936: 2937:
2938: public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null)
2939: {
2940: $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders);
2941:
2942: $this->contentFoldersScheduledForDeletion = unserialize(serialize($contentFoldersToDelete));
2943:
2944: foreach ($contentFoldersToDelete as $contentFolderRemoved) {
2945: $contentFolderRemoved->setContent(null);
2946: }
2947:
2948: $this->collContentFolders = null;
2949: foreach ($contentFolders as $contentFolder) {
2950: $this->addContentFolder($contentFolder);
2951: }
2952:
2953: $this->collContentFolders = $contentFolders;
2954: $this->collContentFoldersPartial = false;
2955:
2956: return $this;
2957: }
2958:
2959: 2960: 2961: 2962: 2963: 2964: 2965: 2966: 2967:
2968: public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2969: {
2970: $partial = $this->collContentFoldersPartial && !$this->isNew();
2971: if (null === $this->collContentFolders || null !== $criteria || $partial) {
2972: if ($this->isNew() && null === $this->collContentFolders) {
2973: return 0;
2974: }
2975:
2976: if($partial && !$criteria) {
2977: return count($this->getContentFolders());
2978: }
2979: $query = ContentFolderQuery::create(null, $criteria);
2980: if ($distinct) {
2981: $query->distinct();
2982: }
2983:
2984: return $query
2985: ->filterByContent($this)
2986: ->count($con);
2987: }
2988:
2989: return count($this->collContentFolders);
2990: }
2991:
2992: 2993: 2994: 2995: 2996: 2997: 2998:
2999: public function addContentFolder(ContentFolder $l)
3000: {
3001: if ($this->collContentFolders === null) {
3002: $this->initContentFolders();
3003: $this->collContentFoldersPartial = true;
3004: }
3005: if (!in_array($l, $this->collContentFolders->getArrayCopy(), true)) {
3006: $this->doAddContentFolder($l);
3007: }
3008:
3009: return $this;
3010: }
3011:
3012: 3013: 3014:
3015: protected function doAddContentFolder($contentFolder)
3016: {
3017: $this->collContentFolders[]= $contentFolder;
3018: $contentFolder->setContent($this);
3019: }
3020:
3021: 3022: 3023: 3024:
3025: public function removeContentFolder($contentFolder)
3026: {
3027: if ($this->getContentFolders()->contains($contentFolder)) {
3028: $this->collContentFolders->remove($this->collContentFolders->search($contentFolder));
3029: if (null === $this->contentFoldersScheduledForDeletion) {
3030: $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders;
3031: $this->contentFoldersScheduledForDeletion->clear();
3032: }
3033: $this->contentFoldersScheduledForDeletion[]= clone $contentFolder;
3034: $contentFolder->setContent(null);
3035: }
3036:
3037: return $this;
3038: }
3039:
3040:
3041: 3042: 3043: 3044: 3045: 3046: 3047: 3048: 3049: 3050: 3051: 3052: 3053: 3054: 3055: 3056:
3057: public function getContentFoldersJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3058: {
3059: $query = ContentFolderQuery::create(null, $criteria);
3060: $query->joinWith('Folder', $join_behavior);
3061:
3062: return $this->getContentFolders($query, $con);
3063: }
3064:
3065: 3066: 3067: 3068: 3069: 3070: 3071: 3072: 3073:
3074: public function clearContentI18ns()
3075: {
3076: $this->collContentI18ns = null;
3077: $this->collContentI18nsPartial = null;
3078:
3079: return $this;
3080: }
3081:
3082: 3083: 3084: 3085: 3086:
3087: public function resetPartialContentI18ns($v = true)
3088: {
3089: $this->collContentI18nsPartial = $v;
3090: }
3091:
3092: 3093: 3094: 3095: 3096: 3097: 3098: 3099: 3100: 3101: 3102: 3103:
3104: public function initContentI18ns($overrideExisting = true)
3105: {
3106: if (null !== $this->collContentI18ns && !$overrideExisting) {
3107: return;
3108: }
3109: $this->collContentI18ns = new PropelObjectCollection();
3110: $this->collContentI18ns->setModel('ContentI18n');
3111: }
3112:
3113: 3114: 3115: 3116: 3117: 3118: 3119: 3120: 3121: 3122: 3123: 3124: 3125: 3126:
3127: public function getContentI18ns($criteria = null, PropelPDO $con = null)
3128: {
3129: $partial = $this->collContentI18nsPartial && !$this->isNew();
3130: if (null === $this->collContentI18ns || null !== $criteria || $partial) {
3131: if ($this->isNew() && null === $this->collContentI18ns) {
3132:
3133: $this->initContentI18ns();
3134: } else {
3135: $collContentI18ns = ContentI18nQuery::create(null, $criteria)
3136: ->filterByContent($this)
3137: ->find($con);
3138: if (null !== $criteria) {
3139: if (false !== $this->collContentI18nsPartial && count($collContentI18ns)) {
3140: $this->initContentI18ns(false);
3141:
3142: foreach($collContentI18ns as $obj) {
3143: if (false == $this->collContentI18ns->contains($obj)) {
3144: $this->collContentI18ns->append($obj);
3145: }
3146: }
3147:
3148: $this->collContentI18nsPartial = true;
3149: }
3150:
3151: $collContentI18ns->getInternalIterator()->rewind();
3152: return $collContentI18ns;
3153: }
3154:
3155: if($partial && $this->collContentI18ns) {
3156: foreach($this->collContentI18ns as $obj) {
3157: if($obj->isNew()) {
3158: $collContentI18ns[] = $obj;
3159: }
3160: }
3161: }
3162:
3163: $this->collContentI18ns = $collContentI18ns;
3164: $this->collContentI18nsPartial = false;
3165: }
3166: }
3167:
3168: return $this->collContentI18ns;
3169: }
3170:
3171: 3172: 3173: 3174: 3175: 3176: 3177: 3178: 3179: 3180:
3181: public function setContentI18ns(PropelCollection $contentI18ns, PropelPDO $con = null)
3182: {
3183: $contentI18nsToDelete = $this->getContentI18ns(new Criteria(), $con)->diff($contentI18ns);
3184:
3185: $this->contentI18nsScheduledForDeletion = unserialize(serialize($contentI18nsToDelete));
3186:
3187: foreach ($contentI18nsToDelete as $contentI18nRemoved) {
3188: $contentI18nRemoved->setContent(null);
3189: }
3190:
3191: $this->collContentI18ns = null;
3192: foreach ($contentI18ns as $contentI18n) {
3193: $this->addContentI18n($contentI18n);
3194: }
3195:
3196: $this->collContentI18ns = $contentI18ns;
3197: $this->collContentI18nsPartial = false;
3198:
3199: return $this;
3200: }
3201:
3202: 3203: 3204: 3205: 3206: 3207: 3208: 3209: 3210:
3211: public function countContentI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3212: {
3213: $partial = $this->collContentI18nsPartial && !$this->isNew();
3214: if (null === $this->collContentI18ns || null !== $criteria || $partial) {
3215: if ($this->isNew() && null === $this->collContentI18ns) {
3216: return 0;
3217: }
3218:
3219: if($partial && !$criteria) {
3220: return count($this->getContentI18ns());
3221: }
3222: $query = ContentI18nQuery::create(null, $criteria);
3223: if ($distinct) {
3224: $query->distinct();
3225: }
3226:
3227: return $query
3228: ->filterByContent($this)
3229: ->count($con);
3230: }
3231:
3232: return count($this->collContentI18ns);
3233: }
3234:
3235: 3236: 3237: 3238: 3239: 3240: 3241:
3242: public function addContentI18n(ContentI18n $l)
3243: {
3244: if ($l && $locale = $l->getLocale()) {
3245: $this->setLocale($locale);
3246: $this->currentTranslations[$locale] = $l;
3247: }
3248: if ($this->collContentI18ns === null) {
3249: $this->initContentI18ns();
3250: $this->collContentI18nsPartial = true;
3251: }
3252: if (!in_array($l, $this->collContentI18ns->getArrayCopy(), true)) {
3253: $this->doAddContentI18n($l);
3254: }
3255:
3256: return $this;
3257: }
3258:
3259: 3260: 3261:
3262: protected function doAddContentI18n($contentI18n)
3263: {
3264: $this->collContentI18ns[]= $contentI18n;
3265: $contentI18n->setContent($this);
3266: }
3267:
3268: 3269: 3270: 3271:
3272: public function removeContentI18n($contentI18n)
3273: {
3274: if ($this->getContentI18ns()->contains($contentI18n)) {
3275: $this->collContentI18ns->remove($this->collContentI18ns->search($contentI18n));
3276: if (null === $this->contentI18nsScheduledForDeletion) {
3277: $this->contentI18nsScheduledForDeletion = clone $this->collContentI18ns;
3278: $this->contentI18nsScheduledForDeletion->clear();
3279: }
3280: $this->contentI18nsScheduledForDeletion[]= clone $contentI18n;
3281: $contentI18n->setContent(null);
3282: }
3283:
3284: return $this;
3285: }
3286:
3287: 3288: 3289: 3290: 3291: 3292: 3293: 3294: 3295:
3296: public function clearContentVersions()
3297: {
3298: $this->collContentVersions = null;
3299: $this->collContentVersionsPartial = null;
3300:
3301: return $this;
3302: }
3303:
3304: 3305: 3306: 3307: 3308:
3309: public function resetPartialContentVersions($v = true)
3310: {
3311: $this->collContentVersionsPartial = $v;
3312: }
3313:
3314: 3315: 3316: 3317: 3318: 3319: 3320: 3321: 3322: 3323: 3324: 3325:
3326: public function initContentVersions($overrideExisting = true)
3327: {
3328: if (null !== $this->collContentVersions && !$overrideExisting) {
3329: return;
3330: }
3331: $this->collContentVersions = new PropelObjectCollection();
3332: $this->collContentVersions->setModel('ContentVersion');
3333: }
3334:
3335: 3336: 3337: 3338: 3339: 3340: 3341: 3342: 3343: 3344: 3345: 3346: 3347: 3348:
3349: public function getContentVersions($criteria = null, PropelPDO $con = null)
3350: {
3351: $partial = $this->collContentVersionsPartial && !$this->isNew();
3352: if (null === $this->collContentVersions || null !== $criteria || $partial) {
3353: if ($this->isNew() && null === $this->collContentVersions) {
3354:
3355: $this->initContentVersions();
3356: } else {
3357: $collContentVersions = ContentVersionQuery::create(null, $criteria)
3358: ->filterByContent($this)
3359: ->find($con);
3360: if (null !== $criteria) {
3361: if (false !== $this->collContentVersionsPartial && count($collContentVersions)) {
3362: $this->initContentVersions(false);
3363:
3364: foreach($collContentVersions as $obj) {
3365: if (false == $this->collContentVersions->contains($obj)) {
3366: $this->collContentVersions->append($obj);
3367: }
3368: }
3369:
3370: $this->collContentVersionsPartial = true;
3371: }
3372:
3373: $collContentVersions->getInternalIterator()->rewind();
3374: return $collContentVersions;
3375: }
3376:
3377: if($partial && $this->collContentVersions) {
3378: foreach($this->collContentVersions as $obj) {
3379: if($obj->isNew()) {
3380: $collContentVersions[] = $obj;
3381: }
3382: }
3383: }
3384:
3385: $this->collContentVersions = $collContentVersions;
3386: $this->collContentVersionsPartial = false;
3387: }
3388: }
3389:
3390: return $this->collContentVersions;
3391: }
3392:
3393: 3394: 3395: 3396: 3397: 3398: 3399: 3400: 3401: 3402:
3403: public function setContentVersions(PropelCollection $contentVersions, PropelPDO $con = null)
3404: {
3405: $contentVersionsToDelete = $this->getContentVersions(new Criteria(), $con)->diff($contentVersions);
3406:
3407: $this->contentVersionsScheduledForDeletion = unserialize(serialize($contentVersionsToDelete));
3408:
3409: foreach ($contentVersionsToDelete as $contentVersionRemoved) {
3410: $contentVersionRemoved->setContent(null);
3411: }
3412:
3413: $this->collContentVersions = null;
3414: foreach ($contentVersions as $contentVersion) {
3415: $this->addContentVersion($contentVersion);
3416: }
3417:
3418: $this->collContentVersions = $contentVersions;
3419: $this->collContentVersionsPartial = false;
3420:
3421: return $this;
3422: }
3423:
3424: 3425: 3426: 3427: 3428: 3429: 3430: 3431: 3432:
3433: public function countContentVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3434: {
3435: $partial = $this->collContentVersionsPartial && !$this->isNew();
3436: if (null === $this->collContentVersions || null !== $criteria || $partial) {
3437: if ($this->isNew() && null === $this->collContentVersions) {
3438: return 0;
3439: }
3440:
3441: if($partial && !$criteria) {
3442: return count($this->getContentVersions());
3443: }
3444: $query = ContentVersionQuery::create(null, $criteria);
3445: if ($distinct) {
3446: $query->distinct();
3447: }
3448:
3449: return $query
3450: ->filterByContent($this)
3451: ->count($con);
3452: }
3453:
3454: return count($this->collContentVersions);
3455: }
3456:
3457: 3458: 3459: 3460: 3461: 3462: 3463:
3464: public function addContentVersion(ContentVersion $l)
3465: {
3466: if ($this->collContentVersions === null) {
3467: $this->initContentVersions();
3468: $this->collContentVersionsPartial = true;
3469: }
3470: if (!in_array($l, $this->collContentVersions->getArrayCopy(), true)) {
3471: $this->doAddContentVersion($l);
3472: }
3473:
3474: return $this;
3475: }
3476:
3477: 3478: 3479:
3480: protected function doAddContentVersion($contentVersion)
3481: {
3482: $this->collContentVersions[]= $contentVersion;
3483: $contentVersion->setContent($this);
3484: }
3485:
3486: 3487: 3488: 3489:
3490: public function removeContentVersion($contentVersion)
3491: {
3492: if ($this->getContentVersions()->contains($contentVersion)) {
3493: $this->collContentVersions->remove($this->collContentVersions->search($contentVersion));
3494: if (null === $this->contentVersionsScheduledForDeletion) {
3495: $this->contentVersionsScheduledForDeletion = clone $this->collContentVersions;
3496: $this->contentVersionsScheduledForDeletion->clear();
3497: }
3498: $this->contentVersionsScheduledForDeletion[]= clone $contentVersion;
3499: $contentVersion->setContent(null);
3500: }
3501:
3502: return $this;
3503: }
3504:
3505: 3506: 3507:
3508: public function clear()
3509: {
3510: $this->id = null;
3511: $this->visible = null;
3512: $this->position = null;
3513: $this->created_at = null;
3514: $this->updated_at = null;
3515: $this->version = null;
3516: $this->version_created_at = null;
3517: $this->version_created_by = null;
3518: $this->alreadyInSave = false;
3519: $this->alreadyInValidation = false;
3520: $this->alreadyInClearAllReferencesDeep = false;
3521: $this->clearAllReferences();
3522: $this->applyDefaultValues();
3523: $this->resetModified();
3524: $this->setNew(true);
3525: $this->setDeleted(false);
3526: }
3527:
3528: 3529: 3530: 3531: 3532: 3533: 3534: 3535: 3536:
3537: public function clearAllReferences($deep = false)
3538: {
3539: if ($deep && !$this->alreadyInClearAllReferencesDeep) {
3540: $this->alreadyInClearAllReferencesDeep = true;
3541: if ($this->collContentAssocs) {
3542: foreach ($this->collContentAssocs as $o) {
3543: $o->clearAllReferences($deep);
3544: }
3545: }
3546: if ($this->collImages) {
3547: foreach ($this->collImages as $o) {
3548: $o->clearAllReferences($deep);
3549: }
3550: }
3551: if ($this->collDocuments) {
3552: foreach ($this->collDocuments as $o) {
3553: $o->clearAllReferences($deep);
3554: }
3555: }
3556: if ($this->collRewritings) {
3557: foreach ($this->collRewritings as $o) {
3558: $o->clearAllReferences($deep);
3559: }
3560: }
3561: if ($this->collContentFolders) {
3562: foreach ($this->collContentFolders as $o) {
3563: $o->clearAllReferences($deep);
3564: }
3565: }
3566: if ($this->collContentI18ns) {
3567: foreach ($this->collContentI18ns as $o) {
3568: $o->clearAllReferences($deep);
3569: }
3570: }
3571: if ($this->collContentVersions) {
3572: foreach ($this->collContentVersions as $o) {
3573: $o->clearAllReferences($deep);
3574: }
3575: }
3576:
3577: $this->alreadyInClearAllReferencesDeep = false;
3578: }
3579:
3580:
3581: $this->currentLocale = 'en_US';
3582: $this->currentTranslations = null;
3583:
3584: if ($this->collContentAssocs instanceof PropelCollection) {
3585: $this->collContentAssocs->clearIterator();
3586: }
3587: $this->collContentAssocs = null;
3588: if ($this->collImages instanceof PropelCollection) {
3589: $this->collImages->clearIterator();
3590: }
3591: $this->collImages = null;
3592: if ($this->collDocuments instanceof PropelCollection) {
3593: $this->collDocuments->clearIterator();
3594: }
3595: $this->collDocuments = null;
3596: if ($this->collRewritings instanceof PropelCollection) {
3597: $this->collRewritings->clearIterator();
3598: }
3599: $this->collRewritings = null;
3600: if ($this->collContentFolders instanceof PropelCollection) {
3601: $this->collContentFolders->clearIterator();
3602: }
3603: $this->collContentFolders = null;
3604: if ($this->collContentI18ns instanceof PropelCollection) {
3605: $this->collContentI18ns->clearIterator();
3606: }
3607: $this->collContentI18ns = null;
3608: if ($this->collContentVersions instanceof PropelCollection) {
3609: $this->collContentVersions->clearIterator();
3610: }
3611: $this->collContentVersions = null;
3612: }
3613:
3614: 3615: 3616: 3617: 3618:
3619: public function __toString()
3620: {
3621: return (string) $this->exportTo(ContentPeer::DEFAULT_STRING_FORMAT);
3622: }
3623:
3624: 3625: 3626: 3627: 3628:
3629: public function isAlreadyInSave()
3630: {
3631: return $this->alreadyInSave;
3632: }
3633:
3634:
3635:
3636: 3637: 3638: 3639: 3640:
3641: public function keepUpdateDateUnchanged()
3642: {
3643: $this->modifiedColumns[] = ContentPeer::UPDATED_AT;
3644:
3645: return $this;
3646: }
3647:
3648:
3649:
3650: 3651: 3652: 3653: 3654: 3655: 3656:
3657: public function setLocale($locale = 'en_US')
3658: {
3659: $this->currentLocale = $locale;
3660:
3661: return $this;
3662: }
3663:
3664: 3665: 3666: 3667: 3668:
3669: public function getLocale()
3670: {
3671: return $this->currentLocale;
3672: }
3673:
3674: 3675: 3676: 3677: 3678: 3679: 3680:
3681: public function getTranslation($locale = 'en_US', PropelPDO $con = null)
3682: {
3683: if (!isset($this->currentTranslations[$locale])) {
3684: if (null !== $this->collContentI18ns) {
3685: foreach ($this->collContentI18ns as $translation) {
3686: if ($translation->getLocale() == $locale) {
3687: $this->currentTranslations[$locale] = $translation;
3688:
3689: return $translation;
3690: }
3691: }
3692: }
3693: if ($this->isNew()) {
3694: $translation = new ContentI18n();
3695: $translation->setLocale($locale);
3696: } else {
3697: $translation = ContentI18nQuery::create()
3698: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
3699: ->findOneOrCreate($con);
3700: $this->currentTranslations[$locale] = $translation;
3701: }
3702: $this->addContentI18n($translation);
3703: }
3704:
3705: return $this->currentTranslations[$locale];
3706: }
3707:
3708: 3709: 3710: 3711: 3712: 3713: 3714: 3715:
3716: public function removeTranslation($locale = 'en_US', PropelPDO $con = null)
3717: {
3718: if (!$this->isNew()) {
3719: ContentI18nQuery::create()
3720: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
3721: ->delete($con);
3722: }
3723: if (isset($this->currentTranslations[$locale])) {
3724: unset($this->currentTranslations[$locale]);
3725: }
3726: foreach ($this->collContentI18ns as $key => $translation) {
3727: if ($translation->getLocale() == $locale) {
3728: unset($this->collContentI18ns[$key]);
3729: break;
3730: }
3731: }
3732:
3733: return $this;
3734: }
3735:
3736: 3737: 3738: 3739: 3740: 3741:
3742: public function getCurrentTranslation(PropelPDO $con = null)
3743: {
3744: return $this->getTranslation($this->getLocale(), $con);
3745: }
3746:
3747:
3748: 3749: 3750: 3751: 3752:
3753: public function getTitle()
3754: {
3755: return $this->getCurrentTranslation()->getTitle();
3756: }
3757:
3758:
3759: 3760: 3761: 3762: 3763: 3764:
3765: public function setTitle($v)
3766: { $this->getCurrentTranslation()->setTitle($v);
3767:
3768: return $this;
3769: }
3770:
3771:
3772: 3773: 3774: 3775: 3776:
3777: public function getDescription()
3778: {
3779: return $this->getCurrentTranslation()->getDescription();
3780: }
3781:
3782:
3783: 3784: 3785: 3786: 3787: 3788:
3789: public function setDescription($v)
3790: { $this->getCurrentTranslation()->setDescription($v);
3791:
3792: return $this;
3793: }
3794:
3795:
3796: 3797: 3798: 3799: 3800:
3801: public function getChapo()
3802: {
3803: return $this->getCurrentTranslation()->getChapo();
3804: }
3805:
3806:
3807: 3808: 3809: 3810: 3811: 3812:
3813: public function setChapo($v)
3814: { $this->getCurrentTranslation()->setChapo($v);
3815:
3816: return $this;
3817: }
3818:
3819:
3820: 3821: 3822: 3823: 3824:
3825: public function getPostscriptum()
3826: {
3827: return $this->getCurrentTranslation()->getPostscriptum();
3828: }
3829:
3830:
3831: 3832: 3833: 3834: 3835: 3836:
3837: public function setPostscriptum($v)
3838: { $this->getCurrentTranslation()->setPostscriptum($v);
3839:
3840: return $this;
3841: }
3842:
3843:
3844:
3845: 3846: 3847: 3848: 3849:
3850: public function enforceVersioning()
3851: {
3852: $this->enforceVersion = true;
3853:
3854: return $this;
3855: }
3856:
3857: 3858: 3859: 3860: 3861: 3862: 3863:
3864: public function isVersioningNecessary($con = null)
3865: {
3866: if ($this->alreadyInSave) {
3867: return false;
3868: }
3869:
3870: if ($this->enforceVersion) {
3871: return true;
3872: }
3873:
3874: if (ContentPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
3875: return true;
3876: }
3877:
3878: return false;
3879: }
3880:
3881: 3882: 3883: 3884: 3885: 3886: 3887:
3888: public function addVersion($con = null)
3889: {
3890: $this->enforceVersion = false;
3891:
3892: $version = new ContentVersion();
3893: $version->setId($this->getId());
3894: $version->setVisible($this->getVisible());
3895: $version->setPosition($this->getPosition());
3896: $version->setCreatedAt($this->getCreatedAt());
3897: $version->setUpdatedAt($this->getUpdatedAt());
3898: $version->setVersion($this->getVersion());
3899: $version->setVersionCreatedAt($this->getVersionCreatedAt());
3900: $version->setVersionCreatedBy($this->getVersionCreatedBy());
3901: $version->setContent($this);
3902: $version->save($con);
3903:
3904: return $version;
3905: }
3906:
3907: 3908: 3909: 3910: 3911: 3912: 3913: 3914: 3915:
3916: public function toVersion($versionNumber, $con = null)
3917: {
3918: $version = $this->getOneVersion($versionNumber, $con);
3919: if (!$version) {
3920: throw new PropelException(sprintf('No Content object found with version %d', $version));
3921: }
3922: $this->populateFromVersion($version, $con);
3923:
3924: return $this;
3925: }
3926:
3927: 3928: 3929: 3930: 3931: 3932: 3933: 3934: 3935:
3936: public function populateFromVersion($version, $con = null, &$loadedObjects = array())
3937: {
3938:
3939: $loadedObjects['Content'][$version->getId()][$version->getVersion()] = $this;
3940: $this->setId($version->getId());
3941: $this->setVisible($version->getVisible());
3942: $this->setPosition($version->getPosition());
3943: $this->setCreatedAt($version->getCreatedAt());
3944: $this->setUpdatedAt($version->getUpdatedAt());
3945: $this->setVersion($version->getVersion());
3946: $this->setVersionCreatedAt($version->getVersionCreatedAt());
3947: $this->setVersionCreatedBy($version->getVersionCreatedBy());
3948:
3949: return $this;
3950: }
3951:
3952: 3953: 3954: 3955: 3956: 3957: 3958:
3959: public function getLastVersionNumber($con = null)
3960: {
3961: $v = ContentVersionQuery::create()
3962: ->filterByContent($this)
3963: ->orderByVersion('desc')
3964: ->findOne($con);
3965: if (!$v) {
3966: return 0;
3967: }
3968:
3969: return $v->getVersion();
3970: }
3971:
3972: 3973: 3974: 3975: 3976: 3977: 3978:
3979: public function isLastVersion($con = null)
3980: {
3981: return $this->getLastVersionNumber($con) == $this->getVersion();
3982: }
3983:
3984: 3985: 3986: 3987: 3988: 3989: 3990: 3991:
3992: public function getOneVersion($versionNumber, $con = null)
3993: {
3994: return ContentVersionQuery::create()
3995: ->filterByContent($this)
3996: ->filterByVersion($versionNumber)
3997: ->findOne($con);
3998: }
3999:
4000: 4001: 4002: 4003: 4004: 4005: 4006:
4007: public function getAllVersions($con = null)
4008: {
4009: $criteria = new Criteria();
4010: $criteria->addAscendingOrderByColumn(ContentVersionPeer::VERSION);
4011:
4012: return $this->getContentVersions($criteria, $con);
4013: }
4014:
4015: 4016: 4017: 4018: 4019: 4020: 4021: 4022: 4023: 4024: 4025: 4026: 4027: 4028: 4029: 4030: 4031:
4032: public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
4033: {
4034: $fromVersion = $this->toArray();
4035: $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
4036:
4037: return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
4038: }
4039:
4040: 4041: 4042: 4043: 4044: 4045: 4046: 4047: 4048: 4049: 4050: 4051: 4052: 4053: 4054: 4055: 4056: 4057:
4058: public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
4059: {
4060: $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
4061: $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
4062:
4063: return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
4064: }
4065:
4066: 4067: 4068: 4069: 4070: 4071: 4072: 4073: 4074: 4075: 4076: 4077: 4078: 4079: 4080: 4081: 4082:
4083: protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
4084: {
4085: $fromVersionNumber = $fromVersion['Version'];
4086: $toVersionNumber = $toVersion['Version'];
4087: $ignoredColumns = array_merge(array(
4088: 'Version',
4089: 'VersionCreatedAt',
4090: 'VersionCreatedBy',
4091: ), $ignoredColumns);
4092: $diff = array();
4093: foreach ($fromVersion as $key => $value) {
4094: if (in_array($key, $ignoredColumns)) {
4095: continue;
4096: }
4097: if ($toVersion[$key] != $value) {
4098: switch ($keys) {
4099: case 'versions':
4100: $diff[$fromVersionNumber][$key] = $value;
4101: $diff[$toVersionNumber][$key] = $toVersion[$key];
4102: break;
4103: default:
4104: $diff[$key] = array(
4105: $fromVersionNumber => $value,
4106: $toVersionNumber => $toVersion[$key],
4107: );
4108: break;
4109: }
4110: }
4111: }
4112:
4113: return $diff;
4114: }
4115: 4116: 4117: 4118: 4119: 4120: 4121: 4122: 4123:
4124: public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
4125: {
4126: $criteria = ContentVersionQuery::create(null, $criteria);
4127: $criteria->addDescendingOrderByColumn(ContentVersionPeer::VERSION);
4128: $criteria->limit($number);
4129:
4130: return $this->getContentVersions($criteria, $con);
4131: }
4132: }
4133: