function test($I_got, $u_thought, $options = array()) { if (is_string($options)) { $options = array('name' => $options); } $options = array_merge(array('name' => 'test', 'compare' => 'equal'), $options); $name = $options['name']; $compare = $options['compare']; switch ($compare) { case 'equal': $success = kind_of_equal($I_got, $u_thought); break; case 'in': $success = array_contain($I_got, $u_thought); break; default: throw new Exception("bad compare method: {$compare}"); break; } $fail = !$success; if ($fail) { $GLOBALS['all_pass'] = false; } include 'static/entry.html'; }
function get_sliderobjects_array($slider) { $category = get_field("categoria", $slider); $category_list = ""; $return = array(); $index = 0; for ($i = 0; $i < sizeof($category); $i++) { $category_list .= strlen($category_list) > 0 ? "," : ""; $category_list .= $category[$i]; } $option = get_field("opciones", $slider); if (is_user_logged_in()) { // print_array($option); // if(array_contain('new',$option)){echo "NEW";} // print_array($category); } // WP_Query arguments if (sizeof($option) > 0) { if (array_contain('new', $option)) { $args = array('posts_per_page' => '10', 'post_type' => array('objeto', 'serie'), 'post_status' => 'publish', 'cat' => $category_list, 'order' => 'DESC', 'orderby' => 'date'); } else { $args = array('posts_per_page' => '10', 'post_type' => array('objeto', 'serie'), 'post_status' => 'publish', 'cat' => $category_list, 'order' => 'ASC', 'orderby' => 'title'); } } else { $args = array('posts_per_page' => '10', 'post_type' => array('objeto', 'serie'), 'post_status' => 'publish', 'cat' => $category_list, 'orderby' => 'rand'); } // The Query $category_posts = new WP_Query($args); if ($category_posts->have_posts()) { while ($category_posts->have_posts()) { $category_posts->the_post(); $return[$index] = get_the_ID(); $index++; } } return $return; }
<a href="#" id="expandgroupconfpanel" class="txt_white">Configuración del grupo</a> </div> <div id="groupconfpanel" class="panel-body message"> <?php $structure = get_proyectstructure($group); $options = get_proyectstructure(); //print_array($options); ?> <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <?php for ($i = 0; $i < sizeof($options); $i++) { ?> <?php $stepactive = array_contain($structure, $options[$i][0][0], 0); ?> <div id="panel_<?php echo $options[$i][0][0]; ?> " class="panel <?php echo $stepactive === false ? "panel-default" : "panel-success"; ?> "> <div class="panel-heading" role="tab" id="heading_<?php echo $i; ?> "> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse_<?php echo $i;
function setunsetstep($group, $step) { include_once 'backend/backend.php'; $backend = new backend(); $retorno = array(FALSE, "Error no se pudo actualizar"); $result = false; $groupoptions = get_proyectstructure($group); $alloptions = get_proyectstructure(); $existe = array_contain($groupoptions, $step, 0); if ($existe) { ///Dar de baja al paso en el grupo $estructura = ""; for ($i = 0; $i < sizeof($groupoptions); $i++) { if ($groupoptions[$i][0] != $step) { $estructura .= $estructura != "" ? "|" : ""; $estructura .= $groupoptions[$i][0]; for ($e = 0; $e < sizeof($groupoptions[$i][1]); $e++) { $estructura .= "," . $groupoptions[$i][1][$e]; } } } $result = $backend->update_groupstructure($group, $estructura); } else { ///Agregar el paso al grupo $newstep = ""; $estructura = ""; switch ($step) { case "2": $newstep = "2,1,2,3,35,4,5,6,7"; break; case "3": $newstep = "3,8,9,11,15,29,30"; break; case "4": $newstep = "4,16,17,18,19"; break; case "5": $newstep = "5,20,36"; break; case "6": $newstep = "6,22"; break; } for ($i = 0; $i < sizeof($alloptions); $i++) { $existe = array_contain($groupoptions, $alloptions[$i][0][0], 0); if ($existe) { $estructura .= $estructura != "" ? "|" : ""; $estructura .= $alloptions[$i][0][0]; for ($e = 0; $e < sizeof($groupoptions[$existe - 1][1]); $e++) { $estructura .= "," . $groupoptions[$existe - 1][1][$e]; } } else { if ($step == $alloptions[$i][0][0]) { $estructura .= $estructura != "" ? "|" : ""; $estructura .= $newstep; } } } $result = $backend->update_groupstructure($group, $estructura); } if ($result) { return array(true, "Grupo actualizado."); } return $retorno; }
function get_object_list($option, $category) { // WP_Query arguments $object_list = array(); $args = array('post_type' => array('objeto', 'serie'), 'post_status' => array('publish')); if ($category) { $thecat = ""; for ($i = 0; $i < sizeof($category); $i++) { $thecat .= $category[$i] . ","; } $args['cat'] = $thecat; } if (array_contain('new', $option)) { $args['order'] = 'DESC'; $args['orderby'] = 'date'; } else { $args['order'] = 'ASC'; $args['orderby'] = 'rand'; } if (array_contain('userfriendlike', $option)) { // $args['order'] = 'DESC'; } if (array_contain('userlike', $option)) { //$args['order'] = 'DESC'; } $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); array_push($object_list, get_the_ID()); } } else { // no posts found } /* Restore original Post Data */ wp_reset_postdata(); return $object_list; }