本文整理汇总了PHP中Plugins::get_by_interface方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugins::get_by_interface方法的具体用法?PHP Plugins::get_by_interface怎么用?PHP Plugins::get_by_interface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugins
的用法示例。
在下文中一共展示了Plugins::get_by_interface方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_plugin_deactivation
/**
*
* @param string $file. The name of the plugin file
*
* Delete the special silo permissions if they're no longer
* being used.
*/
public function action_plugin_deactivation( $file ) {
$silos = Plugins::get_by_interface( 'MediaSilo' );
if ( count( $silos ) <= 1 ) {
ACL::destroy_token( 'upload_media' );
ACL::destroy_token( 'delete_media' );
ACL::destroy_token( 'create_directories' );
ACL::destroy_token( 'delete_directories' );
}
}
示例2: action_handler_dev_feed
public function action_handler_dev_feed($handler_vars)
{
$rss = Plugins::get_by_interface('RSS');
if (count($rss) !== 1) {
exit;
}
$xml = reset($rss)->create_rss_wrapper();
$connection_string = Options::get('tracfeed__connection_string');
$username = Options::get('tracfeed__username');
$password = Options::get('tracfeed__password');
$db = DatabaseConnection::ConnectionFactory($connection_string);
$db->connect($connection_string, $username, $password);
$times = $db->get_column('SELECT time from ticket_change group by time order by time desc limit 15;');
$mintime = array_reduce($times, 'min', reset($times));
$comments = $db->get_results("\n\t\t\tSELECT *, ticket_change.time as changetime from ticket_change \n\t\t\tINNER JOIN ticket on ticket.id = ticket_change.ticket\n\t\t\twhere \n\t\t\tchangetime >= ? and\n\t\t\tnot (field ='comment' and newvalue = '') \n\t\t\torder by ticket_change.time DESC;\n\t\t", array($mintime));
$posts = array();
foreach ($comments as $comment) {
$post_id = md5($comment->ticket . ':' . $comment->changetime . ':' . $comment->author);
if (!array_key_exists($post_id, $posts)) {
$post = new Post();
$post->title = "Ticket #{$comment->ticket}: {$comment->summary}";
$post->content = "Changes by {$comment->author} on ticket <a href=\"http://trac.habariproject.org/habari/ticket/{$comment->ticket}\">#{$comment->ticket}</a>.\n<br>\n<br>";
$post->guid = 'tag:' . Site::get_url('hostname') . ',trac_comment,' . $post_id;
$post->content_type = 'dev_feed';
$post->slug = "http://trac.habariproject.org/habari/ticket/{$comment->ticket}";
$post->pubdate = date('r', $comment->changetime);
$posts[$post_id] = $post;
} else {
$post = $posts[$post_id];
}
switch ($comment->field) {
case 'comment':
$content = $comment->newvalue;
$content = preg_replace('/\\b(https?|ftp|file):\\/\\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|]/i', '<a href="$0">[link]</a>', $content);
$content = preg_replace('%\\br([0-9]+)\\b%', '<a href="http://trac.habariproject.org/habari/changeset/$1">r$1</a>', $content);
$content = preg_replace('%\\b#([0-9]+)\\b%', '<a href="http://trac.habariproject.org/habari/ticket/$1">$1</a>', $content);
$post->content .= "Comment #{$comment->oldvalue} by {$comment->author}:\n<blockquote><pre>{$content}</pre></blockquote>\n<br>";
break;
default:
if (trim($comment->oldvalue) == '') {
$post->content .= "Set <b>{$comment->field}</b> to: {$comment->newvalue}\n<br>";
} else {
$post->content .= "Changed <b>{$comment->field}</b> from: {$comment->oldvalue}\n<br> To: {$comment->newvalue}\n<br>";
}
break;
}
}
$xml = RSS::add_posts($xml, $posts);
ob_clean();
header('Content-Type: application/xml');
echo $xml->asXML();
exit;
}
示例3: get_form
/**
* Returns a form for editing this post
* @param string $context The context the form is being created in, most often 'admin'
* @return FormUI A form appropriate for creating and updating this post.
*/
public function get_form( $context )
{
$form = new FormUI( 'create-content' );
$form->class[] = 'create';
$newpost = ( 0 === $this->id );
// If the post has already been saved, add a link to its permalink
if ( !$newpost ) {
$post_links = $form->append( 'wrapper', 'post_links' );
$permalink = ( $this->status != Post::status( 'published' ) ) ? $this->permalink . '?preview=1' : $this->permalink;
$post_links->append( 'static', 'post_permalink', '<a href="'. $permalink .'" class="viewpost" >'.( $this->status != Post::status( 'published' ) ? _t( 'Preview Post' ) : _t( 'View Post' ) ).'</a>' );
$post_links->class ='container';
}
// Create the Title field
$form->append( 'text', 'title', 'null:null', _t( 'Title' ), 'admincontrol_text' );
$form->title->class[] = 'important';
$form->title->class[] = 'check-change';
$form->title->tabindex = 1;
$form->title->value = $this->title;
// Create the silos
if ( count( Plugins::get_by_interface( 'MediaSilo' ) ) ) {
$form->append( 'silos', 'silos' );
$form->silos->silos = Media::dir();
}
// Create the Content field
$form->append( 'textarea', 'content', 'null:null', _t( 'Content' ), 'admincontrol_textarea' );
$form->content->class[] = 'resizable';
$form->content->class[] = 'check-change';
$form->content->tabindex = 2;
$form->content->value = $this->content;
$form->content->raw = true;
// Create the tags field
$form->append( 'text', 'tags', 'null:null', _t( 'Tags, separated by, commas' ), 'admincontrol_text' );
$form->tags->class = 'check-change';
$form->tags->tabindex = 3;
$tags = (array)$this->get_tags();
array_map(
create_function( '$a',
'$a->term_display = MultiByte::strpos( $a->term_display, \',\' ) === false ? $a->term_display : $a->tag_text_searchable;' ),
$tags
);
$form->tags->value = implode( ', ', $tags );
// Create the splitter
$publish_controls = $form->append( 'tabs', 'publish_controls' );
// Create the publishing controls
// pass "false" to list_post_statuses() so that we don't include internal post statuses
$statuses = Post::list_post_statuses( $this );
unset( $statuses[array_search( 'any', $statuses )] );
$statuses = Plugins::filter( 'admin_publish_list_post_statuses', $statuses );
$settings = $publish_controls->append( 'fieldset', 'settings', _t( 'Settings' ) );
$settings->append( 'select', 'status', 'null:null', _t( 'Content State' ), array_flip( $statuses ), 'tabcontrol_select' );
$settings->status->value = $this->status;
// hide the minor edit checkbox if the post is new
if ( $newpost ) {
$settings->append( 'hidden', 'minor_edit', 'null:null' );
$settings->minor_edit->value = false;
}
else {
$settings->append( 'checkbox', 'minor_edit', 'null:null', _t( 'Minor Edit' ), 'tabcontrol_checkbox' );
$settings->minor_edit->value = true;
$form->append( 'hidden', 'modified', 'null:null' )->value = $this->modified;
}
$settings->append( 'checkbox', 'comments_enabled', 'null:null', _t( 'Comments Allowed' ), 'tabcontrol_checkbox' );
$settings->comments_enabled->value = $this->info->comments_disabled ? false : true;
$settings->append( 'text', 'pubdate', 'null:null', _t( 'Publication Time' ), 'tabcontrol_text' );
$settings->pubdate->value = $this->pubdate->format( 'Y-m-d H:i:s' );
$settings->pubdate->helptext = _t( 'YYYY-MM-DD HH:MM:SS' );
$settings->append( 'hidden', 'updated', 'null:null' );
$settings->updated->value = $this->updated->int;
$settings->append( 'text', 'newslug', 'null:null', _t( 'Content Address' ), 'tabcontrol_text' );
$settings->newslug->value = $this->slug;
// Create the button area
$buttons = $form->append( 'fieldset', 'buttons' );
$buttons->template = 'admincontrol_buttons';
$buttons->class[] = 'container';
$buttons->class[] = 'buttons';
$buttons->class[] = 'publish';
// Create the Save button
//.........这里部分代码省略.........
示例4: load_all
/**
* function load_all
* Loads and stores an instance of all declared Format classes for future use
**/
public static function load_all()
{
self::$formatters = array();
$classes = get_declared_classes();
foreach ($classes as $class) {
if (get_parent_class($class) == 'Format' || $class == 'Format') {
self::$formatters[] = new $class();
}
}
self::$formatters = array_merge(self::$formatters, Plugins::get_by_interface('FormatPlugin'));
self::$formatters = array_reverse(self::$formatters, true);
}
示例5: init_silos
/**
* Initialize the internal list of silo instances
*/
public static function init_silos()
{
if (empty(self::$silos)) {
$tempsilos = Plugins::get_by_interface('MediaSilo');
self::$silos = array();
foreach ($tempsilos as $eachsilo) {
$info = $eachsilo->silo_info();
if (isset($info['name'])) {
self::$silos[$info['name']] = $eachsilo;
}
}
}
}
示例6: addon_success
public function addon_success($form)
{
$plugins = Plugins::get_by_interface('PostReceive');
var_dump($plugins);
$plugin = reset($plugins);
var_dump($plugin->process_update(html_entity_decode($form->json->value)));
}
示例7: get_form
/**
* Returns a form for editing this post
* @param string $context The context the form is being created in, most often 'admin'
* @return FormUI A form appropriate for creating and updating this post.
*/
public function get_form($context)
{
/** @var FormUI $form */
$form = new FormUI('create-content', null, array('class' => array('create')));
$form->set_wrap_each('<div class="container">%s</div>');
$newpost = 0 === $this->id;
// If the post has already been saved, add a link to its permalink
if (!$newpost) {
/** @var FormControlWrapper $post_links */
$post_links = $form->append(FormControlWrapper::create('post_links', null, array('class' => 'container')));
$permalink = $this->status != Post::status('published') ? $this->permalink . '?preview=1' : $this->permalink;
$post_links->append(FormControlStatic::create('post_permalink')->set_static('<a href="' . $permalink . '" class="viewpost" >' . ($this->status != Post::status('published') ? _t('Preview Post') : _t('View Post')) . '</a>'));
}
// Store this post instance into a hidden field for later use when saving data
$form->append(FormControlData::create('post')->set_value($this));
// Create the Title field
$form->append(FormControlLabel::wrap(_t('Title'), FormControlText::create('title', null, array('class' => array('check-change full-width')))->set_value($this->title_internal)));
// Create the silos
if (count(Plugins::get_by_interface('MediaSilo'))) {
$silos = FormControlSilos::create('silos')->set_setting('wrap', '<div class="container silos">%s</div>');
$form->append($silos);
}
// Create the Content field
$form->append(FormControlLabel::wrap(_t('Content'), FormControlTextArea::create('content', null, array('class' => array('resizable', 'check-change full-width rte')))->set_value($this->content_internal)));
$form->content->raw = true;
// @todo What does this do?
// Create the tags field
/** @var FormControlAutocomplete $tags_control */
$form->append(FormControlLabel::wrap(_t('Tags, separated by, commas'), $tags_control = FormControlAutocomplete::create('tags', null, array('style' => 'width:100%;margin:0px 0px 20px;', 'class' => 'check-change full-width'), array('allow_new' => true, 'init_selection' => true)))->set_properties(array('style' => 'width:100%;margin:0px 0px 20px;')));
$tags = (array) $this->get_tags();
array_walk($tags, function (&$element, $key) {
$element->term_display = MultiByte::strpos($element->term_display, ',') === false ? $element->term_display : $element->tag_text_searchable;
});
$tags_control->set_value(implode(',', $tags));
$tags_control->set_ajax(URL::auth_ajax('tag_list'));
// Create the splitter
/** @var FormControlTabs $publish_controls */
$publish_controls = $form->append(FormControlTabs::create('publish_controls')->set_setting('wrap', '%s')->set_setting('class_each', 'container'));
// Create the publishing controls
// pass "false" to list_post_statuses() so that we don't include internal post statuses
$statuses = Post::list_post_statuses($this);
unset($statuses[array_search('any', $statuses)]);
$statuses = Plugins::filter('admin_publish_list_post_statuses', $statuses);
/** @var FormControlFieldset $settings */
$settings = $publish_controls->append(FormControlFieldset::create('post_settings')->set_caption(_t('Settings')));
$settings->append(FormControlLabel::wrap(_t('Content State'), FormControlSelect::create('status')->set_options(array_flip($statuses))->set_value($this->status)));
// hide the minor edit checkbox if the post is new
if ($newpost) {
$settings->append(FormControlData::create('minor_edit')->set_value(false));
} else {
$settings->append(FormControlLabel::wrap(_t('Minor Edit'), FormControlCheckbox::create('minor_edit')->set_value(true)));
$form->append(FormControlData::create('modified')->set_value($this->modified));
}
$settings->append(FormControlLabel::wrap(_t('Comments Allowed'), FormControlCheckbox::create('comments_enabled')->set_value($this->info->comments_disabled ? false : true)));
$settings->append(FormControlLabel::wrap(_t('Publication Time'), FormControlText::create('pubdate')->set_value($this->pubdate->format('Y-m-d H:i:s'))));
$settings->pubdate->set_helptext(_t('YYYY-MM-DD HH:MM:SS'));
$settings->append(FormControlData::create('updated')->set_value($this->updated->int));
$settings->append(FormControlLabel::wrap(_t('Content Address'), FormControlText::create('newslug')->set_value($this->slug)));
// Create the button area
$buttons = $form->append(FormControlFieldset::create('buttons', null, array('class' => array('container', 'buttons', 'publish'))));
// What buttons should we have?
$require_any = array('own_posts' => 'create', 'post_any' => 'create', 'post_' . Post::type_name($this->content_type) => 'create');
$show_buttons = array();
if ($newpost) {
if (User::identify()->can_any($require_any)) {
$show_buttons['save'] = true;
$show_buttons['publish'] = true;
}
} else {
if (ACL::access_check($this->get_access(), 'edit')) {
if ($this->status == Post::status('draft')) {
$show_buttons['publish'] = true;
}
$show_buttons['save'] = true;
}
if (ACL::access_check($this->get_access(), 'delete')) {
$show_buttons['delete'] = true;
}
}
$show_buttons = Plugins::filter('publish_form_buttons', $show_buttons, $this);
if (isset($show_buttons['delete'])) {
// Create the Delete button
$buttons->append(FormControlSubmit::create('delete', null, array('class' => 'three columns'))->set_caption(_t('Delete'))->on_success(array($this, 'form_publish_delete')));
}
if (isset($show_buttons['save'])) {
// Create the Save button
$buttons->append(FormControlSubmit::create('save', null, array('class' => 'three columns'))->set_caption(_t('Save')));
}
if (isset($show_buttons['publish'])) {
// Create the Publish button
$buttons->append(FormControlSubmit::create('publish', null, array('class' => 'three columns'))->set_caption(_t('Publish'))->add_validator(function ($value, FormControlSubmit $control, FormUI $form) {
$form->status->set_value(Post::status('published'));
$allow = Plugins::filter('post_publish_allow', true, $this);
if (!$allow) {
return array('Publishing has been denied');
//.........这里部分代码省略.........