/**
 * get page tags as unordred list or array
 * @since  3.4
 * @param bool $echo Optional, default is true. False will 'return' value
 * @param  bool $asarray if echo is false and asarray is true, returns an array of tags
 * @return array html string or array of tags for page
 */
function get_page_meta_keywords_list($echo = true, $asarray = false)
{
    $tags = getPageGlobal('metak');
    $tags = exec_filter('metak-list', $tags);
    // @filter metak-list (str) filter the meta keywords in list output
    $tags = tagsToAry($tags);
    if (!$echo && $asarray) {
        return $tags;
    }
    $str = "<ul>";
    foreach ($tags as $tag) {
        if (!empty($tag)) {
            $str .= "<li>{$tag}</li>";
        }
    }
    $str .= "</ul>";
    return echoReturn($str);
}
/**
 * filter pages by tags
 * 
 * return pages with tags matching any or all of specified tags
 * optionally exclude matches via exclude flag which inverts the resulting pages
 * 
 * accepts an array or a csv string of keywords
 * eg. getPages('filterTags',array('test','test2','позтюлант'),$case=false, $exclusive=false, $exclude=false);
 * 
 * @since  3.4
 * @param  array   $pages   pagesarray
 * @param  mixed   $tags    array or keyword string of tags to filter by
 * @param  boolean $case    preserve case if true, default case-insensitive
 * @param  boolean $exclusive require match ALL if true, else match ANY
 * @param  boolean $exclude invert filter, return pages not matching tags
 * @return array            filtered PAGES collection
 */
function filterTags($pages, $tags, $case = false, $exclusive = false, $exclude = false)
{
    $filterFunc = $exclusive ? 'filterTagsMatchAll' : 'filterTagsMatchAny';
    // if input tags not array, convert
    if (!is_array($tags)) {
        $tags = tagsToAry($tags, $case);
    }
    // if lowercase, normalize input tags to lowercase
    if (!$case) {
        $tags = array_map('lowercase', $tags);
        $filterFunc .= 'i';
        // change filterfunc to lowercase compare
    }
    $pagesFiltered = filterKeyValueFunc($pages, 'meta', $tags, $filterFunc . 'Cmp');
    if ($exclude) {
        $pagesFiltered = array_diff_key($pages, $pagesFiltered);
    }
    // invert PAGES
    return $pagesFiltered;
}