function kwresearch_construct_pathnid_obj in Keyword Research 6
Same name and namespace in other branches
- 7 kwresearch.module \kwresearch_construct_pathnid_obj()
Creates an object with nid and path attributes based on if pid is a nid or path. Also validates that the path is valid.
Parameters
$pid - either a numeric nid or a path:
$msgs - TODO:
5 calls to kwresearch_construct_pathnid_obj()
- kwresearch_delete_page_keyword in ./
kwresearch.module - Deletes site keyword from db
- kwresearch_delete_page_keywords_by_page in ./
kwresearch.module - Deletes all the page keyword for a given page
- kwresearch_load_page_keyword in ./
kwresearch.module - Loads page keyword object from database
- kwresearch_load_page_keywords_by_page in ./
kwresearch.module - Loads an array of page keyword objects associated with a specific page
- kwresearch_save_page_keyword in ./
kwresearch.module - Saves a page keyword. Links a site keyword to a node/page
File
- ./
kwresearch.module, line 386
Code
function kwresearch_construct_pathnid_obj($pid, $msgs) {
if (!$pid) {
return FALSE;
}
$obj = new stdClass();
if ($pid > 0) {
$obj->nid = $pid;
$obj->path = 'node/' . $obj->nid;
$obj->external = 0;
}
else {
$item = array(
'link_path' => $pid,
);
kwresearch_parse_menu_item($item, $msgs);
if (is_array($msgs)) {
foreach ($msgs as $msg) {
form_set_error($msg['element'], $msg['message']);
if ($msg['status'] == 'error') {
return FALSE;
}
}
}
$obj->path = $item['link_path'];
$obj->external = $item['external'];
list($n, $nid, $e) = explode('/', $path);
if ($n == 'node' && is_numeric($nid)) {
$obj->nid = $nid;
}
}
return $obj;
}