예제 #1
0
파일: Subscriber.php 프로젝트: zonky2/core
 /**
  * Destroy the filter settings for a MetaModel.
  *
  * @param IMetaModel $metaModel The MetaModel to destroy.
  *
  * @return void
  */
 protected function destroyFilterSettings(IMetaModel $metaModel)
 {
     $database = $this->getDatabase();
     // Delete everything from filter settings.
     $arrIds = $database->prepare('SELECT id FROM tl_metamodel_filter WHERE pid=?')->execute($metaModel->get('id'))->fetchEach('id');
     if ($arrIds) {
         $database->prepare(sprintf('DELETE FROM tl_metamodel_filtersetting WHERE pid IN (%s)', implode(',', $arrIds)))->execute();
     }
     $database->prepare('DELETE FROM tl_metamodel_filter WHERE pid=?')->execute($metaModel->get('id'));
 }
예제 #2
0
 /**
  * Create a ICollection instance from the id.
  *
  * @param IMetaModel $metaModel The MetaModel for which to retrieve the render setting.
  *
  * @param string     $settingId The id of the ICollection.
  *
  * @return ICollection The instance or null if not found.
  */
 protected function internalCreateRenderSetting(IMetaModel $metaModel, $settingId)
 {
     $row = $this->serviceContainer->getDatabase()->prepare('SELECT * FROM tl_metamodel_rendersettings WHERE pid=? AND (id=? OR isdefault=1) ORDER BY isdefault ASC')->limit(1)->execute($metaModel->get('id'), $settingId ?: 0);
     /** @noinspection PhpUndefinedFieldInspection */
     if (!$row->numRows) {
         $row = null;
     }
     $renderSetting = new Collection($metaModel, $row ? $row->row() : array());
     if ($renderSetting->get('id')) {
         $this->collectAttributeSettings($metaModel, $renderSetting);
     }
     return $renderSetting;
 }
예제 #3
0
파일: InsertTags.php 프로젝트: zonky2/core
 /**
  * Check if the item is published.
  *
  * @param IMetaModel $objMetaModel Current metamodels.
  * @param int        $intItemId    Id of the item.
  *
  * @return boolean True => Published | False => Not published
  */
 protected function isPublishedItem($objMetaModel, $intItemId)
 {
     // Check publish state of an item.
     $objAttrCheckPublish = $this->getServiceContainer()->getDatabase()->prepare('SELECT colname FROM tl_metamodel_attribute WHERE pid=? AND check_publish=1')->limit(1)->execute($objMetaModel->get('id'));
     if ($objAttrCheckPublish->numRows > 0) {
         $objItem = $objMetaModel->findById($intItemId);
         if (!$objItem->get($objAttrCheckPublish->colname)) {
             return false;
         }
     }
     return true;
 }