/** * Filter by Pages Only * * @param \Illuminate\Database\Eloquent\Builder $query * @param bool|string $showPagesOnly * @return \Illuminate\Database\Eloquent\Builder */ public function scopeShowPagesOnly(Builder $query, $showPagesOnly = true) { if ($showPagesOnly) { $args = self::$siteRepository->getPageEntryIds(); array_unshift($args, $query); call_user_func_array(array($this, 'scopeEntryId'), $args); } return $query; }
/** * Parse a string for these values: * * {filedir_X}, {assets_X:file_name}, {page_X} * * @param string $value WYSIWYG content * @return string */ public function parse($value) { if ($value === null || $value === false || $value === '') { return ''; } preg_match_all('#{page_(\\d+)}#', $value, $pageMatches); foreach ($pageMatches[1] as $i => $entryId) { if ($pageUri = $this->siteRepository->getPageUri($entryId)) { $value = str_replace($pageMatches[0][$i], $pageUri, $value); } } preg_match_all('#{filedir_(\\d+)}#', $value, $filedirMatches); foreach ($filedirMatches[1] as $i => $id) { if ($uploadPref = $this->uploadPrefRepository->find($id)) { $value = str_replace($filedirMatches[0][$i], $uploadPref->url, $value); } } // this is all we need to do for now, since we are only supporting Assets locally, not S3 etc. preg_match_all('#{assets_\\d+:(.*?)}#', $value, $assetsMatches); foreach ($assetsMatches[1] as $i => $url) { $value = str_replace($assetsMatches[0][$i], $url, $value); } return $value; }