/** * Plugin introspection * * Adding the root specification to the property bag of the plugin including * requirements, configuration options, etc. * * @param serendipity_property_bag $propbag Property bag for the plugin * @return null */ public function introspect(&$propbag) { $propbag->add('name', SERENDIPITY_PLUGIN_HEAVYROTATION_TITLE); $propbag->add('description', SERENDIPITY_PLUGIN_HEAVYROTATION_DESCRIPTION); $propbag->add('configuration', array('sidebar_title', 'amazon_api_id', 'amazon_country_code', 'audioscrobbler_username', 'cover_width', 'cover_height')); $propbag->add('stackable', true); $propbag->add('requirements', array('php' => '5.1', 'serendipity' => '0.9')); $propbag->add('groups', array(FRONTEND_EXTERNAL_SERVICES)); $propbag->add('author', 'Lars Strojny'); $propbag->add('version', SERENDIPITY_PLUGIN_HEAVYROTATION_VERSION); }
/** * Plugin introspection * * Adding the root specification to the property bag of the plugin including * requirements, configuration options, etc. * * @param serendipity_property_bag $propbag Property bag for the plugin * @return null */ public function introspect(&$propbag) { $propbag->add('name', SERENDIPITY_PLUGIN_FLICKRBADGE_TITLE); $propbag->add('description', SERENDIPITY_PLUGIN_FLICKRBADGE_DESCRIPTION); $propbag->add('configuration', array('sidebar_title', 'image_number', 'column_count', 'flickr_api_key', 'flickr_username')); $propbag->add('stackable', true); $propbag->add('requirements', array('php' => '5.1', 'serendipity' => '0.9')); $propbag->add('groups', array(FRONTEND_EXTERNAL_SERVICES)); $propbag->add('author', 'Lars Strojny'); $propbag->add('version', SERENDIPITY_PLUGIN_FLICKRBADGE_VERSION); }
/** * Hook for Serendipity events, initialize plug-in features * * @param string $event * @param serendipity_property_bag $bag * @param array $eventData * @param array $addData * @return bool */ function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'external_plugin': switch ($eventData) { case 'spamblockbee.png': header('Content-Type: image/png'); echo file_get_contents(dirname(__FILE__) . '/spamblockbee.png'); break; case 'spamblockbeecaptcha': echo $this->produceCaptchaAnswerJson(); break; } break; case 'frontend_saveComment': // Check only, if no one else denied it before if (!is_array($eventData) || serendipity_db_bool($eventData['allow_comments'])) { return $this->checkComment($eventData, $addData); } return true; break; case 'frontend_comment': $this->printCommentEditExtras($eventData, $addData); break; case 'frontend_footer': // Comment header code only if in single article mode or contactform // If contact form is installed, display on any page not being the article list // else display in single article only. $contactFormInstalled = class_exists('serendipity_event_contactform'); if ($contactFormInstalled && empty($eventData['GET']['page']) || !$contactFormInstalled && !empty($eventData['GET']['id'])) { $this->printJsExtras(); } break; case 'css': $this->printCss($eventData, $addData); break; default: return false; break; } return true; } else { return false; } }
/** * @param string $name * @param serendipity_property_bag $propbag * @return bool */ function introspect_config_item($name, &$propbag) { global $serendipity; switch ($name) { case 'userid': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_FLATTR_USER); $propbag->add('description', ''); $propbag->add('default', ''); break; case 'flattr_btn': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_FLATTR_BUTTON); $propbag->add('description', PLUGIN_FLATTR_BUTTON_DESC); $propbag->add('default', 'compact'); break; case 'placement': $positions = array('add_footer' => PLUGIN_FLATTR_PLACEMENT_FOOTER, 'body' => ENTRY_BODY, 'extended' => EXTENDED_BODY, 'flattr' => PLUGIN_FLATTR_PLACEMENT_SMARTY); $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_FLATTR_PLACEMENT); $propbag->add('description', ''); $propbag->add('select_values', $positions); $propbag->add('default', 'add_footer'); break; case 'flattr_cat': $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_FLATTR_CATS); $propbag->add('description', ''); $propbag->add('select_values', $this->flattr_cats); $propbag->add('default', 'text'); break; case 'flattr_lng': $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_FLATTR_LANG); $propbag->add('description', ''); $propbag->add('select_values', $this->flattr_langs); $propbag->add('default', $this->flatter_langs_alias[$serendipity['lang']]); break; case 'flattr_pop': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_FLATTR_POPOUT); $propbag->add('description', ''); $propbag->add('default', false); break; case 'add_to_feed': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_FLATTR_ADD_TO_FEED); $propbag->add('description', ''); $propbag->add('default', false); break; } return true; }
/** * @param string $event * @param serendipity_property_bag $bag * @param array $eventData * @param null $addData * @return bool */ public function event_hook($event, &$bag, &$eventData, $addData = null) { if (!class_exists("simple_html_dom") || !function_exists("str_get_html")) { require_once dirname(__FILE__) . '/libs/simple_html_dom.php'; } $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'frontend_display': $blacklist = $this->getBlacklist(); foreach ($this->markupElements as $temp) { $element = $temp['element']; if ($blacklist === null) { $eventData[$element] = $this->getDnsBlacklisted($eventData[$element]); } else { $eventData[$element] = $this->d64_lsr_check($blacklist, $eventData[$element]); } } return true; break; default: return false; } } return false; }
/** * @param string $name * @param serendipity_property_bag $propbag * @return bool */ function introspect_config_item($name, &$propbag) { switch ($name) { case 'sidebarTitle': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_TITLE_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_TITLE_D); break; case 'socialbookmarksService': $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_SOCIALBOOKMARKSSERVICE_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_SOCIALBOOKMARKSSERVICE_D); $propbag->add('select_values', array('del.icio.us' => 'del.icio.us', 'ma.gnolia' => 'ma.gnolia', 'furl' => 'Furl', 'linkroll' => 'Linkroll', 'misterwong' => 'Mister Wong')); $propbag->add('default', 'ma.gnolia'); break; case 'socialbookmarksID': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_USERNAME_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_USERNAME_D); $propbag->add('default', 'numblog'); break; case 'displayNumber': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_DISPLAYNUMBER_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_DISPLAYNUMBER_D); $propbag->add('default', '10'); break; case 'cacheTime': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_CACHETIME_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_CACHETIME_D); $propbag->add('default', 1); break; case 'moreLink': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_MORELINK_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_MORELINK_D); $propbag->add('default', 'true'); break; case 'displayTags': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_DISPLAYTAGS_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_DISPLAYTAGS_D); $propbag->add('default', 'true'); break; case 'specialFeatures': $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_SPECIALFEATURES_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_SPECIALFEATURES_D); $propbag->add('select_values', array('usr_recent_bookmarks' => PLUGIN_SOCIALBOOKMARKS_SPECIALFEATURES_USR_RECENT, 'gen_recent_bookmarks' => PLUGIN_SOCIALBOOKMARKS_SPECIALFEATURES_GEN_RECENT, 'gen_popular_bookmarks' => PLUGIN_SOCIALBOOKMARKS_SPECIALFEATURES_GEN_POPULAR, 'usr_js_tagcloud' => PLUGIN_SOCIALBOOKMARKS_SPECIALFEATURES_USR_JS_TAGCLOUD)); $propbag->add('default', 'usr_recent_bookmarks'); break; case 'displayThumbnails': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_DISPLAYTHUMBS_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_DISPLAYTHUMBS_D); $propbag->add('default', 'false'); break; case 'additionalParams': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SOCIALBOOKMARKS_ADDPARAMS_N); $propbag->add('description', PLUGIN_SOCIALBOOKMARKS_ADDPARAMS_D); $propbag->add('default', '?icon;count=30;size=10-20;color=87ceeb-0000ff;title=my%20del.icio.us%20tags;name;showadd'); break; case 'explain': $propbag->add('type', 'content'); $propbag->add('default', PLUGIN_SOCIALBOOKMARKS_EXPLAIN); break; default: return false; } return true; }
/** * Hook for Serendipity events, initialize plug-in features * * @param string $event * @param serendipity_property_bag $bag * @param array $eventData * @param array $addData * @return boolean */ function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); $serendipity['plugin_guestbook_version'] =& $bag->get('version'); // set global plugin path setting, to avoid different pluginpath '/plugins/' as plugins serendipity vars if (!isset($serendipity['guestbook']['pluginpath'])) { $pluginpath = pathinfo(dirname(__FILE__)); $serendipity['guestbook']['pluginpath'] = basename(rtrim($pluginpath['dirname'], '/')) . '/serendipity_event_guestbook/'; } if (isset($hooks[$event])) { switch ($event) { case 'frontend_configure': // checking if db tables exists, otherwise install them $cur = ''; $old = $this->get_config('version', '', false); if ($old == '1.0') { $cur = $old; } if (empty($cur) && (!empty($old) || $old == '' && $old != false)) { $cur = '2.0'; } else { $cur = $this->get_config('dbversion'); } if ($cur == '1.0') { $this->alter_db($cur); $this->set_config('dbversion', '2.0'); } elseif ($cur == '2.0') { $this->alter_db($cur); $this->set_config('dbversion', '3.0'); $this->cleanup(); } elseif ($cur == '3.0') { $this->alter_db($cur); $this->set_config('dbversion', '4'); } elseif ($cur == '4') { $this->alter_db($cur); $this->set_config('dbversion', '5'); } elseif ($cur == '5') { continue; } else { $this->install(); $this->set_config('dbversion', '5'); } 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; } if ($this->selected()) { $serendipity['head_title'] = $this->get_config('headline'); $serendipity['head_subtitle'] = $this->html_specialchars($serendipity['blogTitle']); } break; case 'entry_display': if ($this->selected()) { // This is important to not display an entry list! if (is_array($eventData)) { $eventData['clean_page'] = true; } else { $eventData = array('clean_page' => true); } } return true; break; case 'entries_header': // this one really rolls up output: check form submit, generate entries and form $this->generate_Page(); return true; break; case 'external_plugin': // [0]=guestbookdlsql; [1]=filename; $gb['export'] = explode('/', $eventData); if ($gb['export'][0] == 'guestbookdlsql') { $file = file_get_contents($serendipity['serendipityPath'] . 'templates_c/guestbook/' . $gb['export'][1]); echo $file; header('Status: 302 Found'); header('Content-Type: application/octet-stream; charset=UTF-8'); // text/plain to see as file in browser header('Content-Disposition: inline; filename=' . $gb['export'][1]); } break; // put here all you css stuff you need for frontend guestbook pages // put here all you css stuff you need for frontend guestbook pages case 'css': if (stristr($eventData, '#guestbook_wrapper')) { // class exists in CSS, so a user has customized it and we don't need default return true; } $tfile = serendipity_getTemplateFile('style_guestbook_frontend.css', 'serendipityPath'); if ($tfile) { $search = array('{TEMPLATE_PATH}', '{PLUGIN_PATH}'); $replace = array('templates/' . $serendipity['defaultTemplate'] . '/', $serendipity['guestbook']['pluginpath']); $tfilecontent = str_replace($search, $replace, @file_get_contents($tfile)); } if (!$tfile || $tfile == 'style_guestbook_frontend.css') { $tfile = dirname(__FILE__) . '/style_guestbook_frontend.css'; $search = array('{TEMPLATE_PATH}', '{PLUGIN_PATH}'); $tfilecontent = str_replace($search, $serendipity['guestbook']['pluginpath'], @file_get_contents($tfile)); } if (!empty($tfilecontent)) { $this->cssEventData($eventData, $tfilecontent); } return true; break; case 'backend_sidebar_entries': // forbid sidebar link if user is not in admin group level if ($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN) { return false; } if ($serendipity['version'][0] < 2) { echo "\n" . '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=guestbook">' . PLUGIN_GUESTBOOK_ADMIN_NAME . '</a></li>' . "\n"; } return true; break; case 'backend_sidebar_admin_appearance': // forbid sidebar link if user is not in admin group level if ($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN) { return false; } if ($serendipity['version'][0] > 1) { echo "\n" . '<li><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=guestbook">' . PLUGIN_GUESTBOOK_ADMIN_NAME . '</a></li>' . "\n"; } return true; break; case 'backend_sidebar_entries_event_display_guestbook': // forbid entry access if user is not in admin group level if ($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN) { return false; } // show backend administration menu $this->gbadminpanel(); return true; break; // put here all you css stuff you need for the backend of guestbook pages // put here all you css stuff you need for the backend of guestbook pages case 'css_backend': if (stristr($eventData, '#wrapGB')) { // class exists in CSS, so a user has customized it and we don't need default return true; } $tfile = serendipity_getTemplateFile('style_guestbook_backend.css', 'serendipityPath'); if ($tfile) { $search = array('{TEMPLATE_PATH}', '{PLUGIN_PATH}'); $replace = array('templates/' . $serendipity['defaultTemplate'] . '/', $serendipity['guestbook']['pluginpath']); $tfilecontent = str_replace($search, $replace, @file_get_contents($tfile)); } if ((!$tfile || $tfile == 'style_guestbook_backend.css') && !$tfilecontent) { $tfile = dirname(__FILE__) . '/style_guestbook_backend.css'; $search = array('{TEMPLATE_PATH}', '{PLUGIN_PATH}'); $tfilecontent = str_replace($search, $serendipity['guestbook']['pluginpath'], @file_get_contents($tfile)); } // overwrite Serendipity 1.7 .serendipityAdminContent span !important if ($serendipity['version'][0] < '2') { ?> #wrapGB .gb_entryhead span {color: #CCDDE7 !important;} #wrapGB .gb_entrybody span {color: #222 !important;} #wrapGB .msg_error, #wrapGB .msg_success, #wrapGB .msg_notice, #wrapGB .msg_hint { display: block; margin: 1.5em 0; padding: .5em; } #wrapGB .msg_error { background: #f2dede; border: 1px solid #e4b9b9; color: #b94a48; } #wrapGB .msg_success { background: #dff0d8; border: 1px solid #c1e2b3; color: #468847; } #wrapGB .msg_notice { background: #fcf8e3; border: 1px solid #fbeed5; color: #c09853; } #wrapGB .msg_hint { background: #eee; border: 1px solid #aaa; color: #777; } <?php } // add replaced css content to the end of serendipity_admin.css if (!empty($tfilecontent)) { $this->cssEventData($eventData, $tfilecontent); } return true; break; default: return false; break; } } else { return false; } }
/** * @param string $event * @param serendipity_property_bag $bag * @param array $eventData * @param null $addData * @return bool|true */ public function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; if (intval($serendipity['version'][0]) < 2) { $this->legacy = true; } $hooks =& $bag->get('event_hooks'); $pluginConfigurationKeys = $bag->get('configuration'); if (isset($hooks[$event])) { switch ($event) { case 'backend_entry_toolbar_extended': return $this->processEvent('extended', $eventData, $pluginConfigurationKeys); break; case 'backend_entry_toolbar_body': return $this->processEvent('body', $eventData, $pluginConfigurationKeys); break; default: return false; break; } } return false; }
/** * @test */ public function testIntrospect() { $this->object->introspect($this->propBag); $this->assertEquals('0.3', $this->propBag->get('version')); $this->assertFalse($this->propBag->get('stackable')); }
/** * Example 1 * @test */ public function introspect() { $this->object->introspect($this->propBag); $this->assertEquals('Typeset/Extended Buttons for non-WYSIWYG editors', $this->propBag->get('name')); $this->assertFalse($this->propBag->get('stackable')); }