}
        $success = serendipity_updertEntry(array('id' => serendipity_specialchars($serendipity['POST']['id']), 'timestamp' => time(), 'isdraft' => 0));
        if (is_numeric($success)) {
            $data['published'] = $success;
        } else {
            $data['error_publish'] = $success;
        }
        break;
    case 'updateCheckDisable':
        if (!serendipity_checkFormToken() || !serendipity_checkPermission('blogConfiguration')) {
            break;
        }
        serendipity_set_config_var('updateCheck', false);
        break;
}
$user = serendipity_fetchAuthor($serendipity['authorid']);
// chrome-compatible, from Oliver Gassner, adapted from TextPattern. Hi guys, keep it up. :-)
$bookmarklet = "javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='" . $serendipity['baseURL'] . "',l=d.location,e=encodeURIComponent,p='serendipity_admin.php?serendipity[adminModule]=entries&serendipity[adminAction]=new&serendipity[title]='+e(d.title)+'&serendipity[body]='+e(s)+'&serendipity[url]='+location.href,u=f+p;a=function(){%20%20if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=800,height=800'))%20%20%20%20l.href=u;};if(/Firefox/.test(navigator.userAgent))%20%20setTimeout(a,0);else%20%20a();void(0)";
$data['bookmarklet'] = $bookmarklet;
$data['username'] = $user[0]['realname'];
$data['js_failure_file'] = serendipity_getTemplateFile('admin/serendipity_editor.js');
$output = array();
serendipity_plugin_api::hook_event('backend_frontpage_display', $output);
$data['backend_frontpage_display'] = $output['more'];
$data['usedVersion'] = $serendipity['version'];
$data['updateCheck'] = $serendipity['updateCheck'];
$data['curVersion'] = serendipity_getCurrentVersion();
$data['update'] = version_compare($data['usedVersion'], $data['curVersion'], '<');
serendipity_plugin_api::hook_event('plugin_dashboard_updater', $output, $data['curVersion']);
$data['updateButton'] = $output;
// Can be set through serendipity_config_local.inc.php
Exemple #2
0
        if (isset($_GET['all']) && $_GET['all']) {
            // Fetch all entries in reverse order for later importing. Fetch sticky entries as normal entries.
            $entries = serendipity_fetchEntries(null, true, '', false, false, 'id ASC', '', false, true);
        } else {
            $entries = serendipity_fetchEntries(null, true, $serendipity['RSSfetchLimit'], false, isset($modified_since) ? $modified_since : false, 'timestamp DESC', '', false, true);
        }
        break;
}
if (isset($serendipity['serendipityRealname'])) {
    $title .= ' (' . LOGIN . ': ' . $serendipity['serendipityRealname'] . ')';
}
if (!empty($serendipity['GET']['category'])) {
    $cInfo = serendipity_fetchCategoryInfo((int) $serendipity['GET']['category']);
    $title = serendipity_utf8_encode(htmlspecialchars($title . ' - ' . $cInfo['category_name']));
} elseif (!empty($serendipity['GET']['viewAuthor'])) {
    list($aInfo) = serendipity_fetchAuthor((int) $serendipity['GET']['viewAuthor']);
    $title = serendipity_utf8_encode(htmlspecialchars($aInfo['realname'] . ' - ' . $title));
} else {
    $title = serendipity_utf8_encode(htmlspecialchars($title));
}
$description = serendipity_utf8_encode(htmlspecialchars($description));
$metadata = array('title' => $title, 'description' => $description, 'language' => $serendipity['lang'], 'additional_fields' => array(), 'link' => $serendipity['baseURL'], 'email' => $serendipity['blogMail'], 'fullFeed' => false, 'showMail' => false, 'version' => $version);
if (!defined('S9Y_FRAMEWORK_PLUGIN_API')) {
    include S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
}
$plugins = serendipity_plugin_api::enum_plugins();
if (is_array($plugins)) {
    // load each plugin to make some introspection
    foreach ($plugins as $plugin_data) {
        if (preg_match('|@serendipity_syndication_plugin|', $plugin_data['name'])) {
            $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']);
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'css':
                    if (strpos($eventData, '.serendipityAuthorProfile')) {
                        // class exists in CSS, so a user has customized it and we don't need default
                        return true;
                    }
                    ?>
.serendipityAuthorProfile {
    border: 1px solid #909090;
    width: 300px;
    margin-top: 5px;
    margin-bottom: 5px;
    margin-left: auto;
    margin-right: auto;
    padding: 10px;
}

.serendipityAuthorProfile dt {
    margin-top: 5px;
    font-weight: bold;
}

.serendipityAuthorProfile dd {
    margin-bottom: 5px;
}
.serendipity_authorpic {
    float: right;
    margin: 5px;
    border: 0px;
    display: block;
}

.serendipity_commentcount {
    float: right;
}
<?php 
                    return true;
                    break;
                case 'css_backend':
                    // do use in 2.0+ versions
                    if ($serendipity['version'][0] > 1) {
                        ?>

/* userprofiles plugin ------------- */
.userprofileform { margin-top: 1.5em; }

<?php 
                    }
                    break;
                case 'entries_header':
                    if (!empty($serendipity['GET']['viewAuthor'])) {
                        $tfile = serendipity_getTemplateFile('plugin_userprofile.tpl', 'serendipityPath');
                        if (!$tfile) {
                            $tfile = dirname(__FILE__) . '/plugin_userprofile.tpl';
                        }
                        $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
                        $serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
                        $profile = $this->getConfigVars($serendipity['GET']['viewAuthor']);
                        $local_properties =& $this->getLocalProperties();
                        foreach ($local_properties as $property => $info) {
                            $profile[$property] = $GLOBALS['uInfo'][0][$property];
                        }
                        $properties = array();
                        $properties = array_merge($this->properties, $this->option_properties);
                        $entry = array('body' => $profile['hobbies']);
                        serendipity_plugin_api::hook_event('frontend_display', $entry);
                        $profile['hobbies'] = $entry['body'];
                        $serendipity['smarty']->assign('userProfile', $profile);
                        $serendipity['smarty']->assign('userProfileProperties', $properties);
                        $serendipity['smarty']->assign('userProfileLocalProperties', $local_properties);
                        $serendipity['smarty']->assign('userProfileTitle', PLUGIN_EVENT_USERPROFILES_SHOW);
                        $content = $serendipity['smarty']->fetch('file:' . $tfile);
                        $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
                        echo $content;
                    }
                    $this->show();
                    break;
                case 'backend_sidebar_entries_event_display_profiles':
                    $this->checkSchema();
                    $this->showUsers();
                    return true;
                    break;
                case 'backend_sidebar_admin':
                    echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuUserManagement"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=profiles">' . PLUGIN_EVENT_USERPROFILES_TITLE . '</a></li>';
                    return true;
                    break;
                case 'genpage':
                    $args = implode('/', serendipity_getUriArguments($eventData, true));
                    if ($serendipity['rewrite'] != 'none') {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                    } else {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                    }
                    if (empty($serendipity['GET']['subpage'])) {
                        $serendipity['GET']['subpage'] = $nice_url;
                    }
                    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);
                        }
                    }
                    if (version_compare($serendipity['version'], '0.7.1', '<=')) {
                        $this->show();
                    }
                    return true;
                    break;
                case 'frontend_display':
                    if ($bag->get('scrambles_true_content') && is_array($addData) && isset($addData['no_scramble'])) {
                        return true;
                    }
                case 'frontend_display_cache':
                    $this->showCommentcount($eventData);
                    if (!serendipity_db_bool($this->get_config('authorpic'))) {
                        return true;
                    }
                    if (empty($eventData['author'])) {
                        $tmp = serendipity_fetchAuthor($eventData['authorid']);
                        $author = $tmp[0]['realname'];
                    } else {
                        $author = $eventData['author'];
                    }
                    $authorname = $author;
                    if (isset($GLOBALS['i18n_filename_to'])) {
                        $author = str_replace($GLOBALS['i18n_filename_from'], $GLOBALS['i18n_filename_to'], $author);
                    }
                    if (serendipity_db_bool($this->get_config('gravatar'))) {
                        $img = 'http://www.gravatar.com/avatar.php?' . 'default=' . $this->get_config('gravatar_default', '80') . '&amp;gravatar_id=' . md5($eventData['email']) . '&amp;size=' . $this->get_config('gravatar_size', '80') . '&amp;border=&amp;rating=' . $this->get_config('gravatar_rating', 'R');
                        $this->found_images[$author] = '<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($authorname) : htmlspecialchars($authorname, ENT_COMPAT, LANG_CHARSET)) . '" /><br /><span>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($authorname) : htmlspecialchars($authorname, ENT_COMPAT, LANG_CHARSET)) . '</span></div>';
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } elseif (isset($this->found_images[$author])) {
                        // Author image was already found previously. Display it.
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } elseif ($img = serendipity_getTemplateFile('img/' . preg_replace('@[^a-z0-9]@i', '_', $author) . '.' . $this->get_config('extension'))) {
                        // Author image exists, save it in cache and display it.
                        $this->found_images[$author] = '<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($authorname) : htmlspecialchars($authorname, ENT_COMPAT, LANG_CHARSET)) . '" /><br /><span>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($authorname) : htmlspecialchars($authorname, ENT_COMPAT, LANG_CHARSET)) . '</span></div>';
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } else {
                        // No image found, do not try again in next article.
                        $this->found_images[$author] = '';
                    }
                    // Assign smarty variable {$entry.authorpic}
                    $eventData['authorpic'] = $this->found_images[$author];
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
 function doEntryWork(&$mt_entry, &$tasks)
 {
     global $serendipity;
     $authors = array();
     $entry = array();
     $entry['categories'] = array();
     $entryprops = array();
     $this->debug("doEntryWork: " . print_r($mt_entry, true));
     foreach ($mt_entry as $name => $data) {
         $name = trim($name);
         if (is_string($data)) {
             $data = trim($data);
         }
         $this->debug($name . ': "' . print_r($data, true) . '"');
         switch ($name) {
             case 's9y_comments':
                 $entry['s9y_comments'] = $data;
                 break;
             case 'AUTHOR':
                 if (!isset($authors[$data])) {
                     $au_inf = serendipity_fetchAuthor($data);
                     if (!is_array($au_inf)) {
                         $tasks[] = sprintf(CREATE_AUTHOR, htmlspecialchars($data));
                         $tasks[] = 'Input array is: ' . print_r($data, true) . '<br />Return is: ' . print_r($au_inf, true) . '<br />';
                         $au_inf = serendipity_fetchAuthor($serendipity['authorid']);
                     }
                     $authors[$data] = $au_inf[0];
                 }
                 $entry['authorid'] = $authors[$data]['authorid'];
                 $entry['author'] = $authors[$data]['username'];
                 break;
             case 'TITLE':
                 $entry['title'] = $data;
                 break;
             case 'STATUS':
                 $entry['isdraft'] = $data == 'Publish' ? 'false' : 'true';
                 break;
             case 'ALLOW COMMENTS':
                 $entry['allow_comments'] = $data == '1' ? 'true' : 'false';
                 break;
             case 'DATE':
                 $entry['timestamp'] = $this->totime($data);
                 break;
             case 's9y_body':
             case 'BODY':
                 $entry['body'] = $data;
                 break;
             case 's9y_extended':
             case 'EXTENDED BODY':
                 $entry['extended'] = $data;
                 break;
             case 'CONVERT BREAKS':
                 $entryprops['nl2br'] = $data == '1' ? true : false;
                 break;
             case 'PRIMARY CATEGORY':
             case 'CATEGORY':
                 $categories = explode("", $data);
                 #echo '<pre>' . print_r($this->categories, true) . '</pre>';
                 foreach ($categories as $data) {
                     $data = trim($data);
                     $cat_found = false;
                     if (is_array($this->categories)) {
                         for ($y = 0; $y < sizeof($this->categories); $y++) {
                             echo '"' . $this->categories[$y]['category_name'] . '" == "' . $data . '"<br />';
                             if ($this->categories[$y]['category_name'] == $data) {
                                 $cat_found = true;
                                 break;
                             }
                         }
                         if ($cat_found) {
                             if (!in_array($this->categories[$y]['categoryid'], $entry['categories'])) {
                                 //$entries[$n]['categories'][] = $categories[$y]['categoryid'];
                                 $entry['categories'][] = $this->categories[$y]['categoryid'];
                             }
                         } else {
                             $tasks[] = sprintf(CREATE_CATEGORY, htmlspecialchars($data));
                         }
                     }
                 }
                 break;
         }
     }
     $entry['props'] = $entryprops;
     return $entry;
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        static $state, $locked;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'css_backend':
                    echo ".entrylock { margin: 15px auto 15px auto; width: auto; text-align: center; padding: 5px; border: 1px solid yellow; }\n                          .entrylock a.serendipityPrettyButton { margin: 15px} \n";
                    return true;
                    break;
                case 'backend_entryform':
                    if (!isset($eventData['id']) || $eventData['id'] < 1) {
                        return true;
                    }
                    $time = time();
                    $state = 'unlocked';
                    if (serendipity_db_bool($this->get_config('locking'))) {
                        $this->checkLock($state, $eventData['id']);
                        if ($state == 'unlocked') {
                            // Entry is not yet locked
                            serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entryproperties (property, value, entryid) VALUES ('locked', '{$time}', {$eventData['id']})");
                            serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entryproperties (property, value, entryid) VALUES ('lock_owner', '{$serendipity['authorid']}', {$eventData['id']})");
                            $locked = array('lock_owner' => $serendipity['authorid'], 'locked' => $time);
                        }
                        $owner = serendipity_fetchAuthor($locked['lock_owner']);
                        $link = '<a href="serendipity_admin.php?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=' . (int) $eventData['id'] . '&amp;serendipity[unlock]=true" class="serendipityPrettyButton">' . PLUGIN_EVENT_ENTRYCHECK_UNLOCK . '</a>';
                        printf('<div class="entrylock">' . PLUGIN_EVENT_ENTRYCHECK_LOCKED . ' ' . $link . '</div>', $owner[0]['realname'], serendipity_strftime(DATE_FORMAT_SHORT, $locked['locked']));
                    }
                    return true;
                    break;
                case 'backend_entry_updertEntry':
                    if (serendipity_db_bool($this->get_config('emptyCategories') == true) && count($addData['categories']) < 1 || $addData['categories'][0] == '0') {
                        $eventData[] = PLUGIN_EVENT_ENTRYCHECK_EMPTYCATEGORIES_WARNING;
                    }
                    if (serendipity_db_bool($this->get_config('emptyTitle') == true) && strlen($addData['title']) < 1) {
                        $eventData[] = PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_WARNING;
                    }
                    if (serendipity_db_bool($this->get_config('emptyBody') == true) && strlen($addData['body']) < 1) {
                        $eventData[] = PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_WARNING;
                    }
                    if (serendipity_db_bool($this->get_config('emptyExtended') == true) && strlen($addData['extended']) < 1) {
                        $eventData[] = PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_WARNING;
                    }
                    if ($addData['id'] > 0 && serendipity_db_bool($this->get_config('locking'))) {
                        $state = 'unlocked';
                        if (!$this->checkLock($state, $addData['id'])) {
                            $eventData[] = PLUGIN_EVENT_ENTRYCHECK_LOCK_WARNING;
                        }
                    }
                    return true;
                    break;
                case 'backend_entry_checkSave':
                    // Emit JavaScript
                    ?>
                        if (document.getElementById) {
                            <?php 
                    if ($state == 'locked' && $locked['lock_owner'] != $serendipity['authorid']) {
                        ?>
                            alert('<?php 
                        echo str_replace("'", "\\'", PLUGIN_EVENT_ENTRYCHECK_LOCK_WARNING);
                        ?>
');
                            error = true;
                            <?php 
                    }
                    ?>

                            defaultcat = '<?php 
                    echo $this->get_config('defaultCat');
                    ?>
';
                            el = document.getElementById('categoryselector');
                            empty_category = false;
                            if (el.options[0].selected) {
                                empty_category = true;
                            }

                            for (i = 1; i < el.options.length; i++) {
                                if (el.options[i].selected) {
                                    empty_category = false;
                                }
                            }

                            error = false;
                            if (empty_category) {
                                showerror = true;
                                if (defaultcat != 'none' && defaultcat != '') {
                                    for (i = 1; i < el.options.length; i++) {
                                        if (el.options[i].value == defaultcat) {
                                            el.options[i].selected = true;
                                            showerror = false;
                                            el.selectedIndex = i;
                                        }
                                    }
                                }

<?php 
                    if (serendipity_db_bool($this->get_config('emptyCategories'))) {
                        ?>
                                if (showerror) {
                                    alert('<?php 
                        echo str_replace("'", "\\'", PLUGIN_EVENT_ENTRYCHECK_EMPTYCATEGORIES_WARNING);
                        ?>
');
                                    error = true;
                                }
<?php 
                    }
                    ?>
                            }

                            <?php 
                    if (serendipity_db_bool($this->get_config('emptyTitle')) == true) {
                        ?>
                            if (document.getElementById('entryTitle').value.length < 1) {
                                alert('<?php 
                        echo str_replace("'", "\\'", PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_WARNING);
                        ?>
');
                                error = true;
                            }
                            <?php 
                    }
                    ?>

                            <?php 
                    if (serendipity_db_bool($this->get_config('emptyBody')) == true) {
                        ?>
                            if (typeof(editorbody) != "undefined") {
                                editorbody.setMode('textmode');
                                var serendipitybody = document.getElementById('serendipity[body]').value.replace(/(<([^>]+)>)/ig,"");
                            } else {
                                var serendipitybody = document.getElementById('serendipity[body]').value;
                            }
                            if (serendipitybody.length < 1) {
                                alert('<?php 
                        echo str_replace("'", "\\'", PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_WARNING);
                        ?>
');
                                error = true;
                            }
                            if (typeof(editorbody) != "undefined") {
                                editorbody.setMode('wysiwyg');
                            }
                            <?php 
                    }
                    ?>

                            <?php 
                    if (serendipity_db_bool($this->get_config('emptyExtended')) == true) {
                        ?>
                            if (typeof(editorextended) != "undefined") {
                                editorextended.setMode('textmode');
                                var serendipityextended = document.getElementById('serendipity[extended]').value.replace(/(<([^>]+)>)/ig,"");
                            } else {
                                var serendipityextended = document.getElementById('serendipity[extended]').value;
                            }
                            if (serendipityextended.length < 1) {
                                alert('<?php 
                        echo str_replace("'", "\\'", PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_WARNING);
                        ?>
');
                                error = true;
                            }
                            if (typeof(editorextended) != "undefined") {
                                editorextended.setMode('wysiwyg');
                            }
                            <?php 
                    }
                    ?>

                            if (error) {
                                return false;
                            }
                        }
<?php 
                    return true;
                    break;
            }
        } else {
            return false;
        }
    }