cvs: phpdoc-sl /language oop.xml

[email protected] ("Dejan Markic") Sun, 12 Jan 2003 20:45:49 -0000
Newsgroups php.doc.sl
Message-ID <cvsdejan1042404349@cvsserver>
dejan		Sun Jan 12 15:45:49 2003 EDT

  Modified files:              
    /phpdoc-sl/language	oop.xml 
  Log:
  Started to work on this one.
dejan-20030112154549.txt (text/plain, 12.4 KB)
Index: phpdoc-sl/language/oop.xml
diff -u phpdoc-sl/language/oop.xml:1.1 phpdoc-sl/language/oop.xml:1.2
--- phpdoc-sl/language/oop.xml:1.1	Wed Sep  4 10:02:42 2002
+++ phpdoc-sl/language/oop.xml	Sun Jan 12 15:45:49 2003
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
 <!-- $EN-Revision: 1.36 Maintainer: dejan Status: working -->
  <chapter id="language.oop">
-  <title>Classes and Objects</title>
+  <title>Razredi in objekti</title>
 
   <sect1 id="keyword.class">
-   <title><literal>class</literal></title>
+   <title><literal>razred</literal></title>
    <para>
-    A class is a collection of variables and functions working with
-    these variables.  A class is defined using the following syntax:
+    Razred je zbirka spremenljivk in funkcij, ki delajo s temi spremenljivkami.
+    razred definiramo z naslednjo sintakso:
  
     <informalexample>
      <programlisting role="php">
@@ -44,50 +44,48 @@
    </para>
  
    <para>
-    This defines a class named Cart that consists of an associative
-    array of articles in the cart and two functions to add and remove
-    items from this cart.
+    Zgornje definira razred z imenom Cart, ki ga sestavlja asociativna 
+    tabela artiklov in dve funkciji za dodajanje in odstranjevanje 
+    predmetov.
    </para>
 
    <caution>
     <simpara>
-     The following cautionary notes are valid for PHP 4.
+     Naslednja opozorila so veljavna za PHP 4.
     </simpara>
     
     <simpara>
-     The name <literal>stdClass</literal> is used interally by
-     Zend and is reserved. You cannot have a class named
-     <literal>stdClass</literal> in PHP.
+     Ime <literal>stdClass</literal> uporablja Zend interno in je zato 
+     zasedeno. Uporaba razreda, ki ima ime <literal>stdClass</literal>, 
+     v PHP-ju ni mo&#382;na.
     </simpara>
     
     <simpara>
-      The function names <literal>__sleep</literal> and
-      <literal>__wakeup</literal> are magical in PHP classes. You
-      cannot have functions with these names in any of your
-      classes unless you want the magic functionality associated
-      with them. See below for more information.
+      Funkciji <literal>__sleep</literal> in <literal>__wakeup</literal> sta
+      posebni funkciji v PHP razredih. Funkcije s tem imenom ne morate imeti v
+       va&#353;ih razredih, razen &#269;e bi radi uporabili njuno posebno 
+       funkcionalnost. Spodaj se nahaja ve&#269; informacij.
     </simpara>
     
     <simpara>
-      PHP reserves all function names starting with __ as magical.
-      It is recommended that you do not use function names with
-      __ in PHP unless you want some documented magic functionality.
+      PHP si je rezervilal vse funkcije ki se pri&#269;nejo z __ kot posebne. 
+      Priporo&#269;ljivo je, da ne uporabljate funkcij z __ razen &#269;e bi 
+      radi uporabili kak&353;o od dokumentiranih funkcionalnosti.
     </simpara>
    </caution>
 
    <note>
     <simpara>
-     In PHP 4, only constant initializers for <literal>var</literal>
-     variables are allowed. To initialize variables with non-constant
-     values, you need an initialization function which is called
-     automatically when an object is being constructed from the
-     class. Such a function is called a constructor (see below).
+     V PHP 4 so dovoljeni samo initializatorji konstant <literal>var</literal>
+     Da bi inicializirali spremenljivko z ne-konstantno vrednostjo, morate imeti
+     inicializacijsko fukcijo, ki je klicana avtomati&#269;no ko kreiramo objekt 
+     iz razreda. Taka funkcija se imenuje konstruktor (poglejte spodaj).
     </simpara>
     <informalexample>
      <programlisting role="php">
 <![CDATA[
 <?php
-/* None of these will work in PHP 4. */
+/* Nic od tega ne bo delalo v PHP 4. */
 class Cart
 {
     var $todays_date = date("Y-m-d");
@@ -96,7 +94,7 @@
     var $items = array("VCR", "TV");
 }
 
-/* This is how it should be done. */
+/* To je pravilen postopek. */
 class Cart
 {
     var $todays_date;
@@ -108,7 +106,7 @@
     {
         $this->todays_date = date("Y-m-d");
         $this->name = $GLOBALS['firstname'];
-        /* etc. . . */
+        /* itd. . . */
     }
 }
 ?>
@@ -118,9 +116,8 @@
    </note>
 
    <para>
-    Classes are types, that is, they are blueprints for actual
-    variables. You have to create a variable of the desired type with
-    the <literal>new</literal> operator.
+    Razredi so tipi, ubistvu so na&#269;rti za dejanske spremenljivke. Vi morate 
+    ustvariti spremenljivko &#382;eljenega tipa z operatorjem <literal>new</literal>. 
    </para>
  
    <informalexample>
@@ -137,41 +134,38 @@
    </informalexample>
  
    <para>
-    This creates the objects $cart and $another_cart, both of
-    the class Cart. The function add_item() of the $cart object
-    is being called to add 1 item of article number 10 to the
-    $cart. 3 items of article number 0815 are being added to
-    $another_cart.
+    To ustvari objekta $cart in $another_cart, oba razreda Cart. Funkcija 
+    add_item() $cart objekta je klicana za dodajanje enega predmeta, ki ima 
+    &#353;tevilko artikla 10, v objekt $cart. Trije predmeti, ki imajo &#353tevilko 
+    artikla 0815 so dodani v $another_cart.
    </para>
    
    <para>
-    Both, $cart and $another_cart, have functions add_item(),
-    remove_item() and a variable items. These are distinct
-    functions and variables. You can think of the objects as
-    something similar to directories in a filesystem. In a
-    filesystem you can have two different files README.TXT, as
-    long as they are in different directories.  Just like with
-    directories where you'll have to type the full pathname in
-    order to reach each file from the toplevel directory, you
-    have to specify the complete name of the function you want
-    to call: In PHP terms, the toplevel directory would be the
-    global namespace, and the pathname separator would be -&gt;. 
-    Thus, the names $cart-&gt;items and $another_cart-&gt;items
-    name two different variables. Note that the variable is
-    named $cart-&gt;items, not $cart-&gt;$items, that is, a
-    variable name in PHP has only a single dollar sign.
+    Oba objekta, $cart in $another_cart imata funkciji add_item(), 
+    remove_item in spremenljivke. To so razli&#269;ne funkcije in 
+    spremenljivke. Objekte si lahko predstavljate kot direktorije v 
+    datote&#269;nem sistemu. V datote&#269;nem sistemu imate lahko dve 
+    razli&#269:ni datoteki README.TXT dokler sta ti dve datoteki vsaka v 
+    svojem direktoriju. Tako kot pri direktorijih, kjer morate vpisati celotno 
+    pot iz vrhovnega direktorija, morate tu uporabiti celotno ime funkcije ki jo 
+    &#382;elite klicati. V PHP-ju bi bil vrhovni direktorij globalni imenski 
+    prostor in lo&#269;ilec za direktorije -&gt;. 
+    Tako so imena $vart-&gt;items in $another_cart-&gt;items 
+    imena za dve razli&#269;ni spremenljivki. Zapomnite si da je spremenljivka 
+    imenovana $vart-&gt;items in ne $cart-&gt;$items.  To poemni, da ima 
+    spremenljivka v PHP-ju samo en dolar znak.
    </para>
 
    <informalexample>
     <programlisting role="php">
 <![CDATA[
-// correct, single $
+// pravilno, enojni $
 $cart->items = array("10" => 1); 
 
-// invalid, because $cart->$items becomes $cart->""
+// napacno, ker $cart->$items postane $cart->""
 $cart->$items = array("10" => 1);
 
-// correct, but may or may not be what was intended:
+// pravilno, ce je to kar ste zeleli:
 // $cart->$myvar becomes $cart->items
 $myvar = 'items';
 $cart->$myvar = array("10" => 1);  
@@ -180,24 +174,21 @@
    </informalexample>
 
    <para>
-    Within a class definition, you do not know under which name the object will
-    be accessible in your program: at the time the Cart class was 
-    written, it was unknown that the object will be named $cart or
-    $another_cart later. Thus, you cannot write $cart-&gt;items within
-    the Cart class itself. Instead, in order to be able to access it's own
-    functions and variables from within a class, one can use the
-    pseudo-variable $this which can be read as 'my own' or
-    'current object'. Thus, '$this-&gt;items[$artnr] += $num' can
-    be read as 'add $num to the $artnr counter of my own items
-    array' or 'add $num to the $artnr counter of the items array
-    within the current object'.
+    V definiciji razreda nevemo pod kaksnim imenom bo objekt dostopen v nasem programu: 
+    v trenutku, ko smo pisali razred Cart, ime objekta #cart ali $another_cart 
+    ni bilo zmano. Torej ne morate pisati $cart-&gt;items v samem Cart razredu. 
+    Namesto tega, &#269;e &#382;elimo dostopati do funkcij in spremenljivk 
+    razreda v razredu samem, uporabimo izmi&#353;ljeno spremenljivko $this, ki si 
+    jo lahko predstavljamo kot 'moje' ali 'trenutni objekt'. Torej bi 
+    '$this-&gt;items[$artnr] += $num' lahko prebrali kot 'dodaj $num k $artnr 
+    &#353;tevcu v moji tabeli predmetov' ali 'dodaj $num k $artnr &#353;tevcu 
+    v tabeli predmetov v trenutnem objektu'. 
    </para>
 
    <note>
     <para>
-    There are some nice functions to handle classes and objects. You might want
-    to take a look at the <link linkend="ref.classobj">Class/Object
-    Functions</link>
+    Obstaja kar nekaj zanimivh funkcij za upravljanje razredov in objektov. Oglejte 
+    si <link linkend="ref.classobj">Razredne/Objektne Funkcije</link>
     </para>
    </note>
   </sect1>
@@ -206,19 +197,18 @@
    <title><literal>extends</literal></title>
 
    <para>
-    Often you need classes with similar variables and functions
-    to another existing class. In fact, it is good practice to
-    define a generic class which can be used in all your
-    projects and adapt this class for the needs of each of your
-    specific projects. To facilitate this, classes can be
-    extensions of other classes.  The extended or derived class
-    has all variables and functions of the base class (this is
-    called 'inheritance' despite the fact that nobody died) and what
-    you add in the extended definition. It is not possible to
-    substract from a class, that is, to undefine any existing 
-    functions or variables. An extended class is always dependent
-    on a single base class, that is, multiple inheritance is
-    not supported. Classes are extended using the keyword 'extends'.
+    Velikokrat potrebujete razrede s podobnimi spremenljivkami in 
+    funkcijami v drugem obstoje&#269;em razredu. Pravzaprav je dobra 
+    praksa definirati splo&#353;ni razred, ki ga lahko uporabite v vseh 
+    va&#353;ih projektih in ga prilagajate vsakemu va&#353;emu 
+    specifi&#269;nem projektu. Da si olaj&#353;ate to delo, so razredi 
+    lahko raz&#353;iritev drugih razredov. Raz&#353;irjen ali izpeljan 
+    razred ima vse funkcije in spremenljivke osnovnega razreda 
+    (temu re&#353;emo 'podedovanje', &#353;eprav ni nih&#353;e umrl) in 
+    kar mu dodate v extends definiciji. Odstranjevanje funkcij ali 
+    spremenljivk ni mo&#382;no, torej da bi izbrisali kaksno obstoje&#269;o 
+    funkcijo ali spremenljivko. Raz&#353;irjeni razred je vedno odvisen od 
+    osnovnega razreda. Razredi so raz&#353;irjeni z uporabo 'extends'. 
    </para>
  
    <informalexample>
@@ -238,20 +228,20 @@
    </informalexample>
  
    <para>
-    This defines a class Named_Cart that has all variables and
-    functions of Cart plus an additional variable $owner and an
-    additional function set_owner(). You create a named cart the usual
-    way and can now set and get the carts owner. You can still use
-    normal cart functions on named carts:
+    Zgornje definira razred Named_Cart, ki ima vse spremenljivke in 
+    funkcije razreda Cart in dodatno spremenljivko $owner in dodatno 
+    funkcijo set_owner(). 'Named cart' ustvarite normalno in lahko 
+    sedaj nastavite ali dobite vrednost $owner. Seveda lahko uporabite vse 
+    funkcije in spremenljivke Cart razreda:
    </para>
  
    <informalexample>
     <programlisting role="php">
 <![CDATA[
-$ncart = new Named_Cart;    // Create a named cart
-$ncart->set_owner("kris");  // Name that cart
-print $ncart->owner;        // print the cart owners name
-$ncart->add_item("10", 1);  // (inherited functionality from cart)
+$ncart = new Named_Cart;    // Ustvari objekt Named_Cart razreda
+$ncart->set_owner("kris");  // Uporabimo fukcijo v Named_Cart razredu
+print $ncart->owner;        // Uporabimo spremenljivko v Named_Cart razredu
+$ncart->add_item("10", 1);  // (podedovana funkcionalnost iz Cart razreda)
 ]]>
     </programlisting>
    </informalexample>