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