$tag_max_count = max($posts_count); foreach ($mn_tags as $tag_id => $t) { $percent = floor($posts_count[$tag_id] / $tag_max_count * 100); // decide which class should be assign, according to tag popularity if ($percent < 20) { $tag_class = 'smallest'; } elseif ($percent >= 20 && $percent < 40) { $tag_class = 'small'; } elseif ($percent >= 40 && $percent < 60) { $tag_class = 'medium'; } elseif ($percent >= 60 && $percent < 80) { $tag_class = 'large'; } else { $tag_class = 'largest'; } $tag_cloud .= '<a href="' . generate_tag_url($mn_url, $mn_tags[$tag_id]) . '" class="mn-tag mn-tag-' . $tag_class . '" title="' . $lang['posts_posts'] . ': ' . $posts_count[$tag_id] . '">' . $t['name'] . '</a>' . $tag_divider; } $cut_length = mb_strlen($tag_divider); $tag_cloud = mb_substr($tag_cloud, 0, -$cut_length); echo encoding($tag_cloud); } else { echo encoding($lang['web_msg_no_tags']); } } elseif (isset($mn_mode) && $mn_mode == 'include') { function get_title() { global $dir, $lang, $mn_categories, $mn_users; if (isset($_GET['mn_post'])) { if (is_numeric($_GET['mn_post']) && file_exists(MN_ROOT . $dir['posts'] . 'post_' . $_GET['mn_post'] . '.php')) { $mn_post_id = $_GET['mn_post']; } else {
function posts_tmpl($id, $template, $url) { global $conf, $dir, $file, $lang, $mn_categories, $mn_tags, $mn_mode, $mn_users; if (file_exists(MN_ROOT . $dir['posts'] . 'post_' . $id . '.php') && file_exists(MN_ROOT . $dir['templates'] . $template . '.html')) { $p = get_post_data($id); $tmpl_file = file_get_contents(MN_ROOT . $dir['templates'] . $template . '.html'); $comments_count = get_comments_count($id); $comments = $conf['comments'] ? '<a href="' . generate_post_url($url, $p) . '#mn-comments">' . $lang['web_comments'] . ' (' . $comments_count . ')</a>' : ''; if (!empty($p['full_story'])) { $tmpl_result = preg_replace('/\\[VAR-LINK\\](.*?)\\[\\/VAR-LINK\\]/is', '<a href="' . generate_post_url($url, $p) . '">$1</a>', $tmpl_file); $link = '<a href="' . generate_post_url($url, $p) . '">' . $lang['web_post_link'] . '</a>'; } else { $tmpl_result = preg_replace('/\\[VAR-LINK\\](.*?)\\[\\/VAR-LINK\\]/is', '', $tmpl_file); $link = ''; } if (!empty($p['author']) && !empty($mn_users[$p['author']])) { $author = '<a href="' . $url . 'mn_user='******'author'] . '">' . $mn_users[$p['author']] . '</a>'; $author_name = $mn_users[$p['author']]; } else { $author = '<em class="mn-trivial">' . $lang['web_anonym'] . '</em>'; $author_name = '<em class="mn-trivial">' . $lang['web_anonym'] . '</em>'; } if (!empty($p['cat']) && !empty($mn_categories[$p['cat']]['name'])) { $category = '<a href="' . generate_category_url($url, $mn_categories[$p['cat']]) . '">' . $mn_categories[$p['cat']]['name'] . '</a>'; $category_id = $p['cat']; $category_name = $mn_categories[$p['cat']]['name']; $category_friendly_url = $mn_categories[$p['cat']]['friendly_url']; } else { $category = '<em class="mn-trivial">' . $lang['web_uncategorized'] . '</em>'; $category_id = '-1'; $category_name = '<em class="mn-trivial">' . $lang['web_uncategorized'] . '</em>'; $category_friendly_url = ''; } if (isset($_GET['mn_q']) && $mn_mode != 'rss' && !preg_match('/[\'$&\\/()=%*\\"#~|+{}<>]/i', $_GET['mn_q']) && strlen($_GET['mn_q']) > 2) { $q_search = '/(>[^<]*)(' . $_GET['mn_q'] . ')/is'; $q_replace = '\\1<span class="mn-highlight">\\2</span>'; $p['title'] = preg_replace('/' . $_GET['mn_q'] . '/is', '<span class="mn-highlight">\\0</span>', $p['title']); $p['short_story'] = preg_replace($q_search, $q_replace, $p['short_story']); $p['full_story'] = preg_replace($q_search, $q_replace, $p['full_story']); } if (!empty($p['tags']) && !empty($mn_tags)) { $p['tags-array'] = explode(',', $p['tags']); $tags = ''; $tag_names = ''; foreach ($p['tags-array'] as $tag_id) { if (empty($mn_tags[$tag_id])) { continue; } else { $tags .= '<a href="' . generate_tag_url($url, $mn_tags[$tag_id]) . '">' . $mn_tags[$tag_id]['name'] . '</a>, '; $tag_names .= $mn_tags[$tag_id]['name'] . ', '; } } $tags = substr($tags, 0, -2); $tag_names = substr($tag_names, 0, -2); } else { $tags = ''; $tag_names = ''; } $p_img = explode(';', $p['image']); if (!empty($p_img[0]) && !empty($p_img[1]) && !empty($p_img[2])) { $image_filename = $p_img[0]; $image_url = $conf['admin_url'] . '/' . $dir['images'] . $image_filename; $image_width = $p_img[1]; $image_height = $p_img[2]; $image = '<img src="' . $image_url . '" width="' . $image_width . '" height="' . $image_height . '" alt="' . $p['title'] . '" class="mn-post-image" />'; } else { $image = $image_url = $image_filename = $image_width = $image_height = ''; } if ($mn_mode == 'rss') { $title = htmlspecialchars($p['title'], ENT_QUOTES); $link = generate_post_url($url, $p); $p['title'] = htmlspecialchars($p['title'], ENT_QUOTES); $short_story = htmlspecialchars($p['short_story'], ENT_QUOTES); $p['full_story'] = htmlspecialchars($p['full_story'], ENT_QUOTES); } elseif (substr($template, -2, 2) == '10') { $title = $p['title']; $short_story = $p['short_story'] . $p['full_story']; } else { $title = '<a href="' . generate_post_url($url, $p) . '">' . $p['title'] . '</a>'; $short_story = $p['short_story']; if ($conf['admin_icons'] && isset($_COOKIE['mn_user_name']) && isset($_COOKIE['mn_logged'])) { $title .= ' <a href="' . $conf['admin_url'] . '/mn-posts.php?action=edit&id=' . $id . '"><img src="' . $conf['admin_url'] . '/stuff/img/icons/edit-gray.png" alt="edit" /></a> <a href="' . $conf['admin_url'] . '/mn-posts.php?action=delete&id=' . $id . '&nofancy"><img src="' . $conf['admin_url'] . '/stuff/img/icons/cross-gray.png" alt="delete" /></a>'; } } $tmpl_values_search = array('{AUTHOR}', '{AUTHOR_ID}', '{AUTHOR_NAME}', '{CATEGORY}', '{CATEGORY_FRIENDLY_URL}', '{CATEGORY_ID}', '{CATEGORY_NAME}', '{COMMENTS}', '{COMMENTS_COUNT}', '{FRIENDLY_URL}', '{IMAGE}', '{IMAGE_FILENAME}', '{IMAGE_URL}', '{IMAGE_WIDTH}', '{IMAGE_HEIGHT}', '{LINK}', '{POST_ID}', '{POST_URL}', '{TAGS}', '{TAG_NAMES}', '{TEXT}', '{TEXT_FULL}', '{TEXT_LONG}', '{TEXT_PEREX}', '{TITLE}', '{TITLE_PLAIN}', '{VIEWS}', '{VIEWS_COUNT}'); $tmpl_values_replace = array($author, $p['author'], $author_name, $category, $category_friendly_url, $category_id, $category_name, $comments, $comments_count, $p['friendly_url'], $image, $image_filename, $image_url, $image_width, $image_height, $link, $id, generate_post_url($url, $p), $tags, $tag_names, $short_story, $p['short_story'] . $p['full_story'], $p['full_story'], $p['short_story'], $title, $p['title'], $lang['web_viewed'] . ': ' . $p['views'] . '×', $p['views']); $result = str_ireplace($tmpl_values_search, $tmpl_values_replace, $tmpl_result); $result = $mn_mode != 'rss' ? preg_replace('/\\[PERM-LINK\\](.*?)\\[\\/PERM-LINK\\]/is', '<a href="' . generate_post_url($url, $p) . '">$1</a>', $result) : preg_replace('/\\[PERM-LINK\\](.*?)\\[\\/PERM-LINK\\]/is', '$1', $result); $result = preg_replace('/\\[LINK\\](.*?)\\[\\/LINK\\]/is', '<a href="' . generate_post_url($url, $p) . '">$1</a>', $result); $result = preg_replace('#\\[mn_gallery=(.*?)\\]#ie', 'mn_gallery(\'$1\')', $result); $result = common_tmpl($p['timestamp'], $result); $result = xfields_tmpl('posts', $p['xfields'], $result); return $result; } else { return '<p>' . $lang['web_msg_no_post_or_tmpl'] . '</p>'; } }