Exemple #1
0
 public function parseValue($object, $subject, $predicate, &$extractor, $language = NULL)
 {
     $dtype = null;
     $object_is = 'l';
     if (isBlanknote($object)) {
         $object_is = 'b';
         $object = str_replace(";", "", $object);
     } else {
         if (isInt($object)) {
             $dtype = 'http://www.w3.org/2001/XMLSchema#integer';
         } else {
             if (isIntwithComma($object)) {
                 $object = str_replace(",", "", $object);
                 $dtype = 'http://www.w3.org/2001/XMLSchema#integer';
             } else {
                 if (isFloat($object)) {
                     $dtype = 'http://www.w3.org/2001/XMLSchema#decimal';
                 } else {
                     if (catchPictureURI($object, $subject)) {
                         $object_is = 'r';
                         $image = substr($object, strrpos($object, '/') + 1);
                         $wikipediaImageDescription = 'http://' . $language . '.wikipedia.org/wiki/Image:' . $image;
                         writeTripel($object, 'http://purl.org/dc/terms/rights', $wikipediaImageDescription, 'main', $object_is);
                     } else {
                         if (catchMonthYear($object)) {
                             $dtype = 'http://www.w3.org/2001/XMLSchema#gYearMonth';
                         } else {
                             if (catchDate($object)) {
                                 $dtype = 'http://www.w3.org/2001/XMLSchema#date';
                             } else {
                                 if (catchYear($object)) {
                                     $dtype = 'http://www.w3.org/2001/XMLSchema#gYear';
                                 } else {
                                     if (catchRank($object)) {
                                         $dtype = $GLOBALS['W2RCFG']['w2ruri'] . 'Rank';
                                     } else {
                                         if (catchLargeNumber($object)) {
                                             $dtype = 'http://www.w3.org/2001/XMLSchema#integer';
                                         } else {
                                             if ($dtype = catchLargeMoney($object)) {
                                             } else {
                                                 if ($dtype = catchMoneyWoCent($object)) {
                                                 } else {
                                                     if ($dtype = catchMoney($object)) {
                                                     } else {
                                                         if (catchPercent($object)) {
                                                             $dtype = $GLOBALS['W2RCFG']['w2ruri'] . 'Percent';
                                                         } else {
                                                             if ($dtype = catchUnited($object)) {
                                                             } else {
                                                                 if (catchLink($object)) {
                                                                     $object_is = 'r';
                                                                 } else {
                                                                     if (catchLinkList($object, $subject, $predicate, $dtype, $extractor)) {
                                                                         return null;
                                                                     } else {
                                                                         if ($list = catchExternalLink($object)) {
                                                                             // $list = catchExternalLink($object);
                                                                             foreach ($list[1] as $l) {
                                                                                 if (strlen($l) > 1) {
                                                                                     $l = explode(" ", $l);
                                                                                     $object = $l[0];
                                                                                     $object_is = 'r';
                                                                                     writeTripel($subject, $predicate, $object, 'main', $object_is);
                                                                                     unset($object);
                                                                                 }
                                                                             }
                                                                             return null;
                                                                         } else {
                                                                             if (catchNumberWithReference($object, $subject, $predicate, $extractor)) {
                                                                                 return null;
                                                                             } else {
                                                                                 removeWikiCode($object);
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //if ($GLOBALS['addExplicitTypeTriples'])
     //	printexplicitTyping($predicate,$GLOBALS['filename'],'p',$object_is);
     //if ($GLOBALS['addExplicitTypeTriples']&&$GLOBALS['correctPropertyType'])
     //	$object_is=printexplicitTyping($predicate,$GLOBALS['filename'],'p',$object_is);
     if (strlen(trim($object)) < 1) {
         return null;
     }
     return array($object, $object_is, $dtype, $language);
 }
Exemple #2
0
    return filter_var($boolean, FILTER_VALIDATE_BOOLEAN);
}
var_dump(isBoolean(1));
echo '<br />';
function isBooleanInArray($array)
{
    return filter_var($array, FILTER_VALIDATE_BOOLEAN, FILTER_REQUIRE_ARRAY);
}
$array = array(0, 1, 2, 3, 4, array(0, 1, 2, 3, 4));
var_dump(isBooleanInArray($array));
echo '<br />';
function isFloat($var)
{
    return filter_var($var, FILTER_VALIDATE_FLOAT) ? true : false;
}
var_dump(isFloat('123.45678'));
echo '<br />';
function isFloatInArray($array)
{
    return filter_var($array, FILTER_VALIDATE_FLOAT, FILTER_REQUIRE_ARRAY);
}
$array = array(1.2, "1.7", "", "-12345.678", "1,234.2222", "abcd4.2efgh", array());
echo '<br/>';
var_dump(isFloatInArray($array));
echo '<br />';
function isEmailByRegexp($email)
{
    $pattern = '/^\\S+@[\\w\\d.-]{2,}\\.[\\w]{2,6}$/iU';
    return filter_var($email, FILTER_VALIDATE_REGEXP, array("options" => array("regexp" => $pattern))) ? true : false;
}
$mail = '*****@*****.**';
 /**
  * SOAP::Value::_getSoapType
  *
  * convert php type to soap type
  * @param    string  value
  * @param    string  type  - presumed php type
  *
  * @return   string  type  - soap type
  * @access   private
  */
 function _getSoapType(&$value, &$type)
 {
     $doconvert = FALSE;
     if (0 && $this->wsdl) {
         # see if it's a complex type so we can deal properly with SOAPENC:arrayType
         if (!$type && $this->name) {
             # XXX TODO:
             # look up the name in the wsdl and validate the type
             $this->debug("SOAP_VALUE no type for {$this->name}!");
         } else {
             if ($type) {
                 # XXX TODO:
                 # this code currently handles only one way of encoding array types in wsdl
                 # need to do a generalized function to figure out complex types
                 if (array_key_exists($type, $this->wsdl->complexTypes)) {
                     if ($this->arrayType = $this->wsdl->complexTypes[$type]['arrayType']) {
                         $type = 'Array';
                     } else {
                         if ($this->wsdl->complexTypes[$type]['order'] == 'sequence' && array_key_exists('elements', $this->wsdl->complexTypes[$type])) {
                             reset($this->wsdl->complexTypes[$type]['elements']);
                             # assume an array
                             if (count($this->wsdl->complexTypes[$type]['elements']) == 1) {
                                 $arg = current($this->wsdl->complexTypes[$type]['elements']);
                                 $this->arrayType = $arg['type'];
                                 $type = 'Array';
                             } else {
                                 foreach ($this->wsdl->complexTypes[$type]['elements'] as $element) {
                                     if ($element['name'] == $type) {
                                         $this->arrayType = $element['type'];
                                         $type = $element['type'];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$type || !$this->verifyType($type)) {
         if ($type && $this->wsdl && array_key_exists($type, $this->wsdl->complexTypes)) {
             # do nothing, this preserves our complex types
         } else {
             if (is_object($value)) {
                 # allows for creating special classes to handle soap types
                 $type = get_class($value);
                 # this may return a different type that we process below
                 $value = $value->toSOAP();
             } elseif (isArray($value)) {
                 $type = isHash($value) ? 'Struct' : 'Array';
             } elseif (isInt($value)) {
                 $type = 'int';
             } elseif (isFloat($value)) {
                 $type = 'float';
             } elseif (SOAP_Type_hexBinary::is_hexbin($value)) {
                 $type = 'hexBinary';
             } elseif (isBase64($value)) {
                 $type = 'base64Binary';
             } elseif (isBoolean($value)) {
                 $type = 'boolean';
             } else {
                 $type = gettype($value);
                 # php defaults a lot of stuff to string, if we have no
                 # idea what the type realy is, we have to try to figure it out
                 # this is the best we can do if the user did not use the SOAP_Value class
                 if ($type == 'string') {
                     $doconvert = TRUE;
                 }
             }
         }
     }
     # we have the type, handle any value munging we need
     if ($doconvert) {
         $dt = new SOAP_Type_dateTime($value);
         if ($dt->toUnixtime() != -1) {
             $type = 'dateTime';
             $value = $dt->toSOAP();
         }
     } else {
         if ($type == 'dateTime') {
             # encode a dateTime to ISOE
             $dt = new SOAP_Type_dateTime($value);
             $value = $dt->toSOAP();
         } else {
             // php type name mangle
             if ($type == 'integer') {
                 $type = 'int';
             } else {
                 if ($type == 'boolean') {
                     if ($value != 0 && $value != '0' || strcasecmp($value, 'true') == 0) {
                         $value = 'true';
                     } else {
                         $value = 'false';
                     }
                 }
             }
         }
     }
     return $type;
 }
Exemple #4
0
function fIsFloat()
{
    return function ($d) {
        return isFloat($d);
    };
}
/**
 * @return \Closure
 */
function isNotFloat()
{
    return negate(isFloat());
}
Exemple #6
0
/**
 * Main function to extract data-types, internal Links etc. from the Template.
 * 
 * 
 */
function parseAttributeValue($object, $subject, $predicate)
{
    // Generate DBpedia Links from Internal Links
    //$object = preg_replace_callback('/\[\[([a-zA-Z\., \-_!&\$€¥]]+)(\|[a-zA-Z\., \-_!&\$€¥])*\]\]/','convertDBpediaLinks',$object);
    $object = preg_replace('/\\[\\[([0-9]{4})\\]\\]/', '$1', $object);
    $object = preg_replace_callback('/\\[\\[([^\\:\\|\\]]+)(\\|[^\\]]+)?\\]\\]/', 'convertDBpediaLinks', $object);
    removeSemanticExtension($object);
    $object = str_replace("[[image:green up.png]]", "", $object);
    $object = str_replace("[[image:red down.png]]", "", $object);
    $dtype = null;
    $lang = null;
    $object_is = 'l';
    if (isBlanknote($object)) {
        $object_is = 'b';
        $object = str_replace(";", "", $object);
    } else {
        if (isInt($object)) {
            $dtype = 'http://www.w3.org/2001/XMLSchema#integer';
        } else {
            if (isIntwithComma($object)) {
                $object = str_replace(",", "", $object);
                $dtype = 'http://www.w3.org/2001/XMLSchema#integer';
            } else {
                if (isFloat($object)) {
                    $dtype = 'http://www.w3.org/2001/XMLSchema#decimal';
                } else {
                    if (catchPictureURI($object)) {
                        $object_is = 'r';
                    } else {
                        if (catchMonthYear($object)) {
                            $dtype = 'http://www.w3.org/2001/XMLSchema#gYearMonth';
                        } else {
                            if (catchDate($object)) {
                                $dtype = 'http://www.w3.org/2001/XMLSchema#date';
                            } else {
                                if (catchYear($object)) {
                                    $dtype = 'http://www.w3.org/2001/XMLSchema#gYear';
                                } else {
                                    if (catchRank($object)) {
                                        $dtype = $GLOBALS['W2RCFG']['w2ruri'] . 'Rank';
                                    } else {
                                        if (catchLargeNumber($object)) {
                                            $dtype = 'http://www.w3.org/2001/XMLSchema#integer';
                                        } else {
                                            if ($dtype = catchLargeMoney($object)) {
                                            } else {
                                                if ($dtype = catchMoneyWoCent($object)) {
                                                } else {
                                                    if ($dtype = catchMoney($object)) {
                                                    } else {
                                                        if (catchPercent($object)) {
                                                            $dtype = $GLOBALS['W2RCFG']['w2ruri'] . 'Percent';
                                                        } else {
                                                            if ($dtype = catchUnited($object)) {
                                                            } else {
                                                                if (catchLink($object)) {
                                                                    $object_is = 'r';
                                                                } else {
                                                                    if (catchLinkList($object, $subject, $predicate, $dtype)) {
                                                                        return null;
                                                                    } else {
                                                                        if ($list = catchExternalLink($object)) {
                                                                            // $list = catchExternalLink($object);
                                                                            foreach ($list[1] as $l) {
                                                                                if (strlen($l) > 1) {
                                                                                    $l = explode(" ", $l);
                                                                                    $object = $l[0];
                                                                                    $object_is = 'r';
                                                                                    writeTripel($subject, $predicate, $object, 'main', $object_is);
                                                                                    unset($object);
                                                                                }
                                                                            }
                                                                            return null;
                                                                        } else {
                                                                            if (catchNumberWithReference($object, $subject, $predicate)) {
                                                                                return null;
                                                                            } else {
                                                                                removeWikiCode($object);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($GLOBALS['addExplicitTypeTriples']) {
        printexplicitTyping($predicate, $GLOBALS['filename'], 'p', $object_is);
    }
    if ($GLOBALS['addExplicitTypeTriples'] && $GLOBALS['correctPropertyType']) {
        $object_is = printexplicitTyping($predicate, $GLOBALS['filename'], 'p', $object_is);
    }
    if (strlen(trim($object)) < 1) {
        return null;
    }
    return array($object, $object_is, $dtype, $lang);
}