Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Showing with 111 additions and 69 deletions.
  1. +46 −3 Files.php
  2. +0 −50 GraphML.php
  3. +57 −0 YEd.php
  4. +0 −16 tests/testGraphML.php
  5. +8 −0 tests/testYEd.php
View
49 Files.php
@@ -58,17 +58,18 @@ function makePathAbsolute($path,$base=null,$makeItReal=false) {
}
/**
- * Return the extension of an URL (the last par after .)
+ * Return the extension of an URL (the last part after .)
* TODO testing
* @param String! $url
* @return string the extension without dot?
*/
function fileExtension($url) {
- $dotpos = strrpos($url,'.') ;
+ $name=basename($url) ;
+ $dotpos = strrpos($name,'.') ;
if ($dotpos===false) {
$extension = "" ;
} else {
- $extension = substr($url,$dotpos+1) ;
+ $extension = substr($name,$dotpos+1) ;
}
return $extension ;
}
@@ -286,6 +287,48 @@ function listAllFileNames(
}
}
+
+/**
+ * @param unknown_type $filenames
+ */
+function extensionFrequencies($filenames){
+ $distrib = array() ;
+ foreach ($filenames as $filename) {
+ $extension=fileExtension($filename) ;
+ if (isset($distrib[$extension]) ){
+ $distrib[$extension]++ ;
+ } else {
+ //echo $extension." " ;
+ $distrib[$extension] = 1 ;
+ }
+
+ }
+ return $distrib ;
+}
+
+/**
+ *
+ * file
+ * 'name' => String!,
+ * 'path' => String!,
+ * 'extension' => String!,
+ * 'isHidden' => Boolean!,
+ * 'size' => Integer>=0!,
+ * 'lineNb' => Integer>=0?
+ *
+ * directory = Map (
+ * 'name' => String!,
+ * 'path' => String!,
+ * 'extension' => String!,
+ * 'isHidden' => String!,
+ * 'depth'=>Integer>=0!,
+ * 'cumulatedSize' => Integer>=0!,
+ * 'cumulatedLineNb' => I
+ */
+
+
+
+
/**
* Compute the information about a link. Note that if the link is broken or
* in case of another error, then only the 'link' field will be returned.
View
50 GraphML.php
@@ -178,53 +178,3 @@ public function __construct($graphname = null) {
}
-class GraphMLAsHTML {
- const REGEXPR_AREA_LINE = '#<area shape="([a-z]*)" coords="([0-9,]*)" (href=".*" )?alt="".* onmouseover="showTooltip\(\'(.*)\'\)#' ;
- // "$D/ -> ../repo
- // target="_blank" -> target="detail"
- public static function getImageAreas($html) {
- $areaMap = array() ;
- preg_match_all(self::REGEXPR_AREA_LINE,$html,$matches,PREG_SET_ORDER) ;
- foreach ($matches as $match) {
- if (preg_match('/href="(.*)"/',$match[3],$urlmatch)) {
- $url=$urlmatch[1] ;
- } else {
- $url="" ;
- }
- $areaMap[$match[4]] = array(
- "shape" => $match[1],
- "coords" => $match[2],
- "url" => $url) ;
- }
- return $areaMap ;
- }
-}
-
-
-
-
-/**
- * Describes a Yed palette.
- * The corresponding file is saved in the user application directory
- * (e.g. C:\Documents and Settings\<theUser>\Application Data\)
- * in the palette directory ((e.g. yWorks\yEd\palette) as a regular
- * graphml file.
- */
-class YedPalette extends GraphML {
-
-}
-
-/**
- * Describes a Yed palette set.
- * The corresponding file is saved in the user application directory
- * (e.g. C:\Documents and Settings\<theUser>\Application Data\)
- * in the palette directory as palette_info.xml
- */
-class YedPaletteSet {
-
-
-}
-
-class YedPropertyMapper {
-
-}
View
57 YEd.php
@@ -0,0 +1,57 @@
+<?php
+require_once 'GraphML.php' ;
+
+
+/**
+ * Deals with the HTML file exported by the yEd editor.
+ */
+class YEdHTML {
+ const REGEXPR_AREA_LINE = '#<area shape="([a-z]*)" coords="([0-9,]*)" (href=".*" )?alt="".* onmouseover="showTooltip\(\'(.*)\'\)#' ;
+ // "$D/ -> ../repo
+ // target="_blank" -> target="detail"
+ public static function getImageAreas($html) {
+ $areaMap = array() ;
+ preg_match_all(self::REGEXPR_AREA_LINE,$html,$matches,PREG_SET_ORDER) ;
+ foreach ($matches as $match) {
+ if (preg_match('/href="(.*)"/',$match[3],$urlmatch)) {
+ $url=$urlmatch[1] ;
+ } else {
+ $url="" ;
+ }
+ $areaMap[$match[4]] = array(
+ "shape" => $match[1],
+ "coords" => $match[2],
+ "url" => $url) ;
+ }
+ return $areaMap ;
+ }
+}
+
+
+
+
+/**
+ * Describes a Yed palette.
+ * The corresponding file is saved in the user application directory
+ * (e.g. C:\Documents and Settings\<theUser>\Application Data\)
+ * in the palette directory ((e.g. yWorks\yEd\palette) as a regular
+ * graphml file.
+ */
+class YedPalette extends GraphML {
+
+}
+
+/**
+ * Describes a Yed palette set.
+ * The corresponding file is saved in the user application directory
+ * (e.g. C:\Documents and Settings\<theUser>\Application Data\)
+ * in the palette directory as palette_info.xml
+ */
+class YedPaletteSet {
+
+
+}
+
+class YedPropertyMapper {
+
+}
View
16 tests/testGraphML.php
@@ -1,18 +1,2 @@
<?php
require_once '../GraphML.php' ;
-require_once '../HTML.php' ;
-
-$text = file_get_contents('data/input/g1.html') ;
-var_dump(GraphMLAsHTML::getImageAreas($text)) ;
-
-
-// preg_match_all($regexpr,$text, $matches, PREG_SET_ORDER) ;
-// foreach ($matches as $match) {
-// echo "<li>" ;
-// for($i=1; $i<count($match);$i++) {
-// echo $match[$i] . " --- " ;
-// }
-// echo "</li>" ;
-// }
-
-// exit ;
View
8 tests/testYEd.php
@@ -0,0 +1,8 @@
+<?php
+require_once '../YEd.php' ;
+require_once '../HTML.php' ;
+
+$text = file_get_contents('data/input/g1.html') ;
+var_dump(YEdHTML::getImageAreas($text)) ;
+
+echo '<h1>END OF TESTS</h1>' ;

No commit comments for this range

Something went wrong with that request. Please try again.