/[drupal]/contributions/modules/texy/texy_image.module
ViewVC logotype

Contents of /contributions/modules/texy/texy_image.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Fri Apr 24 12:19:41 2009 UTC (7 months ago) by havran
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +1 -13 lines
File MIME type: text/x-php
From DRUPAL-6--1
1 <?php
2 // $Id: texy_image.module,v 1.2.2.4 2009/04/24 11:46:02 havran Exp $
3
4 /**
5 * @file
6 * Extra image settings for Texy! filter module.
7 */
8
9 /**
10 * Implementation of hook_help().
11 */
12 function texy_image_help($path, $arg) {
13 switch ($path) {
14 case 'admin/help#texy_image':
15 return '<p>'. t('Texy! Image allows you modify image settings for Texy! filter module.') .'</p>';
16 case 'admin/settings/texy/image':
17 return '<p>'. t('Below is a list of image settings for the Texy! filter module.') .'</p>';
18 }
19 }
20
21 /**
22 * Implementation of hook_menu()
23 */
24 function texy_image_menu() {
25 $items['admin/settings/texy/image'] = array(
26 'title' => 'Image',
27 'description' => 'Customize the Texy! image settings.',
28 'page callback' => 'drupal_get_form',
29 'page arguments' => array('texy_form_image_settings'),
30 'access arguments' => array('administer site configuration'),
31 'type' => MENU_LOCAL_TASK,
32 'file' => 'texy_image.admin.inc',
33 );
34
35 return $items;
36 }
37
38 /**
39 * Implementation of hook_texy_settings()
40 */
41 function texy_image_texy_settings(&$texy) {
42 // we need real physical path
43 $texy->imageModule->fileRoot = dirname($_SERVER["SCRIPT_FILENAME"]);
44 // path where images are stored and reachable from
45 // (what about private files?)
46 $texy->imageModule->root = base_path() . file_create_path(variable_get('texy_image_dir', 'images'));
47
48 $_imageclassleft = variable_get('texy_image_class_left', '');
49 if (empty($_imageclassleft)) {
50 // default class
51 $texy->imageModule->leftClass = 'left';
52 } else {
53 // specify a class
54 $texy->imageModule->leftClass = $_imageclassleft;
55 }
56
57 $_imageclassright = variable_get('texy_image_class_right', '');
58 if (empty($_imageclassright)) {
59 // default class
60 $texy->imageModule->rightClass = 'right';
61 } else {
62 // specify a class
63 $texy->imageModule->rightClass = $_imageclassright;
64 }
65
66 $_imagealttext = variable_get('texy_image_alt_text', '');
67 if (empty($_imagealttext)) {
68 // default is empty
69 $texy->imageModule->defaultAlt = '';
70 } else {
71 // specify an alt text
72 $texy->imageModule->defaultAlt = $_imagealttext;
73 }
74
75 $_imagedescclass = variable_get('texy_image_desc_class', '');
76 if (empty($_imagedescclass)) {
77 // default class
78 $texy->figureModule->class = 'image-desc';
79 } else {
80 // specify a class
81 $texy->figureModule->class = $_imagedescclass;
82 }
83
84 $_imagedescclassleft = variable_get('texy_image_desc_class_left', '');
85 if (empty($_imagedescclassleft)) {
86 // default class
87 $texy->figureModule->leftClass = 'image-desc-left';
88 } else {
89 // specify a class
90 $texy->figureModule->leftClass = $_imagedescclassleft;
91 }
92
93 $_imagedescclassright = variable_get('texy_image_desc_class_right', '');
94 if (empty($_imagedescclassleft)) {
95 // default class
96 $texy->figureModule->rightClass = 'image-desc-right';
97 } else {
98 // specify a class
99 $texy->figureModule->rightClass = $_imagedescclassright;
100 }
101 }
102
103 /**
104 * Implementation of hook_texy_handler()
105 */
106 function texy_image_texy_handler(&$texy) {
107 // check for use images with descriptions as dl
108 if (variable_get('texy_image_desc_deflist', FALSE)) {
109 $texy->addHandler('figure', 'imageDefListFigureHandler');
110 }
111 }
112
113 /**
114 * @param TexyHandlerInvocation handler invocation
115 * @param TexyImage
116 * @param TexyLink
117 * @param string
118 * @param TexyModifier
119 * @return TexyHtml|string|FALSE
120 */
121 function imageDefListFigureHandler($invocation, $image, $link, $content, $modifier) {
122 // finish invocation by default way
123 $el = $invocation->proceed();
124
125 // change div -> dl
126 $el->setName('dl');
127
128 // change p -> dd
129 $caption = $el->offsetGet(1);
130 $caption->setName('dd');
131
132 // wrap img into dt
133 $img = $el->offsetGet(0);
134 $el->offsetUnset(0);
135
136 $dt = TexyHtml::el('dt');
137 $dt->add($img);
138 $el->insert(0, $dt);
139
140 return $el;
141 }
142

  ViewVC Help
Powered by ViewVC 1.1.2