public static function content(ContentBlockController $controller) { $content = $controller->getSearchableContent(); $dom = new HtmlDomParser(); $r = $dom->str_get_html($content, true, true, DEFAULT_TARGET_CHARSET, false); if (is_object($r)) { foreach ($r->find('concrete-picture') as $picture) { $fID = $picture->fid; $fo = File::getByID($fID); if (is_object($fo)) { $tag = new AmpImg($fo); $tag->alt($picture->alt); $picture->outertext = (string) $tag; } } foreach ($r->find('img') as $img) { $tag = new Element('amp-img'); $tag->alt($img->alt); $tag->src($img->src); $tag->height($img->height); $tag->width($img->width); $img->outertext = (string) $tag; } foreach ($r->find('*[style]') as $element) { $element->removeAttribute('style'); } $content = (string) $r->restore_noise($r); } $content = LinkAbstractor::translateFrom($content); return $content; }
/** * This is taking data OUT of the database and sending it into the page. * @dataProvider contentsFrom */ public function testFrom($from, $to) { self::createPage('Awesome'); self::createPage('All Right', '/awesome'); $translated = \Concrete\Core\Editor\LinkAbstractor::translateFrom($from); $this->assertEquals($to, $translated); }
public function save($args) { $session = Core::make('app')->make('session'); $session->set('msv_code_display.lastFontSize', $this->post('fontSize')); $session->set('msv_code_display.lastLanguage', $this->post('language')); $session->set('msv_code_display.lastTheme', $this->post('theme')); $session->set('msv_code_display.lastShowLineNumbers', $this->post('showLineNumbers')); $session->set('msv_code_display.lastlineWrapping', $this->post('lineWrapping')); $args['showLineNumbers'] = $args['showLineNumbers'] ? 1 : 0; $args['showInvisibles'] = $args['showInvisibles'] ? 1 : 0; $args['lineWrapping'] = $args['lineWrapping'] ? 1 : 0; $args['content'] = isset($args['content']) ? base64_decode($args['content']) : ''; $args['title'] = trim($args['title']); $args['fontSize'] = max($args['fontSize'], 2); $args['maximumLines'] = max($args['maximumLines'], 0); $args['description'] = LinkAbstractor::translateTo($args['description']); parent::save($args); }
public function testFrom() { $from = '<p>This is really nice.</p><concrete-picture fID="1" alt="Happy Cat" />'; // create the default storage location first. mkdir($this->getStorageDirectory()); $this->getStorageLocation(); $fi = new \Concrete\Core\File\Importer(); $file = dirname(__FILE__) . '/fixtures/background-slider-blue-sky.png'; $r = $fi->import($file, 'background-slider-blue-sky.png'); $path = $r->getRelativePath(); $translated = \Concrete\Core\Editor\LinkAbstractor::translateFrom($from); $to = '<p>This is really nice.</p><img src="' . $path . '" alt="Happy Cat" width="48" height="20">'; $this->assertEquals('background-slider-blue-sky.png', $r->getFilename()); $this->assertEquals($to, $translated); $c = new \Concrete\Block\Content\Controller(); $c->content = $from; $sx = new SimpleXMLElement('<test />'); $c->export($sx); $content = (string) $sx->data->record->content; $this->assertEquals('<p>This is really nice.</p><concrete-picture alt="Happy Cat" file="background-slider-blue-sky.png" />', $content); }
public function save($args) { $args += array('timeout' => 4000, 'speed' => 500); $args['timeout'] = intval($args['timeout']); $args['speed'] = intval($args['speed']); $args['noAnimate'] = isset($args['noAnimate']) ? 1 : 0; $args['pause'] = isset($args['pause']) ? 1 : 0; $args['maxWidth'] = isset($args['maxWidth']) ? intval($args['maxWidth']) : 0; $db = Database::get(); $db->execute('DELETE from btImageSliderEntries WHERE bID = ?', array($this->bID)); parent::save($args); if (isset($args['sortOrder'])) { $count = count($args['sortOrder']); $i = 0; while ($i < $count) { $linkURL = $args['linkURL'][$i]; $internalLinkCID = $args['internalLinkCID'][$i]; switch (intval($args['linkType'][$i])) { case 1: $linkURL = ''; break; case 2: $internalLinkCID = 0; break; default: $linkURL = ''; $internalLinkCID = 0; break; } if (isset($args['description'][$i])) { $args['description'][$i] = LinkAbstractor::translateTo($args['description'][$i]); } $db->execute('INSERT INTO btImageSliderEntries (bID, fID, title, description, sortOrder, linkURL, internalLinkCID) values(?, ?, ?, ?,?,?,?)', array($this->bID, intval($args['fID'][$i]), $args['title'][$i], $args['description'][$i], $args['sortOrder'][$i], $linkURL, $internalLinkCID)); ++$i; } } $this->tracker->track($this); }
/** * This is taking data OUT of the database and sending it into the page. * @dataProvider contentsFrom */ public function testFrom($from, $to) { $translated = LinkAbstractor::translateFrom($from); $this->assertEquals($to, $translated); }
public function save($args) { switch (isset($args['linkType']) ? intval($args['linkType']) : 0) { case 1: $args['externalLink'] = ''; break; case 2: $args['internalLinkCID'] = 0; break; default: $args['externalLink'] = ''; $args['internalLinkCID'] = 0; break; } $args['paragraph'] = LinkAbstractor::translateTo($args['paragraph']); unset($args['linkType']); parent::save($args); }
/** * Pre-proccess the block data before save. * * @param array $args * @return array */ public function save($args) { if (isset($args['content'])) { $args['content'] = LinkAbstractor::translateTo($args['content']); } if ('parallax' === $args['background_type']) { $args['background_image_position'] = 'center'; $args['background_image_attachment'] = 'fixed'; } elseif ('video' === $args['background_type']) { $args['background_image_position'] = 'top left'; $args['background_image_size'] = 'cover'; $args['background_image_attachment'] = 'scroll'; } if ('video' !== $args['background_type']) { $args['video_url'] = ''; } if ('parallax' === $args['mask_type']) { $args['mask_image_position'] = 'center'; $args['mask_image_size'] = 'auto'; $args['mask_image_attachment'] = 'fixed'; } elseif ('none' === $args['mask_type']) { $args['mask_image_file_id'] = 0; } parent::save($args); }
public function view() { $c = $this->request->getCurrentPage(); if (!is_object($c) || $c->isError()) { $c = null; } if ($c !== null && $c->isEditMode()) { $this->set('output', '<div class="ccm-edit-mode-disabled-item"><div style="padding: 10px 5px">' . t('Redirect block') . '</div></div>'); } else { $showMessage = false; switch ($this->showMessage) { case self::SHOWMESSAGE_ALWAYS: $showMessage = true; break; case self::SHOWMESSAGE_EDITORS: if ($c !== null && $this->userCanEdit($c)) { $showMessage = true; } break; } if ($showMessage) { if ($this->useCustomMessage) { $msg = (string) $this->customMessage; if ($msg !== '') { $msg = LinkAbstractor::translateFrom($msg); } } else { $msg = '<span class="redirect-block-message">' . t('This block will redirect selected users.') . '</span>'; } $this->set('output', $msg); } } }
<?php echo $form->checkbox('useCustomMessage', '1', $useCustomMessage); ?> <?php echo t('Use a custom message'); ?> </label> </div> </div> <div class="form-group" id="reblo-customMessage"<?php echo $useCustomMessage ? '' : ' style="display: none"'; ?> > <?php echo $form->label('customMessage', t('Custom message')); ?> <?php echo Core::make('editor')->outputBlockEditModeEditor('customMessage', isset($customMessage) ? LinkAbstractor::translateFromEditMode($customMessage) : ''); ?> </div> <script> $(document).ready(function() { $('#ccm-tab-content-redirect-options .redactor-editor').css({'min-height': '0px', height: '100px'}); $('#ccm-tab-content-redirect-options #useCustomMessage').on('change', function() { $('#ccm-tab-content-redirect-options #reblo-customMessage')[this.checked ? 'show' : 'hide'](); }); }); </script> </div>
function save($args) { $args['content'] = LinkAbstractor::translateTo($args['content']); parent::save($args); }
public function save($args) { if (isset($args['content'])) { $args['content'] = LinkAbstractor::translateTo($args['content']); } parent::save($args); $this->tracker->track($this); }
public function save($args) { $args['content'] = LinkAbstractor::translateTo($args['content']); //Images are passed as-is parent::save($args); }
public function save($args) { $db = Database::get(); $db->execute('DELETE from btHeroSliderEntries WHERE bID = ?', array($this->bID)); parent::save($args); if (isset($args['sortOrder'])) { $count = count($args['sortOrder']); $i = 0; //Log::addEntry("In save"); //Log::addEntry($args['enableSlide'][1]); while ($i < $count) { $enableSlide = $args['enableSlide'][$i]; $linkURL = $args['linkURL'][$i]; $internalLinkCID = $args['internalLinkCID'][$i]; switch (intval($args['linkType'][$i])) { case 1: $linkURL = ''; break; case 2: $internalLinkCID = 0; break; default: $linkURL = ''; $internalLinkCID = 0; break; } if (isset($args['description'][$i])) { $args['description'][$i] = LinkAbstractor::translateTo($args['description'][$i]); } $db->execute('INSERT INTO btHeroSliderEntries (bID, enableSlide, heading, headingColor, description, descriptionColor, background, textLeftAlign, ctatext, internalLinkCID, linkType, externalLink, openInNewWindow, iconID, icontext, fID, fOnstateID, sortOrder) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array($this->bID, $args['enableSlide'][$i], $args['heading'][$i], $args['headingColor'][$i], $args['description'][$i], $args['descriptionColor'][$i], $args['background'][$i], $args['textLeftAlign'][$i], $args['ctatext'][$i], $args['internalLinkCID'][$i], $args['linkType'][$i], $args['externalLink'][$i], $args['openInNewWindow'][$i], $args['iconID'][$i], $args['icontext'][$i], intval($args['fID'][$i]), $args['fOnstateID'][$i], $args['sortOrder'][$i])); ++$i; } } }