View source
<?php
function angularjs_examples_menu() {
$items = array();
$items['angular/nodes'] = array(
'title' => t('Nodes'),
'page callback' => 'angularjs_examples_nodes',
'access arguments' => array(
'access content',
),
);
$items['angular/nodes/list'] = array(
'title' => t('Nodes'),
'page callback' => 'angularjs_examples_nodes_list',
'access arguments' => array(
'access content',
),
'type' => MENU_CALLBACK,
);
return $items;
}
function angularjs_examples_nodes_list() {
return drupal_get_form('angularjs_examples_nodes_list_form_builder');
}
function angularjs_examples_nodes_list_form_builder($form, &$form_state) {
$options = node_type_get_names();
$form['node_type'] = array(
'#type' => 'ng_select',
'#title' => t('Content type'),
'#options' => $options,
'#description' => t('Filter by content-type.'),
'#default_value' => key($options),
'#ng_model' => 'nodeType',
'#ng_controller' => 'ListCtrl',
'#attributes' => array(
'ng-change' => 'filterNodeType()',
),
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#attributes' => array(
'ng-model' => 'query.title',
'placeholder' => t('Filter by title'),
'autocomplete' => 'off',
),
'#ng_controller' => 'ListCtrl',
);
$header = array(
t('Title'),
t('Author'),
);
$row = array(
'{{node.title}}',
'{{node.author.id}}',
);
$form['table'] = array(
'#theme' => 'ng_table',
'#header' => $header,
'#row' => $row,
'#empty' => t('No content found.'),
'#ng_repeat' => 'node in nodes.list | filter: query',
'#ng_model' => 'nodes.list',
'#ng_empty' => '(nodes.list | filter: query).length == 0',
);
return $form;
}
function angularjs_examples_nodes() {
angularjs_init_application('nodelist');
drupal_add_js(drupal_get_path('module', 'angularjs_examples') . '/js/nodelist.js');
return theme('angularjs_examples_nodes');
}
function angularjs_examples_theme() {
$themes = array();
$themes['angularjs_examples_nodes'] = array(
'template' => 'theme/example-nodes',
'parameters' => array(),
);
$themes['angularjs_examples_nodes_list'] = array(
'template' => 'theme/example-nodes-list',
'parameters' => array(
'query' => array(),
),
);
return $themes;
}