Beispiel #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);
 }
Beispiel #2
0
 /**
  * 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;
 }
Beispiel #3
0
function admParamAnswerChange(&$session, $mode)
{
    global $param_id, $param_theme, $param_pos, $param_name, $param_text;
    $session->trace(TC_Gui1, 'admParamAnswerChange');
    $param_text = textAreaToWiki($session, $param_text);
    if (!isInt($param_theme)) {
        $message = 'Theme nicht gültig: ' . $param_theme;
    } elseif (!isInt($param_pos)) {
        $message = 'Pos nicht gültig: ' . $param_pos;
    } elseif ($mode == C_New && dbSingleValue($session, 'select count(id) from ' . dbTable($session, T_Param) . " where theme={$param_theme} and pos={$param_pos}") > 0) {
        $message = 'Eintrag nicht möglich, da (Theme,Pos) schon existiert';
    } elseif ($mode == C_Change && dbSingleValue($session, 'select id from ' . dbTable($session, T_Param) . " where theme={$param_theme} and pos={$param_pos}") <= 0) {
        $message = 'Ändern nicht möglich, da (Id, Theme, Pos) nicht korrekt';
    } else {
        if ($mode == C_New) {
            dbInsert($session, T_Param, 'theme,pos,name,text', $param_theme . ',' . $param_pos . ',' . dbSqlString($session, $param_name) . ',' . dbSqlString($session, $param_text));
            $message = 'Parameter wurde eingefügt';
        } elseif ($mode == C_Change) {
            dbUpdateRaw($session, T_Param, $param_id, 'name=' . dbSqlString($session, $param_name) . ',' . 'text=' . dbSqlString($session, $param_text));
            $message = 'Parameter wurde geändert';
        } else {
            $message = 'Unbekannter Modus: ' . $mode;
        }
    }
    admParam($session, $message);
}
Beispiel #4
0
function basePostingAnswer(&$session)
{
    global $forum_id, $thread_id, $posting_id, $posting_subject, $posting_text, $posting_preview, $posting_insert, $posting_change, $textarea_width, $textarea_height;
    $session->trace(TC_Gui1, 'basePostingAnswer');
    $message = null;
    $mode = null;
    $posting_text = textAreaToWiki($session, $posting_text);
    if (isset($posting_preview)) {
        $mode = isset($posting_id) && isInt($posting_id) ? C_Change : C_New;
    } elseif (isset($posting_insert)) {
        $mode = C_New;
        if (empty($posting_subject)) {
            $message = '+++ Thema fehlt';
        } elseif (strlen($posting_text) < 5) {
            $message = '+++ Beitrag zu kurz';
        } else {
            $date = dbSqlDateTime($session, time());
            $thread_id = $posting_id = dbInsert($session, T_Posting, 'createdat,changedat,forum,author,top,reference,subject,text', "{$date},{$date},{$forum_id}," . dbSqlString($session, $session->fUserName) . ',' . (empty($thread_id) ? 'null' : $thread_id) . ',' . (empty($reference_id) ? 'null' : $reference_id) . ',' . dbSqlString($session, $posting_subject) . ',' . dbSqlString($session, $posting_text));
            dbUpdateRaw($session, T_User, $session->fUserId, 'postings=postings+1');
            baseForum($session);
            $mode = NULL;
        }
    } elseif (isset($posting_change)) {
        $mode = C_Change;
        if (empty($posting_subject)) {
            $message = '+++ Thema fehlt';
        } elseif (strlen($posting_text) < 5) {
            $message = '+++ Beitrag zu kurz';
        } else {
            $date = dbSqlString($session, time());
            dbUpdate($session, T_Posting, $posting_id, 'changedby=' . dbSqlString($session, $session->fUserName) . ',changedat=' . $date . ',subject=' . dbSqlString($session, $posting_subject) . ',text=' . dbSqlString($session, $posting_text) . ',');
            baseThread($session);
            $mode = NULL;
        }
    }
    if ($mode) {
        basePosting($session, $message, $mode);
    }
}
Beispiel #5
0
 /**
  * コンストラクタ。画像の情報をセットする。
  *
  * @param array $image_info 画像の情報を含む配列
  *                        - $arr['w']         = 横幅
  *                        - $arr['h']         = 横幅
  *                        - $arr['type']      = 画像の種類(IMAGETYPE_XXX)
  *                        - $arr['extension'] = 画像の拡張子(jpg|gif|png)
  *                        - $arr['colors']    = 色数
  *                        - $arr['error']     = エラーコード
  */
 function ImageInfoResult($image_info)
 {
     $this->w = 0;
     $this->h = 0;
     $this->type = 0;
     $this->extension = NULL;
     $this->colors = 0;
     $this->error_flag = false;
     $this->error_code = 0;
     if (!is_array($image_info)) {
         $this->error_flag = true;
         $this->error_code = ImageInfo_ERROR_UNKNOWN;
         return;
     }
     //$image_info配列から値を取り出す
     $w = isset($image_info['w']) ? $image_info['w'] : '';
     $h = isset($image_info['h']) ? $image_info['h'] : '';
     $type = isset($image_info['type']) ? $image_info['type'] : '';
     $extension = isset($image_info['extension']) ? $image_info['extension'] : '';
     $colors = isset($image_info['colors']) ? $image_info['colors'] : '';
     $error = isset($image_info['error']) ? $image_info['error'] : '';
     //各値が正しい値でなければエラー
     if (!isInt($w) || !isInt($h) || !isInt($type) || !isInt($colors) || !isInt($error)) {
         $this->error_flag = true;
         $this->error_code = ImageInfo_ERROR_UNKNOWN;
         return;
     }
     $this->w = $w;
     $this->h = $h;
     $this->type = $type;
     $this->extension = $extension;
     $this->colors = $colors;
     $this->error_code = $error;
     if ($this->error_code != 0) {
         //エラーコードが0以外の場合はエラー
         $this->error_flag = true;
     }
 }
function basePostingAnswer(&$session)
{
    $session->trace(TC_Gui1, 'basePostingAnswer');
    $message = null;
    $mode = null;
    $_POST['posting_text'] = textAreaToWiki($session, $_POST['posting_text']);
    if (isset($_POST['posting_preview'])) {
        $mode = isset($_POST['posting_id']) && isInt($_POST['posting_id']) ? C_Change : C_New;
    } elseif (isset($_POST['posting_insert'])) {
        $mode = C_New;
        if (empty($_POST['posting_subject'])) {
            $message = '+++ Thema fehlt';
        } elseif (strlen($_POST['posting_text']) < 5) {
            $message = '+++ Beitrag zu kurz';
        } else {
            $date = dbSqlDateTime($session, time());
            $_POST['thread_id'] = $_POST['posting_id'] = dbInsert($session, T_Posting, 'createdat,changedat,forum,author,top,reference,subject,text', "{$date},{$date}," . $_POST['forum_id'] . ',' . dbSqlString($session, $session->fUserName) . ',' . (empty($_POST['thread_id']) ? 'null' : $_POST['thread_id']) . ',' . (empty($_POST['reference_id']) ? 'null' : $_POST['reference_id']) . ',' . dbSqlString($session, $_POST['posting_subject']) . ',' . dbSqlString($session, $_POST['posting_text']));
            dbUpdateRaw($session, T_User, $session->fUserId, 'postings=postings+1');
            baseForum($session);
            $mode = NULL;
        }
    } elseif (isset($_POST['posting_change'])) {
        $mode = C_Change;
        if (empty($_POST['posting_subject'])) {
            $message = '+++ Thema fehlt';
        } elseif (strlen($_POST['posting_text']) < 5) {
            $message = '+++ Beitrag zu kurz';
        } else {
            $date = dbSqlString($session, time());
            dbUpdate($session, T_Posting, $_POST['posting_id'], 'changedby=' . dbSqlString($session, $session->fUserName) . ',changedat=' . $date . ',subject=' . dbSqlString($session, $_POST['posting_subject']) . ',text=' . dbSqlString($session, $_POST['posting_text']) . ',');
            baseThread($session);
            $mode = NULL;
        }
    }
    if ($mode) {
        basePosting($session, $message, $mode);
    }
}
Beispiel #7
0
function fIsInt()
{
    return function ($d) {
        return isInt($d);
    };
}
Beispiel #8
0
function admMacroAnswerChange(&$session, $mode)
{
    $session->trace(TC_Gui1, 'admMacroAnswerChange');
    $id = null;
    $_POST['macro_text'] = textAreaToWiki($session, $_POST['macro_text']);
    $count = 0;
    if (!isInt($_POST['macro_theme'])) {
        $message = 'Theme nicht gültig: ' . $_POST['macro_theme'];
    } elseif (empty($_POST['macro_name'])) {
        $message = 'kein Name angegeben: ' . $_POST['macro_name'];
    } elseif ($mode == C_New && ($count = dbSingleValue($session, 'select count(id) from ' . dbTable($session, T_Macro) . ' where theme=' . $_POST['macro_theme'] . ' and name=' . dbSqlString($session, $_POST['macro_name']))) > 0) {
        $message = 'Eintrag nicht möglich, da (Theme,Name) schon existiert';
    } elseif ($mode == C_Change && ($id = dbSingleValue($session, 'select id from ' . dbTable($session, T_Macro) . ' where theme=' . $_POST['macro_theme'] . ' and name=' . dbSqlString($session, $_POST['macro_name']))) <= 0) {
        $message = 'Ändern nicht möglich, da (Theme, Name) nicht existiert';
    } else {
        $session->trace(TC_Gui3, 'admMacroAnswerChange-2: ' . $count . ' / ' . $mode);
        if ($mode == C_New) {
            dbInsert($session, T_Macro, 'theme,name,description,value', $_POST['macro_theme'] . ',' . dbSqlString($session, $_POST['macro_name']) . ',' . dbSqlString($session, $_POST['macro_description']) . ',' . dbSqlString($session, $_POST['macro_text']));
            $message = 'Makro ' . $_POST['macro_name'] . ' wurde eingefügt';
        } elseif ($mode == C_Change) {
            dbUpdateRaw($session, T_Macro, $id, 'value=' . dbSqlString($session, $_POST['macro_text']) . ',' . 'description=' . dbSqlString($session, $_POST['macro_description']) . ',' . 'value=' . dbSqlString($session, $_POST['macro_text']));
            $message = 'Makro ' . $_POST['macro_name'] . ' wurde geändert';
        } else {
            $message = 'Unbekannter Modus: ' . $mode;
        }
    }
    admMacro($session, $message);
}
Beispiel #9
0
/**
 * @return \Closure
 */
function isNotInt()
{
    return negate(isInt());
}
Beispiel #10
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);
}