예제 #1
0
 /**
  * Retrieves the block parameters from the storage.
  *
  * @return boolean true if the parameters have been retrieved.
  */
 public function retrieve()
 {
     $blockQuery = $this->domainDa->execute("SELECT id,params\n            FROM innomedia_blocks\n            WHERE block = " . $this->domainDa->formatText($this->blockName) . " AND counter = {$this->blockCounter}" . ($this->pageId == 0 ? " AND page " . (strlen($this->pageName) ? " = " . $this->domainDa->formatText($this->pageName) : " IS NULL") : '') . "\n            AND pageid " . ($this->pageId != 0 ? " = " . $this->pageId : " IS NULL"));
     if ($blockQuery->getNumberRows() > 0) {
         $json_params = json_decode($blockQuery->getFields('params'), true);
         $this->parameters = \Innomedia\Locale\LocaleWebApp::getParamsDecodedByLocales($this->blockName, $json_params, 'backend');
         $this->id = $blockQuery->getFields('id');
         return true;
     } else {
         return false;
     }
 }
예제 #2
0
 /**
  * Get list of media
  * @param array $params list of params of page
  * @return returns the list of object Media saved
  */
 public static function getMediaByParams($params)
 {
     $domainDa = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDataAccess();
     $pageModule = $params['pagemodule'];
     $pageName = $params['pagename'];
     $pageId = strlen($params['pageid']) ? $params['pageid'] : '0';
     $blockModule = $params['blockmodule'];
     $blockName = $params['blockname'];
     $blockCounter = $params['blockcounter'];
     $fileId = $params['fileid'];
     $fieldName = $params['fieldname'];
     $default_language = \Innomedia\Locale\LocaleWebApp::getDefaultLanguage();
     // $current_language = \Innomedia\Locale\LocaleWebApp::getCurrentLanguage('backend');
     $current_language = \Innomedia\Locale\LocaleWebApp::getLanguageOfBlock($blockModule . '/' . $blockName, 'backend');
     $list_language_available = \Innomedia\Locale\LocaleWebApp::getListLanguagesAvailable();
     if ($current_language == $default_language) {
         $i = 0;
         $string_not_like = '';
         foreach ($list_language_available as $key => $value) {
             if ($i != 0) {
                 $string_not_like .= " AND ";
             }
             $string_not_like .= "params NOT LIKE '%\"{$key}\":%'";
             $i++;
         }
     }
     $page = "{$pageModule}/{$pageName}";
     $sql = "SELECT  params\n                FROM    innomedia_blocks\n                WHERE   page " . ($page != "/" ? "= '{$page}'" : "is NULL") . "\n                    AND pageid " . ($pageId != 0 ? "= {$pageId}" : "is NULL") . "\n                    AND block = '{$blockModule}/{$blockName}'\n                    AND counter = {$blockCounter}\n                    AND params LIKE '%\"{$fieldName}\":%'\n                    AND (\n                        (params LIKE '%\"{$current_language}\":%')\n                        " . ($current_language == $default_language ? "OR ({$string_not_like})" : '') . "\n                    )";
     $blocksQuery = $domainDa->execute($sql);
     $list_media = array();
     while (!$blocksQuery->eof) {
         $json_params = json_decode($blocksQuery->getFields('params'), true);
         $params = \Innomedia\Locale\LocaleWebApp::getParamsDecodedByLocales("{$blockModule}/{$blockName}", $json_params, 'backend');
         if (!is_array($params[$fieldName])) {
             $list_id_media[] = $params[$fieldName];
         } else {
             $list_id_media = $params[$fieldName];
         }
         $i = 0;
         foreach ($list_id_media as $value_id) {
             $page = "{$pageModule}/{$pageName}";
             $sql = "SELECT  *\n                        FROM    innomedia_media\n                        WHERE   page " . ($page != "/" ? "= '{$page}'" : "is NULL") . "\n                            AND pageid " . ($pageId != 0 ? "= {$pageId}" : "is NULL") . "\n                            AND block = '{$blockModule}/{$blockName}'\n                            AND blockcounter = {$blockCounter}\n                            AND fileid = '{$fileId}'\n                            AND id = {$value_id}";
             $mediaQuery = $domainDa->execute($sql);
             if (is_object($mediaQuery) && $mediaQuery->resultrows > 0) {
                 $list_media[$i]['id'] = $mediaQuery->getFields('id');
                 $list_media[$i]['name'] = $mediaQuery->getFields('name');
                 $list_media[$i]['path'] = $mediaQuery->getFields('path');
                 $list_media[$i]['filetype'] = $mediaQuery->getFields('filetype');
             }
             $i++;
         }
         $blocksQuery->moveNext();
     }
     return $list_media;
 }
예제 #3
0
 public function getBlocksParameters()
 {
     if ($this->id == 0) {
         return array();
     }
     $blockParams = array();
     $blocksQuery = $this->domainDa->execute("SELECT block, counter, params\n            FROM innomedia_blocks\n            WHERE pageid={$this->id}");
     while (!$blocksQuery->eof) {
         $block = $blocksQuery->getFields('block');
         $json_params = json_decode($blocksQuery->getFields('params'), true);
         $params_for_lang = \Innomedia\Locale\LocaleWebApp::getParamsDecodedByLocales($block, $json_params, $this->scopeSession);
         $blockParams[$block][$blocksQuery->getFields('counter')] = $params_for_lang;
         $blocksQuery->moveNext();
     }
     return $blockParams;
 }