Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // $Id$
- //Valid permissions for this module
- function artoteka_perm() {
- return array('access artoteka','administer artoteka');
- } // function artoteka_perm()
- // Add menu item linked to modul adminstration (settings).
- function artoteka_menu() {
- $items = array();
- $items['admin/settings/artoteka'] = array(
- 'title' => 'Artoteka module settings',
- 'description' => 'Set values',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('artoteka_admin'),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
- return $items;
- } // function artoteka_menu()
- function artoteka_admin() {
- $form = array();
- $form['value1'] = array(
- '#type' => 'textfield',
- '#title' => t('Number value'),
- '#default_value' => variable_get('value1', 1),
- '#size' => 2,
- '#maxlength' => 2,
- '#description' => t("Set number value."),
- '#required' => TRUE,
- );
- $form['value2'] = array(
- '#type' => 'textfield',
- '#title' => t('Number value'),
- '#default_value' => variable_get('value2', 1),
- '#size' => 2,
- '#maxlength' => 2,
- '#description' => t("Set number value."),
- '#required' => TRUE,
- );
- $form['value3'] = array(
- '#type' => 'textfield',
- '#title' => t('Number value'),
- '#default_value' => variable_get('value3', 1),
- '#size' => 2,
- '#maxlength' => 2,
- '#description' => t("Set number value."),
- '#required' => TRUE,
- );
- return system_settings_form($form);
- }
- /**
- * Implementation of hook_block().
- * @param string $op one of "list", "view", "save" and "configure"
- * @param integer $delta code to identify the block
- * @param array $edit only for "save" operation
- */
- function artoteka_block($op='list', $delta=0) {
- // Set up artoteka_block
- $block = array();
- switch ($op) {
- case 'list':
- // Generate listing of blocks from this module, for the admin/block page
- $block[0]["info"] = t('Artoteka');
- break;
- case 'view':
- // Generate our block content,
- // variableS that will be returned for display
- // Get stored values.
- $value1 = variable_get('value1',1);
- $value2 = variable_get('value2',1);
- $value3 = variable_get('value3',1);
- $block_content = t('Global value "1" is ').$value1."<br />";
- $block_content .= t('Global value "2" is ').$value2."<br />";
- $block_content .= t('Global value "3" is ').$value3."<br />";
- $block['subject'] = 'Variables inside block';
- // check to see if there was any
- // content before returning the block view
- if ($block_content == '') {
- // no content
- $block['content'] = 'Set values';
- }
- else {
- // set up the block
- $block['content'] = $block_content;
- }
- break;
- }// end switch
- return $block;
- }
- // end artoteka_block
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement