예제 #1
0
/**
 * Searches for matching pagenames
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_qsearch()
{
    global $conf;
    global $lang;
    $query = cleanID($_POST['q']);
    if (empty($query)) {
        $query = cleanID($_GET['q']);
    }
    if (empty($query)) {
        return;
    }
    require_once DOKU_INC . 'inc/html.php';
    require_once DOKU_INC . 'inc/fulltext.php';
    $data = array();
    $data = ft_pageLookup($query);
    if (!count($data)) {
        return;
    }
    print '<strong>' . $lang['quickhits'] . '</strong>';
    print '<ul>';
    foreach ($data as $id) {
        print '<li>';
        $ns = getNS($id);
        if ($ns) {
            $name = shorten(noNS($id), ' (' . $ns . ')', 30);
        } else {
            $name = $id;
        }
        print html_wikilink(':' . $id, $name);
        print '</li>';
    }
    print '</ul>';
}
예제 #2
0
/**
 * Searches for matching pagenames
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_qsearch()
{
    global $conf;
    global $lang;
    $query = $_POST['q'];
    if (empty($query)) {
        $query = $_GET['q'];
    }
    if (empty($query)) {
        return;
    }
    $data = ft_pageLookup($query, true, useHeading('navigation'));
    if (!count($data)) {
        return;
    }
    print '<strong>' . $lang['quickhits'] . '</strong>';
    print '<ul>';
    foreach ($data as $id => $title) {
        if (useHeading('navigation')) {
            $name = $title;
        } else {
            $ns = getNS($id);
            if ($ns) {
                $name = shorten(noNS($id), ' (' . $ns . ')', 30);
            } else {
                $name = $id;
            }
        }
        echo '<li>' . html_wikilink(':' . $id, $name) . '</li>';
    }
    print '</ul>';
}
/**
* @param object $resource
* @uses $CFG
*/
function get_text_for_indexing_ppt(&$resource, $directfile = '')
{
    global $CFG;
    $indextext = null;
    // SECURITY : do not allow non admin execute anything on system !!
    if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
        return;
    }
    if ($directfile == '') {
        $text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
    } else {
        $text = implode('', file("{$CFG->dataroot}/{$directfile}"));
    }
    $remains = $text;
    $fragments = array();
    while (preg_match('/\\x00\\x9F\\x0F\\x04.{9}(......)(.*)/s', $remains, $matches)) {
        $unpacked = unpack("ncode/Llength", $matches[1]);
        $sequencecode = $unpacked['code'];
        $length = $unpacked['length'];
        // print "length : ".$length." ; segment type : ".sprintf("%x", $sequencecode)."<br/>";
        $followup = $matches[2];
        // local system encoding sequence
        if ($sequencecode == 0xa80f) {
            $aFragment = substr($followup, 0, $length);
            $remains = substr($followup, $length);
            $fragments[] = $aFragment;
        } elseif ($sequencecode == 0xa00f) {
            $aFragment = substr($followup, 0, $length);
            // $aFragment = mb_convert_encoding($aFragment, 'UTF-16', 'UTF-8');
            $aFragment = preg_replace('/\\xA0\\x00\\x19\\x20/s', "'", $aFragment);
            // some quotes
            $aFragment = preg_replace('/\\x00/s', "", $aFragment);
            $remains = substr($followup, $length);
            $fragments[] = $aFragment;
        } else {
            $remains = $followup;
        }
    }
    $indextext = implode(' ', $fragments);
    $indextext = preg_replace('/\\x19\\x20/', "'", $indextext);
    // some quotes
    $indextext = preg_replace('/\\x09/', '', $indextext);
    // some extra chars
    $indextext = preg_replace('/\\x0D/', "\n", $indextext);
    // some quotes
    $indextext = preg_replace('/\\x0A/', "\n", $indextext);
    // some quotes
    $indextextprint = implode('<hr/>', $fragments);
    // debug code
    // $logppt = fopen("C:/php5/logs/pptlog", "w");
    // fwrite($logppt, $indextext);
    // fclose($logppt);
    if (!empty($CFG->block_search_limit_index_body)) {
        $indextext = shorten($text, $CFG->block_search_limit_index_body);
    }
    $indextext = mb_convert_encoding($indextext, 'UTF8', 'auto');
    return $indextext;
}
예제 #4
0
 /**
  * Search
  *
  * Performs the search and stores results
  *
  * @param string $query
  */
 function search($query = '', $page = 0)
 {
     $this->CI->load->helper('shorten');
     // content search
     $content_types = unserialize(setting('search_content_types'));
     if (!empty($content_types)) {
         $this->CI->load->model('publish/content_model');
         $this->CI->load->model('publish/content_type_model');
         $this->CI->load->model('custom_fields_model');
         foreach ($content_types as $type => $summary_field) {
             $content = $this->CI->content_model->get_contents(array('keyword' => $query, 'type' => $type, 'sort' => 'relevance', 'sort_dir' => 'DESC', 'limit' => '50'));
             if (!empty($content)) {
                 foreach ($content as $item) {
                     // prep summary field
                     if (!empty($summary_field)) {
                         $item['summary'] = shorten(strip_tags($item[$summary_field]), setting('search_trim'), TRUE);
                     }
                     $item['result_type'] = 'content';
                     $this->content_results[$item['id']] = $item;
                     $this->relevance_keys['content|' . $item['id']] = $item['relevance'];
                 }
             }
         }
     }
     // product search
     if (setting('search_products') == '1' and module_installed('store')) {
         $this->CI->load->model('store/products_model');
         $products = $this->CI->products_model->get_products(array('keyword' => $query, 'sort' => 'relevance', 'sort_dir' => 'DESC', 'limit' => '50'));
         if (!empty($products)) {
             foreach ($products as $product) {
                 // prep summary field
                 $product['summary'] = shorten(strip_tags($product['description']), setting('search_trim'), TRUE);
                 $product['result_type'] = 'product';
                 $this->product_results[$product['id']] = $product;
                 $this->relevance_keys['product|' . $product['id']] = $product['relevance'];
             }
         }
     }
     // sort results
     arsort($this->relevance_keys);
     // put together final results array
     foreach ($this->relevance_keys as $item => $relevance) {
         list($type, $id) = explode('|', $item);
         if ($type == 'content') {
             $this->results[] = $this->content_results[$id];
         } elseif ($type == 'product') {
             $this->results[] = $this->product_results[$id];
         }
     }
     // how many total results?
     $this->total_results = count($this->results);
     if ($this->total_results == 0) {
         return array();
     }
     // grab the segment of the array corresponding to our page
     return array_slice($this->results, $page * $this->results_per_page, $this->results_per_page);
 }
function do_print($row_in)
{
    global $today, $today_ref, $line_ctr, $units_str, $severities;
    if (empty($today)) {
        $today_ref = date("z", $row_in['problemstart']);
        $today = substr(format_date($row_in['problemstart']), 0, 5);
    } else {
        if (!($today_ref == date("z", $row_in['problemstart']))) {
            // date change?
            $today_ref = date("z", $row_in['problemstart']);
            $today = substr(format_date($row_in['problemstart']), 0, 5);
        }
    }
    $def_city = get_variable('def_city');
    $def_st = get_variable('def_st');
    print "<TR CLASS= ''>\n";
    print "<TD>{$today}</TD>\n";
    //		Date -
    $problemstart = format_date($row_in['problemstart']);
    $problemstart_sh = short_ts($problemstart);
    print "<TD onMouseover=\"Tip('{$problemstart}');\" onmouseout='UnTip();'>{$problemstart_sh}</TD>\n";
    //		start
    $problemend = format_date($row_in['problemend']);
    $problemend_sh = short_ts($problemend);
    print "<TD onMouseover=\"Tip('{$problemend}');\" onmouseout='UnTip();'>{$problemend_sh}</TD>\n";
    //		end
    $elapsed = my_date_diff($row_in['problemstart'], $row_in['problemend']);
    print "<TD>{$elapsed}</TD>\n";
    //		Ending time
    print "<TD ALIGN='center'>{$severities[$row_in['severity']]}</TD>\n";
    $scope = $row_in['tick_scope'];
    $scope_sh = shorten($row_in['tick_scope'], 20);
    print "<TD onMouseover=\"Tip('{$scope}');\" onmouseout='UnTip();'>{$scope_sh}</TD>\n";
    //		Call type
    $comment = $row_in['comments'];
    $short_comment = shorten($row_in['comments'], 50);
    print "<TD onMouseover=\"Tip('{$comment}');\" onMouseout='UnTip();'>{$short_comment}</TD>\n";
    //		Comments/Disposition
    $facility = $row_in['facy_name'];
    $facility_sh = shorten($row_in['facy_name'], 16);
    print "<TD onMouseover=\"Tip('{$facility}');\" onmouseout='UnTip();'>{$facility_sh}</TD>\n";
    //		Facility
    $city = $row_in['tick_city'] == $def_city ? "" : ", {$row_in['tick_city']}";
    $st = $row_in['tick_state'] == $def_st ? "" : ", {$row_in['tick_state']}";
    $addr = "{$row_in['tick_street']}{$city}{$st}";
    $addr_sh = shorten($row_in['tick_street'] . $city . $st, 20);
    print "<TD onMouseover=\"Tip('{$addr}');\" onMouseout='UnTip();'>{$addr_sh}</TD>\n";
    //		Street addr
    print "<TD>{$units_str}</TD>\n";
    //		Units responding
    print "</TR>\n\n";
    $line_ctr++;
}
 /** {@inheritdoc} */
 public function register()
 {
     if (empty($this->provides)) {
         return;
     }
     foreach ($this->provides as $v) {
         if (false !== strpos($v, '\\')) {
             $this->container->add($v);
             if (false === stripos($v, '\\events\\')) {
                 $this->container->add(shorten($v), $v);
             }
         }
     }
 }
예제 #7
0
/**
* Global Search Engine for Moodle
* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr] 
* 2007/08/02
*
* this is a format handler for getting text out of a proprietary binary format 
* so it can be indexed by Lucene search engine
*/
function get_text_for_indexing_txt(&$resource)
{
    global $CFG, $USER;
    // SECURITY : do not allow non admin execute anything on system !!
    if (!isadmin($USER->id)) {
        return;
    }
    // just try to get text empirically from ppt binary flow
    $text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
    if (!empty($CFG->block_search_limit_index_body)) {
        $text = shorten($text, $CFG->block_search_limit_index_body);
    }
    return $text;
}
예제 #8
0
/**
* Global Search Engine for Moodle
* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr] 
* 2007/08/02
*
* this is a format handler for getting text out of a proprietary binary format 
* so it can be indexed by Lucene search engine
*/
function get_text_for_indexing_xml(&$resource)
{
    global $CFG, $USER;
    // SECURITY : do not allow non admin execute anything on system !!
    if (!isadmin($USER->id)) {
        return;
    }
    // just get text
    $text = implode('', file("{$CFG->dataroot}/{$resource->course}/({$resource->reference})"));
    // filter out all xml tags
    $text = preg_replace("/<[^>]*>/", ' ', $text);
    if (!empty($CFG->block_search_limit_index_body)) {
        $text = shorten($text, $CFG->block_search_limit_index_body);
    }
    return $text;
}
예제 #9
0
파일: ajax.php 프로젝트: s-blu/dokuwiki
/**
 * Searches for matching pagenames
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function ajax_qsearch()
{
    global $lang;
    global $INPUT;
    $maxnumbersuggestions = 50;
    $query = $INPUT->post->str('q');
    if (empty($query)) {
        $query = $INPUT->get->str('q');
    }
    if (empty($query)) {
        return;
    }
    $query = urldecode($query);
    $data = ft_pageLookup($query, true, useHeading('navigation'));
    if (!count($data)) {
        return;
    }
    print '<strong>' . $lang['quickhits'] . '</strong>';
    print '<ul>';
    $counter = 0;
    foreach ($data as $id => $title) {
        if (useHeading('navigation')) {
            $name = $title;
        } else {
            $ns = getNS($id);
            if ($ns) {
                /* Displays the Header of the Namespace-Page or of namespace:start as the Name of the NS */
                $ns_name = p_get_first_heading(getNS($id));
                if (!$ns_name) {
                    $ns_name = p_get_first_heading(getNS($id) . ':start');
                }
                $name = shorten(' [' . $ns_name . ']', 30);
            } else {
                $name = $id;
            }
        }
        echo '<li>' . html_wikilink(':' . $id, $name) . '</li>';
        $counter++;
        if ($counter > $maxnumbersuggestions) {
            echo '<li>...</li>';
            break;
        }
    }
    print '</ul>';
}
예제 #10
0
/**
* @param object $resource
* @uses $CFG
*/
function get_text_for_indexing_txt(&$resource, $directfile = '')
{
    global $CFG;
    // SECURITY : do not allow non admin execute anything on system !!
    if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
        return;
    }
    // just try to get text empirically from ppt binary flow
    if ($directfile == '') {
        $text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
    } else {
        $text = implode('', file("{$CFG->dataroot}/{$directfile}"));
    }
    if (!empty($CFG->block_search_limit_index_body)) {
        $text = shorten($text, $CFG->block_search_limit_index_body);
    }
    return $text;
}
예제 #11
0
 function index()
 {
     $this->navigation->PageTitle('Transactions');
     $this->load->model('cp/dataset', 'dataset');
     // prepare gateway select
     $this->load->model('gateway_model');
     $gateways = $this->gateway_model->GetGateways($this->user->Get('client_id'));
     // we're gonna short gateway names
     $this->load->helper('shorten');
     $gateway_options = array();
     $gateway_values = array();
     if (is_array($gateways) && count($gateways)) {
         foreach ($gateways as $gateway) {
             $gateway_options[$gateway['id']] = $gateway['gateway'];
             $gateway_values[$gateway['id']] = shorten($gateway['gateway'], 15);
         }
     }
     // now get deleted gateways and add them in so that, when viewing the
     // transactions table, we have names for each gateway in this array
     $gateways = $this->gateway_model->GetGateways($this->user->Get('client_id'), array('deleted' => '1'));
     if (!empty($gateways)) {
         foreach ($gateways as $gateway) {
             $gateway['gateway_short'] = shorten($gateway['gateway'], 15);
             $gateway_values[$gateway['id']] = $gateway['gateway_short'];
         }
     }
     $columns = array(array('name' => 'ID #', 'sort_column' => 'id', 'type' => 'id', 'width' => '10%', 'filter' => 'id'), array('name' => 'Status', 'sort_column' => 'status', 'type' => 'select', 'options' => array('1' => 'ok', '2' => 'refunded', '0' => 'failed', '3' => 'failed-repeat'), 'width' => '4%', 'filter' => 'status'), array('name' => 'Date', 'sort_column' => 'timestamp', 'type' => 'date', 'width' => '20%', 'filter' => 'timestamp', 'field_start_date' => 'start_date', 'field_end_date' => 'end_date'), array('name' => 'Amount', 'sort_column' => 'amount', 'type' => 'text', 'width' => '10%', 'filter' => 'amount'), array('name' => 'Customer Name', 'sort_column' => 'customers.last_name', 'type' => 'text', 'width' => '20%', 'filter' => 'customer_last_name'), array('name' => 'Card', 'sort_column' => 'card_last_four', 'type' => 'text', 'width' => '10%', 'filter' => 'card_last_four'), array('name' => 'Gateway', 'type' => 'select', 'width' => '10%', 'options' => $gateway_options, 'filter' => 'gateway_id'), array('name' => 'Recurring', 'width' => '10%', 'type' => 'text', 'filter' => 'recurring_id'));
     // set total rows by hand to reduce database load
     $result = $this->db->select('COUNT(order_id) AS total_rows', FALSE)->from('orders')->where('client_id', $this->user->Get('client_id'))->get();
     $this->dataset->total_rows((int) $result->row()->total_rows);
     if ($this->dataset->total_rows > 5000) {
         // we're going to have a memory error with this much data
         $this->dataset->use_total_rows();
     }
     $this->dataset->Initialize('charge_model', 'GetCharges', $columns);
     $this->load->model('charge_model');
     // get total charges
     $total_amount = $this->charge_model->GetTotalAmount($this->user->Get('client_id'), $this->dataset->params);
     // sidebar
     $this->navigation->SidebarButton('Recurring Charges', 'transactions/all_recurring');
     $this->navigation->SidebarButton('New Charge', 'transactions/create');
     $data = array('total_amount' => $total_amount, 'gateways' => $gateway_values);
     $this->load->view(branded_view('cp/transactions.php'), $data);
 }
예제 #12
0
/**
* @param object $resource
* @uses $CFG
*/
function get_text_for_indexing_xml(&$resource, $directfile = '')
{
    global $CFG;
    // SECURITY : do not allow non admin execute anything on system !!
    if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
        return;
    }
    // just get text
    if ($directfile == '') {
        $text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
    } else {
        $text = implode('', file("{$CFG->dataroot}/{$directfile}"));
    }
    // filter out all xml tags
    $text = preg_replace("/<[^>]*>/", ' ', $text);
    if (!empty($CFG->block_search_limit_index_body)) {
        $text = shorten($text, $CFG->block_search_limit_index_body);
    }
    return $text;
}
예제 #13
0
/**
* @param object $resource
* @uses $CFG
*/
function get_text_for_indexing_htm(&$resource, $directfile = '')
{
    global $CFG;
    // SECURITY : do not allow non admin execute anything on system !!
    if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
        return;
    }
    // just get text
    if ($directfile == '') {
        $text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
    } else {
        $text = implode('', file("{$CFG->dataroot}/{$directfile}"));
    }
    // extract keywords and other interesting meta information and put it back as real content for indexing
    if (preg_match('/(.*)<meta ([^>]*)>(.*)/is', $text, $matches)) {
        $prefix = $matches[1];
        $meta_attributes = $matches[2];
        $suffix = $matches[3];
        if (preg_match('/name="(keywords|description)"/i', $meta_attributes)) {
            preg_match('/content="([^"]+)"/i', $meta_attributes, $matches);
            $text = $prefix . ' ' . $matches[1] . ' ' . $suffix;
        }
    }
    // brutally filters all html tags
    $text = preg_replace("/<[^>]*>/", '', $text);
    $text = preg_replace("/<!--[^>]*-->/", '', $text);
    $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
    $text = mb_convert_encoding($text, 'UTF-8', 'auto');
    /*
    * debug code for tracing input
    echo "<hr/>";
    $FILE = fopen("filetrace.log", 'w');
    fwrite($FILE, $text);
    fclose($FILE);
    echo "<hr/>";
    */
    if (!empty($CFG->block_search_limit_index_body)) {
        $text = shorten($text, $CFG->block_search_limit_index_body);
    }
    return $text;
}
예제 #14
0
 /** @return string */
 public function __toString()
 {
     return str_replace('Entity', '', shorten(get_class($this)));
 }
function popup_ticket($id, $print = 'false', $search = FALSE)
{
    /* 7/9/09 - show specified ticket */
    global $istest, $iw_width;
    if ($istest) {
        print "GET<br />\n";
        dump($_GET);
        print "POST<br />\n";
        dump($_POST);
    }
    if ($id == '' or $id <= 0 or !check_for_rows("SELECT * FROM `{$GLOBALS['mysql_prefix']}ticket` WHERE id='{$id}'")) {
        /* sanity check */
        print "Invalid Ticket ID: '{$id}'<BR />";
        return;
    }
    $restrict_ticket = get_variable('restrict_user_tickets') == 1 && !is_administrator() ? " AND owner={$_SESSION['user_id']}" : "";
    $query = "SELECT *,UNIX_TIMESTAMP(problemstart) AS problemstart,UNIX_TIMESTAMP(problemend) AS problemend,UNIX_TIMESTAMP(date) AS date,UNIX_TIMESTAMP(updated) AS updated, `{$GLOBALS['mysql_prefix']}ticket`.`description` AS `tick_descr` FROM `{$GLOBALS['mysql_prefix']}ticket` WHERE ID='{$id}' {$restrict_ticket}";
    // 8/12/09
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    if (!mysql_num_rows($result)) {
        //no tickets? print "error" or "restricted user rights"
        print "<FONT CLASS=\"warn\">No such ticket or user access to ticket is denied</FONT>";
        exit;
    }
    $row = stripslashes_deep(mysql_fetch_assoc($result));
    ?>
	<TABLE BORDER="0" ID = "outer" ALIGN="left">
<?php 
    print "<TD ALIGN='left'>";
    print "<TABLE ID='theMap' BORDER=0><TR CLASS='odd' ><TD  ALIGN='center'>\n\t\t<DIV ID='map' STYLE='WIDTH:" . get_variable('map_width') . "px; HEIGHT: " . get_variable('map_height') . "PX'></DIV>\n\t\t</TD></TR>";
    // 11/29/08
    print "<FORM NAME='sv_form' METHOD='post' ACTION=''><INPUT TYPE='hidden' NAME='frm_lat' VALUE=" . $row['lat'] . ">";
    // 2/11/09
    print "<INPUT TYPE='hidden' NAME='frm_lng' VALUE=" . $row['lng'] . "></FORM>";
    print "<TR ID='pointl1' CLASS='print_TD' STYLE = 'display:none;'>\n\t\t<TD ALIGN='center'><B>Range:</B>&nbsp;&nbsp; <SPAN ID='range'></SPAN>&nbsp;&nbsp;<B>Brng</B>:&nbsp;&nbsp;\n\t\t\t<SPAN ID='brng'></SPAN></TD></TR>\n\n\t\t<TR ID='pointl2' CLASS='print_TD' STYLE = 'display:none;'>\n\t\t\t<TD ALIGN='center'><B>Lat:</B>&nbsp;<SPAN ID='newlat'></SPAN>\n\t\t\t&nbsp;<B>Lng:</B>&nbsp;&nbsp; <SPAN ID='newlng'></SPAN>&nbsp;&nbsp;<B>NGS:</B>&nbsp;<SPAN ID = 'newusng'></SPAN></TD></TR>\n";
    print "</TABLE>\n";
    print "</TD></TR>";
    print "<TR CLASS='odd' ><TD COLSPAN='2' CLASS='print_TD'>";
    $lat = $row['lat'];
    $lng = $row['lng'];
    print "</TABLE>\n";
    ?>
	<SCRIPT SRC='../js/usng.js' TYPE='text/javascript'></SCRIPT>
	<SCRIPT SRC="../js/graticule.js" type="text/javascript"></SCRIPT>
	<SCRIPT>


	function isNull(val) {								// checks var stuff = null;
		return val === null;
		}

	var the_grid;
	var grid = false;
	function doGrid() {
		if (grid) {
			map.removeOverlay(the_grid);
			grid = false;
			}
		else {
			the_grid = new LatLonGraticule();
			map.addOverlay(the_grid);
			grid = true;
			}
		}

	String.prototype.trim = function () {				// 9/14/08
		return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
		};

	String.prototype.parseDeg = function() {
		if (!isNaN(this)) return Number(this);								// signed decimal degrees without NSEW

		var degLL = this.replace(/^-/,'').replace(/[NSEW]/i,'');			// strip off any sign or compass dir'n
		var dms = degLL.split(/[^0-9.,]+/);									// split out separate d/m/s
		for (var i in dms) if (dms[i]=='') dms.splice(i,1);					// remove empty elements (see note below)
		switch (dms.length) {												// convert to decimal degrees...
			case 3:															// interpret 3-part result as d/m/s
				var deg = dms[0]/1 + dms[1]/60 + dms[2]/3600; break;
			case 2:															// interpret 2-part result as d/m
				var deg = dms[0]/1 + dms[1]/60; break;
			case 1:															// decimal or non-separated dddmmss
				if (/[NS]/i.test(this)) degLL = '0' + degLL;	// - normalise N/S to 3-digit degrees
				var deg = dms[0].slice(0,3)/1 + dms[0].slice(3,5)/60 + dms[0].slice(5)/3600; break;
			default: return NaN;
			}
		if (/^-/.test(this) || /[WS]/i.test(this)) deg = -deg; // take '-', west and south as -ve
		return deg;
		}
	Number.prototype.toRad = function() {  // convert degrees to radians
		return this * Math.PI / 180;
		}

	Number.prototype.toDeg = function() {  // convert radians to degrees (signed)
		return this * 180 / Math.PI;
		}
	Number.prototype.toBrng = function() {  // convert radians to degrees (as bearing: 0...360)
		return (this.toDeg()+360) % 360;
		}
	function brng(lat1, lon1, lat2, lon2) {
		lat1 = lat1.toRad(); lat2 = lat2.toRad();
		var dLon = (lon2-lon1).toRad();

		var y = Math.sin(dLon) * Math.cos(lat2);
		var x = Math.cos(lat1)*Math.sin(lat2) -
						Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);
		return Math.atan2(y, x).toBrng();
		}

	distCosineLaw = function(lat1, lon1, lat2, lon2) {
		var R = 6371; // earth's mean radius in km
		var d = Math.acos(Math.sin(lat1.toRad())*Math.sin(lat2.toRad()) +
				Math.cos(lat1.toRad())*Math.cos(lat2.toRad())*Math.cos((lon2-lon1).toRad())) * R;
		return d;
		}
    var km2feet = 3280.83;
	var thisMarker = false;

	var map;
	var icons=[];						// note globals	- 1/29/09
	icons[<?php 
    print $GLOBALS['SEVERITY_NORMAL'];
    ?>
] = "./our_icons/blue.png";		// normal
	icons[<?php 
    print $GLOBALS['SEVERITY_MEDIUM'];
    ?>
] = "./our_icons/green.png";	// green
	icons[<?php 
    print $GLOBALS['SEVERITY_HIGH'];
    ?>
] =  "./our_icons/red.png";		// red
	icons[<?php 
    print $GLOBALS['SEVERITY_HIGH'];
    ?>
+1] =  "./our_icons/white.png";	// white - not in use

	var baseIcon = new GIcon();
	baseIcon.shadow = "./markers/sm_shadow.png";

	baseIcon.iconSize = new GSize(20, 34);
	baseIcon.iconAnchor = new GPoint(9, 34);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);

	map = new GMap2($("map"));		// create the map
<?php 
    $maptype = get_variable('maptype');
    // 08/02/09
    switch ($maptype) {
        case "1":
            break;
        case "2":
            ?>
		map.setMapType(G_SATELLITE_MAP);<?php 
            break;
        case "3":
            ?>
		map.setMapType(G_PHYSICAL_MAP);<?php 
            break;
        case "4":
            ?>
		map.setMapType(G_HYBRID_MAP);<?php 
            break;
        default:
            print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />";
    }
    ?>
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GOverviewMapControl());				// 12/24/08
<?php 
    if (get_variable('terrain') == 1) {
        ?>
	map.addMapType(G_PHYSICAL_MAP);
<?php 
    }
    ?>
	map.setCenter(new GLatLng(<?php 
    print $lat;
    ?>
, <?php 
    print $lng;
    ?>
),11);
	var icon = new GIcon(baseIcon);
	icon.image = icons[<?php 
    print $row['severity'];
    ?>
];
	var point = new GLatLng(<?php 
    print $lat;
    ?>
, <?php 
    print $lng;
    ?>
);	// 1147
	map.addOverlay(new GMarker(point, icon));
	map.enableScrollWheelZoom();

// ====================================Add Active Responding Units to Map =========================================================================
	var icons=[];						// note globals	- 1/29/09
	icons[1] = "./our_icons/white.png";		// normal
	icons[2] = "./our_icons/black.png";	// green

	var baseIcon = new GIcon();
	baseIcon.shadow = "./markers/sm_shadow.png";

	baseIcon.iconSize = new GSize(20, 34);
	baseIcon.iconAnchor = new GPoint(9, 34);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);

	var unit_icon = new GIcon(baseIcon);
	unit_icon.image = icons[1];

function createMarker(unit_point, number) {
	var unit_marker = new GMarker(unit_point, unit_icon);
	// Show this markers index in the info window when it is clicked
	var html = number;
	GEvent.addListener(unit_marker, "click", function() {unit_marker.openInfoWindowHtml(html);});
	return unit_marker;
}


<?php 
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}assigns` WHERE ticket_id='{$id}'";
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    while ($row = mysql_fetch_array($result)) {
        $responder_id = $row['responder_id'];
        if ($row['clear'] == NULL) {
            $query_unit = "SELECT * FROM `{$GLOBALS['mysql_prefix']}responder` WHERE id='{$responder_id}'";
            $result_unit = mysql_query($query_unit) or do_error($query_unit, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
            while ($row_unit = mysql_fetch_array($result_unit)) {
                $unit_id = $row_unit['id'];
                $mobile = $row_unit['mobile'];
                if (my_is_float($row_unit['lat']) && my_is_float($row_unit['lng'])) {
                    if ($mobile == 1) {
                        echo "var unit_icon = new GIcon(baseIcon);\n";
                        echo "var unit_icon_url = \"./our_icons/gen_icon.php?blank=0&text=RU\";\n";
                        // 4/18/09
                        echo "unit_icon.image = unit_icon_url;\n";
                        echo "var unit_point = new GLatLng(" . $row_unit['lat'] . "," . $row_unit['lng'] . ");\n";
                        echo "var unit_marker = createMarker(unit_point, '" . addslashes($row_unit['name']) . "', unit_icon);\n";
                        echo "map.addOverlay(unit_marker);\n";
                        echo "\n";
                    } else {
                        echo "var unit_icon = new GIcon(baseIcon);\n";
                        echo "var unit_icon_url = \"./our_icons/gen_icon.php?blank=4&text=RU\";\n";
                        // 4/18/09
                        echo "unit_icon.image = unit_icon_url;\n";
                        echo "var unit_point = new GLatLng(" . $row_unit['lat'] . "," . $row_unit['lng'] . ");\n";
                        echo "var unit_marker = createMarker(unit_point, '" . addslashes($row_unit['name']) . "', unit_icon);\n";
                        echo "map.addOverlay(unit_marker);\n";
                        echo "\n";
                    }
                    // end if/else ($mobile)
                }
                // end ((my_is_float()) - responding units
            }
            // end outer if
        }
        // end inner while
    }
    //	end outer while
    // =====================================End of functions to show responding units========================================================================
    // ====================================Add Facilities to Map 8/1/09================================================
    ?>
	var icons=[];	
	var g=0;

	var fmarkers = [];

	var baseIcon = new GIcon();
	baseIcon.shadow = "./markers/sm_shadow.png";

	baseIcon.iconSize = new GSize(30, 30);
	baseIcon.iconAnchor = new GPoint(15, 30);
	baseIcon.infoWindowAnchor = new GPoint(9, 2);

	var fac_icon = new GIcon(baseIcon);
	fac_icon.image = icons[1];

function createfacMarker(fac_point, fac_name, id, fac_icon) {
	var fac_marker = new GMarker(fac_point, fac_icon);
	// Show this markers index in the info window when it is clicked
	var fac_html = fac_name;
	fmarkers[id] = fac_marker;
	GEvent.addListener(fac_marker, "click", function() {fac_marker.openInfoWindowHtml(fac_html);});
	return fac_marker;
}

<?php 
    $query_fac = "SELECT *,UNIX_TIMESTAMP(updated) AS updated, `{$GLOBALS['mysql_prefix']}facilities`.id AS fac_id, `{$GLOBALS['mysql_prefix']}facilities`.description AS facility_description, `{$GLOBALS['mysql_prefix']}fac_types`.name AS fac_type_name, `{$GLOBALS['mysql_prefix']}facilities`.name AS facility_name FROM `{$GLOBALS['mysql_prefix']}facilities` LEFT JOIN `{$GLOBALS['mysql_prefix']}fac_types` ON `{$GLOBALS['mysql_prefix']}facilities`.type = `{$GLOBALS['mysql_prefix']}fac_types`.id LEFT JOIN `{$GLOBALS['mysql_prefix']}fac_status` ON `{$GLOBALS['mysql_prefix']}facilities`.status_id = `{$GLOBALS['mysql_prefix']}fac_status`.id ORDER BY `{$GLOBALS['mysql_prefix']}facilities`.type ASC";
    $result_fac = mysql_query($query_fac) or do_error($query_fac, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    while ($row_fac = mysql_fetch_array($result_fac)) {
        $eols = array("\r\n", "\n", "\r");
        // all flavors of eol
        while ($row_fac = stripslashes_deep(mysql_fetch_array($result_fac))) {
            //
            $fac_name = $row_fac['facility_name'];
            //	10/8/09
            $fac_temp = explode("/", $fac_name);
            $fac_index = substr($fac_temp[count($fac_temp) - 1], -6, strlen($fac_temp[count($fac_temp) - 1]));
            // 3/19/11
            print "\t\tvar fac_sym = '{$fac_index}';\n";
            // for sidebar and icon 10/8/09
            $fac_id = $row_fac['id'];
            $fac_type = $row_fac['icon'];
            $f_disp_name = $row_fac['facility_name'];
            //	10/8/09
            $f_disp_temp = explode("/", $f_disp_name);
            $facility_display_name = $f_disp_temp[0];
            if (my_is_float($row_fac['lat']) && my_is_float($row_fac['lng'])) {
                $fac_tab_1 = "<TABLE CLASS='infowin'  width='{$iw_width}' >";
                $fac_tab_1 .= "<TR CLASS='even'><TD COLSPAN=2 ALIGN='center'><B>" . addslashes(shorten($facility_display_name, 48)) . "</B></TD></TR>";
                $fac_tab_1 .= "<TR CLASS='odd'><TD COLSPAN=2 ALIGN='center'><B>" . addslashes(shorten($row_fac['fac_type_name'], 48)) . "</B></TD></TR>";
                $fac_tab_1 .= "<TR CLASS='even'><TD ALIGN='right'>Description:&nbsp;</TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row_fac['facility_description'])) . "</TD></TR>";
                $fac_tab_1 .= "<TR CLASS='odd'><TD ALIGN='right'>Status:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row_fac['status_val']) . " </TD></TR>";
                $fac_tab_1 .= "<TR CLASS='even'><TD ALIGN='right'>Contact:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row_fac['contact_name']) . "&nbsp;&nbsp;&nbsp;Email: " . addslashes($row_fac['contact_email']) . "</TD></TR>";
                $fac_tab_1 .= "<TR CLASS='odd'><TD ALIGN='right'>Phone:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row_fac['contact_phone']) . " </TD></TR>";
                $fac_tab_1 .= "<TR CLASS='even'><TD ALIGN='right'>As of:&nbsp;</TD><TD ALIGN='left'>" . format_date($row_fac['updated']) . "</TD></TR>";
                $fac_tab_1 .= "</TABLE>";
                $fac_tab_2 = "<TABLE CLASS='infowin'  width='{$iw_width}' >";
                $fac_tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Security contact:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row_fac['security_contact']) . " </TD></TR>";
                $fac_tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Security email:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row_fac['security_email']) . " </TD></TR>";
                $fac_tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Security phone:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row_fac['security_phone']) . " </TD></TR>";
                $fac_tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Access rules:&nbsp;</TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row_fac['access_rules'])) . "</TD></TR>";
                $fac_tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Security reqs:&nbsp;</TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row_fac['security_reqs'])) . "</TD></TR>";
                $fac_tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Opening hours:&nbsp;</TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row_fac['opening_hours'])) . "</TD></TR>";
                $fac_tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Prim pager:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row_fac['pager_p']) . " </TD></TR>";
                $fac_tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Sec pager:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row_fac['pager_s']) . " </TD></TR>";
                $fac_tab_2 .= "</TABLE>";
                ?>
//			var fac_sym = (g+1).toString();
			var myfacinfoTabs = [
				new GInfoWindowTab("<?php 
                print nl2brr(addslashes(shorten($row_fac['facility_name'], 10)));
                ?>
", "<?php 
                print $fac_tab_1;
                ?>
"),
				new GInfoWindowTab("More ...", "<?php 
                print str_replace($eols, " ", $fac_tab_2);
                ?>
")
				];
			<?php 
                if ($row_fac['lat'] == 0.999999 && $row_fac['lng'] == 0.999999) {
                    // check for facilities entered in no maps mode 7/28/10
                    echo "var fac_icon = new GIcon(baseIcon);\n";
                    echo "var fac_type = {$fac_type};\n";
                    echo "var fac_icon_url = \"./our_icons/question1.png\";\n";
                    echo "fac_icon.image = fac_icon_url;\n";
                    echo "var fac_point = new GLatLng(" . get_variable('def_lat') . "," . get_variable('def_lng') . ");\n";
                    echo "var fac_marker = createfacMarker(fac_point, myfacinfoTabs, g, fac_icon);\n";
                    echo "map.addOverlay(fac_marker);\n";
                    echo "\n";
                } else {
                    echo "var fac_icon = new GIcon(baseIcon);\n";
                    echo "var fac_type = {$fac_type};\n";
                    ?>
		var origin = ((fac_sym.length)>3)? (fac_sym.length)-3: 0;						// pick low-order three chars 3/22/11
		var iconStr = fac_sym.substring(origin);
<?php 
                    echo "var fac_icon_url = \"./our_icons/gen_fac_icon.php?blank={$fac_type}&text=\" + (iconStr) + \"\";\n";
                    echo "fac_icon.image = fac_icon_url;\n";
                    echo "var fac_point = new GLatLng(" . $row_fac['lat'] . "," . $row_fac['lng'] . ");\n";
                    echo "var fac_marker = createfacMarker(fac_point, myfacinfoTabs, g, fac_icon);\n";
                    echo "map.addOverlay(fac_marker);\n";
                    echo "\n";
                }
            }
            // end if my_is_float - facilities
            ?>
		g++;
<?php 
        }
        // end while
    }
    // =====================================End of functions to show facilities========================================================================
    do_kml();
    // kml functions
    ?>
	function lat2ddm(inlat) {				// 9/7/08
		var x = new Number(inlat);
		var y  = (inlat>0)?  Math.floor(x):Math.round(x);
		var z = ((Math.abs(x-y)*60).toFixed(1));
		var nors = (inlat>0.0)? " N":" S";
		return Math.abs(y) + '\260 ' + z +"'" + nors;
		}

	function lng2ddm(inlng) {
		var x = new Number(inlng);
		var y  = (inlng>0)?  Math.floor(x):Math.round(x);
		var z = ((Math.abs(x-y)*60).toFixed(1));
		var eorw = (inlng>0.0)? " E":" W";
		return Math.abs(y) + '\260 ' + z +"'" + eorw;
		}


	function do_coords(inlat, inlng) {  //9/14/08
		if(inlat.toString().length==0) return;								// 10/15/08
		var str = inlat + ", " + inlng + "\n";
		str += ll2dms(inlat) + ", " +ll2dms(inlng) + "\n";
		str += lat2ddm(inlat) + ", " +lng2ddm(inlng);
		alert(str);
		}

	function ll2dms(inval) {				// lat/lng to degr, mins, sec's - 9/9/08
		var d = new Number(inval);
		d  = (inval>0)?  Math.floor(d):Math.round(d);
		var mi = (inval-d)*60;
		var m = Math.floor(mi)				// min's
		var si = (mi-m)*60;
		var s = si.toFixed(1);
		return d + '\260 ' + Math.abs(m) +"' " + Math.abs(s) + '"';
		}

	</SCRIPT>
<?php 
}
예제 #16
0
function _linklist_makeSelect($mode, $data, $default = '')
{
    global $member;
    $arr = array();
    $str = '';
    $arr_def = (array) $default;
    $size = '';
    $multiple = '';
    switch ($mode) {
        case 'bid[]':
            $size = 'size="3"';
            $multiple = 'multiple="multiple"';
            $arr =& $data;
            if (count($arr) < 2) {
                //set default
                $arr_def = array_keys($arr);
            }
            if (!$member->isAdmin() and count($arr_def) == 1 and empty($arr_def[0])) {
                $arr_def[0] = array_shift(array_keys($arr));
            }
            break;
        case 'gid':
        case 'sortkey':
            //alphabet (group)
            $arr =& $data;
            break;
        case 'blogselected':
            if ($data == 0 or !preg_match("/^[0-9,]+\$/", $data)) {
                //hidden
                $arr[0] = 'ALL';
            } else {
                //get blogname from ids
                $query = sprintf("SELECT bnumber, bname FROM %s " . "WHERE bnumber IN (%s) ORDER BY bnumber", sql_table('blog'), $data);
                $res = sql_query($query);
                while ($row = mysql_fetch_assoc($res)) {
                    $arr[$row['bnumber']] = shorten($row['bname'], 15, '..');
                }
            }
            break;
    }
    $str .= <<<OUT
<select name="{$mode}" {$size} {$multiple}>
OUT;
    foreach ($arr as $key => $val) {
        $selected = in_array($key, $arr_def) ? 'selected="selected"' : '';
        if ($mode == 'bid[]') {
            $val = "{$key}:{$val}";
        }
        $str .= <<<OUT
<option value="{$key}" {$selected}>{$val}</option>
OUT;
    }
    $str .= "</select>";
    return $str;
}
function list_facilities($addon = '', $start)
{
    //	global {$_SESSION['fip']}, $fmp, {$_SESSION['editfile']}, {$_SESSION['addfile']}, {$_SESSION['unitsfile']}, {$_SESSION['facilitiesfile']}, {$_SESSION['routesfile']}, {$_SESSION['facroutesfile']};
    global $iw_width, $u_types, $tolerance;
    //	$assigns = array();
    //	$tickets = array();
    $query = "SELECT `{$GLOBALS['mysql_prefix']}assigns`.`ticket_id`, `{$GLOBALS['mysql_prefix']}assigns`.`responder_id`, `{$GLOBALS['mysql_prefix']}ticket`.`scope` AS `ticket` FROM `{$GLOBALS['mysql_prefix']}assigns` LEFT JOIN `{$GLOBALS['mysql_prefix']}ticket` ON `{$GLOBALS['mysql_prefix']}assigns`.`ticket_id`=`{$GLOBALS['mysql_prefix']}ticket`.`id`";
    $result_as = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    while ($row_as = stripslashes_deep(mysql_fetch_assoc($result_as))) {
        $assigns[$row_as['responder_id']] = $row_as['ticket'];
        $tickets[$row_as['responder_id']] = $row_as['ticket_id'];
    }
    unset($result_as);
    $calls = array();
    $calls_nr = array();
    $calls_time = array();
    $query = "SELECT * , UNIX_TIMESTAMP(packet_date) AS `packet_date` FROM `{$GLOBALS['mysql_prefix']}tracks` ORDER BY `packet_date` ASC";
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__);
    while ($row = mysql_fetch_assoc($result)) {
        if (isset($calls[$row['source']])) {
            // array_key_exists ( mixed key, array search )
            $calls_nr[$row['source']]++;
        } else {
            array_push($calls, trim($row['source']));
            $calls[trim($row['source'])] = TRUE;
            $calls_nr[$row['source']] = 1;
        }
        $calls_time[$row['source']] = $row['packet_date'];
        // save latest - note query order
    }
    $query = "SELECT `id` FROM `{$GLOBALS['mysql_prefix']}facilities`";
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__);
    $facilities = mysql_affected_rows() > 0 ? mysql_affected_rows() : "<I>none</I>";
    unset($result);
    ?>

<SCRIPT >

var color=0;
	var colors = new Array ('odd', 'even');

	function hideDiv(div_area, hide_cont, show_cont) {	//	3/15/11
		if (div_area == "buttons_sh") {
			var controlarea = "hide_controls";
			}
		if (div_area == "resp_list_sh") {
			var controlarea = "resp_list";
			}
		if (div_area == "facs_list_sh") {
			var controlarea = "facs_list";
			}
		if (div_area == "incs_list_sh") {
			var controlarea = "incs_list";
			}
		if (div_area == "region_boxes") {
			var controlarea = "region_boxes";
			}			
		var divarea = div_area 
		var hide_cont = hide_cont 
		var show_cont = show_cont 
		if($(divarea)) {
			$(divarea).style.display = 'none';
			$(hide_cont).style.display = 'none';
			$(show_cont).style.display = '';
			} 
		var params = "f_n=" +controlarea+ "&v_n=h&sess_id=<?php 
    print get_sess_key(__LINE__);
    ?>
";
		var url = "persist2.php";
		sendRequest (url, gb_handleResult, params);			
		} 

	function showDiv(div_area, hide_cont, show_cont) {	//	3/15/11
		if (div_area == "buttons_sh") {
			var controlarea = "hide_controls";
			}
		if (div_area == "resp_list_sh") {
			var controlarea = "resp_list";
			}
		if (div_area == "facs_list_sh") {
			var controlarea = "facs_list";
			}
		if (div_area == "incs_list_sh") {
			var controlarea = "incs_list";
			}
		if (div_area == "region_boxes") {
			var controlarea = "region_boxes";
			}				
		var divarea = div_area
		var hide_cont = hide_cont 
		var show_cont = show_cont 
		if($(divarea)) {
			$(divarea).style.display = '';
			$(hide_cont).style.display = '';
			$(show_cont).style.display = 'none';
			}
		var params = "f_n=" +controlarea+ "&v_n=s&sess_id=<?php 
    print get_sess_key(__LINE__);
    ?>
";
		var url = "persist2.php";
		sendRequest (url, gb_handleResult, params);					
		} 	
	
	function hideGroup(color) {
		for (var i = 0; i < gmarkers.length; i++) {
			if (gmarkers[i]) {
				if (gmarkers[i].id == color) {
					gmarkers[i].show();
					}
				else {
					gmarkers[i].hide();
					}
				}		// end if (gmarkers[i])
			} 	// end for ()
		elem = $("allIcons");
		elem.style.visibility = "visible";
		}			// end function

	function showAll() {
		for (var i = 0; i < gmarkers.length; i++) {
			if (gmarkers[i]) {
				gmarkers[i].show();
				}
			} 	// end for ()
		elem = $("allIcons");
		elem.style.visibility = "hidden";

		}			// end function

	function checkArray(form, arrayName)	{	//	5/3/11
		var retval = new Array();
		for(var i=0; i < form.elements.length; i++) {
			var el = form.elements[i];
			if(el.type == "checkbox" && el.name == arrayName && el.checked) {
				retval.push(el.value);
			}
		}
	return retval;
	}		
		
	function checkForm(form)	{	//	6/10/11
		var errmsg="";
		var itemsChecked = checkArray(form, "frm_group[]");
		if(itemsChecked.length > 0) {
			var params = "f_n=viewed_groups&v_n=" +itemsChecked+ "&sess_id=<?php 
    print get_sess_key(__LINE__);
    ?>
";	//	3/15/11
			var url = "persist3.php";	//	3/15/11	
			sendRequest (url, fvg_handleResult, params);				
//			form.submit();
		} else {
			errmsg+= "\tYou cannot Hide all the regions\n";
			if (errmsg!="") {
				alert ("Please correct the following and re-submit:\n\n" + errmsg);
				return false;
			}
		}
	}
	
	function fvg_handleResult(req) {	// 6/10/11	The persist callback function for viewed groups.
		document.region_form.submit();
		}
		
	function form_validate(theForm) {	//	5/3/11
//		alert("Validating");
		checkForm(theForm);
		}				// end function validate(theForm)			

	function sendRequest(url,callback,postData) {								// 2/14/09
		var req = createXMLHTTPObject();
		if (!req) return;
		var method = (postData) ? "POST" : "GET";
		req.open(method,url,true);
		req.setRequestHeader('User-Agent','XMLHTTP/1.0');
		if (postData)
			req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		req.onreadystatechange = function () {
			if (req.readyState != 4) return;
			if (req.status != 200 && req.status != 304) {
				return;
				}
			callback(req);
			}
		if (req.readyState == 4) return;
		req.send(postData);
		}

	var XMLHttpFactories = [
		function () {return new XMLHttpRequest()	},
		function () {return new ActiveXObject("Msxml2.XMLHTTP")	},
		function () {return new ActiveXObject("Msxml3.XMLHTTP")	},
		function () {return new ActiveXObject("Microsoft.XMLHTTP")	}
		];

	function createXMLHTTPObject() {
		var xmlhttp = false;
		for (var i=0;i<XMLHttpFactories.length;i++) {
			try {
				xmlhttp = XMLHttpFactories[i]();
				}
			catch (e) {
				continue;
				}
			break;
			}
		return xmlhttp;
		}

	function createMarker(point, tabs, color, id, fac_id) {						// (point, myinfoTabs,<?php 
    print $row['type'];
    ?>
, i)
		points = true;													// at least one
//		var letter = to_str(id);
		var fac_id = fac_id;	
		
		var icon = new GIcon(listIcon);
		var icon_url = "./our_icons/gen_fac_icon.php?blank=" + escape(icons[color]) + "&text=" + fac_id;

		icon.image = icon_url;		// 

		var marker = new GMarker(point, icon);
		marker.id = color;				// for hide/unhide - unused

		GEvent.addListener(marker, "click", function() {		// here for both side bar and icon click
			if (marker) {
				map.closeInfoWindow();
				which = id;
				gmarkers[which].hide();
				marker.openInfoWindowTabsHtml(infoTabs[id]);

				setTimeout(function() {										// wait for rendering complete
					if ($("detailmap")) {
						var dMapDiv = $("detailmap");
						var detailmap = new GMap2(dMapDiv);
						detailmap.addControl(new GSmallMapControl());
						detailmap.setCenter(point, 17);  						// larger # = closer
						detailmap.addOverlay(marker);
						}
					else {
						}
					},4000);				// end setTimeout(...)

				}		// end if (marker)
			});			// end GEvent.add Listener()

		gmarkers[id] = marker;									// marker to array for side_bar click function
		infoTabs[id] = tabs;									// tabs to array
		if (!(map_is_fixed)) {
			bounds.extend(point);
			}
		return marker;
		}				// end function create Marker()

	function createdummyMarker(point, tabs, color, id, fac_id) {						// 7/28/10
		points = true;													// at least one
//		var letter = to_str(id);
		var fac_id = fac_id;	
		
		var icon = new GIcon(listIcon);
		var icon_url = "./our_icons/question1.png";

		icon.image = icon_url;		// 

		var dummymarker = new GMarker(point, icon);
		dummymarker.id = color;				// for hide/unhide - unused

		GEvent.addListener(dummymarker, "click", function() {		// here for both side bar and icon click
			if (dummymarker) {
				map.closeInfoWindow();
				which = id;
				gmarkers[which].hide();
				dummymarker.openInfoWindowTabsHtml(infoTabs[id]);

				setTimeout(function() {										// wait for rendering complete
					if ($("detailmap")) {
						var dMapDiv = $("detailmap");
						var detailmap = new GMap2(dMapDiv);
						detailmap.addControl(new GSmallMapControl());
						detailmap.setCenter(point, 17);  						// larger # = closer
						detailmap.addOverlay(dummymarker);
						}
					else {
						}
					},4000);				// end setTimeout(...)

				}		// end if (marker)
			});			// end GEvent.add Listener()

		gmarkers[id] = dummymarker;									// marker to array for side_bar click function
		infoTabs[id] = tabs;									// tabs to array
		if (!(map_is_fixed)) {
			bounds.extend(point);
			}
		return dummymarker;
		}				// end function createdummyMarker()		

	function do_sidebar (sidebar, id, the_class, fac_id) {
		var fac_id = fac_id;
		side_bar_html += "<TR CLASS='" + colors[(id)%2] +"'>";
		side_bar_html += "<TD CLASS='" + the_class + "' onClick = myclick(" + id + "); >" + fac_id + sidebar +"</TD></TR>\n";		// 3/15/11
		}

	function do_sidebar_nm (sidebar, line_no, id, fac_id) {	
		var fac_id = fac_id;	
		var letter = to_str(line_no);	
		side_bar_html += "<TR CLASS='" + colors[(line_no)%2] +"'>";
		side_bar_html += "<TD onClick = myclick_nm(" + id + "); >" + fac_id + sidebar +"</TD></TR>\n";		// 1/23/09, 10/29/09 removed period, 11/11/09, 3/15/11
		}

	function myclick_nm(v_id) {				// Responds to sidebar click - view responder data
		document.view_form.id.value=v_id;
		document.view_form.submit();
		}

	function myclick(id) {					// Responds to sidebar click, then triggers listener above -  note [id]
		GEvent.trigger(gmarkers[id], "click");
		location.href = '#top';		// 11/11/090
		}

	function do_lat (lat) {
		document.forms[0].frm_lat.value=lat.toFixed(6);
		}
	function do_lng (lng) {
		document.forms[0].frm_lng.value=lng.toFixed(6);
		}

	function do_ngs() {											// LL to USNG
		var loc = <?php 
    print get_variable('locale');
    ?>
;
		document.forms[0].frm_ngs.disabled=false;
		if(loc == 0) {
			document.forms[0].frm_ngs.value = LLtoUSNG(document.forms[0].frm_lat.value, document.forms[0].frm_lng.value, 5);
			}
		if(loc == 1) {
			document.forms[0].frm_ngs.value = LLtoOSGB(document.forms[0].frm_lat.value, document.forms[0].frm_lng.value);
			}
		if(loc == 2) {
			document.forms[0].frm_ngs.value = LLtoOSGB(document.forms[0].frm_lat.value, document.forms[0].frm_lng.value);
			}			
		document.forms[0].frm_ngs.disabled=true;
		}

	function do_sel_update_fac (in_unit, in_val) {							// 3/15/11
		to_server_fac(in_unit, in_val);
		}

	function to_server_fac(the_unit, the_status) {									// 3/15/11
		var querystr = "frm_responder_id=" + the_unit;
		querystr += "&frm_status_id=" + the_status;
	
		var url = "as_up_fac_status.php?" + querystr;			// 3/15/11
		var payload = syncAjax(url);						// 
		if (payload.substring(0,1)=="-") {	
			alert ("<?php 
    print __LINE__;
    ?>
: msg failed ");
			return false;
			}
		else {
			parent.frames['upper'].show_msg ('Facility status update applied!')
			return true;
			}				// end if/else (payload.substring(... )
		}		// end function to_server()

	var icons=new Array;							// maps type to icon blank

<?php 
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}fac_types` ORDER BY `id`";
    // types in use
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    $icons = $GLOBALS['fac_icons'];
    while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
        // map type to blank icon id
        $blank = $icons[$row['icon']];
        print "\ticons[" . $row['id'] . "] = " . $row['icon'] . ";\n";
        //
    }
    unset($result);
    $dzf = get_variable('def_zoom_fixed');
    print "\tvar map_is_fixed = ";
    print my_is_int($dzf) && $dzf == 2 || my_is_int($dzf) && $dzf == 3 ? "true;\n" : "false;\n";
    ?>
	var map;
	var side_bar_html = "<TABLE border=0 CLASS='sidebar' ID='tbl_facilities'>";
	side_bar_html += "<TR class='even'>	<TD><B>Icon</B></TD><TD><B>Handle</B></TD><TD ALIGN='left'><B>Name</B></TD><TD ALIGN='left'><B><?php 
    print get_text("Type");
    ?>
</B></TD><TD ALIGN='left'><B><?php 
    print get_text("Status");
    ?>
</B></TD><TD ALIGN='left'><B><?php 
    print get_text("As of");
    ?>
</B></TD></TR>";
	var gmarkers = [];
	var infoTabs = [];
	var which;
	var i = <?php 
    print $start;
    ?>
;					// sidebar/icon index
	var points = false;								// none

	map = new GMap2($("map"));						// create the map
<?php 
    $maptype = get_variable('maptype');
    switch ($maptype) {
        case "1":
            break;
        case "2":
            ?>
		map.setMapType(G_SATELLITE_MAP);<?php 
            break;
        case "3":
            ?>
		map.setMapType(G_PHYSICAL_MAP);<?php 
            break;
        case "4":
            ?>
		map.setMapType(G_HYBRID_MAP);<?php 
            break;
        default:
            print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />";
    }
    ?>

//	map.addControl(new GSmallMapControl());
	map.setUIToDefault();										// 8/13/10

	map.addControl(new GMapTypeControl());
<?php 
    if (get_variable('terrain') == 1) {
        ?>
	map.addMapType(G_PHYSICAL_MAP);
<?php 
    }
    ?>

	map.setCenter(new GLatLng(<?php 
    echo get_variable('def_lat');
    ?>
, <?php 
    echo get_variable('def_lng');
    ?>
), <?php 
    echo get_variable('def_zoom');
    ?>
);
	mapBounds=new GLatLngBounds(map.getBounds().getSouthWest(), map.getBounds().getNorthEast());

	var bounds = new GLatLngBounds();						// create  bounding box
	map.enableScrollWheelZoom();

	do_landb();				// 8/1/11 - show scribbles		
	
	var listIcon = new GIcon();
	listIcon.image = "./markers/yellow.png";	// yellow.png - 16 X 28
	listIcon.shadow = "./markers/sm_shadow.png";
	listIcon.iconSize = new GSize(30, 30);
	listIcon.shadowSize = new GSize(16, 28);
	listIcon.iconAnchor = new GPoint(8, 28);
	listIcon.infoWindowAnchor = new GPoint(9, 2);
	listIcon.infoShadowAnchor = new GPoint(18, 25);

	GEvent.addListener(map, "infowindowclose", function() {		// re-center after  move/zoom
		map.addOverlay(gmarkers[which])
		});

//-----------------------BOUNDARIES STUFF--------------------6/10/11

	var thepoint;
	var points = new Array();
	var boundary = new Array();	
	var bound_names = new Array();
	
	GEvent.addListener(map, "click", function(overlay,boundpoint) {
	for (var n = 0; n < boundary.length; n++) {
		if (boundary[n].Contains(boundpoint)) {
			map.openInfoWindowHtml(boundpoint,"This is " + bound_names[n]);
			}
		}
	});	
<?php 
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}allocates` WHERE `type`= 4 AND `resource_id` = '{$_SESSION['user_id']}' ORDER BY `id` ASC;";
    //	6/10/11
    $result = mysql_query($query);
    //	6/10/11
    $a_gp_bounds = array();
    $gp_bounds = array();
    while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
        //	6/10/11
        $al_groups[] = $row['group'];
        $query2 = "SELECT * FROM `{$GLOBALS['mysql_prefix']}region` WHERE `id`= '{$row['group']}';";
        //	6/10/11
        $result2 = mysql_query($query2);
        // 4/18/11
        while ($row2 = stripslashes_deep(mysql_fetch_assoc($result2))) {
            //	//	6/10/11
            if ($row2['boundary'] != 0) {
                $a_gp_bounds[] = $row2['boundary'];
            }
        }
    }
    if (isset($_SESSION['viewed_groups'])) {
        //	6/10/11
        foreach (explode(",", $_SESSION['viewed_groups']) as $val_vg) {
            $query3 = "SELECT * FROM `{$GLOBALS['mysql_prefix']}region` WHERE `id`= '{$val_vg}';";
            $result3 = mysql_query($query3);
            //	6/10/11
            while ($row3 = stripslashes_deep(mysql_fetch_assoc($result3))) {
                if ($row3['boundary'] != 0) {
                    $gp_bounds[] = $row3['boundary'];
                }
            }
        }
    } else {
        $gp_bounds = $a_gp_bounds;
    }
    foreach ($gp_bounds as $value) {
        //	6/10/11
        ?>
		var points = new Array();
<?php 
        if ($value != 0) {
            $query_bn = "SELECT * FROM `{$GLOBALS['mysql_prefix']}mmarkup` WHERE `id`='{$value}' AND `use_with_f`=1";
            //			print $query_bn;
            $result_bn = mysql_query($query_bn) or do_error($query_bn, mysql_error(), basename(__FILE__), __LINE__);
            while ($row_bn = stripslashes_deep(mysql_fetch_assoc($result_bn))) {
                extract($row_bn);
                $bn_name = $row_bn['line_name'];
                $points = explode(";", $line_data);
                for ($xx = 0; $xx < count($points); $xx++) {
                    $coords = explode(",", $points[$xx]);
                    ?>
					thepoint = new GLatLng(parseFloat(<?php 
                    print $coords[0];
                    ?>
), parseFloat(<?php 
                    print $coords[1];
                    ?>
));
					points.push(thepoint);
<?php 
                }
                // end for ($i = 0 ... )
                ?>

<?php 
                switch ($row_bn['line_type']) {
                    case "p":
                        // poly
                        if (intval($filled) == 1) {
                            //	6/10/11
                            ?>
						var polyline = new GPolygon(points, "<?php 
                            print $line_color;
                            ?>
", <?php 
                            print $line_width;
                            ?>
, <?php 
                            print $line_opacity;
                            ?>
, "<?php 
                            print $fill_color;
                            ?>
", <?php 
                            print $fill_opacity;
                            ?>
, {clickable:false});
						boundary.push(polyline);
						bound_names.push("<?php 
                            print $bn_name;
                            ?>
"); 			
						<?php 
                        } else {
                            ?>
						var polyline = new GPolyline(points, "<?php 
                            print $line_color;
                            ?>
", <?php 
                            print $line_width;
                            ?>
, <?php 
                            print $line_opacity;
                            ?>
, , 0, {clickable:false});
						boundary.push(polyline);
						bound_names.push("<?php 
                            print $bn_name;
                            ?>
"); 			
<?php 
                        }
                        ?>
	
					map.addOverlay(polyline);
<?php 
                        break;
                    case "c":
                        $temp = explode(";", $line_data);
                        $radius = $temp[1];
                        $coords = explode(",", $temp[0]);
                        $lat = $coords[0];
                        $lng = $coords[1];
                        $fill_opacity = intval($filled) == 0 ? 0 : $fill_opacity;
                        echo "\n drawCircle({$lat}, {$lng}, {$radius}, add_hash('{$line_color}'), {$line_opacity}, {$line_width}, add_hash('{$fill_color}'), {$fill_opacity}); // 513\n";
                        break;
                }
            }
            //	End while
        }
        //	end if $value !=0
    }
    //	end foreach $gp_bounds
    //-------------------------END OF BOUNDARIES STUFF-------------------------
    $eols = array("\r\n", "\n", "\r");
    // all flavors of eol
    $status_vals = array();
    // build array of $status_vals
    $status_vals[''] = $status_vals['0'] = "TBD";
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}fac_status` ORDER BY `id`";
    $result_st = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    while ($row_st = stripslashes_deep(mysql_fetch_assoc($result_st))) {
        $temp = $row_st['id'];
        $status_vals[$temp] = $row_st['status_val'];
    }
    unset($result_st);
    $type_vals = array();
    // build array of $status_vals
    $type_vals[''] = $type_vals['0'] = "TBD";
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}fac_types` ORDER BY `id`";
    $result_ty = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    while ($row_ty = stripslashes_deep(mysql_fetch_assoc($result_ty))) {
        $temp = $row_ty['id'];
        $type_vals[$temp] = $row_ty['name'];
    }
    unset($result_ty);
    $query = "SELECT * FROM `{$GLOBALS['mysql_prefix']}allocates` WHERE `type`= 4 AND `resource_id` = '{$_SESSION['user_id']}';";
    // 6/10/11
    $result = mysql_query($query);
    // 6/10/11
    $al_groups = array();
    while ($row_gp = stripslashes_deep(mysql_fetch_assoc($result))) {
        // 6/10/11
        $al_groups[] = $row_gp['group'];
    }
    if (isset($_SESSION['viewed_groups'])) {
        //	6/10/11
        $curr_viewed = explode(",", $_SESSION['viewed_groups']);
    }
    if (!isset($curr_viewed)) {
        $x = 0;
        //	6/10/11
        $where2 = "WHERE (";
        //	6/10/11
        foreach ($al_groups as $grp) {
            //	6/10/11
            $where3 = count($al_groups) > $x + 1 ? " OR " : ")";
            $where2 .= "`a`.`group` = '{$grp}'";
            $where2 .= $where3;
            $x++;
        }
    } else {
        $x = 0;
        //	6/10/11
        $where2 = "WHERE (";
        //	6/10/11
        foreach ($curr_viewed as $grp) {
            //	6/10/11
            $where3 = count($curr_viewed) > $x + 1 ? " OR " : ")";
            $where2 .= "`a`.`group` = '{$grp}'";
            $where2 .= $where3;
            $x++;
        }
    }
    $where2 .= "AND `a`.`type` = 3";
    //	6/10/11
    unset($result);
    //	3/15/11, 6/10/11
    $query = "SELECT *,UNIX_TIMESTAMP(updated) AS updated, \n\t\t`f`.id AS id, \n\t\t`f`.status_id AS status_id,\n\t\t`f`.boundary AS boundary,\t\t\n\t\t`f`.description AS facility_description,\n\t\t`t`.name AS fac_type_name, \n\t\t`f`.name AS name,\n\t\t`f`.type AS type,\n\t\t`f`.street AS street,\n\t\t`f`.city AS city,\n\t\t`f`.state AS state \n\t\tFROM `{$GLOBALS['mysql_prefix']}facilities`  `f`\n\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}allocates` `a` ON ( `f`.`id` = a.resource_id )\t\t\t\n\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}fac_types` `t` ON `f`.type = `t`.id \n\t\tLEFT JOIN `{$GLOBALS['mysql_prefix']}fac_status` `s` ON `f`.status_id = `s`.id \n\t\t{$where2} GROUP BY `f`.id ORDER BY `f`.type ASC";
    $result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
    $num_facilities = mysql_affected_rows();
    $i = 0;
    // counter
    // =============================================================================
    $utc = gmdate("U");
    while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
        // ==========  major while() for Facility ==========
        $boundary = $row['boundary'];
        //-----------------------FACILITY BOUNDARIES / CATCHMENT STUFF--------------------6/10/11
        ?>
	var thepoint;
	var points = new Array();
<?php 
        $query_bn = "SELECT * FROM `{$GLOBALS['mysql_prefix']}mmarkup` WHERE `id`='{$boundary}' AND `use_with_f`=1";
        $result_bn = mysql_query($query_bn) or do_error($query_bn, mysql_error(), basename(__FILE__), __LINE__);
        while ($row_bn = stripslashes_deep(mysql_fetch_assoc($result_bn))) {
            $the_type = $row_bn['line_type'];
            switch ($the_type) {
                case "p":
                    extract($row_bn);
                    $bn_name = $row_bn['line_name'];
                    $points = explode(";", $line_data);
                    for ($i = 0; $i < count($points); $i++) {
                        $coords = explode(",", $points[$i]);
                        ?>
					thepoint = new GLatLng(parseFloat(<?php 
                        print $coords[0];
                        ?>
), parseFloat(<?php 
                        print $coords[1];
                        ?>
));
					points.push(thepoint);
<?php 
                    }
                    // end for ($i = 0 ... )
                    if (intval($filled) == 1) {
                        //	6/10/11
                        ?>
					var polyline = new GPolygon(points, "<?php 
                        print $line_color;
                        ?>
", <?php 
                        print $line_width;
                        ?>
, <?php 
                        print $line_opacity;
                        ?>
, "<?php 
                        print $fill_color;
                        ?>
", <?php 
                        print $fill_opacity;
                        ?>
, {clickable:false});
					boundary.push(polyline);
					bound_names.push("<?php 
                        print $bn_name;
                        ?>
"); 			
<?php 
                    } else {
                        ?>
					var polyline = new GPolyline(points, "<?php 
                        print $line_color;
                        ?>
", <?php 
                        print $line_width;
                        ?>
, <?php 
                        print $line_opacity;
                        ?>
, , 0, {clickable:false});
					boundary.push(polyline);
					bound_names.push("<?php 
                        print $bn_name;
                        ?>
"); 			
<?php 
                    }
                    ?>
					map.addOverlay(polyline);
<?php 
                    break;
                case "c":
                    extract($row_bn);
                    $temp = explode(";", $line_data);
                    $radius = $temp[1];
                    $coords = explode(",", $temp[0]);
                    $lat = $coords[0];
                    $lng = $coords[1];
                    $fill_opacity = intval($filled) == 0 ? 0 : $fill_opacity;
                    echo "\n drawCircle({$lat}, {$lng}, {$radius}, add_hash('{$line_color}'), {$line_opacity}, {$line_width}, add_hash('{$fill_color}'), {$fill_opacity}); // 513\n";
                    break;
            }
            // end switch
        }
        //	End while
        //-------------------------END OF FACILITY BOUNDARIES STUFF-------------------------
        $fac_gps = get_allocates(3, $row['id']);
        //	6/10/11
        $grp_names = "Groups Assigned: ";
        //	6/10/11
        $y = 0;
        //	6/10/11
        foreach ($fac_gps as $value) {
            //	6/10/11
            $counter = count($fac_gps) > $y + 1 ? ", " : "";
            $grp_names .= get_groupname($value);
            $grp_names .= $counter;
            $y++;
        }
        $grp_names .= " / ";
        $the_bg_color = $GLOBALS['FACY_TYPES_BG'][$row['icon']];
        // 2/8/10
        $the_text_color = $GLOBALS['FACY_TYPES_TEXT'][$row['icon']];
        // 2/8/10
        $the_on_click = my_is_float($row['lat']) ? " onClick = myclick({$i}); " : " onClick = myclick_nm({$row['unit_id']}); ";
        //	3/15/11
        $got_point = FALSE;
        print "\n\t\tvar i={$i};\n";
        if (is_guest()) {
            $toedit = $tomail = $toroute = "";
        } else {
            $toedit = "&nbsp;&nbsp;&nbsp;&nbsp;<A HREF='{$_SESSION['facilitiesfile']}?func=responder&edit=true&id=" . $row['id'] . "'><U>Edit</U></A>";
            $tomail = "&nbsp;&nbsp;&nbsp;&nbsp;<SPAN onClick = 'do_mail_in_win({$row['id']})'><U><B>Email</B></U></SPAN>";
            $toroute = "&nbsp;<A HREF='{$_SESSION['facroutesfile']}?fac_id=" . $row['id'] . "'><U>Route To Facility</U></A>";
        }
        $temp = $row['status_id'];
        $the_status = array_key_exists($temp, $status_vals) ? $status_vals[$temp] : "??";
        $temp_type = $row['type'];
        $the_type = array_key_exists($temp_type, $type_vals) ? $type_vals[$temp_type] : "??";
        if (!$got_point && my_is_float($row['lat'])) {
            if ($row['lat'] == 0.999999 && $row['lng'] == 0.999999) {
                echo "\t\tvar point = new GLatLng(" . get_variable('def_lat') . ", " . get_variable('def_lng') . ");\n";
            } else {
                echo "\t\tvar point = new GLatLng(" . $row['lat'] . ", " . $row['lng'] . ");\n";
            }
            $got_point = TRUE;
        }
        $update_error = strtotime('now - 6 hours');
        // set the time for silent setting
        $index = $row['icon_str'];
        // name
        $display_name = $name = htmlentities($row['name'], ENT_QUOTES);
        $handle = htmlentities($row['handle'], ENT_QUOTES);
        // 7/7/11
        $sidebar_line = "&nbsp;&nbsp;<TD WIDTH='15%' TITLE = '{$row['handle']}' {$the_on_click}><U><SPAN STYLE='background-color:{$the_bg_color};  opacity: .7; color:{$the_text_color};'>" . addslashes(shorten($handle, 15)) . "</SPAN></U></TD>";
        //	6/10/11
        $sidebar_line .= "<TD WIDTH='40%' TITLE = '" . addslashes($name) . "' {$the_on_click}><U><SPAN STYLE='background-color:{$the_bg_color};  opacity: .7; color:{$the_text_color};'><NOBR>" . addslashes(shorten($name, 24)) . "</NOBR></SPAN></U></TD><TD WIDTH='15%'>{$the_type}</TD>";
        $sidebar_line .= "<TD WIDTH='20%' CLASS='td_data' TITLE = '" . addslashes($the_status) . "'> " . get_status_sel($row['id'], $row['status_id'], 'f') . "</TD>";
        //	3/15/11
        // as of
        $strike = $strike_end = "";
        $the_time = $row['updated'];
        $the_class = "";
        $strike = $strike_end = "";
        $sidebar_line .= "<TD WIDTH='20%' CLASS='{$the_class}'> {$strike} <NOBR>" . format_sb_date($the_time) . "</NOBR> {$strike_end}</TD>";
        // tab 1
        if (my_is_float($row['lat'])) {
            // position data?
            $temptype = $u_types[$row['type']];
            $the_type = $temptype[0];
            $tab_1 = "<TABLE CLASS='infowin' width='{$iw_width}'>";
            $tab_1 .= "<TR CLASS='even'><TD COLSPAN=2 ALIGN='center'><B>" . addslashes(shorten($display_name, 48)) . "</B> - " . $the_type . "</TD></TR>";
            $tab_1 .= "<TR CLASS='odd'><TD ALIGN='right'>Description:&nbsp;</TD><TD ALIGN='left'>" . addslashes(shorten(str_replace($eols, " ", $row['description']), 32)) . "</TD></TR>";
            $tab_1 .= "<TR CLASS='even'><TD ALIGN='right'>Status:&nbsp;</TD><TD ALIGN='left'>" . $the_status . " </TD></TR>";
            $tab_1 .= "<TR CLASS='odd'><TD ALIGN='right'>Contact:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row['contact_name']) . " Via: " . addslashes($row['contact_email']) . "</TD></TR>";
            $tab_1 .= "<TR CLASS='even'><TD ALIGN='right'>As of:&nbsp;</TD><TD ALIGN='left'>" . format_date($row['updated']) . "</TD></TR>";
            $tab_1 .= "<TR CLASS='odd'><TD COLSPAN=2 ALIGN='center'>" . $toedit . $tomail . "&nbsp;&nbsp;<A HREF='{$_SESSION['facilitiesfile']}?func=responder&view=true&id=" . $row['id'] . "'><U>View</U></A></TD></TR>";
            // 08/8/02
            $tab_1 .= "</TABLE>";
            $tab_2 = "<TABLE CLASS='infowin' width='{$iw_width}' ALIGN = 'center' >";
            $tab_2 .= "<TR CLASS='odd'><TD ALIGN='right' STYLE= 'width:50%'>Security contact:&nbsp;</TD><TD ALIGN='left' STYLE= 'width:50%'>" . addslashes($row['security_contact']) . " </TD></TR>";
            $tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Security email:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row['security_email']) . " </TD></TR>";
            $tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Security phone:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row['security_phone']) . " </TD></TR>";
            $tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>" . get_text("Access rules") . ":&nbsp;</TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row['access_rules'])) . "</TD></TR>";
            $tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Security reqs:&nbsp;</TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row['security_reqs'])) . "</TD></TR>";
            $tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Opening hours:&nbsp;</TD><TD ALIGN='left'>" . addslashes(str_replace($eols, " ", $row['opening_hours'])) . "</TD></TR>";
            $tab_2 .= "<TR CLASS='odd'><TD ALIGN='right'>Prim pager:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row['pager_p']) . " </TD></TR>";
            $tab_2 .= "<TR CLASS='even'><TD ALIGN='right'>Sec pager:&nbsp;</TD><TD ALIGN='left'>" . addslashes($row['pager_s']) . " </TD></TR>";
            $tab_2 .= "</TABLE>";
            // tab 2
            $tabs_done = FALSE;
            // default
            if (!$tabs_done) {
                //
                ?>
			var myinfoTabs = [
				new GInfoWindowTab("<?php 
                print nl2brr(addslashes(shorten($row['name'], 10)));
                ?>
", "<?php 
                print $tab_1;
                ?>
"),
				new GInfoWindowTab("More ...", "<?php 
                print str_replace($eols, " ", $tab_2);
                ?>
"),
				new GInfoWindowTab("Zoom", "<div id='detailmap' class='detailmap'></div>")
				];

<?php 
            }
            // end if/else
            $name = $row['name'];
            // 10/8/09		 4/28/11
            if ($row['lat'] == 0.999999 && $row['lng'] == 0.999999) {
                // check for facilities added in no mpas mode 7/28/10
                ?>
		var fac_id = "<?php 
                print $index;
                ?>
";	//	10/8/09
		var the_class = ((map_is_fixed) && (!(mapBounds.containsLatLng(point))))? "emph" : "td_label";

		do_sidebar ("<?php 
                print $sidebar_line;
                ?>
", i, the_class, fac_id);
		var dummymarker = createdummyMarker(point, myinfoTabs,<?php 
                print $row['type'];
                ?>
, i, fac_id);	// 771 (point,tabs, color, id)
		map.addOverlay(dummymarker);
<?php 
            } else {
                ?>
		var fac_id = "<?php 
                print $index;
                ?>
";	//	10/8/09
		var the_class = ((map_is_fixed) && (!(mapBounds.containsLatLng(point))))? "emph" : "td_label";

		do_sidebar ("<?php 
                print $sidebar_line;
                ?>
", i, the_class, fac_id);
		var marker = createMarker(point, myinfoTabs,<?php 
                print $row['type'];
                ?>
, i, fac_id);	// 771 (point,tabs, color, id)
		map.addOverlay(marker);
<?php 
            }
            // End of check for facilities added in no maps mode 7/28/10
        } else {
            // end position data available
            $name = $row['name'];
            // 11/11/09
            $temp = explode("/", $name);
            $index = substr($temp[count($temp) - 1], -6, strlen($temp[count($temp) - 1]));
            // 3/19/11
            ?>
			var fac_id = "<?php 
            print $index;
            ?>
";	//	11/11/09
<?php 
            print "\tdo_sidebar_nm (\" {$sidebar_line} \" , i, {$row['id']}, fac_id);\n";
            // sidebar only - no map
        }
        $i++;
        // zero-based
    }
    // end  ==========  while() for Facility ==========
    ?>
	if (!(map_is_fixed)) {
		if (!points) {		// any?
			map.setCenter(new GLatLng(<?php 
    echo get_variable('def_lat');
    ?>
, <?php 
    echo get_variable('def_lng');
    ?>
), <?php 
    echo get_variable('def_zoom');
    ?>
);
			}
		else {
			center = bounds.getCenter();
			zoom = map.getBoundsZoomLevel(bounds);
			map.setCenter(center,zoom);
			}
		}

var buttons_html = "";
<?php 
    if (!empty($addon)) {
        print "\n\tbuttons_html +=\"" . $addon . "\"\n";
    }
    ?>
	side_bar_html +="</TABLE>\n";
	$("side_bar").innerHTML += side_bar_html;	// append the assembled side_bar_html contents to the side_bar div
	$("buttons").innerHTML = buttons_html;	// append the assembled side_bar_html contents to the side_bar div
	$("num_facilities").innerHTML = <?php 
    print $num_facilities;
    ?>
;

<?php 
    do_kml();
    ?>


</SCRIPT>
<?php 
}
예제 #18
0
function tpl_content()
{
    global $page, $webimroot, $errors;
    ?>

<?php 
    echo getlocal("page.notifications.intro");
    ?>
<br />
<br />
<?php 
    require_once 'inc_errors.php';
    ?>

<form name="notifyFilterForm" method="get" action="<?php 
    echo $webimroot;
    ?>
/operator/notifications.php">
	
	<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">

	<div class="packedFormField">
		<?php 
    echo getlocal("notifications.kind");
    ?>
<br/>
		<select name="kind" onchange="this.form.submit();"><?php 
    foreach ($page['allkinds'] as $k) {
        echo "<option value=\"" . $k . "\"" . ($k == form_value("kind") ? " selected=\"selected\"" : "") . ">" . getlocal("notifications.kind." . ($k ? $k : "all")) . "</option>";
    }
    ?>
</select>
	</div>

	<div class="packedFormField">
		<?php 
    echo getlocal("notifications.locale");
    ?>
<br/>
		<select name="lang" onchange="this.form.submit();"><?php 
    foreach ($page['locales'] as $k) {
        echo "<option value=\"" . $k["id"] . "\"" . ($k["id"] == form_value("lang") ? " selected=\"selected\"" : "") . ">" . $k["name"] . "</option>";
    }
    ?>
</select>
	</div>
	
	<br clear="all"/>
	
	</div><div class="formbottom"><div class="formbottomi"></div></div></div>
</form>
<br/>

<?php 
    if ($page['pagination']) {
        ?>

<table class="list">
<thead>
<tr class="header">
<th>
	<?php 
        echo getlocal("notifications.head.to");
        ?>
</th><th>
	<?php 
        echo getlocal("notifications.head.subj");
        ?>
</th><th>
	<?php 
        echo getlocal("notifications.head.msg");
        ?>
</th><th>
	<?php 
        echo getlocal("notifications.head.time");
        ?>
</th>
</tr>
</thead>
<tbody>
<?php 
        if ($page['pagination.items']) {
            foreach ($page['pagination.items'] as $b) {
                ?>
	<tr>
	<td class="notlast">
		<a href="<?php 
                echo $webimroot;
                ?>
/operator/notification.php?id=<?php 
                echo $b['id'];
                ?>
" target="_blank" onclick="this.newWindow = window.open('<?php 
                echo $webimroot;
                ?>
/operator/notification.php?id=<?php 
                echo $b['id'];
                ?>
', '', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=720,height=520,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;" class="<?php 
                echo $b['vckind'] == 'xmpp' ? 'xmpp' : 'mail';
                ?>
">
   			<?php 
                echo htmlspecialchars(shorten(topage($b['vcto']), 30));
                ?>
   		</a>
	</td>
	<td class="notlast">
		<?php 
                echo htmlspecialchars(shorten(topage($b['vcsubject']), 30));
                ?>
	</td>
	<td class="notlast">
		<?php 
                echo htmlspecialchars(shorten(topage($b['tmessage']), 30));
                ?>
	</td>
	<td>
   		<?php 
                echo date_to_text($b['created']);
                ?>
	</td>
	</tr>
<?php 
            }
        } else {
            ?>
	<tr>
	<td colspan="4">
		<?php 
            echo getlocal("tag.pagination.no_items.elements");
            ?>
	</td>
	</tr>
<?php 
        }
        ?>
</tbody>
</table>
<?php 
        if ($page['pagination.items']) {
            echo "<br/>";
            echo generate_pagination($page['pagination']);
        }
    }
    ?>

<?php 
}
예제 #19
0
/**
 * Run a search and display the result
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function html_search()
{
    global $conf;
    global $QUERY;
    global $ID;
    global $lang;
    $intro = p_locale_xhtml('searchpage');
    // allow use of placeholder in search intro
    $intro = str_replace(array('@QUERY@', '@SEARCH@'), array(hsc(rawurlencode($QUERY)), hsc($QUERY)), $intro);
    echo $intro;
    flush();
    //show progressbar
    print '<div class="centeralign" id="dw__loading">' . NL;
    print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . NL;
    print 'showLoadBar();' . NL;
    print '//--><!]]></script>' . NL;
    print '<br /></div>' . NL;
    flush();
    //do quick pagesearch
    $data = array();
    $data = ft_pageLookup($QUERY, true, useHeading('navigation'));
    if (count($data)) {
        print '<div class="search_quickresult">';
        print '<h3>' . $lang['quickhits'] . ':</h3>';
        print '<ul class="search_quickhits">';
        foreach ($data as $id => $title) {
            print '<li> ';
            if (useHeading('navigation')) {
                $name = $title;
            } else {
                $ns = getNS($id);
                if ($ns) {
                    $name = shorten(noNS($id), ' (' . $ns . ')', 30);
                } else {
                    $name = $id;
                }
            }
            print html_wikilink(':' . $id, $name);
            print '</li> ';
        }
        print '</ul> ';
        //clear float (see http://www.complexspiral.com/publications/containing-floats/)
        print '<div class="clearer"></div>';
        print '</div>';
    }
    flush();
    //do fulltext search
    $data = ft_pageSearch($QUERY, $regex);
    if (count($data)) {
        $num = 1;
        foreach ($data as $id => $cnt) {
            print '<div class="search_result">';
            print html_wikilink(':' . $id, useHeading('navigation') ? null : $id, $regex);
            if ($cnt !== 0) {
                print ': <span class="search_cnt">' . $cnt . ' ' . $lang['hits'] . '</span><br />';
                if ($num < FT_SNIPPET_NUMBER) {
                    // create snippets for the first number of matches only
                    print '<div class="search_snippet">' . ft_snippet($id, $regex) . '</div>';
                }
                $num++;
            }
            print '</div>';
            flush();
        }
    } else {
        print '<div class="nothing">' . $lang['nothingfound'] . '</div>';
    }
    //hide progressbar
    print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . NL;
    print 'hideLoadBar("dw__loading");' . NL;
    print '//--><!]]></script>' . NL;
    flush();
}
예제 #20
0
function shifts_printable($shifts, $shifttypes)
{
    global $rooms_import;
    $rooms = array_flip($rooms_import);
    uasort($shifts, 'shift_sort');
    $shifts_printable = array();
    foreach ($shifts as $shift) {
        $shifts_printable[] = array('day' => date("l, Y-m-d", $shift['start']), 'start' => date("H:i", $shift['start']), 'shifttype' => ShiftType_name_render(['id' => $shift['shifttype_id'], 'name' => $shifttypes[$shift['shifttype_id']]]), 'title' => shorten($shift['title']), 'end' => date("H:i", $shift['end']), 'room' => $rooms[$shift['RID']]);
    }
    return $shifts_printable;
}
예제 #21
0
파일: Entity.php 프로젝트: sensiblemn/Known
 /**
  * Sets the short URL for this entity.
  * @return string
  */
 function setShortURL()
 {
     function shorten($id, $alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
     {
         $base = strlen($alphabet);
         $short = '';
         while ($id) {
             $id = ($id - ($r = $id % $base)) / $base;
             $short = $alphabet[$r] . $short;
         }
         return $short;
     }
     $seed = rand(0, 99999999);
     $code = shorten($seed);
     while ($entity = static::getByShortURL($code)) {
         $code = shorten(rand(0, 99999999));
     }
     $this->shorturl = $code;
     $this->save();
     return $this->shorturl;
 }
                    $result = mysql_query($query) or do_error($query, 'mysql_query() failed', mysql_error(), basename(__FILE__), __LINE__);
                    if (mysql_num_rows($result) == 99991) {
                        $row = stripslashes_deep(mysql_fetch_assoc($result));
                        // proceed directly to edit
                        ?>
<SCRIPT>
document.list_form.id.value = <?php 
                        echo $row['id'];
                        document . list_form . submit();
                    }
                    // end if (mysql_num_rows($result)==1)
                    $i = 0;
                    echo "\n<CENTER><TABLE BORDER=0 STYLE = 'margin-top:50px;'>\n";
                    echo "\n<TR CLASS = 'even'><TD COLSPAN=99 ALIGN='center'><H3>{$patient} records - click line to edit</H3></TD></TR>\n";
                    while ($row = stripslashes_deep(mysql_fetch_array($result))) {
                        echo "<TR CLASS='" . $evenodd[($i + 1) % 2] . "' VALIGN='baseline' onClick = \"to_edit({$row['pat_id']})\">\n\t\t\t\t\t<TD>{$row['name']}</TD>\n\t\t\t\t\t<TD>" . shorten($row['fullname'], 24) . "</TD>\n\t\t\t\t\t<TD>{$row['ins_value']}</TD>\n\t\t\t\t\t<TD>" . shorten($row['description'], 24) . "</TD>\n\t\t\t\t\t</TR>\n";
                        $i++;
                    }
                    echo "\n</TABLE>\n";
                    ?>
	<INPUT TYPE = "button" VALUE = "Cancel" onClick = "window.close();" STYLE = "margin-top:12px;">
	<INPUT TYPE = "button" VALUE = "Add" onClick = "document.list_form.action.value='new'; document.list_form.submit();" STYLE = "margin-left:30px;">
</CENTER>
<script>	
	function to_edit(id) {						
		document.list_form.id.value=id;	// 
		document.list_form.submit();
		}
</script>

<FORM NAME = "list_form" METHOD = "get" ACTION = "<?php 
예제 #23
0
파일: index.php 프로젝트: hardikk/HNH
function updateRow_TicketDelivery($pDB, $pDB_2, $module_name)
{
    $sTicketId = trim(getParameter('ticket_id'));
    $pTicket_Delivery = new Ticket_Delivery($pDB);
    $pACL = new paloACL($pDB_2);
    $arrResult = $pTicket_Delivery->getTicket_DeliveryById($sTicketId);
    $img_dir = "modules/{$module_name}/images/";
    $value = $arrResult[0];
    $ticket = '';
    $name = $pACL->getUsers($value['accounting_id']);
    $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1];
    // show files
    $download = '';
    foreach ($value['ticket_attachment'] as $row) {
        $url = "/modules/agent_console/ajax-attachments-handler.php?download=" . $row['filepath'] . "&name=" . $row['filename'];
        $filename = $row['filename'];
        $download .= "*<a href='{$url}' target='_blank' title='{$filename}'>" . shorten($filename) . "</a><br/>";
    }
    $print = '<a href="javascript:void(0)" onclick="print(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'print.png" title="In phiếu"></a>';
    $enable = $value['isActive'] == '1' ? '<a href="javascript:void(0)" onclick="disable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'disable.png" title="Hủy yêu cầu giao vé"></a>&nbsp;' : '<a href="javascript:void(0)" onclick="enable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'enable.png" title="Tạo lại yêu cầu giao vé"></a>';
    $print .= '&nbsp;&nbsp;' . $enable;
    if ($value['isActive'] == '0') {
        $value['status'] = 'Đã hủy';
    }
    // function show base on status
    switch ($value['status']) {
        case 'Mới':
            $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
            break;
        case 'Đang giao':
            $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Đổi phân công"></a>&nbsp;
                        <a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'result.png" title="Kết quả"></a>';
            break;
        case 'Đã nhận tiền':
            $function = '<a href="javascript:void(1)" onclick="uncollect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'unpaid.png" title="Hủy nhận tiền"></a>';
            break;
        case 'Chờ xử lý':
            $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
            break;
        default:
            $function = '';
    }
    // show ticket code
    foreach ($value['ticket_code'] as $row) {
        $ticket .= $row . '<br>';
    }
    // append html
    $html = '';
    $html .= '<td class="table_data">' . $value['id'] . '</td>';
    $html .= '<td class="table_data">' . $value['customer_name'] . '</td>';
    $html .= '<td class="table_data">' . $value['customer_phone'] . '</td>';
    $html .= '<td class="table_data"><span title="Chi nhánh: ' . $value['office'] . '">' . $value['agent_name'] . '</span></td>';
    $html .= '<td class="table_data">' . '<a href="javascript:void(1)" title="' . $value['deliver_address'] . '"
			                onclick="view_address(\'' . $value['deliver_address'] . '\')">' . shorten($value['deliver_address']) . '
			              </a></td>';
    $html .= '<td class="table_data">' . $value['pay_amount'] . '</td>';
    $html .= '<td class="table_data">' . $ticket . '</td>';
    $html .= '<td class="table_data">' . showStatus($value['status']) . '</td>';
    $html .= '<td class="table_data">' . $value['delivery_name'] . '</td>';
    $html .= '<td class="table_data">' . (is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date']))) . '</td>';
    $html .= '<td class="table_data">' . $download . '</td>';
    $html .= '<td class="table_data">' . (is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date']))) . '</td>';
    $html .= '<td class="table_data">' . $function . '</td>';
    $html .= '<td class="table_data"><a href="javascript:void(1)" onclick="view_log(\'' . $value['id'] . '\')">
			            <img src="' . $img_dir . 'extra.png" title="Xem chi tiết"></a></td>';
    $html .= '<td class="table_data">' . $print . '</td>';
    return $html;
}
예제 #24
0
function rdssend($songName, $artistName)
{
    /*
    // Get the date passed in from the log book, this should be the same date
    	// the logbook stored in the shared memory at segment 881
    	$datePassed = $_GET['date'];
    	$segment_id   = 881;
    	// You have to attach to the shared memory segment first
    	$shm = shm_attach($segment_id,PHP_INT_SIZE,0600);
    	// Then get the date currently stored in the shared memory segment
    	$dateStored = shm_get_var($shm,1);
    // Everytime the RDS sender script gets called the Logbook updates the 
    	// time saved in the shared memory so we know if we should leave this script
    	if($datePassed != $dateStored) {
    	
    			// Detach the shared memory segment and exit
    			shm_detach($shm);
    		}
    // Declare the new Com port
    	$COM = new phpSerial;
    	
    	// Set the serial device "/dev/ttyS0" for linux "COM1" for windows
    	if (substr(PHP_OS,0,3) == 'WIN'){
    		$COM->deviceSet("COM1");
    	}
    	else{
    		$COM->deviceSet("/dev/ttyS0");
    	}
    // Set the baud rate, parity, length, stop bits, flow control
    	$COM->confBaudRate(9600);
    	$COM->confParity("none");
    	$COM->confCharacterLength(8);
    	$COM->confStopBits(1);
    	$COM->confFlowControl("none");
    */
    // Remove the bad words and make it all uppercase
    $artistName = censor($artistName);
    $songName = censor($songName);
    // if your song name is the password, we'll keep on sending until Now Playing gets updated
    if ($songName == PASSWORD) {
        // See how long the string is so we can see if we need to shorten it
        $artistNameLength = strlen($artistName);
        // if the string is longer than the DPS_MAX, get rid of the " THE "s
        if ($artistNameLength > DPS_MAX) {
            $artistName = str_replace(" THE ", " ", $artistName);
            $artistNameLength = strlen($artistName);
        }
        // if it's still too long, just cut it down to size.
        if ($artistNameLength > DPS_MAX) {
            $artistName = substr($artistName, 0, DPS_MAX);
            $artistNameLength = strlen($artistName);
        }
        // Make the DPS output
        // The Inovonics 730 requires a carriage return at the end of every string
        $dpsOut = "DPS=" . $artistName . chr(13);
        // if the string is longer than the TEXT_MAX, get rid of the " THE "s.
        if ($artistNameLength > TEXT_MAX) {
            $artistName = str_replace(" THE ", " ", $artistName);
            $artistNameLength = strlen($artistName);
        }
        // if it's still too long, just cut it down to size.
        if ($artistNameLength > TEXT_MAX) {
            $artistName = substr($artistName, 0, TEXT_MAX);
        }
        // Make the RT output
        $rtOut = "TEXT=" . $artistName . chr(13);
        /*
        		// Get the date stored again to see if it's been updated
        		$dateStored = shm_get_var($shm,'date');
        // if the stored date hasn't changed, send the output every three minutes
        		while ($datePassed == $dateStored){
        		
        			// Open the COM port
        			$COM->deviceOpen();
        			// Send the strings
        			$COM->sendMessage($dpsOut);
        			$COM->sendMessage($rtOut);
        			// Close the port when you're done
        			$COM->deviceClose();
        	sleep(180);
        	// Grab the stored date again
        			$dateStored = shm_get_var($shm,'date');
        		}
        // Detach from the shared memory segment and exit
        		shm_detach($shm);
        */
        $fs = fopen('test_output.txt', 'w');
        fwrite($fs, $dpsOut);
        fwrite($fs, $rtOut);
        fclose($fs);
        //echo $dpsOut;
        //echo $rtOut;
    } elseif ($songName == "LIVE SESSION" || $songName == "LIVE SESSIONS") {
        $dpsOut = "LIVE SESSION WITH " . $artistName . " ON " . STATION_NAME;
        $dpsLen = strlen($dpsOut);
        $rtOut = $artistName . " LIVE ON " . STATION_NAME;
        $rtLen = strlen($rtOut);
        $stationLen = strlen(STATION_NAME) - 1;
        // if it's too long we'll drop the station name
        if ($dpsLen > DPS_MAX) {
            $dpsOut = "LIVE SESSION WITH " . $artistName;
            $dpsLen = strlen($dpsOut);
        }
        // if it's still to long then we'll drop the " THE "s.
        if ($dpsLen > DPS_MAX) {
            $dpsOut = str_replace(" THE ", " ", $dpsOut);
            $dpsLen = strlen($dpsOut);
        }
        // And it it's still to long, we'll just cut it short
        if ($dpsLen > DPS_MAX) {
            $dpsOut = substr($dpsOut, 0, DPS_MAX);
        }
        // Put it in the format the Inovonics 730 likes
        $dpsOut = "DPS=" . $dpsOut . chr(13);
        // Now for the Radio Text, except to make it fun, we need to know
        // the length of the artist name when we go back to calculate the RT+
        // if it's too long drop the " THE "s.
        if ($rtLen > TEXT_MAX) {
            $artistName = str_replace(" THE ", " ", $artistName);
            $rtOut = $artistName . " LIVE ON " . STATION_NAME;
            $rtLen = strlen($rtOut);
        }
        // if it's still too long we cut the artist name down to size
        if ($rtLen > TEXT_MAX) {
            // The longest the artist name can be is the TEXT_MAX length,
            // minus the length of the STATION_NAME, plus the 9 characters
            // for " LIVE ON " plus 1 because station len is the length minus 1
            $artMax = TEXT_MAX - ($stationLen + 10);
            $artistName = substr($artistName, 0, $artMax);
            $rtOut = $artistName . " LIVE ON " . STATION_NAME;
        }
        // Format the output for the Inovonics 730
        $rtOut = "TEXT=" . $rtOut . chr(13);
        // Let's calculate some RT+
        // The count starts at zero
        $artistNameLength = strlen($artistName) - 1;
        // This will give the starting position of STATION_NAME
        $stationStart = $artistNameLength + 10;
        // This makes it so they are all two digits
        $artistNameLength = str_pad($artistNameLength, 2, "0", STR_PAD_LEFT);
        $stationLen = str_pad($stationLen, 2, "0", STR_PAD_LEFT);
        $stationStart = str_pad($stationStart, 2, "0", STR_PAD_LEFT);
        // Type,Starting Position,Length, Type,Starting Position,Length
        $rtpOut = "RTP=04,00," . $artistNameLength . ",31," . $stationStart . "," . $stationLen . chr(13);
        /*
        	// Grab the date currently stored in memory
        	$dateStored = shm_get_var($shm,'date');
        
        	// if it is still the same as the date passed in, send it every three minutes until it no longer is
        	while ($datePassed == $dateStored){
        
        		// Open the COM port
        		$COM->deviceOpen();
        		// Send the strings
        		$COM->sendMessage($dpsOut);
        		$COM->sendMessage($rtOut);
        		$COM->sendMessage($rtpOut);
        		// Close the port when you're done
        		$COM->deviceClose();
        
        		sleep(180);
        	
        		// Check the date again
        		$dateStored = shm_get_var($shm,'date');
        	}
        
        	// Detach from the shared memory and exit
        	shm_detach($shm);
        */
        $fs = fopen('test_output.txt', 'w');
        fwrite($fs, $dpsOut);
        fwrite($fs, $rtOut);
        fwrite($fs, $rtpOut);
        fclose($fs);
        //echo $dpsOut;
        //echo $rtOut;
        //echo $rtpOut;
    } else {
        // Call the trim function to cut them down to size for DPS and make the right string
        list($songName, $artistName) = shorten($songName, $artistName, DPS_MAX);
        $dpsOut = "DPS=" . $songName . " BY " . $artistName . " ON " . STATION_NAME . chr(13);
        // Call the trim function to cut them down to size for RT and make the string
        list($songName, $artistName) = shorten($songName, $artistName, TEXT_MAX);
        $rtOut = "TEXT=" . $songName . " BY " . $artistName . chr(13);
        // Start calculating the RT+ value
        $artistNameLength = strlen($artistName) - 1;
        $songNameLength = strlen($songName) - 1;
        // The starting value of the artist name is the length of the song name, plus 4 for " BY "
        // and plus one because the length of the song name is one less than it actually is
        $artistStart = $songNameLength + 5;
        // Make it so that they are two digit numbers
        $artistNameLength = str_pad($artistNameLength, 2, "0", STR_PAD_LEFT);
        $songNameLength = str_pad($songNameLength, 2, "0", STR_PAD_LEFT);
        $artistStart = str_pad($artistStart, 2, "0", STR_PAD_LEFT);
        // Make the RT+ output with the right format
        $rtpOut = "RTP=01,00," . $songNameLength . ",04," . $artistStart . "," . $artistNameLength . chr(13);
        /*
        	// Get the stored date from the shared memory segment
        	$dateStored = shm_get_var($shm,'date');
        
        	// if the passed date is the same as the stored date, go ahead and send it
        	if($dateStored == $datePassed){
        		// Open the COM port
        		$COM->deviceOpen();
        		// Send the DPS String
        		$COM->sendMessage($dpsOut);
        		$COM->sendMessage($rtOut);
        		$COM->sendMessage($rtpOut);
        		// Close the port when you're done
        		$COM->deviceClose();
        	}
        	// Detach the shared memory segment and exit
        	shm_detach($shm);
        */
        $fs = fopen('test_output.txt', 'w');
        fwrite($fs, $dpsOut);
        fwrite($fs, $rtOut);
        fwrite($fs, $rtpOut);
        fclose($fs);
        //echo $dpsOut;
        //echo $rtOut;
        //echo $rtpOut;
    }
}
예제 #25
0
// blauer Titelblock einbinden
//Variablen des Titelblocks
//Hilfedatei
$new_hlp_file = "edv_modul_neu_hlp1.php";
//Variable für Überschrift Titellesite
$thismodulname = $LDEDP . " - " . $LDNeuesModulanlegen;
include $root_path . $newmodule_includepath . "inc_titelblock.php";
?>

<?php 
//Das Eingabefeld formatieren, von evtl. Tags befreien, Sonderzeichen & Umlaute in HTML Codes umwandeln
require $root_path . $newmodule_includepath . "inc_func_shorten.php";
$ModulNeuBez = strip_tags($ModulNeuBez);
$ModulNeuBez = htmlentities($ModulNeuBez);
$alteBez = $ModulNeuBez;
$werte = shorten($ModulNeuBez);
$ModulNeuBez = $werte[0];
if ($werte[1] == "true") {
    echo "<FONT FACE='ARIAL' color='#ff0000'><STRONG>{$blank_eingabe}</STRONG></FONT></br><br/>";
}
// Prüfen ob das Eingabefeld Daten enthält
if ($ModulNeuBez == "" or $ModulNeuBez == " ") {
    ?>
	 <FONT FACE='ARIAL' color='#ff0000'><STRONG><?php 
    echo "<blink>" . $fehleingabe . "</blink>";
    ?>
 </STRONG></FONT>
<?php 
} else {
    ?>
<!--Farbe dunkelrot: color="#990000"-->
예제 #26
0
/**
 * This function is to display the added resources (lessons) in the learning path player and builder
 * this function is a modification of display_addedresource_link($type, $id) function
 * the two ids are a bit confusing, I admit, but I did not want to change Patrick's work, I was
 * building upon it. - Denes
 *
 * Parameters:
 * @param completed   - if ="completed" then green presentation with checkbox
 * @param id_in_path  - if onclick then this lesson will be considered completed, that is the unique index in the items table
 * @param id          - that is the correspondent id in the mirror tool (like Agenda item 2)
 * @param type        - that is the correspondent type in the mirror tool (like this is a Link item)
 * @param builder     - if ="builder" then onclick shows in new window
 * @param icon        - if ="icon" then the small icon will appear
 *                      if ="wrap" then wrapped settings are used (and no icon is displayed)
 *                      if ="nolink" then only the name is returned with no href and no icon (note:only in this case, the result is not displayed, but returned)
 * @todo this function is too long, rewrite
 */
function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0)
{
    global $_course, $learnpath_id, $tbl_learnpath_item, $items;
    global $curDirPath, $_configuration, $enableDocumentParsing, $_course, $_user, $_cid;
    $course_id = api_get_course_int_id();
    $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
    $hyperlink_target_parameter = '';
    //or e.g. 'target="_blank"'
    $length = $builder == 'builder' && $icon == 'nolink' ? 65 : 32;
    if ($builder != 'builder') {
        $origin = 'learnpath';
    }
    //origin = learnpath in student view
    $linktype = $type;
    if ($type == 'Link _self' or $type == 'Link _blank') {
        $type = 'Link';
    }
    // YW switched litteral tool names to use of constants declared in main_api.lib.php
    switch ($type) {
        case TOOL_CALENDAR_EVENT:
        case 'Agenda':
            $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
            $result = Database::query("SELECT * FROM {$TABLEAGENDA} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $myrow['title'] = $row['title'];
            }
            $desc = $row['description'];
            $agenda_id = $row['item_id'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($myrow['title'] == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($myrow['title'], $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Agenda&origin={$origin}&agenda_id={$agenda_id}#{$id_in_path}\" class='{$completed}'>" . shorten($myrow['title'], $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Agenda&origin={$origin}&agenda_id={$agenda_id}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../calendar/agenda.php?origin={$origin}&agenda_id={$agenda_id}\" class='{$completed}' target='_blank'>" . shorten($myrow['title'], $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_ANNOUNCEMENT:
        case 'Ad_Valvas':
            $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
            $result = Database::query("SELECT * FROM {$tbl_announcement} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $myrow['content'] = $row['title'];
            }
            $desc = $row['description'];
            $ann_id = $row['item_id'];
            echo str_repeat("&nbsp;&gt;", $level);
            // The title and the text are in the content field and we only want to display the title.
            list($title, $text) = explode('<br>', $myrow['content']);
            if ($title == '') {
                $title = $myrow['content'];
            }
            $title = $myrow['title'];
            $text = $myrow['content'];
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($title == '') {
                $type = 'Announcement';
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($title, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Ad_Valvas&origin={$origin}&ann_id={$ann_id}#{$id_in_path}\" class='{$completed}'>" . shorten($title, $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Ad_Valvas&origin={$origin}&ann_id={$ann_id}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../announcements/announcements.php?origin={$origin}&ann_id={$ann_id}\" class='{$completed}' target='_blank'>" . shorten($title, $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_LINK:
        case 'Link':
            $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
            $result = Database::query("SELECT * FROM {$TABLETOOLLINK} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $myrow['title'] = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($myrow['title'] == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($myrow['title'], $length);
            }
            if ($icon == 'icon') {
                if ($linktype == 'Link _self') {
                    echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>";
                } else {
                    echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>";
                }
            }
            $thelink = $myrow['url'];
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type={$linktype}&origin={$origin}&thelink={$thelink}#{$id_in_path}\" class='{$completed}'>" . shorten($myrow['title'], $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type={$linktype}&origin={$origin}&thelink={$thelink}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"{$thelink}\" class='{$completed}' target='_blank'>" . shorten($myrow['title'], $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_QUIZ:
        case 'Exercise':
            $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
            $result = Database::query("SELECT * FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            if ($builder == 'builder') {
                $origin = 'builder';
            }
            // This is needed for the exercise_submit.php can delete the session info about tests.
            $sql = "select * from {$tbl_lp_item} where id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $myrow['title'] = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($myrow['title'] == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($myrow['title'], $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Exercise&origin={$origin}&exerciseId=" . $myrow["id"] . "#{$id_in_path}\" class='{$completed}'>" . shorten($myrow['title'], $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Exercise&origin={$origin}&exerciseId=" . $myrow["id"] . "#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../exercice/exercise_submit.php?origin={$origin}&exerciseId=" . $myrow['id'] . "\" class='{$completed}' target='_blank'>" . shorten($myrow['title'], $length - 3 * $level) . "</a>";
            }
            break;
        case 'hotpotatoes':
        case 'HotPotatoes':
            $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
            $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
            $result = Database::query("SELECT * FROM " . $TBL_DOCUMENT . " WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $path = $myrow['path'];
            $name = GetQuizName($path, $documentPath);
            if ($builder == 'builder') {
                $origin = 'builder';
            }
            // This is needed for the exercise_submit.php can delete the session info about tests.
            $sql = "select * from {$tbl_lp_item} where id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $name = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($name == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($name, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/jqz.jpg' align=\"absmiddle\" alt='hot potatoes'>";
            }
            $cid = $_course['official_code'];
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=HotPotatoes&origin={$origin}&id={$id}#{$id_in_path}\" class='{$completed}'>" . shorten($name, $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=HotPotatoes&origin={$origin}&id={$id}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "&nbsp;<a href=\"../exercice/showinframes.php?file={$path}&cid={$cid}&uid=" . $_user['user_id'] . "\" class='{$completed}' target='_blank'>" . shorten($name, $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_FORUM:
        case 'Forum':
            $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
            $result = Database::query("SELECT * FROM {$TBL_FORUMS} WHERE c_id = {$course_id} AND forum_id={$id}");
            $myrow = Database::fetch_array($result);
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $myrow["forum_name"] = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($myrow["forum_name"] == '') {
                $type = "Forum";
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($myrow['forum_name'], $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>";
            }
            $forumparameters = "forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"];
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Forum&origin={$origin}&forumparameters={$forumparameters}#{$id_in_path}\" class='{$completed}'>" . shorten($myrow["forum_name"], $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Forum&origin={$origin}&forumparameters={$forumparameters}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../phpbb/viewforum.php?{$forumparameters}\" class='{$completed}' target='_blank'>" . shorten($myrow["forum_name"], $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_THREAD:
        case 'Thread':
            //forum post
            $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD);
            $sql = "SELECT * FROM {$tbl_topics} where c_id = {$course_id} AND topic_id={$id}";
            $result = Database::query($sql);
            $myrow = Database::fetch_array($result);
            $sql = "select * from {$tbl_lp_item} where id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $myrow['topic_title'] = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($myrow["topic_title"] == '') {
                $type = "Forum Post";
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($myrow['topic_title'], $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Thread&origin={$origin}&topic=" . $myrow["topic_id"] . "&forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"] . "#{$id_in_path}\" class='{$completed}'>" . shorten($myrow["topic_title"], $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Thread&origin={$origin}&topic=" . $myrow["topic_id"] . "&forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"] . "#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../phpbb/viewtopic.php?topic=" . $myrow["topic_id"] . "&forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"] . "\" class='{$completed}' target='_blank'>" . shorten($myrow["topic_title"], $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_POST:
        case 'Post':
            //deprecated
            $tbl_posts = Database::get_course_table(TABLE_FORUM_POST);
            $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
            $result = Database::query("SELECT * FROM {$tbl_posts} where c_id = {$course_id} AND post_id={$id}");
            $myrow = Database::fetch_array($result);
            // Grabbing the title of the post.
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $myrow['post_title'] = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            $posternom = $myrow['nom'];
            $posterprenom = $myrow['prenom'];
            $posttime = $myrow['post_time'];
            $posttext = $myrow['post_text'];
            $posttitle = $myrow['post_title'];
            $posttext = str_replace('"', "'", $posttext);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($myrow["post_title"] == '') {
                $type = 'Forum';
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($myrow["post_title"], $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . intval($_GET['source_forum']) . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Post&origin={$origin}&posternom={$posternom}&posterprenom={$posterprenom}&posttime={$posttime}&posttext={$posttext}&posttitle={$posttitle}#{$id_in_path}\" class='{$completed}'>" . shorten($myrow["post_title"], $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . intval($_GET['source_forum']) . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Post&origin={$origin}&posternom={$posternom}&posterprenom={$posterprenom}&posttime={$posttime}&posttext={$posttext}&posttitle={$posttitle}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../phpbb/viewtopic.php?topic=" . $myrow["topic_id"] . "&forum=" . $myrow["forum_id"] . "&md5=" . $myrow["md5"] . "\" class='{$completed}' target='_blank'>" . shorten($myrow["post_title"], $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_DOCUMENT:
        case 'Document':
            $dbTable = Database::get_course_table(TABLE_DOCUMENT);
            $my_sql = "SELECT * FROM {$dbTable} WHERE c_id = {$course_id} AND id={$id}";
            //error_log('New LP - Querying document table: '.$my_sql,0);
            $result = Database::query($my_sql);
            $myrow = Database::fetch_array($result);
            $pathname = explode('/', $myrow['path']);
            // Making a correct name for the link.
            $last = count($pathname) - 1;
            // Making a correct name for the link.
            $filename = $pathname[$last];
            // Making a correct name for the link.
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            echo str_repeat("&nbsp;&gt;", $level);
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            $image = choose_image($filename);
            $sql = "select * from {$tbl_lp_item} where id={$id_in_path}";
            //error_log('New LP - Querying lp_item table: '.$sql, 0);
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $filename = $row['title'];
            }
            $desc = $row['description'];
            if ($myrow['path'] == '' && $filename == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($filename, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/{$image}' align=\"absmiddle\" alt='{$image}'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Document&origin={$origin}&docurl=" . $myrow["path"] . "#{$id_in_path}\" class='{$completed}'>" . shorten($filename, $length - 3 * $level) . "</a>";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Document&origin={$origin}&docurl=" . $myrow["path"] . "#{$id_in_path}";
            } else {
                $enableDocumentParsing = yes;
                if (!$enableDocumentParsing) {
                    // This is the solution for the non-parsing version in the builder.
                    $file = urlencode($myrow['path']);
                    echo "<a href='../document/showinframes.php?file={$file}' class='{$completed}' {$hyperlink_target_parameter}>" . shorten($filename, $length - 3 * $level) . "</a>";
                } else {
                    echo "<a href=\"../document/download.php?doc_url=" . $myrow['path'] . "\" class='{$completed}' {$hyperlink_target_parameter}>" . shorten($filename, $length - 3 * $level) . "</a>";
                }
            }
            break;
        case 'assignments':
        case 'Assignments':
            $name = get_lang('Assignments');
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $name = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($name == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($name, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/works.gif' align=\"absmiddle\">";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Assignments&origin={$origin}#{$id_in_path}\" class='{$completed}'>" . shorten($name, $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Assignments&origin={$origin}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../work/work.php\" class='{$completed}' target='_blank'>" . shorten($name, $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_DROPBOX:
        case 'Dropbox':
            $name = get_lang('Dropbox');
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $name = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($name == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($name, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/dropbox.gif' align=\"absmiddle\">";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Dropbox&origin={$origin}#{$id_in_path}\" class='{$completed}'>" . shorten($name, $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Dropbox&origin={$origin}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../dropbox/index.php\" class='{$completed}' target='_blank'>" . shorten($name, $length - 3 * $level) . "</a>";
            }
            break;
        case 'introduction_text':
        case 'Introduction_text':
            $name = get_lang('IntroductionText');
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $name = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($name == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($name, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Introduction_text&origin={$origin}#{$id_in_path}\" class='{$completed}'>" . shorten($name, $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Introduction_text&origin={$origin}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                $s = api_get_path(WEB_COURSE_PATH) . "{$_cid}/index.php?intro_cmdEdit=1";
                echo "<a href=\"{$s}\" class='{$completed}' target='_blank'>" . shorten($name, $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_COURSE_DESCRIPTION:
        case 'Course_description':
            $name = get_lang('CourseDescription');
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $name = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($name == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($name, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Course_description&origin={$origin}#{$id_in_path}\" class='{$completed}'>" . shorten($name, $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Course_description&origin={$origin}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                $s = api_get_path(WEB_CODE_PATH) . "course_description";
                echo "<a href=\"{$s}\" class='{$completed}' target='_blank'>" . shorten($name, $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_GROUP:
        case 'Groups':
            $name = get_lang('Groups');
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $name = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($name == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($name, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Groups&origin={$origin}#{$id_in_path}\" class='{$completed}'>" . shorten($name, $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Groups&origin={$origin}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../group/group.php?origin={$origin}\" class='{$completed}' target='_blank'>" . shorten($name, $length - 3 * $level) . "</a>";
            }
            break;
        case TOOL_USER:
        case 'Users':
            $name = get_lang('Users');
            $sql = "select * from {$tbl_lp_item} where c_id = {$course_id} AND id={$id_in_path}";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            if ($row['title'] != '') {
                $name = $row['title'];
            }
            $desc = $row['description'];
            echo str_repeat("&nbsp;&gt;", $level);
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "<td>";
            }
            if ($icon != 'nolink') {
                if ($completed == 'completed') {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
                } else {
                    echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
                    //echo "&nbsp;";
                }
            }
            if ($builder != 'builder' && $icon != 'wrap') {
                echo "</td><td>";
            }
            if ($name == '') {
                echo "<span class='messagesmall'>" . get_lang('StepDeleted1') . " {$type} " . get_lang('StepDeleted2') . "</span>";
                return true;
            }
            if ($icon == 'nolink') {
                return shorten($name, $length);
            }
            if ($icon == 'icon') {
                echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>";
            }
            if ($builder != 'builder') {
                echo "<a href=\"" . api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Users&origin={$origin}#{$id_in_path}\" class='{$completed}'>" . shorten($name, $length - 3 * $level) . "</a>";
                $items[] = api_get_self() . "?action=closelesson&source_forum=" . $_GET['source_forum'] . "&how=complete&id_in_path={$id_in_path}&learnpath_id={$learnpath_id}&type=Users&origin={$origin}#{$id_in_path}";
                if ($desc != '') {
                    if ($icon != 'wrap') {
                        echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div></td></tr>";
                    } else {
                        echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . shorten($desc, $length - 3 * $level) . "</div>";
                    }
                }
            } else {
                echo "<a href=\"../user/user.php?origin={$origin}\" class='{$completed}' target='_blank'>" . shorten($name, $length - 3 * $level) . "</a>";
            }
            break;
    }
    //end huge switch-statement
}
 function doSkinVar($skinType, $numberOfWritebacks = 5, $filter = '', $TBorCm = 'all', $numberOfCharacters = 60, $numberOfTitleCharacters = 40, $toadd = "...")
 {
     global $manager, $CONF, $blog;
     if (!is_numeric($numberOfWritebacks)) {
         $filter = $numberOfWritebacks;
         $numberOfWritebacks = 5;
         // defaults to 5
     }
     $b =& $manager->getBlog($CONF['DefaultBlog']);
     $this->defaultblogurl = $b->getURL();
     if (!$this->defaultblogurl) {
         $this->defaultblogurl = $CONF['IndexURL'];
     }
     if ($blog) {
         $b =& $blog;
     }
     $blogid = $b->getID();
     //for select
     $filter = trim($filter);
     if ($filter == 'current') {
         $filter = 'cblog = ' . $blogid;
     } elseif (strstr($filter, '=')) {
         $filter = str_replace('=', '', $filter);
         $filter = ' cblog IN(' . str_replace('/', ',', $filter) . ')';
     } elseif (strstr($filter, '<>')) {
         $filter = str_replace('<>', '', $filter);
         $filter = ' cblog <> ' . str_replace('/', ' AND cblog <> ', $filter);
     }
     setlocale(LC_TIME, $this->getOption('timelocale'));
     $arr_res = array();
     if ($TBorCm != 't') {
         $join = '';
         $query = 'SELECT' . ' c.cnumber as commentid,' . ' c.cuser   as commentator,' . ' c.cbody   as commentbody,' . ' c.citem   as itemid,' . ' c.cmember as memberid,' . ' SUBSTRING(c.ctime, 6, 5) as commentday,' . ' UNIX_TIMESTAMP(c.ctime)  as ctimest';
         if ($EzComment2 = $this->pluginCheck('EzComment2')) {
             if (method_exists($EzComment2, 'getTemplateParts')) {
                 $query .= ', s.comid   as cid, ' . 's.secflg  as secret, ' . 's.module  as modname, ' . 's.userID  as identity ';
                 $join = ' LEFT OUTER JOIN ' . sql_table('plug_ezcomment2') . ' as s ' . ' ON c.cnumber = s.comid ';
             }
         }
         // select
         $query .= ' FROM ' . sql_table('comment') . ' as c ' . $join;
         if ($filter) {
             $query .= ' WHERE ' . $filter;
         }
         $query .= ' ORDER by c.ctime DESC LIMIT 0, ' . $numberOfWritebacks;
         $comments = sql_query($query);
         if (sql_num_rows($comments)) {
             while ($row = sql_fetch_object($comments)) {
                 $content = (array) $row;
                 $tempBody = strip_tags($content['commentbody']);
                 $tempBody = htmlspecialchars($tempBody, ENT_QUOTES, _CHARSET);
                 $tempBody = shorten($tempBody, $numberOfCharacters, $toadd);
                 $tempBody = htmlspecialchars($tempBody, ENT_QUOTES, _CHARSET);
                 $tempBody = str_replace("\r\n", ' ', $tempBody);
                 $tempBody = str_replace("&amp;", '&', $tempBody);
                 $tempBody = str_replace("&gt;", '>', $tempBody);
                 $tempBody = str_replace("&lt;", '<', $tempBody);
                 $content['commentdate'] = strftime($this->getOption('cmdateformat'), $content['ctimest']);
                 $content['commentbody'] = str_replace("&amp;amp;", '&amp;', $tempBody);
                 if (!empty($row->memberid)) {
                     $mem = new MEMBER();
                     $mem->readFromID(intval($row->memberid));
                     $content['commentator'] = $mem->getRealName();
                 }
                 if ($EzComment2) {
                     $bid = intval(getBlogIDFromItemID(intval($comment['itemid'])));
                     if ($EzComment2->getBlogOption($bid, 'secret') == 'yes') {
                         $b = $manager->getBlog($bid);
                         global $member;
                         $judge = $EzComment2->setSecretJudge($bid, $member, $b);
                     }
                 }
                 if ($judge && $content['secret']) {
                     $content = $EzComment2->JudgementCommentSecrets($content, $judge);
                 }
                 /*					$cid  = $row->cnumber;
                 					$ct  = $row->ctimest;
                 					$ctst  = date("y-m-d H:i",$ct);
                 					$text = strip_tags($row->cbody);
                 					$text = htmlspecialchars($text, ENT_QUOTES,_CHARSET);
                 					$ctext = shorten($text,$numberOfCharacters,$toadd);
                  
                 					if (!$row->cmember) $myname = $row->cuser;
                 					else {
                 						$mem = new MEMBER;
                 						$mem->readFromID(intval($row->cmember));
                 						$myname = $mem->getRealName();
                 					}*/
                 //					$itemlink = $this->_createItemLink($row->citem, '');
                 //					$arr_res[$ct] =  "<li>&clubs;<a href=\"".$itemlink."#c".$cid."\">$ctst|".$myname."&gt;".$ctext."</a></li>" ;
                 $itemlink = $this->_createItemLink($content['itemid']);
                 $content['itemlink'] = $itemlink;
                 $arr_res[$content['ctimest']] = TEMPLATE::fill($this->getOption('cmttemplate'), $content);
             }
         }
     }
     //=========================
     if ($manager->pluginInstalled('NP_TrackBack') && $TBorCm != 'c') {
         $query = 'SELECT' . ' t.id        as tbid,' . ' t.title     as entrytitle,' . ' t.excerpt   as expect,' . ' t.url       as tburl,' . ' t.tb_id     as trackbackid,' . ' t.blog_name as blogname,' . ' t.timestamp as tbdate,' . ' SUBSTRING(t.timestamp, 6, 5) as tbday,' . ' UNIX_TIMESTAMP(t.timestamp)  as ttimest' . ' FROM ' . sql_table('plugin_tb') . ' t,' . sql_table('item') . ' i' . ' WHERE t.tb_id = i.inumber';
         if ($this->checkTBVersion()) {
             $query .= ' and t.block = 0';
         }
         if ($filter) {
             $tfilter = str_replace('c.cblog', 'i.iblog', $filter);
             $query .= ' and ' . $tfilter;
         }
         $query .= ' ORDER by t.timestamp DESC LIMIT 0, ' . $numberOfWritebacks;
         $comments = sql_query($query);
         if (sql_num_rows($comments)) {
             while ($row = sql_fetch_object($comments)) {
                 $content = (array) $row;
                 $entrytitle = strip_tags($content['entrytitle']);
                 $entrytitle = htmlspecialchars($entrytitle, ENT_QUOTES, _CHARSET);
                 $entrytitle = shorten($entrytitle, $numberOfCharacters, $toadd);
                 $entrytitle = htmlspecialchars($entrytitle, ENT_QUOTES, _CHARSET);
                 $content['entrytitle'] = $entrytitle;
                 $content['expect'] = str_replace("\r\n", ' ', $content['expect']);
                 $blogname = htmlspecialchars($content['blogname'], ENT_QUOTES, _CHARSET);
                 $content['blogname'] = $blogname;
                 $content['tbdate'] = strftime($this->getOption('tbdateformat'), $content['ttimest']);
                 /*					$title = strip_tags($row->title);
                 					$title = htmlspecialchars($title, ENT_QUOTES,_CHARSET);
                 					$ctitle = shorten($title,$numberOfCharacters,$toadd);
                 					$blogname = htmlspecialchars($row->blog_name, ENT_QUOTES,_CHARSET);
                 					$tbtime = $row->ttimest;
                 					$ttst  = date("y-m-d H:i",$tbtime);*/
                 //					$itemlink = $this->_createItemLink($row->tb_id, '');
                 //					$arr_res[$tbtime] = '<li>&hellip;<a href="'.$itemlink.'#trackback">'.$ttst.'|'.$blogname.' ping: "'.$ctitle.'"</a></li>';
                 $itemlink = $this->_createItemLink($content['trackbackid']);
                 $content['itemlink'] = $itemlink;
                 $arr_res[$content['ttimest']] = TEMPLATE::fill($this->getOption('tbktemplate'), $content);
             }
         }
     }
     //=========================
     krsort($arr_res);
     $ress = array_values($arr_res);
     $show_rescnt = min(intval($numberOfWritebacks), count($arr_res));
     switch ($TBorCm) {
         case 'c':
             $head = $this->getOption('cmlisthead');
             $foot = $this->getOption('cmlistfoot');
             break;
         case 't':
             $head = $this->getOption('tblisthead');
             $foot = $this->getOption('tblistfoot');
             break;
         default:
             $head = ' <ul class="nobullets"> ';
             $foot = ' </ul> ';
             break;
     }
     //		echo ' <ul class="nobullets"> ';
     echo $head;
     for ($j = 0; $j < $show_rescnt; $j++) {
         echo $ress[$j] . "\n";
     }
     echo $foot;
     //		echo " </ul> ";
 }
예제 #28
0
 function hook_cron()
 {
     cron_log('Beginning Twitter cronjob.');
     if (setting('twitter_enabled') != '1') {
         cron_log('Twitter is disabled.  Exiting.');
         $this->settings_model->update_setting('twitter_last_tweet', date('Y-m-d H:i:s'));
         return FALSE;
     }
     if (setting('twitter_content_types') == '') {
         cron_log('No content types have been configured for tweeting.  Exiting.');
         $this->settings_model->update_setting('twitter_last_tweet', date('Y-m-d H:i:s'));
         return FALSE;
     }
     // load libraries
     $CI =& get_instance();
     $CI->load->model('publish/content_model');
     require APPPATH . 'modules/twitter/libraries/twitteroauth.php';
     // only process last hour
     $start_date = date('Y-m-d', strtotime('now - 1 hour'));
     $types = unserialize(setting('twitter_content_types'));
     $topics = setting('twitter_topics') == '' ? NULL : unserialize(setting('twitter_topics'));
     // if they have all topics...
     if (is_int($topics) && ($topics = 0) || is_array($topics) && in_array(0, $topics)) {
         $topics = NULL;
     }
     foreach ($types as $type) {
         $filter = array('type' => $type, 'start_date' => $start_date, 'limit' => '50');
         if (is_int($topics) && $topics != 0 || is_array($topics) && !in_array(0, $topics)) {
             $filter['topics'] = $topics;
         }
         $contents = $CI->content_model->get_contents($filter);
         if (!empty($contents)) {
             // flip so that the latest posts are tweeted last
             $contents = array_reverse($contents);
             foreach ($contents as $content) {
                 // have we already tweeted this?
                 if ($this->db->select('link_id')->from('links')->where('link_module', 'twitter')->where('link_parameter', $content['link_id'])->get()->num_rows() > 0) {
                     continue;
                 }
                 if (!isset($connection)) {
                     $connection = new TwitterOAuth(setting('twitter_consumer_key'), setting('twitter_consumer_secret'), setting('twitter_oauth_token'), setting('twitter_oauth_token_secret'));
                     cron_log('Connected to Twitter via OAuth.');
                 }
                 // build $status
                 // shorten URL
                 $CI->load->model('link_model');
                 $CI->load->helper('string');
                 $string = random_string('alnum', 5);
                 // make sure it's unique
                 $url_path = $CI->link_model->get_unique_url_path($string);
                 $url = site_url($url_path);
                 $this->load->model('twitter/bitly_model', 'bitly');
                 $bitlyUrl = $this->bitly->shorten_url($url);
                 if ($bitlyUrl) {
                     $url = $bitlyUrl;
                 }
                 // start with URL
                 $status = $url;
                 // how many characters remain?
                 $chars_remain = 140 - strlen($status);
                 // shorten title to fit before link
                 $CI->load->helper('shorten');
                 $shortened_title = shorten($content['title'], $chars_remain - 5, FALSE);
                 $shortened_title = str_replace('&hellip', '...', $shortened_title);
                 $status = $shortened_title . ' ' . $status;
                 // insert into links table
                 $CI->link_model->new_link($url_path, FALSE, $content['title'], 'Twitter Link', 'twitter', 'twitter', 'redirect', $content['link_id']);
                 //insert tweet content into tweets_sent
                 $this->twitter_log($status, $content['id'], $type);
                 cron_log('Posting status: ' . $status);
                 $result = $connection->post('statuses/update', array('status' => $status));
                 if ($connection->http_code != 200) {
                     cron_log('Connection to Twitter failed.  Exiting.');
                     return FALSE;
                 }
             }
         }
     }
     // update cron run
     $this->settings_model->update_setting('twitter_last_tweet', date('Y-m-d H:i:s'));
     return TRUE;
 }
예제 #29
0
            $recentTitle = shorten($l->title, $char) . '...';
        } else {
            $recentTitle = $l->title;
        }
        ?>
                                    <div class="item">
                                        <h3 class="title"><a href="<?php 
        echo $l->url;
        ?>
"><?php 
        echo $recentTitle;
        ?>
</a></h3>
                                        <div class="content">
                                        <p><?php 
        echo shorten($l->body, 75);
        ?>
...</p>
                                        <a class="more-link" href="<?php 
        echo $l->url;
        ?>
"><i class="fa fa-link"></i> Read more</a>
                                        </div><!--//content-->
                                    </div>
                                <?php 
    }
    ?>
                            </div>
                            <?php 
}
?>
예제 #30
0
 /**
  * Parse templatevar syndicate_description
  *
  * @param maxLength optional maximum length
  */
 function parse_syndicate_description($maxLength = 250, $addHighlight = 0)
 {
     $syndicated = strip_tags($this->currentItem->body);
     if ($addHighlight) {
         $tmp_highlight = htmlspecialchars(shorten($syndicated, $maxLength, '...'), ENT_QUOTES);
         echo $this->highlightAndParse($tmp_highlight);
     } else {
         echo htmlspecialchars(shorten($syndicated, $maxLength, '...'), ENT_QUOTES);
     }
 }