* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio * @copyright Copyright (c) 2012, Ernest Marcinko */ class wpdreamsBlogselect extends wpdreamsType { private $useall = ""; private $blogs, $selected; function getType() { parent::getType(); $this->processData(); if ( function_exists( 'get_sites' ) ) { $this->blogs = get_sites(array('number' => 1000)); } else { $this->blogs = array(); } echo "
" . $this->label . ""; echo "
"; echo "
"; if ($this->useall != "") echo "
"; else echo "
"; echo '

' . __('Available blogs', 'ajax-search-pro') . '

    '; if ( !is_wp_error($this->blogs) ) { foreach ($this->blogs as $k => $blog) { if ( $this->selected == null || !in_array($blog->id, $this->selected) ) { echo '
  • ' . $blog->blogname . '
  • '; } } } echo "
"; echo '

' . __('Drag here the blogs you want to use!', 'ajax-search-pro') . '

    '; if ( $this->selected != null && count($this->selected)>0 && function_exists('get_blog_details') ) { foreach ($this->selected as $k => $v) { $blog = get_blog_details($v); if ( !is_wp_error($blog) && isset($blog->blogname) ) { echo '
  • ' . $blog->blogname . '
  • '; } } } echo "
"; echo "
"; echo " "; echo " "; ?>
"; } function processData() { $this->data = str_replace("\n", "", $this->data); $this->selected = null; if (!empty($this->data)) { // Check for the use-all checkbox $tmp = explode( "xxx", $this->data ); if (isset($tmp[1])) $this->useall = "checked='checked'"; // Get the selected IDs if ($tmp[0] != "") $this->selected = explode( "|", $tmp[0] ); } else { $this->useall = ""; } } final function getData() { return $this->data; } final function getSelected() { if ($this->useall != '') return "all"; return $this->selected; } } }