Skip to content

Instantly share code, notes, and snippets.

@samsoir
Created July 12, 2010 09:59
Show Gist options
  • Select an option

  • Save samsoir/472316 to your computer and use it in GitHub Desktop.

Select an option

Save samsoir/472316 to your computer and use it in GitHub Desktop.
<?php
/**
* View node that mirrors node, providing a MySQL view to the
* nodes and related tables.
*
* This has been implemented to allow node searching from the
* main context screen
*/
class node_view extends tsMetaNode {
protected $table = 'view_nodes';
protected $flags = array(NF_NO_ADD, NF_NO_DELETE, NF_NO_EXTENDED_SEARCH);
public static function meta($policy) {
// Modify the attributes
$policy->get("node_id")
->addFlag(AF_HIDE|AF_PRIMARY);
// THESE ARE PURELY FOR THE VIEW
$policy->get('name')->addFlag(AF_SEARCHABLE);
$policy->get('type')->addFlag(AF_HIDE);
$policy->get('uri')->addFlag(AF_SEARCHABLE);
// Relationships
$policy->hasOne("nodetype",
array(
"source"=>"node_type_id"
)
)->addFlag(AF_SEARCHABLE | AF_FORCE_LOAD);
// Ordering request by Rowan on 1 Jul 2010
$policy->setOrder(array(
'name',
'node_type_id',
'uri',
'timestamp',
));
}
function action_add($record) {
$this->redirect(session_url(dispatch_url(
'travelsphere.node',
'add'
),
SESSION_REPLACE
));
}
function action_edit($record) {
$this->redirect(session_url(dispatch_url(
'travelsphere.node',
'edit',
array('atkselector' => $this->primaryKey($record))),
SESSION_REPLACE
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment