| 1 |
<?php
|
| 2 |
|
| 3 |
|
| 4 |
/*
|
| 5 |
* Copyright (C) October 2006 Jonathan Hendler
|
| 6 |
*
|
| 7 |
* This program is free software; you can redistribute it and/or
|
| 8 |
* modify it under the terms of the GNU General Public License
|
| 9 |
* as published by the Free Software Foundation; either version 2
|
| 10 |
* of the License, or (at your option) any later version.
|
| 11 |
*
|
| 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
* GNU General Public License for more details.
|
| 16 |
*
|
| 17 |
* You should have received a copy of the GNU General Public License
|
| 18 |
* along with this program; if not, write to the Free Software
|
| 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
| 20 |
*
|
| 21 |
* The author can be contacted at:
|
| 22 |
* - jonathan [at] civicactions (dot) com
|
| 23 |
*
|
| 24 |
* @license http://www.affero.org/oagpl.html
|
| 25 |
* @link http://drupal.org/project/semantic_search
|
| 26 |
*/
|
| 27 |
|
| 28 |
|
| 29 |
/**
|
| 30 |
* on install or settings update
|
| 31 |
* go through all nodes and make sure they are synced and up to date
|
| 32 |
*
|
| 33 |
* sync is one directional drupal->semantic_search
|
| 34 |
* */
|
| 35 |
function _semantic_search_node_sync(&$form_values) {
|
| 36 |
global $_semantic_search_search;
|
| 37 |
if (empty ($_semantic_search_search))
|
| 38 |
_SEMANTIC_SEARCH_INIT();
|
| 39 |
|
| 40 |
//check that ARC DB is installed
|
| 41 |
$_semantic_search_search->sonia->store->installBackend('drupal_set_message');
|
| 42 |
|
| 43 |
//erase arc_db data
|
| 44 |
//TODO would be nice to do this more gracefully
|
| 45 |
// but this is done because update node properties is tricky
|
| 46 |
// since the for the store to know if a property is updated, it must
|
| 47 |
// have the old value and the new value. Currently I do not track the old value
|
| 48 |
if(isset ($form_values['CCK_RESET']) && ($form_values['CCK_RESET'] == 1)) {
|
| 49 |
_semantic_search_node_index_del(); //$content_type
|
| 50 |
$_semantic_search_search->sonia->store->truncateTables('drupal_set_message');
|
| 51 |
}
|
| 52 |
|
| 53 |
$total_node_count = _semantic_search_node_total_count();
|
| 54 |
$batch_size = $form_values['SEMANTIC_SEARCH_IMPORT_BATCH_SIZE'];
|
| 55 |
|
| 56 |
//get all cck types
|
| 57 |
//if not active via settings
|
| 58 |
$type_options = _content_type_info();
|
| 59 |
foreach ($type_options['content types'] as $cck_type => $data) {
|
| 60 |
//create, update, or delete types and fields
|
| 61 |
$is_cck_type = true;
|
| 62 |
$pref_name = 'display_' . $cck_type;
|
| 63 |
$cck_uri = SONIA_CLASS_ID_URI . $cck_type;
|
| 64 |
$total_nodes_completed = _semantic_search_node_index_count($cck_type);
|
| 65 |
|
| 66 |
$semantic_search_set_active = variable_get($pref_name, '1');
|
| 67 |
|
| 68 |
if (!$semantic_search_set_active) {
|
| 69 |
//delete this class and all items
|
| 70 |
$_semantic_search_search->sonia->deleteClass($cck_uri, true, true);
|
| 71 |
_semantic_search_node_index_del($cck_type); //remove these nodes from the index
|
| 72 |
drupal_set_message('SEMANTIC_SEARCH: deleted class ' . $cck_uri . ' and subclasses. ');
|
| 73 |
|
| 74 |
} else if ($total_nodes_completed == 0) {
|
| 75 |
//update class $cck_uri
|
| 76 |
$class_label = $data['name'];
|
| 77 |
$class_comment = $data['description'];
|
| 78 |
//$first_param = $data['title_label'];
|
| 79 |
_semantic_search_sync_cck_class($cck_uri, $class_label, $class_comment, array ());
|
| 80 |
_semantic_search_taxonomy_create($cck_type);
|
| 81 |
}
|
| 82 |
|
| 83 |
|
| 84 |
if ($total_nodes_completed == 0) {
|
| 85 |
foreach ($data['fields'] as $field_type => $field) {
|
| 86 |
$property = SONIA_PROPERTY_ID_URI . $field_type;
|
| 87 |
|
| 88 |
if (!$semantic_search_set_active) {
|
| 89 |
//delete this property
|
| 90 |
$_semantic_search_search->sonia->deleteProperty($property, $cck_uri);
|
| 91 |
//this deletes all traces of CCK property, which mimicks drupal behaviour
|
| 92 |
//I think BAD...
|
| 93 |
//$_semantic_search_search->sonia->deleteProperty($cck_field_uri);
|
| 94 |
drupal_set_message('SEMANTIC_SEARCH: property deleted');
|
| 95 |
} else {
|
| 96 |
//update this property
|
| 97 |
$is_file_field = ($field['type'] == 'file');
|
| 98 |
$label = $field['widget']['label'];
|
| 99 |
$description = $field['widget']['description'];
|
| 100 |
_semantic_search_sync_cck_field($property, $label, $description, $cck_uri, $is_file_field);
|
| 101 |
}
|
| 102 |
}
|
| 103 |
}
|
| 104 |
|
| 105 |
//do actual node sync
|
| 106 |
$sql = "SELECT node.nid FROM node WHERE node.type = '$cck_type' ";
|
| 107 |
$result = db_query($sql);
|
| 108 |
$current_completed = 0;
|
| 109 |
|
| 110 |
while ($nodet = db_fetch_object($result)) {
|
| 111 |
if ( ($current_completed<$batch_size) && !_semantic_search_node_index_node_exists($nodet->nid)){
|
| 112 |
|
| 113 |
$node = node_load(array (
|
| 114 |
'nid' => $nodet->nid
|
| 115 |
));
|
| 116 |
|
| 117 |
$status = $node->status;
|
| 118 |
$node_type = $node->type;
|
| 119 |
|
| 120 |
//if it is a cck node is active in prefs and status= 1
|
| 121 |
if ($is_cck_type && $semantic_search_set_active && ($status == 1)) {
|
| 122 |
|
| 123 |
semantic_search_nodeapi($node,'insert',true); //this handles taxonomy sync as well
|
| 124 |
} else
|
| 125 |
if ($status == 0 || !$semantic_search_set_active) {
|
| 126 |
semantic_search_nodeapi($node, 'delete');
|
| 127 |
}
|
| 128 |
$current_completed++;
|
| 129 |
}
|
| 130 |
}
|
| 131 |
}
|
| 132 |
}
|
| 133 |
|
| 134 |
/**
|
| 135 |
* creates set of classes based on drupal taxonomy
|
| 136 |
* */
|
| 137 |
function _semantic_search_taxonomy_create($node_type){
|
| 138 |
global $_semantic_search_search;
|
| 139 |
//get it's vocabularies
|
| 140 |
$vocabularies = taxonomy_get_vocabularies($node_type);
|
| 141 |
foreach($vocabularies as $vid=>$vocabulary){
|
| 142 |
$tree = taxonomy_get_tree($vocabulary->vid);
|
| 143 |
$vid_uri = _semantic_search_cid_from_vid($vocabulary->vid);
|
| 144 |
$v_uri = $_semantic_search_search->sonia->createClass($vocabulary->name, null, $vid_uri);
|
| 145 |
$_semantic_search_search->sonia->createComment($v_uri, $vocabulary->description);
|
| 146 |
drupal_set_message('SEMANTIC_SEARCH: class <strong>' . $vocabulary->name . '</strong> created from vocabulary.');
|
| 147 |
foreach($tree as $term){
|
| 148 |
$tid_uri = _semantic_search_cid_from_tid($term->tid);
|
| 149 |
$parents = array($vid_uri);
|
| 150 |
foreach($term->parents as $parent){
|
| 151 |
$parents[] =_semantic_search_cid_from_tid($parent);
|
| 152 |
}
|
| 153 |
$t_uri = $_semantic_search_search->sonia->createClass($term->name, $parents, $tid_uri);
|
| 154 |
$_semantic_search_search->sonia->createComment($t_uri, $term->description);
|
| 155 |
drupal_set_message('SEMANTIC_SEARCH: class <strong>' . $term->name . '</strong> created from term.');
|
| 156 |
}
|
| 157 |
}
|
| 158 |
}
|
| 159 |
|
| 160 |
|
| 161 |
/**
|
| 162 |
* checks that the node index is installed
|
| 163 |
* */
|
| 164 |
function _semantic_search_node_index_check(){
|
| 165 |
if(!db_table_exists('semantic_search_node_index')){
|
| 166 |
|
| 167 |
db_query('CREATE TABLE {semantic_search_node_index} (
|
| 168 |
`nid` INT( 11 ) UNSIGNED NOT NULL ,
|
| 169 |
`rdf_id` varchar( 128 ) NOT NULL ,
|
| 170 |
`content_type` varchar( 128 ) NOT NULL ,
|
| 171 |
`index` TEXT NULL ,
|
| 172 |
INDEX ( `nid`,`rdf_id` ) ,
|
| 173 |
FULLTEXT (
|
| 174 |
`index`
|
| 175 |
)
|
| 176 |
) ENGINE = MYISAM COMMENT = \'Keeps track of nodes in semantic_search RDF\'');
|
| 177 |
|
| 178 |
drupal_set_message('SEMANTIC_SEARCH: Created SEMANTIC_SEARCH node index table in database.');
|
| 179 |
}
|
| 180 |
}
|
| 181 |
|
| 182 |
/**
|
| 183 |
* todo, make this specific for a CCK type
|
| 184 |
* */
|
| 185 |
function _semantic_search_node_index_count($content_type = null){
|
| 186 |
if ($content_type === null)
|
| 187 |
return db_result(db_query("SELECT COUNT(rdf_id) as count FROM {semantic_search_node_index}"));
|
| 188 |
else
|
| 189 |
return db_result(db_query("SELECT COUNT(rdf_id) as count FROM {semantic_search_node_index} WHERE content_type='%s'",$content_type));
|
| 190 |
}
|
| 191 |
|
| 192 |
/**
|
| 193 |
* todo, make this specific for a CCK type
|
| 194 |
* */
|
| 195 |
function _semantic_search_node_total_count($content_type = null){
|
| 196 |
if ($content_type === null)
|
| 197 |
return db_result(db_query("SELECT COUNT(nid) as count FROM {node}"));
|
| 198 |
else
|
| 199 |
return db_result(db_query("SELECT COUNT(nid) as count FROM {node} WHERE content_type='%s'",$content_type));
|
| 200 |
}
|
| 201 |
/**
|
| 202 |
* */
|
| 203 |
function _semantic_search_node_index_add_node($nid,$rdf_id,$content_type,&$node){
|
| 204 |
if( _semantic_search_node_index_node_exists($nid)){
|
| 205 |
_semantic_search_node_index_del_node($nid);
|
| 206 |
}
|
| 207 |
db_query("INSERT INTO {semantic_search_node_index} (nid,rdf_id,content_type) VALUES (%d,'%s','%s') ", $nid,$rdf_id,$content_type);
|
| 208 |
}
|
| 209 |
|
| 210 |
/**
|
| 211 |
* */
|
| 212 |
function _semantic_search_node_index_del_node($nid){
|
| 213 |
db_query("DELETE FROM {semantic_search_node_index} WHERE nid = %d ", $nid);
|
| 214 |
}
|
| 215 |
|
| 216 |
/**
|
| 217 |
* */
|
| 218 |
function _semantic_search_node_index_del($content_type = null){
|
| 219 |
if ($content_type === null)
|
| 220 |
db_query("TRUNCATE TABLE {semantic_search_node_index}");
|
| 221 |
else
|
| 222 |
db_query("DELETE FROM {semantic_search_node_index} WHERE content_type='%s'",$content_type);
|
| 223 |
}
|
| 224 |
|
| 225 |
|
| 226 |
/**
|
| 227 |
* */
|
| 228 |
function _semantic_search_node_index_node_exists($nid){
|
| 229 |
return db_result(db_query("SELECT nid FROM {semantic_search_node_index} WHERE nid= %d ", $nid));
|
| 230 |
}
|
| 231 |
|
| 232 |
/**
|
| 233 |
* */
|
| 234 |
function _semantic_search_node_exists($nid){
|
| 235 |
return db_result(db_query("SELECT nid FROM {node} WHERE nid= %d ", $nid));
|
| 236 |
}
|
| 237 |
|
| 238 |
/**
|
| 239 |
*
|
| 240 |
* */
|
| 241 |
function _semantic_search_is_cck_type($node_type){
|
| 242 |
return true;
|
| 243 |
//return db_table_exists('content_type_'.$node_type);
|
| 244 |
}
|
| 245 |
/**
|
| 246 |
* standard drupal nodeapi hook
|
| 247 |
*
|
| 248 |
* support for taxonomy, CCK (types, fields, and nodes),
|
| 249 |
* and (planned) arbitrary nodereference
|
| 250 |
*
|
| 251 |
* @todo create true inheretence
|
| 252 |
* @todo only add data on publish
|
| 253 |
*
|
| 254 |
*/
|
| 255 |
function semantic_search_nodeapi(& $node, $op, $a3 = NULL, $a4 = NULL) {
|
| 256 |
if($op == 'load' || $op == 'prepare' || $op == 'view'
|
| 257 |
|| $op == 'alter' || $op == 'submit') return;
|
| 258 |
|
| 259 |
//hack to allow
|
| 260 |
//editing of nodes with duplicate field values
|
| 261 |
if ($op == 'update'){
|
| 262 |
semantic_search_nodeapi($node,'delete');
|
| 263 |
//dbg($node,$op);
|
| 264 |
$op = 'insert';
|
| 265 |
}
|
| 266 |
|
| 267 |
global $_semantic_search_search;
|
| 268 |
|
| 269 |
$node_type = $node->type;
|
| 270 |
$node_id = $node->nid;
|
| 271 |
$node_status = $node->status;
|
| 272 |
|
| 273 |
//internally always try to delete the node if it is unpublished
|
| 274 |
if (!$node_status)
|
| 275 |
$op = 'delete';
|
| 276 |
|
| 277 |
$is_cck_type = _semantic_search_is_cck_type($node_type);
|
| 278 |
|
| 279 |
$pref_name = 'display_' . $node_type;
|
| 280 |
$pref_value = variable_get($pref_name, '1');
|
| 281 |
|
| 282 |
// add this if pages are to tracked and searched in RDF as well
|
| 283 |
//|| ($node_type == 'page')
|
| 284 |
|
| 285 |
$activate_rdf_sync = ($is_cck_type) && !empty ($node_id) && $pref_value;
|
| 286 |
//prevent SEMANTIC_SEARCH sync
|
| 287 |
if (!$pref_value && $is_cck_type) {
|
| 288 |
global $cck_notice_count;
|
| 289 |
if (!isset ($cck_notice_count))
|
| 290 |
$cck_notice_count = 0;
|
| 291 |
|
| 292 |
$link = url('admin/settings/semantic_search', null, null, true);
|
| 293 |
$title = "Activate the CCK type for SEMANTIC_SEARCH here";
|
| 294 |
if (user_access('admin semantic_search')) {
|
| 295 |
$cck_notice_count++;
|
| 296 |
if ($op != '' && $cck_notice_count == 1) {
|
| 297 |
//too annoying
|
| 298 |
//drupal_set_message('SEMANTIC_SEARCH admin Notice: CCK type "'.$node_type
|
| 299 |
// .'" is not synced with SEMANTIC_SEARCH RDF. Activate <a href="'.$link.'" title="'.$title.'">here</a>');
|
| 300 |
}
|
| 301 |
}
|
| 302 |
return;
|
| 303 |
}
|
| 304 |
|
| 305 |
if ($activate_rdf_sync || !$node_status) {
|
| 306 |
if (empty ($_semantic_search_search))
|
| 307 |
_SEMANTIC_SEARCH_INIT();
|
| 308 |
//drupal_set_message( "id=$node_id op=$op \$node_type = $node_type \$cck_type =$cck_type<br/> ");
|
| 309 |
// drupal_set_message( <br/> ");
|
| 310 |
// dbg($node ,"id=$node_id op=$op \$node_type = $node_type \$cck_type =$cck_type");
|
| 311 |
|
| 312 |
//TODO only add if status is published or "1"
|
| 313 |
$id = $node->nid;
|
| 314 |
$taxonomy = $node->taxonomy;
|
| 315 |
|
| 316 |
//$uri = $_semantic_search_search->makeNodeURI($id);
|
| 317 |
$uri = _semantic_search_getCCKOBJECTIDFromNode($node);
|
| 318 |
$label = SONIA_H :: prep_input($node->title);
|
| 319 |
$primary_class = _semantic_search_getCCKIDFromNode($node);
|
| 320 |
//$primary_class = $_semantic_search_search->makeNodeURI($node_type,'admin/node/types/');
|
| 321 |
//$taxonomy = $node->taxonomy; ///$_semantic_search_search->convertDrupalTaxonomyToSoniaCategories($node->taxonomy);
|
| 322 |
////$id_iri = $_semantic_search_search->sonia->createClass($label, $superclasses,$uri); // for taxonomies
|
| 323 |
$classes = array (
|
| 324 |
$primary_class
|
| 325 |
);
|
| 326 |
|
| 327 |
|
| 328 |
//add taxonomy to the equation
|
| 329 |
//reset
|
| 330 |
$vids = array();
|
| 331 |
if (!empty ($taxonomy)) {
|
| 332 |
if ($a3){
|
| 333 |
/* [1214] => stdClass Object
|
| 334 |
(
|
| 335 |
[tid] => 1214
|
| 336 |
[vid] => 29
|
| 337 |
[name] => Advice about Medicare
|
| 338 |
[description] =>
|
| 339 |
[weight] => 0
|
| 340 |
)
|
| 341 |
|
| 342 |
|
| 343 |
*/
|
| 344 |
foreach ($taxonomy as $tid => $tids) {
|
| 345 |
if(!in_array($tids->vid,$vids)) $classes[$tids->vid] = _semantic_search_cid_from_vid($tids->vid);
|
| 346 |
$vids[] = $tids->vid;
|
| 347 |
//foreach($tids as $tid){
|
| 348 |
//print '<br /> tid'.$tid;
|
| 349 |
$classes[$tid] = _semantic_search_cid_from_tid($tid);
|
| 350 |
//get each of these $tid's parents
|
| 351 |
//although this creates reduntant data
|
| 352 |
// this is done in place of the
|
| 353 |
// RDF store's lack of class inference
|
| 354 |
if (SEMANTIC_SEARCH_TAXONOMY_IMPORT_INFERENCE){
|
| 355 |
$parents = taxonomy_get_parents_all($tid);
|
| 356 |
|
| 357 |
foreach($parents as $parent){
|
| 358 |
$classes[$parent->tid] = _semantic_search_cid_from_tid($parent->tid);
|
| 359 |
}
|
| 360 |
}
|
| 361 |
// }
|
| 362 |
|
| 363 |
}
|
| 364 |
|
| 365 |
|
| 366 |
}
|
| 367 |
else{
|
| 368 |
foreach ($taxonomy as $vid => $tids) {
|
| 369 |
if(!in_array($vid,$vids)) $classes[$vid] = _semantic_search_cid_from_vid($vid);
|
| 370 |
$vids[] = $vid;
|
| 371 |
foreach($tids as $tid){
|
| 372 |
//print '<br /> tid'.$tid;
|
| 373 |
$classes[$tid] = _semantic_search_cid_from_tid($tid);
|
| 374 |
//get each of these $tid's parents
|
| 375 |
//although this creates reduntant data
|
| 376 |
// this is done in place of the
|
| 377 |
// RDF store's lack of class inference
|
| 378 |
if (SEMANTIC_SEARCH_TAXONOMY_IMPORT_INFERENCE){
|
| 379 |
$parents = taxonomy_get_parents_all($tid);
|
| 380 |
|
| 381 |
foreach($parents as $parent){
|
| 382 |
$classes[$parent->tid] = _semantic_search_cid_from_tid($parent->tid);
|
| 383 |
}
|
| 384 |
}
|
| 385 |
}
|
| 386 |
|
| 387 |
}
|
| 388 |
|
| 389 |
}
|
| 390 |
}
|
| 391 |
|
| 392 |
//dbg($classes, ' $classes op= '.$op);
|
| 393 |
switch ($op) {
|
| 394 |
case 'insert' :
|
| 395 |
// create instance of a class
|
| 396 |
$parameters = _semantic_search_getNodeFieldData($node);
|
| 397 |
$rdf_id = $_semantic_search_search->sonia->createObject($label,
|
| 398 |
$classes, $parameters, $uri,true);
|
| 399 |
_semantic_search_node_index_add_node($node_id,$rdf_id,$node->type,$node);
|
| 400 |
$_semantic_search_search->sonia->io->clearCache();
|
| 401 |
drupal_set_message('SEMANTIC_SEARCH: <strong>' . $label . '</strong> created');
|
| 402 |
break;
|
| 403 |
case 'update' :
|
| 404 |
$parameters = _semantic_search_getNodeFieldData($node);
|
| 405 |
$_semantic_search_search->sonia->updateObject($uri, $label, $classes, $parameters);
|
| 406 |
|
| 407 |
//drupal_set_message(dbg($parameters,'$parameters'));
|
| 408 |
$_semantic_search_search->sonia->io->clearCache();
|
| 409 |
drupal_set_message('SEMANTIC_SEARCH: <strong> ' . $label . '</strong> updated');
|
| 410 |
break;
|
| 411 |
case 'delete' :
|
| 412 |
$_semantic_search_search->sonia->deleteObject($uri);
|
| 413 |
_semantic_search_node_index_del_node($node->nid);
|
| 414 |
//do the same to coresponding data in the RDF DB
|
| 415 |
$extra = ($node_status) ? ' deleted. ' : ' deleted from search because it was set to unpublished.';
|
| 416 |
$_semantic_search_search->sonia->io->clearCache();
|
| 417 |
drupal_set_message('SEMANTIC_SEARCH: <strong>' . $label . '</strong> ' . $extra);
|
| 418 |
break;
|
| 419 |
case 'view' :
|
| 420 |
break;
|
| 421 |
|
| 422 |
}
|
| 423 |
} //end rdf sync area
|
| 424 |
}
|
| 425 |
|
| 426 |
/**
|
| 427 |
* convert a Drupal VID to a SEMANTIC_SEARCH class id
|
| 428 |
* define('SEMANTIC_SEARCH_TID_PREFIX','tid');
|
| 429 |
define('SEMANTIC_SEARCH_VID_PREFIX','vid');
|
| 430 |
* */
|
| 431 |
function _semantic_search_cid_from_vid($vid) {
|
| 432 |
return SONIA_CLASS_ID_URI . SEMANTIC_SEARCH_VID_PREFIX . $vid;
|
| 433 |
}
|
| 434 |
|
| 435 |
/**
|
| 436 |
* convert a Drupal TID to a SEMANTIC_SEARCH class id
|
| 437 |
* */
|
| 438 |
function _semantic_search_cid_from_tid($tid) {
|
| 439 |
return SONIA_CLASS_ID_URI . SEMANTIC_SEARCH_TID_PREFIX . $tid;
|
| 440 |
}
|
| 441 |
|
| 442 |
/**
|
| 443 |
* Hook into drupal taxonomy
|
| 444 |
* used here to sync with RDF on admin of taxonomy
|
| 445 |
* */
|
| 446 |
function semantic_search_taxonomy($op, $type, $object = null) {
|
| 447 |
|
| 448 |
global $_semantic_search_search;
|
| 449 |
if (empty ($_semantic_search_search))
|
| 450 |
_SEMANTIC_SEARCH_INIT();
|
| 451 |
|
| 452 |
//get cck types associated
|
| 453 |
//op form, update
|
| 454 |
$actionable = ($op == 'delete') || ($op == 'create') || ($op == 'update');
|
| 455 |
|
| 456 |
// if ($actionable) {
|
| 457 |
// $node_types = $object['nodes'];
|
| 458 |
// $is_cck_type = false;
|
| 459 |
// foreach ($node_types as $node_type) {
|
| 460 |
// //TODO check to see that it is enabled in adming/settings/semantic_search
|
| 461 |
// $pref_name = 'display_' . $node_type;
|
| 462 |
// variable_get($pref_name, '1');
|
| 463 |
// $is_cck_type = $is_cck_type || variable_get($pref_name, '1');
|
| 464 |
// }
|
| 465 |
//
|
| 466 |
// $actionable = $actionable && $is_cck_type;
|
| 467 |
// }
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
if (($type == 'vocabulary') && $actionable) {
|
| 473 |
$vid = $object['vid'];
|
| 474 |
$vid_uri = _semantic_search_cid_from_vid($vid);
|
| 475 |
$name = $object['name'];
|
| 476 |
$description = $object['description'];
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
switch ($op) {
|
| 481 |
case 'create' :
|
| 482 |
$v_uri = $_semantic_search_search->sonia->createClass($name, null, $vid_uri);
|
| 483 |
$_semantic_search_search->sonia->createComment($v_uri, $description);
|
| 484 |
$_semantic_search_search->sonia->io->clearCache();
|
| 485 |
drupal_set_message('SEMANTIC_SEARCH: class ' . $name . ' created.');
|
| 486 |
break;
|
| 487 |
case 'update' :
|
| 488 |
$_semantic_search_search->sonia->updateClass($vid_uri, $name, null);
|
| 489 |
$_semantic_search_search->sonia->updateComment($vid_uri, $description);
|
| 490 |
$_semantic_search_search->sonia->io->clearCache();
|
| 491 |
drupal_set_message('SEMANTIC_SEARCH: class ' . $name . ' updated.');
|
| 492 |
break;
|
| 493 |
case 'delete' :
|
| 494 |
$v_uri = $_semantic_search_search->sonia->deleteClass($vid_uri);
|
| 495 |
$_semantic_search_search->sonia->io->clearCache();
|
| 496 |
drupal_set_message('SEMANTIC_SEARCH: class ' . $name . ' and subclasses deleted.');
|
| 497 |
break;
|
| 498 |
}
|
| 499 |
} else
|
| 500 |
if (($type == 'term') && $actionable) {
|
| 501 |
$vid = $object['vid'];
|
| 502 |
$tid = $object['tid'];
|
| 503 |
$vid_uri = _semantic_search_cid_from_vid($vid);
|
| 504 |
$tid_uri = _semantic_search_cid_from_tid($tid);
|
| 505 |
$superclasses_ = $object['parent'];
|
| 506 |
|
| 507 |
$superclasses = array ();
|
| 508 |
|
| 509 |
if (!empty ($superclasses_)) {
|
| 510 |
foreach ($superclasses_ as $superclass) {
|
| 511 |
$superclasses[] = _semantic_search_cid_from_tid($superclass);
|
| 512 |
}
|
| 513 |
}
|
| 514 |
|
| 515 |
$superclasses[] = $vid_uri;
|
| 516 |
|
| 517 |
|
| 518 |
//TODO
|
| 519 |
//related
|
| 520 |
|
| 521 |
$name = $object['name'];
|
| 522 |
$description = $object['description'];
|
| 523 |
|
| 524 |
switch ($op) {
|
| 525 |
case 'create' :
|
| 526 |
$t_uri = $_semantic_search_search->sonia->createClass($name, $superclasses, $tid_uri);
|
| 527 |
$_semantic_search_search->sonia->createComment($t_uri, $description);
|
| 528 |
$_semantic_search_search->sonia->io->clearCache();
|
| 529 |
drupal_set_message('SEMANTIC_SEARCH: class ' . $name . ' created.');
|
| 530 |
break;
|
| 531 |
case 'update' :
|
| 532 |
$_semantic_search_search->sonia->updateClass($tid_uri, $name, $superclasses);
|
| 533 |
$_semantic_search_search->sonia->updateComment($tid_uri, $description);
|
| 534 |
$_semantic_search_search->sonia->io->clearCache();
|
| 535 |
drupal_set_message('SEMANTIC_SEARCH: class ' . $name . ' updated.');
|
| 536 |
break;
|
| 537 |
case 'delete' :
|
| 538 |
$v_uri = $_semantic_search_search->sonia->deleteClass($tid_uri);
|
| 539 |
$_semantic_search_search->sonia->io->clearCache();
|
| 540 |
drupal_set_message('SEMANTIC_SEARCH: class ' . $name . ' and subclasses deleted.');
|
| 541 |
break;
|
| 542 |
}
|
| 543 |
}
|
| 544 |
}
|
| 545 |
|
| 546 |
//seperate function for update, create, delete to be used from
|
| 547 |
// semantic_search taxonomy, and other syncs?
|
| 548 |
|
| 549 |
////////////////////////////////////////////////////////////////////////////////
|
| 550 |
// EXPERIMENTAL HOOKS
|
| 551 |
//function semantic_search_field_settings($op, $field)
|
| 552 |
//{
|
| 553 |
// dbg($op,'$op semantic_search_field_settings()');
|
| 554 |
// dbg($field,' $field semantic_search_field_settings()');
|
| 555 |
//}
|
| 556 |
//
|
| 557 |
//function semantic_search_field($op, &$node, $field, &$node_field, $teaser, $page)
|
| 558 |
//{
|
| 559 |
// dbg($op,'$op semantic_search_field()');
|
| 560 |
// dbg($field,' $field semantic_search_field()');
|
| 561 |
//}
|
| 562 |
//
|
| 563 |
//function semantic_search_widget($op, &$node, $field, &$node_field, $teaser, $page)
|
| 564 |
//{
|
| 565 |
// dbg($op,'$op semantic_search_widget()');
|
| 566 |
// dbg($field,' $field semantic_search_widget()');
|
| 567 |
//}
|
| 568 |
// END EXPERIMENTAL HOOKS
|
| 569 |
////////////////////////////////////////////////////////////////////////////////
|
| 570 |
|
| 571 |
/**
|
| 572 |
* This hook into CCK synchronizes changes to fields for content types against
|
| 573 |
* the RDF data (RDFS propertie es which belong to classes, and their labels)
|
| 574 |
*
|
| 575 |
* @todo depends on op, kind of a hack, would work if internationalized
|
| 576 |
* @todo should use http://drupal.org/node/82661
|
| 577 |
* @todo label update/create 2nd on phase 2 of of creating a field
|
| 578 |
* */
|
| 579 |
function semantic_search_form_alter($form_id, & $form) {
|
| 580 |
|
| 581 |
if (isset ($_REQUEST['op'])) {
|
| 582 |
$op = $_REQUEST['op'];
|
| 583 |
} else {
|
| 584 |
$op = null;
|
| 585 |
}
|
| 586 |
|
| 587 |
//drupal_set_message( " \$form_id=$form_id <br/> ".dbg($form,"\$op = $op"));
|
| 588 |
//find when the content type is being modified
|
| 589 |
//hack for drupal form messiness
|
| 590 |
if ($form_id == '_content_admin_type_edit') {
|
| 591 |
$label = _semantic_search_getLabelFromForm($form);
|
| 592 |
}
|
| 593 |
|
| 594 |
$is_cck_type = preg_match('/^content_/i', $form_id);
|
| 595 |
if ($is_cck_type) {
|
| 596 |
$cck_id = _semantic_search_getCCKIDFromForm($form, true);
|
| 597 |
$pref_name = 'display_' . $cck_id;
|
| 598 |
$pref_value = variable_get($pref_name, '1');
|
| 599 |
if (!$pref_value) {
|
| 600 |
$link = url('admin/settings/semantic_search', null, null, true);
|
| 601 |
$title = "Activate the CCK type for SEMANTIC_SEARCH here";
|
| 602 |
if ($op != '')
|
| 603 |
drupal_set_message('SEMANTIC_SEARCH: CCK object is not synced with RDF. Activate <a href="' . $link . '" title="' . $title . '">here</a>');
|
| 604 |
return;
|
| 605 |
}
|
| 606 |
}
|
| 607 |
|
| 608 |
switch ($form_id) {
|
| 609 |
case '_content_admin_type_edit' :
|
| 610 |
if ($label != '') {
|
| 611 |
//TODO differentiate create and update which both use this id
|
| 612 |
// $label = _semantic_search_getLabelFromForm($form); //SONIA_H :: prep_input ($form['label']['#default_value']);
|
| 613 |
$title_label_property = SONIA_PROPERTY_ID_URI . 'title_label';
|
| 614 |
$description = SONIA_H :: prep_input($form['description']['#default_value']);
|
| 615 |
//id is a hash of names
|
| 616 |
$uri = _semantic_search_getCCKIDFromForm($form);
|
| 617 |
//echo $form['type_name']['value'];
|
| 618 |
//$title_label = _semantic_search_getCCKTitleLabelFromForm($form);
|
| 619 |
//if (!$this->sonia->propertyExists('title_label'))
|
| 620 |
//{
|
| 621 |
// $title_label_property = $_semantic_search_search->sonia->createProperty($title_label,null,$title_label_property);
|
| 622 |
//}
|
| 623 |
|
| 624 |
$superclasses = array ();
|
| 625 |
|
| 626 |
_semantic_search_sync_cck_class($uri, $label, $description, $superclasses);
|
| 627 |
}
|
| 628 |
// drupal_set_message( " \$form_id=$form_id <br/> ".dbg($form));
|
| 629 |
break;
|
| 630 |
case '_content_admin_field_add_new' :
|
| 631 |
case '_content_admin_field' :
|
| 632 |
if ($op == 'Save field settings' || $op == 'Create field') {
|
| 633 |
$cck_uri = _semantic_search_getCCKIDFromForm($form);
|
| 634 |
$label = _semantic_search_getLabelFromForm($form);
|
| 635 |
$cck_field_uri = _semantic_search_getCCKFieldIDFromForm($form);
|
| 636 |
$is_file_field = _semantic_search_checkIsFileType($form);
|
| 637 |
$description = SONIA_H :: prep_input($form['widget']['description']['#default_value']);
|
| 638 |
_semantic_search_sync_cck_field($cck_field_uri, $label, $description, $cck_uri, $is_file_field);
|
| 639 |
}
|
| 640 |
// drupal_set_message( " \$form_id=$form_id <br/> ".dbg($form));
|
| 641 |
break;
|
| 642 |
case '_content_admin_type_delete' :
|
| 643 |
if ($op == 'delete' || $op == 'Delete') {
|
| 644 |
//note: I don't know if this delete the whole field or a CCK nodes reference to it.
|
| 645 |
// get class
|
| 646 |
$cck_uri = _semantic_search_getCCKIDFromForm($form);
|
| 647 |
//get all related nodes/classes and delete them too
|
| 648 |
// param 2 delete subclass, param 3 delete related objects
|
| 649 |
// deletes all subclasses and all related elements of content ...
|
| 650 |
// consistant with CCK behaviour
|
| 651 |
$_semantic_search_search->sonia->deleteClass($cck_uri, true, true);
|
| 652 |
$_semantic_search_search->sonia->io->clearCache();
|
| 653 |
drupal_set_message('SEMANTIC_SEARCH: deleted class ' . $cck_uri . ' and subclasses. ');
|
| 654 |
}
|
| 655 |
break;
|
| 656 |
case '_content_admin_field_remove' :
|
| 657 |
if ($op == 'Remove') {
|
| 658 |
$cck_uri = _semantic_search_getCCKIDFromForm($form);
|
| 659 |
$cck_field_uri = _semantic_search_getCCKFieldIDFromForm($form);
|
| 660 |
//this won't delete all traces of the property in data
|
| 661 |
$_semantic_search_search->sonia->deleteProperty($cck_field_uri, $cck_uri);
|
| 662 |
//this deletes all traces of CCK property, which mimicks drupal behaviour
|
| 663 |
//I think BAD...
|
| 664 |
//$_semantic_search_search->sonia->deleteProperty($cck_field_uri);
|
| 665 |
drupal_set_message('SEMANTIC_SEARCH: property deleted =' . $cck_field_uri);
|
| 666 |
}
|
| 667 |
break;
|
| 668 |
case '_content_admin_field_add_existing' :
|
| 669 |
if ($op == 'Add field') {
|
| 670 |
$cck_uri = _semantic_search_getCCKIDFromForm($form);
|
| 671 |
$cck_field_uri = _semantic_search_getCCKFieldIDFromForm($form);
|
| 672 |
$_semantic_search_search->sonia->addPropertyToClass($cck_uri, $cck_field_uri);
|
| 673 |
drupal_set_message('SEMANTIC_SEARCH: field added from existing set of Drupal fields');
|
| 674 |
}
|
| 675 |
break;
|
| 676 |
default :
|
| 677 |
|
| 678 |
break;
|
| 679 |
|
| 680 |
}
|
| 681 |
}
|
| 682 |
|
| 683 |
//HELPERS
|
| 684 |
|
| 685 |
function convertDrupalName($label) {
|
| 686 |
return str_replace(' ', '_', trim(strtolower($label)));
|
| 687 |
}
|
| 688 |
|
| 689 |
/**
|
| 690 |
* get the parameter names and data from a node
|
| 691 |
*
|
| 692 |
* @todo may be different for images or irregular field types
|
| 693 |
* */
|
| 694 |
function _semantic_search_getNodeFieldData(& $node) {
|
| 695 |
global $_semantic_search_search;
|
| 696 |
|
| 697 |
$parameters = array ();
|
| 698 |
$count = 0;
|
| 699 |
foreach ($node as $key => $value) {
|
| 700 |
|
| 701 |
if (preg_match('/^field_/i', $key)) {
|
| 702 |
if (is_array($value)) {
|
| 703 |
$is_file_field = $_semantic_search_search->sonia->isFileType(SONIA_PROPERTY_ID_URI . $key);
|
| 704 |
//dbg($value,'$value with images '.$is_file_field.' '. SONIA_PROPERTY_ID_URI.$key);
|
| 705 |
//if the parameter is a file or image
|
| 706 |
if ($is_file_field) {
|
| 707 |
foreach ($value as $item) {
|
| 708 |
|
| 709 |
//
|
| 710 |
if ($item['remove'] == 1) {
|
| 711 |
$image_uri = $_semantic_search_search->sonia->store->getFileInfoByFilename($item['filename'], true);
|
| 712 |
$_semantic_search_search->sonia->deleteAll($image_uri);
|
| 713 |
drupal_set_mesage("SEMANTIC_SEARCH {$item['filename']} removed.");
|
| 714 |
} else {
|
| 715 |
$parameters['images'][$count]['filename'] = $item['filename'];
|
| 716 |
$parameters['images'][$count]['filesize'] = $item['filesize'];
|
| 717 |
$parameters['images'][$count]['filepath'] = $item['filepath'];
|
| 718 |
$parameters['images'][$count]['id'] = $item['fid'];
|
| 719 |
$parameters['images'][$count]['uri'] = SONIA_PROPERTY_ID_URI . $key; //dbg($parameters,' $parameters images');
|
| 720 |
$count++;
|
| 721 |
}
|
| 722 |
}
|
| 723 |
} else {
|
| 724 |
foreach ($value as $v) {
|
| 725 |
//cck field type URL
|
| 726 |
if (isset($v['url'])){
|
| 727 |
$parameters[$count]['value'] =$v['url'];
|
| 728 |
}
|
| 729 |
else {
|
| 730 |
$parameters[$count]['value'] = $v['value'];
|
| 731 |
}
|
| 732 |
|
| 733 |
$parameters[$count]['uri'] = SONIA_PROPERTY_ID_URI . $key;
|
| 734 |
$count++;
|
| 735 |
}
|
| 736 |
}
|
| 737 |
} else // also include blank values if updated so they will be deleted
|
| 738 |
{
|
| 739 |
if (isset($v['url'])){
|
| 740 |
$parameters[$count]['value'] =$v['url'];
|
| 741 |
}
|
| 742 |
else {
|
| 743 |
$parameters[$count]['value'] = $v['value'];
|
| 744 |
}
|
| 745 |
$parameters[$count]['uri'] = SONIA_PROPERTY_ID_URI . $key;
|
| 746 |
$count++;
|
| 747 |
}
|
| 748 |
}
|
| 749 |
}
|
| 750 |
|
| 751 |
return $parameters;
|
| 752 |
}
|
| 753 |
|
| 754 |
/**
|
| 755 |
* synchronize data on a cck class
|
| 756 |
* */
|
| 757 |
function _semantic_search_sync_cck_class($uri, $label, $description, $superclasses = array (), $properties = array ()) {
|
| 758 |
global $_semantic_search_search;
|
| 759 |
if (empty ($_semantic_search_search))
|
| 760 |
_SEMANTIC_SEARCH_INIT();
|
| 761 |
|
| 762 |
$exists = $_semantic_search_search->sonia->classExists($uri);
|
| 763 |
//drupal_set_message( " \$form_id=$form_id <br/> ".dbg($form,"\$op = $op"));
|
| 764 |
if ($exists) {
|
| 765 |
$id_iri = $_semantic_search_search->sonia->updateClass($uri, $label, $superclasses);
|
| 766 |
$_semantic_search_search->sonia->updateComment($uri, $description);
|
| 767 |
//create object title property
|
| 768 |
//
|
| 769 |
//add property to class/cck
|
| 770 |
//$_semantic_search_search->sonia->updateProperty($title_label_property,$title_label_property,array($uri));
|
| 771 |
$_semantic_search_search->sonia->io->clearCache();
|
| 772 |
drupal_set_message('SEMANTIC_SEARCH: class ' . $label . ' updated as ' . $uri);
|
| 773 |
} else {
|
| 774 |
//create class
|
| 775 |
$id_iri = $_semantic_search_search->sonia->createClass($label, $superclasses, $uri);
|
| 776 |
//create description property
|
| 777 |
$_semantic_search_search->sonia->createComment($uri, $description);
|
| 778 |
//update title field
|
| 779 |
//$_semantic_search_search->sonia->addPropertyToClass($uri,$title_label_property);
|
| 780 |
$_semantic_search_search->sonia->io->clearCache();
|
| 781 |
drupal_set_message('SEMANTIC_SEARCH: class ' . $label . ' created as ' . $uri);
|
| 782 |
}
|
| 783 |
}
|
| 784 |
|
| 785 |
/**
|
| 786 |
* synce field info
|
| 787 |
* */
|
| 788 |
function _semantic_search_sync_cck_field($cck_field_uri, $label, $description, $cck_uri, $is_file_field) {
|
| 789 |
global $_semantic_search_search;
|
| 790 |
if (empty ($_semantic_search_search))
|
| 791 |
_SEMANTIC_SEARCH_INIT();
|
| 792 |
//check that ID is not blank
|
| 793 |
$temp_id = SONIA_H :: getIDFromURI($cck_field_uri);
|
| 794 |
//see if property exists
|
| 795 |
$exists = $_semantic_search_search->sonia->propertyExists($cck_field_uri);
|
| 796 |
|
| 797 |
$class_array_one = array (
|
| 798 |
$cck_uri
|
| 799 |
);
|
| 800 |
|
| 801 |
//drupal_set_message('$temp_id = '.$temp_id.dbg($form,"\$op = $op"));
|
| 802 |
if ($temp_id != '') {
|
| 803 |
if ($exists) {
|
| 804 |
//update the property
|
| 805 |
$_semantic_search_search->sonia->updateProperty($cck_field_uri, $label, $class_array_one);
|
| 806 |
//update the property values in class/cck
|
| 807 |
$_semantic_search_search->sonia->io->clearCache();
|
| 808 |
drupal_set_message('SEMANTIC_SEARCH: updated property. ' . $cck_field_uri);
|
| 809 |
} else {
|
| 810 |
//create the property
|
| 811 |
|
| 812 |
$property1 = $_semantic_search_search->sonia->createProperty($label, $class_array_one, $cck_field_uri);
|
| 813 |
//dbg(array($is_file_field,$property1),'$is_file_field - $property1');
|
| 814 |
if ($is_file_field) {
|
| 815 |
$_semantic_search_search->sonia->io->clearCache();
|
| 816 |
$_semantic_search_search->sonia->setAsImageType($property1);
|
| 817 |
$extra = ' (Property is a special file property.) ';
|
| 818 |
} else {
|
| 819 |
$extra = '';
|
| 820 |
}
|
| 821 |
//add property to class/cck
|
| 822 |
$_semantic_search_search->sonia->addPropertyToClass($cck_uri, $cck_field_uri);
|
| 823 |
$_semantic_search_search->sonia->io->clearCache();
|
| 824 |
drupal_set_message('SEMANTIC_SEARCH: added new property. ' . $extra . $cck_field_uri);
|
| 825 |
}
|
| 826 |
}
|
| 827 |
}
|
| 828 |
|
| 829 |
/**
|
| 830 |
*
|
| 831 |
* */
|
| 832 |
function _semantic_search_getLabelFromForm(& $form) {
|
| 833 |
if (isset ($form['widget']['label']['#default_value']) && $form['widget']['label']['#default_value'] != '') {
|
| 834 |
return SONIA_H :: prep_input($form['widget']['label']['#default_value']);
|
| 835 |
} else
|
| 836 |
if (isset ($form['label']['#default_value']) && $form['label']['#default_value'] != '') {
|
| 837 |
return SONIA_H :: prep_input($form['label']['#default_value']);
|
| 838 |
} else
|
| 839 |
if (isset ($form['new']['label']['#default_value']) && $form['new']['label']['#default_value'] != '') {
|
| 840 |
return SONIA_H :: prep_input($form['new']['label']['#default_value']);
|
| 841 |
}
|
| 842 |
|
| 843 |
}
|
| 844 |
|
| 845 |
/**
|
| 846 |
* get the unique URI for the CCK type
|
| 847 |
* */
|
| 848 |
function _semantic_search_getCCKOBJECTIDFromNode(& $node, $return_id = false) {
|
| 849 |
global $_semantic_search_search;
|
| 850 |
if (!empty ($node->type)) {
|
| 851 |
$id = $node->nid;
|
| 852 |
}
|
| 853 |
|
| 854 |
if ($return_id)
|
| 855 |
return $id;
|
| 856 |
return SONIA_OBJECT_ID_URI . $id;
|
| 857 |
}
|
| 858 |
|
| 859 |
function _semantic_search_checkIsFileType(& $form) {
|
| 860 |
if (isset ($form['widget']['widget_type']['#default_value']) && $form['widget']['widget_type']['#default_value'] == 'file') {
|
| 861 |
return true;
|
| 862 |
}
|
| 863 |
return false;
|
| 864 |
}
|
| 865 |
|
| 866 |
/**
|
| 867 |
* get the unique URI for the CCK type
|
| 868 |
* */
|
| 869 |
function _semantic_search_getCCKIDFromNode(& $node, $return_id = false) {
|
| 870 |
global $_semantic_search_search;
|
| 871 |
if (!empty ($node->type)) {
|
| 872 |
$id = $node->type;
|
| 873 |
}
|
| 874 |
|
| 875 |
if ($return_id)
|
| 876 |
return $id;
|
| 877 |
return SONIA_CLASS_ID_URI . $id;
|
| 878 |
}
|
| 879 |
|
| 880 |
/**
|
| 881 |
* get the unique URI for the CCK type
|
| 882 |
* */
|
| 883 |
function _semantic_search_getCCKIDFromForm(& $form, $return_id = false) {
|
| 884 |
global $_semantic_search_search;
|
| 885 |
if (!empty ($form['type_name']['#value'])) {
|
| 886 |
$id = SONIA_H :: prep_input($form['type_name']['#value']);
|
| 887 |
|
| 888 |
} else
|
| 889 |
if (!empty ($form['field']['type_name']['#value'])) {
|
| 890 |
$id = SONIA_H :: prep_input($form['field']['type_name']['#value']);
|
| 891 |
} else
|
| 892 |
if (!empty ($form['existing']['type_name']['#value'])) {
|
| 893 |
$id = SONIA_H :: prep_input($form['existing']['type_name']['#value']);
|
| 894 |
} else
|
| 895 |
if (!empty ($form['new']['type_name']['#value'])) {
|
| 896 |
$id = SONIA_H :: prep_input($form['new']['type_name']['#value']);
|
| 897 |
}
|
| 898 |
if ($return_id)
|
| 899 |
return $id;
|
| 900 |
return SONIA_CLASS_ID_URI . $id;
|
| 901 |
//$_semantic_search_search->makeNodeURI($id,'admin/node/types/');
|
| 902 |
}
|
| 903 |
|
| 904 |
/**
|
| 905 |
* get the unique URI for the CCK field
|
| 906 |
* */
|
| 907 |
function _semantic_search_getCCKFieldIDFromForm(& $form) {
|
| 908 |
global $_semantic_search_search;
|
| 909 |
$cck_id = _semantic_search_getCCKIDFromForm($form, true);
|
| 910 |
if (!empty ($form['field']['field_name']['#value'])) {
|
| 911 |
$id = SONIA_H :: prep_input($form['field']['field_name']['#value']);
|
| 912 |
} else
|
| 913 |
if (!empty ($form['field_name']['#value'])) //HACK better way?
|
| 914 |
{
|
| 915 |
$id = SONIA_H :: prep_input($form['field_name']['#value']);
|
| 916 |
//drupal_set_message( dbg($_REQUEST,"got $id"));
|
| 917 |
} else
|
| 918 |
if (!empty ($_REQUEST['edit']['field_name'])) //HACK better way?
|
| 919 |
{
|
| 920 |
$id = SONIA_H :: prep_input($_REQUEST['edit']['field_name']);
|
| 921 |
//drupal_set_message( dbg($_REQUEST,"got $id"));
|
| 922 |
}
|
| 923 |
|
| 924 |
return SONIA_PROPERTY_ID_URI . $id;
|
| 925 |
//$_semantic_search_search->makeNodeURI($id,'admin/node/types/'.$cck_id.'/fields/');
|
| 926 |
}
|
| 927 |
|
| 928 |
/**
|
| 929 |
* get the unique URI for the CCK field
|
| 930 |
* */
|
| 931 |
function _semantic_search_getCCKTitleLabelFromForm(& $form) {
|
| 932 |
global $_semantic_search_search;
|
| 933 |
$cck_id = _semantic_search_getCCKIDFromForm($form, true);
|
| 934 |
if (!empty ($form['field']['title_label']['#default_value'])) {
|
| 935 |
$id = SONIA_H :: prep_input($form['field']['title_label']['#default_value']);
|
| 936 |
} else
|
| 937 |
if (!empty ($form['title_label']['#value'])) //HACK better way?
|
| 938 |
{
|
| 939 |
$id = SONIA_H :: prep_input($form['title_label']['#default_value']);
|
| 940 |
}
|
| 941 |
|
| 942 |
//else if (!empty($_REQUEST['edit']['field_name'])) //HACK better way?
|
| 943 |
//{
|
| 944 |
//$id = SONIA_H :: prep_input ($_REQUEST['edit']['field_name']);
|
| 945 |
//}
|
| 946 |
//SONIA_PROPERTY_ID_URI.
|
| 947 |
return $id;
|
| 948 |
//$_semantic_search_search->makeNodeURI($id,'admin/node/types/'.$cck_id.'/fields/');
|
| 949 |
}
|
| 950 |
|
| 951 |
/**
|
| 952 |
* get CCK content types
|
| 953 |
* */
|
| 954 |
function _semantic_search_get_content_types() {
|
| 955 |
$options = array ();
|
| 956 |
$count = 0;
|
| 957 |
|
| 958 |
$type_info = _content_type_info();
|
| 959 |
$types = $type_info['content types'];
|
| 960 |
|
| 961 |
foreach ($types as $id => $info) {
|
| 962 |
$options[$id] = $info['label'];
|
| 963 |
$count++;
|
| 964 |
}
|
| 965 |
return $options;
|
| 966 |
}
|
| 967 |
|