protected final function get_api($url, $authenticated = false) { if ($authenticated) { $url .= '/token:' . $this->request_read_token(); } return Koken::api($url); }
function kokenI18nOutput($html) { if ($_SERVER['SCRIPT_NAME'] !== "/preview.php") { Koken::$cache_path = str_replace('/cache.', '/cache.' . $this->kokenI18nCookie(true) . '.', Koken::$cache_path); } return $this->kokenI18nExpand($html); }
static function cleanup() { $overall = round((microtime(true) - self::$start_time) * 1000); if (self::$curl_handle) { curl_close(self::$curl_handle); self::$curl_handle = false; } if (error_reporting() !== 0 && !self::$rss) { arsort(self::$timers); $t = array(); $total = 0; $total = array_sum(self::$timers); foreach (self::$timers as $url => $time) { $p = round($time / $total * 100); $time = round($time * 1000); $t[] = "{$time}ms ({$p}%)\n\t----------------------------------\n\t{$url}"; } $total = round($total * 1000); return "<!--\n\n\tKOKEN DEBUGGING (Longest requests first)\n\n\t" . join("\n\n\t", $t) . "\n\n\tTotal API calls: " . count(self::$timers) . "\n\tTotal API time: {$total}ms\n\tTotal time: {$overall}ms\n-->"; } }
private function parse_dynamic($matches) { return Koken::out($matches[1]); }
/** * Constructor: calls parent constructor */ function __construct($id = NULL) { parent::__construct($id); }
function generate() { $params = array(); foreach ($this->parameters as $key => $val) { if ($key === 'tree') { continue; } $params[] = "'{$key}' => \"" . $this->attr_parse($val) . '"'; } $params = join(',', $params); if (!Koken::$main_load_token && !isset($this->parameters['source']) && isset($this->parameters['infinite'])) { $infinite = $this->attr_parse($this->parameters['infinite']); Koken::$main_load_token = Koken::$tokens[0]; if (isset($this->parameters['infinite_toggle'])) { $infinite_selector = $this->attr_parse($this->parameters['infinite_toggle']); unset($this->parameters['infinite_toggle']); } else { $infinite_selector = ''; } unset($this->parameters['infinite']); } else { $infinite = 'false'; $infinite_selector = ''; } $main = '$value' . Koken::$tokens[0]; $curl = '$curl' . Koken::$tokens[0]; $page = '$page' . Koken::$tokens[0]; $options = '$options' . Koken::$tokens[0]; $collection_name = '$collection' . Koken::$tokens[0]; $paginate = '$paginate' . Koken::$tokens[0]; $custom_source_var = '$source' . Koken::$tokens[0]; $custom_source = $custom_source_var . ' = ' . (isset($this->parameters['source']) ? 'true' : 'false'); $load_url = '$url' . Koken::$tokens[0]; $load_url_var = '\\$url' . Koken::$tokens[0]; $top_token = Koken::$tokens[0]; return <<<DOC <?php \tlist({$load_url}, {$options}, {$collection_name}, {$paginate}) = Koken::load( array({$params}) ); \t{$custom_source}; \tif ({$paginate}) \t{ \t\tif (isset(Koken::\$location['parameters']['page'])) \t\t{ \t\t\t{$load_url} .= '/page:' . Koken::\$location['parameters']['page']; \t\t} \t} \tif ({$options}['list'] && isset(Koken::\$routed_variables['tags'])) \t{ \t\t{$load_url} .= '/tags:' . Koken::\$routed_variables['tags']; \t} \tKoken::\$load_history[] = {$load_url}; \t{$main} = Koken::api({$load_url}); \tif (!{$custom_source_var} && isset({$main}['error'])) \t{ \t\theader("Location: " . Koken::\$location['root_folder'] . "/error/{{$main}['http']}/"); \t} \tif ({$options}['list']) \t{ \t\tif (isset({$main}['page'])) \t\t{ \t\t\t{$page} = array( \t\t\t\t'page' => {$main}['page'], \t\t\t\t'pages' => {$main}['pages'], \t\t\t\t'per_page' => {$main}['per_page'], \t\t\t\t'total' => {$main}['total'], \t\t\t); \t\t\tif ({$infinite}) \t\t\t{ \t\t\t\tKoken::\$location['__infinite_token'] = '{$top_token}'; ?> \t\t\t\t<script> \t\t\t\t\t\$K.infinity.totalPages = <?php echo {$page}['pages']; ?>; \t\t\t\t\t\$K.infinity.selector = '{$infinite_selector}'; \t\t\t\t</script> <?php \t\t\t} \t\t} \t\tif (isset({$main}['content'])) \t\t{ \t\t\t{$main}['__loop__'] = {$main}['content']; \t\t} \t\telse if (isset({$main}['albums'])) \t\t{ \t\t\t{$main}['__loop__'] = {$main}['albums']; \t\t} \t\telse if (isset({$main}['text'])) \t\t{ \t\t\t{$main}['__loop__'] = {$main}['text']; \t\t} \t\telse if (isset({$main}['items'])) \t\t{ \t\t\t\$__arr = array('items' => {$main}['items']); \t\t\tif (isset({$main}['event'])) \t\t\t{ \t\t\t\t\$__arr['__koken__'] = 'event'; \t\t\t\t\$__arr['event'] = {$main}['event']; \t\t\t} \t\t\t{$main}['__loop__'] = array(\$__arr); \t\t\tif (isset({$main}['__koken__']) && !isset({$main}[{$main}['__koken__']])) \t\t\t{ \t\t\t\t{$main}[{$main}['__koken__']] =& {$main}; \t\t\t} \t\t} \t\telse if (isset({$main}[{$collection_name}])) \t\t{ \t\t\t{$main}['__loop__'] = {$main}[{$collection_name}]; \t\t\t{$main}[{$collection_name}] =& {$main}['__loop__']; \t\t} \t\telse \t\t{ \t\t\t{$main}['__loop__'] = {$main}; \t\t} \t\tif (array_key_exists('counts', {$main})) \t\t{ \t\t\t{$main}[{$collection_name}]['counts'] =& {$main}['counts']; \t\t} \t} \tif (({$options}['list'] && !empty({$main}['__loop__'])) || (!{$options}['list'] && {$main} && !isset({$main}['error']))): \t\tif ({$options}['list']) \t\t{ \t\t\tif ({$options}['archive']) \t\t\t{ \t\t\t\tswitch({$options}['archive']) \t\t\t\t{ \t\t\t\t\tcase 'tag': \t\t\t\t\t\t{$main}['archive'] = array('__koken__' => 'tag', 'type' => 'tag', 'title' => str_replace(',', ', ', urldecode(isset(Koken::\$routed_variables['id']) ? Koken::\$routed_variables['id'] : Koken::\$routed_variables['slug']))); \t\t\t\t\t\tbreak; \t\t\t\t\tcase 'category': \t\t\t\t\t\t{$main}['archive'] = array('__koken__' => 'category', 'type' => 'category', 'title' => {$main}['category']['title'], 'slug' => {$main}['category']['slug']); \t\t\t\t\t\tbreak; \t\t\t\t\tcase 'date': \t\t\t\t\t\t{$main}['archive'] = array('__koken__' => 'archive', 'type' => 'date', 'day' => isset(Koken::\$routed_variables['day']) ? Koken::\$routed_variables['day'] : false, 'month' => isset(Koken::\$routed_variables['month']) ? Koken::\$routed_variables['month'] : false, 'year' => Koken::\$routed_variables['year']); \t\t\t\t\t\tbreak; \t\t\t\t} \t\t\t} \t\t} \t\telse \t\t{ \t\t\tif (isset({$main}['page_type']) && isset({$main}['draft'])) \t\t\t{ \t\t\t\t{$main}['content'] = {$main}['draft']; \t\t\t\t{$main}['title'] = {$main}['draft_title']; \t\t\t\techo '<script>\$(document).ready( function() { \$K.textPreview(' . {$main}['id'] . ', ' . ({$main}['published'] ? 'true' : 'false') . '); } );</script>'; \t\t\t\techo <<<CSS <!-- KOKEN HEAD BEGIN --> <style type="text/css"> #k_essay_preview { \theight:28px !important; \tline-height:28px !important; \twidth:100% !important; \tposition:fixed !important; \tz-index:99999 !important; \ttop:0 !important; \tleft:0 !important; \tcolor:#bbb !important; \tfont-size:12px !important; \ttext-align:center !important; \tfont-family:'HelveticaNeue-Medium', Helvetica, Arial, sans-serif !important; \tborder-top: 1px solid #070707 !important; \tborder-bottom: 1px solid #070707 !important; \ttext-shadow: 0 1px 1px #000 !important; \tbackground-color: #303030 !important; \tbackground-repeat: repeat-x !important; \tbackground-image: -khtml-gradient(linear, left top, left bottom, from(#333), to(#242424)) !important; \tbackground-image: -moz-linear-gradient(#333, #242424) !important; \tbackground-image: -ms-linear-gradient(#333, #242424) !important; \tbackground-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #333), color-stop(100%, #242424)) !important; \tbackground-image: -webkit-linear-gradient(#333, #242424) !important; \tbackground-image: linear-gradient(#333, #242424) !important; } #k_essay_preview a { \tcolor:#fff !important; \ttext-decoration:none !important; } </style> <!-- KOKEN HEAD END --> CSS; \t\t\t} \t\t\tif (!isset({$main}[{$main}['__koken__']])) \t\t\t{ \t\t\t\t{$main}[{$main}['__koken__']] =& {$main}; \t\t\t} \t\t} \t\tif (!{$custom_source_var}) \t\t{ \t\t\t\$__meta_source = {$main}; \t\t\tif (!empty({$main}['title'])) \t\t\t{ \t\t\t\t\$the_title = {$main}['title']; \t\t\t} \t\t\telse if (isset({$main}['filename'])) \t\t\t{ \t\t\t\t\$the_title = {$main}['filename']; \t\t\t} \t\t\telse if (isset({$main}['album']['title'])) \t\t\t{ \t\t\t\t\$the_title = {$main}['album']['title']; \t\t\t\t\$__meta_source = {$main}['album']; \t\t\t} \t\t\telse if (isset({$main}['archive']['title'])) \t\t\t{ \t\t\t\t\$the_title = {$main}['archive']['title']; \t\t\t} \t\t\telse if (isset({$main}['event'])) \t\t\t{ \t\t\t\t\$__fmt = Koken::\$site['date_format']; \t\t\t\tif (!isset({$main}['event']['day'])) \t\t\t\t{ \t\t\t\t\tif (isset({$main}['event']['month'])) \t\t\t\t\t{ \t\t\t\t\t\t\$__fmt = 'F Y'; \t\t\t\t\t} \t\t\t\t\telse \t\t\t\t\t{ \t\t\t\t\t\t\$__fmt = 'Y'; \t\t\t\t\t} \t\t\t\t} \t\t\t\t\$the_title = date(\$__fmt, strtotime({$main}['event']['year'] . '-' . (isset({$main}['event']['month']) ? {$main}['event']['month'] : '01') . '-' . (isset({$main}['event']['day']) ? {$main}['event']['day'] : '01'))); \t\t\t} \t\t\telse if (isset({$main}['archive'])) \t\t\t{ \t\t\t\t\$the_title = Koken::title_from_archive({$main}['archive']); \t\t\t} \t\t\tif (isset({$main}['canonical_url']) || isset({$main}['album']['canonical_url'])) \t\t\t{ \t\t\t\t\$__canon = isset({$main}['canonical_url']) ? {$main}['canonical_url'] : {$main}['album']['canonical_url']; \t\t\t\techo '<!-- KOKEN HEAD BEGIN --><link rel="canonical" href="' . \$__canon . '"><!-- KOKEN HEAD END -->'; \t\t\t} \t\t\tif (isset(\$the_title) && isset(Koken::\$the_title_separator) && !Koken::\$page_title_set) \t\t\t{ \t\t\t\tKoken::\$page_title_set = true; \t\t\t\techo '<!-- KOKEN HEAD BEGIN --><koken_title>' . \$the_title . Koken::\$the_title_separator . Koken::\$site['page_title'] . '</koken_title><!-- KOKEN HEAD END -->'; \t\t\t} \t\t\tif (isset({$main}['essay']) && !isset(\$_COOKIE['koken_session_ci']) && !{$main}['essay']['published']) \t\t\t{ \t\t\t\theader('Location: ' . Koken::\$location['root'] . '/error/403/'); \t\t\t\texit; \t\t\t} \t\t\t\$__public = isset({$main}['public']) ? {$main}['public'] : ( isset({$main}['album']['public']) ? {$main}['album']['public'] : true ); \t\t\tif (!\$__public) \t\t\t{ \t\t\t\techo '<!-- KOKEN HEAD BEGIN --><meta name="robots" content="noindex" /><!-- KOKEN HEAD END -->'; \t\t\t} \t\t\tif (isset({$main}['album']) || isset({$main}['context']['album'])) \t\t\t{ \t\t\t\tif (isset({$main}['album'])) \t\t\t\t{ \t\t\t\t\t\$__rss = {$main}['album']['rss'] = Koken::\$location['root'] . '/feed/albums/' . {$main}['album']['id'] . '/recent.rss'; \t\t\t\t\t\$__title = {$main}['album']['title']; \t\t\t\t\t\$__public = {$main}['album']['public']; \t\t\t\t} \t\t\t\telse \t\t\t\t{ \t\t\t\t\t\$__rss = {$main}['context']['album']['rss'] = Koken::\$location['root'] . '/feed/albums/' . {$main}['context']['album']['id'] . '/recent.rss'; \t\t\t\t\t\$__title = {$main}['context']['album']['title']; \t\t\t\t\t\$__public = {$main}['context']['album']['public']; \t\t\t\t} \t\t\t\tif (\$__public) \t\t\t\t{ \t\t\t\t\techo '<!-- KOKEN HEAD BEGIN --><link rel="alternate" type="application/atom+xml" title="' . Koken::\$site['page_title'] . ': Uploads from ' . \$__title . '" href="' . \$__rss . '" /><!-- KOKEN HEAD END -->'; \t\t\t\t} \t\t\t} \t\t\t\$__meta = array('description' => '', 'keywords' => array()); \t\t\t\$__candidates = array('summary', 'description', 'caption', 'excerpt', 'title', 'filename'); \t\t\twhile (strlen(\$__meta['description']) === 0 && count(\$__candidates)) \t\t\t{ \t\t\t\t\$__field = array_shift(\$__candidates); \t\t\t\tif (isset(\$__meta_source[\$__field]) && strlen(\$__meta_source[\$__field]) > 0) \t\t\t\t{ \t\t\t\t\t\$__meta['description'] = preg_replace('/\\s+/', ' ', preg_replace('/ +/', ' ', strip_tags(\$__meta_source[\$__field]))); \t\t\t\t} \t\t\t} \t\t\tif (isset(\$__meta_source['tags']) && !isset(\$__meta_source['page'])) \t\t\t{ \t\t\t\tforeach(\$__meta_source['tags'] as \$__tag) \t\t\t\t{ \t\t\t\t\t\$__meta['keywords'][] = \$__tag['title']; \t\t\t\t} \t\t\t} \t\t\techo '<!-- KOKEN META DESCRIPTION BEGIN -->' . Koken::truncate(\$__meta['description'], 160) . '<!-- KOKEN META DESCRIPTION END -->'; \t\t\techo '<!-- KOKEN META KEYWORDS BEGIN -->' . join(', ', \$__meta['keywords']) . '<!-- KOKEN META KEYWORDS END -->'; \t\t} ?> DOC; }
/** * Constructor: calls parent constructor */ function __construct($id = NULL) { $db_config = Shutter::get_db_configuration(); $this->has_many = array('text' => array('other_field' => 'featured_image'), 'album', 'tag', 'category', 'covers' => array('class' => 'album', 'join_table' => $db_config['prefix'] . 'join_albums_covers', 'other_field' => 'cover', 'join_self_as' => 'cover', 'join_other_as' => 'album')); parent::__construct($id); }
function go($tmpl, $pass = 1) { $raw = Koken::parse($tmpl); // Fix PHP whitespace issues in koken:loops $raw = preg_replace('/\\s+<\\?php\\s+endforeach/', '<?php endforeach', $raw); $raw = preg_replace('/<a(.*)>\\s+<\\?php/', '<a$1><?php', $raw); $raw = preg_replace('/\\?>\\s+<\\/a>/', '?></a>', $raw); if ($pass === 1) { global $final_path; $is_lightbox = 'false'; if ($final_path === 'lightbox.lens') { $is_lightbox = 'true'; } // Filters $raw = str_replace('<head>', "<head><?php Shutter::hook('after_opening_head', array(array('lightbox' => {$is_lightbox}))); ?>", $raw); $raw = str_replace('</head>', "<?php Shutter::hook('before_closing_head', array(array('lightbox' => {$is_lightbox}))); ?></head>", $raw); $raw = str_replace('<body>', "<body><?php Shutter::hook('after_opening_body', array(array('lightbox' => {$is_lightbox}))); ?>", $raw); $raw = str_replace('</body>', "<?php Shutter::hook('before_closing_body', array(array('lightbox' => {$is_lightbox}))); ?></body>", $raw); // die($raw); Koken::$location['page_class'] = Koken::$page_class; $dynamic_array = array(); foreach (Koken::$dynamic_location_parts as $key) { $dynamic_array[$key] = Koken::$location[$key]; } unset($dynamic_array['parameters']['__overrides']); unset($dynamic_array['parameters']['__overrides_display']); $location_json = json_encode($dynamic_array); if (Koken::$pjax) { $js = "<script>\$K.location = \$.extend(\$K.location, {$location_json});\$(window).trigger('k-pjax-end');</script>"; } else { $location = Koken::$location; $site = Koken::$site; $stamp = '?' . KOKEN_VERSION; $generator = 'Koken ' . KOKEN_VERSION; $theme = Koken::$site['theme']['name'] . ' ' . Koken::$site['theme']['version']; $koken_js = Koken::$location['root_folder'] . '/' . (Koken::$draft ? 'preview.php?/' : (Koken::$rewrite ? '' : 'index.php?/')) . 'koken.js' . (Koken::$preview ? '&preview=' . Koken::$preview : ''); if (strpos($koken_js, '.php?') === false) { $koken_js .= '?' . Shutter::get_site_scripts_timestamp(); } if (Koken::$has_video) { $me = "\n\n\t<link href=\"{$location['real_root_folder']}/app/site/themes/common/css/mediaelement/mediaelementplayer.min.css{$stamp}\" rel=\"stylesheet\">\n"; } else { $me = ''; } $js = <<<JS \t<meta name="generator" content="{$generator}" /> \t<meta name="theme" content="{$theme}" />{$me} \t<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> \t<script>window.jQuery || document.write('<script src="{$location['real_root_folder']}/app/site/themes/common/js/jquery.min.js"><\\/script>')</script> \t<script src="{$koken_js}"></script> \t<script>\$K.location = \$.extend(\$K.location, {$location_json});</script> \t<link rel="alternate" type="application/atom+xml" title="{$site['title']}: All uploads" href="{$location['root']}/feed/content/recent.rss" /> \t<link rel="alternate" type="application/atom+xml" title="{$site['title']}: Essays" href="{$location['root']}/feed/essays/recent.rss" /> \t<link rel="alternate" type="application/atom+xml" title="{$site['title']}: Timeline" href="{$location['root']}/feed/timeline/recent.rss" /> JS; } if (Koken::$draft && !Koken::$preview && !Koken::$pjax) { $original_url = Koken::$original_url; $js .= <<<JS <script> if (parent && parent.\$) { \tparent.\$(parent.document).trigger('previewready', '{$original_url}'); \t\$(function() { parent.\$(parent.document).trigger('previewdomready'); }); \t\$(document).on('pjax:end pjax:transition:end', function(event) { \t\tif (event.type === 'pjax:end') { \t\t\tparent.\$(parent.document).trigger('previewready', location.href); \t\t} \t\tparent.\$(parent.document).trigger('previewdomready'); \t}); \t\$(document).on('page:change.console', function() { \t\tparent.\$(parent.document).trigger('previewready', location.href); \t\tparent.\$(parent.document).trigger('previewdomready'); \t}); } if (parent && parent.__koken__) { \t\$(window).on('keydown', function(e) { parent.__koken__.shortcuts(e); }); \t\$(function() { parent.__koken__.panel(); }); } </script> <style type="text/css"> i.k-control-structure { font-style: normal !important; } \tdiv[data-pulse-group] div.cover { \t\twidth: 100%; \t\theight: 100%; \t\tz-index: 1000; \t\tborder: 5px solid transparent; \t\tbox-sizing: border-box; \t\tposition: absolute; \t\tbox-shadow: 0 0 20px rgba(0,0,0,0.6); \t\tdisplay: none; \t\tpointer-events:none; \t\ttop: 0; \t\tleft: 0; \t} \tdiv[data-pulse-group]:hover div.cover, div[data-pulse-group] div.cover.active { \t\tdisplay: block !important; \t} \tdiv[data-pulse-group] div.cover.active { \t\tborder-color: #ff6e00 !important; \t} \tdiv[data-pulse-group] div.cover div { \t\tpointer-events:auto; \t\twidth: 10%; \t\theight: 10%; \t\tmin-width: 28px; \t\tmin-height: 28px; \t\tbackground-size: 28px 28px; \t\tbackground-position:top right; \t\tbackground-repeat:no-repeat; \t\tbackground-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOC4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLz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FsMCwwLjFsMS43LDAuNGMwLDAuMywwLjEsMC42LDAuMSwwLjhjMCwwLjMsMCwwLjYtMC4xLDAuOGwtMS43LDAuNGwwLDAuMQ0KCQkJYy0wLjEsMC40LTAuMywwLjctMC40LDEuMWwwLDAuMWwwLjksMS41Yy0wLjQsMC41LTAuOCwwLjktMS4yLDEuMmwtMS41LTAuOWwtMC4xLDBjLTAuMywwLjItMC43LDAuMy0xLjEsMC40bC0wLjEsMGwtMC40LDEuNw0KCQkJQzE0LjUsMjAuNSwxNC4zLDIwLjUsMTQsMjAuNXogTTE0LDExLjZjLTEuMywwLTIuNCwxLjEtMi40LDIuNGMwLDEuMywxLjEsMi40LDIuNCwyLjRjMS4zLDAsMi40LTEuMSwyLjQtMi40DQoJCQlDMTYuNCwxMi43LDE1LjMsMTEuNiwxNCwxMS42eiIvPg0KCTwvZz4NCjwvZz4NCjwvc3ZnPg0K);\t\tposition: absolute; \t\ttop: 4px; \t\tright: 4px; \t\tcursor: pointer; \t\tz-index: 1001; \t} \tdiv[data-pulse-group] div.cover div:hover { \t\tbackground-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOC4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZp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Q0KCQkJYy0wLjEsMC40LTAuMywwLjctMC40LDEuMWwwLDAuMWwwLjksMS41Yy0wLjQsMC41LTAuOCwwLjktMS4yLDEuMmwtMS41LTAuOWwtMC4xLDBjLTAuMywwLjItMC43LDAuMy0xLjEsMC40bC0wLjEsMGwtMC40LDEuNw0KCQkJQzE0LjUsMjAuNSwxNC4zLDIwLjUsMTQsMjAuNXogTTE0LDExLjZjLTEuMywwLTIuNCwxLjEtMi40LDIuNGMwLDEuMywxLjEsMi40LDIuNCwyLjRjMS4zLDAsMi40LTEuMSwyLjQtMi40DQoJCQlDMTYuNCwxMi43LDE1LjMsMTEuNiwxNCwxMS42eiIvPg0KCTwvZz4NCjwvZz4NCjwvc3ZnPg0K); \t} </style> JS; } } $contents = Koken::render($raw); if ($pass === 1) { // Rerun parse to catch shortcode renders while (strpos($contents, '<koken:') !== false && $pass < 3) { $pass++; $contents = go($contents, $pass); } } else { return $contents; } $contents .= Koken::cleanup(); if (strpos($contents, 'settings.css.lens"') === false && !empty(Koken::$site['custom_css']) || Koken::$draft) { $js .= '<style id="koken_custom_css">' . Koken::$site['custom_css'] . '</style>'; } preg_match_all('/<\\!\\-\\- KOKEN HEAD BEGIN \\-\\->(.*)<!\\-\\- KOKEN HEAD END \\-\\->/msU', $contents, $headers); $contents = preg_replace('/<\\!\\-\\- KOKEN HEAD BEGIN \\-\\->(.*)<!\\-\\- KOKEN HEAD END \\-\\->/msU', '', $contents); $header_str = ''; foreach ($headers[1] as $header) { $header_str .= "\t" . $header . "\n"; } if (strpos($header_str, '<title>') !== false) { $contents = preg_replace('/<title>.*<\\/title>/msU', '', $contents); $header_str = preg_replace('/<koken_title>.*<\\/koken_title>/', '', $header_str); } else { if (strpos($header_str, '<koken_title>') !== false && strpos($contents, '<koken_title') !== false) { $contents = preg_replace('/<title>.*<\\/title>/msU', '', $contents); $header_str = str_replace('koken_title', 'title', $header_str); } else { if (strpos($contents, '<koken_title') !== false) { $contents = str_replace('koken_title', 'title', $contents); } } } if (Koken::$pjax && strpos($header_str, '<title>')) { preg_match('~<title>.*</title>~', $header_str, $title_match); $contents .= $title_match[0]; } $contents = preg_replace('/<koken_title>.*<\\/koken_title>/msU', '', $contents); $header_str .= "\n\t<!--[if IE]>\n\t<script src=\"" . Koken::$location['real_root_folder'] . "/app/site/themes/common/js/html5shiv.js\"></script>\n\t<![endif]-->\n"; if (strpos($contents, '<head>')) { preg_match('/<head>(.*)?<\\/head>/msU', $contents, $header); if (count($header)) { $head = isset($header[1]) ? $header[1] : ''; preg_match_all('/<script.*<\\/script>/msU', $head, $head_js); $head = preg_replace('/\\s*<script.*<\\/script>\\s*/msU', '', $head) . "\n{$header_str}\n{$js}\n" . join("\n", $head_js[0]); $contents = preg_replace('/<head>(.*)?<\\/head>/msU', "<head>\n" . str_replace('$', '\\$', $head) . "\n</head>", $contents); } } else { if (strpos($contents, '</body>')) { $contents = str_replace('</body>', "{$js}\n{$header_str}\n</body>", $contents); } else { if (Koken::$pjax) { $contents .= $js; } } } $final_page_classes = trim(join(' ', array_merge(explode(' ', Koken::$page_class), Shutter::get_body_classes()))); if (preg_match_all('/<body(?:[^>]+)?>/', $contents, $match) && !empty($final_page_classes)) { foreach ($match[0] as $body) { if (strpos($body, 'class="') !== false) { $new_body = preg_replace('/class="([^"]+)"/', "class=\"\$1 " . $final_page_classes . "\"", $body); } else { $new_body = str_replace('>', ' class="' . $final_page_classes . '">', $body); } $contents = str_replace($body, $new_body, $contents); } } if (preg_match_all('/<html(?:[^>]+)?>/', $contents, $match) && !empty($final_page_classes)) { foreach ($match[0] as $html) { if (strpos($html, 'class="') !== false) { $new_html = preg_replace('/class="([^"]+)"/', "class=\"\$1 " . $final_page_classes . "\"", $html); } else { $new_html = str_replace('>', ' class="' . $final_page_classes . '">', $html); } $contents = str_replace($html, $new_html, $contents); } } preg_match('/<!-- KOKEN META DESCRIPTION BEGIN -->(.*)<!-- KOKEN META DESCRIPTION END -->/msU', $contents, $meta_description); preg_match('/<!-- KOKEN META KEYWORDS BEGIN -->(.*)<!-- KOKEN META KEYWORDS END -->/msU', $contents, $meta_keywords); $contents = preg_replace('/<!-- KOKEN META (DESCRIPTION|KEYWORDS) BEGIN -->.*<!-- KOKEN META (DESCRIPTION|KEYWORDS) END -->/msU', '', $contents); $contents = preg_replace('/\\t+/', "\t", $contents); $contents = preg_replace('/\\n\\t*\\n/', "\n", $contents); $contents = preg_replace('/\\n{2,}/', "\n\n", $contents); $contents = preg_replace('/<title>\\s*/ms', '<title>', $contents); if (count($meta_description) && strlen($meta_description[1]) > 0) { $contents = preg_replace('/<meta name="description" content=".*" \\/>/', '<meta name="description" content="' . str_replace('$', '\\$', $meta_description[1]) . '" />', $contents); } if (count($meta_keywords) && strlen($meta_keywords[1]) > 0) { $contents = preg_replace('/<meta name="keywords" content="(.*)" \\/>/', "<meta name=\"keywords\" content=\"\$1, {$meta_keywords[1]}\" />", $contents); } if (Koken::$rss) { $contents = '<?xml version="1.0" encoding="utf-8"?>' . "\n{$contents}"; } else { $contents = Shutter::filter('site.output', $contents); } Koken::cache($contents); if (Koken::$rss) { header('Content-type: text/xml; charset=UTF-8'); } else { header('Content-type: text/html; charset=UTF-8'); } die($contents); }
/** * Extracts images from text * * @param $text * @return array|bool|mixed|string */ protected function extractImagesFormText($text) { $images = FALSE; preg_match('/filter:id="([^"]*)"/', $text, $matches); if ($matches[1]) { list($apiUrl) = koken::load(array('source' => 'contents', 'filter:id' => $matches[1])); $images = Koken::api($apiUrl); if ($images['content']) { $images = $images['content']; } else { $images = array($images); } } return $images; }
/** * Parses the HTML output prior to delivery to the browser and filters out languages other than that selected. * First, filters based on Babel's delimiter, then Babel's tag and finally on the user set separator. * @param string $html A string containing the HTML output. * @return string The filtered HTML. */ function parse_output($html) { Koken::$cache_path = $this->mb_str_replace('/cache.', '/cache.' . $this->langs[$this->lang]['code'] . '.', Koken::$cache_path); $html = $this->translate_navigation($html); $html = $this->translate_labels($html); $html = $this->translate_title($html); $html = $this->filter_on_delim($html); $html = $this->filter_on_tag($html); $html = $this->filter_on_sep($html); return $html; }