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