Пример #1
0
 function recursive_array_search($needle, $haystack)
 {
     foreach ($haystack as $key => $value) {
         $current_key = $key;
         if ($needle === $value or is_array($value) && recursive_array_search($needle, $value) !== false) {
             return $current_key;
         }
     }
     return false;
 }
Пример #2
0
function rename_woocoomerce()
{
    global $menu;

    // Pinpoint menu item
    $woo = recursive_array_search( 'WooCommerce', $menu );

    // Validate
    if( !$woo )
        return;

    $menu[$woo][0] = __('Orders', 'woocommerce');
}
Пример #3
0
function recursive_array_search($needle, $haystack)
{
    foreach ($haystack as $key => $value) {
        $current_key = $key;
        if (is_array($value)) {
            $val = recursive_array_search($needle, $value);
        }
        if ($needle === $value or $val != false and $val != NULL) {
            if ($val == NULL) {
                return array($current_key);
            }
            return array_merge(array($current_key), $val);
        }
    }
    return false;
}
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'];
        }
    }
}
Пример #5
0
 /**
  * @Given /^the search results should include the hellenic-police dataset$/
  */
 public function theSearchResultsShouldIncludeTheHellenicPoliceDataset()
 {
     $result = $this->result->toArray();
     PHPUnit_Framework_Assert::assertTrue(recursive_array_search('hellenic-police', $result['result']));
 }
Пример #6
0
// subscore 3 - common directors subscore
if (strcmp($selected_radio, "common_director_slider") == 0) {
    foreach ($commonDirectors as $movie1 => $value) {
        // $value is an array of movie2 => list_of_genres
        $movie1_index = recursive_array_search($movie1, $movies);
        foreach ($value as $movie2 => $directors) {
            // compute score for the <movie1, movie2> pair
            //$sub_score = count($genres) * $common_genre_slider_value;
            //$sub_score = count($genres) / $max_number_common_genres;
            // UPDATE: this logic has moved to UI logic - we now send every link
            //$sub_score = (count($directors) >= $common_director_slider_value) ? count($directors) : 0;
            $sub_score = count($directors);
            if ($sub_score == 0) {
                continue;
            }
            $movie2_index = recursive_array_search($movie2, $movies);
            if (!isset($scores[$movie1_index][$movie2_index])) {
                $scores[$movie1_index][$movie2_index] = 0;
            }
            $scores[$movie1_index][$movie2_index] += $sub_score;
        }
    }
}
$threshold_score = $max_score * $score_filter_slider_value / 100;
//var_dump($max_score);
//var_dump($threshold_score);
$links = array();
foreach ($scores as $movie1_index => $value) {
    foreach ($value as $movie2_index => $score) {
        //      if ($score < $threshold_score) continue;
        $links[] = array('source' => $movie1_index, 'target' => $movie2_index, 'common_elements' => $score);
Пример #7
0
 /**
  * Delete from the customer database object
  *
  * @access      public
  * @param       int $user_id
  * @param       array $customer_data
  * @return      mixed
  */
 public static function delete_customer($user_id, $customer_data)
 {
     global $s4wc;
     // Sample structure of $customer_data
     // $customer_data = array(
     //  'card' => 'card_104FP72XTgyB3Fd3Pw9jM2Xh'
     // );
     if (!isset($customer_data)) {
         return false;
     }
     // Grab the current object out of the database and return a useable array
     $currentObject = maybe_unserialize(get_user_meta($user_id, $s4wc->settings['stripe_db_location'], true));
     // If the object exists already, do work
     if ($currentObject) {
         $newObject = $currentObject;
         // If a card id is passed, delete the card from the database object
         if (isset($customer_data['card'])) {
             unset($newObject['cards'][recursive_array_search($customer_data['card'], $newObject['cards'])]);
         }
         // Add to the database
         return update_user_meta($user_id, $s4wc->settings['stripe_db_location'], $newObject);
     } else {
         return false;
     }
 }
Пример #8
0
# | Email         developer@artlantis.net                                  |
# | Web           http://www.artlantis.net                                 |
# +------------------------------------------------------------------------+
$pgnt = true;
if ($page_main == 'organizations') {
    if (!permCheck($p)) {
        echo errMod(letheglobal_you_are_not_authorized_to_view_this_page, 'danger');
    } else {
        /* Requests */
        if (!isset($_GET['ID']) || !is_numeric($_GET['ID'])) {
            $ID = 0;
        } else {
            $ID = intval($_GET['ID']);
        }
        /* Mod Settings */
        $mod_confs = $lethe_modules[recursive_array_search('lethe.organizations', $lethe_modules)];
        $pg_title = $mod_confs['title'];
        $pg_nav_buts = '';
        $errText = '';
        /* Demo Check */
        if (!isDemo('addUser,editUser')) {
            $errText = errMod(letheglobal_demo_mode_active, 'danger');
        }
        ?>

<?php 
        if ($page_sub == 'organization') {
            include_once 'pg.organization.php';
        } else {
            if ($page_sub == 'users') {
                include_once 'pg.users.php';
Пример #9
0
/*  | Lethe Newsletter & Mailing System                                      | */
/*  | Copyright (c) Artlantis Design Studio 2014. All rights reserved.       | */
/*  | Version       2.0                                                      | */
/*  | Last modified 20.01.2015                                               | */
/*  | Email         developer@artlantis.net                                  | */
/*  | Web           http://www.artlantis.net                                 | */
/*  +------------------------------------------------------------------------+ */
$pgnt = true;
if ($page_main == 'newsletter') {
    if (!permCheck($p)) {
        echo errMod(letheglobal_you_are_not_authorized_to_view_this_page, 'danger');
    } else {
        $ID = !isset($_GET['ID']) || !is_numeric($_GET['ID']) ? 0 : intval($_GET['ID']);
        $TID = !isset($_GET['TID']) || !is_numeric($_GET['TID']) ? 0 : intval($_GET['TID']);
        /* Mod Settings */
        $mod_confs = $lethe_modules[recursive_array_search('lethe.newsletter', $lethe_modules)];
        $pg_title = $mod_confs['title'];
        $pg_nav_buts = '';
        $errText = '';
        /* Demo Check */
        if (!isDemo('addNewsletter,editNewsletter')) {
            $errText = errMod(letheglobal_demo_mode_active, 'danger');
        }
        /* Source Limit */
        $sourceLimit = calcSource(set_org_id, 'newsletters');
        /* Add Newsletter */
        if (isset($_POST['addNewsletter'])) {
            # Clear Template Data
            $TID = 0;
            if (limitBlock($sourceLimit, set_org_max_newsletter)) {
                if (!isset($_POST['groups']) || !is_array($_POST['groups'])) {
 private function get_question_label($cms_question)
 {
     $this->load->helper('array');
     $this->config->load('form_validation');
     $cms_rules = $this->config->item('cms_rules');
     $key = recursive_array_search($cms_question, $cms_rules);
     if ($key === FALSE) {
         // Try a second time, looking for an array
         $key = recursive_array_search("{$cms_question}[]", $cms_rules);
         if ($key === FALSE) {
             return 'Undefined';
         }
     }
     return $cms_rules[$key]['label'];
 }
Пример #11
0
/*  | Lethe Newsletter & Mailing System                                      | */
/*  | Copyright (c) Artlantis Design Studio 2014. All rights reserved.       | */
/*  | Version       2.0                                                      | */
/*  | Last modified 20.01.2015                                               | */
/*  | Email         developer@artlantis.net                                  | */
/*  | Web           http://www.artlantis.net                                 | */
/*  +------------------------------------------------------------------------+ */
$pgnt = true;
if ($page_main == 'autoresponder') {
    if (!permCheck($p)) {
        echo errMod(letheglobal_you_are_not_authorized_to_view_this_page, 'danger');
    } else {
        $ID = !isset($_GET['ID']) || !is_numeric($_GET['ID']) ? 0 : intval($_GET['ID']);
        /* Mod Settings */
        include_once 'mod.common.php';
        $mod_confs = $lethe_modules[recursive_array_search('lethe.autoresponder', $lethe_modules)];
        $pg_title = $mod_confs['title'];
        $pg_nav_buts = '';
        $errText = '';
        /* Demo Check */
        if (!isDemo('addAutoresponder,editAutoresponder')) {
            $errText = errMod(letheglobal_demo_mode_active, 'danger');
        }
        /* Source Limit */
        $sourceLimit = calcSource(set_org_id, 'autoresponder');
        /* Default Values */
        $ar_action = !isset($_POST['ar_action']) || !is_numeric($_POST['ar_action']) || $_POST['ar_action'] == 999 ? 999 : intval($_POST['ar_action']);
        $ar_time = 1;
        $ar_time_type = 'MINUTE';
        $ar_start_date = date('Y-m-d H:i:s');
        $ar_end_date = strtotime(date('Y-m-d H:i:s'));
Пример #12
0
function decodeState($dpt, $data)
{
    $state = dptSelectDecode($dpt, $data);
    $t = All_DPT();
    $type = recursive_array_search($dpt, $t);
    switch ($type) {
        case "Boolean":
            return $t[$type][$dpt]["Valeurs"][$state];
            break;
        case "8BitEncAbsValue":
            return $t[$type][$dpt]["Valeurs"][$state];
            break;
        default:
            return $state . " " . $t[$type][$dpt]["Unite"];
            break;
    }
}
Пример #13
0
# | Version       2.0                                                      |
# | Last modified 18.11.2014                                               |
# | Email         developer@artlantis.net                                  |
# | Web           http://www.artlantis.net                                 |
# +------------------------------------------------------------------------+
$pgnt = true;
include_once 'mod.common.php';
include_once 'mod.functions.php';
if ($page_main == 'subscribers') {
    if (!permCheck($p)) {
        echo errMod(letheglobal_you_are_not_authorized_to_view_this_page, 'danger');
    } else {
        /* Requests */
        $ID = !isset($_GET['ID']) || !is_numeric($_GET['ID']) ? 0 : intval($_GET['ID']);
        /* Mod Settings */
        $mod_confs = $lethe_modules[recursive_array_search('lethe.subscribers', $lethe_modules)];
        $pg_title = $mod_confs['title'];
        $pg_nav_buts = '';
        $errText = '';
        ?>

<?php 
        if ($page_sub == 'subscriber') {
            include_once 'pg.subscribers.php';
        } else {
            if ($page_sub == 'groups') {
                include_once 'pg.groups.php';
            } else {
                if ($page_sub == 'forms') {
                    include_once 'pg.forms.php';
                } else {
Пример #14
0
//    //$rows[] = $r;
//
//    $common_cast[ $r['movie1_title'] ][ $r['movie2_title'] ] [] = $r['actor_name'];
//
//}
//
//echo json_encode($common_cast);
//mysql_close($con);
$movieTitle = $_GET['movieTitle'];
require "include/php/helper_functions.php";
$movieData = get_data();
$movies = $movieData['movies'];
$commonCast = $movieData['commonCast'];
$commonGenres = $movieData['commonGenres'];
$commonDirectors = $movieData['commonDirectors'];
$movie_index = recursive_array_search($movieTitle, $movies);
unset($movieData['movies']);
// don't send information about all the movies
$movieData['movie_data'] = $movies[$movie_index];
// send common cast to this movie
$movieData['commonCast'] = $commonCast[$movieTitle];
// send common directors to this movie
$movieData['commonDirectors'] = $commonDirectors[$movieTitle];
//var_dump($movieData['commonDirectors']);
// but the genres are filtered because they are too many => not useful information anymore
// we will the genres of the movies found in (commonCast or commonDirectors)
$commonGenres = $commonGenres[$movieTitle];
$finalCommonGenres = array();
if (is_array($movieData['commonCast'])) {
    foreach ($movieData['commonCast'] as $movie => $actors) {
        if ($commonGenres[$movie]) {
Пример #15
0
# | Last modified 18.11.2014                                               |
# | Email         developer@artlantis.net                                  |
# | Web           http://www.artlantis.net                                 |
# +------------------------------------------------------------------------+
if ($page_main == 'templates') {
    if (!permCheck($p)) {
        echo errMod(letheglobal_you_are_not_authorized_to_view_this_page, 'danger');
    } else {
        /* Requests */
        if (!isset($_GET['ID']) || !is_numeric($_GET['ID'])) {
            $ID = 0;
        } else {
            $ID = intval($_GET['ID']);
        }
        /* Mod Settings */
        $mod_confs = $lethe_modules[recursive_array_search('lethe.templates', $lethe_modules)];
        $pg_title = $mod_confs['title'];
        $pg_nav_buts = '';
        $errText = '';
        /* Demo Check */
        if (!isDemo('addTemplate,editTemplate')) {
            $errText = errMod(letheglobal_demo_mode_active, 'danger');
        }
        /* Source Limit */
        $sourceLimit = calcSource(set_org_id, 'templates');
        /* Add Template */
        if (isset($_POST['addTemplate'])) {
            if (limitBlock($sourceLimit, set_org_max_template)) {
                if (!isset($_POST['title']) || empty($_POST['title'])) {
                    $errText .= '* ' . templates_please_enter_a_template_name . '<br>';
                }