Index: trunk/extensions/Wikidata/WiktionaryZ/suggest.js |
— | — | @@ -222,7 +222,7 @@ |
223 | 223 | } |
224 | 224 | |
225 | 225 | function getTypeOf(element) { |
226 | | - return getNameOf(element).replace(/\d+/g, "0"); |
| 226 | + return getNameOf(element).replace(/-\d+/g, ""); |
227 | 227 | } |
228 | 228 | |
229 | 229 | function toggle(element, event) { |
Index: trunk/extensions/Wikidata/WiktionaryZ/Editor.php |
— | — | @@ -10,10 +10,13 @@ |
11 | 11 | protected $keyStack; |
12 | 12 | protected $idStack = array(); |
13 | 13 | protected $currentId; |
| 14 | + protected $classStack = array(); |
| 15 | + protected $currentClass; |
14 | 16 | |
15 | 17 | public function __construct($prefix) { |
16 | 18 | $this->keyStack = new RecordStack(); |
17 | 19 | $this->currentId = $prefix; |
| 20 | + $this->currentClass = $prefix; |
18 | 21 | } |
19 | 22 | |
20 | 23 | protected function getKeyIds($record) { |
— | — | @@ -34,6 +37,15 @@ |
35 | 38 | $this->currentId = array_pop($this->idStack); |
36 | 39 | } |
37 | 40 | |
| 41 | + protected function pushClass($class) { |
| 42 | + $this->classStack[] = $this->currentClass; |
| 43 | + $this->currentClass .= '-' . $class; |
| 44 | + } |
| 45 | + |
| 46 | + protected function popClass() { |
| 47 | + $this->currentClass = array_pop($this->classStack); |
| 48 | + } |
| 49 | + |
38 | 50 | public function pushKey($record) { |
39 | 51 | $this->keyStack->push($record); |
40 | 52 | $this->pushId(implode("-", $this->getKeyIds($record))); |
— | — | @@ -41,6 +53,7 @@ |
42 | 54 | |
43 | 55 | public function pushAttribute($attribute) { |
44 | 56 | $this->pushId($attribute->id); |
| 57 | + $this->pushClass($attribute->id); |
45 | 58 | } |
46 | 59 | |
47 | 60 | public function popKey() { |
— | — | @@ -50,19 +63,20 @@ |
51 | 64 | |
52 | 65 | public function popAttribute() { |
53 | 66 | $this->popId(); |
| 67 | + $this->popClass(); |
54 | 68 | } |
55 | 69 | |
56 | 70 | public function getId() { |
57 | 71 | return $this->currentId; |
58 | 72 | } |
59 | 73 | |
| 74 | + public function getClass() { |
| 75 | + return $this->currentClass; |
| 76 | + } |
| 77 | + |
60 | 78 | public function getKeyStack() { |
61 | 79 | return $this->keyStack; |
62 | 80 | } |
63 | | - |
64 | | - public function getElementType() { |
65 | | - return preg_replace("/\\d+/", "0", $this->getId()); |
66 | | - } |
67 | 81 | } |
68 | 82 | |
69 | 83 | interface PermissionController { |
— | — | @@ -897,13 +911,13 @@ |
898 | 912 | foreach ($this->editors as $editor) { |
899 | 913 | $attribute = $editor->getAttribute(); |
900 | 914 | $idPath->pushAttribute($attribute); |
901 | | - $elementType = $idPath->getElementType(); |
902 | | - $expansionPrefix = $this->getExpansionPrefix($elementType); |
903 | | - $this->setExpansionByEditor($editor, $elementType); |
| 915 | + $class = $idPath->getClass(); |
| 916 | + $expansionPrefix = $this->getExpansionPrefix($class); |
| 917 | + $this->setExpansionByEditor($editor, $class); |
904 | 918 | $attributeId = $idPath->getId(); |
905 | 919 | $result .= '<li>'. |
906 | 920 | '<h4 id="collapse-'. $attributeId .'" class="toggle" onclick="toggle(this, event);">' . $expansionPrefix . ' ' . $attribute->name . '</h4>' . |
907 | | - '<div id="collapsable-'. $attributeId . '" class="expand-' . $elementType . '">' . $editor->view($idPath, $value->getAttributeValue($attribute)) . '</div>' . |
| 921 | + '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->view($idPath, $value->getAttributeValue($attribute)) . '</div>' . |
908 | 922 | '</li>'; |
909 | 923 | $idPath->popAttribute(); |
910 | 924 | } |
— | — | @@ -920,14 +934,14 @@ |
921 | 935 | $attribute = $editor->getAttribute(); |
922 | 936 | |
923 | 937 | $idPath->pushAttribute($attribute); |
924 | | - $elementType = $idPath->getElementType(); |
925 | | - $this->setExpansionByEditor($editor, $elementType); |
926 | | - $expansionPrefix = $this->getExpansionPrefix($elementType); |
| 938 | + $class = $idPath->getClass(); |
| 939 | + $this->setExpansionByEditor($editor, $class); |
| 940 | + $expansionPrefix = $this->getExpansionPrefix($class); |
927 | 941 | $attributeId = $idPath->getId(); |
928 | 942 | |
929 | 943 | $result .= '<li>'. |
930 | 944 | '<h4 id="collapse-'. $attributeId .'" class="toggle" onclick="toggle(this, event);">' . $expansionPrefix . ' ' . $attribute->name . '</h4>' . |
931 | | - '<div id="collapsable-'. $attributeId . '" class="expand-' . $elementType . '">' . $editor->edit($idPath, $value->getAttributeValue($attribute)) . '</div>' . |
| 945 | + '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->edit($idPath, $value->getAttributeValue($attribute)) . '</div>' . |
932 | 946 | '</li>'; |
933 | 947 | $idPath->popAttribute(); |
934 | 948 | } |
— | — | @@ -944,14 +958,14 @@ |
945 | 959 | if ($attribute = $editor->getAddAttribute()) { |
946 | 960 | $attribute = $editor->getAttribute(); |
947 | 961 | $idPath->pushAttribute($attribute); |
948 | | - $elementType = $idPath->getElementType(); |
949 | | - $this->setExpansionByEditor($editor, $elementType); |
950 | | - $expansionPrefix = $this->getExpansionPrefix($elementType); |
| 962 | + $class = $idPath->getClass(); |
| 963 | + $this->setExpansionByEditor($editor, $class); |
| 964 | + $expansionPrefix = $this->getExpansionPrefix($class); |
951 | 965 | $attributeId = $idPath->getId(); |
952 | 966 | |
953 | 967 | $result .= '<li>'. |
954 | 968 | '<h4 id="collapse-'. $attributeId .'" class="toggle" onclick="toggle(this, event);">' . $expansionPrefix . ' ' . $attribute->name . '</h4>' . |
955 | | - '<div id="collapsable-'. $attributeId . '" class="expand-' . $elementType . '">' . $editor->add($idPath) . '</div>' . |
| 969 | + '<div id="collapsable-'. $attributeId . '" class="expand-' . $class . '">' . $editor->add($idPath) . '</div>' . |
956 | 970 | '</li>'; |
957 | 971 | $editor->add($idPath); |
958 | 972 | $idPath->popAttribute(); |
— | — | @@ -1007,11 +1021,11 @@ |
1008 | 1022 | $idPath->pushKey(project($record, $key)); |
1009 | 1023 | $recordId = $idPath->getId(); |
1010 | 1024 | if($i==0) { |
1011 | | - $captionElementType = $idPath->getElementType(); |
1012 | | - $captionExpansionPrefix = $this->getExpansionPrefix($captionElementType); |
1013 | | - $this->setExpansion($this->childrenExpanded, $captionElementType); |
1014 | | - $valueElementType = $idPath->getElementType(); |
1015 | | - $this->setExpansion($this->childrenExpanded, $valueElementType); |
| 1025 | + $captionClass = $idPath->getClass(); |
| 1026 | + $captionExpansionPrefix = $this->getExpansionPrefix($captionClass); |
| 1027 | + $this->setExpansion($this->childrenExpanded, $captionClass); |
| 1028 | + $valueClass = $idPath->getClass(); |
| 1029 | + $this->setExpansion($this->childrenExpanded, $valueClass); |
1016 | 1030 | } |
1017 | 1031 | |
1018 | 1032 | $idPath->pushAttribute($captionAttribute); |
— | — | @@ -1020,7 +1034,7 @@ |
1021 | 1035 | $idPath->popAttribute(); |
1022 | 1036 | |
1023 | 1037 | $idPath->pushAttribute($valueAttribute); |
1024 | | - $result .= '<div id="collapsable-'. $recordId . '" class="expand-' . $valueElementType . '">' . $this->valueEditor->view($idPath, $record->getAttributeValue($valueAttribute)) . '</div>' . |
| 1038 | + $result .= '<div id="collapsable-'. $recordId . '" class="expand-' . $valueClass . '">' . $this->valueEditor->view($idPath, $record->getAttributeValue($valueAttribute)) . '</div>' . |
1025 | 1039 | '</li>'; |
1026 | 1040 | $idPath->popAttribute(); |
1027 | 1041 | |
— | — | @@ -1046,11 +1060,11 @@ |
1047 | 1061 | $recordId = $idPath->getId(); |
1048 | 1062 | |
1049 | 1063 | if($i==0) { |
1050 | | - $captionElementType = $idPath->getElementType(); |
1051 | | - $captionExpansionPrefix = $this->getExpansionPrefix($captionElementType); |
1052 | | - $this->setExpansion($this->childrenExpanded, $captionElementType); |
1053 | | - $valueElementType = $idPath->getElementType(); |
1054 | | - $this->setExpansion($this->childrenExpanded, $valueElementType); |
| 1064 | + $captionClass = $idPath->getClass(); |
| 1065 | + $captionExpansionPrefix = $this->getExpansionPrefix($captionClass); |
| 1066 | + $this->setExpansion($this->childrenExpanded, $captionClass); |
| 1067 | + $valueClass = $idPath->getClass(); |
| 1068 | + $this->setExpansion($this->childrenExpanded, $valueClass); |
1055 | 1069 | } |
1056 | 1070 | |
1057 | 1071 | $idPath->pushAttribute($captionAttribute); |
— | — | @@ -1059,7 +1073,7 @@ |
1060 | 1074 | $idPath->popAttribute(); |
1061 | 1075 | |
1062 | 1076 | $idPath->pushAttribute($valueAttribute); |
1063 | | - $result .= '<div id="collapsable-'. $recordId . '" class="expand-' . $valueElementType . '">' . $this->valueEditor->edit($idPath, $record->getAttributeValue($valueAttribute)) . '</div>' . |
| 1077 | + $result .= '<div id="collapsable-'. $recordId . '" class="expand-' . $valueClass . '">' . $this->valueEditor->edit($idPath, $record->getAttributeValue($valueAttribute)) . '</div>' . |
1064 | 1078 | '</li>'; |
1065 | 1079 | $idPath->popAttribute(); |
1066 | 1080 | |
— | — | @@ -1069,16 +1083,16 @@ |
1070 | 1084 | if ($this->allowAdd) { |
1071 | 1085 | $recordId = 'add-' . $idPath->getId(); |
1072 | 1086 | $idPath->pushAttribute($captionAttribute); |
1073 | | - $elementType = $idPath->getElementType(); |
| 1087 | + $class = $idPath->getClass(); |
1074 | 1088 | |
1075 | | - $this->setExpansion(true, $elementType); |
| 1089 | + $this->setExpansion(true, $class); |
1076 | 1090 | |
1077 | 1091 | $result .= '<li>'. |
1078 | | - '<h' . $this->headerLevel .' id="collapse-'. $recordId .'" class="toggle" onclick="toggle(this, event);">' . $this->getExpansionPrefix($elementType) . ' <img src="extensions/Wikidata/Images/Add.png" title="Enter new list item to add" alt="Add"/> ' . $this->captionEditor->add($idPath) . '</h' . $this->headerLevel .'>'; |
| 1092 | + '<h' . $this->headerLevel .' id="collapse-'. $recordId .'" class="toggle" onclick="toggle(this, event);">' . $this->getExpansionPrefix($class) . ' <img src="extensions/Wikidata/Images/Add.png" title="Enter new list item to add" alt="Add"/> ' . $this->captionEditor->add($idPath) . '</h' . $this->headerLevel .'>'; |
1079 | 1093 | $idPath->popAttribute(); |
1080 | 1094 | |
1081 | 1095 | $idPath->pushAttribute($valueAttribute); |
1082 | | - $result .= '<div id="collapsable-'. $recordId . '" class="expand-' . $elementType . '">' . $this->valueEditor->add($idPath) . '</div>' . |
| 1096 | + $result .= '<div id="collapsable-'. $recordId . '" class="expand-' . $class . '">' . $this->valueEditor->add($idPath) . '</div>' . |
1083 | 1097 | '</li>'; |
1084 | 1098 | $idPath->popAttribute(); |
1085 | 1099 | } |
— | — | @@ -1096,16 +1110,16 @@ |
1097 | 1111 | $recordId = 'add-' . $idPath->getId(); |
1098 | 1112 | |
1099 | 1113 | $idPath->pushAttribute($captionAttribute); |
1100 | | - $elementType = $idPath->getElementType(); |
| 1114 | + $class = $idPath->getClass(); |
1101 | 1115 | |
1102 | | - $this->setExpansion(true, $elementType); |
| 1116 | + $this->setExpansion(true, $class); |
1103 | 1117 | |
1104 | 1118 | $result .= '<li>'. |
1105 | | - '<h' . $this->headerLevel .' id="collapse-'. $recordId .'" class="toggle" onclick="toggle(this, event);">' . $this->getExpansionPrefix($elementType) . ' ' . $this->captionEditor->add($idPath) . '</h' . $this->headerLevel .'>'; |
| 1119 | + '<h' . $this->headerLevel .' id="collapse-'. $recordId .'" class="toggle" onclick="toggle(this, event);">' . $this->getExpansionPrefix($class) . ' ' . $this->captionEditor->add($idPath) . '</h' . $this->headerLevel .'>'; |
1106 | 1120 | $idPath->popAttribute(); |
1107 | 1121 | |
1108 | 1122 | $idPath->pushAttribute($valueAttribute); |
1109 | | - $result .= '<div id="collapsable-'. $recordId . '" class="expand-' . $elementType . '">' . $this->valueEditor->add($idPath) . '</div>' . |
| 1123 | + $result .= '<div id="collapsable-'. $recordId . '" class="expand-' . $class . '">' . $this->valueEditor->add($idPath) . '</div>' . |
1110 | 1124 | '</li>'; |
1111 | 1125 | $idPath->popAttribute(); |
1112 | 1126 | |