/** * This function builds the head containing the meta information * * TODO move to markup()?! * * @param array $tags * @return string */ protected function head(array $tags) { $head = ''; if (!empty($tags)) { $left = ''; if (isset($tags['published'])) { $left .= $tags['published']; } if (isset($tags['author'])) { $left = $left ? $left . ' | ' . $tags['author'] : $tags['author']; } $left = $left ? '<div class="col-md-7"><p>' . $left . '</p></div>' : ''; $right = ''; if (isset($tags['category'])) { $href = Config::getInstance()->app_root . URLs::getInstance()->getURI() . '?' . QueryString::removeAll(array('tag', 'page'), $_SERVER['QUERY_STRING']); foreach ($tags['category'] as $c) { $right .= ' | <a href="' . $href . '&tag=' . $c . '">#' . trim($c) . '</a>'; // $right .= ' | #' . trim($c); } $right = '<div class="col-md-5 pull-right text-right">' . substr($right, 3) . '</div>'; } $head = $left . $right ? '<div class="row content-head">' . $left . $right . '</div>' : ''; } return $head; }
public function markup(Markup $model, $arg, $bool) { // parse head $head = ''; $tags = $model->parseTags(); if (!empty($tags)) { $left = ''; if (isset($tags['published'])) { $left .= $tags['published']; } if (isset($tags['author'])) { $left = $left ? $left . ' | ' . $tags['author'] : $tags['author']; } $left = $left ? '<div class="col-md-7"><p>' . $left . '</p></div>' : ''; $right = ''; if (isset($tags['category'])) { $href = Config::getInstance()->app_root . URLs::getInstance()->getURI() . '?' . QueryString::removeAll(['tag', 'page'], $_SERVER['QUERY_STRING']); foreach ($tags['category'] as $c) { $right .= ' | <a href="' . $href . '&tag=' . $c . '">#' . trim($c) . '</a>'; // $right .= ' | #' . trim($c); } $right = '<div class="col-md-5 pull-right text-right">' . substr($right, 3) . '</div>'; } $head = $left . $right ? '<div class="row content-head">' . $left . $right . '</div>' : ''; } // parse body $body = '<div class="row content-body"><div class="col-md-12">' . $model->parse($arg) . '</div></div>'; if (array_key_exists('static', $model->config) && $model->config['static']) { $href = Config::getInstance()->app_root . URLs::getInstance()->getURI() . '/' . preg_replace('/\\.[^.\\s]{2,4}$/', '', basename($model->config['path'])); // social $social = ''; $general = Config::getInstance()->getGeneralArray('general'); // TODO description if (array_key_exists('social', $general) && $general['social']) { $buttons = Social::getInstance()->socialButtons('https://' . $_SERVER['HTTP_HOST'] . $href, Head::getInstance()->getTitle()); $span = floor(6 / count($buttons)); foreach ($buttons as $b) { $social .= '<div class="col-xs-2 col-md-' . $span . ' text-center">' . $b . '</div>'; } } $static = '<a class="btn btn-default" href="' . $href . '" role="button">Static <i class="fa fa-share-alt"></i></a>'; $body .= '<div class="row content-foot"><div class="col-md-5"><div class="row">' . $social . '</div></div><div class="col-md-7 text-right">' . $static . '</div></div>'; } return '<div class="row content-item"><div class="col-md-12">' . $head . $body . '</div></div>'; }