コード例 #1
0
ファイル: api-v1.php プロジェクト: lordgabber/rartracker
 case validateRoute('GET', 'subtitles'):
     $subtitles = new Subtitles($db, $user);
     httpResponse($subtitles->fetch($_GET["torrentid"]));
     break;
 case validateRoute('POST', 'subtitles'):
     $torrent = new Torrent($db, $user);
     $log = new Logs($db);
     $mailbox = new Mailbox($db, $user);
     $subtitles = new Subtitles($db, $user, $log, $torrent, $mailbox);
     httpResponse($subtitles->upload($_FILES["file"], $_POST));
     break;
 case validateRoute('DELETE', 'subtitles/\\d+'):
     $log = new Logs($db);
     $torrent = new Torrent($db, $user);
     $mailbox = new Mailbox($db, $user);
     $subtitles = new Subtitles($db, $user, $log, $torrent, $mailbox);
     httpResponse($subtitles->delete((int) $params[1], $_GET["reason"]));
     break;
 case validateRoute('GET', 'donations'):
     $donations = new Donations($db, $user);
     list($result, $totalCount) = $donations->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('POST', 'donations'):
     $donate = new Donations($db, $user);
     httpResponse($donate->create($postdata));
     break;
 case validateRoute('PATCH', 'donations/\\d+'):
     $donate = new Donations($db, $user);
     httpResponse($donate->update((int) $params[1], $postdata));
     break;
コード例 #2
0
ファイル: template-tags.php プロジェクト: zenny/Subtitles
 /**
  * Retrieve post subtitle.
  *
  * @since 1.0.0
  */
 function get_the_subtitle($post = 0)
 {
     $subtitle = Subtitles::get_the_subtitle($post);
     return $subtitle;
 }
コード例 #3
0
ファイル: api-v1.php プロジェクト: swetorrentking/rartracker
     httpResponse($subtitles->upload($_FILES["file"], $_POST));
     break;
 case validateRoute('DELETE', 'subtitles/\\d+'):
     $log = new Logs($db);
     $torrent = new Torrent($db, $user);
     $mailbox = new Mailbox($db, $user);
     $subtitles = new Subtitles($db, $user, $log, $torrent, $mailbox);
     httpResponse($subtitles->delete((int) $params[1], $_GET["reason"]));
     break;
 case validateRoute('GET', 'subtitles/\\d+/download'):
     $subtitles = new Subtitles($db, $user);
     $subtitles->download((int) $params[1]);
     die;
     break;
 case validateRoute('GET', 'torrents/\\d+/subtitle'):
     $subtitles = new Subtitles($db, $user);
     $subtitles->downloadByTorrentId((int) $params[1]);
     die;
     break;
 case validateRoute('GET', 'donations'):
     $donations = new Donations($db, $user);
     list($result, $totalCount) = $donations->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('POST', 'donations'):
     $donate = new Donations($db, $user);
     httpResponse($donate->create($postdata));
     break;
 case validateRoute('PATCH', 'donations/\\d+'):
     $donate = new Donations($db, $user);
     httpResponse($donate->update((int) $params[1], $postdata));
コード例 #4
0
function social_warfare_buttons($array = array())
{
    // Setup the default Array parameters
    if (!isset($array['where'])) {
        $array['where'] = 'default';
    }
    if (!isset($array['echo'])) {
        $array['echo'] = true;
    }
    if (!isset($array['content'])) {
        $array['content'] = false;
    }
    // Get the options...or create them if they don't exist
    if (isset($array['post_id'])) {
        $postID = $array['post_id'];
    } else {
        $postID = get_the_ID();
    }
    $options = sw_get_user_options();
    // Check to see if display location was specifically defined for this post
    $specWhere = get_post_meta($postID, 'nc_postLocation', true);
    if ($array['where'] == 'default') {
        if ($specWhere == 'default' || $specWhere == '') {
            if (is_singular('post')) {
                $array['where'] = $options['locationPost'];
            } elseif (is_singular('page')) {
                $array['where'] = $options['locationPage'];
            } elseif (is_singular()) {
                $postType = get_post_type($postID);
                if (isset($options['location' . $postType])) {
                    $array['where'] = $options['location' . $postType];
                } else {
                    $array['where'] = 'none';
                }
            } else {
                $postType = get_post_type($postID);
                if (isset($options['location' . $postType])) {
                    $array['where'] = $options['location' . $postType];
                } elseif ($postType == 'post' || $postType == 'page') {
                    $array['where'] = $options['locationSite'];
                } else {
                    $array['where'] = 'none';
                }
            }
        } else {
            $array['where'] = $specWhere;
        }
    }
    // Disable the buttons on Buddy Press pages
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $array['content'];
        // Disable the buttons if the location is set to "None / Manual"
    } elseif ($array['where'] == 'none' && !isset($array['devs'])) {
        return $array['content'];
        // Disable the button if we're not in the loop, unless there is no content which means the function was called by a developer.
    } elseif ((!is_main_query() || !in_the_loop()) && !isset($array['devs'])) {
        return $array['content'];
        // Don't do anything if we're in the admin section
    } elseif (is_admin()) {
        return $array['content'];
        // If all the checks pass, let's make us some buttons!
    } else {
        // Set the options for the horizontal floating bar
        if ($options['float'] && is_singular()) {
            $floatOption = 'float' . ucfirst($options['floatOption']);
        } else {
            $floatOption = 'floatNone';
        }
        // Disable the plugin on feeds, search results, and non-published content
        if (!is_feed() && !is_search() && get_post_status($postID) == 'publish') {
            // Acquire the social stats from the networks
            if (isset($array['url'])) {
                $buttonsArray['url'] = $array['url'];
            } else {
                $buttonsArray['url'] = get_permalink($postID);
            }
            $language = array();
            $language = apply_filters('sw_languages', $language);
            // Setup the buttons array to pass into the 'sw_network_buttons' hook
            $buttonsArray['shares'] = get_social_warfare_shares($postID);
            $buttonsArray['language'] = apply_filters('sw_languages', $language);
            $buttonsArray['count'] = 0;
            $buttonsArray['totes'] = 0;
            $buttonsArray['options'] = $options;
            if ($buttonsArray['options']['totes'] && $buttonsArray['shares']['totes'] >= $buttonsArray['options']['minTotes']) {
                ++$buttonsArray['count'];
            }
            $buttonsArray['resource'] = array();
            $buttonsArray['postID'] = $postID;
            // Disable the subtitles plugin to avoid letting them inject their subtitle into our share titles
            if (is_plugin_active('subtitles/subtitles.php') && class_exists('Subtitles')) {
                remove_filter('the_title', array(Subtitles::getinstance(), 'the_subtitle'), 10, 2);
            }
            // This array will contain the HTML for all of the individual buttons
            $buttonsArray = apply_filters('sw_network_buttons', $buttonsArray);
            // Create the social panel
            $assets = '<div class="nc_socialPanel sw_' . $options['visualTheme'] . ' sw_d_' . $options['dColorSet'] . ' sw_i_' . $options['iColorSet'] . ' sw_o_' . $options['oColorSet'] . '" data-position="' . $options['locationPost'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-scale="' . $options['buttonSize'] . '" data-align="' . $options['buttonFloat'] . '">';
            // Setup the total shares count if it's on the left
            if ($options['totes'] && $options['swTotesFormat'] == 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes']) {
                $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="6" >';
                $assets .= '<span class="sw_count">' . kilomega($buttonsArray['totes']) . ' <span class="sw_label">' . $language['total'] . '</span></span>';
                $assets .= '</div>';
            }
            // Sort the buttons according to the user's preferences
            if ($options['orderOfIconsSelect'] == 'manual') {
                foreach ($options['newOrderOfIcons'] as $thisIcon => $status) {
                    if (isset($buttonsArray['resource'][$thisIcon])) {
                        $assets .= $buttonsArray['resource'][$thisIcon];
                    }
                }
            } elseif ($options['orderOfIconsSelect'] == 'dynamicCount') {
                arsort($buttonsArray['shares']);
                foreach ($buttonsArray['shares'] as $thisIcon => $status) {
                    if (isset($buttonsArray['resource'][$thisIcon])) {
                        $assets .= $buttonsArray['resource'][$thisIcon];
                    }
                }
            }
            // Create the Total Shares Box if it's on the right
            if ($options['totes'] && $options['swTotesFormat'] != 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes']) {
                if ($options['swTotesFormat'] == 'totes') {
                    $assets .= '<div class="nc_tweetContainer totes" data-id="6" >';
                    $assets .= '<span class="sw_count">' . kilomega($buttonsArray['totes']) . ' <span class="sw_label">' . $language['total'] . '</span></span>';
                    $assets .= '</div>';
                } else {
                    $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="6" >';
                    $assets .= '<span class="sw_count"><span class="sw_label">' . $language['total'] . '</span> ' . kilomega($buttonsArray['totes']) . '</span>';
                    $assets .= '</div>';
                }
            }
            // Close the Social Panel
            $assets .= '</div>';
            // Reset the cache timestamp if needed
            if (sw_is_cache_fresh($postID) == false) {
                delete_post_meta($postID, 'sw_cache_timestamp');
                update_post_meta($postID, 'sw_cache_timestamp', floor(date('U') / 60 / 60));
            }
            if ($array['echo'] == false && $array['where'] != 'none') {
                return $assets;
            } elseif ($array['content'] === false) {
                echo $assets;
            } elseif ($array['where'] == 'below') {
                $content = $array['content'] . '' . $assets;
                return $content;
            } elseif ($array['where'] == 'above') {
                $content = $assets . '' . $array['content'];
                return $content;
            } elseif ($array['where'] == 'both') {
                $content = $assets . '' . $array['content'] . '' . $assets;
                return $content;
            } elseif ($array['where'] == 'none') {
                return $array['content'];
            }
        } else {
            return $array['content'];
        }
    }
}
コード例 #5
0
function social_warfare_buttons($array = array())
{
    // Setup the default Array parameters
    if (!isset($array['where'])) {
        $array['where'] = 'default';
    }
    if (!isset($array['echo'])) {
        $array['echo'] = true;
    }
    if (!isset($array['content'])) {
        $array['content'] = false;
    }
    // Get the options...or create them if they don't exist
    if (isset($array['post_id'])) {
        $postID = $array['post_id'];
    } else {
        $postID = get_the_ID();
    }
    $options = swp_get_user_options();
    // Check to see if display location was specifically defined for this post
    $specWhere = get_post_meta($postID, 'nc_postLocation', true);
    if (!$specWhere) {
        $specWhere = 'default';
    }
    if ($array['where'] == 'default') {
        // If we are on a single page or post
        if (is_singular() && !is_home() && !is_archive()) {
            // Make sure this is the main loop
            //if( get_permalink( $postID ) == swp_get_current_url() ) :
            // Check if a specific display value has not been set for this specific post
            if ($specWhere == 'default' || $specWhere == '') {
                $postType = get_post_type($postID);
                if (isset($options['location_' . $postType])) {
                    $array['where'] = $options['location_' . $postType];
                } else {
                    $array['where'] = 'none';
                }
            } else {
                $array['where'] = $specWhere;
            }
            // If it's not the main loop
            //else:
            //	$array['where'] = 'none';
            //endif;
            // If we are on an archive or home page
        } else {
            $array['where'] = $options['locationSite'];
        }
    }
    // Disable the buttons on Buddy Press pages
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $array['content'];
        // Disable the buttons if the location is set to "None / Manual"
    } elseif ($array['where'] == 'none' && !isset($array['devs'])) {
        return $array['content'];
        // Disable the button if we're not in the loop, unless there is no content which means the function was called by a developer.
    } elseif ((!is_main_query() || !in_the_loop()) && !isset($array['devs'])) {
        return $array['content'];
        // Don't do anything if we're in the admin section
    } elseif (is_admin()) {
        return $array['content'];
        // If all the checks pass, let's make us some buttons!
    } else {
        // Set the options for the horizontal floating bar
        $postType = get_post_type($postID);
        $spec_float_where = get_post_meta($postID, 'nc_floatLocation', true);
        if (isset($array['float']) && $array['float'] == 'ignore') {
            $floatOption = 'float_ignore';
        } elseif ($spec_float_where == 'off' && $options['buttonFloat'] != 'float_ignore') {
            $floatOption = 'floatNone';
        } elseif ($options['float'] && is_singular() && $options['float_location_' . $postType] == 'on') {
            $floatOption = 'float' . ucfirst($options['floatOption']);
        } else {
            $floatOption = 'floatNone';
        }
        // Disable the plugin on feeds, search results, and non-published content
        if (!is_feed() && !is_search() && get_post_status($postID) == 'publish') {
            // Acquire the social stats from the networks
            if (isset($array['url'])) {
                $buttonsArray['url'] = $array['url'];
            } else {
                $buttonsArray['url'] = get_permalink($postID);
            }
            // Fetch the share counts
            $buttonsArray['shares'] = get_social_warfare_shares($postID);
            // Pass the swp_options into the array so we can pass it into the filter
            $buttonsArray['options'] = $options;
            // Customize which buttosn we're going to display
            if (isset($array['buttons'])) {
                // Fetch the global names and keys
                $swp_options = array();
                $swp_available_options = apply_filters('swp_options', $swp_options);
                $available_buttons = $swp_available_options['options']['swp_display']['buttons']['content'];
                // Split the comma separated list into an array
                $button_set_array = explode(',', $array['buttons']);
                // Match the names in the list to their appropriate system-wide keys
                foreach ($button_set_array as $button) {
                    // Trim the network name in case of white space
                    $button = trim($button);
                    // Convert the names to their systme-wide keys
                    if (recursive_array_search($button, $available_buttons)) {
                        $key = recursive_array_search($button, $available_buttons);
                        // Store the result in the array that gets passed to the HTML generator
                        $buttonsArray['buttons'][$key] = $button;
                        // Declare a default share count of zero. This will be overriden later
                        if (!isset($buttonsArray['shares'][$key])) {
                            $buttonsArray['shares'][$key] = 0;
                        }
                    }
                }
                // Manually turn the total shares on or off
                if (array_search('Total', $button_set_array)) {
                    $buttonsArray['buttons']['totes'] = 'Total';
                }
            }
            // Setup the buttons array to pass into the 'swp_network_buttons' hook
            $buttonsArray['count'] = 0;
            $buttonsArray['totes'] = 0;
            if ($buttonsArray['options']['totes'] && $buttonsArray['shares']['totes'] >= $buttonsArray['options']['minTotes'] && !isset($array['buttons']) || isset($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
            }
            $buttonsArray['resource'] = array();
            $buttonsArray['postID'] = $postID;
            // Disable the subtitles plugin to avoid letting them inject their subtitle into our share titles
            if (is_plugin_active('subtitles/subtitles.php') && class_exists('Subtitles')) {
                remove_filter('the_title', array(Subtitles::getinstance(), 'the_subtitle'), 10, 2);
            }
            // This array will contain the HTML for all of the individual buttons
            $buttonsArray = apply_filters('swp_network_buttons', $buttonsArray);
            // Create the social panel
            $assets = '<div class="nc_socialPanel swp_' . $options['visualTheme'] . ' swp_d_' . $options['dColorSet'] . ' swp_i_' . $options['iColorSet'] . ' swp_o_' . $options['oColorSet'] . '" data-position="' . $options['location_post'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-scale="' . $options['buttonSize'] . '" data-align="' . $options['buttonFloat'] . '">';
            // Setup the total shares count if it's on the left
            if ($options['totes'] && $options['swTotesFormat'] == 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes'] && !isset($array['buttons']) || $options['swTotesFormat'] == 'totesAltLeft' && isset($array['buttons']) && isset($array['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
                $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="' . $buttonsArray['count'] . '" >';
                $assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . ' <span class="swp_label">' . __('Shares', 'social-warfare') . '</span></span>';
                $assets .= '</div>';
            }
            // Sort the buttons according to the user's preferences
            if (isset($buttonsArray) && isset($buttonsArray['buttons'])) {
                foreach ($buttonsArray['buttons'] as $key => $value) {
                    if (isset($buttonsArray['resource'][$key])) {
                        $assets .= $buttonsArray['resource'][$key];
                    }
                }
            } elseif ($options['orderOfIconsSelect'] == 'manual') {
                foreach ($options['newOrderOfIcons'] as $key => $value) {
                    if (isset($buttonsArray['resource'][$key])) {
                        $assets .= $buttonsArray['resource'][$key];
                    }
                }
            } elseif ($options['orderOfIconsSelect'] == 'dynamic') {
                arsort($buttonsArray['shares']);
                foreach ($buttonsArray['shares'] as $thisIcon => $status) {
                    if (isset($buttonsArray['resource'][$thisIcon])) {
                        $assets .= $buttonsArray['resource'][$thisIcon];
                    }
                }
            }
            // Create the Total Shares Box if it's on the right
            if ($options['totes'] && $options['swTotesFormat'] != 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes'] && !isset($buttonsArray['buttons']) || $options['swTotesFormat'] != 'totesAltLeft' && isset($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
                if ($options['swTotesFormat'] == 'totes') {
                    $assets .= '<div class="nc_tweetContainer totes" data-id="' . $buttonsArray['count'] . '" >';
                    $assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . ' <span class="swp_label">' . __('Shares', 'social-warfare') . '</span></span>';
                    $assets .= '</div>';
                } else {
                    $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="' . $buttonsArray['count'] . '" >';
                    $assets .= '<span class="swp_count"><span class="swp_label">' . __('Shares', 'social-warfare') . '</span> ' . swp_kilomega($buttonsArray['totes']) . '</span>';
                    $assets .= '</div>';
                }
            }
            // Close the Social Panel
            $assets .= '</div>';
            // Reset the cache timestamp if needed
            if (swp_is_cache_fresh($postID) == false) {
                delete_post_meta($postID, 'swp_cache_timestamp');
                update_post_meta($postID, 'swp_cache_timestamp', floor(date('U') / 60 / 60));
            }
            if (isset($array['genesis'])) {
                if ($array['where'] == 'below' && $array['genesis'] == 'below') {
                    return $assets;
                } elseif ($array['where'] == 'above' && $array['genesis'] == 'above') {
                    return $assets;
                } elseif ($array['where'] == 'both') {
                    return $assets;
                } elseif ($array['where'] == 'none') {
                    return false;
                }
            } else {
                if ($array['echo'] == false && $array['where'] != 'none') {
                    return $assets;
                } elseif ($array['content'] === false) {
                    echo $assets;
                } elseif ($array['where'] == 'below') {
                    $content = $array['content'] . '' . $assets;
                    return $content;
                } elseif ($array['where'] == 'above') {
                    $content = $assets . '' . $array['content'];
                    return $content;
                } elseif ($array['where'] == 'both') {
                    $content = $assets . '' . $array['content'] . '' . $assets;
                    return $content;
                } elseif ($array['where'] == 'none') {
                    return $array['content'];
                }
            }
        } else {
            return $array['content'];
        }
    }
}
コード例 #6
0
 /**
  * Kick off the class if it hasn't been instantiated.
  *
  * There is a lot of information about the Singleton design pattern
  * and singleton implementations for WordPress and plugins. I am not (at all!)
  * an expert on this and may very well be instantiating Subtitles in the
  * wrong way. If there's a better way to do this, or if it's not necessary
  * to use this design pattern with the plugin, please let me know. The reason
  * I've done it this way is because plugins should never be instantiated twice
  * in WordPress. In general, I assume that this won't happen under normal circumstances,
  * but using this design pattern ensures that if someone tries to instantiate
  * Subtitles twice, then it won't be possible to do so.
  *
  * For more reading, see the following links.
  *
  * @link http://en.wikipedia.org/wiki/Singleton_pattern
  * @link http://hardcorewp.com/2013/using-singleton-classes-for-wordpress-plugins/
  * @link http://eamann.com/tech/the-case-for-singletons/
  * @link http://www.toppa.com/2013/the-case-against-singletons-in-wordpress/
  * @link http://eamann.com/tech/making-singletons-safe-in-php/
  *
  * @staticvar Singleton $instance The Singleton instance of this class.
  * @return Singleton The Singleton instance of this class.
  * @access public
  * @static
  *
  * @since 1.0.0
  */
 public static function getinstance()
 {
     if (!self::$instance) {
         self::$instance = new Subtitles();
     }
     return self::$instance;
 }
コード例 #7
0
     * To keep the layout simple, we're making a tradeoff, as subtitle is more significant rather than taxonomy list
     * 
     * @param string 	posted on data
     * @param int 		post ID
     * @return string 	posted on + taxonomy list data
     */
    if (!function_exists('cinnamon_subtitles_posted_on')) {
        function cinnamon_subtitles_posted_on($posted_on, $post_id)
        {
            // Get subtitles
            $subtitle = get_the_subtitle($post_id);
            if ($subtitle && is_singular()) {
                $entry_subtitle = cinnamon_get_entry_subtitle($post_id);
                if ($entry_subtitle) {
                    return sprintf(__('%s under <span class="taxonomies">%s</span>', 'cinnamon'), $posted_on, $entry_subtitle);
                } else {
                    return $posted_on;
                }
            } else {
                return $posted_on;
            }
        }
    }
    add_filter('cinnamon_posted_on', 'cinnamon_subtitles_posted_on', 10, 2);
}
/**
 * Removing Subtitles styling
 */
if (class_exists('Subtitles') && method_exists('Subtitles', 'subtitle_styling')) {
    remove_action('wp_head', array(Subtitles::getInstance(), 'subtitle_styling'));
}
コード例 #8
0
ファイル: functions.php プロジェクト: qhuit/UrbanPekor
/**
 * Removes the built-in styles in the Subtitles plugin.
 *
 * @since checkout 1.0
 */
function checkout_remove_subtitles_styles()
{
    if (class_exists('Subtitles') && method_exists('Subtitles', 'subtitle_styling')) {
        remove_action('wp_head', array(Subtitles::getInstance(), 'subtitle_styling'));
    }
}