示例#1
0
 /**
  * Load Facet sidebar for both assets tab and instantations tab.
  * 
  * @return view
  */
 function load_facet_columns()
 {
     if (isAjax()) {
         $is_all_facet = $this->input->post('issearch');
         $index = $this->input->post('index');
         $this->load->library('sphnixrt');
         if ($is_all_facet > 0 || $this->is_station_user) {
             $states = $this->sphinx->facet_index('state', $index);
             $data['org_states'] = sortByOneKey($states['records'], 'state');
             unset($states);
             $stations = $this->sphinx->facet_index('organization', $index);
             $data['stations'] = sortByOneKey($stations['records'], 'organization');
             unset($stations);
             $nomination = $this->sphinx->facet_index('status', $index);
             $data['nomination_status'] = sortByOneKey($nomination['records'], 'status');
             unset($nomination);
             $media_type = $this->sphinx->facet_index('media_type', $index);
             $media_type = $this->make_facet($media_type, 'media_type', 'media_type');
             $data['media_types'] = sortByOneKey($media_type, 'media_type', TRUE);
             unset($media_type);
             $p_format = $this->sphinx->facet_index('physical_format_name', $index, 'physical');
             $p_format = $this->make_facet($p_format, 'physical_format_name', 'physical_format');
             $data['physical_formats'] = sortByOneKey($p_format, 'physical_format_name', TRUE);
             unset($p_format);
             $d_format = $this->sphinx->facet_index('digital_format_name', $index, 'digital');
             $d_format = $this->make_facet($d_format, 'digital_format_name', 'digital_format');
             $data['digital_formats'] = sortByOneKey($d_format, 'digital_format_name', TRUE);
             unset($d_format);
             $generation = $this->sphinx->facet_index('facet_generation', $index);
             $generation = $this->make_facet($generation, 'facet_generation', 'generation');
             $data['generations'] = sortByOneKey($generation, 'facet_generation', TRUE);
             unset($generation);
             $digitized = $this->sphinx->facet_index('digitized', $index, 'digitized');
             $data['digitized'] = $digitized['records'];
             $migration = $this->sphinx->facet_index('migration', $index, 'migration');
             $data['migration'] = $migration['records'];
         } else {
             if ($index == 'assets_list') {
                 $key_name = 'asset';
             } else {
                 $key_name = 'ins';
             }
             $data['org_states'] = json_decode($this->memcached_library->get($key_name . '_state'), TRUE);
             $data['stations'] = json_decode($this->memcached_library->get($key_name . '_stations'), TRUE);
             $data['nomination_status'] = json_decode($this->memcached_library->get($key_name . '_status'), TRUE);
             $data['media_types'] = json_decode($this->memcached_library->get($key_name . '_media_type'), TRUE);
             $data['physical_formats'] = json_decode($this->memcached_library->get($key_name . '_physical'), TRUE);
             $data['digital_formats'] = json_decode($this->memcached_library->get($key_name . '_digital'), TRUE);
             $data['generations'] = json_decode($this->memcached_library->get($key_name . '_generations'), TRUE);
             $data['digitized'] = json_decode($this->memcached_library->get($key_name . '_digitized'), TRUE);
             $data['migration'] = json_decode($this->memcached_library->get($key_name . '_migration'), TRUE);
         }
         echo $this->load->view('instantiations/_facet_columns', $data, TRUE);
         exit_function();
     }
     show_404();
 }
 private function formatMatchenAsHTML($matchen, $cid, $tid)
 {
     function sortByOneKey(array $array, $key, $asc = true)
     {
         $result = array();
         $values = array();
         foreach ($array as $id => $value) {
             $values[$id] = isset($value[$key]) ? $value[$key] : '';
         }
         if ($asc) {
             asort($values);
         } else {
             arsort($values);
         }
         foreach ($values as $key => $value) {
             $result[$key] = $array[$key];
         }
         return $result;
     }
     $matchen = sortByOneKey($matchen, 'ts');
     $html = '';
     $html .= '<table class="cid-' . $cid . '">';
     $html .= '<th>Datum</th>';
     $html .= '<th class="center">Thuis</th>';
     $html .= '<th class="center">Uit</th>';
     $html .= '<th class="center breed">Score</th>';
     $even_oneven = 'odd';
     foreach ($matchen as $match) {
         $t_status = $this->getWinnerStatus($match['thuisscore']);
         $u_status = $this->getWinnerStatus($match['uitscore']);
         $html .= '<tr style="cursor:pointer;" onclick="window.location=\'../../ontmoetingoverzicht/' . $cid . '/' . $match["mid"] . '\'" class="' . $even_oneven . '"><td class="datum">';
         $html .= $this->formatTsAsDate($match['ts']);
         $html .= '</td><td class="teamnaam right ' . $t_status . ' tid-' . $match['tid_t'] . '">';
         $html .= $match['thuis'] . '<span class="smallscreens"><br/>[' . $match['thuisscore'] . ']</span>';
         $html .= '</td><td class="teamnaam left ' . $u_status . ' tid-' . $match['tid_u'] . '">';
         $html .= $match['uit'] . '<span class="smallscreens"><br/>[' . $match['uitscore'] . ']</span>';
         $html .= '</td><td class="score center breed">';
         $html .= $match['thuisscore'] . '-' . $match['uitscore'];
         $html .= '</td></tr>';
         $even_oneven = $even_oneven == 'odd' ? 'even' : 'odd';
     }
     $html .= '</table>';
     $html .= '<div class="matchen-spacer"></div>';
     return $html;
 }
function pull_ALL_events($lat, $lon, $offset)
{
    //could be dirty
    /*
    	$offset = preg_replace("#[^0-9]#", "", $offset);
    	$rows_per_page = 7;
    	if($GLOBALS['include_YQL'] == false)
    $rows_per_page = 10;
    */
    // date searching
    $d = DATE_TO_SEARCH_FROM;
    $d2 = DATE_TO_SEARCH_TO;
    // DO YQL SECTION FIRST
    $cxn = $GLOBALS['cxn'];
    $main_array = array();
    // create an emptry array
    if ($GLOBALS['include_YQL'] == true) {
        $qry = "SELECT * FROM YQL_event_address\n\t\t\t\tWHERE \n\t\t\t\t'{$d}' <= (SELECT end_date FROM YQL_events \n\t\t\t\tWHERE event_id = YQL_event_address.event_id)\n\t\t\t\t";
        //LIMIT $offset, $rows_per_page
        $res = mysqli_query($cxn, $qry) or die("couldn't do the db loc thing...");
        while ($row = mysqli_fetch_assoc($res)) {
            extract($row);
            $d_total = distance($lat, $lon, $x_coord, $y_coord, "m");
            // the sub array
            $event = array("origin" => "YQL", "id" => $event_id, "distance" => $d_total, "address_DB" => 0, "lat" => $x_coord, "lon" => $y_coord);
            //$distances[$event_id] = $d_total;
            array_push($main_array, $event);
        }
        //end compare and extract loc data while.
    }
    // END YQL
    // DO USER SECTION NEXT
    $qry = "SELECT * FROM event_address\n\t\t\tWHERE\n\t\t\t'{$d}' <= (SELECT end_date FROM user_events \n\t\t\tWHERE event_id = event_address.event_id)";
    //LIMIT $offset, $rows_per_page
    $res = mysqli_query($cxn, $qry) or die("couldn't do the db loc thing...");
    while ($row = mysqli_fetch_assoc($res)) {
        extract($row);
        $d_total = distance($lat, $lon, $x_coord, $y_coord, "m");
        // the sub array
        $event = array("origin" => "user", "id" => $event_id, "distance" => $d_total, "address_DB" => $address_text, "lat" => $x_coord, "lon" => $y_coord);
        //$distances[$event_id] = $d_total;
        array_push($main_array, $event);
    }
    //end compare and extract loc data while.
    // NOW SORT THIS multidimen array
    $main_array = sortByOneKey($main_array, "distance");
    // MAIN LOOP
    $search_output = "";
    // you have to do the limit down here haha
    $offset = preg_replace("#[^0-9]#", "", $offset);
    $rows_per_page = 9;
    if ($GLOBALS['include_YQL'] == false) {
        $rows_per_page = 9;
    }
    $i = 0;
    foreach ($main_array as $event_array) {
        // offset =
        if ($i > $offset + $rows_per_page) {
            //echo "break tripped: i=$i and Offset=$offset, rows/page=$rows_per_page";
            break;
        }
        if (!($i < $offset)) {
            //echo "continue tripped: i=$i and offset=$offset";
            /*
            		echo "<pre>";
            		print_r($event_array);
            		echo "</pre>";
            */
            // THIS PULLS EVENT INFO VIA ID
            //print_r($event_array);
            extract($event_array);
            if ($origin == "YQL") {
                $event_row = get_all_event_list_YQL($id);
                if ($event_row != null) {
                    extract($event_row);
                }
                $all_vars = array("event_id" => $event_id, "user_id" => 0, "event_description" => $event_description, "event_title" => $event_title, "start_date" => $start_date, "country_name" => $country_name, "venue_name" => $venue_name, "venue_zip" => $venue_zip, "venue_state" => $venue_state, "lat" => $lat, "lon" => $lon, "distance" => $distance, "search_output" => $search_output);
                $search_output = search_output_func_YQL($all_vars);
                //see search_functions.php
            } else {
                if ($origin == "user") {
                    // do user stuff here
                    $event_row = get_all_event_list_users($id);
                    if ($event_row != null) {
                        extract($event_row);
                    }
                    $all_vars = array("event_id" => $event_id, "user_id" => $user_id, "event_description" => $event_description, "event_title" => $event_title, "start_date" => $start_date, "end_date" => $end_date, "venue_address" => $address_DB, "lat" => $lat, "lon" => $lon, "distance" => $distance, "search_output" => $search_output, "isContactInfo" => $is_contactable, "contactInfo" => $contact_info, "contactType" => $contact_type);
                    $search_output = search_output_func_users($all_vars);
                    //see search_functions.php
                }
            }
        }
        // end inner else
        $i++;
    }
    //end loop for location search	 FOREACH
    return $search_output;
}
示例#4
0
}
$groups_KEY = $_REQUEST['groups_KEY'];
if (!$_REQUEST['groups_KEY']) {
    echo '<form method="get">
	<label>Select Group</label>
	<select name="groups_KEY">';
    include 'partials/options/_lists.php';
    echo '	</select>
	<input type="submit">
</form>
';
} else {
    $supporters = get_contact_list_array($_REQUEST['groups_KEY']);
    $g = get_group($_REQUEST['groups_KEY']);
    if ($_REQUEST['order']) {
        $supporters = sortByOneKey($supporters, $_REQUEST['order'], $asc = true);
    }
    ?>
<script>
function add_supporters_to_form(){
  	var $form = $(this);
  	var html = '';
  	
  	$(".person-checkbox:checked").each(function(){
      var supporter_groups_key = $(this).data('supporter_groups_key');
      html += '<input type="hidden" name="supporter_groups[]" value="'+supporter_groups_key+'" />';
  	});
  	
    $form.prepend(html);
}
示例#5
0
文件: crons.php 项目: TheHexa1/AMS
 /**
  * Save Facet Search Values into memcahed.
  * 
  * @return 
  */
 function auto_memcached_facets()
 {
     $this->load->library('memcached_library');
     $this->load->model('sphinx_model', 'sphinx');
     $memcached = new StdClass();
     $memcached->ins = 'instantiations_list';
     $memcached->asset = 'assets_list';
     $search_facet = new stdClass();
     $search_facet->state = 'state';
     $search_facet->stations = 'organization';
     $search_facet->status = 'status';
     $search_facet->media_type = 'media_type';
     $search_facet->physical = 'physical_format_name';
     $search_facet->digital = 'digital_format_name';
     $search_facet->generations = 'facet_generation';
     $search_facet->digitized = 'digitized';
     $search_facet->migration = 'migration';
     foreach ($memcached as $index => $index_name) {
         foreach ($search_facet as $columns => $facet) {
             $result = $this->sphinx->facet_index($facet, $index_name, $columns);
             if (in_array($facet, array('media_type', 'physical_format_name', 'digital_format_name', 'facet_generation'))) {
                 $make_facet = array();
                 foreach ($result['records'] as $_row) {
                     $exploded_facet = explode('___', $_row[$facet]);
                     foreach ($exploded_facet as $single_value) {
                         if (isset($make_facet[trim($single_value)])) {
                             $make_facet[trim($single_value)] = $make_facet[trim($single_value)] + $_row['@count'];
                         } else {
                             $make_facet[trim($single_value)] = $_row['@count'];
                         }
                     }
                 }
                 $final_facet = array();
                 foreach ($make_facet as $_index => $_single_facet) {
                     if ($_index != '(**)' && $_index != '') {
                         $final_facet[] = array($facet => $_index, '@count' => $_single_facet);
                     }
                 }
                 $this->memcached_library->set($index . '_' . $columns, json_encode(sortByOneKey($final_facet, $facet, TRUE)), 36000);
             } else {
                 if (in_array($columns, array('digitized', 'migration'))) {
                     $this->memcached_library->set($index . '_' . $columns, json_encode(sortByOneKey($result['records'], $facet, FALSE)), 36000);
                 } else {
                     if ($columns == 'stations') {
                         $result = $this->sphinx->facet_index($facet, $index_name);
                         $this->memcached_library->set($index . '_' . $columns, json_encode(sortByOneKey($result['records'], $facet)), 36000);
                     } else {
                         $result = $this->sphinx->facet_index($facet, $index_name);
                         $this->memcached_library->set($index . '_' . $columns, json_encode(sortByOneKey($result['records'], $facet, FALSE)), 36000);
                     }
                 }
             }
         }
         myLog("Succussfully Updated {$index_name} Facet Search");
     }
     exit;
 }