Overview

Namespaces

  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Exception
      • Loop
      • Tests

Classes

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