Пример #1
0
 /**
  * Generate the form.
  *
  * @return array
  */
 private function generateForm()
 {
     $fields = array();
     // Loop over all attributes now.
     foreach ($this->metaModel->getAttributes() as $attribute) {
         $attrId = $attribute->get('id');
         if (!$this->accepts($attribute)) {
             continue;
         }
         if ($this->knowsAttribute($attribute)) {
             if ($this->input->hasValue('attribute_' . $attrId)) {
                 $fields[] = array('checkbox' => false, 'text' => $this->translator->translate('addAll_addsuccess', static::$table, array($attribute->getName())), 'class' => 'tl_confirm', 'attr_id' => $attrId);
                 continue;
             }
             $fields[] = array('checkbox' => false, 'text' => $this->translator->translate('addAll_alreadycontained', static::$table, array($attribute->getName())), 'class' => 'tl_info', 'attr_id' => $attrId);
             continue;
         }
         $fields[] = array('checkbox' => true, 'text' => $this->translator->translate('addAll_willadd', static::$table, array($attribute->getName())), 'class' => 'tl_new', 'attr_id' => $attrId);
         $this->template->hasCheckbox = true;
     }
     return $fields;
 }
Пример #2
0
 /**
  * Destroy auxiliary data of attributes and delete the attributes themselves from the database.
  *
  * @param IMetaModel $metaModel The MetaModel to destroy.
  *
  * @return void
  */
 protected function destroyAttributes(IMetaModel $metaModel)
 {
     foreach ($metaModel->getAttributes() as $attribute) {
         $attribute->destroyAUX();
     }
     $this->getDatabase()->prepare('DELETE FROM tl_metamodel_attribute WHERE pid=?')->execute($metaModel->get('id'));
 }
Пример #3
0
 /**
  * Perform the action.
  *
  * @param IMetaModel $metaModel       The MetaModel.
  *
  * @param array      $knownAttributes The list of known attributes.
  *
  * @param int        $startSort       The first sort index.
  *
  * @param int        $pid             The pid.
  *
  * @param array      $messages        The messages array.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 protected function perform(IMetaModel $metaModel, $knownAttributes, $startSort, $pid, &$messages)
 {
     $database = $this->getDatabase();
     // Loop over all attributes now.
     foreach ($metaModel->getAttributes() as $attribute) {
         if (!array_key_exists($attribute->get('id'), $knownAttributes)) {
             $arrData = array('pid' => $pid, 'sorting' => $startSort, 'tstamp' => time(), 'dcatype' => 'attribute', 'attr_id' => $attribute->get('id'), 'tl_class' => '');
             $startSort += 128;
             $database->prepare('INSERT INTO tl_metamodel_dcasetting %s')->set($arrData)->execute();
             $messages[] = array('severity' => 'confirm', 'message' => sprintf($GLOBALS['TL_LANG']['tl_metamodel_dcasetting']['addAll_addsuccess'], $attribute->getName()));
         }
     }
 }
Пример #4
0
 /**
  * Perform the action.
  *
  * @param IMetaModel $metaModel       The MetaModel.
  *
  * @param array      $knownAttributes The list of known attributes.
  *
  * @param int        $startSort       The first sort index.
  *
  * @param int        $pid             The pid.
  *
  * @param array      $messages        The output messages.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 protected function perform(IMetaModel $metaModel, $knownAttributes, $startSort, $pid, &$messages)
 {
     $database = $this->getDatabase();
     // Loop over all attributes now.
     foreach ($metaModel->getAttributes() as $attribute) {
         if (!array_key_exists($attribute->get('id'), $knownAttributes)) {
             $arrData = array();
             $objRenderSetting = $attribute->getDefaultRenderSettings();
             foreach ($objRenderSetting->getKeys() as $key) {
                 $arrData[$key] = $objRenderSetting->get($key);
             }
             $arrData = array_replace_recursive($arrData, array('pid' => $pid, 'sorting' => $startSort, 'tstamp' => time(), 'attr_id' => $attribute->get('id')));
             $startSort += 128;
             $database->prepare('INSERT INTO tl_metamodel_rendersetting %s')->set($arrData)->execute();
             $messages[] = array('severity' => 'confirm', 'message' => sprintf($GLOBALS['TL_LANG']['tl_metamodel_rendersetting']['addAll_addsuccess'], $attribute->getName()));
         }
     }
 }