Beispiel #1
0
 public function relations()
 {
     $map = new CMap(parent::relations());
     $nrelation = array('images' => array(self::HAS_MANY, 'Image', 'model_id', 'condition' => 'images.model_name = \'Category\''));
     $map->mergeWith($nrelation);
     return $map;
 }
Beispiel #2
0
 public function delete($con = null)
 {
     try {
         $con = Propel::getConnection();
         $con->begin();
         //deletes generic document
         $genericDocument = Document::getGenericDocument($this);
         $genericDocument->delete();
         parent::delete();
         $con->commit();
         Document::deleteObjCache($this);
         return true;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
Beispiel #3
0
 public function save(Doctrine_Connection $conn = null)
 {
     $slug = Magic::slugify($this->getTitle());
     if ($this->isNew()) {
         $i = 0;
         do {
             $i++;
             $q = Doctrine::getTable('Category')->findOneBySlug($slug);
             if (!$q) {
                 break;
             } else {
                 $slug = Magic::slugify($this->getTitle());
                 $slug .= $i;
             }
         } while ($i);
         $this->setSlug($slug);
     } elseif ($slug != $this->getSlug()) {
         $i = 0;
         do {
             $i++;
             $q = Doctrine::getTable('Category')->findOneBySlug($slug);
             if (!$q) {
                 $this->setSlug($slug);
                 break;
             } else {
                 if ($slug == $this->getSlug()) {
                     break;
                 } else {
                     $slug = Magic::slugify($this->getTitle());
                     $slug .= $i;
                 }
             }
         } while ($i);
     }
     parent::save($conn);
 }
Beispiel #4
0
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     CategoryPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new CategoryPeer();
     }
     return self::$peer;
 }
Beispiel #5
0
 /**
  * Define getter / setter
  */
 public function __get($strName)
 {
     switch ($strName) {
         case 'IsPrimary':
             return $this->IsPrimary();
         case 'Slug':
             return $this->GetSlug();
         case 'CanonicalUrl':
             return $this->getCanonicalUrl();
         case 'HasProducts':
             return $this->HasProducts();
         case 'ParentObject':
             return $this->getParent();
         case 'HasImage':
             return $this->HasImage();
         case 'ListingImage':
             return $this->GetImageLink(ImagesType::listing);
         case 'MiniImage':
             return $this->GetImageLink(ImagesType::mini);
         case 'PreviewImage':
             return $this->GetImageLink(ImagesType::preview);
         case 'SliderImage':
             return $this->GetImageLink(ImagesType::slider);
         case 'CategoryImage':
             return $this->GetImageLink(ImagesType::category);
         case 'PDetailImage':
             return $this->GetImageLink(ImagesType::pdetail);
         case 'SmallImage':
             return $this->GetImageLink(ImagesType::small);
         case 'Image':
             return $this->GetImageLink(ImagesType::normal);
         case 'DirLink':
             return $this->GetDirLink();
         case 'Link':
         case 'Url':
             return $this->getLink();
         case 'AbsoluteUrl':
         case 'AbsoluteLink':
             return $this->GetAbsoluteUrl();
         case 'PageTitle':
             return _xls_truncate($this->GetPageMeta('SEO_CATEGORY_TITLE'), 70);
         case 'PageDescription':
             return $this->GetMetaDescription();
         default:
             return parent::__get($strName);
     }
 }
Beispiel #6
0
 public function init()
 {
     return parent::init();
 }
Beispiel #7
0
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Beispiel #8
0
 function Category($object = null)
 {
     parent::__construct($object);
 }
Beispiel #9
0
 public function rules()
 {
     return array_merge(parent::rules());
 }
Beispiel #10
0
 /**
  * Initializes internal state of Category object.
  * @see        parent::__construct()
  */
 public function __construct()
 {
     // Make sure that parent constructor is always invoked, since that
     // is where any default values for this object are set.
     parent::__construct();
 }