function mia_results($results){
    global $date_fields,$dont_pull;
    $getfields = sql_query("SELECT ref,title FROM resource_type_field");
    $fieldnames = array();
    for($g=0; $g<count($getfields); $g++){
       $fieldnames[$getfields[$g]['ref']]=$getfields[$g]['title'];
    }
    for($i = 0; $i < count($results); $i++) {
        $ref = $results[$i]['ref'];
        if(isset($results[$i]['ref'])){
            $query=sql_query("SELECT * FROM resource_data WHERE resource = $ref AND value != '' AND value!='NULL' AND value != ','");
            for($q=0; $q<count($query); $q++){
                if($query[$q]['value'] != "," && $query[$q]['value'] !="" && array_key_exists($query[$q]['resource_type_field'],$fieldnames)){
                    if(substr($query[$q]['value'],0,1)==","){
                        $results[$i][$fieldnames[$query[$q]['resource_type_field']]]=substr($query[$q]['value'],1);
                    }else{
                        $results[$i][$fieldnames[$query[$q]['resource_type_field']]]=$query[$q]['value'];
                    }
                }
            }

            $access = get_resource_access($results[$i]);
            $filepath = get_resource_path($results[$i]['ref'], TRUE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
            $original_link = get_resource_path($results[$i]['ref'], FALSE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
            if(file_exists($filepath)) {
                $results[$i]['original_link'] = $original_link;
            } else {
                $results[$i]['original_link'] = 'No original link available.';
            }
            // Get the size of the original file:
           /* $original_size = get_original_imagesize($results[$i]['ref'], $filepath, $results[$i]['file_extension']);
            $original_size = formatfilesize($original_size[0]);
            $original_size = str_replace('&nbsp;', ' ', $original_size);
            $results[$i]['original_size'] = $original_size;*/
            foreach($results[$i] as $k => $v){
                if($v == "" || $v ==","){
                    unset($results[$i][$k]);
                }
                if($k == "created_by"){
                    $user = get_user($v);
                    $results[$i][$k]=$user["fullname"];
                }
                if(in_array($k,$date_fields)){
                    $unix = strtotime($v);
                    $datetime = date('y-m-d',$unix);
                    $results[$i][$k] = $datetime;
                }
                if($k == "resource_type" && is_numeric($v)){
                   $results[$i][$k]=get_resource_type_name($v);
                }
                //need to convert type to string here
                if(in_array($k,$dont_pull)){
                   unset($results[$i][$k]);
                }
            }
       }
//  var_dump($results);exit();
  return $results;
  }
}
示例#2
0
function savetoelastic($ref){
global $baseurl, $pagename;
if($pagename != "upload2"){
//error_log($ref);
   $results=array();
   $results[] = get_resource_data($ref,false);
   $resourcetype=get_resource_type_name($results[0]['resource_type']);
   if($resourcetype != "Audio"){
     $thethumb = $baseurl.str_replace("/var/www/include/..","",get_resource_path($ref,true,"thm",false,"jpg"));
     if(!file_exists($thethumb)){
       $thethumb = $results[0]["thumbnail"] = $baseurl."/gfx/no_preview/extension/".$results[0]['file_extension'].".png";
     }
     $results[0]["thumbnail"]=$thethumb;
   }else{
     $results[0]["thumbnail"] = $baseurl."/gfx/no_preview/extension/".$results[0]['file_extension'].".png";
   }
   if($resourcetype == "Audio"){
       $results[0]["preview"]=$baseurl.str_replace("/var/www/include/..","",get_resource_path($ref, true, "", false, "mp3"));
   }else if($resourcetype == "Video"){
       $results[0]["preview"]=$baseurl.str_replace("/var/www/include/..","",get_resource_path($ref, true, "pre", false, "mp4"));
   }
   $results = mia_results($results);
   $results=json_encode($results[0]);
   $query = push_RStoElastic($resourcetype,$ref,$results);
   if($query == false){
       //failed to connect to elastic search
       createcron($attempts=1, $ref);
   }else{
//       var_dump($query);exit();
   }
   return;
}
}
示例#3
0
function  HookMia_uploadEditEditbeforeheader(){
    global $baseurl;
    $resource_types=get_resource_types();
    $resource_extensions=array();
    $display_extensions = array();
    for($i=0; $i<count($resource_types); $i++){
        $display_extensions[get_resource_type_name($i+1)]=$resource_types[$i]['allowed_extensions'];
        //explode the allowed extensions into an array and remove any whitespaces?*
        $extension = preg_replace('/\s*/', '', $resource_types[$i]['allowed_extensions']);
        $before = explode("," , strtolower($extension));
        foreach($before as $after){
            $resource_extensions[] = $after;
        };
    };
    $resource_extensions = json_encode($resource_extensions);
    $getTMS=sql_query("select ref, tms_field from resource_type_field where tms_field != ''");
    $TMS = json_encode($getTMS);
    ?>

<script type="text/javascript">
        var identifier = 0;
        var filesinbatch = new Array();
        var allowedext = <?php echo($resource_extensions); ?>;
        var display_ext = <?php echo json_encode($display_extensions, true); ?>;
        var jpray = <?php echo($TMS); ?>;
</script>
<?php
}
示例#4
0
    ?>
<div class="itemNarrow"><h3><?php 
    echo $lang["access"];
    ?>
</h3><p><?php 
    echo @$lang["access" . $resource["access"]];
    ?>
</p></div><?php 
}
if ($show_resource_type) {
    ?>
<div class="itemNarrow"><h3><?php 
    echo $lang["resourcetype"];
    ?>
</h3><p><?php 
    echo get_resource_type_name($resource["resource_type"]);
    ?>
</p></div><?php 
}
if ($show_hitcount) {
    ?>
<div class="itemNarrow"><h3><?php 
    echo $resource_hit_count_on_downloads ? $lang["downloads"] : $lang["hitcount"];
    ?>
</h3><p><?php 
    echo $resource["hit_count"] + $resource["new_hit_count"];
    ?>
</p></div><?php 
}
hook("extrafields");
# contributed by field
示例#5
0
function display_field($n, $field, $newtab = false)
{
    global $use, $ref, $original_fields, $multilingual_text_fields, $multiple, $lastrt, $is_template, $language, $lang, $blank_edit_template, $edit_autosave, $errors, $tabs_on_edit, $collapsible_sections, $ctrls_to_save, $embedded_data_user_select, $embedded_data_user_select_fields;
    $name = "field_" . $field["ref"];
    $value = $field["value"];
    $value = trim($value);
    if ($field["omit_when_copying"] && $use != $ref) {
        # Omit when copying - return this field back to the value it was originally, instead of using the current value which has been fetched from the new resource.
        reset($original_fields);
        foreach ($original_fields as $original_field) {
            if ($original_field["ref"] == $field["ref"]) {
                $value = $original_field["value"];
            }
        }
    }
    $displaycondition = true;
    if ($field["display_condition"] != "") {
        #Check if field has a display condition set
        $displaycondition = check_display_condition($n, $field);
    }
    if ($multilingual_text_fields) {
        # Multilingual text fields - find all translations and display the translation for the current language.
        $translations = i18n_get_translations($value);
        if (array_key_exists($language, $translations)) {
            $value = $translations[$language];
        } else {
            $value = "";
        }
    }
    if ($multiple) {
        $value = "";
    }
    # Blank the value for multi-edits.
    if ($field["resource_type"] != $lastrt && $lastrt != -1 && $collapsible_sections) {
        ?>
</div><h2 class="CollapsibleSectionHead" id="resource_type_properties"><?php 
        echo htmlspecialchars(get_resource_type_name($field["resource_type"]));
        ?>
 <?php 
        echo $lang["properties"];
        ?>
</h2><div class="CollapsibleSection" id="ResourceProperties<?php 
        if ($ref == -1) {
            echo "Upload";
        }
        echo $field["resource_type"];
        ?>
Section"><?php 
    }
    $lastrt = $field["resource_type"];
    # Blank form if 'reset form' has been clicked.
    if (getval("resetform", "") != "") {
        $value = "";
    }
    # If config option $blank_edit_template is set, always show a blank form for user edit templates.
    if ($ref < 0 && $blank_edit_template && getval("submitted", "") == "") {
        $value = "";
    }
    ?>
	<?php 
    if ($multiple && !hook("replace_edit_all_checkbox", "", array($field["ref"]))) {
        # Multiple items, a toggle checkbox appears which activates the question
        ?>
<div class="edit_multi_checkbox"><input name="editthis_<?php 
        echo htmlspecialchars($name);
        ?>
" id="editthis_<?php 
        echo $n;
        ?>
" type="checkbox" value="yes" onClick="var q=document.getElementById('question_<?php 
        echo $n;
        ?>
');var m=document.getElementById('modeselect_<?php 
        echo $n;
        ?>
');var f=document.getElementById('findreplace_<?php 
        echo $n;
        ?>
');if (this.checked) {q.style.display='block';m.style.display='block';} else {q.style.display='none';m.style.display='none';f.style.display='none';document.getElementById('modeselectinput_<?php 
        echo $n;
        ?>
').selectedIndex=0;}">&nbsp;<label for="editthis<?php 
        echo $n;
        ?>
"><?php 
        echo htmlspecialchars($field["title"]);
        ?>
</label></div><!-- End of edit_multi_checkbox --><?php 
    }
    ?>

	<?php 
    if ($multiple && !hook("replace_edit_all_mode_select", "", array($field["ref"]))) {
        # When editing multiple, give option to select Replace All Text or Find and Replace
        ?>
		<div class="Question" id="modeselect_<?php 
        echo $n;
        ?>
" style="display:none;padding-bottom:0;margin-bottom:0;">
		<label for="modeselectinput"><?php 
        echo $lang["editmode"];
        ?>
</label>
		<select id="modeselectinput_<?php 
        echo $n;
        ?>
" name="modeselect_<?php 
        echo $field["ref"];
        ?>
" class="stdwidth" onChange="var fr=document.getElementById('findreplace_<?php 
        echo $n;
        ?>
');var q=document.getElementById('question_<?php 
        echo $n;
        ?>
');if (this.value=='FR') {fr.style.display='block';q.style.display='none';} else {fr.style.display='none';q.style.display='block';}<?php 
        hook("edit_all_mode_js");
        ?>
">
		<option value="RT"><?php 
        echo $lang["replacealltext"];
        ?>
</option>
		<?php 
        if (in_array($field["type"], array("0", "1", "5", "8"))) {
            # Find and replace appies to text boxes only.
            ?>
		<option value="FR"><?php 
            echo $lang["findandreplace"];
            ?>
</option>
		<?php 
        }
        ?>
		<?php 
        if ($field["type"] == 0 || $field["type"] == 1 || $field["type"] == 5) {
            # Prepend applies to text boxes only.
            ?>
		<option value="PP"><?php 
            echo $lang["prependtext"];
            ?>
</option>
		<?php 
        }
        if (in_array($field["type"], array("0", "1", "2", "3", "5", "7", "8", "9"))) {
            # Append applies to text boxes, checkboxes ,category tree and dropdowns only.
            ?>
		<option value="AP"><?php 
            echo $lang["appendtext"];
            ?>
</option>
		<?php 
        }
        if ($field["type"] == 0 || $field["type"] == 1 || $field["type"] == 5 || $field["type"] == 2 || $field["type"] == 3) {
            ?>
		<!--- Remove applies to text boxes, checkboxes and dropdowns only. -->
		<option value="RM"><?php 
            echo $lang["removetext"];
            ?>
</option>
		<?php 
        }
        ?>
		<?php 
        hook("edit_all_extra_modes");
        ?>
		</select>
		</div><!-- End of modeselect_<?php 
        echo $n;
        ?>
 -->

		<div class="Question" id="findreplace_<?php 
        echo $n;
        ?>
" style="display:none;border-top:none;">
		<label>&nbsp;</label>
		<?php 
        echo $lang["find"];
        ?>
 <input type="text" name="find_<?php 
        echo $field["ref"];
        ?>
" class="shrtwidth">
		<?php 
        echo $lang["andreplacewith"];
        ?>
 <input type="text" name="replace_<?php 
        echo $field["ref"];
        ?>
" class="shrtwidth">
		</div><!-- End of findreplace_<?php 
        echo $n;
        ?>
 -->
		
		<?php 
        hook("edit_all_after_findreplace", "", array($field, $n));
        ?>
		<?php 
    }
    ?>

	<div class="Question" id="question_<?php 
    echo $n;
    ?>
" <?php 
    if ($multiple || !$displaycondition || $newtab) {
        ?>
style="border-top:none;<?php 
        if ($multiple || !$displaycondition) {
            ?>
			display:none;
			<?php 
        }
    }
    ?>
">
		<?php 
    $labelname = $name;
    // Add _selector to label so it will keep working:
    if ($field['type'] == 9) {
        $labelname .= '_selector';
    }
    // Add -d to label so it will keep working
    if ($field['type'] == 4) {
        $labelname .= '-d';
    }
    ?>
	<label for="<?php 
    echo htmlspecialchars($labelname);
    ?>
" ><?php 
    if (!$multiple) {
        echo htmlspecialchars($field["title"]);
        ?>
 <?php 
        if (!$is_template && $field["required"] == 1) {
            ?>
<sup>*</sup><?php 
        }
    }
    ?>
</label>

	<?php 
    # Autosave display
    if ($edit_autosave || $ctrls_to_save) {
        ?>
	<div class="AutoSaveStatus" id="AutoSaveStatus<?php 
        echo $field["ref"];
        ?>
" style="display:none;"></div>
	<?php 
    }
    ?>


	<?php 
    # Define some Javascript for help actions (applies to all fields)
    $help_js = "onBlur=\"HideHelp(" . $field["ref"] . ");return false;\" onFocus=\"ShowHelp(" . $field["ref"] . ");return false;\"";
    #hook to modify field type in special case. Returning zero (to get a standard text box) doesn't work, so return 1 for type 0, 2 for type 1, etc.
    $modified_field_type = "";
    $modified_field_type = hook("modifyfieldtype");
    if ($modified_field_type) {
        $field["type"] = $modified_field_type - 1;
    }
    hook("addfieldextras");
    # ----------------------------  Show field -----------------------------------
    $type = $field["type"];
    if ($type == "") {
        $type = 0;
    }
    # Default to text type.
    if (!hook("replacefield", "", array($field["type"], $field["ref"], $n))) {
        global $auto_order_checkbox;
        include "edit_fields/" . $type . ".php";
    }
    # ----------------------------------------------------------------------------
    # Display any error messages from previous save
    if (array_key_exists($field["ref"], $errors)) {
        ?>
		<div class="FormError">!! <?php 
        echo $errors[$field["ref"]];
        ?>
 !!</div>
		<?php 
    }
    if (trim($field["help_text"] != "")) {
        # Show inline help for this field.
        # For certain field types that have no obvious focus, the help always appears.
        ?>
		<div class="FormHelp" style="padding:0;<?php 
        if (!in_array($field["type"], array(2, 4, 6, 7, 10))) {
            ?>
 display:none;<?php 
        } else {
            ?>
 clear:left;<?php 
        }
        ?>
" id="help_<?php 
        echo $field["ref"];
        ?>
"><div class="FormHelpInner"><?php 
        echo nl2br(trim(htmlspecialchars(i18n_get_translated($field["help_text"], false))));
        ?>
</div></div>
		<?php 
    }
    # If enabled, include code to produce extra fields to allow multilingual free text to be entered.
    if ($multilingual_text_fields && ($field["type"] == 0 || $field["type"] == 1 || $field["type"] == 5)) {
        display_multilingual_text_field($n, $field, $translations);
    }
    if ($embedded_data_user_select || isset($embedded_data_user_select_fields) && in_array($field["ref"], $embedded_data_user_select_fields)) {
        ?>
		<table id="exif_<?php 
        echo $field["ref"];
        ?>
" class="ExifOptions" cellpadding="3" cellspacing="3" <?php 
        if ($embedded_data_user_select) {
            ?>
 style="display: none;" <?php 
        }
        ?>
>                    
			<tbody>
				<tr>		
					<td>
					<?php 
        echo "&nbsp;&nbsp;" . $lang["embeddedvalue"] . ": ";
        ?>
					</td>
					<td width="10" valign="middle">
						<input type="radio" id="exif_extract_<?php 
        echo $field["ref"];
        ?>
" name="exif_option_<?php 
        echo $field["ref"];
        ?>
" value="yes" checked>
					</td>
					<td align="left" valign="middle">
						<label class="customFieldLabel" for="exif_extract_<?php 
        echo $field["ref"];
        ?>
"><?php 
        echo $lang["embedded_metadata_extract_option"];
        ?>
</label>
					</td>
		
							
					<td width="10" valign="middle">
						<input type="radio" id="no_exif_<?php 
        echo $field["ref"];
        ?>
" name="exif_option_<?php 
        echo $field["ref"];
        ?>
" value="no">
					</td>
					<td align="left" valign="middle">
						<label class="customFieldLabel" for="no_exif_<?php 
        echo $field["ref"];
        ?>
"><?php 
        echo $lang["embedded_metadata_donot_extract_option"];
        ?>
</label>
					</td>
		
							
					<td width="10" valign="middle">
						<input type="radio" id="exif_append_<?php 
        echo $field["ref"];
        ?>
" name="exif_option_<?php 
        echo $field["ref"];
        ?>
" value="append">
					</td>
					<td align="left" valign="middle">
						<label class="customFieldLabel" for="exif_append_<?php 
        echo $field["ref"];
        ?>
"><?php 
        echo $lang["embedded_metadata_append_option"];
        ?>
</label>
					</td>
		
							
					<td width="10" valign="middle">
						<input type="radio" id="exif_prepend_<?php 
        echo $field["ref"];
        ?>
" name="exif_option_<?php 
        echo $field["ref"];
        ?>
" value="prepend">
					</td>
					<td align="left" valign="middle">
						<label class="customFieldLabel" for="exif_prepend_<?php 
        echo $field["ref"];
        ?>
"><?php 
        echo $lang["embedded_metadata_prepend_option"];
        ?>
</label>
					</td>
					
							</tr>
			</tbody>
		</table>		
		<?php 
    }
    ?>
	<div class="clearerleft"> </div>
	</div><!-- end of question_<?php 
    echo $n;
    ?>
 div -->
	<?php 
    hook('afterfielddisplay', '', array($n, $field));
}
示例#6
0
		
		}
	
		
	if ($multilingual_text_fields)
		{
		# Multilingual text fields - find all translations and display the translation for the current language.
		$translations=i18n_get_translations($value);
		if (array_key_exists($language,$translations)) {$value=$translations[$language];} else {$value="";}
		}
	
	if ($multiple) {$value="";} # Blank the value for multi-edits.
	
	if (($fields[$n]["resource_type"]!=$lastrt)&& ($lastrt!=-1))
		{
		?><br /><h1 id="resource_type_properties"><?php echo htmlspecialchars(get_resource_type_name($fields[$n]["resource_type"]))?> <?php echo $lang["properties"]?></h1><?php
		}
	$lastrt=$fields[$n]["resource_type"];
	
	# Blank form if 'reset form' has been clicked.
	if (getval("resetform","")!="") {$value="";}

	# If config option $blank_edit_template is set, always show a blank form for user edit templates.
	if ($ref<0 && $blank_edit_template && getval("submitted","")=="") {$value="";}

	?>
	<?php if ($multiple && !hook("replace_edit_all_checkbox","",array($fields[$n]["ref"]))) { # Multiple items, a toggle checkbox appears which activates the question
	?><div><input name="editthis_<?php echo htmlspecialchars($name)?>" id="editthis_<?php echo $n?>" type="checkbox" value="yes" onClick="var q=document.getElementById('question_<?php echo $n?>');var m=document.getElementById('modeselect_<?php echo $n?>');var f=document.getElementById('findreplace_<?php echo $n?>');if (this.checked) {q.style.display='block';m.style.display='block';} else {q.style.display='none';m.style.display='none';f.style.display='none';document.getElementById('modeselectinput_<?php echo $n?>').selectedIndex=0;}">&nbsp;<label for="editthis<?php echo $n?>"><?php echo htmlspecialchars($fields[$n]["title"])?></label></div><?php } ?>

	<?php
	if ($multiple && !hook("replace_edit_all_mode_select","",array($fields[$n]["ref"])))
function updateResourcesFromContacts($resourcestoupdate,$rs_fields,$resref, $oldvals,$oldvalmatch){
    $resourceupdates = array(); $resources=array(); $rf=array(); $rv=array(); $toindex=array();//empty array vars

    //filter for only resources where this name matches the resource_field_type
    $filteredray = array();
    for ($ru=0; $ru<count($resourcestoupdate); $ru++){
        if($resourcestoupdate[$ru]['resource_type_field']==$resref){
            $filteredray[] = $resourcestoupdate[$ru];
        };
    };
    //loop through the filtered resources
    for($r=0; $r<count($filteredray); $r++){
        //for all of the resources and foreach mapped resource field
        foreach($rs_fields as $k => $v){
            if($v !=""){
                // Check to see if resource data exists for that field and resource
                $exists = sql_query("SELECT * FROM resource_data WHERE resource ='".$filteredray[$r]['resource']."' AND resource_type_field='".$k."'");
                //if it doesn't exist and the value has changed
                if(empty($exists) && !in_array($v,$oldvals[0])){
                    //push the data that needs to be INSERTED
                    $resourceupdates[]="(".$filteredray[$r]['resource'].",".$k.",'".$v."')";
                    $oldkey = matcholdkey($k,$oldvalmatch);
                    $toindex[]=$k.",'".$v."',".$filteredray[$r]['resource'].",'".$oldvals[0][$oldkey]."'";
                    // else if the value does exist and the value has changed
                }else if(!in_array($v,$oldvals[0])){
                    //push the data that needs to be UPDATED
                    $resources[]=$filteredray[$r]['resource'];
                    $rf[]=$k;
                    $rv[]=$v;
                    $oldkey=matcholdkey($k,$oldvalmatch);
                    $toindex[]=$k.",'".$v."',".$filteredray[$r]['resource'].",'".$oldvals[0][$oldkey]."'";
                };
            };
        };
    };//end filtered loop

    $updateq = "";
    //if there is data to INSERT build the statement
    if(!empty($resourceupdates)){
        sql_query("INSERT INTO resource_data (resource, resource_type_field, value) VALUES ". join(",",$resourceupdates));
    }
    //if there is data to UPDATE build the statement
    if(!empty($resources)){
        $updateq = "UPDATE resource_data SET value = CASE resource_type_field";
        foreach($rs_fields as $k => $v){
            if($v !=""){
                $updateq .= " WHEN $k THEN '$v' \n";
            }
        };
        $updateq .= "ELSE value END ";
        $updateq .= "WHERE resource IN (" . join(",",$resources).")";
        sql_query($updateq);//update
    }
    //add remove and index keywords
    for($ti = 0; $ti<count($toindex);$ti++){
        $toind = explode(",", $toindex[$ti]);
        remove_keyword_mappings($toind[2],$toind[3],$toind[0]);
        add_keyword_mappings($toind[2],$toind[1],$toind[0]);
    }
    $results=array();
    for($fr=0; $fr<count($filteredray); $fr++){
        $ref=$filteredray[$fr]['resource'];
        $results[]=get_resource_data($ref);
    }
    //elastic search
    $results=mia_results($results);
    $resource_types=get_resource_types();
    $results=mia_elastic_encode($resource_types,$results,false);
    for($e=0; $e<count($results); $e++){
        $resourcetype=get_resource_type_name($results[$e]['resource_type']);
        $ref=$results[$e]['ref'];
        push_RStoElastic($resourcetype,$ref,json_encode($results[$e]));
    }
};//end function
示例#8
0
        }else{
          $query = sql_query("INSERT INTO resource_data VALUES ($ref,$key,'$val')");
          if($query === false){
            $qerr[]="INSERT INTO resource_data VALUES ($ref,$key,'$val')";
          }
        }
      }
    }
    if(empty($qerr)){
      $results=array();
      $results[] = get_resource_data($ref,false);
      $thumb_path = array("thumbnail"=>$baseurl.str_replace("/var/www/include/..","",get_resource_path($ref,true,"thm",false,"jpg")));
      $newresults[] = array_merge($thumb_path,$results[0]);
      $results = $newresults;
      $results = mia_results($results);
      $resourcetype=get_resource_type_name($results[0]['resource_type']);
      $results=json_encode($results[0]);
      $query = push_RStoElastic($resourcetype,$ref,$results);
      if($query == false){
          //failed to connect to elastic search
          createcron($attempts=1,$ref);
          echo("Resolved TMS but failed to connect to Elastic Search. A Cron Job for Elastic Search has been instantiated and will try to resolve the issue" . date('d-m-Y h:i:s')."n");
      }else{
          echo("Art Object data was successfully resolved from TMS and added to Elastic Search ".date('d-m-Y h:i:s')."\n");
      }
    }else{
      echo("Database Error(s) - Failed to Resolve".date('d-m-Y h:i:s')."\n".json_encode($qerr)."\n");
     //handle this somehow
    }
  }
}
示例#9
0
		document.getElementById("tabswitch" + tab).className="Tab TabSelected";
	}
	</script>

<?php
} ?>

<div id="tab0" class="TabbedPanel<?php if ($tabcount>0) { ?> StyledTabbedPanel<?php } ?>">
<div class="clearerleft"> </div>
<div>
<?php 
#  ----------------------------- Draw standard fields ------------------------
?>
<?php if ($show_resourceid) { ?><div class="itemNarrow"><h3><?php echo $lang["resourceid"]?></h3><p><?php echo htmlspecialchars($ref)?></p></div><?php } ?>
<?php if ($show_access_field) { ?><div class="itemNarrow"><h3><?php echo $lang["access"]?></h3><p><?php echo @$lang["access" . $resource["access"]]?></p></div><?php } ?>
<?php if ($show_resource_type) { ?><div class="itemNarrow"><h3><?php echo $lang["resourcetype"]?></h3><p><?php echo  get_resource_type_name($resource["resource_type"])?></p></div><?php } ?>
<?php if ($show_hitcount){ ?><div class="itemNarrow"><h3><?php echo $resource_hit_count_on_downloads?$lang["downloads"]:$lang["hitcount"]?></h3><p><?php echo $resource["hit_count"]+$resource["new_hit_count"]?></p></div><?php } ?>
<?php hook("extrafields");?>
<?php
# contributed by field
if (!hook("replacecontributedbyfield")){
$udata=get_user($resource["created_by"]);
if ($udata!==false)
	{
	?>
<?php if ($show_contributed_by){?>	<div class="itemNarrow"><h3><?php echo $lang["contributedby"]?></h3><p><?php if (checkperm("u")) { ?><a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/team/team_user_edit.php?ref=<?php echo $udata["ref"]?>"><?php } ?><?php echo highlightkeywords(htmlspecialchars($udata["fullname"]),$search)?><?php if (checkperm("u")) { ?></a><?php } ?></p></div><?php } ?>
	<?php
	}
} // end hook replacecontributedby

# Show field data
include "../../include/resource_functions.php";
if (!$metadata_report) {
    exit("This function is not enabled.");
}
$exiftool_fullpath = get_utility_path("exiftool");
if ($exiftool_fullpath == false) {
    echo $lang["exiftoolnotfound"];
} else {
    $ref = getval("ref", "");
    $resource = get_resource_data($ref);
    $ext = $resource['file_extension'];
    if ($ext == "") {
        die($lang['nometadatareport']);
    }
    $resource_type = $resource['resource_type'];
    $type_name = get_resource_type_name($resource_type);
    $image = get_resource_path($ref, true, "", false, $ext);
    if (!file_exists($image)) {
        die($lang['error']);
    }
    #test if filetype is supported by exiftool
    $command = $exiftool_fullpath . " -listf";
    $formats = run_command($command);
    $ext = strtoupper($ext);
    if (strlen(strstr($formats, $ext)) < 2) {
        die(str_replace_formatted_placeholder("%extension", $ext, $lang['filetypenotsupported']));
    }
    if (in_array(strtolower($ext), $exiftool_no_process)) {
        die(str_replace_formatted_placeholder("%extension", $ext, $lang['exiftoolprocessingdisabledforfiletype']));
    }
    #build array of writable tags
示例#11
0
            # Multilingual text fields - find all translations and display the translation for the current language.
            $translations = i18n_get_translations($value);
            if (array_key_exists($language, $translations)) {
                $value = $translations[$language];
            } else {
                $value = "";
            }
        }
        if ($multiple) {
            $value = "";
        }
        # Blank the value for multi-edits.
        if ($fields[$n]["resource_type"] != $lastrt && $lastrt != -1) {
            ?>
<br><h1 id="resource_type_properties"><?php 
            echo get_resource_type_name($fields[$n]["resource_type"]);
            ?>
 <?php 
            echo $lang["properties"];
            ?>
</h1><?php 
        }
        $lastrt = $fields[$n]["resource_type"];
        # Blank form if 'reset form' has been clicked.
        if (getval("resetform", "") != "") {
            $value = "";
        }
        # If config option $blank_edit_template is set, always show a blank form for user edit templates.
        if ($ref < 0 && $blank_edit_template && getval("submitted", "") == "") {
            $value = "";
        }
<h2><?php 
    $title = "";
    $title = get_data_by_field($ref, $view_title_field);
    if (isset($metadata_template_title_field) && isset($metadata_template_resource_type)) {
        if ($resource['resource_type'] == $metadata_template_resource_type) {
            $title = get_data_by_field($ref, $metadata_template_title_field);
        }
    }
    echo trim(htmlspecialchars(i18n_get_translated($title)));
    ?>
</h2>
<?php 
    if ($infobox_display_resource_type) {
        ?>
<p><?php 
        echo get_resource_type_name($resource['resource_type']);
        ?>
</p><?php 
    }
    if ($infobox_display_resource_id) {
        # Display resource ID
        ?>
	<p><?php 
        echo $lang["resourceid"];
        ?>
: <?php 
        echo $ref;
        ?>
</p>
	<?php 
    }
示例#13
0
function display_field($n, $field, $newtab=false){
	global $use, $ref, $original_fields, $multilingual_text_fields, $multiple, $lastrt,$is_template, $language, $lang, $blank_edit_template, $edit_autosave, $errors, $tabs_on_edit,$collapsible_sections, $ctrls_to_save, $embedded_data_user_select, $embedded_data_user_select_fields;
	$name="field_" . $field["ref"];
	$value=$field["value"];
	$value=trim($value);

	if ($field["omit_when_copying"] && $use!=$ref){
		# Omit when copying - return this field back to the value it was originally, instead of using the current value which has been fetched from the new resource.
		reset($original_fields);
		foreach ($original_fields as $original_field){
			if ($original_field["ref"]==$field["ref"]) {$value=$original_field["value"];}
		}
	}
	$displaycondition=true;
	if ($field["display_condition"]!=""){
	    #Check if field has a display condition set
	    $displaycondition=check_display_condition($n,$field);
	}
	if ($multilingual_text_fields){
	    # Multilingual text fields - find all translations and display the translation for the current language.
	    $translations=i18n_get_translations($value);
	    if (array_key_exists($language,$translations)) {$value=$translations[$language];} else {$value="";}
	}
	if ($multiple) {$value="";} # Blank the value for multi-edits.
        if ($field["resource_type"]!=$lastrt && $lastrt!=-1 && $collapsible_sections){?>
            </div><h2 class="CollapsibleSectionHead" id="resource_type_properties">
            <?php echo htmlspecialchars(get_resource_type_name($field["resource_type"]))?> <?php echo $lang["properties"]?></h2><div class="CollapsibleSection" id="ResourceProperties<?php if ($ref==-1) echo "Upload"; ?>
            <?php echo $field["resource_type"]; ?>Section"><?php
        }

	$lastrt=$field["resource_type"];
	# Blank form if 'reset form' has been clicked.
	if (getval("resetform","")!="") {$value="";}

	# If config option $blank_edit_template is set, always show a blank form for user edit templates.
	if ($ref<0 && $blank_edit_template && getval("submitted","")=="") {$value="";}
	if ($multiple && !hook("replace_edit_all_checkbox","",array($field["ref"]))) { # Multiple items, a toggle checkbox appears which activates the question
	?><div class="edit_multi_checkbox"><input name="editthis_<?php echo htmlspecialchars($name)?>" id="editthis_<?php echo $n?>" type="checkbox" value="yes" onClick="var q=document.getElementById('question_<?php echo $n?>');var m=document.getElementById('modeselect_<?php echo $n?>');var f=document.getElementById('findreplace_<?php echo $n?>');if (this.checked) {q.style.display='block';m.style.display='block';} else {q.style.display='none';m.style.display='none';f.style.display='none';document.getElementById('modeselectinput_<?php echo $n?>').selectedIndex=0;}">&nbsp;<label for="editthis<?php echo $n?>"><?php echo htmlspecialchars($field["title"])?></label></div><!-- End of edit_multi_checkbox --><?php } ?>

	<div class="Question" id="question_<?php echo $n?>" <?php
	if ($multiple || !$displaycondition || $newtab)
		{?>style="border-top:none;<?php
		if ($multiple || !$displaycondition){?>display:none;<?php }
		}
		?>">
		<?php
			$labelname = $name;
			// Add _selector to label so it will keep working:
			if($field['type'] == 9) {
				$labelname .= '_selector';
			}

			// Add -d to label so it will keep working
			if($field['type'] == 4) {
				$labelname .= '-d';
			}
		?>
	<label for="<?php echo htmlspecialchars($labelname)?>" >
	<?php if (!$multiple) {?><?php echo htmlspecialchars($field["title"])?>
	<?php if (!$is_template && $field["required"]==1) { ?><sup>*</sup><?php } ?><?php } ?>
	</label>

	<?php
	# Define some Javascript for help actions (applies to all fields)
	$help_js="onBlur=\"HideHelp(" . $field["ref"] . ");return false;\" onFocus=\"ShowHelp(" . $field["ref"] . ");return false;\"";

	#hook to modify field type in special case. Returning zero (to get a standard text box) doesn't work, so return 1 for type 0, 2 for type 1, etc.
	$modified_field_type="";
	$modified_field_type=(hook("modifyfieldtype"));
	if ($modified_field_type){$field["type"]=$modified_field_type-1;}

	hook("addfieldextras");
	# ----------------------------  Show field -----------------------------------
	$type=$field["type"];
	if ($type=="") {$type=0;} # Default to text type.
	if (!hook("replacefield","",array($field["type"],$field["ref"],$n)))
		{
		global $auto_order_checkbox;
		include "edit_fields/" . $type . ".php";
		}
	# ----------------------------------------------------------------------------

	# Display any error messages from previous save
	if (array_key_exists($field["ref"],$errors))
		{
		?>
		<div class="FormError">!! <?php echo $errors[$field["ref"]]?> !!</div>
		<?php
		}

	if (trim($field["help_text"]!=""))
		{
		# Show inline help for this field.
		# For certain field types that have no obvious focus, the help always appears.
		?>
                <div class="FormHelp-selector" onmouseenter="ShowHelp(<?php echo $field["ref"] ?>); return false;" onmouseleave="HideHelp(<?php echo $field["ref"]?>)"><em>i</em></div>
		<div class="FormHelp" style="padding:0; display:none;" id="help_<?php echo $field["ref"]?>">
                <div class="FormHelpInner"><?php echo nl2br(trim(htmlspecialchars(i18n_get_translated($field["help_text"],false))))?></div></div>
		<?php
		}

	# If enabled, include code to produce extra fields to allow multilingual free text to be entered.
	if ($multilingual_text_fields && ($field["type"]==0 || $field["type"]==1 || $field["type"]==5))
		{
		display_multilingual_text_field($n, $field, $translations);
		}
		?>
	<div class="clearerleft"> </div>
	</div><!-- end of question_<?php echo $n?> div -->
	<?php
	hook('afterfielddisplay', '', array($n, $field));
	}
示例#14
0
        $sql = "insert into " . $ecs->table("resource_type") . " (name,class_code,created )\r\n\t\tvalues \r\n\t\t\t('" . $_REQUEST["name"] . "','" . $_SESSION["class_code"] . "',\r\n\t\t\tnow())";
        $db->query($sql);
        admin_log(addslashes($_REQUEST["name"]), 'add', 'resource_type');
        make_json_result("添加“" . $_REQUEST["name"] . "”成功!");
    } else {
        $sql = "update " . $ecs->table("resource_type") . " set name='" . $_REQUEST["name"] . "'\r\n\t\t\twhere rtype_id=" . $id;
        $db->query($sql);
        admin_log(addslashes($_REQUEST["name"]), 'update', 'resource_type');
        make_json_result("修改“" . $id . "," . $_REQUEST["name"] . "”成功!");
    }
} elseif ($_REQUEST['act'] == 'ajax_delete') {
    $id = !empty($_REQUEST['rtype_id']) ? intval($_REQUEST['rtype_id']) : 0;
    //如果做了考试安排,则不能删除
    $sql = "select count(1) from " . $ecs->table("resource") . " where type=" . $id;
    if ($db->getOne($sql)) {
        make_json_error("“" . get_resource_type_name($id) . "”在资料库中已使用,不能直接删除!");
        exit;
    }
    $sql = "delete from " . $ecs->table("resource_type") . " where rtype_id=" . $id;
    $db->query($sql);
    admin_log($_REQUEST["rtype_id"], 'delete', 'resource_type');
    make_json_result("删除成功!");
}
/**
 *  返回班级管理员列表数据
 *
 * @access  public
 * @param
 *
 * @return void
 */