Exemplo n.º 1
1
 /**
  * Create a multi select field using jQuery
  * 
  * @param <type> $name
  * @param <type> $items
  * @param <type> $values
  * @param <type> $class
  * @param <type> $style
  * @param <type> $allmsg
  * @return <type>
  */
 public static function multiSelect($name, $items, $values = null, $class = null, $style = null, $allmsg = null)
 {
     $buf = '<select  multiple="multiple" id="' . $name . '"  name="' . $name . '[]" class="' . $class . '" style="' . $style . '">';
     if ($items) {
         foreach ($items as $item) {
             if (is_array($item)) {
                 $selected = $values && in_array($item[1], $values) ? ' selected = "true" ' : "";
                 $buf .= '<option value="' . htmlspecialchars($item[1]) . '"' . $selected . '>' . htmlentities($item[0]) . '</option>';
             } elseif ($item instanceof DbObject) {
                 $selected = $values && in_multiarray($item->getSelectOptionValue(), $values) ? ' selected = "true" ' : "";
                 $buf .= '<option value="' . htmlspecialchars($item->getSelectOptionValue()) . '"' . $selected . '>' . htmlentities($item->getSelectOptionTitle()) . '</option>';
             } elseif (is_scalar($item)) {
                 $selected = $values && in_array($item, $values) ? ' selected = "true" ' : "";
                 $buf .= '<option value="' . htmlspecialchars($item) . '"' . $selected . '>' . htmlentities($item) . '</option>';
             }
         }
     }
     $buf .= '</select>';
     $buf .= "<script>\r\n                jQuery(\"#{$name}\").asmSelect({addItemTarget: 'bottom', removeLabel: '<img src=\"'" . WEBROOT . "'/img/bin_closed.png\" border=\"0\"/>'});\r\n                jQuery(\"#{$name}\").change(function(e, data) { \$.fn.colorbox.resize(); });\r\n                </script>";
     return $buf;
 }
Exemplo n.º 2
0
function in_multiarray($elem, $array)
{
    $top = sizeof($array) - 1;
    $bottom = 0;
    while ($bottom <= $top) {
        if ($array[$bottom] == $elem) {
            return true;
        } else {
            if (is_array($array[$bottom])) {
                if (in_multiarray($elem, $array[$bottom])) {
                    return true;
                }
            }
        }
        $bottom++;
    }
    return false;
}
Exemplo n.º 3
0
function tpl_thesis($pdo, $data, $count, $ret_array = false)
{
    global $_LANGUAGE;
    $field = array();
    $items = array();
    $tpl = '
<div id="article_result">
<div class="a_side">
<div class="title"><b>' . $_LANGUAGE['a_side_fields'][DEFAULT_LANGUAGE] . '</b></div><br/>
{fields}
<div class="title"><b>' . $_LANGUAGE['a_side_author'][DEFAULT_LANGUAGE] . '</b></div><br/>
<input type="text" name="author" value="" />
</div>
<div class="a_result"><br/>
<div class="count">
<b>' . $_LANGUAGE['thesis_result_count'][DEFAULT_LANGUAGE] . '</b>&nbsp;' . $count . '
</div>
{search}
</div>
</div>
';
    if (DEFAULT_LANGUAGE == 'fa') {
        $search_tpl = '
<div class="entry">
<div class="fa_title"><a href="' . BASE_PATH . '/thesis/{link}" class="thesis_link">{title}</a></div>
<div class="content">
<div class="fa_author">نویسنده: {fullname}</div>
<div class="fa_date">تاریخ: {date}</div>
<div class="fa_major">رشته مرتبط: {major}</div>
</div>
</div>
';
    } else {
        if (DEFAULT_LANGUAGE == 'en') {
            $search_tpl = '
<div class="entry">
<div class="title"><a href="' . BASE_PATH . '/thesis/{link}" class="thesis_link">{title}</a></div>
<div class="content">
<div class="en_author">Author: {fullname}</div>
<div class="en_date">Date: {date}</div>
<div class="en_major">Major: {major}</div>
</div>
</div>
';
        }
    }
    $sql = "select id,title from field";
    $stmt = $pdo->query($sql);
    if ($stmt->rowCount()) {
        $fields = $stmt->fetchAll(PDO::FETCH_ASSOC);
        foreach ($fields as $f) {
            $field[] = '<label>' . $f['title'] . '&nbsp;<input type="radio" name="field" value="' . $f['id'] . '"/></label>';
        }
        $tpl = str_replace("{fields}", implode("\n", $field), $tpl);
    }
    foreach ($data as $row) {
        if ($row['thesis_title'] == null) {
            continue;
        }
        $major = in_multiarray($row['thesis_fId'], $fields, 'id', 'title');
        $title = $row['thesis_title'];
        $link = $row['thesis_id'] . '/' . str_replace(' ', '-', $title) . '.html';
        $stpl = $search_tpl;
        $stpl = str_replace("{title}", $row['thesis_title'], $stpl);
        $stpl = str_replace("{link}", $link, $stpl);
        $stpl = str_replace("{fullname}", $row['thesis_fullname'], $stpl);
        $stpl = str_replace("{date}", $row['thesis_date'], $stpl);
        $stpl = str_replace("{major}", $major, $stpl);
        $items[] = $stpl;
    }
    if (!$ret_array) {
        $tpl = str_replace("{search}", implode("\n", $items), $tpl);
        return $tpl;
    } else {
        return $items;
    }
}
Exemplo n.º 4
0
function in_multiarray($elem, $array, $field, $retkey)
{
    $top = sizeof($array) - 1;
    $bottom = 0;
    while ($bottom <= $top) {
        if ($array[$bottom][$field] == $elem) {
            return $array[$bottom][$retkey];
        } else {
            if (is_array($array[$bottom][$field])) {
                if ($ret = in_multiarray($elem, $array[$bottom][$field], $field, $retkey)) {
                    return $ret;
                }
            }
        }
        $bottom++;
    }
    return false;
}
Exemplo n.º 5
0
<?php

// Opciones del Tema - Lista Redes Sociales
$lista_redes = gobcl_get_option('_gobcl_lista_redes');
// Checkeamos que en el array de redes exista al menos una red activa para mostrar el sidebar
if (in_multiarray($lista_redes, '_gobcl_activa_red', true)) {
    ?>
    <div class="redes-lista">

        <h5 class="titulo-seccion">Síguenos</h5>
        <ul>
            <?php 
    $lista_redes = gobcl_get_option('_gobcl_lista_redes');
    function getNombreRed($nombre_red)
    {
        switch ($nombre_red) {
            case 'facebook':
                return 'Facebook';
            case 'twitter':
                return 'Twitter';
            case 'flickr':
                return 'Flickr';
            case 'youtube':
                return 'YouTube';
            case 'instagram':
                return 'Instagram';
            case 'pinterest':
                return 'Pinterest';
            case 'vimeo':
                return 'Vimeo';
            case 'linkedin':
Exemplo n.º 6
0
 function in_multiarray($elem, $array)
 {
     // if the $array is an array or is an object
     if (is_array($array) || is_object($array)) {
         // if $elem is in $array object
         if (is_object($array)) {
             $temp_array = get_object_vars($array);
             if (in_array($elem, $temp_array)) {
                 return TRUE;
             }
         }
         // if $elem is in $array return true
         if (is_array($array) && in_array($elem, $array)) {
             return TRUE;
         }
         // if $elem isn't in $array, then check foreach element
         foreach ($array as $array_element) {
             // if $array_element is an array or is an object call the in_multiarray function to this element
             // if in_multiarray returns TRUE, than the element is in array, else check next element
             if ((is_array($array_element) || is_object($array_element)) && in_multiarray($elem, $array_element)) {
                 return TRUE;
                 exit;
             }
         }
     }
     // if isn't in array return FALSE
     return FALSE;
 }
Exemplo n.º 7
0
 function wpsight_search_form_fields($search_fields, $search_details, $search_get, $search_advanced = false)
 {
     // Create form fields
     $listing_search = '';
     foreach ($search_fields as $detail => $value) {
         // Check if advanced search field
         if ($search_advanced == true && $value['advanced'] != true) {
             continue;
         }
         if ($search_advanced == false && $value['advanced'] == true) {
             continue;
         }
         if (isset($search_details[$detail]) && $search_details[$detail]) {
             $listing_search .= '<div class="listing-search-field listing-search-field-' . $value['type'] . ' listing-search-field-' . $detail . '">';
             // Create custom options (select)
             if ($value['type'] == 'select') {
                 // tell our js part what's the default value to help make things consistent
                 $default = isset($value['default']) && $value['default'] ? ' data-default="' . $value['default'] . '"' : '';
                 $listing_search .= '<select class="listing-search-' . $detail . ' select" name="' . $detail . '"' . $default . '>' . "\n";
                 // Empty option with label
                 $listing_search .= '<option value="">' . $value['label'] . '</option>' . "\n";
                 foreach ($value['data'] as $k => $v) {
                     $search_get[$detail] = isset($search_get[$detail]) ? $search_get[$detail] : false;
                     if (!empty($k)) {
                         $search_get[$detail] = isset($search_get[$detail]) && !empty($search_get[$detail]) ? $search_get[$detail] : $value['default'];
                         $listing_search .= '<option value="' . $k . '"' . selected($k, sanitize_title($search_get[$detail]), false) . '>' . $v . '</option>' . "\n";
                     }
                 }
                 $listing_search .= '</select><!-- .listing-search-' . $detail . ' -->' . "\n";
                 // Create custom options (text)
             } elseif ($value['type'] == 'text') {
                 $search_get[$detail] = isset($search_get[$detail]) ? $search_get[$detail] : false;
                 $listing_search .= '<input class="listing-search-' . $detail . ' text" title="' . $value['label'] . '" name="' . $detail . '" type="text" value="' . $search_get[$detail] . '" />' . "\n";
             } elseif ($value['type'] == 'number') {
                 $search_get[$detail] = isset($search_get[$detail]) ? $search_get[$detail] : false;
                 $listing_search .= '<input class="listing-search-' . $detail . ' text" title="' . $value['label'] . '" name="' . $detail . '" type="number" value="' . $search_get[$detail] . '" placeholder="' . $value['label'] . '"/>' . "\n";
             } elseif ($value['type'] == 'radio') {
                 // Create radio options
                 if (!empty($value['label'])) {
                     $listing_search .= '<label class="radiogroup" for="' . $detail . '">' . $value['label'] . '</label>' . "\n";
                 }
                 $search_get[$detail] = isset($search_get[$detail]) ? $search_get[$detail] : $value['default'];
                 foreach ($value['data'] as $k => $v) {
                     $default = $value['default'] == $k ? 'true' : 'false';
                     $listing_search .= '<label class="radio"><input type="radio" name="' . $detail . '" value="' . $k . '"' . checked($k, $search_get[$detail], false) . ' data-default="' . $default . '"/> ' . $v . '</label>' . "\n";
                 }
                 // Create taxonomy options
             } elseif ($value['type'] == 'taxonomy') {
                 if (isset($value['data']['dropdown']) && $value['data']['dropdown'] === true) {
                     $taxonomy = $value['taxonomy'];
                     // Pre-select taxonomy if search is term
                     $search_get[$taxonomy] = isset($search_get[$taxonomy]) ? $search_get[$taxonomy] : false;
                     $taxonomy_s = wpsight_search_is_taxnomy_term($search_get['s'], $taxonomy) ? $search_get['s'] : $search_get[$taxonomy];
                     $taxonomy_s = !empty($taxonomy_s) ? sanitize_title($taxonomy_s) : false;
                     // Set wp_dropdown_categories() $args
                     $defaults = array('taxonomy' => $value['taxonomy'], 'show_option_none' => $value['label'], 'selected' => $taxonomy_s, 'hierarchical' => 1, 'echo' => 0, 'name' => $detail, 'class' => 'listing-search-' . $detail . ' select', 'walker' => new wpSight_Walker_TaxonomyDropdown(), 'orderby' => 'ID', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'id' => '', 'depth' => 0, 'hide_if_empty' => false, 'cache' => true);
                     // Mix in search form fields $args
                     $args = wp_parse_args($value['data'], $defaults);
                     // Check if transients are active
                     $transients = apply_filters('wpsight_transients_taxonomies', false, 'listings-search', $args, $value['taxonomy']);
                     // If taxonomy transients are active
                     if ($transients === true) {
                         // If transient does not exist
                         if (false !== $taxonomy_s || isset($value['data']['cache']) && $value['data']['cache'] === false) {
                             // If cache is false, make sure to delete transient
                             $transient = get_transient('wpsight_taxonomy_dropdown_' . $value['taxonomy']);
                             if (false !== $transient) {
                                 delete_transient($transient);
                             }
                             // If an option is pre-selected, create dropdown dynamically
                             $taxonomy_dropdown = wp_dropdown_categories($args);
                         } else {
                             // If we use default dropdown, use transient
                             if (false === ($taxonomy_dropdown = get_transient('wpsight_taxonomy_dropdown_' . $value['taxonomy']))) {
                                 // Create taxonomy dropdown
                                 $taxonomy_dropdown = wp_dropdown_categories($args);
                                 // Set transient for this dropdown
                                 set_transient('wpsight_taxonomy_dropdown_' . $value['taxonomy'], $taxonomy_dropdown, DAY_IN_SECONDS);
                             }
                         }
                         // If taxonomy transients are not active
                     } else {
                         if ($detail == 'property-type' || $detail == 'location') {
                             //add custom param here
                             //$args['search_type'] = $detail;
                             //$args['show_option_none'] = '';
                             $taxonomy_dropdown = custom_multiple_dropdown_categories($args);
                         } else {
                             // Create taxonomy dropdown
                             $taxonomy_dropdown = wp_dropdown_categories($args);
                         }
                     }
                     // Add dropdown
                     $listing_search .= $taxonomy_dropdown;
                 } else {
                     $listing_search .= '<select class="listing-search-' . $detail . ' select" name="' . $detail . '">' . "\n";
                     // Empty option with label
                     $listing_search .= '<option value="">' . $value['label'] . '</option>' . "\n";
                     $taxonomy = $value['taxonomy'];
                     // Pre-select taxonomy if search is term
                     $search_get[$taxonomy] = isset($search_get[$taxonomy]) ? $search_get[$taxonomy] : false;
                     $taxonomy_s = wpsight_search_is_taxnomy_term($search_get['s'], $taxonomy) ? $search_get['s'] : $search_get[$taxonomy];
                     foreach ($value['data'] as $k => $v) {
                         if ($v->parent != 0) {
                             continue;
                         }
                         $listing_search .= '<option value="' . $v->slug . '"' . selected($v->slug, sanitize_title($taxonomy_s), false) . '>' . $v->name . '</option>' . "\n";
                         $children_1 = get_terms($taxonomy, array('child_of' => $v->term_id, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true));
                         if ($children_1) {
                             foreach ($children_1 as $child_1) {
                                 if ($child_1->parent != $v->term_id || !in_multiarray($child_1->term_id, $value['data'])) {
                                     continue;
                                 }
                                 $listing_search .= '<option value="' . $child_1->slug . '"' . selected($child_1->slug, sanitize_title($taxonomy_s), false) . '>' . str_repeat('&#45;', 1) . '&nbsp;' . $child_1->name . '</option>' . "\n";
                                 $children_2 = get_terms($taxonomy, array('child_of' => $child_1->term_id, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true));
                                 if ($children_2) {
                                     foreach ($children_2 as $child_2) {
                                         if ($child_2->parent != $child_1->term_id || !in_multiarray($child_2->term_id, $value['data'])) {
                                             continue;
                                         }
                                         $listing_search .= '<option value="' . $child_2->slug . '"' . selected($child_2->slug, sanitize_title($taxonomy_s), false) . '>' . str_repeat('&#45;', 2) . '&nbsp;' . $child_2->name . '</option>' . "\n";
                                         $children_3 = get_terms($taxonomy, array('child_of' => $child_2->term_id, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true));
                                         if ($children_3) {
                                             foreach ($children_3 as $child_3) {
                                                 if ($child_3->parent != $child_2->term_id || !in_multiarray($child_3->term_id, $value['data'])) {
                                                     continue;
                                                 }
                                                 $listing_search .= '<option value="' . $child_3->slug . '"' . selected($child_3->slug, sanitize_title($taxonomy_s), false) . '>' . str_repeat('&#45;', 3) . '&nbsp;' . $child_3->name . '</option>' . "\n";
                                                 $children_4 = get_terms($taxonomy, array('child_of' => $child_3->term_id, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true));
                                                 if ($children_4) {
                                                     foreach ($children_4 as $child_4) {
                                                         if ($child_4->parent != $child_3->term_id || !in_multiarray($child_4->term_id, $value['data'])) {
                                                             continue;
                                                         }
                                                         $listing_search .= '<option value="' . $child_4->slug . '"' . selected($child_4->slug, sanitize_title($taxonomy_s), false) . '>' . str_repeat('&#45;', 4) . '&nbsp;' . $child_4->name . '</option>' . "\n";
                                                     }
                                                 }
                                                 // endif $children_4
                                             }
                                         }
                                         // endif $children_3
                                     }
                                 }
                                 // endif $children_2
                             }
                         }
                         // endif $children_1
                     }
                     $listing_search .= '</select><!-- .listing-search-' . $detail . ' -->' . "\n";
                 }
             }
             $listing_search .= '</div><!-- .listing-search-field .listing-search-field-' . $detail . ' -->';
         }
     }
     return $listing_search;
 }
Exemplo n.º 8
0
 function in_multiarray($elem, $array, $field = "name")
 {
     $top = sizeof($array) - 1;
     $bottom = 0;
     if (!empty($array)) {
         while ($bottom <= $top) {
             if ($array[$bottom][$field] == $elem) {
                 return true;
             } else {
                 if (is_array($array[$bottom][$field])) {
                     if (in_multiarray($elem, $array[$bottom][$field])) {
                         return true;
                     }
                 }
             }
             $bottom++;
         }
     }
     return false;
 }
Exemplo n.º 9
0
function in_modified_multiarray($value, $array, $levels = 3)
{
    if (is_array($array)) {
        if (in_array($value, $array)) {
            return true;
        } else {
            --$levels;
            if ($levels <= 0) {
                return false;
            }
            foreach ($array as $key => $arr_value) {
                if (in_multiarray($value, $key, $levels)) {
                    return true;
                }
            }
        }
    } else {
        if ($value == $array) {
            return true;
        }
    }
    return false;
}