You are here

simple_dialog_example.module in Simple Dialog 7

Same filename and directory in other branches
  1. 8 simple_dialog_example/simple_dialog_example.module

File

simple_dialog_example/simple_dialog_example.module
View source
<?php

/**
 * Implements hook_menu().
 */
function simple_dialog_example_menu() {
  $items['simple-dialog-example/target-page'] = array(
    'title' => 'Target Page',
    'page callback' => 'simple_dialog_example_target_page',
    'access arguments' => array(
      'administer simple dialog',
    ),
  );
  $items['simple-dialog-example/examples'] = array(
    'title' => 'Examples',
    'page callback' => 'simple_dialog_example_examples_page',
    'access arguments' => array(
      'administer simple dialog',
    ),
  );
  return $items;
}

/**
 * Implements hook_help().
 */
function simple_dialog_example_help($path, $arg) {
  switch ($path) {

    // Main module help for the block module
    case 'admin/help#simple_dialog_example':
      return '<p>' . t('This module provides a few examples of how to implement the simple dialog module. To get started go to: ') . l('simple-dialog-example/examples', 'simple-dialog-example/examples') . '</p>';
  }
}

/**
 * Outputs the page that is loaded into the modal windows
 */
function simple_dialog_example_target_page() {
  $output = '';
  $output .= '<div id="load-this-element"><h3>This is my target text to load</h3><p>Mauris pulvinar. Elementum sed a aliquam ut placerat et, aliquam, non, nisi aenean nec elementum in, nascetur scelerisque, magna eros, turpis non sagittis vel ultrices. Augue penatibus mid porttitor risus adipiscing sociis ac massa, vel, porttitor, urna urna, ultrices tincidunt sociis odio, est vel! Lorem odio placerat ac sagittis nisi, ac augue nunc cursus! Phasellus rhoncus? Duis augue in augue vut natoque tristique, dapibus lacus ultrices et cursus nascetur! Et in pellentesque, odio natoque non non adipiscing, augue magna hac enim, habitasse hac dictumst magnis, mus auctor, porttitor? Est augue, pulvinar et tincidunt sit quis nunc et proin eu duis amet et in ridiculus vel sociis, duis est et odio, quis? Scelerisque dictumst in lundium lectus dapibus et egestas, phasellus.</p><p>Porttitor elementum nunc sagittis odio! Purus velit mauris ridiculus, habitasse mus, placerat ut sociis lectus, magna sociis a et! Rhoncus magnis natoque massa, ridiculus augue augue. Dapibus, scelerisque proin nunc sociis, ultrices platea urna? Massa odio tincidunt facilisis turpis! Nisi in, natoque sed in et scelerisque urna vut a? In augue porta urna mauris aliquam duis a massa nec, tortor magna ridiculus lorem! Sociis tincidunt integer massa, enim augue sit phasellus, mauris in egestas, mattis, ultrices purus porttitor rhoncus. Sociis, vel, turpis dictumst. Lorem sit tincidunt sed porta, et, penatibus dapibus augue sed sed platea tincidunt turpis cum habitasse habitasse porta, magna purus, sociis. Lectus urna rhoncus? Augue aliquam proin, non lacus massa, placerat elit. Lundium! Odio magnis pellentesque.</p></div>';
  return $output;
}

/**
 * Outputs the page with the example links
 */
function simple_dialog_example_examples_page() {
  $output = '<h2>HTML Implementation</h2>';
  $output .= '<p>Here are some examples of implementations using just html mark-up.</p>';
  $output .= '<p>This first one is the simplest implementation using no specific jQuery ui settings:</p>';
  $output .= '<p><pre>
  &lt;a href="' . base_path() . 'simple-dialog-example/target-page" class="simple-dialog" name="load-this-element" title="My Dialog Title"&gt;Click Me To See The Dialog&lt;/a&gt;</pre></p>';
  $output .= '<p><a href="' . base_path() . 'simple-dialog-example/target-page" class="simple-dialog" name="load-this-element" title="My Dialog Title">Click Me To See The Dialog</a></p>';
  $output .= '<p>This implements some custom jQuery ui dialog settings in the "rel" tag of the anchor element:</p>';
  $output .= '<p><pre>
  &lt;a href="' . base_path() . 'simple-dialog-example/target-page" class="simple-dialog" name="load-this-element" title="My Dialog Title" rel="width:900;resizable:false;position:[center,60];"&gt;Click Me To See The Dialog&lt;/a&gt;</pre></p>';
  $output .= '<p><a href="' . base_path() . 'simple-dialog-example/target-page" class="simple-dialog" name="load-this-element" title="My Dialog Title" rel="width:900;resizable:false;position:[center,60];">Click Me To See The Dialog</a></p>';
  $output .= '<h2>Theme Function Implementation</h2>';
  $output .= '<p>This is an example outputting the dialog link using the theme function theme("simple_dialog_link", $args);</p>';
  $output .= '<p><pre>
    $args = ' . "array(\n      'text' => 'My Link Text',\n      'path' => 'simple-dialog-example/target-page',\n      'selector' => 'load-this-element',\n      'title' => 'My Dialog Title',\n      'options' => array(\n        'width' => 900,\n        'resizable' => FALSE,\n        'position' => array('center', 60) // can be an array of xy values\n      ),\n      'class' => array('my-link-class'),\n    );\n              </pre></p>";
  $args = array(
    'text' => 'Click Me To See The Dialog',
    'path' => 'simple-dialog-example/target-page',
    'selector' => 'load-this-element',
    'title' => 'My Dialog Title',
    'options' => array(
      'width' => 900,
      'resizable' => FALSE,
      'position' => array(
        'center',
        60,
      ),
    ),
    'class' => array(
      'my-link-class',
    ),
  );
  $output .= '<p>' . theme('simple_dialog_link', $args) . '</p>';
  return $output;
}

Functions

Namesort descending Description
simple_dialog_example_examples_page Outputs the page with the example links
simple_dialog_example_help Implements hook_help().
simple_dialog_example_menu Implements hook_menu().
simple_dialog_example_target_page Outputs the page that is loaded into the modal windows