updateExtra() public static méthode

Update extra
public static updateExtra ( integer $id, string $key, string $value )
$id integer The id for the extra.
$key string The key you want to update.
$value string The new value.
 /**
  * Insert an item in the database
  *
  * @param array $item
  * @return int
  */
 public static function insert(array $item)
 {
     $item['created_on'] = BackendModel::getUTCDate();
     $item['edited_on'] = BackendModel::getUTCDate();
     $db = BackendModel::get('database');
     // insert extra
     $item['extra_id'] = BackendModel::insertExtra('widget', 'Instagram', 'InstagramFeed');
     $item['id'] = (int) $db->insert('instagram_users', $item);
     // update extra (item id is now known)
     BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => \SpoonFilter::ucfirst(Language::lbl('Instagram', 'InstagramFeed')) . ': ' . $item['username'], 'edit_url' => BackendModel::createURLForAction('Edit', 'Instagram', null) . '&id=' . $item['id']));
     return $item['id'];
 }
Exemple #2
0
 /**
  * Update an existing item.
  *
  * @param array $item The new data.
  * @return int
  */
 public static function update(array $item)
 {
     $db = BackendModel::getContainer()->get('database');
     // update extra
     BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('Edit') . '&id=' . $item['id']));
     // archive all older content_block versions
     $db->update('content_blocks', array('status' => 'archived'), 'id = ? AND language = ?', array($item['id'], BL::getWorkingLanguage()));
     // insert new version
     $item['revision_id'] = $db->insert('content_blocks', $item);
     // how many revisions should we keep
     $rowsToKeep = (int) BackendModel::get('fork.settings')->get('ContentBlocks', 'max_num_revisions', 20);
     // get revision-ids for items to keep
     $revisionIdsToKeep = (array) $db->getColumn('SELECT i.revision_id
          FROM content_blocks AS i
          WHERE i.id = ? AND i.language = ? AND i.status = ?
          ORDER BY i.edited_on DESC
          LIMIT ?', array($item['id'], BL::getWorkingLanguage(), 'archived', $rowsToKeep));
     // delete other revisions
     if (!empty($revisionIdsToKeep)) {
         $db->delete('content_blocks', 'id = ? AND language = ? AND status = ? AND revision_id NOT IN (' . implode(', ', $revisionIdsToKeep) . ')', array($item['id'], BL::getWorkingLanguage(), 'archived'));
     }
     // return the new revision_id
     return $item['revision_id'];
 }
Exemple #3
0
 /**
  * Update a certain category
  *
  * @param array $item
  */
 public static function updateCategory(array $item)
 {
     $item['edited_on'] = BackendModel::getUTCDate();
     BackendModel::getContainer()->get('database')->update('catalog_categories', $item, 'id = ?', array($item['id']));
     // update extra
     BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => BL::getLabel('Category') . ' ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('EditCategory') . '&id=' . $item['id']));
 }
Exemple #4
0
 /**
  * Update the widget so it shows the correct title and has the correct template
  */
 private function updateWidget()
 {
     $editUrl = Model::createURLForAction('Edit', 'ContentBlocks', (string) $this->locale) . '&id=' . $this->id;
     // update data for the extra
     // @TODO replace this with an implementation with doctrine
     $extras = Model::getExtras([$this->extraId]);
     $extra = reset($extras);
     $data = ['id' => $this->id, 'language' => (string) $this->locale, 'edit_url' => $editUrl];
     if (isset($extra['data'])) {
         $data = $data + (array) $extra['data'];
     }
     $data['custom_template'] = $this->template;
     $data['extra_label'] = $this->title;
     Model::updateExtra($this->extraId, 'data', $data);
 }
Exemple #5
0
 /**
  * Update an item
  *
  * @param array $item The data of the record to update.
  *
  * @return int
  */
 public static function update($item)
 {
     // redefine edited on date
     $item['edited_on'] = BackendModel::getUTCDate();
     // we have an extra_id
     if (isset($item['extra_id'])) {
         // update extra
         BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => \SpoonFilter::ucfirst(BL::lbl('Location', 'core')) . ': ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('Edit') . '&id=' . $item['id']));
     }
     // update item
     return BackendModel::get('database')->update('location', $item, 'id = ? AND language = ?', array($item['id'], $item['language']));
 }
Exemple #6
0
 /**
  * Update a certain category
  *
  * @param array $item
  */
 public static function updateCategory(array $item)
 {
     // update faq category
     BackendModel::getContainer()->get('database')->update('faq_categories', $item, 'id = ?', array($item['id']));
     // update extra
     BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => 'Category: ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('EditCategory') . '&id=' . $item['id']));
     // invalidate faq
     BackendModel::invalidateFrontendCache('Faq', BL::getWorkingLanguage());
 }