public function testRenderBasicWithCaption()
 {
     $social_embed = SocialEmbed::create()->withSource('http://foo.com')->withCaption(Caption::create()->appendText('Some caption to the embed'));
     $expected = '<figure class="op-interactive">' . '<iframe src="http://foo.com"></iframe>' . '<figcaption>Some caption to the embed</figcaption>' . '</figure>';
     $rendered = $social_embed->render();
     $this->assertEquals($expected, $rendered);
 }
Example #2
0
 /**
  * Shortcode for displaying caption data.
  *
  * @param array $atts Shortcode attributes.
  *
  * @return string $caption The output for the shortcode to display.
  */
 public function shortcode($atts)
 {
     global $post;
     /*
     Set up the attributes. Most attributes are boolean by declaration,
     so they are not given defaults.
     */
     $a = shortcode_atts(array('format' => 'html'), $atts);
     // Create a new instance of the Caption class
     $caption = new Caption();
     // Get the caption data
     $captiondata = $caption->caption_data($post->ID);
     // Format-specific flags to force format, ordered by presedence
     do {
         // Source link
         if ($this->has_flag('source-link', $atts, false)) {
             $a['format'] = 'html';
             break;
         }
         // Source URL
         if ($this->has_flag('source-url', $atts, false)) {
             $a['format'] = 'plaintext';
             break;
         }
     } while (0);
     // Select the output format
     switch ($a['format']) {
         case 'plaintext':
             $output = $caption->plaintext($captiondata, $atts);
             break;
         default:
             $output = $caption->html($captiondata, $atts);
     }
     return $output;
 }
 public function testRenderWithLikeAndComments()
 {
     $image = Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg')->withCaption(Caption::create()->appendText('Some caption to the image'))->enableLike()->enableComments();
     $expected = '<figure data-feedback="fb:likes,fb:comments">' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '<figcaption>Some caption to the image</figcaption>' . '</figure>';
     $rendered = $image->render();
     $this->assertEquals($expected, $rendered);
 }
 public function testRenderWithCaption()
 {
     $slideshow = SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home2.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home3.jpg'))->withCaption(Caption::create()->appendText('Some caption to the slideshow'));
     $expected = '<figure class="op-slideshow">' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '</figure>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home2.jpg"/>' . '</figure>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home3.jpg"/>' . '</figure>' . '<figcaption>Some caption to the slideshow</figcaption>' . '</figure>';
     $rendered = $slideshow->render();
     $this->assertEquals($expected, $rendered);
 }
 public function testRenderWithLikeAndComments()
 {
     $video = Video::create()->withURL('http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4')->withCaption(Caption::create()->appendText('Some caption to the video'))->enableLike()->enableComments();
     $expected = '<figure data-feedback="fb:likes,fb:comments">' . '<video>' . '<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"/>' . '</video>' . '<figcaption>Some caption to the video</figcaption>' . '</figure>';
     $rendered = $video->render();
     $this->assertEquals($expected, $rendered);
 }
 public function testRenderWithAllFormating()
 {
     $caption = Caption::create()->appendText('Caption Title')->withFontsize(Caption::SIZE_LARGE)->withPosition(Caption::POSITION_BELOW)->withTextAlignment(Caption::ALIGN_LEFT)->withVerticalAlignment(Caption::VERTICAL_BOTTOM);
     $expected = '<figcaption class="op-left op-vertical-bottom op-large op-vertical-below">' . 'Caption Title' . '</figcaption>';
     $rendered = $caption->render();
     $this->assertEquals($expected, $rendered);
 }
Example #7
0
 function &AddCaption($local, $symbol, $text)
 {
     printf("DBG9 %s/%s\n", __CLASS__, __FUNCTION__);
     if ($ret = $this->GetText($local, $symbol) == '') {
         printf("DBG9 %s/%s GetText returns ''\n", __CLASS__, __FUNCTION__);
         $cap = new Caption();
         $cap->Locale($local);
         $cap->Symbol($symbol);
         $cap->Text($text);
         $this->Add($cap);
         return $cap;
     } else {
         printf("DBG9 %s/%s GetText returns {$ret}\n", __CLASS__, __FUNCTION__);
         print_r($ret);
         return null;
     }
 }
 public function testCompleteHeader()
 {
     date_default_timezone_set('UTC');
     $inline = '<script>alert("test & more test");</script>';
     $header = Header::create()->withTitle('Big Top Title')->withSubTitle('Smaller SubTitle')->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00')))->withModifyTime(Time::create(Time::MODIFIED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '10-Feb-2016 10:00:00')))->addAuthor(Author::create()->withName('Author One')->withDescription('Passionate coder and mountain biker'))->addAuthor(Author::create()->withName('Author Two')->withDescription('Weend surfer with heavy weight coding skils')->withURL('http://facebook.com/author'))->withKicker('Some kicker of this article')->withCover(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg')->withCaption(Caption::create()->appendText('Some caption to the image')))->addAd(Ad::create()->withSource('http://foo.com'))->addAd(Ad::create()->withSource('http://foo.com')->withWidth(350)->withHeight(50)->enableDefaultForReuse())->addAd(Ad::create()->withWidth(300)->withHeight(250)->enableDefaultForReuse()->withHTML($inline));
     $expected = '<header>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '<figcaption>Some caption to the image</figcaption>' . '</figure>' . '<h1>Big Top Title</h1>' . '<h2>Smaller SubTitle</h2>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<time class="op-modified" datetime="2016-02-10T10:00:00+00:00">February 10th, 10:00am</time>' . '<address>' . '<a>Author One</a>' . 'Passionate coder and mountain biker' . '</address>' . '<address>' . '<a href="http://facebook.com/author" rel="facebook">Author Two</a>' . 'Weend surfer with heavy weight coding skils' . '</address>' . '<h3 class="op-kicker">Some kicker of this article</h3>' . '<section class="op-ad-template">' . '<figure class="op-ad">' . '<iframe src="http://foo.com"></iframe>' . '</figure>' . '<figure class="op-ad op-ad-default">' . '<iframe src="http://foo.com" width="350" height="50"></iframe>' . '</figure>' . '<figure class="op-ad">' . '<iframe width="300" height="250">' . '<script>alert("test & more test");</script>' . '</iframe>' . '</figure>' . '</section>' . '</header>';
     $rendered = $header->render();
     $this->assertEquals($expected, $rendered);
 }
Example #9
0
 /**
  * Assemble the caption data for the REST API
  *
  * @since 0.8.3
  *
  * @param array $object Details of current post.
  * @param string $field_name Name of field.
  * @param WP_REST_Request $request Current request.
  *
  * @return mixed
  */
 public function rest_caption($object, $field_name, $request)
 {
     // Get the post ID
     $post_id = (int) $object['id'];
     // Instatiate the Caption class
     $caption = new Caption();
     // Get the caption data as non-HTML, raw output
     $data = $caption->caption(false, $post_id);
     // If there's no caption data, set an empty array
     if (empty($data)) {
         $data = array();
     }
     // Assemble the caption data into an object
     $response = new \stdClass();
     $response->caption_text = isset($data['caption_text']) ? $data['caption_text'] : false;
     $response->source_text = isset($data['source_text']) ? $data['source_text'] : false;
     $response->source_url = isset($data['source_url']) ? $data['source_url'] : false;
     return $response;
 }
    public function testRenderWithGeotagAndCaption()
    {
        $script = <<<'JSON'
{
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [23.166667, 89.216667]
    },
    "properties": {
        "title": "Jessore, Bangladesh",
        "radius": 750000,
        "pivot": true,
        "style": "satellite"
    }
}
JSON;
        $map = Map::create()->withGeoTag(GeoTag::create()->withScript($script))->withCaption(Caption::create()->withTitle('Title of Image caption')->withCredit('Some caption to the image')->withPosition(Caption::POSITION_BELOW));
        $expected = '<figure class="op-map">' . '<script type="application/json" class="op-geotag">' . $script . '</script>' . '<figcaption class="op-vertical-below">' . '<h1>Title of Image caption</h1>' . '<cite>Some caption to the image</cite>' . '</figcaption>' . '</figure>';
        $rendered = $map->render();
        $this->assertEquals($expected, $rendered);
    }
 /**
  * Renders the caption.
  */
 protected function printCaption()
 {
     // Get the list of labels
     $labelList = $this->dataSet->getTitleList();
     // Create the caption
     $caption = new Caption();
     $caption->setPlot($this->plot);
     $caption->setLabelList($labelList);
     $palette = $this->plot->getPalette();
     $barColorSet = $palette->barColorSet;
     $caption->setColorSet($barColorSet);
     // Render the caption
     $caption->render();
 }
 protected function setUp()
 {
     date_default_timezone_set('UTC');
     $inline = '<h1>Some custom code</h1>' . '<script>alert("test & more test");</script>';
     $this->article = InstantArticle::create()->withCanonicalUrl('http://foo.com/article.html')->withStyle('myarticlestyle')->withHeader(Header::create()->withTitle('Big Top Title')->withSubTitle('Smaller SubTitle')->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00')))->withModifyTime(Time::create(Time::MODIFIED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '10-Feb-2016 10:00:00')))->addAuthor(Author::create()->withName('Author Name')->withDescription('Author more detailed description'))->addAuthor(Author::create()->withName('Author in FB')->withDescription('Author user in facebook')->withURL('http://facebook.com/author'))->withKicker('Some kicker of this article')->withCover(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg')->withCaption(Caption::create()->appendText('Some caption to the image'))))->addChild(Paragraph::create()->appendText('Some text to be within a paragraph for testing.'))->addChild(Paragraph::create()->appendText('Other text to be within a second paragraph for testing.'))->addChild(Paragraph::create())->addChild(Paragraph::create()->appendText(" \n \t "))->addChild(SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home2.jpg'))->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home3.jpg')))->addChild(Paragraph::create()->appendText('Some text to be within a paragraph for testing.'))->addChild(Ad::create()->withSource('http://foo.com'))->addChild(Paragraph::create()->appendText('Other text to be within a second paragraph for testing.'))->addChild(Analytics::create()->withHTML($inline))->withFooter(Footer::create()->withCredits('Some plaintext credits.'));
 }
Example #13
0
 /**
  * Renders the caption.
  */
 protected function printCaption()
 {
     // Create a list of labels
     $labelList = array();
     foreach ($this->percent as $percent) {
         list($percent, $point) = $percent;
         $label = $point->getX();
         array_push($labelList, $label);
     }
     // Create the caption
     $caption = new Caption();
     $caption->setPlot($this->plot);
     $caption->setLabelList($labelList);
     $palette = $this->plot->getPalette();
     $pieColorSet = $palette->pieColorSet;
     $caption->setColorSet($pieColorSet);
     // Render the caption
     $caption->render();
 }
Example #14
0
 public function actionRemoveCaption()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         Yii::app()->end();
     }
     if (isset($_GET['caption_id']) && isset($_GET['slide_id'])) {
         $caption = Caption::model()->findByPk($_GET['caption_id']);
         if ($caption !== NULL) {
             $caption->delete();
             echo CJSON::encode(array('status' => 'success'));
             Yii::app()->end();
         }
     }
     echo CJSON::encode(array('status' => 'error'));
     Yii::app()->end();
 }
			<?php 
$img_root = get_template_directory() . '/assets/images/';
global $post;
$all_pages = BaseController::get_all_from_type('page');
$programmes = get_page_children($post->ID, $all_pages);
foreach ($programmes as $page_obj) {
    $anchor = '<a href="#">';
    if (!$page_obj instanceof WP_Post || 'publish' !== $page_obj->post_status) {
        continue;
    } else {
        $anchor = exchange_create_link(BaseController::exchange_factory($page_obj), false);
        $slug = array_search($page_obj->post_title, $GLOBALS['EXCHANGE_PLUGIN_CONFIG']['IMAGES']['programme-logos']);
        if (!empty($slug)) {
            echo $anchor . exchange_build_svg($img_root . 'svg/T_logo_' . $slug . '_WEB.svg', true) . '</a>';
        }
    }
}
?>
			</div>
			<?php 
if (class_exists('Caption')) {
    $caption_text = '<p>Building it together. Illustration copyright &copy; Erica Brisson, 2014-15</p>';
    $modifiers = array('classes' => array('text-right'));
    $caption = new Caption($caption_text, 'image');
    $caption->publish();
}
?>
		</figure>
	</div>
</section>
Example #16
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Caption the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Caption::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }