getTags() public static méthode

Get tags for an item
public static getTags ( string $module, integer $otherId, string $type = 'string', string $language = null ) : mixed
$module string The module wherein will be searched.
$otherId integer The id of the record.
$type string The type of the returnvalue, possible values are: array, string (tags will be joined by ,).
$language string The language to use, if not provided the working language will be used.
Résultat mixed
Exemple #1
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // get values for the form
     $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y');
     $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
     $categories = BackendFaqModel::getCategories();
     // create form
     $this->frm = new BackendForm('edit');
     $this->frm->addText('title', $this->record['question'], null, 'inputText title', 'inputTextError title');
     $this->frm->addEditor('answer', $this->record['answer']);
     $this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']);
     $this->frm->addDropdown('category_id', $categories, $this->record['category_id']);
     $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->record['id']), null, 'inputText tagBox', 'inputTextError tagBox');
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true);
 }
 /**
  * Load the form
  *
  * @return void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('edit_album');
     $this->frmAddImage = new BackendForm('add_image');
     $this->frmDeleteImage = new BackendForm('delete_image');
     // get values for the form
     $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y');
     $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
     // set show-in-overview values
     $rbtShowOverviewValues[] = array('label' => BL::lbl('Yes'), 'value' => 'Y');
     $rbtShowOverviewValues[] = array('label' => BL::lbl('No'), 'value' => 'N');
     // create elements
     $this->frm->addText('title', $this->record['title']);
     $this->frm->getField('title')->setAttribute('class', 'title ' . $this->frm->getField('title')->getAttribute('class'));
     $this->frm->addEditor('description', $this->record['description']);
     $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->id), null, 'inputText tagBox', 'inputTextError tagBox');
     $this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']);
     $this->frm->addRadiobutton('show_in_overview', $rbtShowOverviewValues, $this->record['show_in_overview']);
     $this->frm->addDropdown('category', BackendGalleriaModel::getCategoriesForDropdown(), $this->record['category_id']);
     // meta object
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true);
 }
Exemple #3
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // get default template id
     $defaultTemplateId = $this->get('fork.settings')->get('Pages', 'default_template', 1);
     // create form
     $this->frm = new BackendForm('edit');
     // assign in template
     $this->tpl->assign('defaultTemplateId', $defaultTemplateId);
     // create elements
     $this->frm->addText('title', $this->record['title'], null, 'inputText title', 'inputTextError title');
     $this->frm->addEditor('html');
     $this->frm->addHidden('template_id', $this->record['template_id']);
     $this->frm->addRadiobutton('hidden', array(array('label' => BL::lbl('Hidden'), 'value' => 'Y'), array('label' => BL::lbl('Published'), 'value' => 'N')), $this->record['hidden']);
     // a god user should be able to adjust the detailed settings for a page easily
     if ($this->isGod) {
         // init some vars
         $items = array('move', 'children', 'edit', 'delete');
         $checked = array();
         $values = array();
         foreach ($items as $value) {
             $values[] = array('label' => BL::msg(\SpoonFilter::toCamelCase('allow_' . $value)), 'value' => $value);
             if (isset($this->record['allow_' . $value]) && $this->record['allow_' . $value] == 'Y') {
                 $checked[] = $value;
             }
         }
         $this->frm->addMultiCheckbox('allow', $values, $checked);
     }
     // build prototype block
     $block['index'] = 0;
     $block['formElements']['chkVisible'] = $this->frm->addCheckbox('block_visible_' . $block['index'], true);
     $block['formElements']['hidExtraId'] = $this->frm->addHidden('block_extra_id_' . $block['index'], 0);
     $block['formElements']['hidPosition'] = $this->frm->addHidden('block_position_' . $block['index'], 'fallback');
     $block['formElements']['txtHTML'] = $this->frm->addTextArea('block_html_' . $block['index'], '');
     // this is no editor; we'll add the editor in JS
     // add default block to "fallback" position, the only one which we can rest assured to exist
     $this->positions['fallback']['blocks'][] = $block;
     // content has been submitted: re-create submitted content rather than the db-fetched content
     if (isset($_POST['block_html_0'])) {
         // init vars
         $this->blocksContent = array();
         $hasBlock = false;
         $i = 1;
         // loop submitted blocks
         while (isset($_POST['block_position_' . $i])) {
             // init var
             $block = array();
             // save block position
             $block['position'] = $_POST['block_position_' . $i];
             $positions[$block['position']][] = $block;
             // set linked extra
             $block['extra_id'] = $_POST['block_extra_id_' . $i];
             // reset some stuff
             if ($block['extra_id'] <= 0) {
                 $block['extra_id'] = null;
             }
             // init html
             $block['html'] = null;
             // extra-type is HTML
             if ($block['extra_id'] === null) {
                 // reset vars
                 $block['extra_id'] = null;
                 $block['html'] = $_POST['block_html_' . $i];
             } else {
                 // type of block
                 if (isset($this->extras[$block['extra_id']]['type']) && $this->extras[$block['extra_id']]['type'] == 'block') {
                     // set error
                     if ($hasBlock) {
                         $this->frm->addError(BL::err('CantAdd2Blocks'));
                     }
                     // home can't have blocks
                     if ($this->record['id'] == 1) {
                         $this->frm->addError(BL::err('HomeCantHaveBlocks'));
                     }
                     // reset var
                     $hasBlock = true;
                 }
             }
             // set data
             $block['created_on'] = BackendModel::getUTCDate();
             $block['edited_on'] = $block['created_on'];
             $block['visible'] = isset($_POST['block_visible_' . $i]) && $_POST['block_visible_' . $i] == 'Y' ? 'Y' : 'N';
             $block['sequence'] = count($positions[$block['position']]) - 1;
             // add to blocks
             $this->blocksContent[] = $block;
             // increment counter; go fetch next block
             $i++;
         }
     }
     // build blocks array
     foreach ($this->blocksContent as $i => $block) {
         $block['index'] = $i + 1;
         $block['formElements']['chkVisible'] = $this->frm->addCheckbox('block_visible_' . $block['index'], $block['visible'] == 'Y');
         $block['formElements']['hidExtraId'] = $this->frm->addHidden('block_extra_id_' . $block['index'], (int) $block['extra_id']);
         $block['formElements']['hidPosition'] = $this->frm->addHidden('block_position_' . $block['index'], $block['position']);
         $block['formElements']['txtHTML'] = $this->frm->addTextArea('block_html_' . $block['index'], $block['html']);
         // this is no editor; we'll add the editor in JS
         $this->positions[$block['position']]['blocks'][] = $block;
     }
     // redirect
     $redirectValue = 'none';
     if (isset($this->record['data']['internal_redirect']['page_id'])) {
         $redirectValue = 'internal';
     }
     if (isset($this->record['data']['external_redirect']['url'])) {
         $redirectValue = 'external';
     }
     $redirectValues = array(array('value' => 'none', 'label' => \SpoonFilter::ucfirst(BL::lbl('None'))), array('value' => 'internal', 'label' => \SpoonFilter::ucfirst(BL::lbl('InternalLink')), 'variables' => array('isInternal' => true)), array('value' => 'external', 'label' => \SpoonFilter::ucfirst(BL::lbl('ExternalLink')), 'variables' => array('isExternal' => true)));
     $this->frm->addRadiobutton('redirect', $redirectValues, $redirectValue);
     $this->frm->addDropdown('internal_redirect', BackendPagesModel::getPagesForDropdown(), $redirectValue == 'internal' ? $this->record['data']['internal_redirect']['page_id'] : null);
     $this->frm->addText('external_redirect', $redirectValue == 'external' ? urldecode($this->record['data']['external_redirect']['url']) : null, null, null, null, true);
     // page info
     $this->frm->addCheckbox('navigation_title_overwrite', $this->record['navigation_title_overwrite'] == 'Y');
     $this->frm->addText('navigation_title', $this->record['navigation_title']);
     // tags
     $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->id), null, 'inputText tagBox', 'inputTextError tagBox');
     // a specific action
     $isAction = isset($this->record['data']['is_action']) && $this->record['data']['is_action'] == true ? true : false;
     $this->frm->addCheckbox('is_action', $isAction);
     // extra
     $this->frm->addDropdown('extra_type', BackendPagesModel::getTypes());
     // meta
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true);
     // set callback for generating an unique URL
     $this->meta->setURLCallback('Backend\\Modules\\Pages\\Engine\\Model', 'getURL', array($this->record['id'], $this->record['parent_id'], $isAction));
 }
Exemple #4
0
 /**
  * Copy pages
  *
  * @param string $from The language code to copy the pages from.
  * @param string $to   The language code we want to copy the pages to.
  */
 public static function copy($from, $to)
 {
     // get db
     $db = BackendModel::getContainer()->get('database');
     // copy contentBlocks and get copied contentBlockIds
     $copyContentBlocks = new CopyContentBlocksToOtherLocale(Locale::fromString($to), Locale::fromString($from));
     BackendModel::get('command_bus')->handle($copyContentBlocks);
     $contentBlockIds = $copyContentBlocks->extraIdMap;
     // define old block ids
     $contentBlockOldIds = array_keys($contentBlockIds);
     // get all old pages
     $ids = $db->getColumn('SELECT id
          FROM pages AS i
          WHERE i.language = ? AND i.status = ?', array($to, 'active'));
     // any old pages
     if (!empty($ids)) {
         // delete existing pages
         foreach ($ids as $id) {
             // redefine
             $id = (int) $id;
             // get revision ids
             $revisionIDs = (array) $db->getColumn('SELECT i.revision_id
                  FROM pages AS i
                  WHERE i.id = ? AND i.language = ?', array($id, $to));
             // get meta ids
             $metaIDs = (array) $db->getColumn('SELECT i.meta_id
                  FROM pages AS i
                  WHERE i.id = ? AND i.language = ?', array($id, $to));
             // delete meta records
             if (!empty($metaIDs)) {
                 $db->delete('meta', 'id IN (' . implode(',', $metaIDs) . ')');
             }
             // delete blocks and their revisions
             if (!empty($revisionIDs)) {
                 $db->delete('pages_blocks', 'revision_id IN (' . implode(',', $revisionIDs) . ')');
             }
             // delete page and the revisions
             if (!empty($revisionIDs)) {
                 $db->delete('pages', 'revision_id IN (' . implode(',', $revisionIDs) . ')');
             }
         }
     }
     // delete search indexes
     $db->delete('search_index', 'module = ? AND language = ?', array('pages', $to));
     // get all active pages
     $ids = BackendModel::getContainer()->get('database')->getColumn('SELECT id
          FROM pages AS i
          WHERE i.language = ? AND i.status = ?', array($from, 'active'));
     // loop
     foreach ($ids as $id) {
         // get data
         $sourceData = self::get($id, null, $from);
         // get and build meta
         $meta = $db->getRecord('SELECT *
              FROM meta
              WHERE id = ?', array($sourceData['meta_id']));
         // remove id
         unset($meta['id']);
         // init page
         $page = array();
         // build page
         $page['id'] = $sourceData['id'];
         $page['user_id'] = BackendAuthentication::getUser()->getUserId();
         $page['parent_id'] = $sourceData['parent_id'];
         $page['template_id'] = $sourceData['template_id'];
         $page['meta_id'] = (int) $db->insert('meta', $meta);
         $page['language'] = $to;
         $page['type'] = $sourceData['type'];
         $page['title'] = $sourceData['title'];
         $page['navigation_title'] = $sourceData['navigation_title'];
         $page['navigation_title_overwrite'] = $sourceData['navigation_title_overwrite'];
         $page['hidden'] = $sourceData['hidden'];
         $page['status'] = 'active';
         $page['publish_on'] = BackendModel::getUTCDate();
         $page['created_on'] = BackendModel::getUTCDate();
         $page['edited_on'] = BackendModel::getUTCDate();
         $page['allow_move'] = $sourceData['allow_move'];
         $page['allow_children'] = $sourceData['allow_children'];
         $page['allow_edit'] = $sourceData['allow_edit'];
         $page['allow_delete'] = $sourceData['allow_delete'];
         $page['sequence'] = $sourceData['sequence'];
         $page['data'] = $sourceData['data'] !== null ? serialize($sourceData['data']) : null;
         // insert page, store the id, we need it when building the blocks
         $revisionId = self::insert($page);
         // init var
         $blocks = array();
         // get the blocks
         $sourceBlocks = self::getBlocks($id, null, $from);
         // loop blocks
         foreach ($sourceBlocks as $sourceBlock) {
             // build block
             $block = $sourceBlock;
             $block['revision_id'] = $revisionId;
             $block['created_on'] = BackendModel::getUTCDate();
             $block['edited_on'] = BackendModel::getUTCDate();
             if (in_array($block['extra_id'], $contentBlockOldIds)) {
                 $block['extra_id'] = $contentBlockIds[$block['extra_id']];
             }
             // add block
             $blocks[] = $block;
         }
         // insert the blocks
         self::insertBlocks($blocks);
         // init var
         $text = '';
         // build search-text
         foreach ($blocks as $block) {
             $text .= ' ' . $block['html'];
         }
         // add
         BackendSearchModel::saveIndex('Pages', (int) $page['id'], array('title' => $page['title'], 'text' => $text), $to);
         // get tags
         $tags = BackendTagsModel::getTags('pages', $id, 'string', $from);
         // save tags
         if ($tags != '') {
             $saveWorkingLanguage = BL::getWorkingLanguage();
             // If we don't set the working language to the target language,
             // BackendTagsModel::getURL() will use the current working
             // language, possibly causing unnecessary '-2' suffixes in
             // tags.url
             BL::setWorkingLanguage($to);
             BackendTagsModel::saveTags($page['id'], $tags, 'pages', $to);
             BL::setWorkingLanguage($saveWorkingLanguage);
         }
     }
     // build cache
     self::buildCache($to);
 }
Exemple #5
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('edit');
     // set hidden values
     $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y');
     $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
     // get categories
     $categories = BackendBlogModel::getCategories();
     $categories['new_category'] = \SpoonFilter::ucfirst(BL::getLabel('AddCategory'));
     // create elements
     $this->frm->addText('title', $this->record['title'], null, 'inputText title', 'inputTextError title');
     $this->frm->addEditor('text', $this->record['text']);
     $this->frm->addEditor('introduction', $this->record['introduction']);
     $this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']);
     $this->frm->addCheckbox('allow_comments', $this->record['allow_comments'] === 'Y' ? true : false);
     $this->frm->addDropdown('category_id', $categories, $this->record['category_id']);
     if (count($categories) != 2) {
         $this->frm->getField('category_id')->setDefaultElement('');
     }
     $this->frm->addDropdown('user_id', BackendUsersModel::getUsers(), $this->record['user_id']);
     $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->record['id']), null, 'inputText tagBox', 'inputTextError tagBox');
     $this->frm->addDate('publish_on_date', $this->record['publish_on']);
     $this->frm->addTime('publish_on_time', date('H:i', $this->record['publish_on']));
     if ($this->imageIsAllowed) {
         $this->frm->addImage('image');
         $this->frm->addCheckbox('delete_image');
     }
     // meta object
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true);
     // set callback for generating a unique URL
     $this->meta->setUrlCallback('Backend\\Modules\\Blog\\Engine\\Model', 'getURL', array($this->record['id']));
 }
Exemple #6
0
 /**
  * Load the form
  */
 protected function loadForm()
 {
     // create form
     $this->frm = new BackendForm('edit');
     $this->frm->addText('price', $this->record['price'], null, 'inputText price', 'inputTextError price');
     $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->record['id']), null, 'inputText tagBox', 'inputTextError tagBox');
     $this->frm->addDropdown('related_products', $this->allProductsGroupedByCategories, $this->relatedProducts, true);
     $this->frm->addCheckbox('allow_comments', $this->record['allow_comments'] === 'Y' ? true : false);
     $this->frm->addCheckbox('frontpage', $this->record['frontpage']);
     $this->frm->addCheckbox('contact', $this->record['contact']);
     $this->frm->addDropdown('ballcolor', BackendCatalogModel::$ballColorArray, $this->record['ballcolor']);
     foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
         $productLanguage = BackendCatalogModel::getLanguage($this->id, $language);
         $fieldTitle = $this->frm->addText("title_" . strtolower($language), $productLanguage['title']);
         $fieldText = $this->frm->addEditor("text_" . strtolower($language), $productLanguage['text']);
         $fieldSummary = $this->frm->addEditor("summary_" . strtolower($language), $productLanguage['summary']);
         $fieldBalltext = $this->frm->addText("balltext_" . strtolower($language), $productLanguage['balltext']);
         $this->fieldLanguages[$key]["key"] = $key;
         $this->fieldLanguages[$key]["language"] = $language;
         $this->fieldLanguages[$key]["title"] = $fieldTitle->parse();
         $this->fieldLanguages[$key]["text"] = $fieldText->parse();
         $this->fieldLanguages[$key]["summary"] = $fieldSummary->parse();
         $this->fieldLanguages[$key]["balltext"] = $fieldBalltext->parse();
     }
     // categories
     $this->frm->addDropdown('category_id', $this->categories, $this->record['category_id']);
     $this->frm->addDropdown('brand_id', $this->brands, $this->record['brand_id']);
     $specificationsHTML = array();
     $first = true;
     // specifications
     foreach ($this->specifications as $specification) {
         $specificationName = 'specification' . $specification['id'];
         $languages = array();
         $fields = array();
         // parse specification into template
         $this->tpl->assign('id', $specification['id']);
         $this->tpl->assign('label', $specification['title']);
         $this->tpl->assign('spec', true);
         foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
             $value = BackendCatalogModel::getSpecificationValue($specification['id'], $this->record['id'], $language);
             // check if value is set
             $value = isset($value['value']) ? $value['value'] : null;
             $specificationName = 'specification' . $specification['id'] . '_' . $language;
             $specificationText = $this->frm->addText($specificationName, $value);
             $specificationHTML = $specificationText->parse();
             $fields[] = array('field' => $specificationHTML);
             $languages[] = array('language' => $language);
         }
         $this->tpl->assign('fields', $fields);
         //--Check first loop
         if ($first == false) {
             $languages = array();
         }
         $this->tpl->assign('languages', $languages);
         $specificationsHTML[]['specification'] = $this->tpl->getContent(BACKEND_MODULES_PATH . '/' . $this->getModule() . '/Layout/Templates/Specification.tpl');
     }
     $this->tpl->assign('specifications', $specificationsHTML);
     // meta object
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title_nl', true);
     // set callback for generating a unique URL
     $this->meta->setUrlCallback('Backend\\Modules\\Catalog\\Engine\\Model', 'getURL', array($this->record['id']));
     //--Media
     $this->media = new BackendMediaHelper($this->frm, (string) $this->getModule(), (int) $this->id, (string) $this->getAction(), 'product');
 }