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