function introspect_config_item($name, &$propbag)
 {
     switch ($name) {
         case 'beginningOfWeek':
             $options = array();
             for ($i = 1; $i <= 7; $i++) {
                 $options[] = serendipity_formatTime('%A', mktime(0, 0, 0, 3, $i - 1, 2004));
             }
             $propbag->add('type', 'select');
             $propbag->add('select_values', $options);
             $propbag->add('name', CALENDAR_BEGINNING_OF_WEEK);
             $propbag->add('description', CALENDAR_BOW_DESC);
             $propbag->add('default', 1);
             break;
         case 'enableExtEvents':
             $propbag->add('type', 'boolean');
             $propbag->add('name', CALENDAR_ENABLE_EXTERNAL_EVENTS);
             $propbag->add('description', CALENDAR_EXTEVENT_DESC);
             $propbag->add('default', false);
             break;
             // Event Calendar: Support category!
         // Event Calendar: Support category!
         case 'category':
             $categories = array('all' => ALL_CATEGORIES);
             $cats = serendipity_fetchCategories();
             if (is_array($cats)) {
                 $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
                 foreach ($cats as $cat) {
                     $categories[$cat['categoryid']] = str_repeat(' . ', $cat['depth']) . $cat['category_name'];
                 }
             }
             $propbag->add('type', 'select');
             $propbag->add('name', CATEGORIES_PARENT_BASE);
             $propbag->add('description', CATEGORIES_PARENT_BASE_DESC);
             $propbag->add('select_values', $categories);
             $propbag->add('default', 'all');
             break;
         default:
             return false;
     }
     return true;
 }
function serveArchives()
{
    global $serendipity;
    $serendipity['view'] = 'archives';
    $_args = locateHiddenVariables($serendipity['uriArguments']);
    /* We must always *assume* that Year, Month and Day are the first 3 arguments */
    list(, $year, $month, $day) = $_args;
    if ($year == "archives") {
        unset($year);
    }
    $serendipity['GET']['action'] = 'read';
    $serendipity['GET']['hidefooter'] = true;
    if (!isset($year)) {
        $year = date('Y');
        $month = date('m');
        $day = date('j');
        $serendipity['GET']['action'] = null;
        $serendipity['GET']['hidefooter'] = null;
    }
    if (isset($year) && !is_numeric($year)) {
        $year = date('Y');
    }
    if (isset($month) && !is_numeric($month)) {
        $month = date('m');
    }
    if (isset($day) && !is_numeric($day)) {
        $day = date('d');
    }
    switch ($serendipity['calendar']) {
        case 'gregorian':
        default:
            $gday = 1;
            if ($week) {
                $tm = strtotime('+ ' . ($week - 2) . ' WEEKS monday', mktime(0, 0, 0, 1, 1, $year));
                $ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year);
                $te = mktime(23, 59, 59, date('m', $tm), date('j', $tm) + 7, $year);
                $date = serendipity_formatTime(WEEK . ' ' . $week . ', %Y', $ts, false);
            } else {
                if ($day) {
                    $ts = mktime(0, 0, 0, $month, $day, $year);
                    $te = mktime(23, 59, 59, $month, $day, $year);
                    $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false);
                } else {
                    $ts = mktime(0, 0, 0, $month, $gday, $year);
                    if (!isset($gday2)) {
                        $gday2 = date('t', $ts);
                    }
                    $te = mktime(23, 59, 59, $month, $gday2, $year);
                    $date = serendipity_formatTime('%B %Y', $ts, false);
                }
            }
            break;
        case 'persian-utf8':
            require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
            $gday = 1;
            if ($week) {
                --$week;
                $week *= 7;
                ++$week;
                $day = $week;
                // convert day number of year to day number of month AND month number of year
                $j_days_in_month = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
                if ($g_y % 4 == 3) {
                    $j_days_in_month[12]++;
                }
                for ($i = 1; isset($j_days_in_month[$i]); ++$i) {
                    if ($day - $j_days_in_month[$i] > 0) {
                        $day -= $j_days_in_month[$i];
                    } else {
                        break;
                    }
                }
                $tm = persian_mktime(0, 0, 0, $i, $day, $year);
                $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $tm), persian_date_utf('j', $tm), $year);
                $te = persian_mktime(23, 59, 59, persian_date_utf('m', $tm), persian_date_utf('j', $tm) + 7, $year);
                $date = serendipity_formatTime(WEEK . ' ' . $week . '، %Y', $ts, false);
            } else {
                if ($day) {
                    $ts = persian_mktime(0, 0, 0, $month, $day, $year);
                    $te = persian_mktime(23, 59, 59, $month, $day, $year);
                    $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false);
                } else {
                    $ts = persian_mktime(0, 0, 0, $month, $gday, $year);
                    if (!isset($gday2)) {
                        $gday2 = persian_date_utf('t', $ts);
                    }
                    $te = persian_mktime(23, 59, 59, $month, $gday2, $year);
                    $date = serendipity_formatTime('%B %Y', $ts, false);
                }
            }
            list($year, $month, $day) = p2g($year, $month, $day);
            break;
    }
    $serendipity['range'] = array($ts, $te);
    if ($serendipity['GET']['action'] == 'read') {
        if ($serendipity['GET']['category']) {
            $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']);
            $serendipity['head_title'] = $cInfo['category_name'];
        }
        $serendipity['head_subtitle'] .= sprintf(ENTRIES_FOR, $date);
    }
    include S9Y_INCLUDE_PATH . 'include/genpage.inc.php';
}
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $ts = mktime(0, 0, 0, date('m'), 1);
     $add_query = '';
     $category_set = isset($serendipity['GET']['category']);
     if ($category_set) {
         $base_query = 'C' . (int) $serendipity['GET']['category'];
         $add_query = '/' . $base_query;
     }
     $max_x = $this->get_config('count', 3);
     $show_count = serendipity_db_bool($this->get_config('show_count', false));
     $hide_zero_count = serendipity_db_bool($this->get_config('hide_zero_count', false));
     $freq = $this->get_config('frequency', 'months');
     echo '<ul class="plainList">' . "\n";
     if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'sqlite3oo') {
         $dist_sql = 'count(e.id) AS orderkey';
     } else {
         $dist_sql = 'count(DISTINCT e.id) AS orderkey';
     }
     for ($x = 0; $x < $max_x; $x++) {
         $current_ts = $ts;
         switch ($freq) {
             case 'months':
                 switch ($serendipity['calendar']) {
                     default:
                     case 'gregorian':
                         $linkStamp = date('Y/m', $ts);
                         $ts_title = serendipity_formatTime("%B %Y", $ts, false);
                         $ts = mktime(0, 0, 0, date('m', $ts) - 1, 1, date('Y', $ts));
                         // Must be last in 'case' statement
                         break;
                     case 'persian-utf8':
                         require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
                         $linkStamp = persian_date_utf('Y/m', $ts);
                         $ts_title = serendipity_formatTime("%B %Y", $ts, false);
                         $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts) - 1, 1, persian_date_utf('Y', $ts));
                         // Must be last in 'case' statement
                         break;
                 }
                 break;
             case 'weeks':
                 switch ($serendipity['calendar']) {
                     default:
                     case 'gregorian':
                         $linkStamp = date('Y/\\WW', $ts);
                         $ts_title = WEEK . ' ' . date('W, Y', $ts);
                         $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts) - 7, date('Y', $ts));
                         break;
                     case 'persian-utf8':
                         require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
                         $linkStamp = persian_date_utf('Y/\\WW', $ts);
                         $ts_title = WEEK . ' ' . persian_date_utf('W، Y', $ts);
                         $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts), persian_date_utf('d', $ts) - 7, persian_date_utf('Y', $ts));
                         break;
                 }
                 break;
             case 'days':
                 switch ($serendipity['calendar']) {
                     default:
                     case 'gregorian':
                         $linkStamp = date('Y/m/d', $ts);
                         $ts_title = serendipity_formatTime("%B %e. %Y", $ts, false);
                         $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts) - 1, date('Y', $ts));
                         // Must be last in 'case' statement
                         break;
                     case 'persian-utf8':
                         require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
                         $linkStamp = persian_date_utf('Y/m/d', $ts);
                         $ts_title = serendipity_formatTime("%e %B %Y", $ts, false);
                         $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts), persian_date_utf('d', $ts) - 1, persian_date_utf('Y', $ts));
                         // Must be last in 'case' statement
                         break;
                 }
                 break;
         }
         $link = serendipity_rewriteURL(PATH_ARCHIVES . '/' . $linkStamp . $add_query . '.html', 'serendipityHTTPPath');
         $html_count = '';
         $hidden_by_zero_count = false;
         if ($show_count) {
             switch ($freq) {
                 case 'months':
                     $end_ts = $current_ts + date('t', $current_ts) * 24 * 60 * 60 - 1;
                     break;
                 case 'weeks':
                     $end_ts = $current_ts + 7 * 24 * 60 * 60 - 1;
                     break;
                 case 'days':
                     $end_ts = $current_ts + 24 * 60 * 60 - 1;
                     break;
             }
             $ec = serendipity_fetchEntries(array($current_ts, $end_ts), false, '', false, false, null, '', false, true, $dist_sql, '', 'single', false, $category_set);
             if (is_array($ec)) {
                 if (empty($ec['orderkey'])) {
                     $ec['orderkey'] = '0';
                 }
                 $hidden_by_zero_count = $hide_zero_count && $ec['orderkey'] == '0';
                 $html_count .= ' (' . $ec['orderkey'] . ')';
             }
         }
         if (!$hidden_by_zero_count) {
             echo '<li><a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . $html_count . '</a></li>' . "\n";
         }
     }
     echo '<li><a href="' . $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?frontpage">' . RECENT . '</a></li>' . "\n";
     echo '<li><a href="' . serendipity_rewriteURL(PATH_ARCHIVE . $add_query) . '">' . OLDER . '</a></li>' . "\n";
     echo '</ul>' . "\n";
 }
 function generate_content(&$title)
 {
     global $serendipity;
     $number = $this->get_config('number');
     $displaydate = $this->get_config('displaydate', 'true');
     $dateformat = $this->get_config('dateformat');
     $sidebartitle = $title = $this->get_config('sidebartitle', $this->title);
     $rssuri = $this->get_config('rssuri');
     $target = $this->get_config('target');
     $cachetime = $this->get_config('cachetime');
     $feedtype = $this->get_config('feedtype', 'rss');
     $markup = $this->get_config('markup', 'false');
     $bulletimg = $this->get_config('bulletimg');
     $charset = $this->get_config('charset', 'native');
     if (!$number || !is_numeric($number) || $number < 1) {
         $showAll = true;
     } else {
         $showAll = false;
     }
     if (!$dateformat || strlen($dateformat) < 1) {
         $dateformat = '%A, %B %e. %Y';
     }
     if (!$cachetime || !is_numeric($cachetime)) {
         $cachetime = 10800;
         // 3 hours in seconds
     }
     $smarty = serendipity_db_bool($this->get_config('smarty'));
     if ($this->get_config('template') != 'plugin_remoterss.tpl') {
         $smarty = true;
     }
     if (trim($rssuri)) {
         $feedcache = $serendipity['serendipityPath'] . 'templates_c/remoterss_cache_' . md5(preg_replace('@[^a-z0-9]*@i', '', $rssuri) . $this->get_config('template')) . '.dat';
         if (!file_exists($feedcache) || filesize($feedcache) == 0 || filemtime($feedcache) < time() - $cachetime) {
             $this->debug('Cachefile does not existing.');
             if (!$this->urlcheck($rssuri)) {
                 $this->debug('URLCheck failed');
                 echo '<!-- No valid URL! -->';
             } elseif ($feedtype == 'rss') {
                 $this->debug('URLCheck succeeded. Touching ' . $feedcache);
                 // Touching the feedcache file will prevent loops of death when the RSS target is the same URI than our blog.
                 @touch($feedcache);
                 require_once S9Y_PEAR_PATH . 'Onyx/RSS.php';
                 $c = new Onyx_RSS($charset);
                 $this->debug('Running Onyx Parser');
                 $c->parse($rssuri);
                 $this->encoding = $c->rss['encoding'];
                 $use_rss_link = serendipity_db_bool($this->get_config('use_rss_link'));
                 $rss_elements = explode(',', $this->get_config('show_rss_element'));
                 $escape_rss = serendipity_db_bool($this->get_config('escape_rss'));
                 $i = 0;
                 $content = '';
                 $smarty_items = array();
                 while (($showAll || $i < $number) && ($item = $c->getNextItem())) {
                     if (empty($item['title'])) {
                         continue;
                     }
                     $content .= '<div class="rss_item">';
                     if ($use_rss_link) {
                         $content .= '<div class="rss_link"><a href="' . serendipity_specialchars($this->decode($item['link'])) . '" ' . (!empty($target) ? 'target="' . $target . '"' : '') . '>';
                     }
                     if (!empty($bulletimg)) {
                         $content .= '<img src="' . $bulletimg . '" border="0" alt="*" /> ';
                     }
                     $is_first = true;
                     foreach ($rss_elements as $rss_element) {
                         $rss_element = trim($rss_element);
                         if (!$is_first) {
                             $content .= '<span class="rss_' . preg_replace('@[^a-z0-9]@imsU', '', $rss_element) . '">';
                         }
                         if ($escape_rss) {
                             $content .= $this->decode($item[$rss_element]);
                         } else {
                             $content .= serendipity_specialchars($this->decode($item[$rss_element]));
                         }
                         if ($smarty) {
                             $item['display_elements'][preg_replace('@[^a-z0-9]@imsU', '', $rss_element)] = $this->decode($item[$rss_element]);
                         }
                         if (!$is_first) {
                             $content .= '</span>';
                         }
                         if ($is_first && $use_rss_link) {
                             $content .= '</a></div>';
                             // end of first linked element
                         }
                         $is_first = false;
                     }
                     if ($is_first && $use_rss_link) {
                         // No XML element has been configured.
                         $content .= '</a></div>';
                     }
                     $content .= "<br />\n";
                     $item['timestamp'] = @strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']);
                     if (!($item['timestamp'] == -1) and $displaydate == 'true') {
                         $content .= '<div class="serendipitySideBarDate">' . serendipity_specialchars(serendipity_formatTime($dateformat, $item['timestamp'], false)) . '</div>';
                     }
                     if ($smarty) {
                         $smarty_items['items'][$i] = $item;
                         $smarty_items['items'][$i]['css_class'] = preg_replace('@[^a-z0-9]@imsU', '', $rss_element);
                         foreach ($item as $key => $val) {
                             $smarty_items['items'][$i]['decoded_' . str_replace(':', '_', $key)] = $this->decode($key);
                         }
                     }
                     $content .= '</div>';
                     // end of rss_item
                     ++$i;
                 }
                 if ($smarty) {
                     $smarty_items['use_rss_link'] = $use_rss_link;
                     $smarty_items['bulletimg'] = $bulletimg;
                     $smarty_items['escape_rss'] = $escape_rss;
                     $smarty_items['displaydate'] = $displaydate;
                     $smarty_items['dateformat'] = $dateformat;
                     $smarty_items['target'] = $target;
                     $serendipity['smarty']->assign_by_ref('remoterss_items', $smarty_items);
                     $tpl = $this->get_config('template');
                     if (empty($tpl)) {
                         $tpl = 'plugin_remoterss.tpl';
                     }
                     // Template specifics go here
                     switch ($tpl) {
                         case 'plugin_remoterss_nasaiotd.tpl':
                             $smarty_items['nasa_image'] = $c->getData('image');
                             break;
                     }
                     $content = $this->parseTemplate($tpl);
                 }
                 $this->debug('Caching Feed (' . strlen($content) . ' bytes)');
                 $fp = @fopen($feedcache, 'w');
                 if (trim($content) != '' && $fp) {
                     fwrite($fp, $content);
                     fclose($fp);
                     $this->debug('Feed cache written');
                 } else {
                     $this->debug('Could not write (empty?) cache.');
                     echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />';
                     if (trim($content) == '') {
                         $this->debug('Getting old feedcache');
                         $content = @file_get_contents($feedcache);
                     }
                 }
                 $this->debug('RSS Plugin finished.');
             } elseif ($feedtype == 'atom') {
                 $this->debug('URLCheck succeeded. Touching ' . $feedcache);
                 // Touching the feedcache file will prevent loops of death when the RSS target is the same URI than our blog.
                 @touch($feedcache);
                 require_once S9Y_PEAR_PATH . '/simplepie/simplepie.inc';
                 $this->debug('Running simplepie Parser');
                 $simplefeed = new SimplePie();
                 $simplefeed->cache = false;
                 $simplefeed->set_feed_url($rssuri);
                 $success = $simplefeed->init();
                 $simplefeed->set_output_encoding($charset);
                 $simplefeed->handle_content_type();
                 $this->encoding = $charset;
                 $use_rss_link = serendipity_db_bool($this->get_config('use_rss_link'));
                 $rss_elements = explode(',', $this->get_config('show_rss_element'));
                 $escape_rss = serendipity_db_bool($this->get_config('escape_rss'));
                 $i = 0;
                 $content = '';
                 $smarty_items = array();
                 foreach ($simplefeed->get_items() as $simpleitem) {
                     // map SimplePie items to s9y items
                     $item['title'] = $simpleitem->get_title();
                     $item['link'] = $simpleitem->get_permalink();
                     $item['pubdate'] = $simpleitem->get_date('U');
                     $item['date'] = $simpleitem->get_date('U');
                     $item['description'] = $simpleitem->get_description();
                     $item['content'] = $simpleitem->get_content();
                     $item['author'] = $simpleitem->get_author();
                     if (!$showAll && $i > $number) {
                         break;
                     }
                     if (empty($item['title'])) {
                         continue;
                     }
                     $content .= '<div class="rss_item">';
                     if ($use_rss_link) {
                         $content .= '<div class="rss_link"><a href="' . serendipity_specialchars($this->decode($item['link'])) . '" ' . (!empty($target) ? 'target="' . $target . '"' : '') . '>';
                     }
                     if (!empty($bulletimg)) {
                         $content .= '<img src="' . $bulletimg . '" border="0" alt="*" /> ';
                     }
                     $is_first = true;
                     foreach ($rss_elements as $rss_element) {
                         $rss_element = trim($rss_element);
                         if (!$is_first) {
                             $content .= '<span class="rss_' . preg_replace('@[^a-z0-9]@imsU', '', $rss_element) . '">';
                         }
                         if ($escape_rss) {
                             $content .= $this->decode($item[$rss_element]);
                         } else {
                             $content .= serendipity_specialchars($this->decode($item[$rss_element]));
                         }
                         if ($smarty) {
                             $item['display_elements'][preg_replace('@[^a-z0-9]@imsU', '', $rss_element)] = $this->decode($item[$rss_element]);
                         }
                         if (!$is_first) {
                             $content .= '</span>';
                         }
                         if ($is_first && $use_rss_link) {
                             $content .= '</a></div>';
                             // end of first linked element
                         }
                         $is_first = false;
                     }
                     if ($is_first && $use_rss_link) {
                         // No XML element has been configured.
                         $content .= '</a></div>';
                     }
                     $content .= "<br />\n";
                     $item['timestamp'] = @strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']);
                     if (!($item['timestamp'] == -1) and $displaydate == 'true') {
                         $content .= '<div class="serendipitySideBarDate">' . serendipity_specialchars(serendipity_formatTime($dateformat, $item['timestamp'], false)) . '</div>';
                     }
                     if ($smarty) {
                         $smarty_items['items'][$i] = $item;
                         $smarty_items['items'][$i]['css_class'] = preg_replace('@[^a-z0-9]@imsU', '', $rss_element);
                         foreach ($item as $key => $val) {
                             $smarty_items['items'][$i]['decoded_' . str_replace(':', '_', $key)] = $this->decode($key);
                         }
                     }
                     $content .= '</div>';
                     // end of rss_item
                     ++$i;
                 }
                 if ($smarty) {
                     $smarty_items['use_rss_link'] = $use_rss_link;
                     $smarty_items['bulletimg'] = $bulletimg;
                     $smarty_items['escape_rss'] = $escape_rss;
                     $smarty_items['displaydate'] = $displaydate;
                     $smarty_items['dateformat'] = $dateformat;
                     $smarty_items['target'] = $target;
                     $serendipity['smarty']->assign_by_ref('remoterss_items', $smarty_items);
                     $tpl = $this->get_config('template');
                     if (empty($tpl)) {
                         $tpl = 'plugin_remoterss.tpl';
                     }
                     // Template specifics go here
                     switch ($tpl) {
                         case 'plugin_remoterss_nasaiotd.tpl':
                             $smarty_items['nasa_image'] = $c->getData('image');
                             break;
                     }
                     $content = $this->parseTemplate($tpl);
                 }
                 $this->debug('Caching Feed (' . strlen($content) . ' bytes)');
                 $fp = @fopen($feedcache, 'w');
                 if (trim($content) != '' && $fp) {
                     fwrite($fp, $content);
                     fclose($fp);
                     $this->debug('Feed cache written');
                 } else {
                     $this->debug('Could not write (empty?) cache.');
                     echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />';
                     if (trim($content) == '') {
                         $this->debug('Getting old feedcache');
                         $content = @file_get_contents($feedcache);
                     }
                 }
                 $this->debug('RSS Plugin (Atom) finished.');
             } elseif ($feedtype == 'opml') {
                 // Touching the feedcache file will prevent loops of death when the RSS target is the same URI than our blog.
                 @touch($feedcache);
                 $opml = new s9y_remoterss_OPML();
                 $opmltree = $opml->parseOPML($rssuri);
                 if (OPMLDEBUG == 1) {
                     echo "\n<pre>\n";
                     print_r($opmltree);
                     echo "\n</pre>\n";
                 }
                 if ($opmltree['tag'] === 'opml') {
                     $head = $opml->getOPMLHead($opmltree);
                     $ownerName = $opml->getOPMLTag($head, 'ownerName');
                     $blogrolling = $ownerName != false ? $ownerName['value'] == 'Blogroll Owner' ? true : false : false;
                     $i = 0;
                     $content = '';
                     while (($showAll || $i < $number) && ($item = $opml->getOPMLOutlineAttr($opmltree, $i))) {
                         if (!empty($item['url'])) {
                             $url = $this->decode($item['url']);
                         } elseif (!empty($item['htmlUrl'])) {
                             $url = $this->decode($item['htmlUrl']);
                         } elseif (!empty($item['xmlUrl'])) {
                             $url = $this->decode($item['xmlUrl']);
                         } elseif (!empty($item['urlHTTP'])) {
                             $url = $this->decode($item['urlHTTP']);
                         } else {
                             $url = '';
                         }
                         if (!empty($item['text'])) {
                             $text = serendipity_specialchars($this->decode($item['text']));
                         } elseif (!empty($item['title'])) {
                             $text = serendipity_specialchars($this->decode($item['title']));
                         } elseif (!empty($item['description'])) {
                             $text = serendipity_specialchars($this->decode($item['description']));
                         } else {
                             $text = '';
                         }
                         if ($blogrolling === true && (!empty($text) || !empty($url))) {
                             $content .= '&bull; <a href="' . serendipity_specialchars($url) . '" ' . (!empty($target) ? 'target="' . $target . '"' : '') . ' title="' . $text . '">' . $text . "</a>";
                             if (isset($item['isRecent'])) {
                                 $content .= ' <span style="color: Red; ">*</span>';
                             }
                             $content .= "<br />";
                         } elseif (isset($item['type']) && $item['type'] == 'url' || !empty($url)) {
                             $content .= '&bull; <a href="' . serendipity_specialchars($url) . '" ' . (!empty($target) ? 'target="' . $target . '"' : '') . ' title="' . $text . '">' . $text . "</a>";
                             $content .= "<br />";
                         }
                         ++$i;
                     }
                     /* Pretend to be a html_nugget so we can apply markup events. */
                     if ($markup == 'true') {
                         $entry = array('html_nugget' => $content);
                         serendipity_plugin_api::hook_event('frontend_display', $entry);
                         $content = $entry['html_nugget'];
                     }
                     $fp = @fopen($feedcache, 'w');
                     if (trim($content) != '' && $fp) {
                         fwrite($fp, $content);
                         fclose($fp);
                     } else {
                         echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />';
                         if (trim($content) == '') {
                             $content = @file_get_contents($feedcache);
                         }
                     }
                 } else {
                     echo '<!-- Not a valid OPML feed -->';
                 }
             } else {
                 echo '<!-- no valid feedtype -->';
             }
         } else {
             $this->debug('Got feed from cache ' . $feedcache);
             $content = file_get_contents($feedcache);
         }
         echo $content;
     } else {
         echo PLUGIN_REMOTERSS_NOURI;
     }
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'backend_image_addform':
                    if ($serendipity['version'][0] < 2) {
                        if (class_exists('ZipArchive')) {
                            $checkedY = "";
                            $checkedN = "";
                            $this->get_config('unzipping') ? $checkedY = ' checked="checked"' : ($checkedN = ' checked="checked"');
                            ?>
            <br />
            <div>
                <strong><?php 
                            echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES;
                            ?>
</strong><br />
                <?php 
                            echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC;
                            ?>
                <div>
                    <input type="radio" class="input_radio" id="unzip_yes" name="serendipity[unzip_archives]" value="<?php 
                            echo YES;
                            ?>
"<?php 
                            echo $checkedY;
                            ?>
><label for="unzip_yes"><?php 
                            echo YES;
                            ?>
</label>
                    <input type="radio" class="input_radio" id="unzip_no" name="serendipity[unzip_archives]" value="<?php 
                            echo NO;
                            ?>
"<?php 
                            echo $checkedN;
                            ?>
><label for="unzip_no"><?php 
                            echo NO;
                            ?>
</label>
                </div>
            </div>
<?php 
                        }
                        ?>
            <br />
            <strong><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG;
                        ?>
:</strong><br />
            <em><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC;
                        ?>
</em>
            <table id="quickblog_table" style="width: 50%">
                <tr>
                    <td nowrap="nowrap"><?php 
                        echo TITLE;
                        ?>
</td>
                    <td><input class="input_textbox" name="serendipity[quickblog][title]" type="text" style="width: 90%" /></td>
                </tr>

                <tr>
                    <td nowrap="nowrap"><?php 
                        echo ENTRY_BODY;
                        ?>
</td>
                    <td><textarea name="serendipity[quickblog][body]" style="width: 90%; height: 200px"></textarea></td>
                </tr>

                <tr>
                    <td nowrap="nowrap"><?php 
                        echo CATEGORY;
                        ?>
</td>
                    <td><select name="serendipity[quickblog][category]">
                        <option value=""><?php 
                        echo NO_CATEGORY;
                        ?>
</option>
                    <?php 
                        if (is_array($cats = serendipity_fetchCategories())) {
                            $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
                            foreach ($cats as $cat) {
                                echo '<option value="' . $cat['categoryid'] . '">' . str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] . '</option>' . "\n";
                            }
                        }
                        ?>
                    </select></td>
                </tr>

                <tr>
                    <td nowrap="nowrap"><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET;
                        ?>
</td>
                    <td><select id="select_image_target" name="serendipity[quickblog][target]">
                        <option value="none"<?php 
                        echo serendipity_ifRemember('target', 'none', false, 'selected');
                        ?>
><?php 
                        echo NONE;
                        ?>
</option>
                        <option value="js"<?php 
                        echo serendipity_ifRemember('target', 'js', false, 'selected');
                        ?>
><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_JS;
                        ?>
</option>
                        <option value="plugin"<?php 
                        echo serendipity_ifRemember('target', 'plugin', false, 'selected');
                        ?>
><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_ENTRY;
                        ?>
</option>
                        <option value="_blank"<?php 
                        echo serendipity_ifRemember('target', '_blank', false, 'selected');
                        ?>
><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET_BLANK;
                        ?>
</option>
                    </select></td>
                </tr>

                <tr>
                    <td nowrap="nowrap"><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT;
                        ?>
</td>
                    <td>
                        <input type="radio" class="input_radio" id="image_yes" name="serendipity[quickblog][isobject]" value="<?php 
                        echo YES;
                        ?>
"><label for="image_yes"><?php 
                        echo YES;
                        ?>
</label>
                        <input type="radio" class="input_radio" id="image_no" name="serendipity[quickblog][isobject]" value="<?php 
                        echo NO;
                        ?>
" checked="checked"><label for="image_no"><?php 
                        echo NO;
                        ?>
</label>
                    </td>
                </tr>

                <tr>
                    <td nowrap="nowrap"><?php 
                        echo IMAGE_SIZE;
                        ?>
</td>
                    <td><input class="input_textbox" name="serendipity[quickblog][size]" value="<?php 
                        echo $serendipity['thumbSize'];
                        ?>
" type="text" style="width: 50px" /></td>
                </tr>

                <tr>
                    <td align="center" colspan="2"><br /></td>
                </tr>
            </table>
            <div>
                <em><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC;
                        ?>
</em>
            </div>
<?php 
                    } else {
                        ?>

        <div id="imageselectorplus">

<?php 
                        if (class_exists('ZipArchive')) {
                            $checkedY = "";
                            $checkedN = "";
                            $this->get_config('unzipping') ? $checkedY = ' checked="checked"' : ($checkedN = ' checked="checked"');
                            ?>
            <div class="clearfix radio_field">
                <h4><?php 
                            echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES;
                            ?>
</h4>
                <?php 
                            echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FILES_DESC;
                            ?>
                <div>
                    <input type="radio" class="input_radio" id="unzip_yes" name="serendipity[unzip_archives]" value="<?php 
                            echo YES;
                            ?>
"<?php 
                            echo $checkedY;
                            ?>
><label for="unzip_yes"><?php 
                            echo YES;
                            ?>
</label>
                    <input type="radio" class="input_radio" id="unzip_no" name="serendipity[unzip_archives]" value="<?php 
                            echo NO;
                            ?>
"<?php 
                            echo $checkedN;
                            ?>
><label for="unzip_no"><?php 
                            echo NO;
                            ?>
</label>
                </div>
            </div>
<?php 
                        }
                        ?>
            <h4><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG;
                        ?>
:</h4>
            <em><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_QUICKBLOG_DESC;
                        ?>
</em>
            <div id="quickblog_tablefield" class="clearfix">
                <div class="quickblog_form_field">
                    <label for="quickblog_titel"><?php 
                        echo TITLE;
                        ?>
</label>
                    <input id="quickblog_title" class="input_textbox" name="serendipity[quickblog][title]" type="text">
                </div>

                <div class="quickblog_textarea_field">
                    <label for="nuggets2"><?php 
                        echo ENTRY_BODY;
                        ?>
</label>
                    <textarea id="nuggets2" class="quickblog_nugget" data-tarea="nuggets2" name="serendipity[quickblog][body]" rows="10" cols="80"></textarea>
<?php 
                        if ($serendipity['wysiwyg']) {
                            $plugins = serendipity_plugin_api::enum_plugins('*', false, 'serendipity_event_nl2br');
                            ?>
                    <input name="serendipity[properties][disable_markups][]" type="hidden" value="<?php 
                            echo $plugins[0]['name'];
                            ?>
">
<?php 
                            if (!class_exists('serendipity_event_ckeditor')) {
                                ?>
                    <script src="<?php 
                                echo $serendipity['serendipityHTTPPath'];
                                ?>
htmlarea/ckeditor/ckeditor/ckeditor.js"></script>
<?php 
                            }
                            // just add a simple basic toolbar, since we cannot use embedded plugins here
                            ?>
                    <script>
                        CKEDITOR.replace( 'nuggets2',
                        {
                            toolbar : [['Format'],['Bold','Italic','Underline','Superscript','-','NumberedList','BulletedList','Outdent','Blockquote'],['JustifyBlock','JustifyCenter','JustifyRight'],['Link','Unlink'],['Source']],
                            toolbarGroups: null
                        });
                    </script>
<?php 
                        }
                        ?>
                </div>

                <div class="quickblog_form_field">
                    <label for="quickblog_select"><?php 
                        echo CATEGORY;
                        ?>
</label>
                    <select id="quickblog_select" name="serendipity[quickblog][category]">
                        <option value=""><?php 
                        echo NO_CATEGORY;
                        ?>
</option>
                    <?php 
                        if (is_array($cats = serendipity_fetchCategories())) {
                            $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
                            foreach ($cats as $cat) {
                                echo '<option value="' . $cat['categoryid'] . '">' . str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] . '</option>' . "\n";
                            }
                        }
                        ?>
                    </select>
                </div>

                <div class="quickblog_form_select">
                    <label for="select_image_target"><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_TARGET;
                        ?>
</label>
                    <select id="select_image_target" name="serendipity[quickblog][target]">
                        <option value="none"<?php 
                        echo serendipity_ifRemember('target', 'none', false, 'selected');
                        ?>
><?php 
                        echo NONE;
                        ?>
</option>
                        <option value="js"<?php 
                        echo serendipity_ifRemember('target', 'js', false, 'selected');
                        ?>
><?php 
                        echo MEDIA_TARGET_JS;
                        ?>
</option>
                        <option value="plugin"<?php 
                        echo serendipity_ifRemember('target', 'plugin', false, 'selected');
                        ?>
><?php 
                        echo MEDIA_ENTRY;
                        ?>
</option>
                        <option value="_blank"<?php 
                        echo serendipity_ifRemember('target', '_blank', false, 'selected');
                        ?>
><?php 
                        echo MEDIA_TARGET_BLANK;
                        ?>
</option>
                    </select>
                </div>

                <div class="clearfix radio_field quickblog_radio_field">
                    <label><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_ASOBJECT;
                        ?>
</label>
                    <div>
                        <input type="radio" class="input_radio" id="image_yes" name="serendipity[quickblog][isobject]" value="<?php 
                        echo YES;
                        ?>
"><label for="image_yes"><?php 
                        echo YES;
                        ?>
</label>
                        <input type="radio" class="input_radio" id="image_no" name="serendipity[quickblog][isobject]" value="<?php 
                        echo NO;
                        ?>
" checked="checked"><label for="image_no"><?php 
                        echo NO;
                        ?>
</label>
                    </div>
                </div>

                <div class="quickblog_form_field">
                    <label for="quickblog_isize"><?php 
                        echo IMAGE_SIZE;
                        ?>
</label>
                    <input id="quickblog_isize" class="input_textbox" name="serendipity[quickblog][size]" value="<?php 
                        echo $serendipity['thumbSize'];
                        ?>
" type="text">
                </div>
            </div>
            <em><?php 
                        echo PLUGIN_EVENT_IMAGESELECTORPLUS_IMAGE_SIZE_DESC;
                        ?>
</em>
        </div>
<?php 
                    }
                    break;
                case 'backend_image_add':
                    global $new_media;
                    // if file is zip archive and unzipping enabled
                    // unzip file and add all images to database
                    // retrieve file type
                    $target_zip = $eventData;
                    preg_match('@(^.*/)+(.*)\\.+(\\w*)@', $target_zip, $matches);
                    $target_dir = $matches[1];
                    $basename = $matches[2];
                    $extension = $matches[3];
                    $authorid = isset($serendipity['POST']['all_authors']) && $serendipity['POST']['all_authors'] == 'true' ? '0' : $serendipity['authorid'];
                    // only if unzipping function exists, we have archive file and unzipping set to yes
                    if (class_exists('ZipArchive') && $extension == 'zip' && $serendipity['POST']['unzip_archives'] == YES) {
                        // now unzip
                        $zip = new ZipArchive();
                        $res = $zip->open($target_zip);
                        if ($res === TRUE) {
                            $files_to_unzip = array();
                            $extracted_images = array();
                            for ($i = 0; $i < $zip->numFiles; $i++) {
                                $file_to_extract = $zip->getNameIndex($i);
                                if (file_exists($target_dir . $file_to_extract)) {
                                    echo '(' . $file_to_extract . ') ' . ERROR_FILE_EXISTS_ALREADY . '<br />';
                                } else {
                                    $files_to_unzip[] = $file_to_extract;
                                    $extracted_images[] = $target_dir . $file_to_extract;
                                }
                            }
                            $zip->extractTo($target_dir, $files_to_unzip);
                            $zip->close();
                            echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_OK;
                        } else {
                            echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_FAILED;
                        }
                        // now proceed all unzipped images
                        foreach ($extracted_images as $target) {
                            preg_match('@(^.*/)+(.*)\\.+(\\w*)@', $target, $matches);
                            $real_dir = $matches[1];
                            $basename = $matches[2];
                            $extension = $matches[3];
                            $tfile = $basename . "." . $extension;
                            preg_match('@' . $serendipity['uploadPath'] . '(.*/)@', $target, $matches);
                            $image_directory = $matches[1];
                            // make thumbnails for new images
                            $thumbs = array(array('thumbSize' => $serendipity['thumbSize'], 'thumb' => $serendipity['thumbSuffix']));
                            serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
                            foreach ($thumbs as $thumb) {
                                // Create thumbnail
                                if ($created_thumbnail = serendipity_makeThumbnail($tfile, $image_directory, $thumb['thumbSize'], $thumb['thumb'])) {
                                    echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE . " - " . THUMB_CREATED_DONE . '<br />';
                                }
                            }
                            // Insert into database
                            $image_id = serendipity_insertImageInDatabase($tfile, $image_directory, $authorid, null, $realname);
                            echo PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_IMAGE_FROM_ARCHIVE . " ({$tfile}) " . PLUGIN_EVENT_IMAGESELECTORPLUS_UNZIP_ADD_TO_DB . "<br />";
                            $new_media[] = array('image_id' => $image_id, 'target' => $target, 'created_thumbnail' => $created_thumbnail);
                        }
                    }
                case 'backend_image_addHotlink':
                    // Re-Scale thumbnails?
                    $max_scale = array('width' => (int) $this->get_config('thumb_max_width'), 'height' => (int) $this->get_config('thumb_max_height'));
                    if ($max_scale['width'] > 0 || $max_scale['height'] > 0) {
                        $this->resizeThumb($max_scale, $eventData);
                    }
                    if (empty($serendipity['POST']['quickblog']['title'])) {
                        break;
                    }
                    $file = basename($eventData);
                    $directory = str_replace($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', dirname($eventData) . '/');
                    $size = (int) $serendipity['POST']['quickblog']['size'];
                    // check default Serendipity thumbSize, to make this happen like standard image uploads, and to get one "fullsize" image instance only,
                    // else create another quickblog image "resized" instance, to use as entries thumbnail image
                    if ($serendipity['thumbSize'] != $size) {
                        $oldSuffix = $serendipity['thumbSuffix'];
                        $serendipity['thumbSuffix'] = 'quickblog';
                        serendipity_makeThumbnail($file, $directory, $size);
                        $serendipity['thumbSuffix'] = $oldSuffix;
                    }
                    // Non-image object link generation
                    if ($serendipity['POST']['quickblog']['isobject'] == YES) {
                        $objfile = serendipity_parseFileName($file);
                        $filename = $objfile[0];
                        $suffix = $objfile[1];
                        $obj_mime = serendipity_guessMime($suffix);
                        $objpath = $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath'] . $directory . $filename . '.' . $suffix;
                        // try to know about a working environment for imagemagicks pdf preview generation
                        if ($serendipity['magick'] === true && strtolower($suffix) == 'pdf' && $serendipity['thumbSize'] == $size) {
                            $objpreview = $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath'] . $directory . $filename . '.' . $serendipity['thumbSuffix'] . '.' . $suffix . '.png';
                        } else {
                            $objpreview = serendipity_getTemplateFile('admin/img/mime_' . preg_replace('@[^0-9a-z_\\-]@i', '-', $obj_mime) . '.png');
                        }
                        if (!$objpreview || empty($objpreview)) {
                            $objpreview = serendipity_getTemplateFile('admin/img/mime_unknown.png');
                        }
                    }
                    // New draft post
                    $entry = array();
                    $entry['isdraft'] = 'false';
                    $entry['title'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['quickblog']['title']) : htmlspecialchars($serendipity['POST']['quickblog']['title'], ENT_COMPAT, LANG_CHARSET);
                    if (isset($objpath) && !empty($objpath)) {
                        $entry['body'] = '<a href="' . $objpath . '"><img alt="" class="serendipity_image_left serendipity_quickblog_image" src="' . $objpreview . '">' . $filename . '</a> (-' . $obj_mime . '-)<p>' . $serendipity['POST']['quickblog']['body'] . '</p>';
                    } else {
                        $entry['body'] = '<!--quickblog:' . $serendipity['POST']['quickblog']['target'] . '|' . $eventData . '-->' . $serendipity['POST']['quickblog']['body'];
                    }
                    $entry['authorid'] = $serendipity['authorid'];
                    $entry['exflag'] = false;
                    $entry['categories'][0] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['quickblog']['category']) : htmlspecialchars($serendipity['POST']['quickblog']['category'], ENT_COMPAT, LANG_CHARSET);
                    #$entry['allow_comments']    = 'true'; // both disabled
                    #$entry['moderate_comments'] = 'false'; // to take default values
                    $serendipity['POST']['properties']['fake'] = 'fake';
                    $id = serendipity_updertEntry($entry);
                    break;
                case 'frontend_display':
                    // auto resizing images based on width and/or height attributes in img tag
                    if (serendipity_db_bool($this->get_config('autoresize'))) {
                        if (!empty($eventData['body'])) {
                            $eventData['body'] = $this->substituteImages($eventData['body']);
                        }
                        if (!empty($eventData['extended'])) {
                            $eventData['extended'] = $this->substituteImages($eventData['extended']);
                        }
                    }
                    if (empty($eventData['body'])) {
                        return;
                    }
                    // displaying quickblog posts
                    if (is_object($serendipity['smarty']) && preg_match('@<!--quickblog:(.+)-->@imsU', $eventData['body'], $filematch)) {
                        $eventData['body'] = $this->parse_quickblog_post($filematch[1], $eventData['body']);
                    }
                    // displaying galleries introduced by markup
                    foreach ($this->markup_elements as $temp) {
                        if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
                            $element = $temp['element'];
                            $eventData[$element] = $this->media_insert($eventData[$element], $eventData);
                        }
                    }
                    return true;
                    break;
                case 'backend_entry_presave':
                    if (is_numeric($eventData['id'])) {
                        $eventData['body'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $eventData['body']);
                        $eventData['extended'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $eventData['extended']);
                        $this->gotMilk = true;
                    } else {
                        $this->cache['body'] = $eventData['body'];
                        $this->cache['extended'] = $eventData['extended'];
                    }
                    break;
                case 'backend_publish':
                case 'backend_save':
                    if ($this->gotMilk === false) {
                        $old = md5($this->cache['body']) . md5($this->cache['extended']);
                        $this->cache['body'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $this->cache['body']);
                        $this->cache['extended'] = str_replace('{{s9yisp_entryid}}', $eventData['id'], $this->cache['extended']);
                        $new = md5($this->cache['body']) . md5($this->cache['extended']);
                        if ($old != $new) {
                            serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries\n                                                     SET body     = '" . serendipity_db_escape_string($this->cache['body']) . "',\n                                                         extended = '" . serendipity_db_escape_string($this->cache['extended']) . "'\n                                                   WHERE       id = " . (int) $eventData['id']);
                        }
                    }
                    break;
                case 'entry_display':
                    if ($this->selected()) {
                        if (is_array($eventData)) {
                            $eventData['clean_page'] = true;
                            // This is important to not display an entry list!
                        } else {
                            $eventData = array('clean_page' => true);
                        }
                    }
                    break;
                case 'entries_header':
                    if (!$this->selected()) {
                        return true;
                    }
                    if ($serendipity['version'][0] > 1) {
                        return true;
                    }
                    if (!headers_sent()) {
                        header('HTTP/1.0 200');
                        header('Status: 200 OK');
                    }
                    $entry = serendipity_fetchEntry('id', $serendipity['GET']['id']);
                    $imageid = $serendipity['GET']['image'];
                    $imgsrc = '';
                    if (preg_match('@<a title="([^"]+)" id="s9yisp' . $imageid . '"></a>@imsU', $entry['body'], $imgmatch)) {
                        $imgsrc = $imgmatch[1];
                    } elseif (preg_match('@<a title="([^"]+)" id="s9yisp' . $imageid . '"></a>@imsU', $entry['extended'], $imgmatch)) {
                        $imgsrc = $imgmatch[1];
                    } else {
                        return;
                    }
                    $link = '<a href="' . serendipity_archiveURL($serendipity['GET']['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])) . '#s9yisp' . $imageid . '">';
                    echo '<div class="serendipity_Entry_Date">
                             <h3 class="serendipity_date">' . serendipity_formatTime(DATE_FORMAT_ENTRY, $entry['timestamp']) . '</h3>';
                    echo '<h4 class="serendipity_title"><a href="#">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '</a></h4>';
                    echo '<div class="serendipity_entry"><div class="serendipity_entry_body">';
                    echo '<div class="serendipity_center">' . $link . '<!-- s9ymdb:' . $entry['id'] . ' --><img src="' . $imgsrc . '" /></a></div>';
                    echo '<br />';
                    echo $link . '&lt;&lt; ' . BACK . '</a>';
                    echo "</div>\n</div>\n</div>\n";
                    return true;
                    break;
                case 'frontend_image_add_unknown':
                case 'frontend_image_add_filenameonly':
                case 'frontend_image_selector_submit':
                case 'frontend_image_selector_more':
                case 'frontend_image_selector_imagecomment':
                case 'frontend_image_selector_imagealign':
                case 'frontend_image_selector_imagesize':
                case 'frontend_image_selector_hiddenfields':
                case 'frontend_image_selector_imagelink':
                    return true;
                    break;
                case 'css_backend':
                    if ($serendipity['version'][0] > 1) {
                        ?>

#imageselectorplus .radio_field input {
    margin: 0 0.5em;
}
#quickblog_tablefield {
   display: table-cell;
}
#uploadform .quickblog_nugget {
    margin-left: 0;
    padding: 0;
}
#quickblog_tablefield .quickblog_form_field {
    margin: .375em 0;
}
#quickblog_tablefield .quickblog_radio_field div label,
#quickblog_tablefield .radio_field label {
    padding-left: .5em;
}
#quickblog_tablefield .quickblog_form_select {
    margin-top: 0.75em;
    margin-bottom: 0.75em;
}
#quickblog_tablefield .quickblog_radio_field label {
    padding-left: 0;
}
#quickblog_tablefield .quickblog_radio_field div {
    display: inline;
}
#quickblog_tablefield .quickblog_radio_field input {
    margin-left: 0.5em;
}

<?php 
                    }
                    break;
                case 'css':
                    ?>

#content .serendipity_quickblog_image {
    border: medium none transparent;
}
.serendipity_mediainsert_gallery {
    border: 1px solid #C0C0C0;
    margin: 0px;
    overflow: auto;
    padding: 0.4em;
}

<?php 
                    break;
                case 'frontend_image_selector':
                    if ($serendipity['version'][0] < 2) {
                        $eventData['finishJSFunction'] = 'serendipity_imageSelectorPlus_done(\'' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['GET']['textarea']) : htmlspecialchars($serendipity['GET']['textarea'], ENT_COMPAT, LANG_CHARSET)) . '\')';
                    } else {
                        $eventData['finishJSFunction'] = 'serendipity.serendipity_imageSelector_done(\'' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['GET']['textarea']) : htmlspecialchars($serendipity['GET']['textarea'], ENT_COMPAT, LANG_CHARSET)) . '\')';
                    }
                    return true;
                    break;
                default:
                    return false;
            }
        } else {
            return false;
        }
    }
    function showElementEntrylist($filter = array(), $limit = 0)
    {
        global $serendipity;
        $filter_sql = implode(' AND ', $filter);
        $orderby = 'timestamp DESC';
        // Fetch the entries
        $entries = serendipity_fetchEntries(false, false, $limit, true, false, $orderby, $filter_sql);
        $rows = 0;
        if (!is_array($entries)) {
            return;
        }
        foreach ($entries as $entry) {
            $rows++;
            // Find out if the entry has been modified later than 30 minutes after creation
            if ($entry['timestamp'] <= $entry['last_modified'] - 60 * 30) {
                $lm = '<a href="#" title="' . LAST_UPDATED . ': ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['last_modified']) . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a>';
            } else {
                $lm = '';
            }
            if (!$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
                $entry_pre = '<a href="#" title="' . ENTRY_PUBLISHED_FUTURE . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock_future.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a> ';
            } else {
                $entry_pre = '';
            }
            if (serendipity_db_bool($entry['properties']['ep_is_sticky'])) {
                $entry_pre .= ' ' . STICKY_POSTINGS . ': ';
            }
            if (serendipity_db_bool($entry['isdraft'])) {
                $entry_pre .= ' ' . DRAFT . ': ';
            }
            ?>
            <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
            echo $rows % 2 ? 'even' : 'uneven';
            ?>
">

                <table width="100%" cellspacing="0" cellpadding="3">
                    <tr>
                        <td>
                            <strong><?php 
            echo $entry_pre;
            ?>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="#<?php 
            echo $entry['id'];
            ?>
"><?php 
            echo serendipity_truncateString(function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET), 50);
            ?>
</a></strong>
                        </td>
                        <td align="right">
                            <?php 
            echo serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ' ' . $lm;
            ?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <?php 
            echo POSTED_BY . ' ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['author']) : htmlspecialchars($entry['author'], ENT_COMPAT, LANG_CHARSET));
            if (count($entry['categories'])) {
                echo ' ' . IN . ' ';
                $cats = array();
                foreach ($entry['categories'] as $cat) {
                    $caturl = serendipity_categoryURL($cat);
                    $cats[] = '<a href="' . $caturl . '">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cat['category_name']) : htmlspecialchars($cat['category_name'], ENT_COMPAT, LANG_CHARSET)) . '</a>';
                }
                echo implode(', ', $cats);
            }
            $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
            $entry['preview_link'] = '?serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=preview&amp;serendipity[id]=' . $entry['id'];
            ?>

                        </td>
                        <td align="right">
                            <?php 
            if (serendipity_db_bool($entry['isdraft']) || !$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
                ?>
                            <a target="_blank" href="<?php 
                echo $entry['preview_link'];
                ?>
&amp;<?php 
                echo serendipity_setFormToken('url');
                ?>
" title="<?php 
                echo PREVIEW . ' #' . $entry['id'];
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo PREVIEW;
                ?>
" /><?php 
                echo PREVIEW;
                ?>
</a>
                            <?php 
            } else {
                ?>
                            <a target="_blank" href="<?php 
                echo $entry['link'];
                ?>
" title="<?php 
                echo VIEW . ' #' . $entry['id'];
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo VIEW;
                ?>
" /><?php 
                echo VIEW;
                ?>
</a>
                            <?php 
            }
            ?>
                            <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="<?php 
            echo EDIT . ' #' . $entry['id'];
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/edit.png');
            ?>
" alt="<?php 
            echo EDIT;
            ?>
" /><?php 
            echo EDIT;
            ?>
</a>
                        </td>
                    </tr>
                </table>
            </div>
<?php 
        }
        // end entries output
    }
    /**
     * generate entry row for static page overview panel
     *
     * Show a row for a given static page.
     * This row is similar to the one used for entries.
     * It contains the linked title, the author and quick access for preview, editing and deletion of the page.
     * The background color of the table produced differs for even rows and uneven rows.
     *
     * @param entry array with database information for the static page
     * @param is_even true for even rows and wrong for uneven rows.
     * @return null
     */
    function showListEntry($entry, $is_even)
    {
        global $serendipity;
        // Find out if the entry has been modified later than 30 minutes after creation
        if ($entry['timestamp'] <= $entry['last_modified'] - 60 * 30) {
            $lm = '<a href="#" title="' . LAST_UPDATED . ': ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['last_modified']) . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a>';
        } else {
            $lm = '';
        }
        $entry_pre = '';
        if (!serendipity_db_bool($entry['publishstatus'])) {
            $entry_pre .= ' ' . DRAFT . ': ';
        }
        ?>
            <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
        echo $is_even ? 'even' : 'uneven';
        ?>
">
                <table width="100%" cellspacing="0" cellpadding="3">
                    <tr>
                        <td>
                            <strong><?php 
        echo $entry_pre;
        ?>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=event_display&amp;serendipity[adminAction]=staticpages&amp;serendipity[staticpagecategory]=pages&amp;serendipity[staticid]=<?php 
        echo $entry['id'];
        ?>
" title="#<?php 
        echo $entry['pagetitle'];
        ?>
"><?php 
        echo serendipity_truncateString(function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['headline']) : htmlspecialchars($entry['headline'], ENT_COMPAT, LANG_CHARSET), 50);
        ?>
</a></strong>
                            </td>
                            <td align="right">
                                <?php 
        echo serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ' ' . $lm;
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <?php 
        echo POSTED_BY . ' ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($this->selectAuthor($entry['authorid'])) : htmlspecialchars($this->selectAuthor($entry['authorid']), ENT_COMPAT, LANG_CHARSET));
        ?>
                            </td>
                            <td align="right">
                                <?php 
        $link = $serendipity['baseURL'] . $serendipity['indexFile'];
        $link .= '?serendipity[staticid]=' . $entry['id'] . '&serendipity[staticPreview]=1';
        ?>
                                <form action="serendipity_admin.php" method="post" name="serendipityEntry">
                                <a target="_blank" href="<?php 
        echo $link;
        ?>
" title="<?php 
        echo VIEW . ' #' . $entry['pagetitle'];
        ?>
" class="serendipityIconLink"><img src="<?php 
        echo serendipity_getTemplateFile('admin/img/zoom.png');
        ?>
" alt="<?php 
        echo VIEW . "#" . $entry['pagetitle'];
        ?>
" /></a>
                                    <input type="hidden" name="serendipity[adminModule]" value="event_display" />
                                    <input type="hidden" name="serendipity[adminAction]" value="staticpages" />
                                    <input type="hidden" name="serendipity[staticpagecategory]" value="pages" />
                                    <input type="hidden" name="serendipity[staticpage]" value="<?php 
        echo $entry['id'];
        ?>
" />
                                    <input type="image" name="serendipity[staticSubmit]" src="<?php 
        echo serendipity_getTemplateFile('admin/img/edit.png');
        ?>
" alt="<?php 
        echo EDIT . "#" . $entry['pagetitle'];
        ?>
">
                                    <input type="image" name="serendipity[staticDelete]" src="<?php 
        echo serendipity_getTemplateFile('admin/img/delete.png');
        ?>
" onclick="return confirm('<?php 
        echo sprintf(DELETE_SURE, $entry['pagetitle']);
        ?>
');" alt="<?php 
        echo DELETE . "#" . $entry['pagetitle'];
        ?>
" />
                                </form>
                            </td>
                        </tr>
                    </table>
                </div>        
            <?php 
    }
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     $notmodified = $this->get_config('notmodified');
     $position = $this->get_config('position');
     // %1 = position, %2 = the message itself, %3 = last_modified timestamp
     $format_string_mod = '<div class="entry_last_modified" style="text-align: %s">%s %s</div>';
     // %1 = position, %2 = the message itself
     $format_string_nomod = '<div class="entry_last_modified" style="text-align: %s">%s</div>';
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'entry_display':
                 if (!isset($eventData[0])) {
                     continue;
                 }
                 $extended_key =& $this->getFieldReference('extended', $eventData);
                 if ($addData['extended'] || $addData['preview']) {
                     $eventData[0]['exflag'] = 1;
                     if ($eventData[0]['timestamp'] != $eventData[0]['last_modified']) {
                         $lm = sprintf($format_string_mod, $position, PLUGIN_EVENT_ENTRYLASTMODIFIED_HTML, serendipity_formatTime(DATE_FORMAT_SHORT, $eventData[0]['last_modified']));
                         $eventData[0]['add_footer'] .= $lm;
                         $eventData[0]['string_last_modified'] .= $lm;
                     } elseif ($notmodified == true && PLUGIN_EVENT_ENTRYLASTMODIFIED_NOTMODIFIED != '') {
                         $lm = sprintf($format_string_nomod, $position, PLUGIN_EVENT_ENTRYLASTMODIFIED_NOTMODIFIED);
                         $eventData[0]['add_footer'] .= $lm;
                         $eventData[0]['string_last_modified'] .= $lm;
                     }
                 } elseif (is_array($eventData)) {
                     $elements = count($eventData);
                     for ($i = 0; $i < $elements; $i++) {
                         if (!isset($eventData[$i]['add_footer'])) {
                             $eventData[$i]['add_footer'] = '';
                         }
                         if ($eventData[$i]['timestamp'] != $eventData[$i]['last_modified']) {
                             $lm = sprintf($format_string_mod, $position, PLUGIN_EVENT_ENTRYLASTMODIFIED_HTML, serendipity_formatTime(DATE_FORMAT_SHORT, $eventData[$i]['last_modified']));
                             $eventData[$i]['add_footer'] .= $lm;
                             $eventData[$i]['string_last_modified'] .= $lm;
                         } elseif ($notmodified == true && PLUGIN_EVENT_ENTRYLASTMODIFIED_NOTMODIFIED != '') {
                             $lm = sprintf($format_string_nomod, $position, PLUGIN_EVENT_ENTRYLASTMODIFIED_NOTMODIFIED);
                             $eventData[$i]['add_footer'] .= $lm;
                             $eventData[$i]['string_last_modified'] .= $lm;
                         }
                     }
                 }
                 return true;
                 break;
         }
     }
     return false;
 }
/**
 * Smarty Modifier: Format a timestamp
 *
 * @access public
 * @param   int     The timestamp to format (unix seconds)
 * @param   string  The strftime() format options on how to format this string
 * @param   boolean Shall timezone conversions be applied?
 * @param   boolean Try to detect a valid timestamp?
 * @param   boolean Use strftime or date?
 * @return
 */
function serendipity_smarty_formatTime($timestamp, $format, $useOffset = true, $detectTimestamp = false, $useDate = false)
{
    if ($detectTimestamp !== false && stristr($detectTimestamp, 'date') === false) {
        return $timestamp;
    }
    if (defined($format)) {
        return serendipity_formatTime(constant($format), $timestamp, $useOffset, $useDate);
    } else {
        return serendipity_formatTime($format, $timestamp, $useOffset, $useDate);
    }
}
    function showFeeds()
    {
        # Shows feeds in admin area
        global $serendipity;
        echo '<h2>' . PLUGIN_AGGREGATOR_TITLE . '</h2>';
        if (!empty($serendipity['POST']['aggregatorAction'])) {
            $this->createFeeds();
        } elseif (!empty($serendipity['POST']['aggregatorOPMLImport'])) {
            $this->importOPML();
        }
        $feeds = $this->getFeeds();
        $feeds[] = array('feedid' => 0, 'feedname' => '', 'feedurl' => '', 'charset' => '', 'htmlurl' => '', 'match_expression' => '', 'feedicon' => '', 'categoryids' => array(), 'last_update' => time());
        if ($serendipity['version'][0] == '2') {
            echo '<span class="msg_notice"><span class="icon-info-circled"></span> ';
        }
        echo PLUGIN_AGGREGATOR_DESC;
        if ($serendipity['version'][0] == '1') {
            echo '<br /><br />';
        } else {
            echo '</span>';
        }
        if ($serendipity['version'][0] == '2') {
            echo '<span class="msg_hint"><span class="icon-help-circled"></span> ';
        }
        echo PLUGIN_AGGREGATOR_FEEDLIST;
        if ($serendipity['version'][0] == '1') {
            echo '<br /><br />';
        } else {
            echo '</span>';
        }
        echo '
            <form action="?" method="post">
            <div>
                <input type="hidden" name="serendipity[adminModule]" value="event_display" />
                <input type="hidden" name="serendipity[adminAction]" value="aggregator" />
            </div>';
        if ($serendipity['version'][0] == '1') {
            echo '<table align="center" width="100%" cellpadding="5" cellspacing="0" border=0>';
        } else {
            echo '<table>';
        }
        echo '
            <thead>
                <tr>
                    <th>#</th>
                    <th>' . PLUGIN_AGGREGATOR_FEEDNAME . '</th>
                    <th>' . PLUGIN_AGGREGATOR_FEEDURI . ' / ' . PLUGIN_AGGREGATOR_HTMLURI . '</th>
                    <th>' . PLUGIN_AGGREGATOR_CATEGORIES . '</th>
                    <th>' . PLUGIN_AGGREGATOR_MATCH_EXPRESSION . '* / ' . PLUGIN_AGGREGATOR_FEEDICON . '</th>
                </tr>
            </thead>
            <tbody>';
        $evenidx = 0;
        foreach ($feeds as $idx => $feed) {
            $cat = $this->fetchCat("serendipity[feed][{$feed['feedid']}][categoryids][]", $feed['categoryids']);
            $even = $evenidx++ % 2 ? 'even' : 'uneven';
            echo '
            <tr style="padding: 10px;" class="serendipity_admin_list_item serendipity_admin_list_item_' . $even . '">
                <td valign="top"><em>' . $idx . '</em></td>
                <td valign="top">
                    <input class="input_textbox" type="text" name="serendipity[feed][' . $feed['feedid'] . '][feedname]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['feedname']) : htmlspecialchars($feed['feedname'], ENT_COMPAT, LANG_CHARSET)) . '" /> ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['charset']) : htmlspecialchars($feed['charset'], ENT_COMPAT, LANG_CHARSET)) . '
                </td>
                <td width="100%" valign="top">
                    <input class="input_textbox" style="width: 100%" type="text" name="serendipity[feed][' . $feed['feedid'] . '][feedurl]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['feedurl']) : htmlspecialchars($feed['feedurl'], ENT_COMPAT, LANG_CHARSET)) . '" />
                    <input class="input_textbox" style="width: 65%; margin-top: 2px;" type="text" name="serendipity[feed][' . $feed['feedid'] . '][htmlurl]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['htmlurl']) : htmlspecialchars($feed['htmlurl'], ENT_COMPAT, LANG_CHARSET)) . '" />
                </td>
                <td valign="top" rowspan="2">' . $cat . '</td>
                <td valign="top" rowspan="2"><textarea rows=6 cols=25 name="serendipity[feed][' . $feed['feedid'] . '][match_expression]">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['match_expression']) : htmlspecialchars($feed['match_expression'], ENT_COMPAT, LANG_CHARSET)) . '</textarea><br />
                    <input class="input_textbox" style="width: 65%; margin-top: 2px;" type="text" name="serendipity[feed][' . $feed['feedid'] . '][feedicon]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['feedicon']) : htmlspecialchars($feed['feedicon'], ENT_COMPAT, LANG_CHARSET)) . '" />

            </tr>
            <tr style="padding: 10px;" class="serendipity_admin_list_item serendipity_admin_list_item_' . $even . '">
                <td></td>
                <td colspan="2" valign="top">
                    <div style="font-size: 8pt;">' . PLUGIN_AGGREGATOR_FEEDUPDATE . ' ' . serendipity_formatTime(DATE_FORMAT_SHORT, $feed['last_update']) . '</div>
                </td>
            </tr>';
        }
        echo '
            <tr>
                <td colspan="4"><br />
                    <input type="submit" name="serendipity[aggregatorAction]" value="' . GO . '" class="serendipityPrettyButton input_button" />
                </td>
            </tr>
            </tbody>
            </table>
            * ' . PLUGIN_AGGREGATOR_MATCH_EXPRESSION_DESC . '
            </form>';
        echo '
            <form action="?" method="post">
            <div>
                <input type="hidden" name="serendipity[adminModule]" value="event_display" />
                <input type="hidden" name="serendipity[adminAction]" value="aggregator" />
            </div>';
        if ($serendipity['version'][0] == '1') {
            echo '
            <div>
                <hr /><strong>
                ' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST . '</strong><br /><br />
                ' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST_DESC . '<br /><br />
                URL: <input class="input_textbox" type="text" name="serendipity[aggregatorOPML]" value="http://" /><br />
                <input class="input_checkbox" type="checkbox" id="import_categories" name="serendipity[aggregatorOPMLCategories]" value="true" /><label for="import_categories">' . PLUGIN_AGGREGATOR_IMPORTCATEGORIES . '</label>
                <input class="input_checkbox" type="checkbox" id="import_categories2" name="serendipity[aggregatorOPMLCategoriesNoNesting]" value="true" /><label for="import_categories2">' . PLUGIN_AGGREGATOR_IMPORTCATEGORIES2 . '</label>
                <br /><br />
                <input type="submit" name="serendipity[aggregatorOPMLImport]" value="' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST_BUTTON . '" class="serendipityPrettyButton input_button" />
            </div>';
        } else {
            echo '
            <h3>' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST . '</h3>
            <span class="msg_hint"><span class="icon-help-circled"></span> ' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST_DESC . '</span>
            <div class="form_field">
                <label for="serendipity_aggregator_opml">URL</label>
                <input id="serendipity_aggregator_opml" type="text" name="serendipity[aggregatorOPML]" value="http://">
            </div>
            <div class="form_check">
                <input type="checkbox" id="import_categories" name="serendipity[aggregatorOPMLCategories]" value="true"><label for="import_categories">' . PLUGIN_AGGREGATOR_IMPORTCATEGORIES . '</label>
                <input type="checkbox" id="import_categories2" name="serendipity[aggregatorOPMLCategoriesNoNesting]" value="true"><label for="import_categories2">' . PLUGIN_AGGREGATOR_IMPORTCATEGORIES2 . '</label>
            </div>';
        }
        if ($serendipity['version'][0] == '1') {
            echo '
            <div>
                <hr /><strong>
                ' . PLUGIN_AGGREGATOR_EXPORTFEEDLIST . '</strong><br /><br />
                <a href="' . serendipity_rewriteURL('plugin/opmlfeeds.xml') . '" class="serendipityPrettyButton">' . PLUGIN_AGGREGATOR_EXPORTFEEDLIST_BUTTON . '</a>
            </div>
            </form>';
        } else {
            echo '
            <h3>' . PLUGIN_AGGREGATOR_EXPORTFEEDLIST . '</h3>
            <a class="button_link" href="' . serendipity_rewriteURL('plugin/opmlfeeds.xml') . '"><span class="icon-rss"></span> ' . PLUGIN_AGGREGATOR_EXPORTFEEDLIST_BUTTON . '</a>
            </form>';
        }
    }
Example #11
0
<?php 
        if (!empty($header_class)) {
            ?>
            <img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php 
            echo serendipity_getTemplateFile('admin/img/admin_msg_note.png');
            ?>
" alt="" />
<?php 
        }
        ?>
        <a name="c<?php 
        echo $comment['id'];
        ?>
"></a>
        <?php 
        echo ($comment['type'] == 'NORMAL' ? COMMENT : ($comment['type'] == 'TRACKBACK' ? TRACKBACK : PINGBACK)) . ' #' . $comment['id'] . ', ' . IN_REPLY_TO . ' <strong><a href="' . $comment['entry_url'] . '">' . htmlspecialchars($comment['title']) . '</a></strong>, ' . ON . ' ' . serendipity_formatTime('%b %e %Y, %H:%M', $comment['timestamp']);
        ?>
    </td>
</tr>
<tr>
    <td class="serendipity_admin_list_item <?php 
        echo $class;
        ?>
" id="comment_<?php 
        echo $comment['id'];
        ?>
">
        <table width="100%" cellspacing="0" cellpadding="3" border="0">
            <tr>
                <td rowspan="3" width="20" align="center"><input class="input_checkbox" type="checkbox" name="serendipity[delete][<?php 
        echo $comment['id'];
 function renderScrobblerOutput()
 {
     $formatstring = $this->get_config('formatstring');
     $formatstring_block = $this->get_config('formatstring_block');
     $artistlink = $this->get_config('artistlink');
     $songlink = $this->get_config('songlink');
     $spacer = $this->get_config('spacer');
     $profiletitle = $this->get_config('profiletitle');
     $this->getSongsFromScrobbler();
     $this->readScrobblerCache();
     if ($this->get_config('newwindow')) {
         $onlick = ' onclick="window.open(this.href);"';
     }
     if (!$this->songs) {
         echo '<span style="font-weight: bold;">' . PLUGIN_AUDIOSCROBBLER_ERROR . ':</span><br /><ul><li>' . join('</li><li>', $this->scrobbler_error) . '</li></ul>';
         return;
     }
     $content = array();
     $i = 0;
     foreach ($this->songs as $key => $value) {
         $value['songtitle'] = utf8_decode($value['songtitle']);
         $value['artisttitle'] = utf8_decode($value['artisttitle']);
         $value['songtitle'] = utf8_decode($value['songtitle']);
         $add = '';
         if ($songlink) {
             if (is_string(strstr($value['link'], '&mode'))) {
                 //fix ampersand entity
                 $song = '<a href="' . str_replace('&mode', '&amp;mode', $value['link']) . '"' . $onclick . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($value['songtitle'], ENT_QUOTES) : htmlspecialchars($value['songtitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET)) . '</a>' . "\n";
             } elseif (is_string(strstr($value['link'], '&amp;mode'))) {
                 //link is ok
                 $song = '<a href="' . $value['link'] . '"' . $onclick . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($value['songtitle'], ENT_QUOTES) : htmlspecialchars($value['songtitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET)) . '</a>' . "\n";
             } else {
                 //encode it
                 $song = '<a href="http://www.audioscrobbler.com/music/' . urlencode(utf8_encode($value['artisttitle'])) . '/_/' . urlencode(utf8_encode($value['songtitle'])) . '"' . $onclick . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($value['songtitle'], ENT_QUOTES) : htmlspecialchars($value['songtitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET)) . '</a>' . "\n";
             }
         } else {
             $song = function_exists('serendipity_specialchars') ? serendipity_specialchars($value['songtitle'], ENT_QUOTES) : htmlspecialchars($value['songtitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET);
         }
         if ($artistlink == 0) {
             $artist = function_exists('serendipity_specialchars') ? serendipity_specialchars($value['artisttitle'], ENT_QUOTES) : htmlspecialchars($value['artisttitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET);
         } elseif ($artistlink == 1) {
             $artist = '<a href="http://www.audioscrobbler.com/music/' . urlencode(utf8_encode($value['artisttitle'])) . '"' . $onclick . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($value['artisttitle'], ENT_QUOTES) : htmlspecialchars($value['artisttitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET)) . '</a>' . "\n";
         } elseif ($artistlink == 2) {
             if ($value['artisttitle'] != '' || $value['artistlink'] != 'http://mm.musicbrainz.org/artist/') {
                 $artist = '<a href="' . $value['artistlink'] . '"' . $onclick . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($value['artisttitle'], ENT_QUOTES) : htmlspecialchars($value['artisttitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET)) . '</a>' . "\n";
             } else {
                 $artist = function_exists('serendipity_specialchars') ? serendipity_specialchars($value['artisttitle'], ENT_QUOTES) : htmlspecialchars($value['artisttitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET);
             }
         } else {
             if (trim($value['artistlink']) != 'http://mm.musicbrainz.org/artist/' && trim($value['artistlink']) != '') {
                 $artist = '<a href="' . $value['artistlink'] . '"' . $onclick . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($value['artisttitle'], ENT_QUOTES) : htmlspecialchars($value['artisttitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET)) . '</a>' . "\n";
             } else {
                 $artist = '<a href="http://www.audioscrobbler.com/music/' . urlencode(utf8_encode($value['artisttitle'])) . '"' . $onclick . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($value['artisttitle'], ENT_QUOTES) : htmlspecialchars($value['artisttitle'], ENT_QUOTES | ENT_COMPAT, LANG_CHARSET)) . '</a>' . "\n";
             }
         }
         $replacements = array('%ARTIST%' => $artist, '%SONG%' => $song, '%DATE%' => $this->renderScrobblerDate($value['date'], $dateformat));
         $add = str_replace(array_keys($replacements), array_values($replacements), $formatstring);
         $content[] = $add;
         $i++;
         if ($i == $this->number) {
             break;
         }
     }
     $entries = join($spacer, $content);
     $output = str_replace('%ENTRIES%', $entries, $formatstring_block);
     $profiletitle = str_replace('%USER%', $this->username, $profiletitle);
     $output = str_replace('%PROFILE%', '<a href="http://www.audioscrobbler.com/user/' . urlencode(utf8_encode($this->username)) . '"' . $onclick . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($profiletitle, ENT_QUOTES) : htmlspecialchars($profiletitle, ENT_QUOTES | ENT_COMPAT, LANG_CHARSET)) . '</a>', $output);
     $lstime = serendipity_formatTime($this->get_config('dateformat'), filemtime($this->scrobblercache), true);
     $output = str_replace('%LASTUPDATE%', function_exists('serendipity_specialchars') ? serendipity_specialchars($lstime) : htmlspecialchars($lstime, ENT_COMPAT, LANG_CHARSET), $output);
     $output = str_replace('audioscrobbler.com', 'last.fm', $output);
     return $output;
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'frontend_configure':
                    if ($this->get_config('ext_vis_stat') == 'no') {
                        return;
                    }
                    //checking if db tables exists, otherwise install them
                    $tableChecker = serendipity_db_query("SELECT counter_id FROM {$serendipity['dbPrefix']}visitors LIMIT 1", true);
                    if (!is_array($tableChecker)) {
                        $this->createTables();
                    }
                    if ((int) $this->get_config('db_indices_created', '0') == 0) {
                        $this->updateTables();
                    }
                    if ((int) $this->get_config('db_indices_created', '1') == 1) {
                        $this->updateTables(1);
                    }
                    //Unique visitors are beeing registered and counted here. Calling function below.
                    $sessionChecker = serendipity_db_query("SELECT count(sessID) FROM {$serendipity['dbPrefix']}visitors WHERE '" . serendipity_db_escape_string(session_id()) . "' = sessID GROUP BY sessID", true);
                    if (!is_array($sessionChecker) || is_array($sessionChecker) && $sessionChecker[0] == 0) {
                        $referer = $useragent = $remoteaddr = 'unknown';
                        // gathering intel
                        if ($_SERVER['REMOTE_ADDR']) {
                            $remoteaddr = $_SERVER['REMOTE_ADDR'];
                        }
                        if ($_SERVER['HTTP_USER_AGENT']) {
                            $useragent = substr($_SERVER['HTTP_USER_AGENT'], 0, 255);
                        }
                        if ($_SERVER['HTTP_REFERER']) {
                            $referer = substr($_SERVER['HTTP_REFERER'], 0, 255);
                        }
                        $found = 0;
                        // avoiding banned browsers
                        if ($this->get_config('banned_bots') == 'yes') {
                            // excludelist botagents
                            $banned_array = array('1' => "unknown", '2' => "bot", '3' => "slurpy", '4' => "agent 007", '5' => "ichiro", '6' => "ia_archiver", '7' => "zyborg", '8' => "linkwalker", '9' => "crawler", '10' => "python", '11' => "w3c_validator", '12' => "almaden", '13' => "topicspy", '14' => "poodle predictor", '15' => "link checker pro", '16' => "xenu link sleuth", '17' => "iconsurf", '18' => "zoe indexer", '19' => "grub-client", '20' => "spider", '21' => "pompos", '22' => "virus_detector", '23' => "bot", '24' => "Wells Search II", '25' => "Dumbot", '26' => "GeoBot", '27' => "DigExt", '28' => "Jeeves/Teoma", '29' => "FeedBurner", '30' => "Technorati", '31' => "Java/1.5.0_10", '32' => "Java/1.5.0_06", '33' => "MarsEdit", '34' => "Blogslive", '35' => "XMLRPCCocoa", '36' => "Google", '37' => "MagpieRSS", '38' => "Sphere Scout", '39' => "BlogCorpusReader", '41' => "libwww-perl", '42' => "WordPress", '43' => "ping.wordblog.de", '44' => "PEAR HTTP_Request", '45' => "Java/1.5.0_07", '46' => "BlogPulseLive(support@blogpulse.com)", '47' => "TrackBack", '48' => "Blogdimension", '49' => "Yahoo");
                            foreach ($banned_array as $ban) {
                                if (stristr($useragent, $ban) !== false) {
                                    $found = 1;
                                    break;
                                }
                            }
                        }
                        if ($found == 0) {
                            $this->countVisitor($useragent, $remoteaddr, $referer);
                        }
                    } else {
                        // Update visitor timestamp
                        $this->updateVisitor();
                    }
                    break;
                case 'css_backend':
                    ?>

.serendipity_statistics table {
    background: #eaeaea;
    background-image: -webkit-linear-gradient(#fff, #eaeaea);
    background-image: linear-gradient(#fff, #eaeaea);
    border-color: #ddd #bbb #999;
    color: #222;
    text-shadow: #fff 0 1px 1px;
    width: 100%;
}
.stats_imagecell {
    vertical-align: bottom;
}
.stats_header {
    width: auto;
    display: block;
    background: #eee;
}
.stats_header span {
    text-align: right;
    width: 50%;
    float: right;
}
.serendipity_statistics .wide_box dl {
    clear: left;
    display: table;
    width: 100%;
}
.serendipity_statistics .wide_box dt {
    display: table-row;
}
.serendipity_statistics .wide_box dd {
    margin-left: 0;
    padding: 0px 0.5em 0.5em 0;
}

<?php 
                    break;
                case 'backend_sidebar_entries':
                    if ($serendipity['version'][0] < 2) {
                        ?>
                        <li><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=statistics"><?php 
                        echo PLUGIN_EVENT_STATISTICS_NAME;
                        ?>
</a></li>
<?php 
                    }
                    break;
                case 'backend_sidebar_admin_appearance':
                    if ($serendipity['version'][0] > 1) {
                        ?>
                        <li><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=statistics"><?php 
                        echo PLUGIN_EVENT_STATISTICS_NAME;
                        ?>
</a></li>
<?php 
                    }
                    break;
                case 'backend_sidebar_entries_event_display_statistics':
                    $max_items = $this->get_config('max_items');
                    $ext_vis_stat = $this->get_config('ext_vis_stat');
                    if (!$max_items || !is_numeric($max_items) || $max_items < 1) {
                        $max_items = 20;
                    }
                    if ($ext_vis_stat == 'yesTop') {
                        $this->extendedVisitorStatistics($max_items);
                    }
                    if ($this->get_config('stat_all') == 'yes') {
                        $first_entry = serendipity_db_query("SELECT timestamp FROM {$serendipity['dbPrefix']}entries ORDER BY timestamp ASC limit 1", true);
                        $last_entry = serendipity_db_query("SELECT timestamp FROM {$serendipity['dbPrefix']}entries ORDER BY timestamp DESC limit 1", true);
                        $total_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}entries", true);
                        $draft_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}entries WHERE isdraft = 'true'", true);
                        $publish_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}entries WHERE isdraft = 'false'", true);
                        $author_rows = serendipity_db_query("SELECT author, count(author) as entries FROM {$serendipity['dbPrefix']}entries GROUP BY author ORDER BY author");
                        $category_count = serendipity_db_query("SELECT count(categoryid) FROM {$serendipity['dbPrefix']}category", true);
                        $cat_sql = "SELECT c.category_name, count(e.id) as postings\n                                                        FROM {$serendipity['dbPrefix']}entrycat ec,\n                                                             {$serendipity['dbPrefix']}category c,\n                                                             {$serendipity['dbPrefix']}entries e\n                                                        WHERE ec.categoryid = c.categoryid AND ec.entryid = e.id\n                                                        GROUP BY ec.categoryid, c.category_name\n                                                        ORDER BY postings DESC";
                        $category_rows = serendipity_db_query($cat_sql);
                        $image_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}images", true);
                        $image_rows = serendipity_db_query("SELECT extension, count(id) AS images FROM {$serendipity['dbPrefix']}images GROUP BY extension ORDER BY images DESC");
                        $subscriber_count = count(serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}comments WHERE type = 'NORMAL' AND subscribed = 'true' GROUP BY email"));
                        $subscriber_rows = serendipity_db_query("SELECT e.timestamp, e.id, e.title, count(c.id) as postings\n                                                        FROM {$serendipity['dbPrefix']}comments c,\n                                                             {$serendipity['dbPrefix']}entries e\n                                                        WHERE e.id = c.entry_id AND type = 'NORMAL' AND subscribed = 'true'\n                                                        GROUP BY e.id, c.email, e.title, e.timestamp\n                                                        ORDER BY postings DESC\n                                                        LIMIT {$max_items}");
                        $comment_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}comments WHERE type = 'NORMAL'", true);
                        $comment_rows = serendipity_db_query("SELECT e.timestamp, e.id, e.title, count(c.id) as postings\n                                                        FROM {$serendipity['dbPrefix']}comments c,\n                                                             {$serendipity['dbPrefix']}entries e\n                                                        WHERE e.id = c.entry_id AND type = 'NORMAL'\n                                                        GROUP BY e.id, e.title, e.timestamp\n                                                        ORDER BY postings DESC\n                                                        LIMIT {$max_items}");
                        $commentor_rows = serendipity_db_query("SELECT author, max(email) as email, max(url) as url, count(id) as postings\n                                                        FROM {$serendipity['dbPrefix']}comments c\n                                                        WHERE type = 'NORMAL'\n                                                        GROUP BY author\n                                                        ORDER BY postings DESC\n                                                        LIMIT {$max_items}");
                        $tb_count = serendipity_db_query("SELECT count(id) FROM {$serendipity['dbPrefix']}comments WHERE type = 'TRACKBACK'", true);
                        $tb_rows = serendipity_db_query("SELECT e.timestamp, e.id, e.title, count(c.id) as postings\n                                                        FROM {$serendipity['dbPrefix']}comments c,\n                                                             {$serendipity['dbPrefix']}entries e\n                                                        WHERE e.id = c.entry_id AND type = 'TRACKBACK'\n                                                        GROUP BY e.timestamp, e.id, e.title\n                                                        ORDER BY postings DESC\n                                                        LIMIT {$max_items}");
                        $tbr_rows = serendipity_db_query("SELECT author, max(email) as email, max(url) as url, count(id) as postings\n                                                        FROM {$serendipity['dbPrefix']}comments c\n                                                        WHERE type = 'TRACKBACK'\n                                                        GROUP BY author\n                                                        ORDER BY postings DESC\n                                                        LIMIT {$max_items}");
                        $length = serendipity_db_query("SELECT SUM(LENGTH(body) + LENGTH(extended)) FROM {$serendipity['dbPrefix']}entries", true);
                        $length_rows = serendipity_db_query("SELECT id, title, (LENGTH(body) + LENGTH(extended)) as full_length FROM {$serendipity['dbPrefix']}entries ORDER BY full_length DESC LIMIT {$max_items}");
                        ?>
    <h2><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_STATISTICS;
                        ?>
</h2>

    <div class="serendipity_statistics clearfix">
        <section>
            <h3><?php 
                        echo ENTRIES;
                        ?>
</h3>

            <dl>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_FIRST_ENTRY;
                        ?>
</dt>
                <dd><?php 
                        echo serendipity_formatTime(DATE_FORMAT_ENTRY . ' %H:%m', $first_entry[0]);
                        ?>
</dd>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_LAST_ENTRY;
                        ?>
</dt>
                <dd><?php 
                        echo serendipity_formatTime(DATE_FORMAT_ENTRY . ' %H:%m', $last_entry[0]);
                        ?>
</dd>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TOTAL_ENTRIES;
                        ?>
</dt>
                <dd><?php 
                        echo $total_count[0];
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ENTRIES;
                        ?>
                    <dl>
                        <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TOTAL_PUBLIC;
                        ?>
</dt>
                        <dd><?php 
                        echo $publish_count[0];
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ENTRIES;
                        ?>
</dd>
                        <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TOTAL_DRAFTS;
                        ?>
</dt>
                        <dd><?php 
                        echo $draft_count[0];
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ENTRIES;
                        ?>
</dd>
                    </dl>
                </dd>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_PER_AUTHOR;
                        ?>
</h3>

            <dl>
<?php 
                        if (is_array($author_rows)) {
                            foreach ($author_rows as $author => $author_stat) {
                                ?>
                <dt><?php 
                                echo $author_stat['author'];
                                ?>
</dt>
                <dd><?php 
                                echo $author_stat['entries'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_ENTRIES;
                                ?>
 (<?php 
                                echo 100 * round($author_stat['entries'] / max($total_count[0], 1), 3);
                                ?>
%)</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_CATEGORIES;
                        ?>
</h3>

            <p><?php 
                        echo $category_count[0];
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_CATEGORIES2;
                        ?>
</p>

            <h4><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_DISTRIBUTION_CATEGORIES;
                        ?>
</h4>

            <dl>
<?php 
                        if (is_array($category_rows)) {
                            foreach ($category_rows as $category => $cat_stat) {
                                ?>
                <dt><?php 
                                echo $cat_stat['category_name'];
                                ?>
</dt>
                <dd><?php 
                                echo $cat_stat['postings'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_DISTRIBUTION_CATEGORIES2;
                                ?>
</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_UPLOADED_IMAGES;
                        ?>
</h3>

            <p><?php 
                        echo $image_count[0];
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_UPLOADED_IMAGES2;
                        ?>
</p>

            <h4><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_DISTRIBUTION_IMAGES;
                        ?>
</h4>

            <dl>
<?php 
                        if (is_array($image_rows)) {
                            foreach ($image_rows as $image => $image_stat) {
                                ?>
                <dt><?php 
                                echo $image_stat['extension'];
                                ?>
</dt>
                <dd><?php 
                                echo $image_stat['images'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_DISTRIBUTION_IMAGES2;
                                ?>
</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo COMMENTS;
                        ?>
</h3>

            <dl>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_COMMENTS;
                        ?>
</dt>
                <dd><?php 
                        echo $comment_count[0];
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_COMMENTS2;
                        ?>
</dd>
            </dl>

            <h4><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_COMMENTS3;
                        ?>
</h4>

            <dl>
<?php 
                        if (is_array($comment_rows)) {
                            foreach ($comment_rows as $comment => $com_stat) {
                                ?>
                <dt><a href="<?php 
                                echo serendipity_archiveURL($com_stat['id'], $com_stat['title'], 'serendipityHTTPPath', true, array('timestamp' => $com_stat['timestamp']));
                                ?>
"><?php 
                                echo $com_stat['title'];
                                ?>
</a></dt>
                <dd><?php 
                                echo $com_stat['postings'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_COMMENTS2;
                                ?>
</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TOPCOMMENTS;
                        ?>
</h3>

            <dl>
<?php 
                        if (is_array($commentor_rows)) {
                            foreach ($commentor_rows as $comment => $com_stat) {
                                $link_start = '';
                                $link_end = '';
                                $link_url = '';
                                if (!empty($com_stat['email'])) {
                                    $link_start = '<a href="mailto:' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($com_stat['email']) : htmlspecialchars($com_stat['email'], ENT_COMPAT, LANG_CHARSET)) . '">';
                                    $link_end = '</a>';
                                }
                                if (!empty($com_stat['url'])) {
                                    if (substr($com_stat['url'], 0, 7) != 'http://' && substr($com_stat['url'], 0, 8) != 'https://') {
                                        $com_stat['url'] = 'http://' . $com_stat['url'];
                                    }
                                    $link_url = ' (<a href="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($com_stat['url']) : htmlspecialchars($com_stat['url'], ENT_COMPAT, LANG_CHARSET)) . '">' . PLUGIN_EVENT_STATISTICS_OUT_LINK . '</a>)';
                                }
                                if (empty($com_stat['author'])) {
                                    $com_stat['author'] = ANONYMOUS;
                                }
                                ?>
                <dt><?php 
                                echo $link_start . $com_stat['author'] . $link_end . $link_url;
                                ?>
 </dt>
                <dd><?php 
                                echo $com_stat['postings'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_COMMENTS2;
                                ?>
</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_SUBSCRIBERS;
                        ?>
</h3>

            <p><?php 
                        echo $subscriber_count;
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_SUBSCRIBERS2;
                        ?>
</p>

            <h4><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TOPSUBSCRIBERS;
                        ?>
</h4>

            <dl>
<?php 
                        if (is_array($subscriber_rows)) {
                            foreach ($subscriber_rows as $subscriber => $subscriber_stat) {
                                ?>
                <dt><a href="<?php 
                                echo serendipity_archiveURL($subscriber_stat['id'], $subscriber_stat['title'], 'serendipityHTTPPath', true, array('timestamp' => $subscriber_stat['timestamp']));
                                ?>
"><?php 
                                echo $subscriber_stat['title'];
                                ?>
</a></dt>
                <dd><?php 
                                echo $subscriber_stat['postings'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_TOPSUBSCRIBERS2;
                                ?>
</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TRACKBACKS;
                        ?>
</h3>

            <p><?php 
                        echo $tb_count[0];
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TRACKBACKS2;
                        ?>
</p>

            <h4><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TOPTRACKBACK;
                        ?>
</h4>

            <dl>
<?php 
                        if (is_array($tb_rows)) {
                            foreach ($tb_rows as $tb => $tb_stat) {
                                ?>
                <dt><a href="<?php 
                                echo serendipity_archiveURL($tb_stat['id'], $tb_stat['title'], 'serendipityHTTPPath', true, array('timestamp' => $tb_stat['timestamp']));
                                ?>
"><?php 
                                echo $tb_stat['title'];
                                ?>
</a></dt>
                <dd><?php 
                                echo $tb_stat['postings'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_TOPTRACKBACK2;
                                ?>
</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TOPTRACKBACKS3;
                        ?>
</h3>

            <dl>
<?php 
                        if (is_array($tbr_rows)) {
                            foreach ($tbr_rows as $tb => $tb_stat) {
                                if (empty($tb_stat['author'])) {
                                    $tb_stat['author'] = ANONYMOUS;
                                }
                                ?>
                <dt><a href="<?php 
                                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($tb_stat['url']) : htmlspecialchars($tb_stat['url'], ENT_COMPAT, LANG_CHARSET);
                                ?>
"><?php 
                                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($tb_stat['author']) : htmlspecialchars($tb_stat['author'], ENT_COMPAT, LANG_CHARSET);
                                ?>
</a></dt>
                <dd><?php 
                                echo $tb_stat['postings'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_TOPTRACKBACK2;
                                ?>
</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3>(Needs a heading)</h3>

            <dl>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_COMMENTS_PER_ARTICLE;
                        ?>
</dt>
                <dd><?php 
                        echo round($comment_count[0] / max($publish_count[0], 1), 2);
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_COMMENTS_PER_ARTICLE2;
                        ?>
</dd>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TRACKBACKS_PER_ARTICLE;
                        ?>
</dt>
                <dd><?php 
                        echo round($tb_count[0] / max($publish_count[0], 1), 2);
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_TRACKBACKS_PER_ARTICLE2;
                        ?>
</dd>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ARTICLES_PER_DAY;
                        ?>
</dt>
                <dd><?php 
                        echo round($publish_count[0] / ((time() - $first_entry[0]) / (60 * 60 * 24)), 2);
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ARTICLES_PER_DAY2;
                        ?>
</dd>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ARTICLES_PER_WEEK;
                        ?>
</dt>
                <dd><?php 
                        echo round($publish_count[0] / ((time() - $first_entry[0]) / (60 * 60 * 24 * 7)), 2);
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ARTICLES_PER_WEEK2;
                        ?>
</dd>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ARTICLES_PER_MONTH;
                        ?>
</dt>
                <dd><?php 
                        echo round($publish_count[0] / ((time() - $first_entry[0]) / (60 * 60 * 24 * 31)), 2);
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_ARTICLES_PER_MONTH2;
                        ?>
</dd>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_CHARS;
                        ?>
</dt>
                <dd><?php 
                        echo $length[0];
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_CHARS2;
                        ?>
</dd>
                <dt><?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_CHARS_PER_ARTICLE;
                        ?>
</dt>
                <dd><?php 
                        echo round($length[0] / max($publish_count[0], 1), 2);
                        ?>
 <?php 
                        echo PLUGIN_EVENT_STATISTICS_OUT_CHARS_PER_ARTICLE2;
                        ?>
</dd>
            </dl>
        </section>

        <section>
            <h3><?php 
                        printf(PLUGIN_EVENT_STATISTICS_OUT_LONGEST_ARTICLES, $max_items);
                        ?>
</h3>

            <dl>
<?php 
                        if (is_array($length_rows)) {
                            foreach ($length_rows as $tb => $length_stat) {
                                ?>
                <dt><a href="<?php 
                                echo serendipity_archiveURL($length_stat['id'], $length_stat['title'], 'serendipityHTTPPath', true, array('timestamp' => $length_stat['timestamp']));
                                ?>
"><?php 
                                echo $length_stat['title'];
                                ?>
</a></dt>
                <dd><?php 
                                echo $length_stat['full_length'];
                                ?>
 <?php 
                                echo PLUGIN_EVENT_STATISTICS_OUT_CHARS2;
                                ?>
</dd>
<?php 
                            }
                        }
                        ?>
            </dl>
        </section>

        <section>
            <h3><?php 
                        echo TOP_REFERRER;
                        ?>
</h3>

            <?php 
                        echo serendipity_displayTopReferrers($max_items, true);
                        ?>
        </section>

        <section>
            <h3><?php 
                        echo TOP_EXITS;
                        ?>
</h3>

            <?php 
                        echo serendipity_displayTopExits($max_items, true);
                        ?>
        </section>
    <?php 
                        serendipity_plugin_api::hook_event('event_additional_statistics', $eventData, array('maxitems' => $max_items));
                        ?>
    </div>
<?php 
                    }
                    if ($ext_vis_stat == 'yesBot') {
                        $this->extendedVisitorStatistics($max_items);
                    }
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     if ($event == 'frontend_header') {
         $start_url = $serendipity['baseURL'];
         $start_title = $serendipity['blogTitle'];
         echo '<link rel="start" href="' . $start_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($start_title) : htmlspecialchars($start_title, ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n";
         if ($serendipity['GET']['action'] == 'read' && !empty($serendipity['GET']['id'])) {
             // Article detail view
             echo '<link rel="up" href="' . $start_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($start_title) : htmlspecialchars($start_title, ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n";
             $this->backAndForth($this->showPaging($serendipity['GET']['id']));
             // END article detail view
             echo '<link rel="canonical" href="' . $this->getEntry($serendipity['GET']['id']) . '" />' . "\n";
         } elseif ($serendipity['GET']['action'] == 'read' && is_array($serendipity['range'])) {
             // Specific Date Archives view
             echo '<link rel="up" href="' . serendipity_rewriteURL(PATH_ARCHIVE) . '" title="' . ARCHIVES . '" />' . "\n";
             echo '<link rel="canonical" href="' . $this->getArchiveParameters() . '" />' . "\n";
             $links = array();
             $add_query = '';
             $year = date('Y', $serendipity['range'][0]);
             $month = date('m', $serendipity['range'][0]);
             $day = date('d', $serendipity['range'][0]);
             $pageMonthNext = array('day' => '1', 'month' => $month + 1, 'year' => $year);
             $pageMonthPrev = array('day' => '1', 'month' => $month - 1, 'year' => $year);
             $pageDayNext = array('day' => $day + 1, 'month' => $month, 'year' => $year);
             $pageDayPrev = array('day' => $day - 1, 'month' => $month, 'year' => $year);
             $diff = $serendipity['range'][1] - $serendipity['range'][0];
             if (isset($serendipity['GET']['category'])) {
                 $categoryid = (int) serendipity_db_escape_string($serendipity['GET']['category']);
                 $add_query = '/C' . $categoryid;
             }
             if ($diff < 86400) {
                 // Paging day by day
                 $ts = mktime(0, 0, 0, $pageDayPrev['month'], $pageDayPrev['day'], $pageDayPrev['year']);
                 $links['prev'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', date('Y', $ts), date('m', $ts), date('d', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false)));
                 $ts = mktime(0, 0, 0, $pageDayNext['month'], $pageDayNext['day'], $pageDayNext['year']);
                 $links['next'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', date('Y', $ts), date('m', $ts), date('d', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false)));
             } elseif ($diff < 86400 * 28) {
                 // Paging by week
                 // TODO - Don't know :-)
             } else {
                 // Paging by month
                 $ts = mktime(0, 0, 0, $pageMonthPrev['month'], $pageMonthPrev['day'], $pageMonthPrev['year']);
                 $links['prev'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d', date('Y', $ts), date('m', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime('%B %Y', $ts, false)));
                 $ts = mktime(0, 0, 0, $pageMonthNext['month'], $pageMonthNext['day'], $pageMonthNext['year']);
                 $links['next'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d', date('Y', $ts), date('m', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime('%B %Y', $ts, false)));
             }
             $this->backAndForth($links);
             // END Specific Date Archives view
         } elseif ($serendipity['GET']['action'] == 'archives') {
             // Full month/year archives overview
             echo '<link rel="up" href="' . serendipity_rewriteURL(PATH_ARCHIVE) . '" title="' . ARCHIVES . '" />' . "\n";
             // END Full month/year archives overview
             echo '<link rel="canonical" href="' . $this->getArchiveParameters() . '" />' . "\n";
         } elseif (!empty($serendipity['GET']['category'])) {
             // Category based view
             $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']);
             if (function_exists('serendipity_categoryURL')) {
                 $categories_url = serendipity_categoryURL($cInfo, 'serendipityHTTPPath');
             } else {
                 $categories_url = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $cInfo['categoryid'], 'title' => $cInfo['category_name'])), 'serendipityHTTPPath');
             }
             echo '<link rel="up" href="' . $categories_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cInfo['category_name']) : htmlspecialchars($cInfo['category_name'], ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n";
             echo '<link rel="canonical" href="' . $categories_url . '" />' . "\n";
             $categories = serendipity_fetchCategories('all');
             $links = array();
             if (is_array($categories) && count($categories)) {
                 $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
                 $capture_next = false;
                 foreach ($categories as $cat) {
                     if ($capture_next) {
                         $links['next'] = $this->getCat($cat);
                         break;
                     }
                     if (is_array($prev_cat) && $cat['categoryid'] == $serendipity['GET']['category']) {
                         $links['prev'] = $this->getCat($prev_cat);
                         $capture_next = true;
                     }
                     $prev_cat = $cat;
                 }
             }
             $this->backAndForth($links);
             // END Category based view
         } elseif (!empty($serendipity['GET']['viewAuthor'])) {
             // User view
             $uInfo = serendipity_fetchUsers();
             $links = array();
             if (is_array($uInfo)) {
                 $capture_next = false;
                 foreach ($uInfo as $user) {
                     if ($capture_next) {
                         $links['next'] = $this->getUser($user);
                         break;
                     }
                     if ($user['authorid'] == $serendipity['GET']['viewAuthor']) {
                         $authors_url = $this->getUser($user);
                         echo '<link rel="up" href="' . $authors_url['link'] . '" title="' . $authors_url['title'] . '" />' . "\n";
                         echo '<link rel="canonical" href="' . $authors_url['link'] . '" />' . "\n";
                         if (is_array($prev_user)) {
                             $links['prev'] = $this->getUser($prev_user);
                             $capture_next = true;
                         }
                     }
                     $prev_user = $user;
                 }
                 $this->backAndForth($links);
             }
             // END User view
         } else {
             // Frontpage
             $this->backAndForth();
             // END Frontpage
             if ($serendipity['view'] == 'start') {
                 echo '<link rel="canonical" href="' . $serendipity['baseURL'] . '" />' . "\n";
             }
         }
     }
 }
Example #15
0
/**
 * Shows the entry panel overview
 *
 * Shows a list of existing entries, with pagination and cookie-remember settings.
 *
 * @access public
 * @return null
 */
function serendipity_drawList()
{
    global $serendipity, $sort_order, $per_page;
    $filter_import = array('author', 'category', 'isdraft');
    $sort_import = array('perPage', 'ordermode', 'order');
    foreach ($filter_import as $f_import) {
        serendipity_restoreVar($serendipity['COOKIE']['entrylist_filter_' . $f_import], $serendipity['GET']['filter'][$f_import]);
        serendipity_JSsetCookie('entrylist_filter_' . $f_import, $serendipity['GET']['filter'][$f_import]);
    }
    foreach ($sort_import as $s_import) {
        serendipity_restoreVar($serendipity['COOKIE']['entrylist_sort_' . $s_import], $serendipity['GET']['sort'][$s_import]);
        serendipity_JSsetCookie('entrylist_sort_' . $s_import, $serendipity['GET']['sort'][$s_import]);
    }
    $perPage = !empty($serendipity['GET']['sort']['perPage']) ? $serendipity['GET']['sort']['perPage'] : $per_page[0];
    $page = (int) $serendipity['GET']['page'];
    $offSet = $perPage * $page;
    if (empty($serendipity['GET']['sort']['ordermode']) || $serendipity['GET']['sort']['ordermode'] != 'ASC') {
        $serendipity['GET']['sort']['ordermode'] = 'DESC';
    }
    if (!empty($serendipity['GET']['sort']['order']) && !empty($sort_order[$serendipity['GET']['sort']['order']])) {
        $orderby = serendipity_db_escape_string($serendipity['GET']['sort']['order'] . ' ' . $serendipity['GET']['sort']['ordermode']);
    } else {
        $orderby = 'timestamp ' . serendipity_db_escape_string($serendipity['GET']['sort']['ordermode']);
    }
    $filter = array();
    if (!empty($serendipity['GET']['filter']['author'])) {
        $filter[] = "e.authorid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['author']) . "'";
    }
    if (!empty($serendipity['GET']['filter']['category'])) {
        $filter[] = "ec.categoryid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['category']) . "'";
    }
    if (!empty($serendipity['GET']['filter']['isdraft'])) {
        if ($serendipity['GET']['filter']['isdraft'] == 'draft') {
            $filter[] = "e.isdraft = 'true'";
        } elseif ($serendipity['GET']['filter']['isdraft'] == 'publish') {
            $filter[] = "e.isdraft = 'false'";
        }
    }
    if (!empty($serendipity['GET']['filter']['body'])) {
        if ($serendipity['dbType'] == 'mysql') {
            $filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($serendipity['GET']['filter']['body']) . "')";
            $full = true;
        }
    }
    $filter_sql = implode(' AND ', $filter);
    // Fetch the entries
    $entries = serendipity_fetchEntries(false, false, serendipity_db_limit($offSet, $perPage + 1), true, false, $orderby, $filter_sql);
    ?>
<div class="serendipity_admin_list">
<form action="?" method="get">
    <input type="hidden" name="serendipity[action]"      value="admin"      />
    <input type="hidden" name="serendipity[adminModule]" value="entries"    />
    <input type="hidden" name="serendipity[adminAction]" value="editSelect" />
    <table width="100%" class="serendipity_admin_filters">
        <tr>
            <td class="serendipity_admin_filters_headline" colspan="6"><strong><?php 
    echo FILTERS;
    ?>
</strong> - <?php 
    echo FIND_ENTRIES;
    ?>
</td>
        </tr>
        <tr>
            <td valign="top" width="80"><?php 
    echo AUTHOR;
    ?>
</td>
            <td valign="top">
                <select name="serendipity[filter][author]">
                    <option value="">--</option>
<?php 
    $users = serendipity_fetchUsers('', null, true);
    if (is_array($users)) {
        foreach ($users as $user) {
            if (isset($user['artcount']) && $user['artcount'] < 1) {
                continue;
            }
            echo '<option value="' . $user['authorid'] . '" ' . (isset($serendipity['GET']['filter']['author']) && $serendipity['GET']['filter']['author'] == $user['authorid'] ? 'selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n";
        }
    }
    ?>
              </select> <select name="serendipity[filter][isdraft]">
                    <option value="all"><?php 
    echo COMMENTS_FILTER_ALL;
    ?>
</option>
                    <option value="draft"   <?php 
    echo isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'draft' ? 'selected="selected"' : '';
    ?>
><?php 
    echo DRAFT;
    ?>
</option>
                    <option value="publish" <?php 
    echo isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'publish' ? 'selected="selected"' : '';
    ?>
><?php 
    echo PUBLISH;
    ?>
</option>
                </select>
            </td>
            <td valign="top" width="80"><?php 
    echo CATEGORY;
    ?>
</td>
            <td valign="top">
                <select name="serendipity[filter][category]">
                    <option value="">--</option>
<?php 
    $categories = serendipity_fetchCategories();
    $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
    foreach ($categories as $cat) {
        echo '<option value="' . $cat['categoryid'] . '"' . ($serendipity['GET']['filter']['category'] == $cat['categoryid'] ? ' selected="selected"' : '') . '>' . str_repeat('&nbsp;', $cat['depth']) . htmlspecialchars($cat['category_name']) . '</option>' . "\n";
    }
    ?>
              </select>
            </td>
            <td valign="top" width="80"><?php 
    echo CONTENT;
    ?>
</td>
            <td valign="top"><input class="input_textbox" size="10" type="text" name="serendipity[filter][body]" value="<?php 
    echo isset($serendipity['GET']['filter']['body']) ? htmlspecialchars($serendipity['GET']['filter']['body']) : '';
    ?>
" /></td>
        </tr>
        <tr>
            <td class="serendipity_admin_filters_headline" colspan="6"><strong><?php 
    echo SORT_ORDER;
    ?>
</strong></td>
        </tr>
        <tr>
            <td>
                <?php 
    echo SORT_BY;
    ?>
            </td>
            <td>
                <select name="serendipity[sort][order]">
<?php 
    foreach ($sort_order as $so_key => $so_val) {
        echo '<option value="' . $so_key . '" ' . (isset($serendipity['GET']['sort']['order']) && $serendipity['GET']['sort']['order'] == $so_key ? 'selected="selected"' : '') . '>' . $so_val . '</option>' . "\n";
    }
    ?>
              </select>
            </td>
            <td><?php 
    echo SORT_ORDER;
    ?>
</td>
            <td>
                <select name="serendipity[sort][ordermode]">
                    <option value="DESC" <?php 
    echo isset($serendipity['GET']['sort']['ordermode']) && $serendipity['GET']['sort']['ordermode'] == 'DESC' ? 'selected="selected"' : '';
    ?>
><?php 
    echo SORT_ORDER_DESC;
    ?>
</option>
                    <option value="ASC" <?php 
    echo isset($serendipity['GET']['sort']['ordermode']) && $serendipity['GET']['sort']['ordermode'] == 'ASC' ? 'selected="selected"' : '';
    ?>
><?php 
    echo SORT_ORDER_ASC;
    ?>
</option>
                </select>
            </td>
            <td><?php 
    echo ENTRIES_PER_PAGE;
    ?>
</td>
            <td>
                <select name="serendipity[sort][perPage]">
<?php 
    foreach ($per_page as $per_page_nr) {
        echo '<option value="' . $per_page_nr . '"   ' . (isset($serendipity['GET']['sort']['perPage']) && $serendipity['GET']['sort']['perPage'] == $per_page_nr ? 'selected="selected"' : '') . '>' . $per_page_nr . '</option>' . "\n";
    }
    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right" colspan="6"><input type="submit" name="go" value="<?php 
    echo GO;
    ?>
" class="serendipityPrettyButton input_button" /></td>
        </tr>
    </table>
    </form>

    <table class="serendipity_admin_list" cellpadding="5" width="100%">
<?php 
    if (is_array($entries)) {
        $count = count($entries);
        $qString = '?serendipity[adminModule]=entries&amp;serendipity[adminAction]=editSelect';
        foreach ((array) $serendipity['GET']['sort'] as $k => $v) {
            $qString .= '&amp;serendipity[sort][' . $k . ']=' . $v;
        }
        foreach ((array) $serendipity['GET']['filter'] as $k => $v) {
            $qString .= '&amp;serendipity[filter][' . $k . ']=' . $v;
        }
        $linkPrevious = $qString . '&amp;serendipity[page]=' . ($page - 1);
        $linkNext = $qString . '&amp;serendipity[page]=' . ($page + 1);
        ?>
        <tr>
            <td>
                <?php 
        if ($offSet > 0) {
            ?>
                    <a href="<?php 
            echo $linkPrevious;
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/previous.png');
            ?>
" /><?php 
            echo PREVIOUS;
            ?>
</a>
                <?php 
        }
        ?>
            </td>
            <td align="right">
                <?php 
        if ($count > $perPage) {
            ?>
                    <a href="<?php 
            echo $linkNext;
            ?>
" class="serendipityIconLinkRight"><?php 
            echo NEXT;
            ?>
<img src="<?php 
            echo serendipity_getTemplateFile('admin/img/next.png');
            ?>
" /></a>
                <?php 
        }
        ?>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
    function invertSelection() {
        var f = document.formMultiDelete;
        for (var i = 0; i < f.elements.length; i++) {
            if (f.elements[i].type == 'checkbox') {
                f.elements[i].checked = !(f.elements[i].checked);
            }
        }
    }
    </script>
    <form action="?" method="post" name="formMultiDelete" id="formMultiDelete">
        <?php 
        echo serendipity_setFormToken();
        ?>
        <input type="hidden" name="serendipity[action]" value="admin" />
        <input type="hidden" name="serendipity[adminModule]" value="entries" />
        <input type="hidden" name="serendipity[adminAction]" value="multidelete" />
<?php 
        // Print the entries
        $rows = 0;
        foreach ($entries as $entry) {
            $rows++;
            if ($rows > $perPage) {
                continue;
            }
            // Find out if the entry has been modified later than 30 minutes after creation
            if ($entry['timestamp'] <= $entry['last_modified'] - 60 * 30) {
                $lm = '<a href="#" title="' . LAST_UPDATED . ': ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['last_modified']) . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a>';
            } else {
                $lm = '';
            }
            if (!$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
                $entry_pre = '<a href="#" title="' . ENTRY_PUBLISHED_FUTURE . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock_future.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a> ';
            } else {
                $entry_pre = '';
            }
            if (serendipity_db_bool($entry['properties']['ep_is_sticky'])) {
                $entry_pre .= ' ' . STICKY_POSTINGS . ': ';
            }
            if (serendipity_db_bool($entry['isdraft'])) {
                $entry_pre .= ' ' . DRAFT . ': ';
            }
            ?>
<!--            <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
            echo $rows % 2 ? 'even' : 'uneven';
            ?>
"> -->
            <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
            echo $rows % 2 ? 'even' : 'uneven';
            ?>
">

                <table width="100%" cellspacing="0" cellpadding="3">
                    <tr>
                        <td>
                            <strong><?php 
            echo $entry_pre;
            ?>
<a href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="#<?php 
            echo $entry['id'];
            ?>
"><?php 
            echo serendipity_truncateString(htmlspecialchars($entry['title']), 50);
            ?>
</a></strong>
                        </td>
                        <td align="right">
                            <?php 
            echo serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ' ' . $lm;
            ?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <?php 
            echo POSTED_BY . ' ' . htmlspecialchars($entry['author']);
            if (count($entry['categories'])) {
                echo ' ' . IN . ' ';
                $cats = array();
                foreach ($entry['categories'] as $cat) {
                    $caturl = serendipity_categoryURL($cat);
                    $cats[] = '<a href="' . $caturl . '">' . htmlspecialchars($cat['category_name']) . '</a>';
                }
                echo implode(', ', $cats);
            }
            $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
            $entry['preview_link'] = '?serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=preview&amp;serendipity[id]=' . $entry['id'];
            ?>

                        </td>
                        <td align="right">
                            <?php 
            if (serendipity_db_bool($entry['isdraft']) || !$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
                ?>
                            <a target="_blank" href="<?php 
                echo $entry['preview_link'];
                ?>
" title="<?php 
                echo PREVIEW . ' #' . $entry['id'];
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo PREVIEW;
                ?>
" /><?php 
                echo PREVIEW;
                ?>
</a>
                            <?php 
            } else {
                ?>
                            <a target="_blank" href="<?php 
                echo $entry['link'];
                ?>
" title="<?php 
                echo VIEW . ' #' . $entry['id'];
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo VIEW;
                ?>
" /><?php 
                echo VIEW;
                ?>
</a>
                            <?php 
            }
            ?>
                            <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="<?php 
            echo EDIT . ' #' . $entry['id'];
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/edit.png');
            ?>
" alt="<?php 
            echo EDIT;
            ?>
" /><?php 
            echo EDIT;
            ?>
</a>
                            <a href="?<?php 
            echo serendipity_setFormToken('url');
            ?>
&amp;serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=delete&amp;serendipity[id]=<?php 
            echo $entry['id'];
            ?>
" title="<?php 
            echo DELETE . ' #' . $entry['id'];
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/delete.png');
            ?>
" alt="<?php 
            echo DELETE;
            ?>
" /><?php 
            echo DELETE;
            ?>
</a>
                            <input class="input_checkbox" type="checkbox" name="serendipity[multiDelete][]" value="<?php 
            echo $entry['id'];
            ?>
" />
                        </td>
                    </tr>
                </table>
            </div>
<?php 
        }
        // end entries output
        ?>
        <table class="serendipity_admin_list" cellpadding="5" width="100%">
            <tr>
                <td>
                    <?php 
        if ($offSet > 0) {
            ?>
                        <a href="<?php 
            echo $linkPrevious;
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/previous.png');
            ?>
" /><?php 
            echo PREVIOUS;
            ?>
</a>
                    <?php 
        }
        ?>
                </td>
                <td align="right">
                    <?php 
        if ($count > $perPage) {
            ?>
                        <a href="<?php 
            echo $linkNext;
            ?>
" class="serendipityIconLinkRight"><?php 
            echo NEXT;
            ?>
<img src="<?php 
            echo serendipity_getTemplateFile('admin/img/next.png');
            ?>
" /></a>
                    <?php 
        }
        ?>
                </td>
            </tr>
        </table>

        <table class="serendipity_admin_list" cellpadding="0" width="100%">
            <tr>
                <td align="right">
                    <input type="button" name="toggle" value="<?php 
        echo INVERT_SELECTIONS;
        ?>
" onclick="invertSelection()" class="serendipityPrettyButton input_button" />
                    <input type="submit" name="toggle" value="<?php 
        echo DELETE_SELECTED_ENTRIES;
        ?>
" class="serendipityPrettyButton input_button" />
                </td>
            </tr>
        </table>
        </form>

        <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php 
        echo ($rows + 1) % 2 ? 'even' : 'uneven';
        ?>
">
            <table width="100%" cellspacing="0" cellpadding="3">
                    <tr>
                        <td>
                            <form action="?" method="get">
                                <input type="hidden" name="serendipity[action]"      value="admin"      />
                                <input type="hidden" name="serendipity[adminModule]" value="entries"    />
                                <input type="hidden" name="serendipity[adminAction]" value="editSelect" />
                            <?php 
        echo EDIT_ENTRY;
        ?>
: #<input class="input_textbox" type="text" size="3" name="serendipity[id]" /> <input type="submit" name="serendipity[editSubmit]" value="<?php 
        echo GO;
        ?>
" class="serendipityPrettyButton input_button" />
                            </form>
                        </td>
                    </tr>
            </table>
        </div>
 <?php 
    } else {
        // We've got nothing
        ?>
        <tr>
            <td align="center" class="serendipityAdminMsgNote">
                <img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php 
        echo serendipity_getTemplateFile('admin/img/admin_msg_note.png');
        ?>
" alt="" />
                <?php 
        echo NO_ENTRIES_TO_PRINT;
        ?>
            </td>
        </tr>
    </table>
<?php 
    }
    ?>
</div>
<?php 
}
Example #16
0
             $tm = persian_mktime(0, 0, 0, $i, $day, $year);
             $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $tm), persian_date_utf('j', $tm), $year);
             $te = persian_mktime(23, 59, 59, persian_date_utf('m', $tm), persian_date_utf('j', $tm) + 7, $year);
             $date = serendipity_formatTime(WEEK . ' ' . $week . '، %Y', $ts, false);
         } else {
             if ($day) {
                 $ts = persian_mktime(0, 0, 0, $month, $day, $year);
                 $te = persian_mktime(23, 59, 59, $month, $day, $year);
                 $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false);
             } else {
                 $ts = persian_mktime(0, 0, 0, $month, $gday, $year);
                 if (!isset($gday2)) {
                     $gday2 = persian_date_utf('t', $ts);
                 }
                 $te = persian_mktime(23, 59, 59, $month, $gday2, $year);
                 $date = serendipity_formatTime('%B %Y', $ts, false);
             }
         }
         list($year, $month, $day) = p2g($year, $month, $day);
         break;
 }
 $serendipity['range'] = array($ts, $te);
 if ($serendipity['GET']['action'] == 'read') {
     if ($serendipity['GET']['category']) {
         $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']);
         $serendipity['head_title'] = $cInfo['category_name'];
     }
     $serendipity['head_subtitle'] .= sprintf(ENTRIES_FOR, $date);
 }
 ob_start();
 include S9Y_INCLUDE_PATH . 'include/genpage.inc.php';
 function print_entries(&$entries)
 {
     $extended = true;
     $preview = false;
     $addData = array('extended' => $extended, 'preview' => $preview, 'no_scramble' => true);
     serendipity_plugin_api::hook_event('entry_display', $entries, $addData);
     /* pre-walk the array to collect them keyed by date */
     $bydate = array();
     if (!is_array($entries) || $entries[0] == false) {
         return;
     }
     $lastDate = '';
     for ($x = 0, $num_entries = count($entries); $x < $num_entries; $x++) {
         $d = $this->prep_out(serendipity_formatTime(DATE_FORMAT_ENTRY, $entries[$x]['timestamp']));
         $bydate[$d][] = $entries[$x];
     }
     foreach ($bydate as $date => $ents) {
         $header = $date;
         foreach ($ents as $x => $entry) {
             $this->print_entry($x, $entry, $header);
             $header = false;
         }
         // end for-loop (entries)
     }
     // end for-loop (dates)
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'backend_publish':
                case 'backend_save':
                    // Purge, so that the data within the entry takes precedence over other changes
                    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}wikireferences WHERE entryid = " . (int) $eventData['id']);
                    break;
                case 'backend_sidebar_entries':
                    $this->setupDB();
                    echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=wikireferences">' . PLUGIN_EVENT_WIKILINKS_MAINT . '</a></li>';
                    break;
                case 'backend_sidebar_entries_event_display_wikireferences':
                    $entries = serendipity_db_query("SELECT id, refname FROM {$serendipity['dbPrefix']}wikireferences ORDER BY refname ASC");
                    echo '<p>' . PLUGIN_EVENT_WIKILINKS_MAINT_DESC . '</p>';
                    echo '<form action="serendipity_admin.php" method="post" name="serendipityEntry">';
                    echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />';
                    echo '<input type="hidden" name="serendipity[adminAction]" value="wikireferences" />';
                    echo '<select name="serendipity[wikireference]">';
                    echo '<option value="">...</option>';
                    foreach ((array) $entries as $idx => $row) {
                        echo '<option value="' . $row['id'] . '" ' . ($row['id'] == $serendipity['POST']['wikireference'] ? 'selected="selected"' : '') . '>' . $row['refname'] . '</option>' . "\n";
                    }
                    echo '</select>';
                    echo '<input type="submit" class="serendipityPrettyButton input_button" name="serendipity[typeSubmit]" value="' . GO . '" />';
                    echo '<br /><br />';
                    if ($serendipity['POST']['wikireference'] > 0) {
                        if ($serendipity['POST']['saveSubmit']) {
                            serendipity_db_update('wikireferences', array('id' => $serendipity['POST']['wikireference']), array('refname' => $serendipity['POST']['wikireference_refname'], 'ref' => $serendipity['POST']['wikireference_ref']));
                            echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>';
                        }
                        $ref = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}wikireferences WHERE id = " . (int) $serendipity['POST']['wikireference'], true, 'assoc');
                        $entry = serendipity_fetchEntry('id', $ref['entryid']);
                        echo '<div>';
                        echo '<label>' . PLUGIN_EVENT_WIKILINKS_DB_REFNAME . '</label><br />';
                        echo '<input type="text" name="serendipity[wikireference_refname]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($ref['refname']) : htmlspecialchars($ref['refname'], ENT_COMPAT, LANG_CHARSET)) . '" />';
                        echo '<input type="submit" class="serendipityPrettyButton input_button" name="serendipity[saveSubmit]" value="' . SAVE . '" />';
                        echo '</div>';
                        echo '<div>';
                        echo '<label>' . PLUGIN_EVENT_WIKILINKS_DB_REF . '</label><br />';
                        echo '<textarea cols="80" rows="20" name="serendipity[wikireference_ref]">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($ref['ref']) : htmlspecialchars($ref['ref'], ENT_COMPAT, LANG_CHARSET)) . '</textarea>';
                        echo '</div>';
                        echo '<div>';
                        echo '<label>' . PLUGIN_EVENT_WIKILINKS_DB_ENTRYDID . '</label>';
                        echo '<a href="' . serendipity_archiveUrl($ref['entryid'], $entry['title']) . '">' . $entry['title'] . '</a>';
                        echo '<p><a class="serendipityPrettyButton" href="?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=' . $entry['id'] . '">' . EDIT_ENTRY . '</a></p>';
                        echo '</div>';
                    }
                    echo '</form>';
                    break;
                case 'frontend_display':
                    $this->out_references = array();
                    foreach ($this->markup_elements as $temp) {
                        if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
                            $element = $temp['element'];
                            $is_body = false;
                            if ($element == 'body' || $element == 'extended') {
                                $source =& $this->getFieldReference($element, $eventData);
                                if ($source === '') {
                                    // Prevent bug from serendipity 0.9
                                    $source =& $eventData[$element];
                                }
                                $is_body = true;
                            } else {
                                $source =& $eventData[$element];
                            }
                            $this->references = $this->refcount = array();
                            $this->ref_entry = $eventData['id'];
                            $source = preg_replace_callback('^' . $this->get_config('reference_match') . '^imsU', array($this, '_reference'), $source);
                            $source = preg_replace_callback("#(\\[\\[|\\(\\(|\\{\\{)(.+)(\\]\\]|\\)\\)|\\}\\})#isUm", array($this, '_wikify'), $source);
                            $source .= $this->reference_parse();
                            if ($is_body) {
                                if (!is_array($eventData['properties']['references'])) {
                                    $eventData['properties']['references'] = array();
                                }
                                $eventData['properties']['references'] += $this->references;
                            }
                        }
                    }
                    return true;
                    break;
                case 'external_plugin':
                    $what = '';
                    if ($eventData == 'popup_choose_entry') {
                        $what = 'body';
                    } elseif ($eventData == 'popup_choose_entrybody') {
                        $what = 'body';
                    } elseif ($eventData == 'popup_choose_entryextended') {
                        $what = 'extended';
                    } elseif (preg_match('/^popup_choose_entry(.*)$/i', $eventData, $matches)) {
                        // get the custom thing that is to be selected, for example a nugget
                        $what = $matches[1];
                    }
                    if (empty($what)) {
                        return false;
                    }
                    ?>
<html>
    <head>
        <title><?php 
                    echo PLUGIN_EVENT_WIKILINKS_LINKENTRY;
                    ?>
</title>
        <meta http-equiv="Content-Type" content="text/html; charset=<?php 
                    echo LANG_CHARSET;
                    ?>
" />
        <link rel="stylesheet" type="text/css" href="<?php 
                    echo 'serendipity.css.php?serendipity[css_mode]=serendipity_admin.css';
                    ?>
" />
        <link rel="stylesheet" type="text/css" href="<?php 
                    echo serendipity_getTemplateFile('admin/pluginmanager.css');
                    ?>
" />
    </head>

<body id="serendipity_admin_page">
<div id="serendipityAdminFrame">
    <div id="serendipityAdminBanner">
        <h1><?php 
                    echo SERENDIPITY_ADMIN_SUITE;
                    ?>
</h1>
        <h2><?php 
                    echo PLUGIN_EVENT_WIKILINKS_LINKENTRY_DESC;
                    ?>
</h2>
    </div>
    <div id="serendipityAdminContent">

        <ul>
<?php 
                    $sql = "SELECT *\n              FROM {$serendipity['dbPrefix']}entries\n          ORDER BY timestamp DESC";
                    $e = serendipity_db_query($sql);
                    if (is_array($e)) {
                        foreach ($e as $entry) {
                            $link = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
                            $jslink = "'<a href=\\'{$link}\\'>" . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . "<' + '/a>'";
                            echo '<li style="margin-bottom: 10px">' . '<a href="javascript:parent.self.opener.use_link_' . $what . '(' . $jslink . '); self.close();" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '"><strong>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '</strong></a> (<a href="' . $link . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">#' . $entry['id'] . '</a>)<br />' . POSTED_BY . ' ' . $entry['author'] . ' ' . ON . ' ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ($entry['isdraft'] != 'false' ? ' (' . DRAFT . ')' : '') . '</a></li>' . "\n";
                        }
                    }
                    ?>
        </ul>
    </div>
</div>
</body>
</html>
<?php 
                    return true;
                case 'backend_entry_toolbar_extended':
                    if (!isset($txtarea)) {
                        $txtarea = 'serendipity[extended]';
                        $func = 'extended';
                    }
                case 'backend_entry_toolbar_body':
                    if (!isset($txtarea)) {
                        if (isset($eventData['backend_entry_toolbar_body:textarea'])) {
                            // event caller has given us the name of the textarea converted
                            // into a wysiwg editor(for example, the staticpages plugin)
                            $txtarea = $eventData['backend_entry_toolbar_body:textarea'];
                        } else {
                            // default value
                            $txtarea = 'serendipity[body]';
                        }
                        if (isset($eventData['backend_entry_toolbar_body:nugget'])) {
                            $func = $eventData['backend_entry_toolbar_body:nugget'];
                        } else {
                            $func = 'body';
                        }
                    }
                    // CKEDITOR needs this little switch
                    if (preg_match('@^nugget@i', $func)) {
                        $cke_txtarea = $func;
                    } else {
                        $cke_txtarea = $txtarea;
                    }
                    if (!isset($popcl)) {
                        $popcl = ' serendipityPrettyButton';
                    }
                    if (!isset($style)) {
                        $style = 'text-align: right; margin-top: 5px';
                    }
                    ?>
<script type="text/javascript">
<!--
function use_link_<?php 
                    echo $func;
                    ?>
(txt) {

    // use the shared insert function instead of the wikilinks provided function
    // the shared JS function implements all the wikilinks functionality + NO WYSIWYG insertion
    serendipity_imageSelector_addToBody(txt, '<?php 
                    echo $func;
                    ?>
' );
    return;

    if(typeof(CKEDITOR) != 'undefined') {
        var oEditor = CKEDITOR.instances['<?php 
                    echo $cke_txtarea;
                    ?>
'];
        oEditor.insertHtml(txt);
    } else if(typeof(FCKeditorAPI) != 'undefined') {
        var oEditor = FCKeditorAPI.GetInstance('<?php 
                    echo $txtarea;
                    ?>
') ;
        oEditor.InsertHtml(txt);
    } else if(typeof(xinha_editors) != 'undefined') {
        if(typeof(xinha_editors['<?php 
                    echo $txtarea;
                    ?>
']) != 'undefined') {
            // this is good for the two default editors (body & extended)
            xinha_editors['<?php 
                    echo $txtarea;
                    ?>
'].insertHTML(txt);
        } else if(typeof(xinha_editors['<?php 
                    echo $func;
                    ?>
']) != 'undefined') {
            // this should work in any other cases than previous one
            xinha_editors['<?php 
                    echo $func;
                    ?>
'].insertHTML(txt);
        } else {
            // this is the last chance to retrieve the instance of the editor !
            // editor has not been registered by the name of it's textarea
            // so we must iterate over editors to find the good one
            for (var editorName in xinha_editors) {
                if('<?php 
                    echo $txtarea;
                    ?>
' == xinha_editors[editorName]._textArea.name) {
                    xinha_editors[editorName].insertHTML(txt);
                    return;
                }
            }
            // not found ?!?
        }
    } else if(typeof(HTMLArea) != 'undefined') {
        if(typeof(editor<?php 
                    echo $func;
                    ?>
) != 'undefined')
            editor<?php 
                    echo $func;
                    ?>
.insertHTML(txt);
        else if(typeof(htmlarea_editors) != 'undefined' && typeof(htmlarea_editors['<?php 
                    echo $func;
                    ?>
']) != 'undefined')
            htmlarea_editors['<?php 
                    echo $func;
                    ?>
'].insertHTML(txt);
    } else if(typeof(TinyMCE) != 'undefined') {
        //tinyMCE.execCommand('mceInsertContent', false, txt);
        tinyMCE.execInstanceCommand('<?php 
                    echo $txtarea;
                    ?>
', 'mceInsertContent', false, txt);
    } else  {
        // default case: no wysiwyg editor
        txtarea = document.getElementById('<?php 
                    echo $txtarea;
                    ?>
');
        if (txtarea.createTextRange && txtarea.caretPos) {
            caretPos = txtarea.caretPos;
            caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + ' ' + txt + ' ' : caretPos.text + ' ' + txt + ' ';
        } else {
            txtarea.value  += ' ' + txt + ' ';
        }

        // alert(obj);
        txtarea.focus();
    }
}
//-->
</script>
<?php 
                    echo '<input type="button" class="serendipityPrettyButton input_button" onclick="entrypopup = window.open(\'' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?/plugin/popup_choose_entry' . $func . '\', \'js_entrypopup\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\')" value="' . PLUGIN_EVENT_WIKILINKS_LINKENTRY . '" />';
                    return true;
                default:
                    return false;
            }
        } else {
            return false;
        }
    }