示例#1
0
 /**
  * Count existing tab separators elements.
  *
  * @param \Database\Result $model  Current row.
  * @param Helper           $helper Wrapper helper.
  *
  * @return int
  */
 public function countExistingTabSeparators(\Database\Result $model, Helper $helper)
 {
     if ($helper->isTypeOf(Helper::TYPE_START)) {
         $modelId = $model->id;
     } else {
         $modelId = $model->bootstrap_parentId;
     }
     $number = \ContentModel::countBy('type=? AND bootstrap_parentId', array($helper->getTypeName(Helper::TYPE_SEPARATOR), $modelId));
     return $number;
 }
示例#2
0
 /**
  * count related elements optionally limited by type
  *
  * @param Model $model
  * @param string $type
  * @return int
  */
 public static function countRelatedElements(Model $model, $type = null)
 {
     if ($model->getType() == $model::TYPE_START) {
         if ($type === null) {
             $column = 'bootstrap_parentId';
             $values = $model->id;
         } else {
             $column = array('bootstrap_parentId=?', 'type=?');
             $values = array($model->id, $model->getTypeName($type));
         }
     } elseif ($type === null) {
         $column = array('id !=?', '(bootstrap_parentId=? OR id=?)');
         $values = array($model->id, $model->bootstrap_parentId, $model->bootstrap_parentId);
     } elseif ($type == $model::TYPE_START) {
         $column = 'id';
         $values = $model->bootstrap_parentId;
     } else {
         $column = array('id !=?', 'bootstrap_parentId=?', 'type=?');
         $values = array($model->id, $model->bootstrap_parentId, $model->getTypeName($type));
     }
     return \ContentModel::countBy($column, $values);
 }
示例#3
0
 /**
  * Count related elements.
  *
  * @param string|null $type Name of the type. If empty current type is used.
  *
  * @return int
  */
 public function countRelatedElements($type = null)
 {
     $model = $this->model;
     if ($this->isTypeOf(static::TYPE_START)) {
         if ($type === null) {
             $column = array('bootstrap_parentId=?');
             $values = array($model->id);
         } else {
             $column = array('bootstrap_parentId=?', 'type=?');
             $values = array($model->id, $this->getTypeName($type));
         }
     } elseif ($type === null) {
         $column = array('id !=?', '(bootstrap_parentId=? OR id=?)');
         $values = array($model->id, $model->bootstrap_parentId, $model->bootstrap_parentId);
     } elseif ($type == static::TYPE_START) {
         $column = array('id=?');
         $values = array($model->bootstrap_parentId);
     } else {
         $column = array('id !=?', 'bootstrap_parentId=?', 'type=?');
         $values = array($model->id, $model->bootstrap_parentId, $this->getTypeName($type));
     }
     $column[] = 'invisible=?';
     $values[] = '';
     return \ContentModel::countBy($column, $values);
 }
示例#4
0
 /**
  * count existing tab separators elements
  *
  * @param ContentWrapper\Model $model
  *
  * @return int
  */
 public function countExistingTabSeparators(ContentWrapper\Model $model)
 {
     $id = $model->getType() == ContentWrapper\Model::TYPE_START ? $model->id : $model->bootstrap_parentId;
     $number = \ContentModel::countBy('type=? AND bootstrap_parentId', array($model->getTypeName(ContentWrapper\Model::TYPE_SEPARATOR), $id));
     return $number;
 }