本文整理汇总了PHP中serendipity_plugin_api类的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_plugin_api类的具体用法?PHP serendipity_plugin_api怎么用?PHP serendipity_plugin_api使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了serendipity_plugin_api类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanup
function cleanup()
{
$err = false;
$bugp = $this->get_config('bugpath');
$path = $this->get_config('path');
// allow numeric client ID only
if ($err = preg_match("/^[^0-9]+\$/", $this->get_config('client_id'))) {
printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_CID_ERROR, S9YPOT_ERR_END);
}
// webbug path must be absolute, no trailing slash
if (!empty($bugp) && ($err = !preg_match("/^http(.*)[^\\/]\$/", $bugp))) {
printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_BUGURL_ERROR, S9YPOT_ERR_END);
}
// path must be absolute, no trailing slash
if (!empty($path) && ($err = !preg_match("/^[\\/].*[^\\/]\$/", $path))) {
printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_PATH_ERROR, S9YPOT_ERR_END);
}
// check for an existing POT installation
$location = sprintf("%s/%s", $this->get_config('path'), $this->get_config('fname'));
if (!empty($path) && ($err = !file_exists($location))) {
printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_FNAME_ERROR, S9YPOT_ERR_END);
}
// s9y plugin error messaging is quite sub-optimal, print explanation what happened
// reset all config values so nothing gets logged using a wrong client ID (logging will fail due to wrong path)
if ($err || empty($bugp) && empty($path)) {
$this->set_config('client_id', S9YPOT_DEFAULT_CID);
$this->set_config('path', S9YPOT_DEFAULT_PATH);
$this->set_config('fname', S9YPOT_DEFAULT_FNAME);
$this->set_config('bugpath', S9YPOT_BUGDEFAULT_FNAME);
printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_ERR_RESET, S9YPOT_ERR_END);
}
serendipity_plugin_api::remove_plugin_value($this->instance, array('path', 'fname', 'client_id', 'bugpath'));
}
示例2: generate_content
function generate_content(&$title)
{
global $serendipity;
$title = $this->title;
$fullentry = serendipity_db_bool($this->get_config('fullentry', 'true'));
?>
<form id="searchform" action="<?php
echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'];
?>
" method="get">
<div>
<input type="hidden" name="serendipity[action]" value="search" />
<input type="hidden" name="serendipity[fullentry]" value="<?php
echo $fullentry;
?>
" />
<input type="text" id="serendipityQuickSearchTermField" name="serendipity[searchTerm]" size="13" />
<input class="quicksearch_submit" type="submit" value=">" name="serendipity[searchButton]" title="<?php
echo GO;
?>
" style="width: 2em;" />
</div>
<div id="LSResult" style="display: none;"><div id="LSShadow"></div></div>
</form>
<?php
serendipity_plugin_api::hook_event('quicksearch_plugin', $serendipity);
}
示例3: generate_content
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title', $this->title);
$eventData = array('display_dat' => '');
serendipity_plugin_api::hook_event('frontend_display:html_layout', $eventData);
echo $eventData['display_dat'];
}
示例4: showSearch
function showSearch()
{
global $serendipity;
$this->setupDB();
$term = serendipity_db_escape_string($serendipity['GET']['searchTerm']);
if ($serendipity['dbType'] == 'postgres') {
$group = '';
$distinct = 'DISTINCT';
$find_part = "(c.title ILIKE '%{$term}%' OR c.body ILIKE '%{$term}%')";
} elseif ($serendipity['dbType'] == 'sqlite') {
$group = 'GROUP BY id';
$distinct = '';
$term = serendipity_mb('strtolower', $term);
$find_part = "(lower(c.title) LIKE '%{$term}%' OR lower(c.body) LIKE '%{$term}%')";
} else {
$group = 'GROUP BY id';
$distinct = '';
$term = str_replace('"', '"', $term);
if (preg_match('@["\\+\\-\\*~<>\\(\\)]+@', $term)) {
$find_part = "MATCH(c.title,c.body) AGAINST('{$term}' IN BOOLEAN MODE)";
} else {
$find_part = "MATCH(c.title,c.body) AGAINST('{$term}')";
}
}
$querystring = "SELECT c.title AS ctitle, c.body, c.author, c.entry_id, c.timestamp AS ctimestamp, c.url, c.type,\n e.id, e.title, e.timestamp\n FROM {$serendipity['dbPrefix']}comments AS c\n LEFT OUTER JOIN {$serendipity['dbPrefix']}entries AS e\n ON e.id = c.entry_id\n WHERE c.status = 'approved'\n AND {$find_part}\n {$group}\n ORDER BY c.timestamp DESC";
$results = serendipity_db_query($querystring, false, 'assoc');
if (!is_array($results)) {
if ($results !== 1 && $results !== true) {
echo function_exists('serendipity_specialchars') ? serendipity_specialchars($results) : htmlspecialchars($results, ENT_COMPAT, LANG_CHARSET);
}
$results = array();
}
$myAddData = array("from" => "serendipity_plugin_commentsearch:generate_content");
foreach ($results as $idx => $result) {
$results[$idx]['permalink'] = serendipity_archiveURL($result['id'], $result['title'], 'baseURL', true, $result);
$results[$idx]['comment'] = $result['body'];
//(function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($result['body'])) : htmlspecialchars(strip_tags($result['body']), ENT_COMPAT, LANG_CHARSET));
serendipity_plugin_api::hook_event('frontend_display', $results[$idx], $myAddData);
// let the template decide, if we want to have tags or not
$results[$idx]['commenthtml'] = $results[$idx]['comment'];
$results[$idx]['comment'] = strip_tags($results[$idx]['comment']);
}
$serendipity['smarty']->assign(array('comment_searchresults' => count($results), 'comment_results' => $results));
$filename = 'plugin_commentsearch_searchresults.tpl';
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
$inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
$serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
$content = $serendipity['smarty']->fetch('file:' . $tfile);
$serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
echo $content;
}
示例5: show
function show()
{
global $serendipity;
$include_file = realpath($this->get_config('include'));
ob_start();
include $include_file;
$content = ob_get_contents();
ob_end_clean();
if (serendipity_db_bool($this->get_config('markup'))) {
$entry = array('body' => $content);
serendipity_plugin_api::hook_event('frontend_display', $entry);
echo $entry['body'];
} else {
echo $content;
}
}
示例6: generate_content
function generate_content(&$title)
{
$plug = $this->get_config('event_plugin', 'false');
if ($plug == 'false') {
return;
}
$wrap =& serendipity_plugin_api::get_event_plugins($plug);
$faketitle = '';
if (is_object($wrap)) {
$wrap->generate_content($faketitle);
}
if ($this->get_config('title') != '') {
$title = $this->get_config('title');
} else {
$title = $faketitle;
}
}
示例7: uninstall
function uninstall(&$propbag)
{
global $serendipity;
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
// delete directory with external images from articles
$upload_dir = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . 'plugin_mobile_output/';
if (is_dir($upload_dir)) {
// delete all files in the upload directory
$files = glob($upload_dir . '*');
if (is_array($files) && !empty($files)) {
foreach ($files as $file) {
@unlink($file);
}
}
@rmdir($upload_dir);
}
}
示例8: generate_content
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title');
$show_where = $this->get_config('show_where', 'both');
if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) {
return false;
} else {
if ($show_where == 'overview' && isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) {
return false;
}
}
if ($this->get_config('markup', 'true') == 'true') {
$entry = array('html_nugget' => $this->get_config('content'));
serendipity_plugin_api::hook_event('frontend_display', $entry);
echo $entry['html_nugget'];
} else {
echo $this->get_config('content');
}
}
示例9: showPaging
function showPaging($id = false)
{
global $serendipity;
if (!$id) {
return false;
}
$links = array();
$cond = array();
$cond['and'] = " AND e.isdraft = 'false' AND e.timestamp <= " . serendipity_serverOffsetHour(time(), true);
serendipity_plugin_api::hook_event('frontend_fetchentry', $cond);
$querystring = "SELECT\n e.id, e.title, e.timestamp\n FROM\n {$serendipity['dbPrefix']}entries e\n {$cond['joins']}\n WHERE\n e.id [COMP] " . (int) $id . "\n {$cond['and']}\n ORDER BY e.id [ORDER]\n LIMIT 1";
$prevID = serendipity_db_query(str_replace(array('[COMP]', '[ORDER]'), array('<', 'DESC'), $querystring));
$nextID = serendipity_db_query(str_replace(array('[COMP]', '[ORDER]'), array('>', 'ASC'), $querystring));
if ($link = $this->makeLink($prevID)) {
$links['prev'] = $link;
}
if ($link = $this->makeLink($nextID)) {
$links['next'] = $link;
}
return $links;
}
示例10: array
*/
$serendipity['permissionLevels'] = array(USERLEVEL_EDITOR => USERLEVEL_EDITOR_DESC, USERLEVEL_CHIEF => USERLEVEL_CHIEF_DESC, USERLEVEL_ADMIN => USERLEVEL_ADMIN_DESC);
/*
* Check if the installed version is higher than the version of the config
*/
if (IS_up2date === false && !defined('IN_upgrader')) {
if (preg_match(PAT_CSS, $_SERVER['REQUEST_URI'], $matches)) {
$css_mode = 'serendipity_admin.css';
return 1;
}
serendipity_die(sprintf(SERENDIPITY_NEEDS_UPGRADE, $serendipity['versionInstalled'], $serendipity['version'], $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php'));
}
// We don't care who tells us what to do
if (!isset($serendipity['GET']['action'])) {
$serendipity['GET']['action'] = isset($serendipity['POST']['action']) ? $serendipity['POST']['action'] : '';
}
if (!isset($serendipity['GET']['adminAction'])) {
$serendipity['GET']['adminAction'] = isset($serendipity['POST']['adminAction']) ? $serendipity['POST']['adminAction'] : '';
}
// Some stuff...
if (!isset($_SESSION['serendipityAuthedUser'])) {
$_SESSION['serendipityAuthedUser'] = false;
}
if (isset($_SESSION['serendipityUser'])) {
$serendipity['user'] = $_SESSION['serendipityUser'];
}
if (isset($_SESSION['serendipityEmail'])) {
$serendipity['email'] = $_SESSION['serendipityEmail'];
}
serendipity_plugin_api::hook_event('frontend_configure', $serendipity);
/* vim: set sts=4 ts=4 expandtab : */
示例11: uninstall
function uninstall()
{
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
示例12: show
function show()
{
global $serendipity;
if ($this->selected()) {
if (!headers_sent()) {
header('HTTP/1.0 200');
header('Status: 200 OK');
}
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$_ENV['staticpage_pagetitle'] = preg_replace('@[^a-z0-9]@i', '_', $this->get_config('pagetitle'));
$serendipity['smarty']->assign('staticpage_pagetitle', $_ENV['staticpage_pagetitle']);
if ($this->get_config('articleformat') == TRUE) {
echo '<div class="serendipity_Entry_Date">
<h3 class="serendipity_date">' . $this->get_config('pagetitle') . '</h3>';
}
echo '<h4 class="serendipity_title"><a href="#">' . $this->get_config('headline') . '</a></h4>';
if ($this->get_config('articleformat') == TRUE) {
echo '<div class="serendipity_entry"><div class="serendipity_entry_body">';
}
$include_file = realpath($this->get_config('include'));
ob_start();
include $include_file;
$content = ob_get_contents();
ob_end_clean();
if ($this->get_config('markup') == TRUE) {
$entry = array('body' => $content);
serendipity_plugin_api::hook_event('frontend_display', $entry);
echo $entry['body'];
} else {
echo $content;
}
if ($this->get_config('articleformat') == TRUE) {
echo '</div></div></div>';
}
}
}
示例13: generate_content
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title', $this->title);
$max_entries = $this->get_config('max_entries');
$max_chars = $this->get_config('max_chars');
$wordwrap = $this->get_config('wordwrap');
$dateformat = $this->get_config('dateformat');
if (!$max_entries || !is_numeric($max_entries) || $max_entries < 1) {
$max_entries = 15;
}
if (!$max_chars || !is_numeric($max_chars) || $max_chars < 1) {
$max_chars = 120;
}
if (!$wordwrap || !is_numeric($wordwrap) || $wordwrap < 1) {
$wordwrap = 30;
}
if (!$dateformat || strlen($dateformat) < 1) {
$dateformat = '%a, %d.%m.%Y %H:%M';
}
$viewtype = '';
if ($this->get_config('viewmode') == 'comments') {
$viewtype .= ' AND co.type = \'NORMAL\'';
} elseif ($this->get_config('viewmode') == 'trackbacks') {
$viewtype .= ' AND (co.type = \'TRACKBACK\' OR co.type = \'PINGBACK\')';
}
$cond = array();
$cond['and'] = ' AND e.isdraft = \'false\' ';
if ($this->get_config('authorid') == 'login') {
serendipity_ACL_SQL($cond, true);
serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'entries'));
}
$q = 'SELECT co.body AS comment,
co.timestamp AS stamp,
co.author AS user,
e.title AS subject,
e.timestamp AS entrystamp,
e.id AS entry_id,
co.id AS comment_id,
co.type AS comment_type,
co.url AS comment_url,
co.title AS comment_title,
co.email AS comment_email
FROM ' . $serendipity['dbPrefix'] . 'comments AS co,
' . $serendipity['dbPrefix'] . 'entries AS e
' . $cond['joins'] . '
WHERE e.id = co.entry_id
AND NOT (co.type = \'TRACKBACK\' AND co.author = \'' . serendipity_db_escape_string($serendipity['blogTitle']) . '\' AND co.title != \'\')
AND co.status = \'approved\'
' . $viewtype . '
' . $cond['and'] . '
ORDER BY co.timestamp DESC
LIMIT ' . $max_entries;
$sql = serendipity_db_query($q);
// echo $q;
if ($sql && is_array($sql)) {
foreach ($sql as $key => $row) {
if (function_exists('mb_strimwidth')) {
$comment = mb_strimwidth(strip_tags($row['comment']), 0, $max_chars, " [...]", LANG_CHARSET);
} else {
$comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1);
$aComment = explode('@@@', $comments);
$comment = $aComment[0];
if (count($aComment) > 1) {
$comment .= ' [...]';
}
}
$showurls = $this->get_config('showurls', 'trackbacks');
$isTrackBack = $row['comment_type'] == 'TRACKBACK' || $row['comment_type'] == 'PINGBACK';
if ($row['comment_url'] != '' && ($isTrackBack && ($showurls == 'trackbacks' || $showurls == 'all') || !$isTrackBack && ($showurls == 'comments' || $showurls == 'all'))) {
/* Fix invalid cases in protocoll part */
$row['comment_url'] = preg_replace('@^http://@i', 'http://', $row['comment_url']);
$row['comment_url'] = preg_replace('@^https://@i', 'https://', $row['comment_url']);
if (substr($row['comment_url'], 0, 7) != 'http://' && substr($row['comment_url'], 0, 8) != 'https://') {
$row['comment_url'] = 'http://' . $row['comment_url'];
}
$user = '<a class="highlight" href="' . htmlspecialchars(strip_tags($row['comment_url'])) . '" title="' . htmlspecialchars(strip_tags($row['comment_title'])) . '">' . htmlspecialchars(strip_tags($row['user'])) . '</a>';
} else {
$user = htmlspecialchars(strip_tags($row['user']));
}
$user = trim($user);
if (empty($user)) {
$user = PLUGIN_COMMENTS_ANONYMOUS;
}
if (function_exists('mb_strimwidth')) {
$pos = 0;
$parts = array();
$enc = LANG_CHARSET;
$comment_len = mb_strlen($comment, $enc);
while ($pos < $comment_len) {
$part = mb_strimwidth($comment, $pos, $wordwrap, '', $enc);
$pos += mb_strlen($part, $enc);
$parts[] = $part;
}
$comment = implode("\n", $parts);
} else {
$comment = wordwrap($comment, $wordwrap, "\n", 1);
}
$entry = array('comment' => $comment, 'email' => $row['comment_email'], 'url' => $row['comment_url'], 'author' => $row['user']);
// Let's help the BBCOde plugin a bit:
//.........这里部分代码省略.........
示例14: die
<?php
// Contributed by Christian Machmeier <cm@redsplash.de>
// Randomizing contributed by Christian Brabandt <cb@256bit.org>
if (IN_serendipity !== true) {
die("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_plugin_recententries extends serendipity_plugin
{
var $title = PLUGIN_RECENTENTRIES_TITLE;
function introspect(&$propbag)
{
$this->title = $this->get_config('title', $this->title);
$propbag->add('name', PLUGIN_RECENTENTRIES_TITLE);
$propbag->add('description', PLUGIN_RECENTENTRIES_BLAHBLAH);
$propbag->add('stackable', true);
$propbag->add('author', 'Christian Machmeier, Christian Brabandt, Judebert, Don Chambers');
$propbag->add('version', '2.6');
$propbag->add('requirements', array('serendipity' => '1.6', 'smarty' => '2.6.7', 'php' => '4.1.0'));
$propbag->add('configuration', array('title', 'number', 'number_from', 'dateformat', 'category', 'randomize', 'show_where'));
$propbag->add('groups', array('FRONTEND_VIEWS'));
}
function introspect_config_item($name, &$propbag)
{
global $serendipity;
switch ($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', TITLE);
$propbag->add('description', TITLE_FOR_NUGGET);
示例15: strtotime
if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation'] && isset($serendipity['POST']['new_timestamp']) && $serendipity['POST']['new_timestamp'] != date(DATE_FORMAT_2, $serendipity['POST']['chk_timestamp'])) {
// The user changed the timestamp, now set the DB-timestamp to the user's date
$entry['timestamp'] = strtotime($serendipity['POST']['new_timestamp']);
if ($entry['timestamp'] == -1) {
echo DATE_INVALID . '<br />';
// The date given by the user is not convertable. Reset the timestamp.
$entry['timestamp'] = $serendipity['POST']['timestamp'];
}
}
// Save server timezone in database always, so substract the offset we added for display; otherwise it would be added time and again
if (!empty($entry['timestamp'])) {
$entry['timestamp'] = serendipity_serverOffsetHour($entry['timestamp'], true);
}
// Save the entry, or just display a preview
$use_legacy = true;
serendipity_plugin_api::hook_event('backend_entry_iframe', $use_legacy);
if ($use_legacy) {
if ($serendipity['POST']['preview'] != 'true') {
/* We don't need an iframe to save a draft */
if ($serendipity['POST']['isdraft'] == 'true') {
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="" />' . IFRAME_SAVE_DRAFT . '</div><br />';
serendipity_updertEntry($entry);
} else {
if ($serendipity['use_iframe']) {
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="" />' . IFRAME_SAVE . '</div><br />';
serendipity_iframe_create('save', $entry);
} else {
serendipity_iframe($entry, 'save');
}
}
} else {