Beispiel #1
0
function nm_search()
{
    global $NMPAGEURL, $i18n;
    if ($NMPAGEURL == '') {
        return;
    }
    $placeholder = isset($i18n['news_manager/SEARCH_PLACEHOLDER']) ? $i18n['news_manager/SEARCH_PLACEHOLDER'] : '';
    $url = nm_get_url();
    ?>
  <form id="search" action="<?php 
    echo $url;
    ?>
" method="post">
    <input type="text" class="text" name="keywords" value="" <?php 
    if ($placeholder) {
        echo 'placeholder="', htmlspecialchars($placeholder), '"';
    }
    ?>
 /><!--[if IE]><input type="text" style="display: none;" disabled="disabled" size="20" value="Ignore field. IE bug fix"
    /><![endif]--><input type="submit" class="submit" name="search" value="<?php 
    i18n('news_manager/SEARCH');
    ?>
" />
  </form>
  <?php 
}
Beispiel #2
0
function nm_admin_panel()
{
    global $NMPAGEURL;
    $posts = nm_get_posts(true);
    if (nm_post_files_differ($posts)) {
        nm_update_cache();
        $posts = nm_get_posts(true);
        if (nm_post_files_differ($posts)) {
            nm_display_message('<b>Warning:</b> Post files/cache mismatch', true);
        } else {
            nm_display_message('Post cache file has been updated', false);
        }
        // not translated
    }
    ?>
  <h3 class="floated"><?php 
    i18n('news_manager/PLUGIN_NAME');
    ?>
</h3>
  <div class="edit-nav clearfix">
    <a href="#" id="filter-button" ><?php 
    i18n('FILTER');
    ?>
</a>
    <a href="load.php?id=news_manager&amp;edit"><?php 
    i18n('news_manager/NEW_POST');
    ?>
</a>
    <a href="load.php?id=news_manager&amp;settings"><?php 
    i18n('news_manager/SETTINGS');
    ?>
</a>
  </div>
  <?php 
    if (!empty($posts)) {
        ?>
    <div id="filter-search">
      <form>
        <input type="text" class="text" id="tokens" placeholder="<?php 
        echo lowercase(strip_tags(i18n_r('FILTER')));
        ?>
..." />
        &nbsp;
        <a href="load.php?id=news_manager" class="cancel"><?php 
        i18n('news_manager/CANCEL');
        ?>
</a>
      </form>
    </div>
    <table id="posts" class="highlight">
    <tr>
      <th><?php 
        i18n('news_manager/POST_TITLE');
        ?>
</th>
      <th style="text-align: right;"><?php 
        i18n('news_manager/DATE');
        ?>
</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
    <?php 
        foreach ($posts as $post) {
            $title = stripslashes($post->title);
            $date = shtDate($post->date);
            $url = nm_get_url('post') . $post->slug;
            $url = nm_patch_i18n_url($url);
            ?>
      <tr>
        <td class="posttitle">
          <a href="load.php?id=news_manager&amp;edit=<?php 
            echo $post->slug;
            ?>
" title="<?php 
            i18n('news_manager/EDIT_POST');
            ?>
: <?php 
            echo $title;
            ?>
">
            <?php 
            echo $title;
            ?>
          </a>
        </td>
        <td style="text-align: right;">
          <?php 
            if (strtotime($post->date) > time()) {
                echo '<span style="color:#aaa">', $date, '</span>';
            } else {
                echo '<span>', $date, '</span>';
            }
            ?>
        </td>
        <td style="width: 20px;text-align: center;">
          <?php 
            if ($post->private == 'Y') {
                echo '<span style="color: #aaa;">P</span>';
            }
            ?>
        </td>
        <td class="secondarylink">
          <?php 
            if ($NMPAGEURL && $NMPAGEURL != '') {
                ?>
            <a href="<?php 
                echo $url;
                ?>
" target="_blank" title="<?php 
                i18n('news_manager/VIEW_POST');
                ?>
: <?php 
                echo $title;
                ?>
">
              #
            </a>
          <?php 
            }
            ?>
        </td>
        <td class="delete">
          <a href="load.php?id=news_manager&amp;delete=<?php 
            echo $post->slug;
            ?>
" class="nm_delconfirm" title="<?php 
            i18n('news_manager/DELETE_POST');
            ?>
: <?php 
            echo $title;
            ?>
?">
            &times;
          </a>
        </td>
      </tr>
      <?php 
        }
        ?>
    </table>
    <p>
      <b><?php 
        echo count($posts);
        ?>
</b>
      <?php 
        i18n('news_manager/POSTS');
        ?>
    </p>

    <script>
    $(document).ready(function() {
      // filter button opens up filter dialog
      $("#filter-button").on("click", function($e) {
        $e.preventDefault();
        $("#filter-search").slideToggle();
        $(this).toggleClass("current");
        $("#filter-search #tokens").focus();
      });
      // ignore enter key in filter form
      $("#filter-search #tokens").keydown(function($e) {
        if($e.keyCode == 13) {
          $e.preventDefault();
        }
      });
      // close filter dialog on cancel
      $("#filter-search .cancel").on("click", function($e) {
        $e.preventDefault();
        $("#posts tr").show();
        $('#filter-button').toggleClass("current");
        $("#filter-search #tokens").val("");
        $("#filter-search").slideUp();
      });
      // filter table, see:
      // http://kobikobi.wordpress.com/2008/09/15/using-jquery-to-filter-table-rows/
      $("#posts tr:has(td.posttitle)").each(function() {
        var t = $(this).find('td.posttitle').text().toLowerCase();
        $("<td class='indexColumn'></td>")
        .hide().text(t).appendTo(this);
      });
      $("#tokens").keyup(function() {
        var s = $(this).val().toLowerCase().split(" ");
      $("#posts tr:hidden").show();
      $.each(s, function(){
           $("#posts tr:visible .indexColumn:not(:contains('"
              + this + "'))").parent().hide();
        });
      });
      // confirm delete 
      $('.nm_delconfirm').on('click', function () {
        return confirm($(this).attr("title"));
      });
    });
    </script>

    <?php 
    }
}
Beispiel #3
0
}
?>

<h3 class="floated">
  <?php 
if (empty($data)) {
    i18n('news_manager/NEW_POST');
} else {
    i18n('news_manager/EDIT_POST');
}
?>
</h3>
<div class="edit-nav" >
  <?php 
if (!empty($NMPAGEURL) && $NMPAGEURL != '' && !$newpost) {
    $url = nm_get_url('post') . $slug;
    $url = nm_patch_i18n_url($url);
    ?>
    <a href="<?php 
    echo $url;
    ?>
" target="_blank">
      <?php 
    i18n('news_manager/VIEW_POST');
    ?>
    </a>
    <?php 
}
?>
  <a href="#" id="metadata_toggle">
    <?php 
Beispiel #4
0
function nm_show_navigation($index, $total, $tag = null)
{
    $p1 = intval(NMFIRSTPAGE);
    if (!$tag) {
        $first = nm_get_url();
        $page = nm_get_url('page');
    } else {
        $first = nm_get_url('tag') . rawurlencode($tag);
        if (nm_get_option('tagpagination') == 'f') {
            $page = $first . '/' . NMPARAMPAGE . '/';
        } else {
            $page = $first . '&amp;' . NMPARAMPAGE . '=';
        }
    }
    $container = nm_clean_markup(nm_get_option('markupnavcontainer', ''));
    $nav = nm_clean_markup(nm_get_option('markupnav', 'div'));
    $item = nm_clean_markup(nm_get_option('markupnavitem', 'span'));
    $clcontainer = nm_clean_classes(nm_get_option('classnavcontainer', ''));
    $clnav = nm_clean_classes(nm_get_option('classnav'));
    $clprev = nm_clean_classes(nm_get_option('classnavitemprev', 'previous'));
    $clnext = nm_clean_classes(nm_get_option('classnavitemnext', 'next'));
    $cldisabled = nm_clean_classes(nm_get_option('classnavitemdisabled', 'disabled'));
    $clcurrent = nm_clean_classes(nm_get_option('classnavitemcurrent', 'current'));
    if ($container) {
        echo "<{$container}", nm_class_attr($clcontainer), ">", PHP_EOL;
    }
    echo "<{$nav}", nm_class_attr($clnav), ">", PHP_EOL;
    if (!nm_get_option('navoldnew', false)) {
        $prevnext = nm_get_option('navprevnext', '1');
        $showalways = strtolower($prevnext[0]) == 'a';
        // navPrevNext a[lways]
        if ($prevnext && $index > $p1) {
            echo "<{$item}", nm_class_attr($clprev), "><a href=\"";
            echo $index > $p1 + 1 ? $page . ($index - 1) : $first;
            echo "\" title=\"", i18n_r('news_manager/PREV_TITLE'), '">', i18n_r('news_manager/PREV_TEXT'), "</a></{$item}>", PHP_EOL;
        } else {
            if ($showalways) {
                echo " <{$item}", nm_class_attr($clprev . ' ' . $cldisabled), "><span>", i18n_r('news_manager/PREV_TEXT'), "</span></{$item}>", PHP_EOL;
            }
        }
        if (nm_get_option('navnumber', true)) {
            for ($i = 0; $i < $total; $i++) {
                if ($i + $p1 == $index) {
                    echo " <{$item}", nm_class_attr($clcurrent), "><span>", $i + 1, "</span></{$item}>", PHP_EOL;
                } else {
                    echo " <{$item}><a href=\"";
                    echo $i == 0 ? $first : $page . ($i + $p1);
                    echo "\">", $i + 1, "</a></{$item}>", PHP_EOL;
                }
            }
        }
        if ($prevnext && $index < $total - 1 + $p1) {
            echo " <{$item}", nm_class_attr($clnext), "><a href=\"", $page . ($index + 1);
            echo "\" title=\"", i18n_r('news_manager/NEXT_TITLE'), "\">", i18n_r('news_manager/NEXT_TEXT'), "</a></{$item}>", PHP_EOL;
        } else {
            if ($showalways) {
                echo " <{$item}", nm_class_attr($clnext . ' ' . $cldisabled), "><span>", i18n_r('news_manager/NEXT_TEXT'), "</span></{$item}>", PHP_EOL;
            }
        }
    } else {
        # Older/Newer navigation
        $clold = nm_clean_classes(nm_get_option('classnavitemold', 'left'));
        $clnew = nm_clean_classes(nm_get_option('classnavitemnew', 'right'));
        $showalways = strtolower(substr(nm_get_option('navoldnew'), 0, 1)) == 'a';
        // navOldNew a[lways]
        if ($index < $total - 1 + $p1) {
            echo "<{$item}", nm_class_attr($clold), ">";
            echo "<a href=\"", $page . ($index + 1), "\">", i18n_r('news_manager/OLDER_POSTS'), "</a>";
            echo "</{$item}>", PHP_EOL;
        } else {
            if ($showalways) {
                echo " <{$item}", nm_class_attr($clold . ' ' . $cldisabled), "><span>", i18n_r('news_manager/OLDER_POSTS'), "</span></{$item}>", PHP_EOL;
            }
        }
        if ($index > $p1) {
            echo "<{$item}", nm_class_attr($clnew), ">";
            echo "<a href=\"", $index > $p1 + 1 ? $page . ($index - 1) : $first, "\">", i18n_r('news_manager/NEWER_POSTS'), "</a>";
            echo "</{$item}>", PHP_EOL;
        } else {
            if ($showalways) {
                echo " <{$item}", nm_class_attr($clnew . ' ' . $cldisabled), "><span>", i18n_r('news_manager/NEWER_POSTS'), "</span></{$item}>", PHP_EOL;
            }
        }
    }
    echo "</{$nav}>", PHP_EOL;
    if ($container) {
        echo "</{$container}>", PHP_EOL;
    }
}
Beispiel #5
0
function nm_update_sitemap_xml($xml)
{
    if (!defined('NMNOSITEMAP') || !NMNOSITEMAP) {
        $posts = nm_get_posts();
        $tags = array();
        $excludetags = defined('NMSITEMAPEXCLUDETAGS') && (NMSITEMAPEXCLUDETAGS === true || NMSITEMAPEXCLUDETAGS === 1);
        foreach ($posts as $post) {
            $url = nm_get_url('post') . $post->slug;
            $file = NMPOSTPATH . $post->slug . '.xml';
            $date = makeIso8601TimeStamp(date('Y-m-d H:i:s', strtotime($post->date)));
            $item = $xml->addChild('url');
            $item->addChild('loc', $url);
            $item->addChild('lastmod', $date);
            $item->addChild('changefreq', 'monthly');
            $item->addChild('priority', '0.5');
            if (!$excludetags && !empty($post->tags)) {
                foreach (explode(',', nm_lowercase_tags(strip_decode($post->tags))) as $tag) {
                    if (substr($tag, 0, 1) != '_') {
                        if (!in_array($tag, $tags)) {
                            $url = nm_get_url('tag') . rawurlencode($tag);
                            $item = $xml->addChild('url');
                            $item->addChild('loc', $url);
                            $item->addChild('lastmod', $date);
                            $item->addChild('changefreq', 'monthly');
                            $item->addChild('priority', '0.5');
                            $tags[] = $tag;
                        }
                    }
                }
            }
        }
    }
    return $xml;
}
function nm_custom_display_posts($templ = '', $tag = '', $type = '')
{
    global $NMRECENTPOSTS, $NMCUSTOMIMAGES, $NMCUSTOMOFFSET;
    if ($templ == '') {
        $templ = '<p><a href="{{ post_link }}">{{ post_title }}</a> {{ post_date }}</p>' . PHP_EOL;
    }
    foreach (array('post_link', 'post_slug', 'post_title', 'post_date', 'post_excerpt', 'post_content', 'post_number', 'post_image', 'post_image_url', 'post_author') as $token) {
        if (strpos($templ, '{{' . $token . '}}')) {
            $templ = str_replace('{{' . $token . '}}', '{{ ' . $token . ' }}', $templ);
        }
    }
    if ($type == 'future') {
        $posts = array_reverse(nm_get_posts(true));
        $allposts = array();
        $now = time();
        foreach ($posts as $post) {
            if ($post->private != 'Y' && strtotime($post->date) > $now) {
                $allposts[] = $post;
            }
        }
    } else {
        $allposts = nm_get_posts();
    }
    if (trim($tag) !== '') {
        $posts = array();
        foreach ($allposts as $post) {
            if (in_array($tag, explode(',', $post->tags))) {
                $posts[] = $post;
            }
        }
    } else {
        $posts = $allposts;
    }
    unset($allposts);
    if (!empty($posts)) {
        ob_start();
        // content filter
        if (strpos($templ, '{{ post_date }}') !== false) {
            global $NMCUSTOMDATE;
            $fmt = $NMCUSTOMDATE ? $NMCUSTOMDATE : i18n_r('news_manager/DATE_FORMAT');
        } else {
            $fmt = false;
        }
        $w = isset($NMCUSTOMIMAGES['width']) ? $NMCUSTOMIMAGES['width'] : 0;
        $h = isset($NMCUSTOMIMAGES['height']) ? $NMCUSTOMIMAGES['height'] : 0;
        $c = isset($NMCUSTOMIMAGES['crop']) ? $NMCUSTOMIMAGES['crop'] : 0;
        $d = isset($NMCUSTOMIMAGES['default']) ? $NMCUSTOMIMAGES['default'] : '';
        $count = 0;
        $offset = $NMCUSTOMOFFSET ? intval($NMCUSTOMOFFSET) : 0;
        $posts = array_slice($posts, $offset, $NMRECENTPOSTS, true);
        foreach ($posts as $post) {
            $str = $templ;
            $str = str_replace('{{ post_number }}', strval($count), $str);
            $str = str_replace('{{ post_slug }}', $post->slug, $str);
            $str = str_replace('{{ post_link }}', nm_get_url('post') . $post->slug, $str);
            $str = str_replace('{{ post_title }}', stripslashes($post->title), $str);
            if (strpos($str, '{{ post_image') !== false && function_exists('nm_get_image_url')) {
                $img = htmlspecialchars(nm_get_image_url((string) $post->image, $w, $h, $c, $d));
                $str = str_replace('{{ post_image_url }}', $img, $str);
                if (!empty($img)) {
                    $str = str_replace('{{ post_image }}', '<img src="' . $img . '" alt="" />', $str);
                } else {
                    $str = str_replace('{{ post_image }}', '', $str);
                }
            }
            if ($fmt) {
                $date = nm_get_date($fmt, strtotime($post->date));
                $str = str_replace('{{ post_date }}', $date, $str);
            }
            if (strpos($str, '{{ post_author }}') !== false) {
                if (isset($post->author)) {
                    $author = strval($post->author);
                    global $NMAUTHOR;
                    // NM Custom Authors (array)
                    if ($NMAUTHOR && isset($NMAUTHOR[$author])) {
                        $author = $NMAUTHOR[$author];
                    }
                } else {
                    if (function_exists('nm_get_option')) {
                        $author = nm_get_option('defaultauthor');
                        // NM 3.0+ custom setting
                        if (!$author) {
                            $author = '';
                        }
                    } else {
                        $author = '';
                    }
                }
                $str = str_replace('{{ post_author }}', $author, $str);
            }
            if (strpos($str, '{{ post_excerpt }}') !== false || strpos($str, '{{ post_content }}') !== false) {
                $postxml = getXML(NMPOSTPATH . $post->slug . '.xml');
                if (strpos($str, '{{ post_excerpt }}') !== false) {
                    if (function_exists('nm_make_excerpt1')) {
                        $excerpt = nm_make_excerpt(strip_decode($postxml->content));
                    } else {
                        // NM < 3.0 - remove <p>, </p>
                        $excerpt = substr(nm_create_excerpt(strip_decode($postxml->content)), 3, -4);
                    }
                    $str = str_replace('{{ post_excerpt }}', $excerpt, $str);
                } else {
                    $str = str_replace('{{ post_content }}', strip_decode($postxml->content), $str);
                }
            }
            echo $str;
            $count++;
        }
        $output = ob_get_contents();
        ob_end_clean();
        echo exec_filter('content', $output);
        // content filter
    }
}