/**
  * Get either a Gravatar URL or complete image tag for a specified email address.
  *
  * @param string $email The email address
  * @param string $size Size in pixels, defaults to 80px [ 1 - 2048 ]
  * @param string $default Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
  * @param string $rating Maximum rating (inclusive) [ g | pg | r | x ]
  * @param boole $img True to return a complete IMG tag False for just the URL
  * @param array $attr Optional, additional key/value attributes to include in the IMG tag
  * @return String containing either just a URL or a complete image tag
  * @source http://gravatar.com/site/implement/images/php/
  */
 public function get($email, $criteria, $img)
 {
     if (isset($criteria['size'])) {
         $size = $criteria['size'];
     } else {
         $size = 80;
     }
     if (isset($criteria['default'])) {
         $default = $criteria['default'];
     } else {
         $default = 'mm';
     }
     if (isset($criteria['rating'])) {
         $rating = $criteria['rating'];
     } else {
         $rating = 'g';
     }
     $url = '//www.gravatar.com/avatar/';
     $url .= md5(strtolower(trim($email)));
     $url .= "?s={$size}&d={$default}&r={$rating}";
     if ($img) {
         $url = '<img src="' . $url . '"';
         if (isset($criteria['attr'])) {
             foreach ($criteria['attr'] as $key => $val) {
                 $url .= ' ' . $key . '="' . $val . '"';
             }
         }
         $url .= ' />';
     }
     return TemplateHelper::getRaw($url);
 }
 public function getHtmlLink($attributes = false)
 {
     $url = $this->getUrl();
     $text = $this->getText();
     if ($url && $text) {
         // Open  Link
         $htmlLink = '<a href="' . $url . '"';
         // Add Title (if not in attributes)
         if (!is_array($attributes) || !array_key_exists('title', $attributes)) {
             $htmlLink .= ' title="' . $text . '"';
         }
         // Add Target (if not in attributes)
         if ((!is_array($attributes) || !array_key_exists('title', $attributes)) && $this->target) {
             $htmlLink .= ' target="' . $this->target . '"';
         }
         // Add Attributes
         if (is_array($attributes)) {
             foreach ($attributes as $attr => $value) {
                 $htmlLink .= ' ' . $attr . '="' . $value . '"';
             }
         }
         // Close Up Link
         $htmlLink .= '>' . $text . '</a>';
         // Get Raw
         return TemplateHelper::getRaw($htmlLink);
     }
     return false;
 }
 public function renderFormCustomMacro($macro, array $args)
 {
     $oldPath = craft()->path->getTemplatesPath();
     $newPath = craft()->path->getPluginsPath() . 'teammanager/templates';
     craft()->path->setTemplatesPath($newPath);
     $html = craft()->templates->renderMacro('_includes/forms', $macro, array($args));
     craft()->path->setTemplatesPath($oldPath);
     return TemplateHelper::getRaw($html);
 }
 /**
  * The Parsedown filter
  *
  * @param string $text The text to be parsed
  * @param string $mode The parsing mode ('text' or 'line').
  * @param mixed $tags
  * @return string
  */
 public function parsedownFilter($text, $parseAs = 'text')
 {
     if ($parseAs == 'line') {
         $parsed = craft()->parsedown->parseLine($text);
     } else {
         $parsed = craft()->parsedown->parseText($text);
     }
     return TemplateHelper::getRaw($parsed);
 }
 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $options = $settings['options'];
     $options = craft()->sproutFields_emailSelectField->obfuscateEmailAddresses($options);
     $rendered = craft()->templates->render('emailselect/input', array('name' => $field->handle, 'value' => $value, 'options' => $options, 'settings' => $settings, 'field' => $field));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
Example #6
0
 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $attributes = $field->getAttributes();
     $errorMessage = craft()->sproutFields_emailField->getErrorMessage($attributes['name'], $settings);
     $placeholder = isset($settings['placeholder']) ? $settings['placeholder'] : '';
     $rendered = craft()->templates->render('email/input', array('name' => $field->handle, 'value' => $value, 'field' => $field, 'pattern' => $settings['customPattern'], 'errorMessage' => $errorMessage, 'renderingOptions' => $renderingOptions, 'placeholder' => $placeholder));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
 public function staticMap($data, $options = array())
 {
     if ($data instanceof GoogleMaps_MapDataModel) {
         $model = $data->getStaticMapModel($options);
         return TemplateHelper::getRaw(craft()->googleMaps_staticMap->image($model, $options));
     } else {
         $options = array_merge($options, $data);
         $model = GoogleMaps_StaticMapModel::populateModel($options);
         return TemplateHelper::getRaw(craft()->googleMaps_staticMap->image($model, $options));
     }
 }
 public function getSettingsHtml()
 {
     // If not set, create a default row
     if (!$this->_matrixBlockColors) {
         $this->_matrixBlockColors = array(array('blockType' => '', 'backgroundColor' => ''));
     }
     // Generate table
     $matrixBlockColorsTable = craft()->templates->renderMacro('_includes/forms', 'editableTableField', array(array('label' => Craft::t('Block Type Colors'), 'instructions' => Craft::t('Add background colors to your matrix block types'), 'id' => 'matrixBlockColors', 'name' => 'matrixBlockColors', 'cols' => array('blockType' => array('heading' => Craft::t('Block Type Handle'), 'type' => 'singleline'), 'backgroundColor' => array('heading' => Craft::t('CSS Background Color'), 'type' => 'singleline', 'class' => 'code')), 'rows' => $this->_matrixBlockColors, 'addRowLabel' => Craft::t('Add a block type color'))));
     // Output settings template
     return craft()->templates->render('matrixcolors/_settings', array('matrixBlockColorsTable' => TemplateHelper::getRaw($matrixBlockColorsTable)));
 }
 /**
  * I'm invisible, I don't need to show up on the front end
  * I do need to save my value to session to retrieve it via prepValueFromPost()
  * You should also know that prepValueFromPost() won't be called unless you:
  * - Set a hidden field to an empty value with my name
  *
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     try {
         $value = craft()->templates->renderObjectTemplate($settings['value'], parent::getFieldVariables());
     } catch (\Exception $e) {
         SproutInvisibleFieldPlugin::log($e->getMessage());
     }
     craft()->httpSession->add($field->handle, $value);
     // We really don't need the extra processing that it takes to render a template
     return TemplateHelper::getRaw(sprintf('<input type="hidden" name="%s" />', $field->handle));
 }
Example #10
0
 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     try {
         $value = craft()->templates->renderObjectTemplate($settings['value'], parent::getFieldVariables());
     } catch (\Exception $e) {
         SproutFieldsPlugin::log($e->getMessage(), LogLevel::Error);
     }
     $rendered = craft()->templates->render('hidden/input', array('name' => $field->handle, 'value' => $value, 'field' => $field, 'renderingOptions' => $renderingOptions));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
Example #11
0
 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $name = $field->handle;
     $namespaceInputId = $this->getNamespace() . '-' . $name;
     $selectedStyle = $settings['style'];
     $pluginSettings = craft()->plugins->getPlugin('sproutfields')->getSettings()->getAttributes();
     $selectedStyleCss = str_replace("{{ name }}", $name, $pluginSettings[$selectedStyle]);
     $rendered = craft()->templates->render('notes/input', array('settings' => $settings, 'selectedStyleCss' => $selectedStyleCss));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
Example #12
0
 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $name = $field->handle;
     $namespaceInputId = $this->getNamespace() . '-' . $name;
     $pattern = craft()->sproutFields_phoneField->convertMaskToRegEx($settings['mask']);
     $pattern = trim($pattern, '/');
     $attributes = $field->getAttributes();
     $errorMessage = craft()->sproutFields_phoneField->getErrorMessage($attributes['name'], $settings);
     $rendered = craft()->templates->render('phone/input', array('name' => $name, 'value' => $value, 'settings' => $settings, 'field' => $field, 'pattern' => $pattern, 'errorMessage' => $errorMessage, 'namespaceInputId' => $namespaceInputId, 'renderingOptions' => $renderingOptions));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
Example #13
0
 /**
  * @param string $url
  * @param int    $limit
  * @param int    $offset
  * @param null   $cacheDuration
  *
  * @return array
  */
 public function getFeedItems($url, $limit = 0, $offset = 0, $cacheDuration = null)
 {
     $limit = NumberHelper::makeNumeric($limit);
     $offset = NumberHelper::makeNumeric($offset);
     $items = craft()->feeds->getFeedItems($url, $limit, $offset, $cacheDuration);
     // Prevent everyone from having to use the |raw filter when outputting the title and content
     $rawProperties = array('title', 'content', 'summary');
     foreach ($items as &$item) {
         foreach ($rawProperties as $prop) {
             $item[$prop] = TemplateHelper::getRaw($item[$prop]);
         }
     }
     return $items;
 }
 public function getSettingsHtml()
 {
     // If Craft Pro
     if (craft()->getEdition() == Craft::Pro) {
         $options = array();
         $userGroups = craft()->userGroups->getAllGroups();
         foreach ($userGroups as $group) {
             $options[] = array('label' => $group->name, 'value' => $group->id);
         }
         $checkboxes = craft()->templates->render('_includes/forms/checkboxGroup', array('name' => 'userGroups', 'options' => $options, 'values' => $this->getSettings()->userGroups));
         $noGroups = '<p class="error">No user groups exist. <a href="' . UrlHelper::getCpUrl('settings/users/groups/new') . '">Create one now...</a></p>';
         craft()->templates->includeCssResource('autoassignusergroup/css/settings.css');
         return craft()->templates->render('autoassignusergroup/_settings', array('userGroupsField' => TemplateHelper::getRaw(count($userGroups) ? $checkboxes : $noGroups)));
     } else {
         craft()->templates->includeJs('$(".btn.submit").val("Continue");');
         $output = '<h2>Craft Upgrade Required</h2>';
         $output .= '<p>In order to use this plugin, Craft Pro is required.</p>';
         return craft()->templates->renderString($output);
     }
 }
Example #15
0
 /**
  * Parses source markdown into valid html using various rules and parsers
  *
  * @param string $source  The markdown source to parse
  * @param array  $options Passed in parameters via a template filter call
  *
  * @return \Twig_Markup|DoxterModel The parsed content flagged as safe to output
  */
 public function parse($source, array $options = array())
 {
     if ($source instanceof DoxterModel) {
         return $source;
     }
     $codeBlockSnippet = null;
     $addHeaderAnchors = true;
     $addHeaderAnchorsTo = array('h1', 'h2', 'h3');
     $addTypographyStyles = true;
     $startingHeaderLevel = 1;
     $parseReferenceTags = true;
     $parseShortcodes = true;
     $options = array_merge(craft()->plugins->getPlugin('doxter')->getSettings()->getAttributes(), $options);
     extract($options);
     // Parsing reference tags first so that we can parse markdown within them
     if ($parseReferenceTags) {
         if ($this->onBeforeReferenceTagParsing(compact('source', 'options'))) {
             $source = $this->parseReferenceTags($source, $options);
         }
     }
     if ($parseShortcodes) {
         if ($this->onBeforeShortcodeParsing(compact('source'))) {
             $source = $this->parseShortcodes($source);
         }
     }
     if ($this->onBeforeMarkdownParsing(compact('source'))) {
         $source = $this->parseMarkdown($source);
     }
     if ($this->onBeforeCodeBlockParsing(compact('source', 'codeBlockSnippet'))) {
         $source = $this->parseCodeBlocks($source, compact('codeBlockSnippet'));
     }
     if ($addHeaderAnchors) {
         if ($this->onBeforeHeaderParsing(compact('source', 'addHeaderAnchorsTo'))) {
             $source = $this->parseHeaders($source, compact('addHeaderAnchorsTo', 'startingHeaderLevel'));
         }
     }
     if ($addTypographyStyles) {
         $source = $this->addTypographyStyles($source, $options);
     }
     return TemplateHelper::getRaw($source);
 }
 protected function injector($text, $class = 'chars', $after = '')
 {
     switch ($class) {
         case 'words':
             $parts = explode(' ', trim(strip_tags($text)));
             break;
         case 'lines':
             $parts = preg_split('/<br[^>]*>/i', strip_tags(nl2br(trim($text)), '<br>'));
             break;
         default:
             $parts = str_split(trim(strip_tags($text)));
             break;
     }
     $count = 1;
     $formattedParts = array_map(function ($part) use(&$count, $class, $after) {
         $part = '<span class="' . substr($class, 0, -1) . $count . '" aria-hidden="true">' . $part . '</span>' . $after;
         $count = $count + 1;
         return $part;
     }, $parts);
     $ariaLabel = TemplateHelper::getRaw(' aria-label="' . trim(strip_tags($text)) . '"');
     $joined = TemplateHelper::getRaw(implode('', $formattedParts));
     $result = ['original' => $text, 'ariaLabel' => $ariaLabel, $class => $joined];
     return $result;
 }
 /**
  * Renders the recipient list UI for this mailer
  *
  * @param SproutEmail_EntryModel[] $values
  *
  * @return string|\Twig_Markup
  */
 public function getRecipientListsHtml(array $values = null)
 {
     $lists = $this->getRecipientLists();
     $options = array();
     $selected = array();
     if (!count($lists)) {
         return craft()->templates->render('sproutemail/settings/_defaultmailer-norecipients');
     }
     foreach ($lists as $list) {
         $options[] = array('label' => $list->name, 'value' => $list->id);
     }
     if (is_array($values) && count($values)) {
         foreach ($values as $value) {
             $selected[] = $value->list;
         }
     }
     $html = craft()->templates->renderMacro('_includes/forms', 'checkboxGroup', array(array('id' => 'recipientLists', 'name' => 'recipient[recipientLists]', 'options' => $options, 'values' => $selected)));
     return TemplateHelper::getRaw($html);
 }
 /**
  * Returns an anchor pre-filled with this element's URL and title.
  *
  * @return \Twig_Markup
  */
 public function getLink()
 {
     $link = '<a href="' . $this->getUrl() . '">' . HtmlHelper::encode($this->__toString()) . '</a>';
     return TemplateHelper::getRaw($link);
 }
 /**
  * Renders an error template.
  *
  * @throws \Exception
  * @return null
  */
 public function actionRenderError()
 {
     $error = craft()->errorHandler->getError();
     $code = (string) $error['code'];
     if (craft()->request->isSiteRequest()) {
         $prefix = craft()->config->get('errorTemplatePrefix');
         if (craft()->templates->doesTemplateExist($prefix . $code)) {
             $template = $prefix . $code;
         } else {
             if ($code == 503 && craft()->templates->doesTemplateExist($prefix . 'offline')) {
                 $template = $prefix . 'offline';
             } else {
                 if (craft()->templates->doesTemplateExist($prefix . 'error')) {
                     $template = $prefix . 'error';
                 }
             }
         }
     }
     if (!isset($template)) {
         craft()->templates->setTemplateMode(TemplateMode::CP);
         if (craft()->templates->doesTemplateExist($code)) {
             $template = $code;
         } else {
             $template = 'error';
         }
     }
     try {
         $variables = array_merge($error);
         // Escape any inner-word underscores, which Markdown mistakes for italics
         // TODO: This won't be necessary in 3.0 thanks to Parsedown
         $variables['message'] = preg_replace('/(?<=[a-zA-Z])_(?=[a-zA-Z])/', '\\_', $variables['message']);
         // If this is a PHP error and html_errors (http://php.net/manual/en/errorfunc.configuration.php#ini.html-errors)
         // is enabled, then allow the HTML not get encoded
         if (strncmp($variables['type'], 'PHP ', 4) === 0 && AppHelper::getPhpConfigValueAsBool('html_errors')) {
             $variables['message'] = TemplateHelper::getRaw($variables['message']);
         }
         $this->renderTemplate($template, $variables);
     } catch (\Exception $e) {
         if (YII_DEBUG) {
             throw $e;
         } else {
             // Just output the error message
             echo str_replace(array('“', '”', '‘', '’'), array('"', '"', '\'', '\''), $e->getMessage());
         }
     }
 }
 public function autoLinkTweet($text, $options = array())
 {
     $html = craft()->twitter->autoLinkTweet($text, $options);
     return TemplateHelper::getRaw($html);
 }
Example #21
0
 /**
  * Returns an <img> tag based on this asset.
  *
  * @return \Twig_Markup|null
  */
 public function getImg()
 {
     if ($this->kind == 'image') {
         $img = '<img src="' . $this->url . '" width="' . $this->getWidth() . '" height="' . $this->getHeight() . '" alt="' . HtmlHelper::encode($this->title) . '" />';
         return TemplateHelper::getRaw($img);
     }
 }
Example #22
0
 public function renderJSONLD($object = array())
 {
     $result = craft()->seomatic->renderJSONLD($object);
     return TemplateHelper::getRaw(rtrim($result));
 }
 /**
  * Sends a password reset email to a user.
  *
  * A new verification code will generated for the user overwriting any existing one.
  *
  * @param UserModel $user The user to send the forgot password email to.
  *
  * @return bool Whether the email was sent successfully.
  */
 public function sendPasswordResetEmail(UserModel $user)
 {
     $url = $this->getPasswordResetUrl($user);
     return craft()->email->sendEmailByKey($user, 'forgot_password', array('link' => TemplateHelper::getRaw($url)));
 }
 /**
  * Returns a link to the control panel section for the mailer passed in
  *
  * @param SproutEmailBaseMailer $mailer
  *
  * @deprecate Deprecated for 0.9.0 in favour of BaseMailer API
  *
  * @return string|\Twig_Markup
  */
 public function getMailerCpSectionLink(SproutEmailBaseMailer $mailer)
 {
     $vars = array('name' => $mailer->getId(), 'title' => $mailer->getTitle(), 'sproutemail' => UrlHelper::getCpUrl('sproutemail'));
     $template = '<a href="{sproutemail}/{name}" title="{title}">{title}</a>';
     try {
         $link = craft()->templates->renderObjectTemplate($template, $vars);
         return TemplateHelper::getRaw($link);
     } catch (\Exception $e) {
         sproutEmail()->error('Unable to create Control Panel Section link for {name}', $vars);
         return $mailer->getTitle();
     }
 }
 /**
  * Returns getFootHtml() wrapped in a \Twig_Markup object.
  *
  * @return \Twig_Markup
  */
 public function getFootHtmlFunction()
 {
     $html = craft()->templates->getFootHtml();
     return TemplateHelper::getRaw($html);
 }
Example #26
0
 public function getDescription()
 {
     return TemplateHelper::getRaw("Adds a <strong style='color:red'><code>dbug</code></strong> function to pretty dump variables in twig.");
 }
Example #27
0
 /**
  * Finish importing.
  *
  * @param array  $settings
  * @param string $backup
  */
 public function finish($settings, $backup)
 {
     craft()->import_history->end($settings['history'], ImportModel::StatusFinished);
     if ($settings['email']) {
         // Gather results
         $results = array('success' => $settings['rows'], 'errors' => array());
         // Gather errors
         foreach ($this->log as $line => $result) {
             $results['errors'][$line] = $result;
         }
         // Recalculate successful results
         $results['success'] -= count($results['errors']);
         // Prepare the mail
         $email = new EmailModel();
         $emailSettings = craft()->email->getSettings();
         $email->toEmail = $emailSettings['emailAddress'];
         // Get current user
         $currentUser = craft()->userSession->getUser();
         // Zip the backup
         if ($currentUser->can('backup') && $settings['backup'] && IOHelper::fileExists($backup)) {
             $destZip = craft()->path->getTempPath() . IOHelper::getFileName($backup, false) . '.zip';
             if (IOHelper::fileExists($destZip)) {
                 IOHelper::deleteFile($destZip, true);
             }
             IOHelper::createFile($destZip);
             if (Zip::add($destZip, $backup, craft()->path->getDbBackupPath())) {
                 $backup = $destZip;
             }
         }
         // Set email content
         $email->subject = Craft::t('The import task is finished');
         $email->htmlBody = TemplateHelper::getRaw(craft()->templates->render('import/_email', array('results' => $results, 'backup' => $backup)));
         // Send it
         craft()->email->sendEmail($email);
     }
 }
 /**
  * @param null|array $selected
  *
  * @return \Twig_Markup
  */
 public function getRecipientListsHtml($selected = null)
 {
     $lists = $this->getRecipientLists();
     $options = array();
     if (count($lists)) {
         foreach ($lists as $list) {
             $options[] = array('label' => sprintf('%s (%d)', $list->name, count($list->recipients)), 'value' => $list->id);
         }
     }
     $html = craft()->templates->renderMacro('_includes/forms', 'checkboxGroup', array(array('id' => 'recipientLists', 'name' => 'recipient[recipientLists]', 'options' => $options, 'values' => $selected)));
     return TemplateHelper::getRaw($html);
 }
Example #29
0
 /**
  * Preps the field value for use.
  *
  * @param mixed $value
  * @return mixed
  */
 public function prepValue($value)
 {
     if (is_array($value)) {
         // Get Defaults
         $defaults = $this->getLinkitValueDefaults();
         // Settings
         $settings = $this->getSettings();
         // Merge With Defaults
         $value = array_merge($defaults, $value);
         // Process?
         if ($value['type'] == '') {
             $value = false;
         } else {
             // Process Entry Field - Criteria
             // TODO - Should I Be Using the craft()->entries->getEntryById( $entryId )
             $entryCriteria = craft()->elements->getCriteria(ElementType::Entry);
             if ($value['entry'] && $value['type'] == 'entry') {
                 if (is_array($value['entry'])) {
                     $entryCriteria->id = array_values(array_filter($value['entry']));
                 } else {
                     $entryCriteria->id = false;
                 }
             } else {
                 $entryCriteria->id = false;
             }
             $entryCriteria->locale = $this->getTargetLocale('Entry');
             $value['entryCriteria'] = $entryCriteria;
             // Process Asset Field - Criteria
             $assetCriteria = craft()->elements->getCriteria(ElementType::Asset);
             if ($value['asset'] && $value['type'] == 'asset') {
                 if (is_array($value['asset'])) {
                     $assetCriteria->id = array_values(array_filter($value['asset']));
                 } else {
                     $assetCriteria->id = false;
                 }
             } else {
                 $assetCriteria->id = false;
             }
             $assetCriteria->locale = $this->getTargetLocale('Asset');
             $value['assetCriteria'] = $assetCriteria;
             // Process Category Field - Criteria
             $categoryCriteria = craft()->elements->getCriteria(ElementType::Category);
             if ($value['category'] && $value['type'] == 'category') {
                 if (is_array($value['category'])) {
                     $categoryCriteria->id = array_values(array_filter($value['category']));
                 } else {
                     $categoryCriteria->id = false;
                 }
             } else {
                 $categoryCriteria->id = false;
             }
             $categoryCriteria->locale = $this->getTargetLocale('Category');
             $value['categoryCriteria'] = $categoryCriteria;
             /*
             Alternate Version Added from BaseElementFieldType - Do we need all this?
             
             $entryCriteria = craft()->elements->getCriteria(ElementType::Entry);
             $entryCriteria->locale = $this->getEntryTargetLocale();
             $entryCriteria->limit = null;
             
             if($value['entry'])
             {
             	// $value will be an array of element IDs if there was a validation error
             	// or we're loading a draft/version.
             	if (is_array($value['entry']))
             	{
             		$entryCriteria->id = array_values(array_filter($value['entry']));
             		$entryCriteria->fixedOrder = true;
             	}
             	else if ($value['entry'] === '')
             	{
             		$entryCriteria->id = false;
             	}
             	else if (isset($this->element) && $this->element->id)
             	{
             		$entryCriteria->relatedTo = array(
             			'sourceElement' => $this->element->id,
             			'sourceLocale'  => $this->element->locale,
             			'field'         => $this->model->id
             		);
             
             		if ($this->sortable)
             		{
             			$entryCriteria->order = 'sortOrder';
             		}
             	}
             	else
             	{
             		$entryCriteria->id = false;
             	}
             }
             else
             {
             	$entryCriteria->id = false;
             }
             $value['criteria'] = $entryCriteria;			
             */
             // Set default link text?
             $linkText = $settings['defaultText'] != '' && $value['text'] == '' ? $settings['defaultText'] : $value['text'];
             // Define Links, URL & Link Text Per Type
             switch ($value['type']) {
                 case 'email':
                     $value['url'] = $value['email'] ? 'mailto:' . $value['email'] : false;
                     $value['linkText'] = $linkText ? $linkText : $value['email'];
                     break;
                 case 'tel':
                     $value['url'] = $value['tel'] ? 'tel:' . $value['tel'] : false;
                     $value['linkText'] = $linkText ? $linkText : $value['tel'];
                     break;
                 case 'custom':
                     $value['url'] = $value['custom'] ? $value['custom'] : false;
                     $value['linkText'] = $linkText ? $linkText : $value['custom'];
                     break;
                 case 'entry':
                     if ($entryCriteria->first()) {
                         $value['entry'] = $entryCriteria->first();
                         $value['url'] = $entryCriteria->first()->getUrl();
                         $value['linkText'] = $linkText ? $linkText : $entryCriteria->first()->title;
                     } else {
                         $value['entry'] = false;
                         $value['url'] = false;
                         $value['linkText'] = $linkText ? $linkText : '';
                     }
                     break;
                 case 'asset':
                     if ($assetCriteria->first()) {
                         $value['asset'] = $assetCriteria->first();
                         $value['url'] = $assetCriteria->first()->getUrl();
                         $value['linkText'] = $linkText ? $linkText : $assetCriteria->first()->title;
                     } else {
                         $value['asset'] = false;
                         $value['url'] = false;
                         $value['linkText'] = $linkText ? $linkText : '';
                     }
                     break;
                 case 'category':
                     if ($categoryCriteria->first()) {
                         $value['category'] = $categoryCriteria->first();
                         $value['url'] = $categoryCriteria->first()->getUrl();
                         $value['linkText'] = $linkText ? $linkText : $categoryCriteria->first()->title;
                     } else {
                         $value['category'] = false;
                         $value['url'] = false;
                         $value['linkText'] = $linkText ? $linkText : '';
                     }
                     break;
             }
             // Set Unused Link Types To false
             $value['email'] = $value['type'] == 'email' ? $value['email'] : false;
             $value['custom'] = $value['type'] == 'custom' ? $value['custom'] : false;
             $value['tel'] = $value['type'] == 'tel' ? $value['tel'] : false;
             $value['entry'] = $value['type'] == 'entry' ? $value['entry'] : false;
             $value['asset'] = $value['type'] == 'asset' ? $value['asset'] : false;
             $value['category'] = $value['type'] == 'category' ? $value['category'] : false;
             // Set Target
             $value['target'] = $value['target'] == '1' ? '_blank' : false;
             // Build The Link
             $value['link'] = $value['url'] ? TemplateHelper::getRaw('<a href="' . $value['url'] . '"' . ($value['target'] ? ' target="' . $value['target'] . '"' : '') . ' title="' . $value['linkText'] . '">' . $value['linkText'] . '</a>') : false;
         }
     }
     return $value;
 }
    /**
     * @inheritDoc IFieldType::prepValue()
     *
     * @param mixed $value
     *
     * @return mixed
     */
    public function prepValue($value)
    {
        // make an html table
        $html = '
			<table>

				<thead>
					<tr>
		';
        if (!empty($value['columns'])) {
            foreach ($value['columns'] as $col) {
                $html .= '<th align="' . $col['align'] . '" width="' . $col['width'] . '">' . $col['heading'] . '</th>';
            }
        }
        $html .= '
					</tr>
				</thead>

				<tbody>

		';
        if (!empty($value['rows'])) {
            foreach ($value['rows'] as $row) {
                $html .= '<tr>';
                $i = 0;
                foreach ($row as $cell) {
                    $html .= '<td align="' . $value['columns'][$i]['align'] . '">' . $cell . '</td>';
                    $i++;
                }
                $html .= '</tr>';
            }
        }
        $html .= '

				</tbody>

			</table>
		';
        $value['table'] = TemplateHelper::getRaw($html);
        return $value;
    }