Beispiel #1
0
function isItalian()
{
    if ("IT" == localize()) {
        return true;
    }
    return false;
}
Beispiel #2
0
 public function testLocalizeUnknown()
 {
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "aa";
     $this->assertEquals("Authors", localize("authors.title", -1, true));
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en";
     localize("authors.title", -1, true);
 }
Beispiel #3
0
 function echo_loc2($buf) {
//  if ($_GET['test']!='1') {
//   echo ($buf);
//  } else {
   echo (localize($buf));
//  }
 }
Beispiel #4
0
 public static function getAllAuthorsByFirstLetter()
 {
     list(, $result) = parent::executeQuery("select {0}\nfrom authors\ngroup by substr (upper (sort), 1, 1)\norder by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array(), -1);
     $entryArray = array();
     while ($post = $result->fetchObject()) {
         array_push($entryArray, new Entry($post->title, Author::getEntryIdByLetter($post->title), str_format(localize("authorword", $post->count), $post->count), "text", array(new LinkNavigation("?page=" . parent::PAGE_AUTHORS_FIRST_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count));
     }
     return $entryArray;
 }
Beispiel #5
0
 public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
 {
     $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
     $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
     list($totalNumber, $result) = parent::executeQuery($sql, $columns, "", array('%' . $query . '%'), $n, $database, $numberPerPage);
     $entryArray = array();
     while ($post = $result->fetchObject()) {
         $tag = new Tag($post);
         array_push($entryArray, new Entry($tag->name, $tag->getEntryId(), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation($tag->getUri()))));
     }
     return array($entryArray, $totalNumber);
 }
Beispiel #6
0
 public static function getEntryArray($query, $params)
 {
     list(, $result) = parent::executeQuery($query, self::RATING_COLUMNS, "", $params, -1);
     $entryArray = array();
     while ($post = $result->fetchObject()) {
         $ratingObj = new Rating($post->id, $post->rating);
         $rating = $post->rating / 2;
         $rating = str_format(localize("ratingword", $rating), $rating);
         array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation($ratingObj->getUri())), "", $post->count));
     }
     return $entryArray;
 }
Beispiel #7
0
    public static function getAllLanguages()
    {
        $result = parent::getDb()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count
from languages, books_languages_link
where languages.id = books_languages_link.lang_code
group by languages.id, books_languages_link.lang_code
order by languages.lang_code');
        $entryArray = array();
        while ($post = $result->fetchObject()) {
            $language = new Language($post->id, $post->lang_code);
            array_push($entryArray, new Entry(Language::getLanguageString($language->lang_code), $language->getEntryId(), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation($language->getUri())), "", $post->count));
        }
        return $entryArray;
    }
Beispiel #8
0
}
$mail->SMTPAuth = !empty($config['cops_mail_configuration']["smtp.username"]);
if (!empty($config['cops_mail_configuration']["smtp.username"])) {
    $mail->Username = $config['cops_mail_configuration']["smtp.username"];
}
if (!empty($config['cops_mail_configuration']["smtp.password"])) {
    $mail->Password = $config['cops_mail_configuration']["smtp.password"];
}
if (!empty($config['cops_mail_configuration']["smtp.secure"])) {
    $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"];
}
$mail->From = $config['cops_mail_configuration']["address.from"];
$mail->FromName = $config['cops_title_default'];
foreach (explode(";", $emailDest) as $emailAddress) {
    if (empty($emailAddress)) {
        continue;
    }
    $mail->AddAddress($emailAddress);
}
$mail->AddAttachment($data->getLocalPath());
$mail->IsHTML(true);
$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename();
$mail->Body = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName() . "</h2>" . $book->getComment();
$mail->AltBody = "Sent by COPS";
if (!$mail->Send()) {
    echo localize("mail.messagenotsent");
    echo 'Mailer Error: ' . $mail->ErrorInfo;
    exit;
}
echo localize("mail.messagesent");
Beispiel #9
0
 /**
  * @dataProvider providerGetAcceptLanguages
  */
 public function testGetAcceptLanguages($acceptLanguage, $result)
 {
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $acceptLanguage;
     $langs = array_keys(GetAcceptLanguages());
     $this->assertEquals($result, $langs[0]);
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en";
     localize("authors.title", -1, true);
 }
Beispiel #10
0
 public static function getAllBooks()
 {
     list(, $result) = parent::executeQuery("select {0}\nfrom books\ngroup by substr (upper (sort), 1, 1)\norder by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", self::getFilterString(), array(), -1);
     $entryArray = array();
     while ($post = $result->fetchObject()) {
         array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation("?page=" . parent::PAGE_ALL_BOOKS_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count));
     }
     return $entryArray;
 }
Beispiel #11
0
 public function getCustomByBook($book)
 {
     $queryFormat = "SELECT {0}.id AS id, {0}.value AS value FROM {0} WHERE {0}.book = {1}";
     $query = str_format($queryFormat, $this->getTableName(), $book->id);
     $result = $this->getDb()->query($query);
     if ($post = $result->fetchObject()) {
         return new CustomColumn($post->id, $post->value, $this);
     }
     return new CustomColumn(NULL, localize("customcolumn.float.unknown"), $this);
 }
Beispiel #12
0
 private function startXmlDocument($page)
 {
     global $config;
     self::getXmlStream()->startDocument('1.0', 'UTF-8');
     self::getXmlStream()->startElement("feed");
     self::getXmlStream()->writeAttribute("xmlns", "http://www.w3.org/2005/Atom");
     self::getXmlStream()->writeAttribute("xmlns:xhtml", "http://www.w3.org/1999/xhtml");
     self::getXmlStream()->writeAttribute("xmlns:opds", "http://opds-spec.org/2010/catalog");
     self::getXmlStream()->writeAttribute("xmlns:opensearch", "http://a9.com/-/spec/opensearch/1.1/");
     self::getXmlStream()->writeAttribute("xmlns:dcterms", "http://purl.org/dc/terms/");
     self::getXmlStream()->startElement("title");
     self::getXmlStream()->text($page->title);
     self::getXmlStream()->endElement();
     if ($page->subtitle != "") {
         self::getXmlStream()->startElement("subtitle");
         self::getXmlStream()->text($page->subtitle);
         self::getXmlStream()->endElement();
     }
     self::getXmlStream()->startElement("id");
     if ($page->idPage) {
         $idPage = $page->idPage;
         if (!is_null(GetUrlParam(DB))) {
             $idPage = str_replace("cops:", "cops:" . GetUrlParam(DB) . ":", $idPage);
         }
         self::getXmlStream()->text($idPage);
     } else {
         self::getXmlStream()->text($_SERVER['REQUEST_URI']);
     }
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("updated");
     self::getXmlStream()->text(self::getUpdatedTime());
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("icon");
     self::getXmlStream()->text($page->favicon);
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("author");
     self::getXmlStream()->startElement("name");
     self::getXmlStream()->text($page->authorName);
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("uri");
     self::getXmlStream()->text($page->authorUri);
     self::getXmlStream()->endElement();
     self::getXmlStream()->startElement("email");
     self::getXmlStream()->text($page->authorEmail);
     self::getXmlStream()->endElement();
     self::getXmlStream()->endElement();
     $link = new LinkNavigation("", "start", "Home");
     self::renderLink($link);
     $link = new LinkNavigation("?" . getQueryString(), "self");
     self::renderLink($link);
     $urlparam = "?";
     if (!is_null(GetUrlParam(DB))) {
         $urlparam = addURLParameter($urlparam, DB, GetUrlParam(DB));
     }
     if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) {
         // Good and compliant way of handling search
         $urlparam = addURLParameter($urlparam, "page", Base::PAGE_OPENSEARCH);
         $link = new Link("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here");
     } else {
         // Bad way, will be removed when OPDS client are fixed
         $urlparam = addURLParameter($urlparam, "query", "{searchTerms}");
         $urlparam = str_replace("%7B", "{", $urlparam);
         $urlparam = str_replace("%7D", "}", $urlparam);
         $link = new Link($config['cops_full_url'] . 'feed.php' . $urlparam, "application/atom+xml", "search", "Search here");
     }
     self::renderLink($link);
     if ($page->containsBook() && !is_null($config['cops_books_filter']) && count($config['cops_books_filter']) > 0) {
         $Urlfilter = getURLParam("tag", "");
         foreach ($config['cops_books_filter'] as $lib => $filter) {
             $link = new LinkFacet("?" . addURLParameter(getQueryString(), "tag", $filter), $lib, localize("tagword.title"), $filter == $Urlfilter);
             self::renderLink($link);
         }
     }
 }
Beispiel #13
0
  function fillObjectDetails($loop, $rec) {
//   ajax_echo_r ($rec);
   $vars = $loop->getVariables();
//   ajax_echo_r ($vars);
   foreach ($vars as $var) {
    if ($var) {
     $loop->fill(       "%".$var."%" , $rec->$var);
    }
   }
   
   $loop->processfcb('');
   $loop->fill(  '%imgfolder%' , $this->imgfolder          );
   $loop->fill(   '%viewroot%' , $this->viewroot           );
   return localize($loop->output());
  }
Beispiel #14
0
         $headerdirection = $textdir["tableheading"][$file];
     } elseif ($strings["tablealias"][$file] != "") {
         $heading = $strings["tablealias"][$file];
         // Also used below for h2
         $headerdirection = $textdir["tablealias"][$file];
     } else {
         localize(1);
         $heading = $file;
         // Also used below for h2
         $headerdirection = $textdir["browserfile"];
         $dontlocalizeagain = 1;
         // Just spare the running of an extra function (since it was already (by necessity) run within this else)--see the "if" just below
     }
     // end else (if there is no heading or alias set for the specific table--having this option allows titles to appear with the table name (in some form at least), even if a localization was not set (or if it was not set because the name is intended to be the heading))
     if (!$dontlocalizeagain) {
         localize(1);
         // Go back to the localization for the user's choice of language
     }
     // end if (if need to localize again)
 }
 // end else (if there is no heading or alias in the given language)
 // This will be overwritten in browse9.php if there is a file defined
 $title = $strings["browserfile"] . ": " . $heading;
 // Call header function to add XHTML headers
 // If no file is set, refer the user back to the main page.
 if (!$file) {
     headerAdd($charset, $defaultlanguage, $title, $headerdirection, "", $style);
     delaytime(0, $browserfile);
 }
 // end if (if there is no file defined, redirect the user back to the main page)
 // Get table metadata such as:
Beispiel #15
0
 function getMessage($id) {
  $tmp = new Template($this->viewroot,'messages.htt');
  $tmp->loadloop("block_".$id);
  $tmp->fill('%imgfolder%', getrootdir().$this->imgfolder);
  return localize($tmp->output());
 }
Beispiel #16
0
/**
 * Retrieves the translated $phrase in $locale (when available), 
 * the original $phrase otherwise.
 */
function __L($phrase, $locale = null)
{
    return localize($phrase, $locale);
}
Beispiel #17
0
 /**
  * Converts any value to a string to become part of a rendered template. This
  * means escaping, if required, and conversion to a unicode object. If value
  * is a string, it is expected to have already been translated.
  *
  * @static
  *
  * @param $value
  * @param $context
  *
  * @return SafeString|string
  */
 public static function renderValueInContext($value, $context)
 {
     $value = dja_localtime($value, $context->use_tz);
     $value = localize($value, $context->use_l10n);
     if ($context->autoescape && !$value instanceof SafeData || $value instanceof EscapeData) {
         return escape($value);
     } else {
         return $value;
     }
 }
Beispiel #18
0
 public static function addCompleteArray($in)
 {
     global $config;
     $out = $in;
     $out["c"] = array("version" => VERSION, "i18n" => array("coverAlt" => localize("i18n.coversection"), "authorsTitle" => localize("authors.title"), "bookwordTitle" => localize("bookword.title"), "tagsTitle" => localize("tags.title"), "seriesTitle" => localize("series.title"), "customizeTitle" => localize("customize.title"), "aboutTitle" => localize("about.title"), "previousAlt" => localize("paging.previous.alternate"), "nextAlt" => localize("paging.next.alternate"), "searchAlt" => localize("search.alternate"), "sortAlt" => localize("sort.alternate"), "homeAlt" => localize("home.alternate"), "cogAlt" => localize("cog.alternate"), "permalinkAlt" => localize("permalink.alternate"), "publisherName" => localize("publisher.name"), "pubdateTitle" => localize("pubdate.title"), "languagesTitle" => localize("language.title"), "contentTitle" => localize("content.summary"), "sortorderAsc" => localize("search.sortorder.asc"), "sortorderDesc" => localize("search.sortorder.desc"), "customizeEmail" => localize("customize.email")), "url" => array("detailUrl" => "index.php?page=13&id={0}&db={1}", "coverUrl" => "fetch.php?id={0}&db={1}", "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"), "config" => array("use_fancyapps" => $config["cops_use_fancyapps"], "max_item_per_page" => $config['cops_max_item_per_page'], "kindleHack" => "", "server_side_rendering" => useServerSideRendering(), "html_tag_filter" => $config['cops_html_tag_filter']));
     if ($config['cops_thumbnail_handling'] == "1") {
         $out["c"]["url"]["thumbnailUrl"] = $out["c"]["url"]["coverUrl"];
     } else {
         if (!empty($config['cops_thumbnail_handling'])) {
             $out["c"]["url"]["thumbnailUrl"] = $config['cops_thumbnail_handling'];
         }
     }
     if (preg_match("/./", $_SERVER['HTTP_USER_AGENT'])) {
         $out["c"]["config"]["kindleHack"] = 'style="text-decoration: none !important;"';
     }
     return $out;
 }
Beispiel #19
0
					if ($tablealias != '') {
						$option_array[$tablelist_counter]['text'] = $tablealias;
						$option_array[$tablelist_counter]['dir'] = $textdirec;
					} // end elseif (if there is at least a specified heading for the table in the default language)

					elseif ($tableheading != '') {
						$option_array[$tablelist_counter]['text'] = $tableheading;
						$option_array[$tablelist_counter]['dir'] = $textdirec;
					} // end elseif (if there is at least a specified alias for the table in the default language)

					else {
						$option_array[$tablelist_counter]['text'] = $row2[0];
						$option_array[$tablelist_counter]['dir'] = $default_lang_direction;
					} // end else (if there is no table alias)

					localize(1); // Go back to the localization for the user's choice of language

				} // end else (if there is no table alias or table heading in the user's language)
			
				$tablelist_counter++;
			} // end if
		} // end foreach (of all the tables being added to the drop-down menu)

		// Run function to sort a multidimensional array (the 2nd dimension only) by a specified field
		$option_mult_arr[] = fieldSort($option_array, 'text');

		$advancedaccessno = $accesskeynobutton - 1;
		$advancedaccess = chr($advancedaccessno);
		if ($advancedaccessno >= 106) {
			$advancedaccess = "accesskey=\"".$advancedaccess."\"";
		} // end if (if the letters are still greater than the last possible ("j"), give an accesskey)
Beispiel #20
0
 public static function getEntryArrayWithBookNumber($query, $columns, $params, $category)
 {
     list(, $result) = self::executeQuery($query, $columns, "", $params, -1);
     $entryArray = array();
     while ($post = $result->fetchObject()) {
         $instance = new $category($post);
         if (property_exists($post, "sort")) {
             $title = $post->sort;
         } else {
             $title = $post->name;
         }
         array_push($entryArray, new Entry($title, $instance->getEntryId(), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation($instance->getUri())), "", $post->count));
     }
     return $entryArray;
 }
Beispiel #21
0
 function ajax_echo($txt) {            // used to solve some ajax output problems on Unix systems if any (usually if the UTF-8 and Windows-1251 meets together)
  echo localize(cfstrconv($txt));
 }
Beispiel #22
0
  function fillSubtables($ret, $subtables, $subcolumns) {
   foreach ($subtables as $subtable) {
    $sql = "SELECT * FROM `".$subtable."`;";
    $$subtable = $this->db->query_assoc($sql, 'ID');
   }
   
//   ajax_echo_r ($subcolumns);
   
   foreach ($ret as $item) {
    for ($i=0; $i<sizeof($subcolumns); $i++) {
//     echo $subcolumns[$i]."-";
//     echo $item->$subcolumns[$i]."<br>";
     $st = $$subtables[$i];
//     ajax_echo_r ($st[3]);
//     return 1;
     if ($subtables[$i]=='users') {
      $item->$subcolumns[$i] = $st[$item->$subcolumns[$i]]->Firstname." ".$st[$item->$subcolumns[$i]]->Surname;
     } else {
      $item->$subcolumns[$i] = localize($st[$item->$subcolumns[$i]]->Description);
     }
     
//     echo $item->$subcolumns[$i]."<br>";
//     return false;
    }
   }
   
   return $ret;
  }
Beispiel #23
0
    public static function getAllCustoms($customId)
    {
        $result = parent::getDb()->query(str_format('select {0}.id as id, {0}.value as name, count(*) as count
from {0}, {1}
where {0}.id = {1}.{2}
group by {0}.id, {0}.value
order by {0}.value', self::getTableName($customId), self::getTableLinkName($customId), self::getTableLinkColumn($customId)));
        $entryArray = array();
        while ($post = $result->fetchObject()) {
            $customColumn = new CustomColumn($post->id, $post->name, $customId);
            array_push($entryArray, new Entry($customColumn->name, $customColumn->getEntryId(), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation($customColumn->getUri())), "", $post->count));
        }
        return $entryArray;
    }