/**
  * Echo or return the entry's links in a HTML hCard compliant string.
  *
  * Accepted options for the $atts property are:
  *  preferred (bool) Retrieve the preferred entry link.
  *  type (array) || (string) Retrieve specific link types.
  *   Permitted Types:
  *    website
  *    blog
  *  format (string) The tokens to use to display the phone number block parts.
  *   Permitted Tokens:
  *    %label%
  *    %title%
  *    %url%
  *    %image%
  *    %separator%
  *  label (string) The label to be displayed for the links.
  *  size (string) The valid image sizes. Valid values are: mcr || tny || vsm || sm || lg || xlg
  *  separator (string) The separator to use.
  *  before (string) HTML to output before the social media networks.
  *  after (string) HTML to after before the social media networks.
  *  return (bool) Return string if set to TRUE instead of echo string.
  *
  * Filters:
  *  cn_output_default_atts_link => (array) Register the methods default attributes.
  *
  * @link  http://microformats.org/wiki/hcard-examples#Site_profiles
  *
  * @access public
  * @since  unknown
  *
  * @param  array $atts   Accepted values as noted above.
  * @param  bool  $cached Returns the cached data rather than querying the db.
  *
  * @return string
  */
 public function getLinkBlock($atts = array(), $cached = TRUE)
 {
     /*
      * // START -- Set the default attributes array. \\
      */
     $defaults = array('preferred' => NULL, 'type' => NULL, 'format' => '', 'label' => NULL, 'size' => 'lg', 'icon_size' => 32, 'separator' => ':', 'before' => '', 'after' => '', 'return' => FALSE);
     $defaults = apply_filters('cn_output_default_atts_link', $defaults);
     $atts = cnSanitize::args($atts, $defaults);
     $atts['id'] = $this->getId();
     /*
      * // END -- Set the default attributes array if not supplied. \\
      */
     $rows = array();
     $links = $this->getLinks($atts, $cached);
     $search = array('%label%', '%title%', '%url%', '%image%', '%icon%', '%separator%');
     $iconSizes = array(16, 24, 32, 48, 64);
     $targetOptions = array('new' => '_blank', 'same' => '_self');
     if (empty($links)) {
         return '';
     }
     /*
      * Ensure the supplied size is valid, if not reset to the default value.
      */
     $icon = array();
     $icon['width'] = in_array($atts['icon_size'], $iconSizes) ? $atts['icon_size'] : 32;
     $icon['height'] = $icon['width'];
     $icon['src'] = CN_URL . 'assets/images/icons/link/link_' . $icon['width'] . '.png';
     foreach ($links as $link) {
         $icon = apply_filters('cn_output_link_icon', $icon, $link->type);
         $replace = array();
         if (empty($atts['label'])) {
             $name = empty($link->name) ? '' : $link->name;
         } else {
             $name = $atts['label'];
         }
         $url = cnSanitize::field('url', $link->url);
         $target = array_key_exists($link->target, $targetOptions) ? $targetOptions[$link->target] : '_self';
         $follow = $link->follow ? '' : 'rel="nofollow"';
         $replace[] = '<span class="link-name">' . $name . '</span>';
         // The `notranslate` class is added to prevent Google Translate from translating the text.
         $replace[] = empty($link->title) ? '' : '<a class="url" href="' . $url . '"' . ' target="' . $target . '" ' . $follow . '>' . $link->title . '</a>';
         $replace[] = '<a class="url notranslate" href="' . $url . '"' . ' target="' . $target . '" ' . $follow . '>' . $url . '</a>';
         if (FALSE !== filter_var($link->url, FILTER_VALIDATE_URL) && FALSE !== strpos($atts['format'], '%image%')) {
             $screenshot = new cnSiteShot(array('url' => $link->url, 'alt' => $url, 'title' => $name, 'target' => $target, 'follow' => $link->follow, 'return' => TRUE));
             $size = $screenshot->setSize($atts['size']);
             /** @noinspection CssInvalidPropertyValue */
             $screenshot->setBefore('<span class="cn-image-style" style="display: inline-block;"><span style="display: block; max-width: 100%; width: ' . $size['width'] . 'px">');
             $screenshot->setAfter('</span></span>');
             $replace[] = $screenshot->render();
         } else {
             $replace[] = '';
         }
         $replace[] = '<span class="link-icon"><a class="url" title="' . $link->title . '" href="' . $url . '" target="' . $target . '" ' . $follow . '><img src="' . $icon['src'] . '" height="' . $icon['height'] . '" width="' . $icon['width'] . '"/></a></span>';
         $replace[] = '<span class="cn-separator">' . $atts['separator'] . '</span>';
         $row = "\t" . '<span class="link ' . $link->type . '">';
         $row .= str_ireplace($search, $replace, empty($atts['format']) ? empty($defaults['format']) ? '%label%%separator% %title%' : $defaults['format'] : $atts['format']);
         $row .= '</span>';
         $rows[] = apply_filters('cn_output_link', cnString::replaceWhatWith($row, ' '), $link, $this, $atts);
     }
     $block = '<span class="link-block">' . PHP_EOL . implode(PHP_EOL, $rows) . PHP_EOL . '</span>';
     $block = apply_filters('cn_output_links', $block, $links, $this, $atts);
     $html = $atts['before'] . $block . $atts['after'] . PHP_EOL;
     return $this->echoOrReturn($atts['return'], $html);
 }
 /**
  * The string to set the <a> or <img> alt attribute.
  *
  * @access public
  * @since  8.2.5
  *
  * @param string $alt
  */
 public function setAlt($alt)
 {
     $this->alt = is_string($alt) && 0 < strlen($alt) ? cnSanitize::field('attribute', $alt) : '';
 }
 /**
  * Set the entry notes.
  *
  * @access public
  * @since  unknown
  *
  * @param string $notes
  * @param string $context
  */
 public function setNotes($notes, $context = 'db')
 {
     $this->notes = cnSanitize::field('notes', $notes, $context);
 }