__construct();} /** * PHP 5 Constructor */ function __construct(){ #add_action("admin_menu", array(&$this,"add_admin_pages")); add_action('plugins_loaded', array(&$this,"register_widgets" ) ); add_action("init", array(&$this,"add_scripts")); add_action("wp_head", array(&$this,"add_css")); add_filter('media_buttons_context', array(&$this, 'media_buttons_context')); add_action('media_upload_qype-search', array(&$this, 'media_upload_content')); add_action('media_upload_qype-favorites', array(&$this, 'media_upload_content_favorites')); # $this->adminOptions = $this->getAdminOptions(); add_shortcode('qype', array( &$this , 'qype_shortcode_handler' ) ); $qypeStyleFile = WP_PLUGIN_URL.'/all-in-one-qype-suite/css/style.css'; wp_register_style('qypeStyle', $qypeStyleFile); //***************************************************************************************** // These lines allow the plugin to be translated into different languages // You will need to create the appropriate language files // this assumes your language files will be in the format: all-in-one-qype-suite-locationcode.mo // This also assumes your text domain will be: all-in-one-qype-suite // For more info: http://codex.wordpress.org/Translating_WordPress //***************************************************************************************** $locale = get_locale(); $mofile = dirname(__FILE__)."/languages/".$locale.".mo"; load_textdomain("qype-suite", $mofile); } function register_widgets() { require_once( dirname(__FILE__)."/php/widgets/user-widget/widget.php"); $GLOBALS['QypeUserWidget'] = & new QypeUserWidget(); require_once( dirname(__FILE__)."/php/widgets/city-widget/widget.php"); $GLOBALS['QypeCityWidget'] = & new QypeCityWidget(); require_once( dirname(__FILE__)."/php/widgets/button-widget/widget.php"); $GLOBALS['QypeButtonWidget'] = & new QypeButtonWidget(); } # /** # * Retrieves the options from the database. # * @return array # */ # function getAdminOptions() { # $adminOptions = array("optionName" => "Value"); # $savedOptions = get_option($this->adminOptionsName); # if (!empty($savedOptions)) { # foreach ($savedOptions as $key => $option) { # $adminOptions[$key] = $option; # } # } # update_option($this->adminOptionsName, $adminOptions); # return $adminOptions; # } # # /** # * Saves the admin options to the database. # */ # function saveAdminOptions(){ # update_option($this->adminOptionsName, $this->adminOptions); # } # # function add_admin_pages(){ # add_submenu_page('options-general.php', "Qype", "Qype", 10, "Qype", array(&$this,"output_sub_admin_page_0")); # } # # /** # * Outputs the HTML for the admin sub page. # */ # function output_sub_admin_page_0(){ # ? > #
#

Admin Menu Placeholder for Qype a subpage of 'options-general.php'

#

You can modify the content that is output to this page by modifying the method output_sub_admin_page_0

#
# < ?php # } /** * qype_shortcode_handler - produces and returns the content to replace the shortcode tag * * @param array $atts An array of attributes passed from the shortcode * @param string $content If the shortcode wraps round some html, this will be passed. */ function qype_shortcode_handler( $atts , $content = null) { $attributes = shortcode_atts(array( 'id' => 1, 'language' => 'de' ), $atts); //get place data $place = QypePlace::find_by_id( $attributes['id']); if( !$place->valid() ) return 'place not found'; // render baloon with image, link, raiting address, map?? return WpQypeSuite::tooltip($place, $content); } /** * Tells WordPress to load the scripts */ function add_scripts(){ wp_enqueue_script('jquery'); wp_enqueue_script('dimensions', WP_PLUGIN_URL.'/all-in-one-qype-suite/js/jquery.dimensions.js', array("jquery")); wp_enqueue_script('cluetip', WP_PLUGIN_URL.'/all-in-one-qype-suite/js/jquery.cluetip.js', array('dimensions')); wp_enqueue_script('qtip', WP_PLUGIN_URL.'/all-in-one-qype-suite/js/qtip.js', array('cluetip')); } /** * Adds a link to the stylesheet to the header */ function add_css(){ wp_enqueue_style( 'qypeStyle'); echo ''; } //***************************************************************************************** function media_buttons_context($context) { global $post_ID, $temp_ID; $dir = dirname(__FILE__); $image_btn = WP_PLUGIN_URL.'/all-in-one-qype-suite/imgs/icon.gif'; $image_title = __('All in one Qype Suite - Place Chooser', 'qype-suite'); $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID"; $out = ' '.$image_title.''; return $context.$out; } function media_upload_content_favorites () { $this->media_upload_content('qype-favorites'); } function media_upload_content($tab = 'qype-search') { add_filter('media_upload_tabs', array(&$this, 'media_upload_tabs')); wp_enqueue_style( 'media'); wp_enqueue_style( 'qypeStyle'); add_action('qype_media_upload_header', 'media_upload_header'); if( $tab == 'qype-favorites' ) { wp_iframe(array(&$this, 'media_favorites_tab')); } else { wp_iframe(array(&$this, 'media_search_tab')); } } function media_upload_tabs($tabs) { return array( 'qype-search' => 'Search', 'qype-favorites' => 'Favorites' ); } function media_search_tab() { #do_action('qype_media_upload_header'); if( !empty($_GET['search_qype_query']) || !empty($_GET['search_qype_locator']) ) { $term = $_GET['search_qype_query']; $city = $_GET['search_qype_locator']; $places = QypePlace::find_all_by_term_and_city( $term, $city, 20 ); } include(dirname(__FILE__).'/php/tabs/search-tab.php'); } function media_favorites_tab() { #do_action('qype_media_upload_header'); include(dirname(__FILE__).'/php/tabs/favorites-tab.php'); } static function tooltip( $place, $title = '', $link = '' ) { $qypelogo = WP_PLUGIN_URL.'/all-in-one-qype-suite/imgs/'. __('qype_widget_logo.en.gif', 'qype-suite'); $starsource = WP_PLUGIN_URL.'/all-in-one-qype-suite/imgs/rating_small_'; $startype = '.png'; // set content to place title if content empty if( empty( $title ) ) $title = $place->title; if( empty( $link ) ) $link = $place->link; $content = ''.$title.' '; return $content; } } class QypeWidget { function getDisplayTemplate($file) { $path = file_exists(TEMPLATEPATH . '/'.$file) ? TEMPLATEPATH : dirname(__FILE__); return $path.'/php/widgets/'.$file; } function get_language() { list( $language, $country ) = explode( '_', get_locale() ); return $language; } function get_tld() { $lng = $this->get_language(); switch( $lng ) { case 'en': return 'co.uk'; default: return $lng; } } } } //instantiate the class if (class_exists('WpQypeSuite')) { $WpQypeSuite = new WpQypeSuite(); } ?>