function do_pre_htEdit()
    {
        global $wgOut, $wgUser;
        $this->loadEditText();
        $MvOverlay = new MV_Overlay();
        // strip semantic tags which are managed by the interface:
        $semantic_data = $MvOverlay->get_and_strip_semantic_tags($this->stripped_edit_text);
        $out = $js_eval = '';
        // add a div for previews:
        $wgOut->addHTML('<div id="wikiPreview_' . $this->mvd_id . '"></div>');
        // set the default action so save page:
        $wgOut->addHTML($this->getAjaxForm());
        // add in adjust html if present:
        $wgOut->addHTML($this->adj_html);
        // structure layout via tables (@@todo switch to class based css layout)
        $wgOut->addHTML('<table style="background: transparent;" width="100%"><tr><td valign="top" width="90">');
        // output the person selector:
        if (!isset($semantic_data['spoken_by'])) {
            $semantic_data['spoken_by'] = '';
        }
        $img = mv_get_person_img($semantic_data['spoken_by']);
        $wgOut->addHTML('<img id="mv_edit_im_' . htmlspecialchars($this->mvd_id) . '" style="display: block;margin-left: auto;margin-right: auto;" src="' . htmlspecialchars($img->getURL()) . '" width="44">');
        $wgOut->addHTML('<input style="font-size:x-small"
						value="' . htmlspecialchars($semantic_data['spoken_by']) . '"
						name="smw_Spoken_By"
						onClick="this.value=\'\';"
						type="text" id="auto_comp_' . htmlspecialchars($this->mvd_id) . '" size="12"
						maxlength="125" autocomplete="off"/>');
        // only add one auto_comp_choices_ per object/request pass
        if (!isset($this->auto_comp_choices)) {
            $this->auto_comp_choices = true;
            $wgOut->addHTML('<div id="auto_comp_choices_' . htmlspecialchars($this->mvd_id) . '" class="autocomplete"></div>');
        }
        // add container formatting for MV_Overlay
        $wgOut->addHTML('</td>' . '<td>');
    }
Exemplo n.º 2
0
    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;
    }
Exemplo n.º 3
0
 function getHTML()
 {
     global $wgUser;
     $o = '';
     $sk = $wgUser->getSkin();
     $dbr = wfGetDB(DB_SLAVE);
     //if in overview mode don't print out the navigator:
     global $wgRequest;
     if ($wgRequest->getVal('view') == 'overview') {
         return '';
     }
     // get all annotative layers
     $stream_id = $this->mv_interface->article->mvTitle->getStreamId();
     $stream_name = $this->mv_interface->article->mvTitle->getStreamName();
     $stream_time_req = $this->mv_interface->article->mvTitle->getTimeRequest();
     $start_sec = $this->mv_interface->article->mvTitle->getStartTimeSeconds();
     $duration_sec = $this->mv_interface->article->mvTitle->getDuration();
     $end_sec = $this->mv_interface->article->mvTitle->getEndTimeSeconds();
     // print "start $start_sec end:$end_sec \n ";
     foreach (array('prev', 'next') as $pntype) {
         if ($o != '') {
             $o .= ' ';
         }
         if ($pntype == 'prev') {
             if ($start_sec == 0) {
                 continue;
             }
             $qstart = 0;
             $qend = $start_sec - 1;
             $orderby = 'end_time DESC';
         } elseif ($pntype == 'next') {
             $qstart = $end_sec + 1;
             $qend = $duration_sec;
             $orderby = 'start_time ASC';
         }
         // print "Qstart looking for $pntype:$qstart:  ".seconds2npt($qstart) ." Qend:$qend : " . seconds2npt($qend) . " \n";
         $mvd_rows = MV_Index::getMVDInRange($stream_id, $qstart, $qend, $mvd_type = 'anno_en', $getText = false, $smw_properties = array('Speech_by', 'Bill', 'category'), $options = array('LIMIT' => 1, 'ORDER BY' => $orderby));
         //print $dbr->lastQuery();
         //print_r($mvd_rows);
         //die;
         // print "SHOULD GET $pntype for $stream_time_req";
         reset($mvd_rows);
         if (count($mvd_rows) != 0) {
             $row = current($mvd_rows);
             // $prev_end = $row->end_time;
             $stime_req = seconds2npt($row->start_time) . '/' . seconds2npt($row->end_time);
             $streamTitle = Title::newFromText($stream_name . '/' . $stime_req, MV_NS_STREAM);
             $tool_tip = '';
             // print_r($row);
             if (isset($row->Speech_by)) {
                 if (trim($row->Speech_by) != '') {
                     //check if the person has an icon:
                     $pimg = mv_get_person_img($row->Speech_by);
                     $o .= wfMsg('mv_' . $pntype . '_speech', $sk->makeKnownLinkObj($streamTitle, '<img title="' . str_replace('_', ' ', $row->Speech_by) . '" width="40" src="' . $pimg->getURL() . '">'));
                     //$o .= wfMsg( 'mv_' . $pntype . '_speech', $sk->makeKnownLinkObj( $streamTitle, str_replace( '_', ' ', $row->Speech_by ) ) );
                     // $tool_tip.=	 'Speech By: '. $row->Speech_by;
                 } elseif (trim($row->Bill) != '') {
                     $o .= wfMsg('mv_' . $pntype . '_bill', $sk->makeKnownLinkObj($streamTitle, str_replace('_', ' ', $row->Bill)));
                 } elseif (is_array($row->category) && count($row->category) != 0) {
                     $first_cat = current($row->category);
                     $o .= wfMsg('mv_' . $pntype . '_cat', $sk->makeKnownLinkObj($streamTitle, str_replace('_', ' ', $first_cat)));
                 }
             }
         }
     }
     return $o;
 }