| 1 | package OpenInteract2::Brick::PackageFromTable; | ||||||||||
| 2 | |||||||||||
| 3 | 87 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 87 | ▶ | use base qw( OpenInteract2::Brick ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 87 | ▶ | use OpenInteract2::Exception; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 87 | my %INLINED_SUBS = ( | |||||||||
| 8 | 'package.ini' => 'PACKAGEINI', | ||||||||||
| 9 | 'MANIFEST.SKIP' => 'MANIFESTSKIP', | ||||||||||
| 10 | 'spops.ini' => 'SPOPSINI', | ||||||||||
| 11 | 'action.ini' => 'ACTIONINI', | ||||||||||
| 12 | 'messages_en.msg' => 'MESSAGES_ENMSG', | ||||||||||
| 13 | 'SQLInstall.pm' => 'SQLINSTALLPM', | ||||||||||
| 14 | 'Action.pm' => 'ACTIONPM', | ||||||||||
| 15 | 'App.pm' => 'APPPM', | ||||||||||
| 16 | 'form.tmpl' => 'FORMTMPL', | ||||||||||
| 17 | 'display.tmpl' => 'DISPLAYTMPL', | ||||||||||
| 18 | 'search_form.tmpl' => 'SEARCH_FORMTMPL', | ||||||||||
| 19 | 'search_results.tmpl' => 'SEARCH_RESULTSTMPL', | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 87 | ▶ | sub get_name { | ||||||||
|
Subroutine
get_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 23 | 87 | return 'package_from_table'; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub get_resources { | ||||||||
|
Subroutine
get_resources: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 27 | return ( | ||||||||||
| 28 | 0 | 'package.ini' => [ 'package.ini', 'yes' ], | |||||||||
| 29 | 'MANIFEST.SKIP' => [ 'MANIFEST.SKIP', 'yes' ], | ||||||||||
| 30 | 'spops.ini' => [ 'conf spops.ini', 'yes' ], | ||||||||||
| 31 | 'action.ini' => [ 'conf action.ini', 'yes' ], | ||||||||||
| 32 | 'messages_en.msg' => [ 'msg/[% package_name %]-messages-en.msg', 'yes' ], | ||||||||||
| 33 | 'SQLInstall.pm' => [ 'OpenInteract2 SQLInstall [% class_name %].pm', 'yes' ], | ||||||||||
| 34 | 'Action.pm' => [ 'OpenInteract2 Action [% class_name %].pm', 'yes' ], | ||||||||||
| 35 | 'App.pm' => [ 'OpenInteract2 App [% class_name %].pm', 'yes' ], | ||||||||||
| 36 | 'form.tmpl' => [ 'template form.tmpl', 'yes' ], | ||||||||||
| 37 | 'display.tmpl' => [ 'template display.tmpl', 'yes' ], | ||||||||||
| 38 | 'search_form.tmpl' => [ 'template search_form.tmpl', 'yes' ], | ||||||||||
| 39 | 'search_results.tmpl' => [ 'template search_results.tmpl', 'yes' ], | ||||||||||
| 40 | ); | ||||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub load { | ||||||||
|
Subroutine
load: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 44 | 0 | my ( $self, $resource_name ) = @_; | |||||||||
| 45 | 0 | my $inline_sub_name = $INLINED_SUBS{ $resource_name }; | |||||||||
| 46 | 0 | ▶ | unless ( $inline_sub_name ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | OpenInteract2::Exception->throw( | |||||||||
| 48 | "Resource name '$resource_name' not found ", | ||||||||||
| 49 | "in ", ref( $self ), "; cannot load content." ); | ||||||||||
| 50 | } | ||||||||||
| 51 | 0 | return $self->$inline_sub_name(); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 87 | OpenInteract2::Brick->register_factory_type( get_name() => __PACKAGE__ ); | |||||||||
| 55 | |||||||||||
| 56 | =pod | ||||||||||
| 57 | |||||||||||
| 58 | =head1 NAME | ||||||||||
| 59 | |||||||||||
| 60 | OpenInteract2::Brick::PackageFromTable - All resources used for creating a package based on a table | ||||||||||
| 61 | |||||||||||
| 62 | =head1 SYNOPSIS | ||||||||||
| 63 | |||||||||||
| 64 | oi2_manage easy_app --package=books --table=books --dsn=DBI:Pg:dbname=pubs --username=foo --password=bar | ||||||||||
| 65 | |||||||||||
| 66 | =head1 DESCRIPTION | ||||||||||
| 67 | |||||||||||
| 68 | This class just holds all the static resources used when creating a package with basic Create, Update,Delete and Search functionality based on an existing database table. | ||||||||||
| 69 | |||||||||||
| 70 | These resources are associated with OpenInteract2 version 1.99_06. | ||||||||||
| 71 | |||||||||||
| 72 | =head2 Resources | ||||||||||
| 73 | |||||||||||
| 74 | You can grab resources individually using the names below and | ||||||||||
| 75 | C<load_resource()> and C<copy_resources_to()>, or you can copy all the | ||||||||||
| 76 | resources at once using C<copy_all_resources_to()> -- see | ||||||||||
| 77 | L<OpenInteract2::Brick> for details. | ||||||||||
| 78 | |||||||||||
| 79 | =over 4 | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | =item B<package.ini> | ||||||||||
| 83 | |||||||||||
| 84 | =item B<MANIFEST.SKIP> | ||||||||||
| 85 | |||||||||||
| 86 | =item B<spops.ini> | ||||||||||
| 87 | |||||||||||
| 88 | =item B<action.ini> | ||||||||||
| 89 | |||||||||||
| 90 | =item B<messages_en.msg> | ||||||||||
| 91 | |||||||||||
| 92 | =item B<SQLInstall.pm> | ||||||||||
| 93 | |||||||||||
| 94 | =item B<Action.pm> | ||||||||||
| 95 | |||||||||||
| 96 | =item B<App.pm> | ||||||||||
| 97 | |||||||||||
| 98 | =item B<form.tmpl> | ||||||||||
| 99 | |||||||||||
| 100 | =item B<display.tmpl> | ||||||||||
| 101 | |||||||||||
| 102 | =item B<search_form.tmpl> | ||||||||||
| 103 | |||||||||||
| 104 | =item B<search_results.tmpl> | ||||||||||
| 105 | |||||||||||
| 106 | |||||||||||
| 107 | =back | ||||||||||
| 108 | |||||||||||
| 109 | =head1 COPYRIGHT | ||||||||||
| 110 | |||||||||||
| 111 | Copyright (c) 2005 Chris Winters. All rights reserved. | ||||||||||
| 112 | |||||||||||
| 113 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 114 | it under the same terms as Perl itself. | ||||||||||
| 115 | |||||||||||
| 116 | =head1 AUTHORS | ||||||||||
| 117 | |||||||||||
| 118 | |||||||||||
| 119 | Chris Winters E<lt>chris@cwinters.comE<gt> | ||||||||||
| 120 | |||||||||||
| 121 | |||||||||||
| 122 | =cut | ||||||||||
| 123 | |||||||||||
| 124 | |||||||||||
| 125 | 0 | ▶ | sub PACKAGEINI { | ||||||||
|
Subroutine
PACKAGEINI: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 126 | 0 | return <<'SOMELONGSTRING'; | |||||||||
| 127 | [package] | ||||||||||
| 128 | name = [% package_name %] | ||||||||||
| 129 | version = 0.01 | ||||||||||
| 130 | author = Who AmI <me@whoami.com> | ||||||||||
| 131 | url = http://www.whereami.com/ | ||||||||||
| 132 | sql_installer = OpenInteract2::SQLInstall::[% class_name %] | ||||||||||
| 133 | description = Description of package [% package_name %] goes here. Use can use '\' as a line continuation. | ||||||||||
| 134 | |||||||||||
| 135 | # Dependencies: use multiple lines for multiple dependencies | ||||||||||
| 136 | module = | ||||||||||
| 137 | |||||||||||
| 138 | # Other options: config_watcher, spops_file, action_file, message_file | ||||||||||
| 139 | |||||||||||
| 140 | # Add template plugins here: key is name of plugin, value is class | ||||||||||
| 141 | [package template_plugin] | ||||||||||
| 142 | |||||||||||
| 143 | # Register observers here: key is name of observer, value is class | ||||||||||
| 144 | [package observer] | ||||||||||
| 145 | |||||||||||
| 146 | |||||||||||
| 147 | SOMELONGSTRING | ||||||||||
| 148 | } | ||||||||||
| 149 | |||||||||||
| 150 | 0 | ▶ | sub MANIFESTSKIP { | ||||||||
|
Subroutine
MANIFESTSKIP: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 151 | 0 | return <<'SOMELONGSTRING'; | |||||||||
| 152 | \bCVS\b | ||||||||||
| 153 | ~$ | ||||||||||
| 154 | ^oi2_manage\.log$ | ||||||||||
| 155 | \.old$ | ||||||||||
| 156 | \.bak$ | ||||||||||
| 157 | \.backup$ | ||||||||||
| 158 | ^tmp | ||||||||||
| 159 | ^_ | ||||||||||
| 160 | |||||||||||
| 161 | SOMELONGSTRING | ||||||||||
| 162 | } | ||||||||||
| 163 | |||||||||||
| 164 | 0 | ▶ | sub SPOPSINI { | ||||||||
|
Subroutine
SPOPSINI: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 165 | 0 | return <<'SOMELONGSTRING'; | |||||||||
| 166 | [[% package_name %]] | ||||||||||
| 167 | class = OpenInteract2::[% class_name %] | ||||||||||
| 168 | isa = | ||||||||||
| 169 | base_table = [% table %] | ||||||||||
| 170 | field_discover = yes | ||||||||||
| 171 | field = | ||||||||||
| 172 | id_field = [% key_field %] | ||||||||||
| 173 | |||||||||||
| 174 | # We assume the ID field is auto-incrementable | ||||||||||
| 175 | increment_field = yes | ||||||||||
| 176 | |||||||||||
| 177 | # ...and that we have a sequence associated with it; if you're not | ||||||||||
| 178 | # using Oracle, PostgreSQL, or other sequenced-based systems then you | ||||||||||
| 179 | # can ignore this | ||||||||||
| 180 | sequence_name = [% table %]_seq | ||||||||||
| 181 | |||||||||||
| 182 | is_secure = no | ||||||||||
| 183 | no_insert = [% key_field %] | ||||||||||
| 184 | no_update = [% key_field %] | ||||||||||
| 185 | skip_undef = | ||||||||||
| 186 | sql_defaults = | ||||||||||
| 187 | |||||||||||
| 188 | |||||||||||
| 189 | # Additional names by which you can lookup this object class | ||||||||||
| 190 | #alias = | ||||||||||
| 191 | |||||||||||
| 192 | # Set to 'yes' for automatic full-text indexing. | ||||||||||
| 193 | #is_searchable = no | ||||||||||
| 194 | |||||||||||
| 195 | # ...and also list fields to be indexed | ||||||||||
| 196 | #fulltext_field = | ||||||||||
| 197 | |||||||||||
| 198 | # Field/method name used to generically generate an object's title | ||||||||||
| 199 | name = [% name_field %] | ||||||||||
| 200 | |||||||||||
| 201 | # Name of this class of objects (e.g., 'News') | ||||||||||
| 202 | object_name = [% class_name %] | ||||||||||
| 203 | |||||||||||
| 204 | # Datetime fields get auto-converted to DateTime objects | ||||||||||
| 205 | [% FOREACH field = field_info -%] | ||||||||||
| 206 | [% IF field.is_datetime %]convert_date_field = [% field.name %][% END %] | ||||||||||
| 207 | [% END -%] | ||||||||||
| 208 | |||||||||||
| 209 | [[% package_name %] track] | ||||||||||
| 210 | create = yes | ||||||||||
| 211 | update = no | ||||||||||
| 212 | remove = yes | ||||||||||
| 213 | |||||||||||
| 214 | [[% package_name %] display] | ||||||||||
| 215 | ACTION = [% package_name %] | ||||||||||
| 216 | TASK = display | ||||||||||
| 217 | |||||||||||
| 218 | # Additional information | ||||||||||
| 219 | # | ||||||||||
| 220 | |||||||||||
| 221 | # Define a containing relationship. Key is class of object, value is | ||||||||||
| 222 | # the ID field in your object. So if your object contains a user ID | ||||||||||
| 223 | # field in 'user_id', you'd use 'OpenInteract2::User = user_id'; see | ||||||||||
| 224 | # SPOPS::Manual::Relationships' for details. | ||||||||||
| 225 | |||||||||||
| 226 | #[[% package_name %] has_a] | ||||||||||
| 227 | #OpenInteract2::Theme = theme_id | ||||||||||
| 228 | |||||||||||
| 229 | # Define a relationship between objects from this class and any number | ||||||||||
| 230 | # of other objects | ||||||||||
| 231 | |||||||||||
| 232 | #[[% package_name %] links_to] | ||||||||||
| 233 | #OpenInteract2::Foo = foo_[% package_name %]_link | ||||||||||
| 234 | |||||||||||
| 235 | # Security to apply to newly created objects from this class. | ||||||||||
| 236 | #[[% package_name %] creation_security] | ||||||||||
| 237 | #user = WRITE | ||||||||||
| 238 | #group = site_admin_group:WRITE | ||||||||||
| 239 | #world = READ | ||||||||||
| 240 | |||||||||||
| 241 | |||||||||||
| 242 | |||||||||||
| 243 | SOMELONGSTRING | ||||||||||
| 244 | } | ||||||||||
| 245 | |||||||||||
| 246 | 0 | ▶ | sub ACTIONINI { | ||||||||
|
Subroutine
ACTIONINI: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 247 | 0 | return <<'SOMELONGSTRING'; | |||||||||
| 248 | [[% package_name %]] | ||||||||||
| 249 | class = OpenInteract2::Action::[% class_name %] | ||||||||||
| 250 | task_default = search_form | ||||||||||
| 251 | |||||||||||
| 252 | c_object_type = [% package_name %] | ||||||||||
| 253 | |||||||||||
| 254 | # Search parameters | ||||||||||
| 255 | c_search_form_template = [% package_name %]::search_form | ||||||||||
| 256 | [% FOREACH field = fields -%] | ||||||||||
| 257 | [% IF field.is_boolean -%] | ||||||||||
| 258 | c_search_fields_exact = [% field.name %] | ||||||||||
| 259 | [% ELSIF field.is_text -%] | ||||||||||
| 260 | c_search_fields_like = [% field.name %] | ||||||||||
| 261 | [% END -%] | ||||||||||
| 262 | [% END -%] | ||||||||||
| 263 | c_search_results_template = [% package_name %]::search_results | ||||||||||
| 264 | |||||||||||
| 265 | # Display parameters | ||||||||||
| 266 | c_display_template = [% package_name %]::display | ||||||||||
| 267 | c_display_fail_task = search_form | ||||||||||
| 268 | |||||||||||
| 269 | # Add parameters | ||||||||||
| 270 | c_display_add_template = [% package_name %]::form | ||||||||||
| 271 | c_add_task = display | ||||||||||
| 272 | c_add_fail_task = display_add | ||||||||||
| 273 | |||||||||||
| 274 | [% FOREACH field = fields -%] | ||||||||||
| 275 | [% IF field.is_key; NEXT -%] | ||||||||||
| 276 | [% ELSIF field.is_date -%] | ||||||||||
| 277 | c_add_fields_date = [% field.name %] | ||||||||||
| 278 | [% ELSIF field.is_boolean -%] | ||||||||||
| 279 | c_add_fields_boolean = [% field.name %] | ||||||||||
| 280 | [% ELSE -%] | ||||||||||
| 281 | c_add_fields = [% field.name %] | ||||||||||
| 282 | [% END -%] | ||||||||||
| 283 | [% END -%] | ||||||||||
| 284 | |||||||||||
| 285 | # Update parameters | ||||||||||
| 286 | c_display_form_template = [% package_name %]::form | ||||||||||
| 287 | c_display_form_fail_task = search_form | ||||||||||
| 288 | c_update_task = display | ||||||||||
| 289 | c_update_fail_task = display_form | ||||||||||
| 290 | |||||||||||
| 291 | [% FOREACH field = fields -%] | ||||||||||
| 292 | [% IF field.is_key; NEXT -%] | ||||||||||
| 293 | [% ELSIF field.is_date -%] | ||||||||||
| 294 | c_update_fields_date = [% field.name %] | ||||||||||
| 295 | [% ELSIF field.is_boolean -%] | ||||||||||
| 296 | c_update_fields_boolean = [% field.name %] | ||||||||||
| 297 | [% ELSE -%] | ||||||||||
| 298 | c_update_fields = [% field.name %] | ||||||||||
| 299 | [% END -%] | ||||||||||
| 300 | [% END -%] | ||||||||||
| 301 | |||||||||||
| 302 | # Remove parameters | ||||||||||
| 303 | c_remove_task = search_form | ||||||||||
| 304 | c_remove_fail_task = search_form | ||||||||||
| 305 | |||||||||||
| 306 | |||||||||||
| 307 | SOMELONGSTRING | ||||||||||
| 308 | } | ||||||||||
| 309 | |||||||||||
| 310 | 0 | ▶ | sub MESSAGES_ENMSG { | ||||||||
|
Subroutine
MESSAGES_ENMSG: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 311 | 0 | return <<'SOMELONGSTRING'; | |||||||||
| 312 | [% package_name %].title_update = Update the Object | ||||||||||
| 313 | [% package_name %].title_create = Create a New Object | ||||||||||
| 314 | [% package_name %].title_search_form = Search for Objects | ||||||||||
| 315 | [% package_name %].title_search_results = Search Results | ||||||||||
| 316 | [% package_name %].title_display = Object Details | ||||||||||
| 317 | [% package_name %].no_results = No results found. <a href="[_1]">Create a new object</a>? | ||||||||||
| 318 | |||||||||||
| 319 | [% FOREACH field = fields -%] | ||||||||||
| 320 | [% package_name %].[% field.name %]_title = [% field.display %] | ||||||||||
| 321 | [% END -%] | ||||||||||
| 322 | |||||||||||
| 323 | SOMELONGSTRING | ||||||||||
| 324 | } | ||||||||||
| 325 | |||||||||||
| 326 | 0 | ▶ | sub SQLINSTALLPM { | ||||||||
|
Subroutine
SQLINSTALLPM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 327 | 0 | return <<'SOMELONGSTRING'; | |||||||||
| 328 | package OpenInteract2::SQLInstall::[% class_name %]; | ||||||||||
| 329 | |||||||||||
| 330 | # Sample of SQL installation class. This uses the given name as the | ||||||||||
| 331 | # base includes a sequence for PostgreSQL users (and Oracle too). | ||||||||||
| 332 | |||||||||||
| 333 | use strict; | ||||||||||
| 334 | use base qw( OpenInteract2::SQLInstall ); | ||||||||||
| 335 | |||||||||||
| 336 | my %FILES = ( | ||||||||||
| 337 | pg => [ '[% table %].sql', | ||||||||||
| 338 | '[% table %]_sequence.sql' ], | ||||||||||
| 339 | default => [ '[% table %].sql' ], | ||||||||||
| 340 | ); | ||||||||||
| 341 | |||||||||||
| 342 | sub get_structure_set { | ||||||||||
| 343 | return '[% package_name %]'; | ||||||||||
| 344 | } | ||||||||||
| 345 | |||||||||||
| 346 | sub get_structure_file { | ||||||||||
| 347 | my ( $self, $set, $type ) = @_; | ||||||||||
| 348 | return $FILES{pg} if ( $type eq 'Pg' ); | ||||||||||
| 349 | return $FILES{default}; | ||||||||||
| 350 | } | ||||||||||
| 351 | |||||||||||
| 352 | # Uncomment this if you're passing along initial data | ||||||||||
| 353 | |||||||||||
| 354 | #sub get_data_file { | ||||||||||
| 355 | # return 'initial_data.dat'; | ||||||||||
| 356 | #} | ||||||||||
| 357 | |||||||||||
| 358 | # Uncomment this if you're using security | ||||||||||
| 359 | |||||||||||
| 360 | #sub get_security_file { | ||||||||||
| 361 | # return 'install_security.dat'; | ||||||||||
| 362 | #} | ||||||||||
| 363 | |||||||||||
| 364 | 1; | ||||||||||
| 365 | |||||||||||
| 366 | SOMELONGSTRING | ||||||||||
| 367 | } | ||||||||||
| 368 | |||||||||||
| 369 | 0 | ▶ | sub ACTIONPM { | ||||||||
|
Subroutine
ACTIONPM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 370 | 0 | return <<'SOMELONGSTRING'; | |||||||||
| 371 | package OpenInteract2::Action::[% class_name %]; | ||||||||||
| 372 | |||||||||||
| 373 | use strict; | ||||||||||
| 374 | |||||||||||
| 375 | use base qw( | ||||||||||
| 376 | OpenInteract2::Action::CommonAdd | ||||||||||
| 377 | OpenInteract2::Action::CommonDisplay | ||||||||||
| 378 | OpenInteract2::Action::CommonRemove | ||||||||||
| 379 | OpenInteract2::Action::CommonSearch | ||||||||||
| 380 | OpenInteract2::Action::CommonUpdate | ||||||||||
| 381 | ); | ||||||||||
| 382 | |||||||||||
| 383 | use Log::Log4perl qw( get_logger ); | ||||||||||
| 384 | use OpenInteract2::Constants qw( :log ); | ||||||||||
| 385 | use OpenInteract2::Context qw( CTX ); | ||||||||||
| 386 | |||||||||||
| 387 | # It's always nice to let CVS deal with this | ||||||||||
| 388 | $OpenInteract2::Action::[% class_name %]::VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/); | ||||||||||
| 389 | |||||||||||
| 390 | ######################################## | ||||||||||
| 391 | # DISPLAY | ||||||||||
| 392 | |||||||||||
| 393 | # customize what parameters get sent to 'display.tmpl' | ||||||||||
| 394 | # More info: see OpenInteract2::Action::CommonDisplay | ||||||||||
| 395 | |||||||||||
| 396 | sub _display_customize { | ||||||||||
| 397 | my ( $self, $template_params ) = @_; | ||||||||||
| 398 | } | ||||||||||
| 399 | |||||||||||
| 400 | |||||||||||
| 401 | ######################################## | ||||||||||
| 402 | # ADD | ||||||||||
| 403 | |||||||||||
| 404 | # customize what parameters get sent to 'form.tmpl' on an add | ||||||||||
| 405 | # More info: see OpenInteract2::Action::CommonAdd | ||||||||||
| 406 | |||||||||||
| 407 | sub _display_add_customize { | ||||||||||
| 408 | my ( $self, $template_params ) = @_; | ||||||||||
| 409 | } | ||||||||||
| 410 | |||||||||||
| 411 | # customize what occurs when adding an object, including validation | ||||||||||
| 412 | # More info: see OpenInteract2::Action::CommonAdd | ||||||||||
| 413 | |||||||||||
| 414 | sub _add_customize { | ||||||||||
| 415 | my ( $self, $object, $save_options ) = @_; | ||||||||||
| 416 | } | ||||||||||
| 417 | |||||||||||
| 418 | # perform any actions after the add has occurred | ||||||||||
| 419 | # More info: see OpenInteract2::Action::CommonAdd | ||||||||||
| 420 | |||||||||||
| 421 | sub _add_post_action { | ||||||||||
| 422 | my ( $self, $object ) = @_; | ||||||||||
| 423 | } | ||||||||||
| 424 | |||||||||||
| 425 | |||||||||||
| 426 | ######################################## | ||||||||||
| 427 | # UPDATE | ||||||||||
| 428 | |||||||||||
| 429 | # customize what parameters get sent to 'form.tmpl' on an update | ||||||||||
| 430 | # More info: see OpenInteract2::Action::CommonUpdate | ||||||||||
| 431 | |||||||||||
| 432 | sub _display_form_customize { | ||||||||||
| 433 | my ( $self, $template_params ) = @_; | ||||||||||
| 434 | } | ||||||||||
| 435 | |||||||||||
| 436 | # customize what occurs when updating an object, including validation; | ||||||||||
| 437 | # the hashref $old_data is the object's old data for comparison | ||||||||||
| 438 | # More info: see OpenInteract2::Action::CommonUpdate | ||||||||||
| 439 | |||||||||||
| 440 | sub _update_customize { | ||||||||||
| 441 | my ( $self, $object, $old_data, $save_options ) = @_; | ||||||||||
| 442 | } | ||||||||||
| 443 | |||||||||||
| 444 | # perform any actions after the add has occurred; the hashref | ||||||||||
| 445 | # $old_data is the object's old data for comparison | ||||||||||
| 446 | # More info: see OpenInteract2::Action::CommonUpdate | ||||||||||
| 447 | |||||||||||
| 448 | sub _update_post_action { | ||||||||||
| 449 | my ( $self, $object, $old_data ) = @_; | ||||||||||
| 450 | } | ||||||||||
| 451 | |||||||||||
| 452 | |||||||||||
| 453 | ######################################## | ||||||||||
| 454 | # REMOVE | ||||||||||
| 455 | |||||||||||
| 456 | # perform any actions before the remove has occurred; you'll find the | ||||||||||
| 457 | # object we're about to remove in: | ||||||||||
| 458 | # $self->param( 'c_object' ); | ||||||||||
| 459 | # More info: see OpenInteract2::Action::CommonRemove | ||||||||||
| 460 | |||||||||||
| 461 | sub _remove_customize { | ||||||||||
| 462 | my ( $self ) = @_; | ||||||||||
| 463 | } | ||||||||||
| 464 | |||||||||||
| 465 | |||||||||||
| 466 | ######################################## | ||||||||||
| 467 | # SEARCH | ||||||||||
| 468 | |||||||||||
| 469 | |||||||||||
| 470 | # modify template parameters sent to 'search_form.tmpl' | ||||||||||
| 471 | # More info: see OpenInteract2::Action::CommonSearch | ||||||||||
| 472 | |||||||||||
| 473 | sub _search_form_customize { | ||||||||||
| 474 | my ( $self, $template_params ) = @_; | ||||||||||
| 475 | } | ||||||||||
| 476 | |||||||||||
| 477 | # modify the query criteria before we translate them to SQL | ||||||||||
| 478 | # More info: see OpenInteract2::Action::CommonSearch | ||||||||||
| 479 | |||||||||||
| 480 | sub _search_criteria_customize { | ||||||||||
| 481 | my ( $self ) = @_; | ||||||||||
| 482 | } | ||||||||||
| 483 | |||||||||||
| 484 | # modify the query pieces before we run the query | ||||||||||
| 485 | # More info: see OpenInteract2::Action::CommonSearch | ||||||||||
| 486 | |||||||||||
| 487 | sub _search_query_customize { | ||||||||||
| 488 | my ( $self ) = @_; | ||||||||||
| 489 | } | ||||||||||
| 490 | |||||||||||
| 491 | # any parameters you return as a hashref get passed to the final | ||||||||||
| 492 | # SPOPS::DBI->fetch_iterator() call | ||||||||||
| 493 | # More info: see OpenInteract2::Action::CommonSearch | ||||||||||
| 494 | |||||||||||
| 495 | sub _search_additonal_params { | ||||||||||
| 496 | my ( $self ) = @_; | ||||||||||
| 497 | } | ||||||||||
| 498 | |||||||||||
| 499 | # modify template parameters sent to 'search_results.tmpl' | ||||||||||
| 500 | # More info: see OpenInteract2::Action::CommonSearch | ||||||||||
| 501 | |||||||||||
| 502 | sub _search_customize { | ||||||||||
| 503 | my ( $self, $template_params ) = @_; | ||||||||||
| 504 | } | ||||||||||
| 505 | |||||||||||
| 506 | 1; | ||||||||||
| 507 | |||||||||||
| 508 | SOMELONGSTRING | ||||||||||
| 509 | } | ||||||||||
| 510 | |||||||||||
| 511 | 0 | ▶ | sub APPPM { | ||||||||
|
Subroutine
APPPM: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 512 | 0 | return <<'SOMELONGSTRING'; | |||||||||
| 513 | package OpenInteract2::App::[% class_name %]; | ||||||||||
| 514 | |||||||||||
| 515 | use strict; | ||||||||||
| 516 | use base qw( Exporter OpenInteract2::App ); | ||||||||||
| 517 | use OpenInteract2::Manage; | ||||||||||
| 518 | |||||||||||
| 519 | $OpenInteract2::App::[% class_name %]::VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/); | ||||||||||
| 520 | @OpenInteract2::App::[% class_name %]::EXPORT = qw( install ); | ||||||||||
| 521 | |||||||||||
| 522 | my $NAME = '[% package_name %]'; | ||||||||||
| 523 | |||||||||||
| 524 | sub new { | ||||||||||
| 525 | return OpenInteract2::App->new( $NAME ); | ||||||||||
| 526 | } | ||||||||||
| 527 | |||||||||||
| 528 | sub get_brick { | ||||||||||
| 529 | require OpenInteract2::Brick; | ||||||||||
| 530 | return OpenInteract2::Brick->new( $NAME ); | ||||||||||
| 531 | } | ||||||||||
| 532 | |||||||||||
| 533 | sub get_brick_name { | ||||||||||
| 534 | return $NAME; | ||||||||||
| 535 | } | ||||||||||
| 536 | |||||||||||
| 537 | # Not a method, just an exported sub | ||||||||||
| 538 | sub install { | ||||||||||
| 539 | my ( $website_dir ) = @_; | ||||||||||
| 540 | my $manage = OpenInteract2::Manage->new( 'install_package' ); | ||||||||||
| 541 | $manage->param( website_dir => $website_dir ); | ||||||||||
| 542 | $manage->param( package_class => __PACKAGE__ ); | ||||||||||
| 543 | return $manage->execute; | ||||||||||
| 544 | } | ||||||||||
| 545 | |||||||||||
| 546 | OpenInteract2::App->register_factory_type( $NAME => __PACKAGE__ ); | ||||||||||
| 547 | |||||||||||
| 548 | 1; | ||||||||||
| 549 | |||||||||||
| 550 | __END__ | ||||||||||