static function getEventJSONFromAPIProxy($event_id, $files = 'avatar,gallery', $select = self::EVENT_FIELDS)
 {
     $result = MapasCulturaisApiProxy::fetch(MAPASCULTURAIS_URL . "api/event/findOne/?id=EQ({$event_id})&@select={$select}&@files=({$files}):url");
     return $result->body;
 }
Beispiel #2
0
/**
 * Enqueue scripts and styles.
 */
function cultural_scripts()
{
    wp_enqueue_script('jquery');
    wp_enqueue_style('cultural-style', get_stylesheet_uri(), array('magnific-popup'));
    $js_lib_path = get_bloginfo('template_directory') . (WP_DEBUG ? '/js/lib/' : '/js/min/');
    /* JUDO Font Awesome for the icons */
    wp_enqueue_style('font-awesome', get_bloginfo('template_directory') . '/css/font-awesome-4.3.0/css/font-awesome.min.css');
    wp_enqueue_script('event-emmiter', $js_lib_path . 'EventEmitter.js', array('jquery'), '3.1.8', true);
    wp_enqueue_script('imagesloaded', $js_lib_path . 'imagesloaded.pkgd.js', array('jquery', 'event-emmiter'), '3.1.8', true);
    wp_enqueue_script('masonry', $js_lib_path . 'masonry.pkgd.js', '', '3.1.5', true);
    wp_enqueue_script('responsive-nav', $js_lib_path . 'responsive-nav.js', array('jquery'), '1.0.32', true);
    /* Modernizr */
    wp_enqueue_script('modernizr', $js_lib_path . 'modernizr.js', '', '2.6.2');
    wp_enqueue_script('magnific-popup', $js_lib_path . 'jquery.magnific-popup.js', array('jquery'), '2.6.2');
    wp_enqueue_style('magnific-popup', get_bloginfo('template_directory') . '/css/magnific-popup.css');
    wp_enqueue_script('slider', get_bloginfo('template_directory') . '/js/min/idangerous.swiper-min.js', array('jquery'), '1.0.32', true);
    wp_enqueue_script('main', get_bloginfo('template_directory') . '/js/main.js', array('imagesloaded', 'masonry'), '', true);
    /* Load the comment reply JavaScript. */
    if (is_singular() && get_option('thread_comments') && comments_open()) {
        wp_enqueue_script('comment-reply');
    }
    //_pr(get_queried_object());
    $savedFilters = MapasCulturaisConfiguration::getOption();
    //var_dump(array_keys($savedFilters['classificacaoEtaria']));
    $configModel = MapasCulturaisConfiguration::getConfigModel();
    $empty = [];
    foreach ($savedFilters as $key => $data) {
        if ($configModel[$key]->type === 'entity') {
            foreach ($data as $id => $json) {
                $data[$id] = json_decode($json);
            }
        } elseif (is_array($data)) {
            $_data = array_keys(array_filter($data, function ($e) {
                if ($e) {
                    return $e;
                }
            }));
            if ($_data) {
                $data = $_data;
            } else {
                $data = array_keys($data);
                $empty[$key] = true;
            }
        }
        $savedFilters[$key] = $data;
    }
    $savedFilters['empty'] = $empty;
    $geoDivisions = array();
    foreach ($savedFilters as $key => $val) {
        if (substr($key, 0, 3) === 'geo') {
            unset($savedFilters[$key]);
            $geoDivisions[$key] = $val;
        }
    }
    $savedFilters['geoDivisions'] = $geoDivisions;
    $vars = array('generalFilters' => $savedFilters, 'apiUrl' => MapasCulturaisApiProxy::getProxyURL());
    if (is_category()) {
        $category = get_queried_object();
        $catFilters = array('geoDivisions' => array());
        foreach (get_option("category_{$category->cat_ID}") as $key => $options) {
            if (substr($key, 0, 3) === 'geo' && $options) {
                $catFilters['geoDivisions'][$key] = array_keys(array_filter($options));
            } elseif (in_array($key, array('linguagens', 'classificacaoEtaria'))) {
                $catFilters[$key] = array();
                foreach ($options as $name => $val) {
                    if ($val) {
                        $catFilters[$key][] = $name;
                    }
                }
            } else {
                $catFilters[$key] = $options;
            }
        }
        $vars['catid'] = $category->cat_ID;
        $vars['categoryFilters'] = $catFilters;
    }
    wp_localize_script('main', 'vars', $vars);
}
                    }
                }
            }
        }
    }
    static function mapObjects(&$object)
    {
        if (is_array($object)) {
            foreach ($object as $i => $obj) {
                self::mapObjects($obj);
            }
        } else {
            if (is_object($object)) {
                foreach ($object as $prop => $val) {
                    if ($prop == 'singleUrl') {
                        if (!isset(self::$objects[$val])) {
                            self::$objects[$val] = array();
                        }
                        self::$objects[$val][] = $object;
                    } else {
                        if (is_array($val) || is_object($val)) {
                            self::mapObjects($val);
                        }
                    }
                }
            }
        }
    }
}
MapasCulturaisApiProxy::init();