예제 #1
0
 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);
 }
예제 #2
0
 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);
 }
예제 #3
0
 /**
  * This is saving data from the content editor HTML INTO the database.
  *  @dataProvider contentsTo
  */
 public function testTo($from, $to)
 {
     $translated = LinkAbstractor::translateTo($from);
     $this->assertEquals($to, $translated);
 }
예제 #4
0
 /**
  * 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);
 }
예제 #5
0
 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);
 }
 /**
  * Normalize the data set by user when adding/editing a block.
  *
  * @param array $data
  *
  * @return \Concrete\Core\Error\Error|array
  */
 private function normalize($data)
 {
     if (!isset($this->app)) {
         $this->app = \Core::make('app');
     }
     $errors = $this->app->make('helper/validation/error');
     /* @var \Concrete\Core\Error\Error $errors */
     $normalized = array();
     if (!is_array($data) || empty($data)) {
         $errors->add(t('No data received'));
     } else {
         static::loadComposer();
         $normalized['redirectToCID'] = 0;
         $normalized['redirectToURL'] = '';
         switch (isset($data['redirectToType']) ? $data['redirectToType'] : '') {
             case 'cid':
                 $normalized['redirectToCID'] = isset($data['redirectToCID']) ? (int) $data['redirectToCID'] : 0;
                 if ($normalized['redirectToCID'] <= 0) {
                     $errors->add(t('Please specify the destination page'));
                 } else {
                     $c = \Page::getCurrentPage();
                     if (is_object($c) && !$c->isError() && $c->getCollectionID() == $normalized['redirectToCID']) {
                         $errors->add(t('The destination page is the current page.'));
                     }
                 }
                 break;
             case 'url':
                 $normalized['redirectToURL'] = isset($data['redirectToURL']) ? trim((string) $data['redirectToURL']) : '';
                 if ($normalized['redirectToURL'] === '') {
                     $errors->add(t('Please specify the destination page'));
                 } else {
                     $c = \Page::getCurrentPage();
                     if (is_object($c) && !$c->isError()) {
                         $myURL = (string) \URL::to($c);
                         if (rtrim($myURL, '/') === rtrim($normalized['redirectToURL'], '/')) {
                             $errors->add(t('The destination page is the current page.'));
                         }
                     }
                 }
                 break;
             default:
                 $errors->add(t('Please specify the kind of the destination page'));
                 break;
         }
         foreach (array('redirectGroupIDs', 'dontRedirectGroupIDs') as $var) {
             $list = array();
             if (isset($data[$var]) && is_string($data[$var])) {
                 foreach (preg_split('/\\D+/', $data[$var], -1, PREG_SPLIT_NO_EMPTY) as $gID) {
                     $gID = (int) $gID;
                     if ($gID > 0 && !in_array($gID, $list, true) && \Group::getByID($gID) !== null) {
                         $list[] = $gID;
                     }
                 }
             }
             $normalized[$var] = implode(',', $list);
         }
         foreach (array('redirectIPs', 'dontRedirectIPs') as $f) {
             $normalized[$f] = '';
             if (isset($data[$f])) {
                 $v = array();
                 foreach (preg_split('/[\\s,]+/', str_replace('|', ' ', (string) $data[$f]), -1, PREG_SPLIT_NO_EMPTY) as $s) {
                     $s = trim($s);
                     if ($s !== '') {
                         $ipRange = IPFactory::rangeFromString($s);
                         if ($ipRange === null) {
                             $errors->add(t('Invalid IP address: %s', $s));
                         } else {
                             $v[] = $ipRange->toString(false);
                         }
                     }
                 }
                 if (!empty($v)) {
                     $normalized[$f] = implode('|', $v);
                 }
             }
         }
         $normalized['redirectEditors'] = isset($data['redirectEditors']) && $data['redirectEditors'] ? 1 : 0;
         $normalized['showMessage'] = isset($data['showMessage']) && $data['showMessage'] ? (int) $data['showMessage'] : 0;
         switch ($normalized['showMessage']) {
             case self::SHOWMESSAGE_NEVER:
             case self::SHOWMESSAGE_EDITORS:
             case self::SHOWMESSAGE_ALWAYS:
                 break;
             default:
                 $errors->add(t('Please specify if the message should be shown'));
                 break;
         }
         $normalized['useCustomMessage'] = isset($data['useCustomMessage']) && $data['useCustomMessage'] ? 1 : 0;
         if (isset($data['customMessage']) && is_string($data['customMessage']) && $data['customMessage'] !== '') {
             $normalized['customMessage'] = LinkAbstractor::translateTo($data['customMessage']);
         } else {
             $normalized['customMessage'] = '';
         }
     }
     return $errors->has() ? $errors : $normalized;
 }
예제 #7
0
		function save($args) {
			$args['content'] = LinkAbstractor::translateTo($args['content']);
			parent::save($args);
		}
예제 #8
0
 public function save($args)
 {
     if (isset($args['content'])) {
         $args['content'] = LinkAbstractor::translateTo($args['content']);
     }
     parent::save($args);
     $this->tracker->track($this);
 }
예제 #9
0
 public function save($args)
 {
     $args['content'] = LinkAbstractor::translateTo($args['content']);
     //Images are passed as-is
     parent::save($args);
 }
예제 #10
0
 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;
         }
     }
 }