コード例 #1
0
 public function Get()
 {
     global $g_ui_locale_id;
     $ps_query = $this->request->getParameter('q', pString);
     $ps_type = $this->request->getParameter('type', pString);
     $vo_conf = Configuration::load();
     $vs_user = trim($vo_conf->get("geonames_user"));
     $va_items = array();
     if (unicode_strlen($ps_query) >= 3) {
         $vs_base = "http://api.geonames.org/search";
         $t_locale = new ca_locales($g_ui_locale_id);
         $vs_lang = $t_locale->get("language");
         $va_params = array("q" => $ps_query, "lang" => $vs_lang, 'style' => 'full', 'username' => $vs_user);
         foreach ($va_params as $vs_key => $vs_value) {
             $vs_query_string .= "{$vs_key}=" . urlencode($vs_value) . "&";
         }
         try {
             $vo_xml = new SimpleXMLElement(@file_get_contents("{$vs_base}?{$vs_query_string}"));
             //var_dump($vo_result);
             foreach ($vo_xml->children() as $vo_child) {
                 if ($vo_child->getName() != "totalResultsCount") {
                     $va_items[$vo_child->geonameId . ""] = array('displayname' => $vo_child->name, 'country' => $vo_child->countryName ? $vo_child->countryName : null, 'continent' => $vo_child->continentCode ? $vo_child->continentCode : null, 'fcl' => $vo_child->fclName ? $vo_child->fclName : null, 'lat' => $vo_child->lat ? $vo_child->lat : null, 'lng' => $vo_child->lng ? $vo_child->lng : null, 'idno' => $vo_child->geonameId);
                 }
             }
         } catch (Exception $e) {
             $va_items[0] = array('displayname' => _t('Could not connect to GeoNames'), 'country' => '', 'continent' => '', 'fcl' => '', 'lat' => '', 'lng' => '', 'idno' => '');
         }
     }
     $this->view->setVar('geonames_list', $va_items);
     return $this->render('ajax_geonames_list_html.php');
 }
コード例 #2
0
 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $ps_value = trim($ps_value);
     $va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('minChars', 'maxChars', 'minValue', 'maxValue', 'regex', 'mustNotBeBlank'));
     $vn_strlen = unicode_strlen($ps_value);
     if ($va_settings['minChars'] && $vn_strlen < $va_settings['minChars']) {
         // length is too short
         $vs_err_msg = $va_settings['minChars'] == 1 ? _t('%1 must be at least 1 character long', $pa_element_info['displayLabel']) : _t('%1 must be at least %2 characters long', $pa_element_info['displayLabel'], $va_settings['minChars']);
         $this->postError(1970, $vs_err_msg, 'IntegerAttributeValue->parseValue()');
         return false;
     }
     if ($va_settings['maxChars'] && $vn_strlen > $va_settings['maxChars']) {
         // length is too long
         $vs_err_msg = $va_settings['maxChars'] == 1 ? _t('%1 must be no more than 1 character long', $pa_element_info['displayLabel']) : _t('%1 must be no more than %2 characters long', $pa_element_info['displayLabel'], $va_settings['maxChars']);
         $this->postError(1970, $vs_err_msg, 'IntegerAttributeValue->parseValue()');
         return false;
     }
     if (strlen($ps_value) && !is_numeric($ps_value)) {
         // value is not numeric
         $vs_err_str = _t('%1 must a number', $pa_element_info['displayLabel']);
         $this->postError(1970, $vs_err_str, 'NumericAttributeValue->parseValue()');
         return false;
     }
     if (strlen($ps_value) == 0) {
         if ((bool) $va_settings['mustNotBeBlank']) {
             $this->postError(1970, _t('%1 must not be empty', $pa_element_info['displayLabel']), 'IntegerAttributeValue->parseValue()');
             return false;
         } else {
             return null;
         }
     }
     $pn_value = intval($ps_value);
     if (strlen($va_settings['minValue']) && $pn_value < $va_settings['minValue']) {
         // value is too small
         $vs_err_str = _t('%1 must be at least %2', $pa_element_info['displayLabel'], $va_settings['minValue']);
         $this->postError(1970, $vs_err_str, 'NumericAttributeValue->parseValue()');
         return false;
     }
     if (strlen($va_settings['maxValue']) && $pn_value > $va_settings['maxValue']) {
         // value is too large
         $vs_err_str = _t('%1 must be no more than %2', $pa_element_info['displayLabel'], $va_settings['maxValue']);
         $this->postError(1970, $vs_err_str, 'NumericAttributeValue->parseValue()');
         return false;
     }
     if ($va_settings['regex'] && !preg_match("!" . $va_settings['regex'] . "!", $ps_value)) {
         // regex failed
         // TODO: need more descriptive error message
         $this->postError(1970, _t('%1 does not conform to required format', $pa_element_info['displayLabel']), 'IntegerAttributeValue->parseValue()');
         return false;
     }
     if (!preg_match('/^\\d*$/', $ps_value)) {
         //this is not an integer, it contains symbols other than [0-9]
         $this->postError(1970, _t('%1 is not an integer value', $pa_element_info['displayLabel']), 'IntegerAttributeValue->parseValue()');
         return false;
     }
     return array('value_longtext1' => $pn_value, 'value_integer1' => $pn_value);
 }
コード例 #3
0
 public function Get($pa_additional_query_params = null, $pa_options = null)
 {
     global $g_ui_locale_id;
     $vn_max = $this->request->getParameter('maxRows', pInteger) ? $this->request->getParameter('maxRows', pInteger) : 20;
     $ps_query = $this->request->getParameter('term', pString);
     $ps_gn_elements = urldecode($this->request->getParameter('gnElements', pString));
     $ps_gn_delimiter = urldecode($this->request->getParameter('gnDelimiter', pString));
     $pa_elements = explode(',', $ps_gn_elements);
     $vo_conf = Configuration::load();
     $vs_user = trim($vo_conf->get("geonames_user"));
     $va_items = array();
     if (unicode_strlen($ps_query) >= 3) {
         $vs_base = $vo_conf->get('geonames_api_base_url') . '/search';
         $t_locale = new ca_locales($g_ui_locale_id);
         $vs_lang = $t_locale->get("language");
         $va_params = array("q" => $ps_query, "lang" => $vs_lang, 'style' => 'full', 'username' => $vs_user, 'maxRows' => $vn_max);
         $vs_query_string = '';
         foreach ($va_params as $vs_key => $vs_value) {
             $vs_query_string .= "{$vs_key}=" . urlencode($vs_value) . "&";
         }
         try {
             $vs_xml = caQueryExternalWebservice("{$vs_base}?{$vs_query_string}");
             $vo_xml = new SimpleXMLElement($vs_xml);
             $va_attr = $vo_xml->status ? $vo_xml->status->attributes() : null;
             if ($va_attr && isset($va_attr['value']) && (int) $va_attr['value'] > 0) {
                 $va_items[0] = array('displayname' => _t('Connection to GeoNames with username "%1" was rejected with the message "%2". Check your configuration and make sure your GeoNames.org account is enabled for web services.', $vs_user, $va_attr['message']), 'lat' => '', 'lng' => '');
                 $va_items[0]['label'] = $va_items[0]['displayname'];
             } else {
                 foreach ($vo_xml->children() as $vo_child) {
                     if ($vo_child->getName() == "geoname") {
                         $va_elements = array();
                         foreach ($pa_elements as $ps_element) {
                             $vs_val = $vo_child->{trim($ps_element)};
                             if (strlen(trim($vs_val)) > 0) {
                                 $va_elements[] = trim($vs_val);
                             }
                         }
                         $va_items[(string) $vo_child->geonameId] = array('displayname' => $vo_child->name, 'label' => join($ps_gn_delimiter, $va_elements) . ($vo_child->lat ? " [" . $vo_child->lat . "," : '') . ($vo_child->lng ? $vo_child->lng . "]" : ''), 'lat' => $vo_child->lat ? $vo_child->lat : null, 'lng' => $vo_child->lng ? $vo_child->lng : null, 'id' => (string) $vo_child->geonameId);
                     }
                 }
             }
         } catch (Exception $e) {
             $va_items[0] = array('displayname' => _t('Could not connect to GeoNames'), 'lat' => '', 'lng' => '', 'id' => 0);
             $va_items[0]['label'] = $va_items[0]['displayname'];
         }
     }
     $this->view->setVar('geonames_list', $va_items);
     return $this->render('ajax_geonames_list_html.php');
 }
コード例 #4
0
ファイル: LCSHController.php プロジェクト: guaykuru/pawtucket
 public function Get()
 {
     $ps_query = $this->request->getParameter('q', pString);
     $ps_type = $this->request->getParameter('type', pString);
     $va_vocs = array();
     $vs_voc_query = '';
     if ($vn_element_id = $this->request->getParameter('element_id', pInteger)) {
         $t_element = new ca_metadata_elements($vn_element_id);
         if ($vs_voc = $t_element->getSetting('vocabulary')) {
             $vs_voc_query .= '&q=' . urlencode($vs_voc);
         }
     }
     $va_items = array();
     if (unicode_strlen($ps_query) >= 3) {
         try {
             //
             // Get up to 50 suggestions as ATOM feed
             //
             $vs_data = @file_get_contents($x = "http://id.loc.gov/search/?q=" . urlencode($ps_query) . $vs_voc_query . '&format=atom&count=50');
             if ($vs_data) {
                 $o_xml = @simplexml_load_string($vs_data);
                 if ($o_xml) {
                     $o_entries = $o_xml->{'entry'};
                     if ($o_entries && sizeof($o_entries)) {
                         foreach ($o_entries as $o_entry) {
                             $o_links = $o_entry->{'link'};
                             $va_attr = $o_links[0]->attributes();
                             $vs_url = (string) $va_attr->{'href'};
                             $va_items[$vs_url] = array('displayname' => (string) $o_entry->{'title'}, 'idno' => (string) $o_entry->{'id'});
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             $va_items['error'] = array('displayname' => _t('ERROR') . ':' . $e->getMessage(), 'idno' => '');
         }
     }
     $this->view->setVar('lcsh_list', $va_items);
     return $this->render('ajax_lcsh_list_html.php');
 }
コード例 #5
0
 public function Get($pa_additional_query_params = null, $pa_options = null)
 {
     if (!($ps_query = $this->request->getParameter('q', pString))) {
         $ps_query = $this->request->getParameter('term', pString);
     }
     $ps_type = $this->request->getParameter('type', pString);
     $va_vocs = array();
     $vs_voc_query = '';
     if ($vn_element_id = $this->request->getParameter('element_id', pInteger)) {
         $t_element = new ca_metadata_elements($vn_element_id);
         if ($vs_voc = $t_element->getSetting('vocabulary')) {
             $vs_voc_query .= '&q=' . rawurlencode($vs_voc);
         }
     }
     $vo_conf = Configuration::load();
     $va_items = array();
     if (unicode_strlen($ps_query) >= 3) {
         try {
             $vs_data = caQueryExternalWebservice('http://id.loc.gov/search/?q=' . urlencode('"' . $ps_query . '"') . $vs_voc_query . '&format=atom&count=150');
             if ($vs_data) {
                 $o_xml = @simplexml_load_string($vs_data);
                 if ($o_xml) {
                     $o_entries = $o_xml->{'entry'};
                     if ($o_entries && sizeof($o_entries)) {
                         foreach ($o_entries as $o_entry) {
                             $o_links = $o_entry->{'link'};
                             $va_attr = $o_links[0]->attributes();
                             $vs_url = (string) $va_attr->{'href'};
                             $va_items[] = array('label' => (string) $o_entry->{'title'}, 'idno' => (string) $o_entry->{'id'}, 'url' => $vs_url);
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             $va_items['error'] = array('displayname' => _t('ERROR') . ':' . $e->getMessage(), 'idno' => '');
         }
     }
     $this->view->setVar('lcsh_list', $va_items);
     return $this->render('ajax_lcsh_list_html.php');
 }
コード例 #6
0
 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('minChars', 'maxChars', 'regex'));
     $vn_strlen = unicode_strlen($ps_value);
     if ($vn_strlen < $va_settings['minChars']) {
         // text is too short
         $vs_err_msg = $va_settings['minChars'] == 1 ? _t('%1 must be at least 1 character long', $pa_element_info['displayLabel']) : _t('%1 must be at least %2 characters long', $pa_element_info['displayLabel'], $va_settings['minChars']);
         $this->postError(1970, $vs_err_msg, 'TextAttributeValue->parseValue()');
         return false;
     }
     if ($vn_strlen > $va_settings['maxChars']) {
         // text is too short
         $vs_err_msg = $va_settings['maxChars'] == 1 ? _t('%1 must be no more than 1 character long', $pa_element_info['displayLabel']) : _t('%1 must be no more than %2 characters long', $pa_element_info['displayLabel'], $va_settings['maxChars']);
         $this->postError(1970, $vs_err_msg, 'TextAttributeValue->parseValue()');
         return false;
     }
     if ($va_settings['regex'] && !preg_match("!" . $va_settings['regex'] . "!", $ps_value)) {
         // regex failed
         $this->postError(1970, _t('%1 does not conform to required format', $pa_element_info['displayLabel']), 'TextAttributeValue->parseValue()');
         return false;
     }
     return array('value_longtext1' => $ps_value);
 }
コード例 #7
0
 /**
  * Perform lookup on a remote data service and return matched values
  *
  * @param array $pa_additional_query_params
  * @param array $pa_options
  */
 public function Get($pa_additional_query_params = null, $pa_options = null)
 {
     $o_config = Configuration::load();
     if (!($ps_query = $this->request->getParameter('q', pString))) {
         $ps_query = $this->request->getParameter('term', pString);
     }
     $ps_type = $this->request->getParameter('type', pString);
     $pn_element_id = $this->request->getParameter('element_id', pInteger);
     $t_element = new ca_metadata_elements($pn_element_id);
     if (!$t_element->getPrimaryKey()) {
         // error
         $va_items['error'] = array('label' => _t('ERROR: Invalid element_id'), 'idno' => '');
     } else {
         $vs_service = $t_element->getSetting('service');
         $va_items = array();
         if (unicode_strlen($ps_query) >= 3) {
             try {
                 // Load plugin and connect to information service
                 if (!($o_plugin = InformationServiceManager::getInformationServiceInstance($vs_service))) {
                     $va_items['error'] = array('label' => _t('ERROR: Invalid service'), 'idno' => '');
                 } else {
                     $va_data = $o_plugin->lookup($t_element->getSettings(), $ps_query, array('element_id' => $pn_element_id));
                     if ($va_data && isset($va_data['results']) && is_array($va_data['results'])) {
                         foreach ($va_data['results'] as $va_result) {
                             $va_items[] = array('label' => (string) $va_result['label'], 'idno' => (string) $va_result['idno'], 'url' => (string) $va_result['url']);
                         }
                     }
                 }
             } catch (Exception $e) {
                 $va_items['error'] = array('label' => _t('ERROR') . ': ' . $e->getMessage(), 'idno' => '');
             }
         }
     }
     $this->view->setVar('information_service_list', $va_items);
     return $this->render('ajax_information_service_list_html.php');
 }
コード例 #8
0
		<table class="listtable" width="100%" border="0" cellpadding="0" cellspacing="1">
			<thead>
			<tr>
			<th style="width:10px; text-align:center;" class='list-header-nosort'>
				<input type='checkbox' name='record' value='' id='addItemToSetSelectAllControl' class='addItemToSetControl' onchange="jQuery('.addItemToSetControl').attr('checked', (jQuery('#addItemToSetSelectAllControl').attr('checked') == 'checked'));"/>		
			</th>
			<th class='list-header-nosort'>
				<?php 
print $vs_default_action == "Edit" ? _t("Edit") : _t("View");
?>
			</th>
<?php 
// output headers
$vn_id_count = 0;
foreach ($va_display_list as $va_display_item) {
    $vs_item_display_str = unicode_strlen($va_display_item['display']) > 30 ? strip_tags(mb_substr($va_display_item['display'], 0, 27)) . "..." : $va_display_item['display'];
    if ($va_display_item['is_sortable']) {
        if ($vs_current_sort == $va_display_item['bundle_sort']) {
            if ($vs_current_sort_dir == 'desc') {
                $vs_th_class = 'list-header-sorted-desc';
                $vs_new_sort_direction = 'asc';
            } else {
                $vs_th_class = 'list-header-sorted-asc';
                $vs_new_sort_direction = 'desc';
            }
            print "<th class='{$vs_th_class}'><span id='listHeader" . $vn_id_count . "'><nobr>" . caNavLink($this->request, $vs_item_display_str, '', $this->request->getModulePath(), $this->request->getController(), 'Index', array('sort' => $va_display_item['bundle_sort'], 'direction' => $vs_new_sort_direction)) . "</nobr></span></th>";
            TooltipManager::add('#listHeader' . $vn_id_count, _t("Currently sorting by ") . $va_display_item['display']);
        } else {
            print "<th class='list-header-unsorted'><span id='listHeader1" . $vn_id_count . "'><nobr>" . caNavLink($this->request, $vs_item_display_str, '', $this->request->getModulePath(), $this->request->getController(), 'Index', array('sort' => $va_display_item['bundle_sort'])) . "</nobr></span></th>";
            TooltipManager::add('#listHeader1' . $vn_id_count, _t("Click to sort by ") . $va_display_item['display']);
        }
コード例 #9
0
 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $ps_value = trim($ps_value);
     $va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('minChars', 'maxChars', 'regex', 'requireValue'));
     if (!$va_settings['requireValue'] && !$ps_value) {
         return array('value_longtext1' => '');
     }
     $vn_strlen = unicode_strlen($ps_value);
     if ($vn_strlen < $va_settings['minChars']) {
         // text is too short
         $vs_err_msg = $va_settings['minChars'] == 1 ? _t('%1 must be at least 1 character long', $pa_element_info['displayLabel']) : _t('%1 must be at least %2 characters long', $pa_element_info['displayLabel'], $va_settings['minChars']);
         $this->postError(1970, $vs_err_msg, 'UrlAttributeValue->parseValue()');
         return false;
     }
     if ($vn_strlen > $va_settings['maxChars']) {
         // text is too short
         $vs_err_msg = $va_settings['maxChars'] == 1 ? _t('%1 must be no more than 1 character long', $pa_element_info['displayLabel']) : _t('%1 be no more than %2 characters long', $pa_element_info['displayLabel'], $va_settings['maxChars']);
         $this->postError(1970, $vs_err_msg, 'UrlAttributeValue->parseValue()');
         return false;
     }
     if (!$va_settings['regex']) {
         $va_settings['regex'] = "(http|ftp|https|rtmp|rtsp):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&;:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?";
     }
     if ($va_settings['regex'] && !preg_match("!" . $va_settings['regex'] . "!", $ps_value)) {
         // default to http if it's just a hostname + path
         if (!preg_match("!^[A-Za-z]+:\\/\\/!", $ps_value)) {
             $ps_value = "http://{$ps_value}";
         } else {
             // regex failed
             $this->postError(1970, _t('%1 is not a valid url', $pa_element_info['displayLabel']), 'UrlAttributeValue->parseValue()');
             return false;
         }
     }
     return array('value_longtext1' => $ps_value);
 }
コード例 #10
0
// 					print "<option value='".$vs_view."' ".(($vs_view == $vs_current_view) ? "SELECTED='1'" : "").">".$vs_name."</option>\n";
// 				}
// 			}
// 			print "</select>\n";
// 			print "</div>";
$va_search_history = $this->getVar('search_history');
$vs_cur_search = $vo_result_context->getSearchExpression();
if (is_array($va_search_history) && sizeof($va_search_history) > 0) {
    print "<div class='col'>";
    print _t("Search history:") . " ";
    print caFormTag($this->request, 'Index', 'caSearchHistoryForm');
    print "<select name='search' onchange='this.form.submit();'>\n";
    foreach (array_reverse($va_search_history) as $vs_search => $va_search_info) {
        $SELECTED = $vs_cur_search == $va_search_info['display'] ? 'SELECTED="1"' : '';
        $vs_display = strip_tags($va_search_info['display']);
        if (unicode_strlen($vs_display) > 15) {
            $vs_display = unicode_substr($vs_display, 0, 12) . '...';
        }
        print "<option value='" . htmlspecialchars($vs_search, ENT_QUOTES, 'UTF-8') . "' {$SELECTED}>" . $vs_display . " (" . $va_search_info['hits'] . ")</option>\n";
    }
    print "</select>\n";
    print "</form>\n";
    print "</div>";
}
print "</form>\n";
?>
			<a href='#' id='hideOptions' onclick='$("#searchOptionsBox").slideUp(250); $("#showOptions").slideDown(1); return false;'><?php 
print _t("Hide");
?>
 &rsaquo; </a>
			<div style='clear:both;height:1px;'>&nbsp;</div>
コード例 #11
0
        print "<option value='" . $vs_view . "' " . ($vs_view == $vs_current_view ? "SELECTED='1'" : "") . ">" . $vs_name . "</option>\n";
    }
}
print "</select>\n";
print "</div>";
$va_search_history = $this->getVar('search_history');
$vs_cur_search = $vo_result_context->getSearchExpression();
if (is_array($va_search_history) && sizeof($va_search_history) > 0) {
    print "<div class='col'>";
    print _t("Search history:") . " ";
    print caFormTag($this->request, 'Index', 'caSearchHistoryForm');
    print "<select name='search' onchange='this.form.submit();'>\n";
    foreach (array_reverse($va_search_history) as $vs_search => $va_search_info) {
        $SELECTED = $vs_cur_search == $va_search_info['display'] ? 'SELECTED="1"' : '';
        $vs_display = strip_tags($va_search_info['display']);
        if (unicode_strlen($vs_display) > 20) {
            $vs_display = unicode_substr($vs_display, 0, 17) . '...';
        }
        print "<option value='" . htmlspecialchars($vs_search, ENT_QUOTES, 'UTF-8') . "' {$SELECTED}>" . $vs_display . " (" . $va_search_info['hits'] . ")</option>\n";
    }
    print "</select>\n";
    print "</form>\n";
    print "</div>";
}
print "</form>\n";
?>
			<a href='#' id='hideOptions' onclick='$("#searchOptionsBox").slideUp(250); $("#showOptions").slideDown(1); return false;'><?php 
print _t("Hide");
?>
 <img src="<?php 
print $this->request->getThemeUrlPath();
コード例 #12
0
			</th>

<?php 
// output headers
$vn_id_count = 0;
foreach ($va_display_list as $va_display_item) {
    if ($va_display_item['is_sortable']) {
        if ($vs_current_sort == $va_display_item['bundle_sort']) {
            print "<th class='list-header-sorted-asc'><span id='listHeader" . $vn_id_count . "'><nobr>" . (unicode_strlen($va_display_item['display']) > 17 ? strip_tags(mb_substr($va_display_item['display'], 0, 15)) . "..." : $va_display_item['display']) . "</nobr></span></th>";
            TooltipManager::add('#listHeader' . $vn_id_count, _t("Currently sorting by ") . $va_display_item['display']);
        } else {
            print "<th class='list-header-unsorted'><span id='listHeader1" . $vn_id_count . "'><nobr>" . caNavLink($this->request, unicode_strlen($va_display_item['display']) > 17 ? strip_tags(mb_substr($va_display_item['display'], 0, 15)) . "..." : $va_display_item['display'], '', $this->request->getModulePath(), $this->request->getController(), 'Index', array('sort' => $va_display_item['bundle_sort'])) . "</nobr></span></th>";
            TooltipManager::add('#listHeader1' . $vn_id_count, _t("Click to sort by ") . $va_display_item['display']);
        }
    } else {
        print "<th class='list-header-nosort'><span id='listHeader2" . $vn_id_count . "'><nobr>" . (unicode_strlen($va_display_item['display']) > 17 ? strip_tags(mb_substr($va_display_item['display'], 0, 15)) . "..." : $va_display_item['display']) . "</nobr></span></th>";
        TooltipManager::add('#listHeader2' . $vn_id_count, $va_display_item['display']);
    }
    $vn_id_count++;
}
?>
			</tr></thead><tbody>
<?php 
$i = 0;
$vn_item_count = 0;
while ($vn_item_count < $vn_items_per_page && $vo_result->nextHit()) {
    $vn_entity_id = $vo_result->get('entity_id');
    if ($vo_ar->userCanAccess($this->request->user->getUserID(), array("editor", "entities"), "EntityEditor", "Edit", array("entity_id" => $vn_entity_id))) {
        $vs_action = "Edit";
    } else {
        $vs_action = "Summary";
コード例 #13
0
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
?>
<div class="tooltipImage">
	<?php 
print $this->getVar('tooltip_representation');
?>
</div>
<div class="tooltipCaption">
<?php 
if ($this->getVar('tooltip_title')) {
    print "<div><b>TITLE:</b> ";
    print unicode_strlen($this->getVar('tooltip_title')) > 200 ? substr(strip_tags($this->getVar('tooltip_title')), '0', '200') . "..." : $this->getVar('tooltip_title');
    print "</div>";
}
if ($this->getVar('tooltip_idno')) {
    print "<div><b>ID:</b> ";
    print $this->getVar('tooltip_idno');
    print "</div>";
}
if ($this->getVar('tooltip_altid')) {
    print "<div><b>Alternate ID:</b> ";
    print $this->getVar('tooltip_altid');
    print "</div>";
}
?>
</div>
コード例 #14
0
 public function Get()
 {
     //$tt = new Timer();
     $ps_query = $this->request->getParameter('q', pString);
     //file_put_contents("/tmp/times", "### QUERY: {$ps_query}\n", FILE_APPEND);
     $va_items = array();
     if (unicode_strlen($ps_query) >= 3) {
         try {
             $vo_ctx = stream_context_create(array('http' => array('timeout' => 5)));
             /* // ITIS
             			$i = 0;
             			$vo_doc = new DOMDocument();
             			//$t = new Timer();
             			$vs_result = @file_get_contents("http://www.itis.gov/ITISWebService/services/ITISService/searchForAnyMatch?srchKey={$ps_query}",0,$vo_ctx);
             			//file_put_contents("/tmp/times", "ITIS: {$t->getTime(2)}\n", FILE_APPEND);
             			if(strlen($vs_result)>0){
             				$vo_doc->loadXML($vs_result);
             				$vo_resultlist = $vo_doc->getElementsByTagName("anyMatchList");
             				foreach($vo_resultlist as $vo_result){
             					$vs_cn = $vs_sn = $vs_id = "";
             					foreach($vo_result->childNodes as $vo_field){
             						switch($vo_field->nodeName){
             							case "ax23:commonNameList":
             								foreach($vo_field->childNodes as $vo_cns){
             									if($vo_cns->nodeName == "ax23:commonNames"){
             										foreach($vo_cns->childNodes as $vo_cn){
             											if($vo_cn->nodeName == "ax23:commonName"){
             												$vs_cn = $vo_cn->textContent;
             											}
             										}
             									}
             								}
             								break;
             							case "ax23:tsn":
             								$vs_id = $vo_field->textContent;
             								break;
             							case "ax23:sciName":
             								$vs_sn = $vo_field->textContent;
             								break;
             							default:
             								break;
             						}
             					}
             					if(strlen($vs_id)>0){
             						$va_items["itis".$vs_id] = array(
             							"idno" => "ITIS:{$vs_id}",
             							"common_name" => $vs_cn,
             							"sci_name" => $vs_sn
             						);
             						if(++$i == 50){ // let's limit to 50 results, right?
             							break;
             						}
             					}
             				}
             			} else {
             				$va_items['error_itis'] = array(
             					'msg' => _t('ERROR: ITIS web service query failed.'),
             				);
             			}*/
             // uBio
             $vo_conf = new Configuration();
             $vs_ubio_keycode = trim($vo_conf->get("ubio_keycode"));
             if (strlen($vs_ubio_keycode) > 0) {
                 $vo_doc = new DOMDocument();
                 //$t = new Timer();
                 $vs_result = @file_get_contents("http://www.ubio.org/webservices/service.php?function=namebank_search&searchName={$ps_query}&sci=1&vern=1&keyCode={$vs_ubio_keycode}", 0, $vo_ctx);
                 //file_put_contents("/tmp/times", "uBIO: {$t->getTime(2)}\n", FILE_APPEND);
                 if (strlen($vs_result) > 0) {
                     $vo_doc->loadXML($vs_result);
                     $vo_resultlist = $vo_doc->getElementsByTagName("value");
                     $i = 0;
                     foreach ($vo_resultlist as $vo_result) {
                         $vs_name = $vs_id = $vs_package = $vs_cn = "";
                         if ($vo_result->parentNode->nodeName == "scientificNames") {
                             foreach ($vo_result->childNodes as $vo_field) {
                                 switch ($vo_field->nodeName) {
                                     case "nameString":
                                         $vs_name = base64_decode($vo_field->textContent);
                                         break;
                                     case "namebankID":
                                         $vs_id = $vo_field->textContent;
                                         break;
                                     case "packageName":
                                         $vs_package = $vo_field->textContent;
                                         break;
                                     default:
                                         break;
                                 }
                             }
                         } elseif ($vo_result->parentNode->nodeName == "vernacularNames") {
                             foreach ($vo_result->childNodes as $vo_field) {
                                 switch ($vo_field->nodeName) {
                                     case "fullNameStringLink":
                                         $vs_name = base64_decode($vo_field->textContent);
                                         break;
                                     case "namebankIDLink":
                                         $vs_id = $vo_field->textContent;
                                         break;
                                     case "packageName":
                                         $vs_package = $vo_field->textContent;
                                         break;
                                     case "nameString":
                                         $vs_cn = base64_decode($vo_field->textContent);
                                         break;
                                     default:
                                         break;
                                 }
                             }
                         }
                         if (strlen($vs_name) > 0 && strlen($vs_id) > 0) {
                             $va_items["ubio" . $vs_id] = array("idno" => "uBio:{$vs_id}", "sci_name" => $vs_name . (strlen($vs_package) > 0 ? " ({$vs_package}) " : ""), "common_name" => $vs_cn);
                             if (++$i == 100) {
                                 // let's limit to 100 results, right?
                                 break;
                             }
                         }
                     }
                 } else {
                     $va_items['error_ubio'] = array('msg' => _t('ERROR: uBio web service query failed.'));
                 }
             } else {
                 $va_items['error_ubio'] = array('msg' => _t('ERROR: No uBio keycode in app.conf.'));
             }
         } catch (Exception $e) {
             $va_items['error'] = array("msg" => _t('ERROR') . ':' . $e->getMessage());
         }
     }
     $this->view->setVar('taxonomy_list', $va_items);
     //file_put_contents("/tmp/times", "TOTAL: {$tt->getTime(2)}\n", FILE_APPEND);
     return $this->render('ajax_taxonomy_list_html.php');
 }
コード例 #15
0
ファイル: sets_html.php プロジェクト: guaykuru/pawtucket
'>
					<div id='setItemContainer<?php 
        print $vn_item_id;
        ?>
' class='imagecontainer'>
						<div class='remove'><a href='#' class='setDeleteButton' id='setItemDelete<?php 
        print $vn_item_id;
        ?>
'>X</a></div>
						<div class='setItemThumbnail'>
<?php 
        if ($va_item['representation_tag_thumbnail']) {
            print caNavLink($this->request, $va_item['representation_tag_thumbnail'], '', 'Detail', 'Object', 'Show', array('object_id' => $va_item['row_id']));
        }
        if ($va_item['name']) {
            if (unicode_strlen($va_item['name']) > 70) {
                $va_title[] = '<em>' . unicode_substr($va_item['name'], 0, 67) . '...</em>';
            } else {
                $va_title[] = '<em>' . $va_item['name'] . '</em>';
            }
        }
        if ($va_item['idno']) {
            $va_title[] = $va_item['idno'];
        }
        $vs_title = join('<br/>', $va_title);
        ?>
						</div>
						<div id='caption<?php 
        print $vn_item_id;
        ?>
' class='setItemCaption'><?php 
コード例 #16
0
    $vn_object_id = $vo_result->get('object_id');
    if ($vo_ar->userCanAccess($this->request->user->getUserID(), array("editor", "objects"), "ObjectEditor", "Edit", array("object_id" => $vn_object_id))) {
        $vs_action = "Edit";
    } else {
        $vs_action = "Summary";
    }
    if (!$vn_col) {
        print "<tr>";
    }
    if (!($vs_idno = $vo_result->get('ca_objects.idno'))) {
        $vs_idno = "???";
    }
    $va_labels = $vo_result->getDisplayLabels($this->request);
    $vs_caption = "";
    foreach ($va_labels as $vs_label) {
        $vs_label = "<br/>" . (unicode_strlen($vs_label) > 27 ? strip_tags(mb_substr($vs_label, 0, 25, 'utf-8')) . "..." : $vs_label);
        $vs_caption .= $vs_label;
    }
    # --- get the height of the image so can calculate padding needed to center vertically
    $va_media_info = $vo_result->getMediaInfo('ca_object_representations.media', 'preview170');
    $vn_padding_top = 0;
    $vn_padding_top_bottom = (170 - $va_media_info["HEIGHT"]) / 2;
    print "<td align='center' valign='top' style='padding:20px 2px 2px 2px;'><div class='objectThumbnailsImageContainer' style='padding: " . $vn_padding_top_bottom . "px 0px " . $vn_padding_top_bottom . "px 0px;'>";
    ?>
				<input type='checkbox' name='add_to_set_ids' value='<?php 
    print (int) $vn_object_id;
    ?>
' class="addItemToSetControl addItemToSetControlInThumbnails" />
					
<?php 
    $va_tmp = $vo_result->getMediaTags('ca_object_representations.media', 'preview170');
コード例 #17
0
<div class="thumbnailCaption">
<?php 
$vs_caption = "";
if ($this->getVar('caption_title')) {
    $vs_caption .= "<i>";
    $vs_caption .= unicode_strlen($this->getVar('caption_title')) > 45 ? preg_replace('![^A-Za-z0-9]+$!', '', substr(strip_tags($this->getVar('caption_title')), 0, 45)) . '...' : $this->getVar('caption_title');
    $vs_caption .= "</i><br/>";
}
print caNavLink($this->request, $vs_caption, '', 'Detail', 'Object', 'Show', array('object_id' => $this->getVar("object_id")));
?>
</div>
コード例 #18
0
		</div>
<?php 
    }
    ?>
	<table class="listtable" width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
<?php 
    // output headers
    $vn_count = 0;
    foreach ($va_display_list as $va_display_item) {
        // Skip first few columns as needed
        if ($vn_count < $vn_start) {
            $vn_count++;
            continue;
        }
        print "<th class='displayHeader'>" . (unicode_strlen($va_display_item['display']) > 30 ? strip_tags(mb_substr($va_display_item['display'], 0, 27)) . "..." : $va_display_item['display']) . "</th>";
        $vn_count++;
        if ($vn_count >= $vn_start + 6) {
            break;
        }
    }
    ?>
		</tr>
<?php 
    $i = 0;
    $vo_result->seek(0);
    while ($vo_result->nextHit()) {
        $vn_loan_id = $vo_result->get('loan_id');
        $i == 2 ? $i = 0 : "";
        ?>
			<tr <?php 
コード例 #19
0
 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $ps_value = trim($ps_value);
     $va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('minChars', 'maxChars', 'minValue', 'maxValue', 'regex', 'mustNotBeBlank', 'mustBeUnique'));
     $vn_strlen = unicode_strlen($ps_value);
     if ($va_settings['minChars'] && $vn_strlen < $va_settings['minChars']) {
         // length is too short
         $vs_err_msg = $va_settings['minChars'] == 1 ? _t('%1 must be at least 1 character long', $pa_element_info['displayLabel']) : _t('%1 must be at least %2 characters long', $pa_element_info['displayLabel'], $va_settings['minChars']);
         $this->postError(1970, $vs_err_msg, 'IntegerAttributeValue->parseValue()');
         return false;
     }
     if ($va_settings['maxChars'] && $vn_strlen > $va_settings['maxChars']) {
         // length is too long
         $vs_err_msg = $va_settings['maxChars'] == 1 ? _t('%1 must be no more than 1 character long', $pa_element_info['displayLabel']) : _t('%1 must be no more than %2 characters long', $pa_element_info['displayLabel'], $va_settings['maxChars']);
         $this->postError(1970, $vs_err_msg, 'IntegerAttributeValue->parseValue()');
         return false;
     }
     if (strlen($ps_value) && !is_numeric($ps_value)) {
         // value is not numeric
         $vs_err_str = _t('%1 must a number', $pa_element_info['displayLabel']);
         $this->postError(1970, $vs_err_str, 'NumericAttributeValue->parseValue()');
         return false;
     }
     if (strlen($ps_value) == 0) {
         if ((bool) $va_settings['mustNotBeBlank']) {
             $this->postError(1970, _t('%1 must not be empty', $pa_element_info['displayLabel']), 'IntegerAttributeValue->parseValue()');
             return false;
         } else {
             return null;
         }
     }
     $pn_value = intval($ps_value);
     if (strlen($va_settings['minValue']) && $pn_value < $va_settings['minValue']) {
         // value is too small
         $vs_err_str = _t('%1 must be at least %2', $pa_element_info['displayLabel'], $va_settings['minValue']);
         $this->postError(1970, $vs_err_str, 'NumericAttributeValue->parseValue()');
         return false;
     }
     if (strlen($va_settings['maxValue']) && $pn_value > $va_settings['maxValue']) {
         // value is too large
         $vs_err_str = _t('%1 must be no more than %2', $pa_element_info['displayLabel'], $va_settings['maxValue']);
         $this->postError(1970, $vs_err_str, 'NumericAttributeValue->parseValue()');
         return false;
     }
     if ($va_settings['regex'] && !preg_match("!" . $va_settings['regex'] . "!", $ps_value)) {
         // regex failed
         // TODO: need more descriptive error message
         $this->postError(1970, _t('%1 does not conform to required format', $pa_element_info['displayLabel']), 'IntegerAttributeValue->parseValue()');
         return false;
     }
     if (!preg_match('/[^\\d\\-]*$/', $ps_value)) {
         //this is not an integer, it contains symbols other than [0-9]
         $this->postError(1970, _t('%1 is not an integer value', $pa_element_info['displayLabel']), 'IntegerAttributeValue->parseValue()');
         return false;
     }
     if (isset($va_settings['mustBeUnique']) && (bool) $va_settings['mustBeUnique']) {
         if (isset($pa_options['transaction']) && ($o_trans = $pa_options['transaction'])) {
             $o_db = $o_trans->getDb();
         } else {
             $o_db = new Db();
         }
         $qr_values = $o_db->query('SELECT value_id FROM ca_attribute_values WHERE element_id=? AND value_integer1=?', $pa_element_info['element_id'], $pn_value);
         if ($qr_values->numRows() > 0) {
             $this->postError(1970, _t('%1 must be unique across all values. The value you entered already exists.', $pa_element_info['displayLabel']), 'IntegerAttributeValue->parseValue()');
             return false;
         }
     }
     return array('value_longtext1' => $pn_value, 'value_integer1' => $pn_value);
 }