/**
  * For each CTA element in array, embed the right pattern class instantiation.
  *
  * @since 0.1.0
  *
  * @param string $type String describing the kind of block we're building.
  *
  * @TODO proper Error notifications.
  **/
 protected function build_block_elements()
 {
     // Check for CTA elements.
     foreach ($this->input as $e) {
         switch ($e['acf_fc_layout']) {
             case 'block_graphic':
                 $image_arr = $e['block_graphic_select'];
                 if (empty($image_arr) || empty($image_arr['mime_type'])) {
                     break;
                 }
                 $image_mods = array();
                 if ('image/svg+xml' === $image_arr['mime_type']) {
                     $image = new ImageSVG($image_arr, $this->element, $image_mods);
                 } else {
                     $image = new Image($image_arr, $this->element, $image_mods);
                 }
                 $this->output .= $image->embed();
                 break;
             case 'block_logo':
                 if (!empty($e['block_programme'])) {
                     $colour = isset($this->modifiers['colour']) ? $this->modifiers['colour'] : 'default';
                     $image_mods = array('background-colour' => $colour);
                     $image = new ImageSVG($e['block_programme'], $this->element, $image_mods);
                     $this->output .= $image->embed();
                 }
                 break;
             case 'block_paragraph':
                 if (!empty($e['block_paragraph_text'])) {
                     $paragraph = new Paragraph($e['block_paragraph_text'], $this->element);
                     $this->output .= $paragraph->embed();
                 }
                 break;
             case 'block_header':
                 if (!empty($e['block_header_text'])) {
                     $subheader = new SubHeader($e['block_header_text'], $this->element);
                     $this->output .= $subheader->embed();
                 }
                 break;
             case 'block_button':
                 $button_mods = array('link' => array(), 'data' => array());
                 if (!empty($e['button_link'])) {
                     $button_mods['link']['href'] = $e['button_link'];
                 }
                 if (!empty($e['button_target'])) {
                     $button_mods['link']['target'] = $e['button_target'];
                 }
                 if (!empty($e['button_help_text'])) {
                     $button_mods['link']['title'] = $e['button_help_text'];
                 }
                 if (!empty($e['button_size'])) {
                     $button_mods['size'] = $e['button_size'];
                 }
                 $button = new Button($e, $this->element, $button_mods);
                 $this->output .= $button->embed();
                 break;
             default:
                 break;
         }
     }
 }
 protected function build_block_elements()
 {
     // Subheader.
     $section_header_text = !empty($this->input['uploaded_files_header']) ? $this->input['uploaded_files_header'] : __('Available downloads', EXCHANGE_PLUGIN);
     $section_header_mods = array('type' => 'taped_header', 'colour' => exchange_slug_to_hex('blue-3'));
     $section_header = new SectionHeader($section_header_text, $this->element, $section_header_mods);
     $this->output .= $section_header->embed();
     // Paragraph.
     $paragraph_text = '<ul class="documentblock__file-list dont-break-out">';
     foreach ($this->input['add_file'] as $doc) {
         if (!is_numeric($doc['file'])) {
             continue;
         }
         if (function_exists('acf_get_attachment')) {
             $meta = acf_get_attachment($doc['file']);
         }
         if (empty($meta)) {
             continue;
         }
         $description = !empty($meta['description']) ? $meta['description'] : $meta['filename'];
         $paragraph_text .= '<li class="documentblock__file-list__item">';
         $paragraph_text .= '<a href="' . $meta['url'] . '" target="_blank">' . $description . '</a>';
         $paragraph_text .= '</li>';
     }
     $paragraph_text .= '</ul>';
     $paragraph = new Paragraph($paragraph_text, $this->element);
     $this->output .= $paragraph->embed();
 }
예제 #3
0
 /**
  * @param $unit
  * @return \AbstractComponent
  */
 private function getErrorMessage($unit)
 {
     $errorMsg = new \Paragraph();
     $properties = $errorMsg->getElementProperties();
     $properties->addClass('vf__error');
     $validation = new \Validation();
     $errorMsg->setContent($validation->getNotVaildValueMessage($unit));
     return $errorMsg;
 }
예제 #4
0
 /**
  * getIndex() and setIndex() should get and set the index, respectively
  */
 public function testGetSetIndex()
 {
     $index = 999;
     $paragraph = new Paragraph();
     $paragraph->setIndex($index);
     $expected = $index;
     $actual = $paragraph->getIndex();
     $this->assertEquals($expected, $actual);
     return;
 }
 public function testRenderWithSingleContainerUnordered()
 {
     $list = ListElement::createUnordered()->addItem(ListItem::create()->appendText(Paragraph::create()->appendText('Item 1')))->addItem(ListItem::create()->appendText(Div::create()->appendText('Item 2')))->addItem(ListItem::create()->appendText(Span::create()->appendText('Item 3')));
     $expected = '<ul>' . '<li><p>Item 1</p></li>' . '<li><div>Item 2</div></li>' . '<li><span>Item 3</span></li>' . '</ul>';
     $rendered = $list->render();
     $this->assertEquals($expected, $rendered);
 }
 public function testIsRTLEnabled()
 {
     $article = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->enableRTL()->withHeader(Header::create()->withTitle(H1::create()->appendText('Peace on <b>earth</b>'))->addAuthor(Author::create()->withName('bill'))->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00'))))->addChild(Paragraph::create()->appendText('Yes, peace is good for everybody!')->appendText(LineBreak::create())->appendText(' Man kind.'));
     $result = $article->render();
     $expected = '<!doctype html>' . '<html dir="rtl">' . '<head>' . '<link rel="canonical" href="http://wp.localtest.me/2016/04/12/stress-on-earth/"/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="1.5.2"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<header>' . '<h1>Peace on &lt;b&gt;earth&lt;/b&gt;</h1>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<address>' . '<a>bill</a>' . '</address>' . '</header>' . '<p>Yes, peace is good for everybody!<br/> Man kind.</p>' . '</article>' . '</body>' . '</html>';
     $this->assertEquals($expected, $result);
 }
예제 #7
0
 public function testRenderWithParagraphCreditsAppend()
 {
     $footer = Footer::create()->addCredit(Paragraph::create()->appendText('Some paragraph credits.'))->addCredit(Paragraph::create()->appendText('Other paragraph credits.'));
     $expected = '<footer>' . '<aside>' . '<p>' . 'Some paragraph credits.' . '</p>' . '<p>' . 'Other paragraph credits.' . '</p>' . '</aside>' . '</footer>';
     $rendered = $footer->render();
     $this->assertEquals($expected, $rendered);
 }
 public function testRenderWithNestedFormattedText()
 {
     $paragraph = Paragraph::create()->appendText(Bold::create()->appendText('Some ')->appendText(Italic::create()->appendText('nested formatting'))->appendText('.'));
     $expected = '<p>' . '<b>Some <i>nested formatting</i>.</b>' . '</p>';
     $rendered = $paragraph->render();
     $this->assertEquals($expected, $rendered);
 }
 /**
  * Build interview, QA-style.
  *
  * @return HTML string with questions and answers
  **/
 public function build_interview()
 {
     if (is_array($this->input) && count($this->input) > 0) {
         $output = '';
         foreach ($this->input as $qa) {
             if (!empty($qa['question']) && !empty($qa['answer'])) {
                 $modifiers_q = array('style' => 'question');
                 $modifiers_a = array('style' => 'answer');
                 $question = new Paragraph($qa['question'], $this->element, $modifiers_q);
                 $answer = new Paragraph($qa['answer'], $this->element, $modifiers_a);
                 $output .= $question->embed();
                 $output .= $answer->embed();
             }
         }
         return $output;
     }
     return __('There are no questions or answers to show here!', EXCHANGE_PLUGIN);
 }
 /**
  * Build interview, Conversation-style.
  *
  * @return HTML string with names and statements.
  **/
 public function build_interview()
 {
     if (is_array($this->input) && !empty($this->input)) {
         $output = '';
         foreach ($this->input as $vs) {
             if (!empty($vs['voice']) && !empty($vs['statement'])) {
                 $voice = '<td class="' . $this->element . '__voice">' . $vs['voice'] . '</td>';
                 $statement = '<td class="' . $this->element . '__statement">' . $vs['statement'] . '</td>';
                 $row = '<tr>' . $voice . $statement . '</tr>';
                 $output .= $row;
             }
         }
         $paragraph = new Paragraph('<table>' . $output . '</table>', $this->element);
         return $paragraph->embed();
     } else {
         return __('There are no questions or answers to show here!', EXCHANGE_PLUGIN);
     }
 }
예제 #11
0
 /**
  * Add paragraph to Area
  *
  * #### Example
  * ```php
  * $objArea->addParagraph(
  *     "Cool paragraph with lots of text in it. It's an absolute must-read.",
  *     "You must read this"
  * );
  * ```
  *
  * @param string $strBody The paragraph's body text
  * @param string $strHeader The paragraph's optional header
  * @param array $meta Standard meta array
  * @return \ValidFormBuilder\Paragraph
  */
 public function addParagraph($strBody, $strHeader = "", $meta = array())
 {
     $objParagraph = new Paragraph($strHeader, $strBody, $meta);
     $objParagraph->setMeta("parent", $this, true);
     // *** Add field to the fieldset.
     $this->__fields->addObject($objParagraph);
     return $objParagraph;
 }
 public function publish_org_description()
 {
     $desc = $this->org_description;
     if (!empty($desc)) {
         $desc_obj = new Paragraph($desc, 'participant__organisation__description');
         $desc_obj->publish_stripped();
     }
 }
예제 #13
0
         $paragraph->SetText(str_replace("\"", "\\\"", $para_text));
         $paragraph->SetDate($date->GetDate());
         $paragraph->SetOrder($para_order);
         $paragraph->SetUser($para_user_id);
         $paragraph->SetPage($para_page_id);
         if ($paragraph->Update()) {
             $message_position = 6;
             $message = $screen_module_name . " alterado com sucesso.";
         } else {
             $message_position = 6;
             $message = "Problemas na operação.";
         }
     }
 }
 if ($action == 4) {
     $paragraph = new Paragraph();
     $paragraph->SetDatabase($database);
     $paragraph->SetId($para_id);
     if ($paragraph->Delete()) {
         $date = new Date();
         $message_position = 6;
         $message = $screen_module_name . " excluído com sucesso.";
         $para_id = "";
         $para_text = "";
         $para_date = $date->GetNowFull();
         $para_order = "";
         $para_user_id = $guardian->GetUserId();
         $para_page_id = "";
     } else {
         $message_position = 6;
         $message = "Problemas na operação.";
예제 #14
0
 * doQueryOrder.php
 *
 * Query order for paragraphs page.
 *
 * Written by: Bruno Schifer Bernardi
 * Last Updated: September 27, 2007
 */
?>

<?php 
require '../constants/cdConstants.php';
require '../src/cdDatabase.php';
require '../src/cdParagraph.php';
?>

<?php 
$page_id = $_GET["p_para_page_id"];
$paragraph = new Paragraph();
$paragraph->SetDatabase($database);
$paragraph->SetPage($page_id);
$next_order = $paragraph->SelectNextOrder();
?>

<script language="Javascript">

	parent.document.form_admin.p_para_order.value = "<?php 
echo $next_order;
?>
";

</script>
        if ($arti_id != "") {
            $page->SetArticle($arti_id);
            $page->SelectFirstPageByArticle($arti_id);
        }
    }
    $page_id = $page->GetId();
    echo "Página: " . $page->GetNumber() . "<br>";
    ?>

							</td>
						</tr>
						<tr>
							<td bgcolor="#FFFFFF" align="left" width="100%"><br>

<?php 
    $paragraph = new Paragraph();
    $paragraph->SetDatabase($database);
    $paragraph->SetPage($page_id);
    $result = $paragraph->SelectByPage();
    while ($data = $database->FetchArray($result)) {
        echo $data["para_text"];
    }
    ?>
			

							</td>
						</tr>
						<tr>
							<td bgcolor="#FFFFFF" align="center" width="100%">

<?php 
예제 #16
0
 /**
  * Executes paragraphCreate action
  *
  * @param sfRequest $request A request object
  */
 public function createNewParagraph($id)
 {
     $paragraph = new Paragraph();
     $paragraph->setIdContent($id);
     $paragraph->save();
     if (!$paragraph->getId()) {
         // action on error
         exit;
     }
     return $paragraph;
 }
예제 #17
0
 /**
  * @dataProvider dataProviderTestGetDefines
  */
 public function testGetDefines($string, $count, array $getDefines)
 {
     $paragraph = new Paragraph($string);
     $this->assertSame($count, $paragraph->getCount());
     $this->assertSame($getDefines, array_keys($paragraph->getDefines()));
 }
예제 #18
0
 function DropTables()
 {
     $moderator = new Moderator();
     $moderator->SetDatabase($this);
     $moderator->Drop();
     $message = new Message();
     $message->SetDatabase($this);
     $message->Drop();
     $topic = new Topic();
     $topic->SetDatabase($this);
     $topic->Drop();
     $user_info = new UserInfo();
     $user_info->SetDatabase($this);
     $user_info->Drop();
     $session = new Session();
     $session->SetDatabase($this);
     $session->Drop();
     $new = new News();
     $new->SetDatabase($this);
     $new->Drop();
     $shout = new Shout();
     $shout->SetDatabase($this);
     $shout->Drop();
     $paragraph = new Paragraph();
     $paragraph->SetDatabase($this);
     $paragraph->Drop();
     $privilege = new Privilege();
     $privilege->SetDatabase($this);
     $privilege->Drop();
     $role = new Role();
     $role->SetDatabase($this);
     $role->Drop();
     $menu_item = new MenuItem();
     $menu_item->SetDatabase($this);
     $menu_item->Drop();
     $module = new Module();
     $module->SetDatabase($this);
     $module->Drop();
     $page = new Page();
     $page->SetDatabase($this);
     $page->Drop();
     $article = new Article();
     $article->SetDatabase($this);
     $article->Drop();
     $subject = new Subject();
     $subject->SetDatabase($this);
     $subject->Drop();
     $menu = new Menu();
     $menu->SetDatabase($this);
     $menu->Drop();
     $profile = new Profile();
     $profile->SetDatabase($this);
     $profile->Drop();
     $user = new User();
     $user->SetDatabase($this);
     $user->Drop();
 }
예제 #19
0
 /**
  * Adds a \ValidFormBuilder\Paragraph object to the internal elements collection.
  *
  * This renders a paragraph inside the form. Formfields can be added before and after the paragraph.
  * **Example:**
  *
  * ```php
  * $objForm->addField("name", "Your Name", ValidForm::VFORM_STRING);
  * $objForm->addParagraph("Next, you should enter your last name.", "Enter your name!");
  * $objForm->addField("last-name", "Last Name", ValidForm::VFORM_STRING);
  * ```
  *
  * @param string $strBody Paragraph body
  * @param string $strHeader Optional header above the paragraph
  * @param array $meta Custom meta array
  * @return \ValidFormBuilder\Paragraph
  */
 public function addParagraph($strBody, $strHeader = "", $meta = array())
 {
     $objParagraph = new Paragraph($strHeader, $strBody, $meta);
     // *** Fieldset already defined?
     $objFieldset = $this->__elements->getLast("ValidFormBuilder\\Fieldset");
     if ($this->__elements->count() == 0 || !is_object($objFieldset)) {
         $objFieldset = $this->addFieldset();
     }
     $objParagraph->setMeta("parent", $objFieldset, true);
     // *** Add field to the fieldset.
     $objFieldset->addField($objParagraph);
     return $objParagraph;
 }
예제 #20
0
 $page = new Page();
 $page->SetDatabase($database);
 $page->Backup($handle1, $handle2);
 $menu = new Menu();
 $menu->SetDatabase($database);
 $menu->Backup($handle1, $handle2);
 $module = new Module();
 $module->SetDatabase($database);
 $module->Backup($handle1, $handle2);
 $new = new News();
 $new->SetDatabase($database);
 $new->Backup($handle1, $handle2);
 $profile = new Profile();
 $profile->SetDatabase($database);
 $profile->Backup($handle1, $handle2);
 $paragraph = new Paragraph();
 $paragraph->SetDatabase($database);
 $paragraph->Backup($handle1, $handle2);
 $privilege = new Privilege();
 $privilege->SetDatabase($database);
 $privilege->Backup($handle1, $handle2);
 $role = new Role();
 $role->SetDatabase($database);
 $role->Backup($handle1, $handle2);
 $menu_item = new MenuItem();
 $menu_item->SetDatabase($database);
 $menu_item->Backup($handle1, $handle2);
 $shout = new Shout();
 $shout->SetDatabase($database);
 $shout->Backup($handle1, $handle2);
 $user_info = new UserInfo();
 public function createParagraph($paragraphNum = 1)
 {
     $paragraph = new Paragraph();
     $paragraph->setIdDocument($this->getIdDocument());
     $paragraph->setDocumentOrder($paragraphNum);
     $paragraph->save();
     return $paragraph;
 }
 public function testIsValid()
 {
     $ia = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->withHeader(Header::create()->withTitle(H1::create()->appendText('Peace on <b>earth</b>'))->addAuthor(Author::create()->withName('bill'))->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00'))))->addChild(Paragraph::create()->appendText('Yes, peace is good for everybody!')->appendText(LineBreak::create())->appendText(' Man kind.'));
     $this->assertTrue($ia->isValid());
 }
예제 #23
0
     $module = new Module();
     $module->SetDatabase($database);
     $module->Create();
     break;
 case 10:
     $new = new News();
     $new->SetDatabase($database);
     $new->Create();
     break;
 case 11:
     $profile = new Profile();
     $profile->SetDatabase($database);
     $profile->Create();
     break;
 case 12:
     $paragraph = new Paragraph();
     $paragraph->SetDatabase($database);
     $paragraph->Create();
     break;
 case 13:
     $privilege = new Privilege();
     $privilege->SetDatabase($database);
     $privilege->Create();
     break;
 case 14:
     $role = new Role();
     $role->SetDatabase($database);
     $role->Create();
     break;
 case 15:
     $menu_item = new MenuItem();
 protected function build_translation($translation)
 {
     $lang_term = $this->get_translation_language($translation);
     if (empty($lang_term)) {
         return;
     }
     $p_mods = array('lang' => $lang_term->slug, 'misc' => array('id' => $lang_term->slug));
     if ($lang_term->description === 'rtl') {
         $p_mods['misc']['dir'] = 'rtl';
     }
     $p = new Paragraph($translation['translation_text'], $this->element, $p_mods);
     $this->output .= $p->embed();
 }