[SUCS Devel] site r665 - in trunk: components lib/Validate

imranh at sucs.org imranh at sucs.org
Mon Apr 13 19:51:31 BST 2015


Author: imranh
Date: 2015-04-13 19:51:21 +0100 (Mon, 13 Apr 2015)
New Revision: 665

Modified:
   trunk/components/libraryadmin.php
   trunk/lib/Validate/ISPN.php
   trunk/lib/Validate/Validate.php
Log:
Revert 664 and redo the fix but better

Modified: trunk/components/libraryadmin.php
===================================================================
--- trunk/components/libraryadmin.php	2015-04-13 10:31:51 UTC (rev 664)
+++ trunk/components/libraryadmin.php	2015-04-13 18:51:21 UTC (rev 665)
@@ -16,7 +16,7 @@
 
 function valid_isbn($isbn) {
 
-        return Validate_ISPN::isbn($isbn);
+        return (new Validate_ISPN)->isbn($isbn);
 }
 
 if ($session->groups[$permission]) {

Modified: trunk/lib/Validate/ISPN.php
===================================================================
--- trunk/lib/Validate/ISPN.php	2015-04-13 10:31:51 UTC (rev 664)
+++ trunk/lib/Validate/ISPN.php	2015-04-13 18:51:21 UTC (rev 665)
@@ -58,7 +58,7 @@
  */
 class Validate_ISPN
 {
-    public static function isbn($isbn)
+    function isbn($isbn)
     {
         if (preg_match("/[^0-9 IXSBN-]/", $isbn)) {
             return false;
@@ -91,7 +91,7 @@
      * @author Helgi Þormar <dufuz at php.net>
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    public static function isbn13($isbn)
+    function isbn13($isbn)
     {
         if (preg_match("/[^0-9 ISBN-]/", $isbn)) {
             return false;
@@ -121,7 +121,7 @@
      * @author Damien Seguy <dams at nexen.net>
      * @author Helgi Þormar <dufuz at php.net>
      */
-    public static function isbn10($isbn)
+    function isbn10($isbn)
     {
         static  $weights_isbn = array(10,9,8,7,6,5,4,3,2);
 
@@ -141,7 +141,7 @@
 
         // Requires base class Validate
         require_once 'Validate.php';
-        return Validate::_checkControlNumber($isbn, $weights_isbn, 11, 11);
+        return (new Validate)->_checkControlNumber($isbn, $weights_isbn, 11, 11);
     }
 
 
@@ -157,7 +157,7 @@
      * @access public
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    public static function issn($issn)
+    function issn($issn)
     {
         static $weights_issn = array(8,7,6,5,4,3,2);
 
@@ -172,7 +172,7 @@
 
         // Requires base class Validate
         require_once 'Validate.php';
-        return Validate::_checkControlNumber($issn, $weights_issn, 11, 11);
+        return (new Validate)->_checkControlNumber($issn, $weights_issn, 11, 11);
     }
 
     /**
@@ -191,7 +191,7 @@
      * @access public
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    public static function ismn($ismn)
+    function ismn($ismn)
     {
         static $weights_ismn = array(3,1,3,1,3,1,3,1,3);
 
@@ -212,7 +212,7 @@
 
         // Requires base class Validate
         require_once 'Validate.php';
-        return Validate::_checkControlNumber($ismn, $weights_ismn, 10, 10);
+        return (new Validate)->_checkControlNumber($ismn, $weights_ismn, 10, 10);
     }
 
     /**
@@ -228,7 +228,7 @@
      * @access public
      * @author David Grant <david at grant.org.uk>
      */
-    public static function isrc($isrc)
+    function isrc($isrc)
     {
         $isrc = str_replace(array('ISRC', '-', ' '), '', strtoupper($isrc));
         if (!preg_match("/[A-Z]{2}[A-Z0-9]{3}[0-9]{7}/", $isrc)) {
@@ -252,7 +252,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    public static function ean8($ean)
+    function ean8($ean)
     {
         static $weights_ean8 = array(3,1,3,1,3,1,3);
         return Validate_ISPN::process($ean, 8, $weights_ean8, 10, 10);
@@ -272,7 +272,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    public static function ean13($ean)
+    function ean13($ean)
     {
         static $weights_ean13 = array(1,3,1,3,1,3,1,3,1,3,1,3);
         return Validate_ISPN::process($ean, 13, $weights_ean13, 10, 10);
@@ -292,7 +292,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    public static function ean14($ean)
+    function ean14($ean)
     {
         static $weights_ean14 = array(3,1,3,1,3,1,3,1,3,1,3,1,3);
         return Validate_ISPN::process($ean, 14, $weights_ean14, 10, 10);
@@ -312,7 +312,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    public static function ucc12($ucc)
+    function ucc12($ucc)
     {
         static $weights_ucc12 = array(3,1,3,1,3,1,3,1,3,1,3);
         return Validate_ISPN::process($ucc, 12, $weights_ucc12, 10, 10);
@@ -332,7 +332,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    public static function sscc($sscc)
+    function sscc($sscc)
     {
         static $weights_sscc = array(3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3);
         return Validate_ISPN::process($sscc, 18, $weights_sscc, 10, 10);
@@ -349,9 +349,9 @@
      * @param array $weights holds the weight that will be used in calculations for the validation
      * @return bool    true if number is valid, otherwise false
      * @access public
-     * @see Validate::_checkControlNumber()
+     * @see (new Validate)->_checkControlNumber()
      */
-    public static function process($data, $length, &$weights, $modulo = 10, $subtract = 0)
+    function process($data, $length, &$weights, $modulo = 10, $subtract = 0)
     {
         //$weights = array(3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3);
         //$weights = array_slice($weights, 0, $length);
@@ -365,7 +365,7 @@
 
         // Requires base class Validate
         require_once 'Validate.php';
-        return Validate::_checkControlNumber($data, $weights, $modulo, $subtract);
+        return (new Validate)->_checkControlNumber($data, $weights, $modulo, $subtract);
     }
 }
 ?>

Modified: trunk/lib/Validate/Validate.php
===================================================================
--- trunk/lib/Validate/Validate.php	2015-04-13 10:31:51 UTC (rev 664)
+++ trunk/lib/Validate/Validate.php	2015-04-13 18:51:21 UTC (rev 665)
@@ -583,7 +583,7 @@
         return $ret;
     }
 
-    public static function _modf($val, $div) {
+    function _modf($val, $div) {
         if (function_exists('bcmod')) {
             return bcmod($val, $div);
         } elseif (function_exists('fmod')) {
@@ -604,7 +604,7 @@
      *
      * @access protected
      */
-    public static function _multWeights($number, &$weights) {
+    function _multWeights($number, &$weights) {
         if (!is_array($weights)) {
             return -1;
         }
@@ -634,7 +634,7 @@
      *
      * @access protected
      */
-    public static function _getControlNumber($number, &$weights, $modulo = 10, $subtract = 0, $allow_high = false) {
+    function _getControlNumber($number, &$weights, $modulo = 10, $subtract = 0, $allow_high = false) {
         // calc sum
         $sum = Validate::_multWeights($number, $weights);
         if ($sum == -1) {
@@ -663,7 +663,7 @@
      *
      * @access protected
      */
-    public static function _checkControlNumber($number, &$weights, $modulo = 10, $subtract = 0) {
+    function _checkControlNumber($number, &$weights, $modulo = 10, $subtract = 0) {
         if (strlen($number) < count($weights)) {
             return false;
         }




More information about the Devel mailing list