From e0949aa0adfdfee4f78733277ff43d850ef3582e Mon Sep 17 00:00:00 2001 From: mensonge Date: Fri, 28 Nov 2008 06:09:45 +0000 Subject: New Feature: possibility to import a structure of hierarchical tags from a file git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@179 b3834d28-1941-0410-a4f8-b48e95affb8f --- importStructure.php | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 importStructure.php (limited to 'importStructure.php') diff --git a/importStructure.php b/importStructure.php new file mode 100644 index 0000000..eb3df86 --- /dev/null +++ b/importStructure.php @@ -0,0 +1,80 @@ +getCurrentObjectUser(); + + +/* Managing all possible inputs */ +// First input is $_FILES + + +$tplVars = array(); +$tplVars['msg'] = ''; + +if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) { + $userinfo = $userservice->getCurrentObjectUser(); + + + // File handle + $html = file_get_contents($_FILES['userfile']['tmp_name']); + + // Create link array + preg_match_all('/(.*?)\n/', $html, $matches); + + //print_r($matches); die(); + + $fatherTag = ''; + $countNewLinks = 0; + foreach($matches[1] as $match) { + if($match == '') { + // do nothing because void line + }elseif(substr($match, 0, 2) == '//') { + // do nothing because commentary + } elseif(substr($match, 0, 2) == ' ') { + // add as child of previous tag + if($fatherTag != '') { + $tag2tagservice->addLinkedTags($fatherTag, $match, '>', $currentUser->getId()); + $countNewLinks++; + } else { + $tplVars['error'] = T_('Bad indentation'). ' '.$match; + } + } else{ + $fatherTag = $match; + } + } + $tplVars['msg'] = T_('New links between tags: ').$countNewLinks; + +} + +$templatename = 'importStructure.tpl'; +$tplVars['subtitle'] = T_('Import Structure'); +$tplVars['formaction'] = createURL('importStructure'); +$templateservice->loadTemplate($templatename, $tplVars); + +?> -- cgit v1.2.3-54-g00ecf