public function store() { if (!(is_array($this->parameters) && strlen($this->blockName))) { return false; } $checkQuery = $this->domainDa->execute("SELECT id, params\n FROM innomedia_blocks\n WHERE block = " . $this->domainDa->formatText($this->blockName) . "\n AND counter = {$this->blockCounter}\n AND page " . (strlen($this->pageName) ? " = " . $this->domainDa->formatText($this->pageName) : " IS NULL") . "\n AND pageid " . ($this->pageId != 0 ? " = " . $this->pageId : " IS NULL")); $current_language = \Innomedia\Locale\LocaleWebApp::getCurrentLanguage('backend'); if ($checkQuery->getNumberRows() > 0) { $id = $checkQuery->getFields('id'); $this->id = $id; $params = \Innomedia\Locale\LocaleWebApp::getParamsDecodedByLocalesForUpdate($this->blockName, $checkQuery->getFields('params'), $this->parameters, 'backend'); return $this->domainDa->execute("UPDATE innomedia_blocks\n SET params=" . $this->domainDa->formatText(json_encode($params)) . " WHERE id={$id}"); } else { $id = $this->domainDa->getNextSequenceValue('innomedia_blocks_id_seq'); $this->id = $id; // $params = array(); // $params[$current_language] = $this->parameters; $params = \Innomedia\Locale\LocaleWebApp::getParamsDecodedByLocalesForUpdate($this->blockName, null, $this->parameters, 'backend'); return $this->domainDa->execute("INSERT INTO innomedia_blocks (id,block,counter,params" . (strlen($this->pageName) ? ",page" : "") . ($this->pageId != 0 ? ",pageid" : "") . ") VALUES ({$id}, " . $this->domainDa->formattext($this->blockName) . "," . $this->blockCounter . ',' . $this->domainDa->formatText(json_encode($params, true)) . (strlen($this->pageName) ? "," . $this->domainDa->formattext($this->pageName) : "") . ($this->pageId != 0 ? ",{$this->pageId}" : "") . ")"); } }
/** * Create path of object media * @param string $alias [description] * @return string return path created */ protected function buildPath($alias = '') { $path = ''; if (strlen($this->pageName)) { $path .= strtolower($this->pageName); if ($this->pageId != 0) { $path .= '/' . $this->pageId; } } if (strlen($this->blockName)) { if (strlen($path) > 0) { $path .= '/'; } $path .= 'block_' . strtolower($this->blockName); if ($this->blockCounter != 0) { $path .= '/' . $this->blockCounter; } if (strlen($this->fileId)) { $path .= '/' . $this->fileId; } } if (strlen($path) > 0) { // $current_language = \Innomedia\Locale\LocaleWebApp::getCurrentLanguage('backend'); $folder = \Innomedia\Locale\LocaleWebApp::getLanguageOfBlock($this->blockName, 'backend'); $path .= '/' . str_replace('__', '', $folder); $path .= '/'; } $name = $this->name; if (strlen($alias)) { $name = pathinfo($this->name, PATHINFO_BASENAME) . '_' . $alias . '.' . pathinfo($this->name, PATHINFO_EXTENSION); } $path .= $name; return $path; }
public function updateContent() { if ($this->id == 0) { return false; } $pagesParamsQuery = $this->domainDa->execute("SELECT params\n FROM innomedia_pages\n WHERE id = {$this->id}"); $params = \Innomedia\Locale\LocaleWebApp::getParamsDecodedByLocalesForUpdate(null, $pagesParamsQuery->getFields('params'), $this->parameters, 'backend'); // Update the page database row. $updated = $this->domainDa->execute("UPDATE innomedia_pages\n SET\n name =" . $this->domainDa->formatText($this->name) . ",\n params =" . $this->domainDa->formatText(json_encode($params)) . ",\n blocks =" . $this->domainDa->formatText(json_encode($this->instanceBlocks)) . "\n WHERE id={$this->id}"); if (!$updated) { return false; } // Set the page name for the page tree path. $pageName = isset($this->parameters['slug']) ? $this->parameters['slug'] : ''; // Fallback to page title if the page slug is empty. if (!strlen($pageName)) { $pageName = isset($this->parameters['title']) ? $this->parameters['title'] : ''; } // Fallback to internal page name if the page title is empty. if (!strlen($pageName)) { $pageName = $this->name; } // Fallback to page id if the page name is still empty. if (!strlen($pageName)) { $pageName = $id; } // Rename the page tree path if needed. $tree = new PageTree(); $tree->renamePage($this->id, $pageName); }