示例#1
0
 /**
  * Set a runtime action/error message.
  * This is a deprecated helper function left in place until all instances of it are removed from the code base.
  *
  * @access public
  * @since unknown
  * @deprecated 0.7.5
  *
  * @param $type    string
  * @param $message string
  *
  * @return void
  */
 public function setRuntimeMessage($type, $message)
 {
     cnMessage::runtime($type, $message);
 }
 /**
  * Process a logo upload, creating its size variation and caching it for later use.
  *
  * NOTE: The entry slug should be run thru rawurldecode() before being passed to this method.
  *
  * @access private
  * @since  8.1
  * @static
  * @uses   Connections_Directory()
  * @uses   is_wp_error()
  * @uses   cnMessage::set()
  * @uses   cnImage::get()
  * @uses   is_admin()
  * @param  string $entrySlug The entry slug.
  *
  * @return array             An associative array containing the the details about the uploaded logo.
  */
 private static function processLogo($entrySlug)
 {
     if (!isset($_FILES['original_logo'])) {
         return FALSE;
     }
     // Grab an instance of the Connections object.
     $instance = Connections_Directory();
     if (is_wp_error($img = cnImage::upload($_FILES['original_logo'], $entrySlug))) {
         cnMessage::set('error', implode('<br />', $img->get_error_messages()));
         return FALSE;
     }
     $cropMode = array(0 => 'none', 1 => 'crop', 2 => 'fill', 3 => 'fit');
     $logo = cnImage::get($img['url'], array('crop_mode' => ($key = array_search(cnSettingsAPI::get('connections', 'image_logo', 'ratio'), $cropMode)) || $key === 0 ? $key : 2, 'width' => cnSettingsAPI::get('connections', 'image_logo', 'width'), 'height' => cnSettingsAPI::get('connections', 'image_logo', 'height'), 'quality' => cnSettingsAPI::get('connections', 'image_logo', 'quality'), 'sub_dir' => $entrySlug), 'data');
     if (is_wp_error($logo)) {
         cnMessage::set('error', implode('<br />', $logo->get_error_messages()));
     }
     // Output the debug log.
     if ($instance->options->getDebug() && is_admin()) {
         if (isset($logo['log'])) {
             cnMessage::runtime('notice', 'Logo Image Process Log<br/> <pre>' . $logo['log'] . '</pre>');
         }
     }
     return $img;
 }