[TEP-COMMIT] [CVS catalog] update the language class somewhat (more updates pending)

hpdl-OfajU3CKLf1/[email protected] 20 Nov 2004 02:11:48 -0000
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>catalog/catalog/includes/classes</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">language.php</a></tt></td><td align="right" id="added">+34</td><td align="right" id="removed">-5</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/language.php?rev=1.7&amp;content-type=text/vnd.viewcvs-markup">1.7</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/language.php.diff?r1=1.7&amp;r2=1.8">-&gt;</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/language.php?rev=1.8&amp;content-type=text/vnd.viewcvs-markup">1.8</a></td></tr>
</table>
<pre class="comment">
update the language class somewhat (more updates pending)

now caches the language database query result set
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes">classes</a><br /></span>
<div class="fileheader"><big><b>language.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/language.php?rev=1.7&amp;content-type=text/vnd.viewcvs-markup">1.7</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/language.php.diff?r1=1.7&amp;r2=1.8">-&gt;</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/classes/language.php?rev=1.8&amp;content-type=text/vnd.viewcvs-markup">1.8</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.7 -r1.8
--- language.php	2004/02/16 07:08:16	1.7
+++ language.php	2004/11/20 02:11:47	1.8
@@ -59,13 +59,15 @@
</small></pre><pre class="diff" id="context"> 
       $this-&gt;catalog_languages = array();
 
</pre><pre class="diff" id="removed">-      $Qlanguages = $osC_Database-&gt;query('select languages_id, name, code, image, directory from :table_languages order by sort_order');
-      $Qlanguages-&gt;bindRaw(':table_languages', TABLE_LANGUAGES);
</pre><pre class="diff" id="added">+      $Qlanguages = $osC_Database-&gt;query('select * from :table_languages order by sort_order, name');
+      $Qlanguages-&gt;bindTable(':table_languages', TABLE_LANGUAGES);
+      $Qlanguages-&gt;setCache('languages');
</pre><pre class="diff" id="context">       $Qlanguages-&gt;execute();
 
       while ($Qlanguages-&gt;next()) {
         $this-&gt;catalog_languages[$Qlanguages-&gt;value('code')] = array('id' =&gt; $Qlanguages-&gt;valueInt('languages_id'),
                                                                      'name' =&gt; $Qlanguages-&gt;value('name'),
</pre><pre class="diff" id="added">+                                                                     'code' =&gt; $Qlanguages-&gt;value('code'),
</pre><pre class="diff" id="context">                                                                      'image' =&gt; $Qlanguages-&gt;value('image'),
                                                                      'directory' =&gt; $Qlanguages-&gt;value('directory'));
       }
</pre><pre class="diff"><small id="info">@@ -79,10 +81,21 @@
</small></pre><pre class="diff" id="context">     }
 
     function set_language($language) {
</pre><pre class="diff" id="removed">-      if ( (tep_not_null($language)) &amp;&amp; (isset($this-&gt;catalog_languages[$language])) ) {
-        $this-&gt;language = $this-&gt;catalog_languages[$language];
</pre><pre class="diff" id="added">+      global $osC_Session;
+
+      if (empty($language) &amp;&amp; $osC_Session-&gt;exists('language')) {
+        foreach ($this-&gt;catalog_languages as $l) {
+          if ($l['directory'] == $osC_Session-&gt;value('language')) {
+            $language = $l['code'];
+            break;
+          }
+        }
+      }
+
+      if (!empty($language) &amp;&amp; $this-&gt;exists($language)) {
+        $this-&gt;language = $this-&gt;get($language);
</pre><pre class="diff" id="context">       } else {
</pre><pre class="diff" id="removed">-        $this-&gt;language = $this-&gt;catalog_languages[DEFAULT_LANGUAGE];
</pre><pre class="diff" id="added">+        $this-&gt;language = $this-&gt;get(DEFAULT_LANGUAGE);
</pre><pre class="diff" id="context">       }
     }
 
</pre><pre class="diff"><small id="info">@@ -98,6 +111,22 @@
</small></pre><pre class="diff" id="context">           }
         }
       }
</pre><pre class="diff" id="added">+    }
+
+    function get($language) {
+      return $this-&gt;catalog_languages[$language];
+    }
+
+    function getAll() {
+      return $this-&gt;catalog_languages;
+    }
+
+    function exists($language) {
+      if (isset($this-&gt;catalog_languages[$language])) {
+        return true;
+      }
+
+      return false;
</pre><pre class="diff" id="context">     }
   }
 ?&gt;
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.9</small></center>
</body></html>


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8