* @copyright Lance Cleveland * @package wpCSL * @subpackage Notifications * */ class wpCSL_notifications__adpress { /** * Build a new notification object. * * @param type $params */ function __construct($params) { foreach ($params as $name => $value) { $this->$name = $value; } } /** * Add a notification to the notice stack * * @param type $level * @param type $content * @param type $link */ function add_notice($level = 1, $content, $link = null) { $this->notices[] = new wpCSL_notifications_notice__adpress( array( 'level' => $level, 'content' => $content, 'link' => $link ) ); } /** * Render the notices to the browser page. */ function display() { echo $this->get(); } /** * Return a formatted HTML string representing the notification. * * @param boolean $simple - set to true to see simplified unformatted notices. * @return string - the HTML or simple string output */ function get($simple=false) { // No need to do anything if there aren't any notices if (!isset($this->notices)) return; foreach ($this->notices as $notice) { $levels[$notice->level][] = $notice; } ksort($levels, SORT_NUMERIC); $difference = max(array_keys($levels)); $notice_output = ''; $actionMessage = __('needs attention',WPCSL__slplus__VERSION); foreach ($levels as $key => $value) { if (!$simple) { $color = round($difference); switch ($difference) { case 1: $notice_output .= "
\n"; break; case 1: $notice_output .= "
\n"; break; case 4: $notice_output .= "
\n"; break; case 3: $notice_output .= "
\n"; break; case 2: $notice_output .= "
\n"; break; case 5: $notice_output .= "
\n"; break; case 6: $notice_output .= "
\n"; break; case 7: $notice_output .= "
\n"; break; case 9: $notice_output .= "
\n"; $actionMessage = __('wants you to know',WPCSL__slplus__VERSION); break; case 8: $notice_output .= "
\n"; break; default: $notice_output .= "
\n"; break; } $notice_output .= sprintf( __('

%s %s: ',WPCSL__slplus__VERSION), $this->url, $this->name, $actionMessage ); $notice_output .= "

    \n"; } foreach ($value as $notice) { if (!$simple) { $notice_output .= '
  • '; } $notice_output .= $notice->display(); if (!$simple) { $notice_output .= '
  • '; } $notice_output .= "\n"; } if (!$simple) { $notice_output .= "
\n"; $notice_output .= "

\n"; } } return $notice_output; } } /** * This class represents each individual notice. * */ class wpCSL_notifications_notice__adpress { function __construct($params) { foreach($params as $name => $value) { $this->$name = $value; } } function display() { $retval = $this->content; if ( isset($this->link) && !is_null($this->link) && ($this->link != '') ) { $retval .= " (link}\">Details)"; } return $retval; } } ?>