~ / Public Domain Software / AmDictionary PHP5 Class / More Instances $_
More Instances

Here is a more sophisticated example — two instances of the dictionary on the same page. Each of these instances is navigated independently. You can, for example, do search on the left while focusing on a single specific entry on the right.

In this specific case, both instances operate on the same set of entries, but there will be no significant difference if we connect these two (or even more) dictionaries to different data sources. AmDictionary Class can smoothly handle both several different dictionaries and several instances of the same dictionary on a single page. And vice versa, it can also run a single dictionary with its components dispersed among several webpages.

The appearance of dictionaries was slightly differentiated through parameters (remember that you can completely differentiate them by applying individual CSS skins). The right instance has no „Reverse Search” button, quotes in its index only part of an alphabet, and uses dash to separate a term from its definition. The instances also use different page navigators for long lists of entries. Click the „All Entries” category on both dictionaries and note at the bottom that the left dictionary uses navigator that includes links of all available pages while the right dictionary quotes only the current page.

At the current stage of development the AmDictionary PHP5 Class has nearly 50 parameters — full discussion will come in a document „AmDictionary PHP5 Class. Core Documentation And Manual”.

This example also demonstrates how to display default content (i.e. when nothing was requested; see code below). The left dictionary checks its own context and, finding that there is no context (FALSE), it displays a list of all entries. The right dictionary also checks the context in which it currently finds itself, but if no context is found then it displays the listing of „А” letter.

All entries in this example and others were rewritten from „Russian-English Dictionary — Русско-английский словарь”, Москва, Издательство „Русский язык”, 1978. Though it may be difficult to deal with, Russian was intentionally selected for the examples in order to emphasize interoperability of the presented software.

аист stork
апте||ка chemist’s shop; drug-store (амер.); ~карь chemist; druggist (амер); ~чка medicine chest (ящчичек с лекарствами); first-aid outfit (первой помощи)
болезнь illness; disease (определённая); душевная ~ mental disorder; ◊ морская ~ seasickness
больн||ой 1. прил. sick, ill; sore (об органах, частях тела); он болен he is ill; ~ая нога bad foot; ◊ ~ вопрос pressing problem; ~ое место tender (или sore) spot; 2. сущ. sick man; patient; invalid; in-patient (находящийся в больнице)
волнен||ие 1. emotion, agitation; нас охватило глубокое ~ we were in the grip of deep emotion; от ~ия он не мог говорить he was so moved he could not utter a word; 2. (народное) unrest, disturbance; 3.: ~ на море rough (или heavy) sea
горючее fuel; (для автомобиля тж.) petrol; gas (-oline) (амер.)
друг I friend; ~ детства playfellow
друг II ~ ~га each other; ~ за ~ом one after another; ~ против ~а (напротив) face to face; ~ с ~ом with each other
едини||ца 1. unit; 2. (цифра) one; 3. (отметка) bad mark; ~чный single, isolated
желан||ие wish, desire; ~ный desirable, long wished for
законодатель||ный legislative; ~ство legislation
законопроект bill; draft law
изгн||ание exile; ~анник exile; ~ать oust; banish; exile (отправить в ссылку)
количество quantity; amount (сумма); number (число)
леж||ать 1. lie; 2. (находиться) be; be situated (быть расположенным); где лежат газеты? where are the newspapers? ◊ на нём ~ит ответственность за... he is responsible for...; на ней ~ит всё хозяйство she has all the housekeeping on her hands; ~ачий recumbent
First Prev 1 2 3 Next Last
аист — stork
апте||ка — chemist’s shop; drug-store (амер.); ~карь chemist; druggist (амер); ~чка medicine chest (ящчичек с лекарствами); first-aid outfit (первой помощи)
AmDictionary PHP5 Class 1.0.0 RC. Copyright © 2008-2012 Aleksander Maksymiuk, http://setpro.net.pl/. This is a free software under the terms of the GNU General Public License.
<?php   /* core code of this example */

  if (!class_exists('AmDictionary')) {
    require('possible/path/amdictionary.class.php');
  }
  /* create */
  $left = new AmDictionary('left');
  $right = new AmDictionary('right');

  /* do some configuration */
  $left->SetParam('alphabet', '|А|Б|В|Г|Д|Е|Ж|З|И|К|Л|М|Н|О|П|Р|С|Т|У|Ф|Х|Ц|Ч|Ш|Щ|Ы|Э|Ю|Я');
  $left->SetParam('index_inline', FALSE);
  $left->SetParam('entry_inline', FALSE);
  $left->SetParam('navigator_brief', '');
  $right->SetParam('alphabet', '|А|Б|В|Г|Д|Е|Ж|З|И|К|Л|М|Н|О|П|Р|С|Т|У|Ф');
  $right->SetParam('search_reverse', FALSE);
  $right->SetParam('separator', ' — ');

  /* run (glue desired components together) */
  echo '<table width="100%"><tr valign="top">' .
    '<td width="5%">' .
      $left->BuildIndex() .
    '</td>' .
    '<td width="45%">' .
      $left->BuildSearch() .
      $left->BuildCatIndex() .
      ($left->Context() ? $left->BuildCatIndexList() : $left->BuildCatIndexList(ID_ALLENTRIES)) .
      $left->BuildIndexList() .
      $left->BuildSearchList() .
      $left->BuildEntry() .
    '</td>' .
    '<td width="50%">' .
      $right->BuildSearch() .
      $right->BuildCatIndex() .
      $right->BuildIndex() .
      $right->BuildCatIndexList() .
      ($right->Context() ? $right->BuildIndexList() : $right->BuildIndexList('А')) .
      $right->BuildSearchList() .
      $right->BuildEntry() .
    '</td>' .
  '</tr></table>' .
  $right->BuildDictInfo();

?>