r1637 - in branches/0.2: core/Base core/Form core/Logic doc main/Containers main/Utils

From: <voxusAT@ATshadanakar.org>
Date: Sat, 20 May 2006 20:38:08 +0400 (MSD)

Author: voxus
Date: 2006-05-20 20:38:07 +0400 (Sat, 20 May 2006)
New Revision: 1637

Added:
   branches/0.2/core/Form/ListedPrimitive.class.php
Modified:
   branches/0.2/core/Base/Enumeration.class.php
   branches/0.2/core/Form/PlainForm.class.php
   branches/0.2/core/Form/PrimitiveEnumeration.class.php
   branches/0.2/core/Form/PrimitiveList.class.php
   branches/0.2/core/Logic/LogicalBlock.class.php
   branches/0.2/doc/ChangeLog
   branches/0.2/main/Containers/ManyToManyLinked.class.php
   branches/0.2/main/Containers/OneToManyLinked.class.php
   branches/0.2/main/Containers/UnifiedContainer.class.php
   branches/0.2/main/Utils/HeaderUtils.class.php
   branches/0.2/main/Utils/Mail.class.php
   branches/0.2/main/Utils/RussianTextUtils.class.php
Log:
* sync: trunk => 0.2 branch

Modified: branches/0.2/core/Base/Enumeration.class.php
===================================================================
--- branches/0.2/core/Base/Enumeration.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/core/Base/Enumeration.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -39,6 +39,15 @@
                         return $enum->getObjectList();
                 }
                 
+ /**
+ * must return any existent ID
+ * 1 should be ok for most enumerations
+ **/
+ public static function getAnyId()
+ {
+ return 1;
+ }
+
                 public function getObjectList()
                 {
                         $list = array();

Added: branches/0.2/core/Form/ListedPrimitive.class.php
===================================================================
--- branches/0.2/core/Form/ListedPrimitive.class.php (rev 0)
+++ branches/0.2/core/Form/ListedPrimitive.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -0,0 +1,21 @@
+<?php
+/***************************************************************************
+ * Copyright (C) 2006 by Konstantin V. Arkhipov *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/* $Id$ */
+
+ /**
+ * @ingroup Primitives
+ **/
+ interface ListedPrimitive
+ {
+ /// @return plain array of possible primitive choices
+ public function getList();
+ }
+?>
\ No newline at end of file

Property changes on: branches/0.2/core/Form/ListedPrimitive.class.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: branches/0.2/core/Form/PlainForm.class.php
===================================================================
--- branches/0.2/core/Form/PlainForm.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/core/Form/PlainForm.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -1,13 +1,13 @@
 <?php
-/***************************************************************************
- * Copyright (C) 2005 by Konstantin V. Arkhipov, Anton E. Lebedevich *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
+/****************************************************************************
+ * Copyright (C) 2005-2006 by Konstantin V. Arkhipov, Anton E. Lebedevich *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ****************************************************************************/
 /* $Id$ */
 
         /**
@@ -104,8 +104,14 @@
                 public function getChoiceValue($name)
                 {
                         $prm = $this->get($name);
+
+ Assert::isTrue($prm instanceof ListedPrimitive);
+
                         $list = $prm->getList();
                         $value = $prm->getValue();
+
+ if ($value instanceof Identifiable)
+ $value = $value->getId();
 
                         if ($value !== null)
                                 return $list[$value];
@@ -116,10 +122,20 @@
                 public function getActualChoiceValue($name)
                 {
                         $prm = $this->get($name);
+
+ Assert::isTrue($prm instanceof ListedPrimitive);
+
                         $list = $prm->getList();
                         $value = $prm->getActualValue();
                         $default= $prm->getDefault();
                         
+ if ($value instanceof Identifiable) {
+ $value = $value->getId();
+
+ if ($default)
+ $default = $default->getId();
+ }
+
                         if ($value !== null && isset($list[$value]))
                                 return $list[$value];
                         elseif (isset($list[$default]))

Modified: branches/0.2/core/Form/PrimitiveEnumeration.class.php
===================================================================
--- branches/0.2/core/Form/PrimitiveEnumeration.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/core/Form/PrimitiveEnumeration.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -13,8 +13,25 @@
         /**
          * @ingroup Primitives
         **/
- final class PrimitiveEnumeration extends IdentifiablePrimitive
+ final class PrimitiveEnumeration
+ extends IdentifiablePrimitive
+ implements ListedPrimitive
         {
+ public function getList()
+ {
+ if ($this->value)
+ return $this->value->getObjectList();
+ elseif ($this->default)
+ return $this->default->getObjectList();
+ else {
+ return new $this->className(
+ call_user_func(array($this->className, 'getAnyId'))
+ );
+ }
+
+ /* NOTREACHED */
+ }
+
                 public function of($className)
                 {
                         Assert::isTrue(

Modified: branches/0.2/core/Form/PrimitiveList.class.php
===================================================================
--- branches/0.2/core/Form/PrimitiveList.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/core/Form/PrimitiveList.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- * Copyright (C) 2004-2005 by Konstantin V. Arkhipov *
+ * Copyright (C) 2004-2006 by Konstantin V. Arkhipov *
  * *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -13,7 +13,7 @@
         /**
          * @ingroup Primitives
         **/
- class PrimitiveList extends BasePrimitive
+ class PrimitiveList extends BasePrimitive implements ListedPrimitive
         {
                 protected $list = array();
                 
@@ -43,6 +43,7 @@
                                 && isset($this->list[$scope[$this->name]])
                         ) {
                                 $this->value = $scope[$this->name];
+
                                 return true;
                         } else
                                 return false;

Modified: branches/0.2/core/Logic/LogicalBlock.class.php
===================================================================
--- branches/0.2/core/Logic/LogicalBlock.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/core/Logic/LogicalBlock.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -58,11 +58,11 @@
                         $args = &$this->args;
                         $size = count($args);
                         
- $out = true;
                         
                         switch ($this->logic) {
                                 case Expression::LOGIC_AND:
                                         
+ $out = true;
                                         for ($i = 0; $i < $size; ++$i)
                                                 if (isset($args[$i + 1]))
                                                         $out =
@@ -76,6 +76,7 @@
                         
                                 case Expression::LOGIC_OR:
                                         
+ $out = false;
                                         for ($i = 0; $i < $size; ++$i)
                                                 if (isset($args[$i + 1]))
                                                         $out =

Modified: branches/0.2/doc/ChangeLog
===================================================================
--- branches/0.2/doc/ChangeLog 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/doc/ChangeLog 2006-05-20 16:38:07 UTC (rev 1637)
@@ -1,5 +1,20 @@
 # $Id$
 
+2006-05-20 Konstantin V. Arkhipov <voxusAT@ATshadanakar.org>
+
+ * main/Utils/HeaderUtils.class.php,
+ main/Utils/RussianTextUtils.class.php, main/Utils/Mail.class.php,
+ main/Containers/UnifiedContainer.class.php,
+ main/Containers/OneToManyLinked.class.php,
+ main/Containers/ManyToManyLinked.class.php,
+ core/Form/PlainForm.class.php,
+ core/Form/PrimitiveEnumeration.class.php,
+ core/Form/PrimitiveList.class.php, core/Base/Enumeration.class.php,
+ core/Logic/LogicalBlock.class.php: synced with trunk.
+
+ * branches/0.2/core/Form/ListedPrimitive.class.php: arrived from
+ trunk.
+
 2006-05-12 Konstantin V. Arkhipov <voxusAT@ATshadanakar.org>
 
         * main/Utils/RussianTextUtils.class.php,

Modified: branches/0.2/main/Containers/ManyToManyLinked.class.php
===================================================================
--- branches/0.2/main/Containers/ManyToManyLinked.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/main/Containers/ManyToManyLinked.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -18,7 +18,7 @@
                 abstract public function getHelperTable();
 
                 public function __construct(
- DAOConnected $parent, GenericDAO $dao, $lazy = true
+ Identifiable $parent, GenericDAO $dao, $lazy = true
                 )
                 {
                         parent::__construct($parent, $dao, $lazy);

Modified: branches/0.2/main/Containers/OneToManyLinked.class.php
===================================================================
--- branches/0.2/main/Containers/OneToManyLinked.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/main/Containers/OneToManyLinked.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -16,7 +16,7 @@
         abstract class OneToManyLinked extends UnifiedContainer
         {
                 public function __construct(
- DAOConnected $parent, GenericDAO $dao, $lazy = true
+ Identifiable $parent, GenericDAO $dao, $lazy = true
                 )
                 {
                         parent::__construct($parent, $dao, $lazy);

Modified: branches/0.2/main/Containers/UnifiedContainer.class.php
===================================================================
--- branches/0.2/main/Containers/UnifiedContainer.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/main/Containers/UnifiedContainer.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -75,7 +75,7 @@
                 abstract protected function getParentIdField();
 
                 public function __construct(
- DAOConnected $parent, GenericDAO $dao, $lazy = true
+ Identifiable $parent, GenericDAO $dao, $lazy = true
                 )
                 {
                         Assert::isBoolean($lazy);

Modified: branches/0.2/main/Utils/HeaderUtils.class.php
===================================================================
--- branches/0.2/main/Utils/HeaderUtils.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/main/Utils/HeaderUtils.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -101,6 +101,7 @@
 
                 public static function sendNotCachedHeader()
                 {
+ header('Cache-control: no-cache');
                         header(
                                 'Expires: '
                                 .date('D, d M Y H:i:s', date('U') - self::$cacheLifeTime)

Modified: branches/0.2/main/Utils/Mail.class.php
===================================================================
--- branches/0.2/main/Utils/Mail.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/main/Utils/Mail.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -13,6 +13,9 @@
         class MailException extends BaseException {/*_*/};
         class MailNotSentException extends MailException {/*_*/};
         
+ /**
+ * @ingroup Utils
+ **/
         class Mail
         {
                 private $to = null;

Modified: branches/0.2/main/Utils/RussianTextUtils.class.php
===================================================================
--- branches/0.2/main/Utils/RussianTextUtils.class.php 2006-05-20 15:52:40 UTC (rev 1636)
+++ branches/0.2/main/Utils/RussianTextUtils.class.php 2006-05-20 16:38:07 UTC (rev 1637)
@@ -19,6 +19,7 @@
                 const FEMALE = 1;
                 const NEUTRAL = 2;
         
+ // TODO: deprecated by selectCaseForNumber
                 private static $secondDecade = array(11, 12, 13, 14, 15, 16, 17, 18, 19);
         
                 private static $orderedSuffixes = array(
@@ -51,6 +52,7 @@
                 /**
                  * Returns suffix for word
                  *
+ * @deprecated by selectCaseForNumber
                  * @param $number integer variable
                  * @param $suffixes array of suffixes as array('ца', 'цы', null)
                 **/
@@ -80,6 +82,34 @@
                                         return $suffixes[2];
                         }
                 }
+
+ /**
+ * Select russian case for number
+ * for example:
+ * 1 результат
+ * 2 результата
+ * 5 результатов
+ * @param $number integer
+ * @param $cases words to select from array('результат', 'результата', 'результатов')
+ */
+ public static function selectCaseForNumber($number, $cases)
+ {
+ if (($number % 10) == 1 && ($number % 100) != 11) {
+
+ return $cases[0];
+
+ } elseif (
+ ($number % 10) > 1
+ && ($number % 10) < 5
+ && ($number < 10 || $number > 20)
+ ) {
+
+ return $cases[1];
+
+ } else {
+ return $cases[2];
+ }
+ }
 
                 /**
                  * doesn't duplicate strtolower('%B', ...)
Received on Sat May 20 2006 - 20:38:08 MSD

This archive was generated by hypermail 2.2.0 : Sat Oct 27 2007 - 20:06:04 MSD