/**
  * Acquire an array of single or multiple link texts from the query
  * this will be cached for later retrieval.
  * 
  * @see Usu_Main::query()
  * @uses trim()
  * 
  * @access protected
  * @return array array of link test 
  */
 protected function acquireLinkText()
 {
     if (false !== ($final_text_array = Usu_Main::i()->getVar('registry')->retrieve($this->key, $this->keys_index[$this->key]))) {
         if (Usu_Main::monitorPerformance()) {
             Usu_Main::$performance['queries_saved']++;
         }
         return $final_text_array;
     }
     $result = Usu_Main::i()->query($this->query);
     $text_array = tep_db_fetch_array($result);
     tep_db_free_result($result);
     if (false === $text_array) {
         return false;
     }
     $final_text_array = array();
     foreach ($text_array as $key => $text) {
         if (tep_not_null(trim($text))) {
             $final_text_array[$key] = $text;
         }
     }
     // We will cache this result
     Usu_Main::i()->getVar('registry')->attach($this->key, $this->keys_index[$this->key], $final_text_array);
     return $final_text_array;
 }
/**
 * Standard osCommerce tep_href_link() link wrapper function
 * @uses die()
 * @uses substr()
 * @uses strstr()
 * @uses str_replace()
 * 
 * 
 * @param string $page - base file name or sometimes a path
 * @param string $parameters - querystring parameters
 * @param string $connection - SSL / NONSSL
 * @param bool $add_session_id
 * @param bool $search_engine_safe
 * @return string - URL
 */
function osc_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true)
{
    global $request_type, $session_started, $SID;
    if (!tep_not_null($page)) {
        die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');
    }
    if ($connection == 'NONSSL') {
        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
    } elseif ($connection == 'SSL') {
        if (ENABLE_SSL == true) {
            $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
        } else {
            $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
        }
    } else {
        die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');
    }
    $multi_language_valid = true;
    if (false !== strpos($page, '/') || substr($page, -4, strlen($page)) != '.php') {
        $multi_language_valid = false;
    }
    if (tep_not_null($parameters)) {
        $link .= $page;
        $link .= ($multi_language_valid ? usu5_multi_language('left') : null) . '?' . tep_output_string($parameters);
        $separator = '&';
    } else {
        $link .= $page;
        $link .= $multi_language_valid ? usu5_multi_language('left') : null;
        $separator = '?';
    }
    while (substr($link, -1) == '&' || substr($link, -1) == '?') {
        $link = substr($link, 0, -1);
    }
    // Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
    if ($add_session_id == true && $session_started == true && SESSION_FORCE_COOKIE_USE == 'False') {
        if (tep_not_null($SID)) {
            $_sid = $SID;
        } elseif ($request_type == 'NONSSL' && $connection == 'SSL' && ENABLE_SSL == true || $request_type == 'SSL' && $connection == 'NONSSL') {
            if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
                $_sid = tep_session_name() . '=' . tep_session_id();
            }
        }
    }
    if (SEARCH_ENGINE_FRIENDLY_URLS == 'true' && $search_engine_safe == true) {
        while (strstr($link, '&&')) {
            $link = str_replace('&&', '&', $link);
        }
        $link = str_replace('?', '/', $link);
        $link = str_replace('&', '/', $link);
        $link = str_replace('=', '/', $link);
        $separator = '?';
    }
    if (isset($_sid)) {
        $link .= $separator . tep_output_string($_sid);
    }
    // Remove index.php from the link when it is www.mysite.com/index.php
    if (false !== do_homepage_redirect($link)) {
        $link = str_replace(FILENAME_DEFAULT, '', $link);
    }
    if (Usu_Main::monitorPerformance()) {
        Usu_Main::$performance['std_urls']++;
        Usu_Main::$performance['std_url_array'][] = $link;
    }
    switch (defined('USU5_USE_W3C_VALID') && USU5_USE_W3C_VALID == 'true') {
        case true:
            return htmlspecialchars(utf8_encode($link));
            break;
        default:
            return $link;
            break;
    }
    return $link;
}