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\Category;
19: use Thelia\Model\CategoryQuery;
20: use Thelia\Model\Content;
21: use Thelia\Model\ContentQuery;
22: use Thelia\Model\Document;
23: use Thelia\Model\DocumentI18n;
24: use Thelia\Model\DocumentI18nQuery;
25: use Thelia\Model\DocumentPeer;
26: use Thelia\Model\DocumentQuery;
27: use Thelia\Model\Folder;
28: use Thelia\Model\FolderQuery;
29: use Thelia\Model\Product;
30: use Thelia\Model\ProductQuery;
31:
32: 33: 34: 35: 36: 37: 38:
39: abstract class BaseDocument extends BaseObject implements Persistent
40: {
41: 42: 43:
44: const PEER = 'Thelia\\Model\\DocumentPeer';
45:
46: 47: 48: 49: 50: 51:
52: protected static $peer;
53:
54: 55: 56: 57:
58: protected $startCopy = false;
59:
60: 61: 62: 63:
64: protected $id;
65:
66: 67: 68: 69:
70: protected $product_id;
71:
72: 73: 74: 75:
76: protected $category_id;
77:
78: 79: 80: 81:
82: protected $folder_id;
83:
84: 85: 86: 87:
88: protected $content_id;
89:
90: 91: 92: 93:
94: protected $file;
95:
96: 97: 98: 99:
100: protected $position;
101:
102: 103: 104: 105:
106: protected $created_at;
107:
108: 109: 110: 111:
112: protected $updated_at;
113:
114: 115: 116:
117: protected $aProduct;
118:
119: 120: 121:
122: protected $aCategory;
123:
124: 125: 126:
127: protected $aContent;
128:
129: 130: 131:
132: protected $aFolder;
133:
134: 135: 136:
137: protected $collDocumentI18ns;
138: protected $collDocumentI18nsPartial;
139:
140: 141: 142: 143: 144:
145: protected $alreadyInSave = false;
146:
147: 148: 149: 150: 151:
152: protected $alreadyInValidation = false;
153:
154: 155: 156: 157:
158: protected $alreadyInClearAllReferencesDeep = false;
159:
160:
161:
162: 163: 164: 165:
166: protected $currentLocale = 'en_US';
167:
168: 169: 170: 171:
172: protected $currentTranslations;
173:
174: 175: 176: 177:
178: protected $documentI18nsScheduledForDeletion = null;
179:
180: 181: 182: 183: 184:
185: public function getId()
186: {
187: return $this->id;
188: }
189:
190: 191: 192: 193: 194:
195: public function getProductId()
196: {
197: return $this->product_id;
198: }
199:
200: 201: 202: 203: 204:
205: public function getCategoryId()
206: {
207: return $this->category_id;
208: }
209:
210: 211: 212: 213: 214:
215: public function getFolderId()
216: {
217: return $this->folder_id;
218: }
219:
220: 221: 222: 223: 224:
225: public function getContentId()
226: {
227: return $this->content_id;
228: }
229:
230: 231: 232: 233: 234:
235: public function getFile()
236: {
237: return $this->file;
238: }
239:
240: 241: 242: 243: 244:
245: public function getPosition()
246: {
247: return $this->position;
248: }
249:
250: 251: 252: 253: 254: 255: 256: 257: 258:
259: public function getCreatedAt($format = 'Y-m-d H:i:s')
260: {
261: if ($this->created_at === null) {
262: return null;
263: }
264:
265: if ($this->created_at === '0000-00-00 00:00:00') {
266:
267:
268: return null;
269: }
270:
271: try {
272: $dt = new DateTime($this->created_at);
273: } catch (Exception $x) {
274: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
275: }
276:
277: if ($format === null) {
278:
279: return $dt;
280: }
281:
282: if (strpos($format, '%') !== false) {
283: return strftime($format, $dt->format('U'));
284: }
285:
286: return $dt->format($format);
287:
288: }
289:
290: 291: 292: 293: 294: 295: 296: 297: 298:
299: public function getUpdatedAt($format = 'Y-m-d H:i:s')
300: {
301: if ($this->updated_at === null) {
302: return null;
303: }
304:
305: if ($this->updated_at === '0000-00-00 00:00:00') {
306:
307:
308: return null;
309: }
310:
311: try {
312: $dt = new DateTime($this->updated_at);
313: } catch (Exception $x) {
314: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
315: }
316:
317: if ($format === null) {
318:
319: return $dt;
320: }
321:
322: if (strpos($format, '%') !== false) {
323: return strftime($format, $dt->format('U'));
324: }
325:
326: return $dt->format($format);
327:
328: }
329:
330: 331: 332: 333: 334: 335:
336: public function setId($v)
337: {
338: if ($v !== null && is_numeric($v)) {
339: $v = (int) $v;
340: }
341:
342: if ($this->id !== $v) {
343: $this->id = $v;
344: $this->modifiedColumns[] = DocumentPeer::ID;
345: }
346:
347:
348: return $this;
349: }
350:
351: 352: 353: 354: 355: 356:
357: public function setProductId($v)
358: {
359: if ($v !== null && is_numeric($v)) {
360: $v = (int) $v;
361: }
362:
363: if ($this->product_id !== $v) {
364: $this->product_id = $v;
365: $this->modifiedColumns[] = DocumentPeer::PRODUCT_ID;
366: }
367:
368: if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
369: $this->aProduct = null;
370: }
371:
372:
373: return $this;
374: }
375:
376: 377: 378: 379: 380: 381:
382: public function setCategoryId($v)
383: {
384: if ($v !== null && is_numeric($v)) {
385: $v = (int) $v;
386: }
387:
388: if ($this->category_id !== $v) {
389: $this->category_id = $v;
390: $this->modifiedColumns[] = DocumentPeer::CATEGORY_ID;
391: }
392:
393: if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
394: $this->aCategory = null;
395: }
396:
397:
398: return $this;
399: }
400:
401: 402: 403: 404: 405: 406:
407: public function setFolderId($v)
408: {
409: if ($v !== null && is_numeric($v)) {
410: $v = (int) $v;
411: }
412:
413: if ($this->folder_id !== $v) {
414: $this->folder_id = $v;
415: $this->modifiedColumns[] = DocumentPeer::FOLDER_ID;
416: }
417:
418: if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
419: $this->aFolder = null;
420: }
421:
422:
423: return $this;
424: }
425:
426: 427: 428: 429: 430: 431:
432: public function setContentId($v)
433: {
434: if ($v !== null && is_numeric($v)) {
435: $v = (int) $v;
436: }
437:
438: if ($this->content_id !== $v) {
439: $this->content_id = $v;
440: $this->modifiedColumns[] = DocumentPeer::CONTENT_ID;
441: }
442:
443: if ($this->aContent !== null && $this->aContent->getId() !== $v) {
444: $this->aContent = null;
445: }
446:
447:
448: return $this;
449: }
450:
451: 452: 453: 454: 455: 456:
457: public function setFile($v)
458: {
459: if ($v !== null && is_numeric($v)) {
460: $v = (string) $v;
461: }
462:
463: if ($this->file !== $v) {
464: $this->file = $v;
465: $this->modifiedColumns[] = DocumentPeer::FILE;
466: }
467:
468:
469: return $this;
470: }
471:
472: 473: 474: 475: 476: 477:
478: public function setPosition($v)
479: {
480: if ($v !== null && is_numeric($v)) {
481: $v = (int) $v;
482: }
483:
484: if ($this->position !== $v) {
485: $this->position = $v;
486: $this->modifiedColumns[] = DocumentPeer::POSITION;
487: }
488:
489:
490: return $this;
491: }
492:
493: 494: 495: 496: 497: 498: 499:
500: public function setCreatedAt($v)
501: {
502: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
503: if ($this->created_at !== null || $dt !== null) {
504: $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
505: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
506: if ($currentDateAsString !== $newDateAsString) {
507: $this->created_at = $newDateAsString;
508: $this->modifiedColumns[] = DocumentPeer::CREATED_AT;
509: }
510: }
511:
512:
513: return $this;
514: }
515:
516: 517: 518: 519: 520: 521: 522:
523: public function setUpdatedAt($v)
524: {
525: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
526: if ($this->updated_at !== null || $dt !== null) {
527: $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
528: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
529: if ($currentDateAsString !== $newDateAsString) {
530: $this->updated_at = $newDateAsString;
531: $this->modifiedColumns[] = DocumentPeer::UPDATED_AT;
532: }
533: }
534:
535:
536: return $this;
537: }
538:
539: 540: 541: 542: 543: 544: 545: 546:
547: public function hasOnlyDefaultValues()
548: {
549:
550: return true;
551: }
552:
553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566:
567: public function hydrate($row, $startcol = 0, $rehydrate = false)
568: {
569: try {
570:
571: $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
572: $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
573: $this->category_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
574: $this->folder_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
575: $this->content_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
576: $this->file = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
577: $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
578: $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
579: $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
580: $this->resetModified();
581:
582: $this->setNew(false);
583:
584: if ($rehydrate) {
585: $this->ensureConsistency();
586: }
587: $this->postHydrate($row, $startcol, $rehydrate);
588: return $startcol + 9;
589:
590: } catch (Exception $e) {
591: throw new PropelException("Error populating Document object", $e);
592: }
593: }
594:
595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607:
608: public function ensureConsistency()
609: {
610:
611: if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
612: $this->aProduct = null;
613: }
614: if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
615: $this->aCategory = null;
616: }
617: if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
618: $this->aFolder = null;
619: }
620: if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
621: $this->aContent = null;
622: }
623: }
624:
625: 626: 627: 628: 629: 630: 631: 632: 633: 634:
635: public function reload($deep = false, PropelPDO $con = null)
636: {
637: if ($this->isDeleted()) {
638: throw new PropelException("Cannot reload a deleted object.");
639: }
640:
641: if ($this->isNew()) {
642: throw new PropelException("Cannot reload an unsaved object.");
643: }
644:
645: if ($con === null) {
646: $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
647: }
648:
649:
650:
651:
652: $stmt = DocumentPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
653: $row = $stmt->fetch(PDO::FETCH_NUM);
654: $stmt->closeCursor();
655: if (!$row) {
656: throw new PropelException('Cannot find matching row in the database to reload object values.');
657: }
658: $this->hydrate($row, 0, true);
659:
660: if ($deep) {
661:
662: $this->aProduct = null;
663: $this->aCategory = null;
664: $this->aContent = null;
665: $this->aFolder = null;
666: $this->collDocumentI18ns = null;
667:
668: }
669: }
670:
671: 672: 673: 674: 675: 676: 677: 678: 679: 680:
681: public function delete(PropelPDO $con = null)
682: {
683: if ($this->isDeleted()) {
684: throw new PropelException("This object has already been deleted.");
685: }
686:
687: if ($con === null) {
688: $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
689: }
690:
691: $con->beginTransaction();
692: try {
693: $deleteQuery = DocumentQuery::create()
694: ->filterByPrimaryKey($this->getPrimaryKey());
695: $ret = $this->preDelete($con);
696: if ($ret) {
697: $deleteQuery->delete($con);
698: $this->postDelete($con);
699: $con->commit();
700: $this->setDeleted(true);
701: } else {
702: $con->commit();
703: }
704: } catch (Exception $e) {
705: $con->rollBack();
706: throw $e;
707: }
708: }
709:
710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723:
724: public function save(PropelPDO $con = null)
725: {
726: if ($this->isDeleted()) {
727: throw new PropelException("You cannot save an object that has been deleted.");
728: }
729:
730: if ($con === null) {
731: $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
732: }
733:
734: $con->beginTransaction();
735: $isInsert = $this->isNew();
736: try {
737: $ret = $this->preSave($con);
738: if ($isInsert) {
739: $ret = $ret && $this->preInsert($con);
740:
741: if (!$this->isColumnModified(DocumentPeer::CREATED_AT)) {
742: $this->setCreatedAt(time());
743: }
744: if (!$this->isColumnModified(DocumentPeer::UPDATED_AT)) {
745: $this->setUpdatedAt(time());
746: }
747: } else {
748: $ret = $ret && $this->preUpdate($con);
749:
750: if ($this->isModified() && !$this->isColumnModified(DocumentPeer::UPDATED_AT)) {
751: $this->setUpdatedAt(time());
752: }
753: }
754: if ($ret) {
755: $affectedRows = $this->doSave($con);
756: if ($isInsert) {
757: $this->postInsert($con);
758: } else {
759: $this->postUpdate($con);
760: }
761: $this->postSave($con);
762: DocumentPeer::addInstanceToPool($this);
763: } else {
764: $affectedRows = 0;
765: }
766: $con->commit();
767:
768: return $affectedRows;
769: } catch (Exception $e) {
770: $con->rollBack();
771: throw $e;
772: }
773: }
774:
775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785:
786: protected function doSave(PropelPDO $con)
787: {
788: $affectedRows = 0;
789: if (!$this->alreadyInSave) {
790: $this->alreadyInSave = true;
791:
792:
793:
794:
795:
796:
797: if ($this->aProduct !== null) {
798: if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
799: $affectedRows += $this->aProduct->save($con);
800: }
801: $this->setProduct($this->aProduct);
802: }
803:
804: if ($this->aCategory !== null) {
805: if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
806: $affectedRows += $this->aCategory->save($con);
807: }
808: $this->setCategory($this->aCategory);
809: }
810:
811: if ($this->aContent !== null) {
812: if ($this->aContent->isModified() || $this->aContent->isNew()) {
813: $affectedRows += $this->aContent->save($con);
814: }
815: $this->setContent($this->aContent);
816: }
817:
818: if ($this->aFolder !== null) {
819: if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
820: $affectedRows += $this->aFolder->save($con);
821: }
822: $this->setFolder($this->aFolder);
823: }
824:
825: if ($this->isNew() || $this->isModified()) {
826:
827: if ($this->isNew()) {
828: $this->doInsert($con);
829: } else {
830: $this->doUpdate($con);
831: }
832: $affectedRows += 1;
833: $this->resetModified();
834: }
835:
836: if ($this->documentI18nsScheduledForDeletion !== null) {
837: if (!$this->documentI18nsScheduledForDeletion->isEmpty()) {
838: DocumentI18nQuery::create()
839: ->filterByPrimaryKeys($this->documentI18nsScheduledForDeletion->getPrimaryKeys(false))
840: ->delete($con);
841: $this->documentI18nsScheduledForDeletion = null;
842: }
843: }
844:
845: if ($this->collDocumentI18ns !== null) {
846: foreach ($this->collDocumentI18ns as $referrerFK) {
847: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
848: $affectedRows += $referrerFK->save($con);
849: }
850: }
851: }
852:
853: $this->alreadyInSave = false;
854:
855: }
856:
857: return $affectedRows;
858: }
859:
860: 861: 862: 863: 864: 865: 866: 867:
868: protected function doInsert(PropelPDO $con)
869: {
870: $modifiedColumns = array();
871: $index = 0;
872:
873: $this->modifiedColumns[] = DocumentPeer::ID;
874: if (null !== $this->id) {
875: throw new PropelException('Cannot insert a value for auto-increment primary key (' . DocumentPeer::ID . ')');
876: }
877:
878:
879: if ($this->isColumnModified(DocumentPeer::ID)) {
880: $modifiedColumns[':p' . $index++] = '`id`';
881: }
882: if ($this->isColumnModified(DocumentPeer::PRODUCT_ID)) {
883: $modifiedColumns[':p' . $index++] = '`product_id`';
884: }
885: if ($this->isColumnModified(DocumentPeer::CATEGORY_ID)) {
886: $modifiedColumns[':p' . $index++] = '`category_id`';
887: }
888: if ($this->isColumnModified(DocumentPeer::FOLDER_ID)) {
889: $modifiedColumns[':p' . $index++] = '`folder_id`';
890: }
891: if ($this->isColumnModified(DocumentPeer::CONTENT_ID)) {
892: $modifiedColumns[':p' . $index++] = '`content_id`';
893: }
894: if ($this->isColumnModified(DocumentPeer::FILE)) {
895: $modifiedColumns[':p' . $index++] = '`file`';
896: }
897: if ($this->isColumnModified(DocumentPeer::POSITION)) {
898: $modifiedColumns[':p' . $index++] = '`position`';
899: }
900: if ($this->isColumnModified(DocumentPeer::CREATED_AT)) {
901: $modifiedColumns[':p' . $index++] = '`created_at`';
902: }
903: if ($this->isColumnModified(DocumentPeer::UPDATED_AT)) {
904: $modifiedColumns[':p' . $index++] = '`updated_at`';
905: }
906:
907: $sql = sprintf(
908: 'INSERT INTO `document` (%s) VALUES (%s)',
909: implode(', ', $modifiedColumns),
910: implode(', ', array_keys($modifiedColumns))
911: );
912:
913: try {
914: $stmt = $con->prepare($sql);
915: foreach ($modifiedColumns as $identifier => $columnName) {
916: switch ($columnName) {
917: case '`id`':
918: $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
919: break;
920: case '`product_id`':
921: $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
922: break;
923: case '`category_id`':
924: $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
925: break;
926: case '`folder_id`':
927: $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
928: break;
929: case '`content_id`':
930: $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
931: break;
932: case '`file`':
933: $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR);
934: break;
935: case '`position`':
936: $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
937: break;
938: case '`created_at`':
939: $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
940: break;
941: case '`updated_at`':
942: $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
943: break;
944: }
945: }
946: $stmt->execute();
947: } catch (Exception $e) {
948: Propel::log($e->getMessage(), Propel::LOG_ERR);
949: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
950: }
951:
952: try {
953: $pk = $con->lastInsertId();
954: } catch (Exception $e) {
955: throw new PropelException('Unable to get autoincrement id.', $e);
956: }
957: $this->setId($pk);
958:
959: $this->setNew(false);
960: }
961:
962: 963: 964: 965: 966: 967: 968:
969: protected function doUpdate(PropelPDO $con)
970: {
971: $selectCriteria = $this->buildPkeyCriteria();
972: $valuesCriteria = $this->buildCriteria();
973: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
974: }
975:
976: 977: 978: 979:
980: protected $validationFailures = array();
981:
982: 983: 984: 985: 986: 987: 988:
989: public function getValidationFailures()
990: {
991: return $this->validationFailures;
992: }
993:
994: 995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004:
1005: public function validate($columns = null)
1006: {
1007: $res = $this->doValidate($columns);
1008: if ($res === true) {
1009: $this->validationFailures = array();
1010:
1011: return true;
1012: }
1013:
1014: $this->validationFailures = $res;
1015:
1016: return false;
1017: }
1018:
1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028:
1029: protected function doValidate($columns = null)
1030: {
1031: if (!$this->alreadyInValidation) {
1032: $this->alreadyInValidation = true;
1033: $retval = null;
1034:
1035: $failureMap = array();
1036:
1037:
1038:
1039:
1040:
1041:
1042:
1043: if ($this->aProduct !== null) {
1044: if (!$this->aProduct->validate($columns)) {
1045: $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
1046: }
1047: }
1048:
1049: if ($this->aCategory !== null) {
1050: if (!$this->aCategory->validate($columns)) {
1051: $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
1052: }
1053: }
1054:
1055: if ($this->aContent !== null) {
1056: if (!$this->aContent->validate($columns)) {
1057: $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures());
1058: }
1059: }
1060:
1061: if ($this->aFolder !== null) {
1062: if (!$this->aFolder->validate($columns)) {
1063: $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures());
1064: }
1065: }
1066:
1067:
1068: if (($retval = DocumentPeer::doValidate($this, $columns)) !== true) {
1069: $failureMap = array_merge($failureMap, $retval);
1070: }
1071:
1072:
1073: if ($this->collDocumentI18ns !== null) {
1074: foreach ($this->collDocumentI18ns as $referrerFK) {
1075: if (!$referrerFK->validate($columns)) {
1076: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1077: }
1078: }
1079: }
1080:
1081:
1082: $this->alreadyInValidation = false;
1083: }
1084:
1085: return (!empty($failureMap) ? $failureMap : true);
1086: }
1087:
1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097:
1098: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1099: {
1100: $pos = DocumentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1101: $field = $this->getByPosition($pos);
1102:
1103: return $field;
1104: }
1105:
1106: 1107: 1108: 1109: 1110: 1111: 1112:
1113: public function getByPosition($pos)
1114: {
1115: switch ($pos) {
1116: case 0:
1117: return $this->getId();
1118: break;
1119: case 1:
1120: return $this->getProductId();
1121: break;
1122: case 2:
1123: return $this->getCategoryId();
1124: break;
1125: case 3:
1126: return $this->getFolderId();
1127: break;
1128: case 4:
1129: return $this->getContentId();
1130: break;
1131: case 5:
1132: return $this->getFile();
1133: break;
1134: case 6:
1135: return $this->getPosition();
1136: break;
1137: case 7:
1138: return $this->getCreatedAt();
1139: break;
1140: case 8:
1141: return $this->getUpdatedAt();
1142: break;
1143: default:
1144: return null;
1145: break;
1146: }
1147: }
1148:
1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163:
1164: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1165: {
1166: if (isset($alreadyDumpedObjects['Document'][$this->getPrimaryKey()])) {
1167: return '*RECURSION*';
1168: }
1169: $alreadyDumpedObjects['Document'][$this->getPrimaryKey()] = true;
1170: $keys = DocumentPeer::getFieldNames($keyType);
1171: $result = array(
1172: $keys[0] => $this->getId(),
1173: $keys[1] => $this->getProductId(),
1174: $keys[2] => $this->getCategoryId(),
1175: $keys[3] => $this->getFolderId(),
1176: $keys[4] => $this->getContentId(),
1177: $keys[5] => $this->getFile(),
1178: $keys[6] => $this->getPosition(),
1179: $keys[7] => $this->getCreatedAt(),
1180: $keys[8] => $this->getUpdatedAt(),
1181: );
1182: if ($includeForeignObjects) {
1183: if (null !== $this->aProduct) {
1184: $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
1185: }
1186: if (null !== $this->aCategory) {
1187: $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
1188: }
1189: if (null !== $this->aContent) {
1190: $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
1191: }
1192: if (null !== $this->aFolder) {
1193: $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
1194: }
1195: if (null !== $this->collDocumentI18ns) {
1196: $result['DocumentI18ns'] = $this->collDocumentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1197: }
1198: }
1199:
1200: return $result;
1201: }
1202:
1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213:
1214: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1215: {
1216: $pos = DocumentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1217:
1218: $this->setByPosition($pos, $value);
1219: }
1220:
1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228:
1229: public function setByPosition($pos, $value)
1230: {
1231: switch ($pos) {
1232: case 0:
1233: $this->setId($value);
1234: break;
1235: case 1:
1236: $this->setProductId($value);
1237: break;
1238: case 2:
1239: $this->setCategoryId($value);
1240: break;
1241: case 3:
1242: $this->setFolderId($value);
1243: break;
1244: case 4:
1245: $this->setContentId($value);
1246: break;
1247: case 5:
1248: $this->setFile($value);
1249: break;
1250: case 6:
1251: $this->setPosition($value);
1252: break;
1253: case 7:
1254: $this->setCreatedAt($value);
1255: break;
1256: case 8:
1257: $this->setUpdatedAt($value);
1258: break;
1259: }
1260: }
1261:
1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278:
1279: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1280: {
1281: $keys = DocumentPeer::getFieldNames($keyType);
1282:
1283: if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1284: if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
1285: if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]);
1286: if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]);
1287: if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]);
1288: if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]);
1289: if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]);
1290: if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
1291: if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
1292: }
1293:
1294: 1295: 1296: 1297: 1298:
1299: public function buildCriteria()
1300: {
1301: $criteria = new Criteria(DocumentPeer::DATABASE_NAME);
1302:
1303: if ($this->isColumnModified(DocumentPeer::ID)) $criteria->add(DocumentPeer::ID, $this->id);
1304: if ($this->isColumnModified(DocumentPeer::PRODUCT_ID)) $criteria->add(DocumentPeer::PRODUCT_ID, $this->product_id);
1305: if ($this->isColumnModified(DocumentPeer::CATEGORY_ID)) $criteria->add(DocumentPeer::CATEGORY_ID, $this->category_id);
1306: if ($this->isColumnModified(DocumentPeer::FOLDER_ID)) $criteria->add(DocumentPeer::FOLDER_ID, $this->folder_id);
1307: if ($this->isColumnModified(DocumentPeer::CONTENT_ID)) $criteria->add(DocumentPeer::CONTENT_ID, $this->content_id);
1308: if ($this->isColumnModified(DocumentPeer::FILE)) $criteria->add(DocumentPeer::FILE, $this->file);
1309: if ($this->isColumnModified(DocumentPeer::POSITION)) $criteria->add(DocumentPeer::POSITION, $this->position);
1310: if ($this->isColumnModified(DocumentPeer::CREATED_AT)) $criteria->add(DocumentPeer::CREATED_AT, $this->created_at);
1311: if ($this->isColumnModified(DocumentPeer::UPDATED_AT)) $criteria->add(DocumentPeer::UPDATED_AT, $this->updated_at);
1312:
1313: return $criteria;
1314: }
1315:
1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323:
1324: public function buildPkeyCriteria()
1325: {
1326: $criteria = new Criteria(DocumentPeer::DATABASE_NAME);
1327: $criteria->add(DocumentPeer::ID, $this->id);
1328:
1329: return $criteria;
1330: }
1331:
1332: 1333: 1334: 1335:
1336: public function getPrimaryKey()
1337: {
1338: return $this->getId();
1339: }
1340:
1341: 1342: 1343: 1344: 1345: 1346:
1347: public function setPrimaryKey($key)
1348: {
1349: $this->setId($key);
1350: }
1351:
1352: 1353: 1354: 1355:
1356: public function isPrimaryKeyNull()
1357: {
1358:
1359: return null === $this->getId();
1360: }
1361:
1362: 1363: 1364: 1365: 1366: 1367: 1368: 1369: 1370: 1371: 1372:
1373: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1374: {
1375: $copyObj->setProductId($this->getProductId());
1376: $copyObj->setCategoryId($this->getCategoryId());
1377: $copyObj->setFolderId($this->getFolderId());
1378: $copyObj->setContentId($this->getContentId());
1379: $copyObj->setFile($this->getFile());
1380: $copyObj->setPosition($this->getPosition());
1381: $copyObj->setCreatedAt($this->getCreatedAt());
1382: $copyObj->setUpdatedAt($this->getUpdatedAt());
1383:
1384: if ($deepCopy && !$this->startCopy) {
1385:
1386:
1387: $copyObj->setNew(false);
1388:
1389: $this->startCopy = true;
1390:
1391: foreach ($this->getDocumentI18ns() as $relObj) {
1392: if ($relObj !== $this) {
1393: $copyObj->addDocumentI18n($relObj->copy($deepCopy));
1394: }
1395: }
1396:
1397:
1398: $this->startCopy = false;
1399: }
1400:
1401: if ($makeNew) {
1402: $copyObj->setNew(true);
1403: $copyObj->setId(NULL);
1404: }
1405: }
1406:
1407: 1408: 1409: 1410: 1411: 1412: 1413: 1414: 1415: 1416: 1417: 1418:
1419: public function copy($deepCopy = false)
1420: {
1421:
1422: $clazz = get_class($this);
1423: $copyObj = new $clazz();
1424: $this->copyInto($copyObj, $deepCopy);
1425:
1426: return $copyObj;
1427: }
1428:
1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437:
1438: public function getPeer()
1439: {
1440: if (self::$peer === null) {
1441: self::$peer = new DocumentPeer();
1442: }
1443:
1444: return self::$peer;
1445: }
1446:
1447: 1448: 1449: 1450: 1451: 1452: 1453:
1454: public function setProduct(Product $v = null)
1455: {
1456: if ($v === null) {
1457: $this->setProductId(NULL);
1458: } else {
1459: $this->setProductId($v->getId());
1460: }
1461:
1462: $this->aProduct = $v;
1463:
1464:
1465:
1466: if ($v !== null) {
1467: $v->addDocument($this);
1468: }
1469:
1470:
1471: return $this;
1472: }
1473:
1474:
1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482:
1483: public function getProduct(PropelPDO $con = null, $doQuery = true)
1484: {
1485: if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) {
1486: $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con);
1487: 1488: 1489: 1490: 1491: 1492: 1493:
1494: }
1495:
1496: return $this->aProduct;
1497: }
1498:
1499: 1500: 1501: 1502: 1503: 1504: 1505:
1506: public function setCategory(Category $v = null)
1507: {
1508: if ($v === null) {
1509: $this->setCategoryId(NULL);
1510: } else {
1511: $this->setCategoryId($v->getId());
1512: }
1513:
1514: $this->aCategory = $v;
1515:
1516:
1517:
1518: if ($v !== null) {
1519: $v->addDocument($this);
1520: }
1521:
1522:
1523: return $this;
1524: }
1525:
1526:
1527: 1528: 1529: 1530: 1531: 1532: 1533: 1534:
1535: public function getCategory(PropelPDO $con = null, $doQuery = true)
1536: {
1537: if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) {
1538: $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con);
1539: 1540: 1541: 1542: 1543: 1544: 1545:
1546: }
1547:
1548: return $this->aCategory;
1549: }
1550:
1551: 1552: 1553: 1554: 1555: 1556: 1557:
1558: public function setContent(Content $v = null)
1559: {
1560: if ($v === null) {
1561: $this->setContentId(NULL);
1562: } else {
1563: $this->setContentId($v->getId());
1564: }
1565:
1566: $this->aContent = $v;
1567:
1568:
1569:
1570: if ($v !== null) {
1571: $v->addDocument($this);
1572: }
1573:
1574:
1575: return $this;
1576: }
1577:
1578:
1579: 1580: 1581: 1582: 1583: 1584: 1585: 1586:
1587: public function getContent(PropelPDO $con = null, $doQuery = true)
1588: {
1589: if ($this->aContent === null && ($this->content_id !== null) && $doQuery) {
1590: $this->aContent = ContentQuery::create()->findPk($this->content_id, $con);
1591: 1592: 1593: 1594: 1595: 1596: 1597:
1598: }
1599:
1600: return $this->aContent;
1601: }
1602:
1603: 1604: 1605: 1606: 1607: 1608: 1609:
1610: public function setFolder(Folder $v = null)
1611: {
1612: if ($v === null) {
1613: $this->setFolderId(NULL);
1614: } else {
1615: $this->setFolderId($v->getId());
1616: }
1617:
1618: $this->aFolder = $v;
1619:
1620:
1621:
1622: if ($v !== null) {
1623: $v->addDocument($this);
1624: }
1625:
1626:
1627: return $this;
1628: }
1629:
1630:
1631: 1632: 1633: 1634: 1635: 1636: 1637: 1638:
1639: public function getFolder(PropelPDO $con = null, $doQuery = true)
1640: {
1641: if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) {
1642: $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con);
1643: 1644: 1645: 1646: 1647: 1648: 1649:
1650: }
1651:
1652: return $this->aFolder;
1653: }
1654:
1655:
1656: 1657: 1658: 1659: 1660: 1661: 1662: 1663:
1664: public function initRelation($relationName)
1665: {
1666: if ('DocumentI18n' == $relationName) {
1667: $this->initDocumentI18ns();
1668: }
1669: }
1670:
1671: 1672: 1673: 1674: 1675: 1676: 1677: 1678: 1679:
1680: public function clearDocumentI18ns()
1681: {
1682: $this->collDocumentI18ns = null;
1683: $this->collDocumentI18nsPartial = null;
1684:
1685: return $this;
1686: }
1687:
1688: 1689: 1690: 1691: 1692:
1693: public function resetPartialDocumentI18ns($v = true)
1694: {
1695: $this->collDocumentI18nsPartial = $v;
1696: }
1697:
1698: 1699: 1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709:
1710: public function initDocumentI18ns($overrideExisting = true)
1711: {
1712: if (null !== $this->collDocumentI18ns && !$overrideExisting) {
1713: return;
1714: }
1715: $this->collDocumentI18ns = new PropelObjectCollection();
1716: $this->collDocumentI18ns->setModel('DocumentI18n');
1717: }
1718:
1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732:
1733: public function getDocumentI18ns($criteria = null, PropelPDO $con = null)
1734: {
1735: $partial = $this->collDocumentI18nsPartial && !$this->isNew();
1736: if (null === $this->collDocumentI18ns || null !== $criteria || $partial) {
1737: if ($this->isNew() && null === $this->collDocumentI18ns) {
1738:
1739: $this->initDocumentI18ns();
1740: } else {
1741: $collDocumentI18ns = DocumentI18nQuery::create(null, $criteria)
1742: ->filterByDocument($this)
1743: ->find($con);
1744: if (null !== $criteria) {
1745: if (false !== $this->collDocumentI18nsPartial && count($collDocumentI18ns)) {
1746: $this->initDocumentI18ns(false);
1747:
1748: foreach($collDocumentI18ns as $obj) {
1749: if (false == $this->collDocumentI18ns->contains($obj)) {
1750: $this->collDocumentI18ns->append($obj);
1751: }
1752: }
1753:
1754: $this->collDocumentI18nsPartial = true;
1755: }
1756:
1757: $collDocumentI18ns->getInternalIterator()->rewind();
1758: return $collDocumentI18ns;
1759: }
1760:
1761: if($partial && $this->collDocumentI18ns) {
1762: foreach($this->collDocumentI18ns as $obj) {
1763: if($obj->isNew()) {
1764: $collDocumentI18ns[] = $obj;
1765: }
1766: }
1767: }
1768:
1769: $this->collDocumentI18ns = $collDocumentI18ns;
1770: $this->collDocumentI18nsPartial = false;
1771: }
1772: }
1773:
1774: return $this->collDocumentI18ns;
1775: }
1776:
1777: 1778: 1779: 1780: 1781: 1782: 1783: 1784: 1785: 1786:
1787: public function setDocumentI18ns(PropelCollection $documentI18ns, PropelPDO $con = null)
1788: {
1789: $documentI18nsToDelete = $this->getDocumentI18ns(new Criteria(), $con)->diff($documentI18ns);
1790:
1791: $this->documentI18nsScheduledForDeletion = unserialize(serialize($documentI18nsToDelete));
1792:
1793: foreach ($documentI18nsToDelete as $documentI18nRemoved) {
1794: $documentI18nRemoved->setDocument(null);
1795: }
1796:
1797: $this->collDocumentI18ns = null;
1798: foreach ($documentI18ns as $documentI18n) {
1799: $this->addDocumentI18n($documentI18n);
1800: }
1801:
1802: $this->collDocumentI18ns = $documentI18ns;
1803: $this->collDocumentI18nsPartial = false;
1804:
1805: return $this;
1806: }
1807:
1808: 1809: 1810: 1811: 1812: 1813: 1814: 1815: 1816:
1817: public function countDocumentI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1818: {
1819: $partial = $this->collDocumentI18nsPartial && !$this->isNew();
1820: if (null === $this->collDocumentI18ns || null !== $criteria || $partial) {
1821: if ($this->isNew() && null === $this->collDocumentI18ns) {
1822: return 0;
1823: }
1824:
1825: if($partial && !$criteria) {
1826: return count($this->getDocumentI18ns());
1827: }
1828: $query = DocumentI18nQuery::create(null, $criteria);
1829: if ($distinct) {
1830: $query->distinct();
1831: }
1832:
1833: return $query
1834: ->filterByDocument($this)
1835: ->count($con);
1836: }
1837:
1838: return count($this->collDocumentI18ns);
1839: }
1840:
1841: 1842: 1843: 1844: 1845: 1846: 1847:
1848: public function addDocumentI18n(DocumentI18n $l)
1849: {
1850: if ($l && $locale = $l->getLocale()) {
1851: $this->setLocale($locale);
1852: $this->currentTranslations[$locale] = $l;
1853: }
1854: if ($this->collDocumentI18ns === null) {
1855: $this->initDocumentI18ns();
1856: $this->collDocumentI18nsPartial = true;
1857: }
1858: if (!in_array($l, $this->collDocumentI18ns->getArrayCopy(), true)) {
1859: $this->doAddDocumentI18n($l);
1860: }
1861:
1862: return $this;
1863: }
1864:
1865: 1866: 1867:
1868: protected function doAddDocumentI18n($documentI18n)
1869: {
1870: $this->collDocumentI18ns[]= $documentI18n;
1871: $documentI18n->setDocument($this);
1872: }
1873:
1874: 1875: 1876: 1877:
1878: public function removeDocumentI18n($documentI18n)
1879: {
1880: if ($this->getDocumentI18ns()->contains($documentI18n)) {
1881: $this->collDocumentI18ns->remove($this->collDocumentI18ns->search($documentI18n));
1882: if (null === $this->documentI18nsScheduledForDeletion) {
1883: $this->documentI18nsScheduledForDeletion = clone $this->collDocumentI18ns;
1884: $this->documentI18nsScheduledForDeletion->clear();
1885: }
1886: $this->documentI18nsScheduledForDeletion[]= clone $documentI18n;
1887: $documentI18n->setDocument(null);
1888: }
1889:
1890: return $this;
1891: }
1892:
1893: 1894: 1895:
1896: public function clear()
1897: {
1898: $this->id = null;
1899: $this->product_id = null;
1900: $this->category_id = null;
1901: $this->folder_id = null;
1902: $this->content_id = null;
1903: $this->file = null;
1904: $this->position = null;
1905: $this->created_at = null;
1906: $this->updated_at = null;
1907: $this->alreadyInSave = false;
1908: $this->alreadyInValidation = false;
1909: $this->alreadyInClearAllReferencesDeep = false;
1910: $this->clearAllReferences();
1911: $this->resetModified();
1912: $this->setNew(true);
1913: $this->setDeleted(false);
1914: }
1915:
1916: 1917: 1918: 1919: 1920: 1921: 1922: 1923: 1924:
1925: public function clearAllReferences($deep = false)
1926: {
1927: if ($deep && !$this->alreadyInClearAllReferencesDeep) {
1928: $this->alreadyInClearAllReferencesDeep = true;
1929: if ($this->collDocumentI18ns) {
1930: foreach ($this->collDocumentI18ns as $o) {
1931: $o->clearAllReferences($deep);
1932: }
1933: }
1934: if ($this->aProduct instanceof Persistent) {
1935: $this->aProduct->clearAllReferences($deep);
1936: }
1937: if ($this->aCategory instanceof Persistent) {
1938: $this->aCategory->clearAllReferences($deep);
1939: }
1940: if ($this->aContent instanceof Persistent) {
1941: $this->aContent->clearAllReferences($deep);
1942: }
1943: if ($this->aFolder instanceof Persistent) {
1944: $this->aFolder->clearAllReferences($deep);
1945: }
1946:
1947: $this->alreadyInClearAllReferencesDeep = false;
1948: }
1949:
1950:
1951: $this->currentLocale = 'en_US';
1952: $this->currentTranslations = null;
1953:
1954: if ($this->collDocumentI18ns instanceof PropelCollection) {
1955: $this->collDocumentI18ns->clearIterator();
1956: }
1957: $this->collDocumentI18ns = null;
1958: $this->aProduct = null;
1959: $this->aCategory = null;
1960: $this->aContent = null;
1961: $this->aFolder = null;
1962: }
1963:
1964: 1965: 1966: 1967: 1968:
1969: public function __toString()
1970: {
1971: return (string) $this->exportTo(DocumentPeer::DEFAULT_STRING_FORMAT);
1972: }
1973:
1974: 1975: 1976: 1977: 1978:
1979: public function isAlreadyInSave()
1980: {
1981: return $this->alreadyInSave;
1982: }
1983:
1984:
1985:
1986: 1987: 1988: 1989: 1990:
1991: public function keepUpdateDateUnchanged()
1992: {
1993: $this->modifiedColumns[] = DocumentPeer::UPDATED_AT;
1994:
1995: return $this;
1996: }
1997:
1998:
1999:
2000: 2001: 2002: 2003: 2004: 2005: 2006:
2007: public function setLocale($locale = 'en_US')
2008: {
2009: $this->currentLocale = $locale;
2010:
2011: return $this;
2012: }
2013:
2014: 2015: 2016: 2017: 2018:
2019: public function getLocale()
2020: {
2021: return $this->currentLocale;
2022: }
2023:
2024: 2025: 2026: 2027: 2028: 2029: 2030:
2031: public function getTranslation($locale = 'en_US', PropelPDO $con = null)
2032: {
2033: if (!isset($this->currentTranslations[$locale])) {
2034: if (null !== $this->collDocumentI18ns) {
2035: foreach ($this->collDocumentI18ns as $translation) {
2036: if ($translation->getLocale() == $locale) {
2037: $this->currentTranslations[$locale] = $translation;
2038:
2039: return $translation;
2040: }
2041: }
2042: }
2043: if ($this->isNew()) {
2044: $translation = new DocumentI18n();
2045: $translation->setLocale($locale);
2046: } else {
2047: $translation = DocumentI18nQuery::create()
2048: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2049: ->findOneOrCreate($con);
2050: $this->currentTranslations[$locale] = $translation;
2051: }
2052: $this->addDocumentI18n($translation);
2053: }
2054:
2055: return $this->currentTranslations[$locale];
2056: }
2057:
2058: 2059: 2060: 2061: 2062: 2063: 2064: 2065:
2066: public function removeTranslation($locale = 'en_US', PropelPDO $con = null)
2067: {
2068: if (!$this->isNew()) {
2069: DocumentI18nQuery::create()
2070: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2071: ->delete($con);
2072: }
2073: if (isset($this->currentTranslations[$locale])) {
2074: unset($this->currentTranslations[$locale]);
2075: }
2076: foreach ($this->collDocumentI18ns as $key => $translation) {
2077: if ($translation->getLocale() == $locale) {
2078: unset($this->collDocumentI18ns[$key]);
2079: break;
2080: }
2081: }
2082:
2083: return $this;
2084: }
2085:
2086: 2087: 2088: 2089: 2090: 2091:
2092: public function getCurrentTranslation(PropelPDO $con = null)
2093: {
2094: return $this->getTranslation($this->getLocale(), $con);
2095: }
2096:
2097:
2098: 2099: 2100: 2101: 2102:
2103: public function getTitle()
2104: {
2105: return $this->getCurrentTranslation()->getTitle();
2106: }
2107:
2108:
2109: 2110: 2111: 2112: 2113: 2114:
2115: public function setTitle($v)
2116: { $this->getCurrentTranslation()->setTitle($v);
2117:
2118: return $this;
2119: }
2120:
2121:
2122: 2123: 2124: 2125: 2126:
2127: public function getDescription()
2128: {
2129: return $this->getCurrentTranslation()->getDescription();
2130: }
2131:
2132:
2133: 2134: 2135: 2136: 2137: 2138:
2139: public function setDescription($v)
2140: { $this->getCurrentTranslation()->setDescription($v);
2141:
2142: return $this;
2143: }
2144:
2145:
2146: 2147: 2148: 2149: 2150:
2151: public function getChapo()
2152: {
2153: return $this->getCurrentTranslation()->getChapo();
2154: }
2155:
2156:
2157: 2158: 2159: 2160: 2161: 2162:
2163: public function setChapo($v)
2164: { $this->getCurrentTranslation()->setChapo($v);
2165:
2166: return $this;
2167: }
2168:
2169:
2170: 2171: 2172: 2173: 2174:
2175: public function getPostscriptum()
2176: {
2177: return $this->getCurrentTranslation()->getPostscriptum();
2178: }
2179:
2180:
2181: 2182: 2183: 2184: 2185: 2186:
2187: public function setPostscriptum($v)
2188: { $this->getCurrentTranslation()->setPostscriptum($v);
2189:
2190: return $this;
2191: }
2192:
2193: }
2194: