function get_dataHelpers($titleKey = 'new', $mvd_id = 'new') { global $mvMetaDataHelpers, $mvMetaCategoryHelper, $wgUser, $mvgScriptPath; $o = ''; $sk = $wgUser->getSkin(); $mvd_type = strtolower(array_shift(split(':', $titleKey))); // init metadata array: label $metaData = array('prop' => array(), 'categories' => array()); // just get msg and basic div layout: \ // css layout of forms was F*@#!!! withing me for some reason so yay table :P $o .= '<span class="mv_basic_edit"><a href="#" onClick="mv_mvd_advs_toggle(' . htmlspecialchars($mvd_id) . ');return false;">' . wfMsg('mv_advanced_edit') . '</a></span> <span style="display:none" class="mv_advanced_edit"><a href="#" onClick="mv_mvd_advs_toggle(' . htmlspecialchars($mvd_id) . ');return false;">' . wfMsg('mv_basic_edit') . '</a></span>'; $o .= '<input type="hidden" id="adv_basic_' . htmlspecialchars($mvd_id) . '" name="adv_basic" value="basic">'; $o .= '<table class="mv_basic_edit mv_dataHelpers" id="mv_dataHelpers_' . htmlspecialchars($mvd_id) . '">'; if (isset($mvMetaDataHelpers[strtolower($mvd_type)])) { // get existing metadata if ($mvd_id != 'new' && $mvd_id != 'seq') { $mvTitle = new MV_Title($titleKey); if (!$mvTitle->validRequestTitle()) { $o .= "<span class=\"error\">Error:</span>" . wfMsg('mvMVDFormat'); return $o; } $metaData = $mvTitle->getMetaData(); } foreach ($mvMetaDataHelpers[strtolower($mvd_type)] as $prop => $ac_index) { $val = ''; // normalize the $prop = str_replace(' ', '_', $prop); // set existing "value" if (isset($metaData['prop'][$prop])) { $val = $metaData['prop'][$prop]; } // make sure the property exists: $swmTitle = Title::newFromText((string) $prop, SMW_NS_PROPERTY); $smwImageHTML = ''; if ($swmTitle->exists()) { // $help_img =$sk->makeKnownLinkObj($swmTitle, '<img src="'.htmlspecialchars($mvgScriptPath).'/skins/images/help_icon.png">'); // special case for person image: (would be good to generalize but kind of complicated) if ($swmTitle->getText() == 'Speech_by') { $img = mv_get_person_img($val); $smwImageHTML = '<img id="smw_' . htmlspecialchars($prop) . '_img" style="display: block;margin-left: auto;margin-right: auto;" src="' . htmlspecialchars($img->getURL()) . '" width=\\"44\\">'; } $o .= "<tr><td><label>" . htmlspecialchars($swmTitle->getText()) . ':</label></td><td>' . $smwImageHTML . '<input class="mv_anno_ac_' . htmlspecialchars($mvd_id) . '" ' . 'size="40" name="smw_' . htmlspecialchars($prop) . '" type="text" value="' . htmlspecialchars($val) . '"> ' . '<div class="autocomplete" id="smw_' . htmlspecialchars($prop) . '_choices_' . htmlspecialchars($mvd_id) . '" style="display: none;"/> </td></tr>'; } else { print '<span class="error">Error:</span>' . $sk->makeKnownLinkObj($swmTitle, $swmTitle->getText()) . ' does not exist<br />'; } } $mvgScriptPath = htmlspecialchars($mvgScriptPath); $mvd_id = htmlspecialchars($mvd_id); if ($mvMetaCategoryHelper) { // list each category with a little - next to it that removes its respective hidden field. $i = 0; $o .= '<tr><td>' . wfMsgExt('mv_existing_categories', array('parsemag', 'escapenoentities'), count($metaData['categories'])) . '</td><td>'; $o .= '<div id="mv_ext_cat_container_' . htmlspecialchars($mvd_id) . '"></div>'; foreach ($metaData['categories'] as $cat => $page) { $catTitle = Title::newFromText($cat, NS_CATEGORY); $o .= '<span id="ext_cat_' . htmlspecialchars($i) . '"><input value="' . $catTitle->getDBkey() . '" type="hidden" style="display:none;" name="ext_cat_' . $i . '" class="mv_ext_cat">' . $catTitle->getText() . '<a href="#" onclick="$j(\'#ext_cat_' . $i . '\').fadeOut(\'fast\').remove();return false;"> <img border="0" src="' . $mvgScriptPath . '/skins/images/delete.png"> </a> </span><br />'; $i++; } $o .= '</tr>'; $o .= "<tr><td><label for=\"category\">" . wfMsg('mv_add_category') . ":</label></td><td><input id=\"mv_add_cat_ext_{$mvd_id}\" maxlength=\"255\" size=\"20\" class=\"mv_anno_ac_{$mvd_id}\" name=\"category\" type=\"text\">\n\t\t\t\t\t\t\t<img onClick=\"mv_add_category('{$mvd_id}', \$j('#mv_add_cat_ext_{$mvd_id}').val());\$j('#mv_add_cat_ext_{$mvd_id}').val('');\" border=\"0\" src=\"{$mvgScriptPath}/skins/images/add.png\">\n\t\t\t\t\t\t\t<div class=\"autocomplete\" id=\"category_choices_{$mvd_id}\" style=\"display: none;\"/></td></tr>"; } // output a short desc field (the text with striped semantic values)... $o .= '<tr><td>' . wfMsg("mv_basic_text_desc") . '</td><td><textarea name="basic_wpTextbox" rows="2" cols="40">'; if (isset($metaData['striped_text'])) { $o .= htmlspecialchars($metaData['striped_text']); } $o .= '</textarea></td></tr>'; } $o .= '</table>'; return $o; }