Add upstream plugins

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
2019-10-25 22:42:20 +02:00
parent 5d3c2ec184
commit 290736650a
1186 changed files with 302577 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<?php
/**
* Render the request as csv
*
* @author Time.ly Network Inc.
* @since 2.0
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Csv extends Ai1ec_Http_Response_Render_Strategy {
/* (non-PHPdoc)
* @see Ai1ec_Http_Response_Render_Strategy::render()
*/
public function render( array $params ) {
$this->_dump_buffers();
$now = gmdate( 'D, d M Y H:i:s' );
$filename = $params['filename'];
header( 'Expires: Tue, 03 Jul 2001 06:00:00 GMT' );
header( 'Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate' );
header( 'Last-Modified: ' . $now . ' GMT' );
// force download
header( 'Content-Type: application/force-download' );
header( 'Content-Type: application/octet-stream' );
header( 'Content-Type: application/download' );
// disposition / encoding on response body
header( 'Content-Disposition: attachment;filename="' . addcslashes(
$filename, '"' ) . '"' );
header( 'Content-Transfer-Encoding: binary' );
$columns = $params['columns'];
for ( $i = 0; $i < count( $columns ); $i++ ) {
if ( $i > 0 ) {
echo( ',' );
}
echo( $columns[$i] );
}
echo( "\n" );
$data = $params['data'];
for ( $i = 0; $i < count( $data ); $i++ ) {
$row = $data[$i];
for ( $j = 0; $j < count( $row ); $j++ ) {
if ( $j > 0 ) {
echo( ',' );
}
echo( $row[$j] );
}
echo( "\n" );
}
return Ai1ec_Http_Response_Helper::stop( 0 );
}
}

View File

@@ -0,0 +1,119 @@
<?php
/**
* Render the request as html.
*
* @author Time.ly Network Inc.
* @since 2.0
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Html extends Ai1ec_Http_Response_Render_Strategy {
/**
* Twig page content placeholder.
*/
const CALENDAR_PLACEHOLDER = '<!-- AI1EC_PAGE_CONTENT_PLACEHOLDER -->';
/**
* @var string the event html.
*/
protected $_html;
/**
* @var string The html for the footer of the event.
*/
protected $_html_footer = '';
/**
* Caller identifier. Just for paranoid check in append_content method.
* Expected 'calendar' or none.
*
* @var string
*/
protected $_caller = '';
/**
* Registers proper filters for content modifications.
*
* @param array $params Function params.
*
* @return void Method does not return.
*/
public function render( array $params ) {
$this->_html = $params['data'];
if ( isset( $params['caller'] ) ) {
$this->_caller = $params['caller'];
}
if ( isset( $params['footer'] ) ) {
$this->_html_footer = $params['footer'];
}
if ( isset( $params['is_event'] ) ) {
// Filter event post content, in single- and multi-post views
add_filter( 'the_content', array( $this, 'event_content' ), PHP_INT_MAX - 1 );
return;
}
// Replace page content - make sure it happens at (almost) the very end of
add_filter( 'the_content', array( $this, 'append_content' ), PHP_INT_MAX - 1 );
}
/**
* Append locally generated content to normal page content. By default,
* first checks if we are in The Loop before outputting to prevent multiple
* calendar display - unless setting is turned on to skip this check.
* We should not append full calendar body to single event content as it
* leads to "calendar" nesting if default calendar page contains calendar
* shortcode.
*
* @param string $content Post/Page content
* @return string Modified Post/Page content
*/
public function append_content( $content ) {
if (
'calendar' === $this->_caller &&
! $this->_registry->get( 'calendar.state' )->append_content()
) {
return $content;
}
$settings = $this->_registry->get( 'model.settings' );
// Include any admin-provided page content in the placeholder specified in
// the calendar theme template.
if ( $settings->get( 'skip_in_the_loop_check' ) || in_the_loop() ) {
$content = str_replace(
self::CALENDAR_PLACEHOLDER,
$content,
$this->_html
);
$content .= $this->_html_footer;
}
return $content;
}
/**
* event_content function
*
* Filter event post content by inserting relevant details of the event
* alongside the regular post content.
*
* @param string $content Post/Page content
*
* @return string Post/Page content
**/
public function event_content( $content ) {
if ( ! $this->_registry->get( 'calendar.state' )->append_content() ) {
$content = '';
}
$to_return = $this->_html . $content;
if ( isset( $this->_html_footer ) ) {
$to_return .= $this->_html_footer;
}
// Pass the orginal content to the filter so that it can be modified
return apply_filters(
'ai1ec_event_content',
$to_return,
$content
);
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Render the request as ical.
*
* @author Time.ly Network Inc.
* @since 2.0
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Ical extends Ai1ec_Http_Response_Render_Strategy {
/* (non-PHPdoc)
* @see Ai1ec_Http_Response_Render_Strategy::render()
*/
public function render( array $params ) {
$this->_dump_buffers();
header( 'Content-type: text/calendar; charset=utf-8' );
echo $params['data'];
return Ai1ec_Http_Response_Helper::stop( 0 );
}
}

View File

@@ -0,0 +1,20 @@
<?php
/**
* Render the request as json.
*
* @author Time.ly Network Inc.
* @since 2.0
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Json extends Ai1ec_Render_Strategy_Jsonp {
/* (non-PHPdoc)
* @see Ai1ec_Http_Response_Render_Strategy::render()
*/
public function render( array $params ) {
$params['callback'] = '';
return parent::render( $params );
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* Render the request as jsonp.
*
* @author Time.ly Network Inc.
* @since 2.0
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Jsonp extends Ai1ec_Http_Response_Render_Strategy {
/* (non-PHPdoc)
* @see Ai1ec_Http_Response_Render_Strategy::render()
*/
public function render( array $params ) {
$this->_dump_buffers();
header( 'HTTP/1.1 200 OK' );
header( 'Content-Type: application/json; charset=UTF-8' );
$data = Ai1ec_Http_Response_Helper::utf8( $params['data'] );
$output = json_encode( $data );
if ( ! empty( $params['callback'] ) ) {
$output = $params['callback'] . '(' . $output . ')';
} else if ( isset( $_GET['callback'] ) ) {
$output = $_GET['callback'] . '(' . $output . ')';
}
echo $output;
return Ai1ec_Http_Response_Helper::stop( 0 );
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Render the request as ical.
*
* @author Time.ly Network Inc.
* @since 2.0
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Redirect extends Ai1ec_Http_Response_Render_Strategy {
/* (non-PHPdoc)
* @see Ai1ec_Http_Response_Render_Strategy::render()
*/
public function render( array $params ) {
Ai1ec_Wp_Uri_Helper::local_redirect(
$params['url'],
$params['query_args']
);
}
}

View File

@@ -0,0 +1,19 @@
<?php
/**
* Do not render anything.
*
* @author Time.ly Network Inc.
* @since 2.0
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Void extends Ai1ec_Http_Response_Render_Strategy {
/* (non-PHPdoc)
* @see Ai1ec_Http_Response_Render_Strategy::render()
*/
public function render( array $params ) {
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* Render the request as xcal.
*
* @author Time.ly Network Inc.
* @since 2.3
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Xcal extends Ai1ec_Http_Response_Render_Strategy {
/* (non-PHPdoc)
* @see Ai1ec_Http_Response_Render_Strategy::render()
*/
public function render( array $params ) {
$this->_dump_buffers();
header( 'Content-Type: application/force-download; name="calendar.xml"' );
header( 'Content-type: text/xml' );
header( 'Content-Transfer-Encoding: binary' );
header( 'Content-Disposition: attachment; filename="calendar.xml"' );
header( 'Expires: 0' );
header( 'Cache-Control: no-cache, must-revalidate' );
header( 'Pragma: no-cache' );
echo $params['data'];
return Ai1ec_Http_Response_Helper::stop( 0 );
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* Render the request as xml.
*
* @author Time.ly Network Inc.
* @since 2.0
*
* @package AI1EC
* @subpackage AI1EC.Http.Response.Render.Strategy
*/
class Ai1ec_Render_Strategy_Xml extends Ai1ec_Http_Response_Render_Strategy {
/* (non-PHPdoc)
* @see Ai1ec_Http_Response_Render_Strategy::render()
*/
public function render( array $params ) {
$this->_dump_buffers();
header( 'HTTP/1.1 200 OK' );
header( 'Content-Type: text/xml; charset=UTF-8' );
$data = Ai1ec_Http_Response_Helper::utf8( $params['data'] );
$output = Ai1ec_XML_Builder::serialize_to_xml( $data );
echo $output;
return Ai1ec_Http_Response_Helper::stop( 0 );
}
}