| [ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 # CMS - CMS Made Simple 3 # (c)2004-6 by Ted Kulp (ted@cmsmadesimple.org) 4 # This project's homepage is: http://cmsmadesimple.org 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; either version 2 of the License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # BUT withOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: class.module.inc.php 3808 2007-03-05 20:41:03Z calguy1000 $ 20 21 /** 22 * Base module class. 23 * 24 * All modules should inherit and extend this class with their functionality. 25 * 26 * @since 0.9 27 * @package CMS 28 */ 29 class CMSModule 30 { 31 /** 32 * ------------------------------------------------------------------ 33 * Initialization Functions and parameters 34 * ------------------------------------------------------------------ 35 */ 36 var $cms; 37 var $config; 38 var $curlang; 39 var $langhash; 40 var $params; 41 var $wysiwygactive; 42 var $error; 43 var $modinstall; 44 var $modtemplates; 45 var $modlang; 46 var $modform; 47 var $modredirect; 48 var $modmisc; 49 var $xml_exclude_files = array('^\.svn' , '^CVS$' , '^\#.*\#$' , '~$', '\.bak$' ); 50 var $xmldtd = ' 51 <!DOCTYPE module [ 52 <!ELEMENT module (dtdversion,name,version,description*,help*,about*,requires*,file+)> 53 <!ELEMENT dtdversion (#PCDATA)> 54 <!ELEMENT name (#PCDATA)> 55 <!ELEMENT version (#PCDATA)> 56 <!ELEMENT mincmsversion (#PCDATA)> 57 <!ELEMENT description (#PCDATA)> 58 <!ELEMENT help (#PCDATA)> 59 <!ELEMENT about (#PCDATA)> 60 <!ELEMENT requires (requiredname,requiredversion)> 61 <!ELEMENT requiredname (#PCDATA)> 62 <!ELEMENT requiredversion (#PCDATA)> 63 <!ELEMENT file (filename,isdir,data)> 64 <!ELEMENT filename (#PCDATA)> 65 <!ELEMENT isdir (#PCDATA)> 66 <!ELEMENT data (#PCDATA)> 67 ]>'; 68 var $smarty; 69 70 function CMSModule() 71 { 72 global $gCms; 73 74 $this->cms =& $gCms; 75 $this->config =& $gCms->GetConfig(); 76 77 global $CMS_ADMIN_PAGE; 78 if (isset($CMS_ADMIN_PAGE)) 79 { 80 $this->curlang = ''; 81 } 82 else 83 { 84 $this->curlang = get_site_preference('frontendlang',''); 85 if (isset($config['locale']) && $config['locale'] != '') { 86 $this->curlang = $config['locale']; 87 } 88 if( $this->curlang == '' ) { 89 $this->curlang = 'en_US'; 90 } 91 } 92 $this->langhash = array(); 93 $this->params = array(); 94 $this->wysiwygactive = false; 95 $this->error = ''; 96 97 $this->params[] = array( 98 'name' => 'lang', 99 'default' => 'en_US', 100 'help' => lang('langparam'), 101 'optional' => true); 102 103 #$smarty = new CMSModuleSmarty($config, $this->GetName()); 104 $this->smarty = &$gCms->GetSmarty(); 105 106 $this->SetParameters(); 107 108 $this->modinstall = false; 109 $this->modtemplates = false; 110 $this->modlang = false; 111 $this->modform = false; 112 $this->modredirect = false; 113 $this->modmisc = false; 114 } 115 116 function LoadTemplateMethods() 117 { 118 if (!$this->modtemplates) 119 { 120 require_once(cms_join_path(dirname(__FILE__), 'module_support', 'modtemplates.inc.php')); 121 $this->modtemplates = true; 122 } 123 } 124 125 function LoadLangMethods() 126 { 127 if (!$this->modlang) 128 { 129 require_once(cms_join_path(dirname(__FILE__), 'module_support', 'modlang.inc.php')); 130 $this->modlang = true; 131 } 132 } 133 134 function LoadFormMethods() 135 { 136 if (!$this->modform) 137 { 138 require_once(cms_join_path(dirname(__FILE__), 'module_support', 'modform.inc.php')); 139 $this->modform = true; 140 } 141 } 142 143 function LoadRedirectMethods() 144 { 145 if (!$this->modredirect) 146 { 147 require_once(cms_join_path(dirname(__FILE__), 'module_support', 'modredirect.inc.php')); 148 $this->modredirect = true; 149 } 150 } 151 152 function LoadMiscMethods() 153 { 154 if (!$this->modmisc) 155 { 156 require_once(cms_join_path(dirname(__FILE__), 'module_support', 'modmisc.inc.php')); 157 $this->modmisc = true; 158 } 159 } 160 161 /** 162 * ------------------------------------------------------------------ 163 * Basic Functions. Name and Version MUST be overridden. 164 * ------------------------------------------------------------------ 165 */ 166 167 /** 168 * Returns a sufficient about page for a module 169 */ 170 function GetAbout() 171 { 172 $this->LoadMiscMethods(); 173 return cms_module_GetAbout($this); 174 } 175 176 /** 177 * Returns a sufficient help page for a module 178 * this function should not be overridden 179 */ 180 function GetHelpPage() 181 { 182 $this->LoadMiscMethods(); 183 return cms_module_GetHelpPage($this); 184 } 185 186 /** 187 * Returns the name of the module 188 */ 189 function GetName() 190 { 191 return 'unset'; 192 } 193 194 /** 195 * Returns the full path of the module directory. 196 */ 197 function GetModulePath() 198 { 199 if (is_subclass_of($this, 'CMSModule')) 200 { 201 return cms_join_path($this->config['root_path'], 'modules' , $this->GetName()); 202 } 203 else 204 { 205 return dirname(__FILE__); 206 } 207 } 208 209 /** 210 * Returns a translatable name of the module. For modulues who's names can 211 * probably be translated into another language (like News) 212 */ 213 function GetFriendlyName() 214 { 215 return $this->GetName(); 216 } 217 218 /** 219 * Returns the version of the module 220 */ 221 function GetVersion() 222 { 223 return '0.0.0.1'; 224 } 225 226 /** 227 * Returns the minimum version necessary to run this version of the module. 228 */ 229 function MinimumCMSVersion() 230 { 231 global $CMS_VERSION; 232 return $CMS_VERSION; 233 } 234 235 /** 236 * Returns the maximum version necessary to run this version of the module. 237 */ 238 function MaximumCMSVersion() 239 { 240 global $CMS_VERSION; 241 return $CMS_VERSION; 242 } 243 244 /** 245 * Returns the help for the module 246 * 247 * @param string Optional language that the admin is using. If that language 248 * is not defined, use en_US. 249 */ 250 function GetHelp($lang = 'en_US') 251 { 252 return ''; 253 } 254 255 /** 256 * Returns XHTML that nees to go between the <head> tags 257 */ 258 function GetHeaderHTML() 259 { 260 return ''; 261 } 262 263 /** 264 * Use this method to prevent the admin interface from outputting header, footer, 265 * theme, etc, so your module can output files directly to the administrator. 266 * Do this by returning true. 267 * 268 */ 269 function SuppressAdminOutput(&$request) 270 { 271 return false; 272 } 273 274 /** 275 * Register a route to use for pretty url parsing 276 * 277 * @param string Route to register 278 * @param array Defaults for parameters that might not be included in the url 279 */ 280 function RegisterRoute($routeregex, $defaults = array()) 281 { 282 global $gCms; 283 $route =& new CmsRoute(); 284 $route->module = $this->GetName(); 285 $route->defaults = $defaults; 286 $route->regex = $routeregex; 287 $routes =& $gCms->variables['routes']; 288 $routes[] =& $route; 289 } 290 291 /** 292 * Returns a list of parameters and their help strings in a hash. This is generally 293 * used internally. 294 */ 295 function GetParameters() 296 { 297 return $this->params; 298 } 299 300 /** 301 * Setup your parameters here. It doesn't have to be here, but it makes the 302 * code more legible. 303 */ 304 function SetParameters() 305 { 306 } 307 308 function CreateParameter($param, $defaultval='', $helpstring='', $optional=true) 309 { 310 array_unshift($this->params, array( 311 'name' => $param, 312 'default' => $defaultval, 313 'help' => $helpstring, 314 'optional' => $optional 315 )); 316 } 317 318 /** 319 * Returns a short description of the module 320 * 321 * @param string Optional language that the admin is using. If that language 322 * is not defined, use en_US. 323 */ 324 function GetDescription($lang = 'en_US') 325 { 326 return ''; 327 } 328 329 /** 330 * Returns a description of what the admin link does. 331 * 332 * @param string Optional language that the admin is using. If that language 333 * is not defined, use en_US. 334 */ 335 function GetAdminDescription($lang = 'en_US') 336 { 337 return ''; 338 } 339 340 /** 341 * Returns whether this module should only be loaded from the admin 342 */ 343 function IsAdminOnly() 344 { 345 return false; 346 } 347 348 /** 349 * Returns the changelog for the module 350 */ 351 function GetChangeLog() 352 { 353 return ''; 354 } 355 356 /** 357 * Returns the name of the author 358 */ 359 function GetAuthor() 360 { 361 return ''; 362 } 363 364 /** 365 * Returns the email address of the author 366 */ 367 function GetAuthorEmail() 368 { 369 return ''; 370 } 371 372 /** 373 * ------------------------------------------------------------------ 374 * Reference functions 375 * ------------------------------------------------------------------ 376 */ 377 378 /** 379 * Returns the cms->config object as a reference 380 */ 381 function & GetConfig() 382 { 383 global $gCms; 384 $config = &$gCms->GetConfig(); 385 return $config; 386 } 387 388 /** 389 * Returns the cms->db object as a reference 390 */ 391 function & GetDb() 392 { 393 global $gCms; 394 $db = &$gCms->GetDb(); 395 return $db; 396 } 397 398 /** 399 * Returns the cms->variables as a reference 400 */ 401 function & GetVariables() 402 { 403 return $this->cms->variables; 404 } 405 406 /** 407 * ------------------------------------------------------------------ 408 * Content Type Related Functions 409 * ------------------------------------------------------------------ 410 */ 411 412 /** 413 * Does this module support a custom content type? 414 */ 415 function HasContentType() 416 { 417 return FALSE; 418 } 419 420 function RegisterContentType($name, $file, $friendlyname = '') 421 { 422 global $gCms; 423 $contenttypes =& $gCms->contenttypes; 424 if (!isset($contenttypes[strtolower($name)])) 425 { 426 $obj =& new CmsContentTypePlaceholder(); 427 $obj->type = strtolower($name); 428 $obj->filename = $file; 429 $obj->loaded = false; 430 $obj->friendlyname = ($friendlyname != '' ? $friendlyname : $name); 431 $contenttypes[strtolower($name)] =& $obj; 432 } 433 } 434 435 /** 436 * Return an instance of the new content type 437 */ 438 function GetContentTypeInstance() 439 { 440 return FALSE; 441 } 442 443 function IsExclusive() 444 { 445 return FALSE; 446 } 447 448 /** 449 * ------------------------------------------------------------------ 450 * Installation Related Functions 451 * ------------------------------------------------------------------ 452 */ 453 454 /** 455 * Function that will get called as module is installed. This function should 456 * do any initialization functions including creating database tables. It 457 * should return a string message if there is a failure. Returning nothing (FALSE) 458 * will allow the install procedure to proceed. 459 */ 460 function Install() 461 { 462 $filename = dirname(dirname(dirname(__FILE__))) . '/modules/'.$this->GetName().'/method.install.php'; 463 if (@is_file($filename)) 464 { 465 { 466 global $gCms; 467 $db =& $gCms->GetDb(); 468 $config =& $gCms->GetConfig(); 469 $smarty =& $gCms->GetSmarty(); 470 471 include($filename); 472 } 473 } 474 else 475 { 476 return FALSE; 477 } 478 } 479 480 /** 481 * Display a message after a successful installation of the module. 482 */ 483 function InstallPostMessage() 484 { 485 return FALSE; 486 } 487 488 /** 489 * Function that will get called as module is uninstalled. This function should 490 * remove any database tables that it uses and perform any other cleanup duties. 491 * It should return a string message if there is a failure. Returning nothing 492 * (FALSE) will allow the uninstall procedure to proceed. 493 */ 494 function Uninstall() 495 { 496 $filename = dirname(dirname(dirname(__FILE__))) . '/modules/'.$this->GetName().'/method.uninstall.php'; 497 if (@is_file($filename)) 498 { 499 { 500 global $gCms; 501 $db =& $gCms->GetDb(); 502 $config =& $gCms->GetConfig(); 503 $smarty =& $gCms->GetSmarty(); 504 505 include($filename); 506 } 507 } 508 else 509 { 510 return FALSE; 511 } 512 } 513 514 /** 515 * Display a message and a Yes/No dialog before doing an uninstall. Returning noting 516 * (FALSE) will go right to the uninstall. 517 */ 518 function UninstallPreMessage() 519 { 520 return FALSE; 521 } 522 523 /** 524 * Display a message after a successful uninstall of the module. 525 */ 526 function UninstallPostMessage() 527 { 528 return FALSE; 529 } 530 531 /** 532 * Function to perform any upgrade procedures. This is mostly used to for 533 * updating databsae tables, but can do other duties as well. It should 534 * return a string message if there is a failure. Returning nothing (FALSE) 535 * will allow the upgrade procedure to proceed. Upgrades should have a path 536 * so that they can be upgraded from more than one version back. While not 537 * a requirement, it makes life easy for your users. 538 * 539 * @param string The version we are upgrading from 540 * @param string The version we are upgrading to 541 */ 542 function Upgrade($oldversion, $newversion) 543 { 544 $filename = dirname(dirname(dirname(__FILE__))) . '/modules/'.$this->GetName().'/method.upgrade.php'; 545 if (@is_file($filename)) 546 { 547 { 548 global $gCms; 549 $db =& $gCms->GetDb(); 550 $config =& $gCms->GetConfig(); 551 $smarty =& $gCms->GetSmarty(); 552 553 include($filename); 554 } 555 } 556 } 557 558 /** 559 * Returns whether or not modules should be autoupgraded while upgrading 560 * CMS versions. Generally only useful for modules included with the CMS 561 * base install, but there could be a situation down the road where we have 562 * different distributions with different modules included in them. Defaults 563 * to TRUE, as there is not many reasons to not allow it. 564 */ 565 function AllowAutoInstall() 566 { 567 return TRUE; 568 } 569 570 /** 571 * Returns whether or not modules should be autoupgraded while upgrading 572 * CMS versions. Generally only useful for modules included with the CMS 573 * base install, but there could be a situation down the road where we have 574 * different distributions with different modules included in them. Defaults 575 * to TRUE, as there is not many reasons to not allow it. 576 */ 577 function AllowAutoUpgrade() 578 { 579 return TRUE; 580 } 581 582 /** 583 * Returns a list of dependencies and minimum versions that this module 584 * requires. It should return an hash, eg. 585 * return array('somemodule'=>'1.0', 'othermodule'=>'1.1'); 586 */ 587 function GetDependencies() 588 { 589 return array(); 590 } 591 592 /** 593 * Checks to see if currently installed modules depend on this module. This is 594 * used by the plugins.php page to make sure that a module can't be uninstalled 595 * before any modules depending on it are uninstalled first. 596 */ 597 function CheckForDependents() 598 { 599 global $gCms; 600 $db =& $gCms->GetDb(); 601 602 $result = false; 603 604 $query = "SELECT * FROM ".cms_db_prefix()."module_deps WHERE parent_module = ?"; 605 $dbresult = $db->Execute($query, array($this->GetName())); 606 607 if ($dbresult && $dbresult->RecordCount() > 0) 608 { 609 $result = true; 610 } 611 612 return $result; 613 } 614 615 616 /** 617 * Creates an xml data package from the module directory. 618 */ 619 function CreateXMLPackage( &$message, &$filecount ) 620 { 621 global $gCms; 622 $modops =& $gCms->GetModuleOperations(); 623 return $modops->CreateXmlPackage($this, $message, $filecount); 624 } 625 626 627 /** 628 * Return true if there is an admin for the module. Returns false by 629 * default. 630 */ 631 function HasAdmin() 632 { 633 return false; 634 } 635 636 /** 637 * Should we use output buffering in the admin for this module? 638 */ 639 function HasAdminBuffering() 640 { 641 return true; 642 } 643 644 /** 645 * Returns which admin section this module belongs to. 646 * this is used to place the module in the appropriate admin navigation 647 * section. Valid options are currently: 648 * 649 * content, layout, files, usersgroups, extensions, preferences, admin 650 * 651 */ 652 function GetAdminSection() 653 { 654 return 'extensions'; 655 } 656 657 /** 658 * Returns true or false, depending on whether the user has the 659 * right permissions to see the module in their Admin menus. 660 * 661 * Defaults to true. 662 */ 663 function VisibleToAdminUser() 664 { 665 return true; 666 } 667 668 /** 669 * Returns true if the module should be treated as a content module. 670 * Returns false by default. 671 */ 672 function IsContentModule() 673 { 674 return false; 675 } 676 677 /** 678 * Returns true if the module should be treated as a plugin module (like 679 * {cms_module module='name'}. Returns false by default. 680 */ 681 function IsPluginModule() 682 { 683 return false; 684 } 685 686 /** 687 * Returns true if the module acts as a soap server 688 */ 689 function IsSoapModule() 690 { 691 return false; 692 } 693 694 /** 695 * ------------------------------------------------------------------ 696 * Login Related Functions 697 * ------------------------------------------------------------------ 698 */ 699 700 /** 701 * Called after a successful login. It sends the user object. 702 * 703 * @param User The user that just logged in 704 */ 705 function LoginPost(&$user) 706 { 707 } 708 709 /** 710 * Called after a successful logout. 711 */ 712 function LogoutPost() 713 { 714 } 715 716 /** 717 * ------------------------------------------------------------------ 718 * User Related Functions 719 * ------------------------------------------------------------------ 720 */ 721 722 /** 723 * Called before a user is added to the database. Sends the user object. 724 * 725 * @param User The user that was just created 726 */ 727 function AddUserPre(&$user) 728 { 729 } 730 731 /** 732 * Called after a user is added to the database. Sends the user object. 733 * 734 * @param User The user that was just created 735 */ 736 function AddUserPost(&$user) 737 { 738 } 739 740 /** 741 * Called before a user is saved to the database. Sends the user object. 742 * 743 * @param User The user that was just edited 744 */ 745 function EditUserPre(&$user) 746 { 747 } 748 749 /** 750 * Called after a user is saved to the database. Sends the user object. 751 * 752 * @param User The user that was just edited 753 */ 754 function EditUserPost(&$user) 755 { 756 } 757 758 /** 759 * Called before a user is deleted from the database. Sends the user object. 760 * 761 * @param User The user that was just deleted 762 */ 763 function DeleteUserPre(&$user) 764 { 765 } 766 767 /** 768 * Called after a user is deleted from the database. Sends the user object. 769 * 770 * @param User The user that was just deleted 771 */ 772 function DeleteUserPost(&$user) 773 { 774 } 775 776 /** 777 * ------------------------------------------------------------------ 778 * Group Related Functions 779 * ------------------------------------------------------------------ 780 */ 781 782 /** 783 * Called before a group is added to the database. Sends the group object. 784 * 785 * @param Group The group that was just created 786 */ 787 function AddGroupPre(&$group) 788 { 789 } 790 791 /** 792 * Called after a group is added to the database. Sends the group object. 793 * 794 * @param Group The group that was just created 795 */ 796 function AddGroupPost(&$group) 797 { 798 } 799 800 /** 801 * Called before a group is saved to the database. Sends the group object. 802 * 803 * @param Group The group that was just edited 804 */ 805 function EditGroupPre(&$group) 806 { 807 } 808 809 /** 810 * Called after a group is saved to the database. Sends the group object. 811 * 812 * @param Group The group that was just edited 813 */ 814 function EditGroupPost(&$group) 815 { 816 } 817 818 /** 819 * Called before a group is deleted from the database. Sends the group object. 820 * 821 * @param Group The group that was just deleted 822 */ 823 function DeleteGroupPre(&$group) 824 { 825 } 826 827 /** 828 * Called after a group is deleted from the database. Sends the group object. 829 * 830 * @param Group The group that was just deleted 831 */ 832 function DeleteGroupPost(&$group) 833 { 834 } 835 836 /** 837 * ------------------------------------------------------------------ 838 * Template Related Functions 839 * ------------------------------------------------------------------ 840 */ 841 842 /** 843 * Called before a template is added to the database. Sends the template 844 * object. 845 * 846 * @param Template The template that was just created 847 */ 848 function AddTemplatePre(&$template) 849 { 850 } 851 852 /** 853 * Called after a template is added to the database. Sends the template 854 * object. 855 * 856 * @param Template The template that was just created 857 */ 858 function AddTemplatePost(&$template) 859 { 860 } 861 862 /** 863 * Called before a template is saved to the database. Sends the template 864 * object. 865 * 866 * @param Template The template that was just edited 867 */ 868 function EditTemplatePre(&$template) 869 { 870 } 871 872 /** 873 * Called after a template is saved to the database. Sends the template 874 * object. 875 * 876 * @param Template The template that was just edited 877 */ 878 function EditTemplatePost(&$template) 879 { 880 } 881 882 /** 883 * Called before a template is deleted from the database. Sends the template 884 * object. 885 * 886 * @param Template The template that was just deleted 887 */ 888 function DeleteTemplatePre(&$template) 889 { 890 } 891 892 /** 893 * Called after a template is deleted from the database. Sends the template 894 * object. 895 * 896 * @param Template The template that was just deleted 897 */ 898 function DeleteTemplatePost(&$template) 899 { 900 } 901 902 function TemplatePreCompile(&$template) 903 { 904 } 905 906 function TemplatePostCompile(&$template) 907 { 908 } 909 910 /** 911 * ------------------------------------------------------------------ 912 * General Content Related Functions 913 * ------------------------------------------------------------------ 914 */ 915 916 function ContentEditPre(&$content) 917 { 918 } 919 920 function ContentEditPost(&$content) 921 { 922 } 923 924 function ContentDeletePre(&$content) 925 { 926 } 927 928 function ContentDeletePost(&$content) 929 { 930 } 931 932 /** 933 * ------------------------------------------------------------------ 934 * Stylesheet Related Functions 935 * ------------------------------------------------------------------ 936 */ 937 938 /** 939 * Called before a Stylesheet is added to the database. Sends the stylesheet 940 * object. 941 * 942 * @param Stylesheet The stylesheet that was just created 943 */ 944 function AddStylesheetPre(&$stylesheet) 945 { 946 } 947 948 /** 949 * Called after a stylesheet is added to the database. Sends the stylesheet 950 * object. 951 * 952 * @param Stylesheet The stylesheet that was just created 953 */ 954 function AddStylesheetPost(&$stylesheet) 955 { 956 } 957 958 /** 959 * Called before a stylesheet is saved to the database. Sends the stylesheet 960 * object. 961 * 962 * @param stylesheet The stylesheet that was just edited 963 */ 964 function EditStylesheetPre(&$stylesheet) 965 { 966 } 967 968 /** 969 * Called after a stylesheet is saved to the database. Sends the stylesheet 970 * object. 971 * 972 * @param stylesheet The stylesheet that was just edited 973 */ 974 function EditStylesheetPost(&$stylesheet) 975 { 976 } 977 978 /** 979 * Called before a stylesheet is deleted from the database. Sends the stylesheet 980 * object. 981 * 982 * @param stylesheet The stylesheet that was just deleted 983 */ 984 function DeleteStylesheetPre(&$stylesheet) 985 { 986 } 987 988 /** 989 * Called after a stylesheet is deleted from the database. Sends the stylesheet 990 * object. 991 * 992 * @param stylesheet The stylesheet that was just deleted 993 */ 994 function DeleteStylesheetPost(&$stylesheet) 995 { 996 } 997 998 /** 999 * ------------------------------------------------------------------ 1000 * HTML Blob Related Functions 1001 * ------------------------------------------------------------------ 1002 */ 1003 1004 /** 1005 * Called before an HTML blob is added to the database. Sends the html blob 1006 * object. 1007 * 1008 * @param HtmlBlob The HTML blob that was just created 1009 */ 1010 function AddHtmlBlobPre(&$htmlblob) 1011 { 1012 } 1013 1014 /** 1015 * Called after an HTML blob is added to the database. Sends the html blob 1016 * object. 1017 * 1018 * @param HtmlBlob The HTML blob that was just created 1019 */ 1020 function AddHtmlBlobPost(&$htmlblob) 1021 { 1022 } 1023 1024 /** 1025 * Called before an HTML blob is saved to the database. Sends the html blob 1026 * object. 1027 * 1028 * @param HtmlBlob The HTML blob that was just edited 1029 */ 1030 function EditHtmlBlobPre(&$htmlblob) 1031 { 1032 } 1033 1034 /** 1035 * Called after an HTML blob is saved to the database. Sends the html blob 1036 * object. 1037 * 1038 * @param HtmlBlob The HTML blob that was just edited 1039 */ 1040 function EditHtmlBlobPost(&$htmlblob) 1041 { 1042 } 1043 1044 /** 1045 * Called before an HTML blob is deleted from the database. Sends the html 1046 * blob object. 1047 * 1048 * @param HtmlBlob The HTML blob that was just deleted 1049 */ 1050 function DeleteHtmlBlobPre(&$htmlblob) 1051 { 1052 } 1053 1054 /** 1055 * Called after an HTML blob is deleted from the database. Sends the html 1056 * blob object. 1057 * 1058 * @param HtmlBlob The HTML blob that was just deleted 1059 */ 1060 function DeleteHtmlBlobPost(&$htmlblob) 1061 { 1062 } 1063 1064 function GlobalContentPreCompile(&$gc) 1065 { 1066 } 1067 1068 function GlobalContentPostCompile(&$gc) 1069 { 1070 } 1071 1072 1073 /** 1074 * ------------------------------------------------------------------ 1075 * Content Related Functions 1076 * ------------------------------------------------------------------ 1077 */ 1078 1079 /** 1080 * Called with the content of the template before it's sent to smarty 1081 * for processing. 1082 * 1083 * Deprecated: This isn't called anymore. 1084 * 1085 * @param string The template text 1086 */ 1087 function ContentTemplate(&$template) 1088 { 1089 } 1090 1091 /** 1092 * Called with the content of the stylesheet before it is pasted into the 1093 * template. 1094 * 1095 * @param string The stylesheet text 1096 */ 1097 function ContentStylesheet(&$stylesheet) 1098 { 1099 } 1100 1101 /** 1102 * Called with the title before it is pasted into the template. 1103 * 1104 * Deprecated: This isn't called anymore. 1105 * 1106 * @param string The title text 1107 */ 1108 function ContentTitle(&$title) 1109 { 1110 } 1111 1112 /** 1113 * Called with the content data before it is pasted into the template. 1114 * 1115 * Deprecated: This isn't called anymore. Use ContentPreCompile. 1116 * 1117 * @param string The content text 1118 */ 1119 function ContentData(&$content) 1120 { 1121 } 1122 1123 /** 1124 * Called with the content of the html blob before it is pasted into the 1125 * template (but after content is pasted in) 1126 * 1127 * Deprecated: This isn't called anymore. Use GlobalContentPreCompile. 1128 * 1129 * @param string The html blob text 1130 */ 1131 function ContentHtmlBlob(&$htmlblob) 1132 { 1133 } 1134 1135 /** 1136 * Called before the pasted together template/content/html blobs/etc are 1137 * sent to smarty for processing. 1138 * 1139 * Deprecated: Not useful anymore, since it's all handled separately now 1140 * 1141 * @param string The prerendered text 1142 */ 1143 function ContentPreRender(&$content) 1144 { 1145 } 1146 1147 /** 1148 * Called before the content is sent off to smarty for processing. Basically 1149 * overlaps with ContentPreRender, but it makes more sense to be named 1150 * PreCompile. 1151 * 1152 * @param string The precompiled text 1153 */ 1154 function ContentPreCompile(&$content) 1155 { 1156 } 1157 1158 /** 1159 * Called right after smarty is done processing and ready to head off to the 1160 * cache. Does the same as PostRenderNonCached, but with a better name. 1161 * 1162 * @param string The postcompiled text 1163 */ 1164 function ContentPostCompile(&$content) 1165 { 1166 } 1167 1168 /** 1169 * This serves no purpose anymore. Template, content and html blobs are 1170 * never pushed together at any point and cached. 1171 * 1172 * Deprecated 1173 * 1174 * @param string The postrendered text 1175 */ 1176 function ContentPostRenderNonCached(&$content) 1177 { 1178 } 1179 1180 /** 1181 * Called after content is sent to smarty for processing and right before 1182 * display. Cached content will still call this function before display, 1183 * but it is called EVERY time a page is requested. 1184 * 1185 * @param string The postrendered text 1186 */ 1187 function ContentPostRender(&$content) 1188 { 1189 } 1190 1191 /** 1192 * Called before any smarty "template" (content blocks/content tempaltes/modules) 1193 * gets pushed off for compilation. 1194 * (new in 0.12) 1195 * 1196 * @param string The precompiled text 1197 */ 1198 function SmartyPreCompile(&$content) 1199 { 1200 } 1201 1202 /** 1203 * Called after any smarty "template" (content blocks/content tempaltes/modules) 1204 * is done being compiled by smarty, but before caching. 1205 * (new in 0.12) 1206 * 1207 * @param string The precompiled text 1208 */ 1209 function SmartyPostCompile(&$content) 1210 { 1211 } 1212 1213 /** 1214 * ------------------------------------------------------------------ 1215 * WYSIWYG Related Functions 1216 * ------------------------------------------------------------------ 1217 */ 1218 1219 /** 1220 * Returns true if this module should be treated as a WYSIWYG module. It 1221 * returns false be default. 1222 */ 1223 function IsWYSIWYG() 1224 { 1225 return false; 1226 } 1227 1228 /** 1229 * Returns true if this wysiwyg should be considered active, eventhough it's 1230 * not the choice of the user. Used for forcing a wysiwyg. 1231 * returns false be default. 1232 */ 1233 function WYSIWYGActive() 1234 { 1235 return $this->wysiwygactive; 1236 } 1237 1238 /** 1239 * Returns content destined for the <form> tag. It's useful if javascript is 1240 * needed for the onsubmit of the form. 1241 */ 1242 function WYSIWYGPageForm() 1243 { 1244 return ''; 1245 } 1246 1247 /** 1248 * This is a function that would be called before a form is submitted. 1249 * Generally, a dropdown box or something similar that would force a submit 1250 * of the form via javascript should put this in their onchange line as well 1251 * so that the WYSIWYG can do any cleanups before the actual form submission 1252 * takes place. 1253 */ 1254 function WYSIWYGPageFormSubmit() 1255 { 1256 return ''; 1257 } 1258 1259 /** 1260 * Returns header code specific to this WYSIWYG 1261 * 1262 * @param string The html-code of the page before replacing WYSIWYG-stuff 1263 */ 1264 function WYSIWYGGenerateHeader($htmlresult='') 1265 { 1266 return ''; 1267 } 1268 1269 /** 1270 * Returns body code specific to this WYSIWYG 1271 */ 1272 function WYSIWYGGenerateBody() 1273 { 1274 return ''; 1275 } 1276 1277 /** 1278 * Returns the textarea specific for this WYSIWYG. 1279 * 1280 * @param string HTML name of the textarea 1281 * @param int Number of columns wide that the textarea should be 1282 * @param int Number of rows long that the textarea should be 1283 * @param string Encoding of the content 1284 * @param string Content to show in the textarea 1285 * @param string Stylesheet for content, if available 1286 */ 1287 function WYSIWYGTextarea($name='textarea',$columns='80',$rows='15',$encoding='',$content='',$stylesheet='') 1288 { 1289 $this->wysiwygactive=true; 1290 return '<textarea name="'.$name.'" cols="'.$columns.'" rows="'.$rows.'">'.$content.'</textarea>'; 1291 } 1292 1293 /** 1294 * Returns whether or not this module should show in any module lists generated by a WYSIWYG. 1295 */ 1296 function ShowInWYSIWYG() 1297 { 1298 return true; 1299 } 1300 1301 /** 1302 * ------------------------------------------------------------------ 1303 * Navigation Related Functions 1304 * ------------------------------------------------------------------ 1305 */ 1306 1307 /** 1308 * Used for navigation between "pages" of a module. Forms and links should 1309 * pass an action with them so that the module will know what to do next. 1310 * By default, DoAction will be passed 'default' and 'defaultadmin', 1311 * depending on where the module was called from. If being used as a module 1312 * or content type, 'default' will be passed. If the module was selected 1313 * from the list on the admin menu, then 'defaultadmin' will be passed. 1314 * 1315 * @param string Name of the action to perform 1316 * @param string The ID of the module 1317 * @param string The parameters targeted for this module 1318 */ 1319 function DoAction($name, $id, $params, $returnid='') 1320 { 1321 if ($name != '') 1322 { 1323 $filename = dirname(dirname(dirname(__FILE__))) . '/modules/'.$this->GetName().'/action.' . $name . '.php'; 1324 if (@is_file($filename)) 1325 { 1326 { 1327 global $gCms; 1328 $db =& $gCms->GetDb(); 1329 $config =& $gCms->GetConfig(); 1330 $smarty =& $gCms->GetSmarty(); 1331 1332 include($filename); 1333 1334 } 1335 } 1336 } 1337 } 1338 1339 function DoActionBase($name, $id, $params, $returnid='') 1340 { 1341 if (isset($params['lang'])) 1342 { 1343 $this->curlang = $params['lang']; 1344 #clear langhash so that new language can be loaded 1345 $this->langhash = array(); 1346 } 1347 if( !isset($params['action']) ) 1348 { 1349 $params['action'] = $name; 1350 } 1351 return $this->DoAction($name, $id, $params, $returnid); 1352 } 1353 1354 1355 /** 1356 * Returns the xhtml equivalent of an fieldset and legend. This is basically a nice little wrapper 1357 * to make sure that id's are placed in names and also that it's xhtml compliant. 1358 * 1359 * @param string The id given to the module on execution (not really used yet, but might be later) 1360 * @param string The html name of the textbox (not really used yet, but might be later on) 1361 * @param string The legend_text for this fieldset, if applicaple 1362 * @param string Any additional text that should be added into the tag when rendered 1363 * @param string Any additional text that should be added into the legend tag when rendered 1364 */ 1365 function CreateFieldsetStart( $id, $name, $legend_text='', $addtext='', $addtext_legend='' ) 1366 { 1367 $this->LoadFormMethods(); 1368 return cms_module_CreateFieldsetStart($this, $id, $name, $legend_text, $addtext, $addtext_legend); 1369 } 1370 1371 /** 1372 * Returns the end of the fieldset in a form. This is basically just a wrapper around </form>, but 1373 * could be extended later on down the road. It's here mainly for consistency. 1374 */ 1375 function CreateFieldsetEnd() 1376 { 1377 return '</fieldset>'."\n"; 1378 } 1379 1380 1381 /** 1382 * Returns the start of a module form, optimized for frontend use 1383 * 1384 * @param string The id given to the module on execution 1385 * @param string The id to eventually return to when the module is finished it's task 1386 * @param string The action that this form should do when the form is submitted 1387 * @param string Method to use for the form tag. Defaults to 'post' 1388 * @param string Optional enctype to use, Good for situations where files are being uploaded 1389 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend) 1390 * @param string Text to append to the end of the id and name of the form 1391 * @param array Extra parameters to pass along when the form is submitted 1392 */ 1393 function CreateFrontendFormStart($id,$returnid,$action='default',$method='post', 1394 $enctype='',$inline=true,$idsuffix='',$params=array()) 1395 { 1396 return $this->CreateFormStart($id,$action,$returnid,$method,$enctype,$inline,$idsuffix,$params); 1397 } 1398 1399 1400 /** 1401 * Returns the start of a module form 1402 * 1403 * @param string The id given to the module on execution 1404 * @param string The action that this form should do when the form is submitted 1405 * @param string The id to eventually return to when the module is finished it's task 1406 * @param string Method to use for the form tag. Defaults to 'post' 1407 * @param string Optional enctype to use, Good for situations where files are being uploaded 1408 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend) 1409 * @param string Text to append to the end of the id and name of the form 1410 * @param array Extra parameters to pass along when the form is submitted 1411 * @param string Text to append to the <form>-statement, for instanse for javascript-validation code 1412 */ 1413 function CreateFormStart($id, $action='default', $returnid='', $method='post', $enctype='', $inline=false, $idsuffix='', $params = array(), $extra='') 1414 { 1415 $this->LoadFormMethods(); 1416 return cms_module_CreateFormStart($this, $id, $action, $returnid, $method, $enctype, $inline, $idsuffix, $params, $extra); 1417 } 1418 1419 /** 1420 * Returns the end of the a module form. This is basically just a wrapper around </form>, but 1421 * could be extended later on down the road. It's here mainly for consistency. 1422 */ 1423 function CreateFormEnd() 1424 { 1425 return '</form>'."\n"; 1426 } 1427 1428 /** 1429 * Returns the xhtml equivalent of an input textbox. This is basically a nice little wrapper 1430 * to make sure that id's are placed in names and also that it's xhtml compliant. 1431 * 1432 * @param string The id given to the module on execution 1433 * @param string The html name of the textbox 1434 * @param string The predefined value of the textbox, if any 1435 * @param string The number of columns wide the textbox should be displayed 1436 * @param string The maximum number of characters that should be allowed to be entered 1437 * @param string Any additional text that should be added into the tag when rendered 1438 */ 1439 function CreateInputText($id, $name, $value='', $size='10', $maxlength='255', $addttext='') 1440 { 1441 $this->LoadFormMethods(); 1442 return cms_module_CreateInputText($this, $id, $name, $value, $size, $maxlength, $addttext); 1443 } 1444 1445 /** 1446 * Returns the xhtml equivalent of an label for input field. This is basically a nice little wrapper 1447 * to make sure that id's are placed in names and also that it's xhtml compliant. 1448 * 1449 * @param string The id given to the module on execution 1450 * @param string The html name of the input field this label is associated to 1451 * @param string The text in the label 1452 * @param string Any additional text that should be added into the tag when rendered 1453 */ 1454 function CreateLabelForInput($id, $name, $labeltext='', $addttext='') 1455 { 1456 $this->LoadFormMethods(); 1457 return cms_module_CreateLabelForInput($this, $id, $name, $labeltext, $addttext); 1458 } 1459 1460 /** 1461 * Returns the xhtml equivalent of an input textbox with label. This is basically a nice little wrapper 1462 * to make sure that id's are placed in names and also that it's xhtml compliant. 1463 * 1464 * @param string The id given to the module on execution 1465 * @param string The html name of the textbox 1466 * @param string The predefined value of the textbox, if any 1467 * @param string The number of columns wide the textbox should be displayed 1468 * @param string The maximum number of characters that should be allowed to be entered 1469 * @param string Any additional text that should be added into the tag when rendered 1470 * @param string The text for label 1471 * @param string Any additional text that should be added into the tag when rendered 1472 */ 1473 function CreateInputTextWithLabel($id, $name, $value='', $size='10', $maxlength='255', $addttext='', $label='', $labeladdtext='') 1474 { 1475 $this->LoadFormMethods(); 1476 return cms_module_CreateInputTextWithLabel($this, $id, $name, $value, $size, $maxlength, $addttext, $label, $labeladdtext); 1477 } 1478 1479 /** 1480 * Returns the xhtml equivalent of a file-selector field. This is basically a nice little wrapper 1481 * to make sure that id's are placed in names and also that it's xhtml compliant. 1482 * 1483 * @param string The id given to the module on execution 1484 * @param string The html name of the textbox 1485 * @param string The MIME-type to be accepted, default is all 1486 * @param string The number of columns wide the textbox should be displayed 1487 * @param string Any additional text that should be added into the tag when rendered 1488 */ 1489 function CreateInputFile($id, $name, $accept='', $size='10',$addttext='') 1490 { 1491 $this->LoadFormMethods(); 1492 return cms_module_CreateInputFile($this, $id, $name, $accept, $size, $addttext); 1493 } 1494 1495 /** 1496 * Returns the xhtml equivalent of an input password-box. This is basically a nice little wrapper 1497 * to make sure that id's are placed in names and also that it's xhtml compliant. 1498 * 1499 * @param string The id given to the module on execution 1500 * @param string The html name of the textbox 1501 * @param string The predefined value of the textbox, if any 1502 * @param string The number of columns wide the textbox should be displayed 1503 * @param string The maximum number of characters that should be allowed to be entered 1504 * @param string Any additional text that should be added into the tag when rendered 1505 */ 1506 function CreateInputPassword($id, $name, $value='', $size='10', $maxlength='255', $addttext='') 1507 { 1508 $this->LoadFormMethods(); 1509 return cms_module_CreateInputPassword($this, $id, $name, $value, $size, $maxlength, $addttext); 1510 } 1511 1512 /** 1513 * Returns the xhtml equivalent of a hidden field. This is basically a nice little wrapper 1514 * to make sure that id's are placed in names and also that it's xhtml compliant. 1515 * 1516 * @param string The id given to the module on execution 1517 * @param string The html name of the hidden field 1518 * @param string The predefined value of the field, if any 1519 * @param string Any additional text that should be added into the tag when rendered 1520 */ 1521 function CreateInputHidden($id, $name, $value='', $addttext='') 1522 { 1523 $this->LoadFormMethods(); 1524 return cms_module_CreateInputHidden($this, $id, $name, $value, $addttext); 1525 } 1526 1527 /** 1528 * Returns the xhtml equivalent of a checkbox. This is basically a nice little wrapper 1529 * to make sure that id's are placed in names and also that it's xhtml compliant. 1530 * 1531 * @param string The id given to the module on execution 1532 * @param string The html name of the checkbox 1533 * @param string The predefined value of the field, if any 1534 * @param string Any additional text that should be added into the tag when rendered 1535 */ 1536 function CreateInputCheckbox($id, $name, $value='', $selectedvalue='', $addttext='') 1537 { 1538 $this->LoadFormMethods(); 1539 return cms_module_CreateInputCheckbox($this, $id, $name, $value, $selectedvalue, $addttext); 1540 } 1541 1542 1543 /** 1544 * Returns the xhtml equivalent of a submit button. This is basically a nice little wrapper 1545 * to make sure that id's are placed in names and also that it's xhtml compliant. 1546 * 1547 * @param string The id given to the module on execution 1548 * @param string The html name of the button 1549 * @param string The predefined value of the button, if any 1550 * @param string Any additional text that should be added into the tag when rendered 1551 * @param string Use an image instead of a regular button 1552 */ 1553 function CreateInputSubmit($id, $name, $value='', $addttext='', $image='', $confirmtext='') 1554 { 1555 $this->LoadFormMethods(); 1556 return cms_module_CreateInputSubmit($this, $id, $name, $value, $addttext, $image, $confirmtext); 1557 } 1558 1559 /** 1560 * Returns the xhtml equivalent of a reset button. This is basically a nice little wrapper 1561 * to make sure that id's are placed in names and also that it's xhtml compliant. 1562 * 1563 * @param string The id given to the module on execution 1564 * @param string The html name of the button 1565 * @param string The predefined value of the button, if any 1566 * @param string Any additional text that should be added into the tag when rendered 1567 */ 1568 function CreateInputReset($id, $name, $value='Reset', $addttext='') 1569 { 1570 $this->LoadFormMethods(); 1571 return cms_module_CreateInputReset($this, $id, $name, $value, $addttext); 1572 } 1573 1574 /** 1575 * Returns the xhtml equivalent of a file upload input. This is basically a nice little wrapper 1576 * to make sure that id's are placed in names and also that it's xhtml compliant. 1577 * 1578 * @param string The id given to the module on execution 1579 * @param string The html name of the input 1580 * @param string Any additional text that should be added into the tag when rendered 1581 */ 1582 function CreateFileUploadInput($id, $name, $addttext='') 1583 { 1584 $this->LoadFormMethods(); 1585 return cms_module_CreateFileUploadInput($this, $id, $name, $addttext); 1586 } 1587 1588 1589 /** 1590 * Returns the xhtml equivalent of a dropdown list. This is basically a nice little wrapper 1591 * to make sure that id's are placed in names and also that it is xhtml compliant. 1592 * 1593 * @param string The id given to the module on execution 1594 * @param string The html name of the dropdown list 1595 * @param string An array of items to put into the dropdown list... they should be $key=>$value pairs 1596 * @param string The default selected index of the dropdown list. Setting to -1 will result in the first choice being selected 1597 * @param string The default selected value of the dropdown list. Setting to '' will result in the first choice being selected 1598 * @param string Any additional text that should be added into the tag when rendered 1599 */ 1600 function CreateInputDropdown($id, $name, $items, $selectedindex=-1, $selectedvalue='', $addttext='') 1601 { 1602 $this->LoadFormMethods(); 1603 return cms_module_CreateInputDropdown($this, $id, $name, $items, $selectedindex, $selectedvalue, $addttext); 1604 } 1605 1606 /** 1607 * Returns the xhtml equivalent of a multi-select list. This is basically a nice little wrapper 1608 * to make sure that id's are placed in names and also that it is xhtml compliant. 1609 * 1610 * @param string The id given to the module on execution 1611 * @param string The html name of the select list 1612 * @param string An array of items to put into the list... they should be $key=>$value pairs 1613 * @param string An array of items in the list that should default to selected. 1614 * @param string The number of rows to be visible in the list (before scrolling). 1615 * @param string Any additional text that should be added into the tag when rendered 1616 * @param boolean indicates wether multiple selections are allowed (defaults to true) 1617 */ 1618 function CreateInputSelectList($id, $name, $items, $selecteditems=array(), $size=3, $addttext='', $multiple = true) 1619 { 1620 $this->LoadFormMethods(); 1621 return cms_module_CreateInputSelectList($this, $id, $name, $items, $selecteditems, $size, $addttext, $multiple); 1622 } 1623 1624 /** 1625 * Returns the xhtml equivalent of a set of radio buttons. This is basically a nice little wrapper 1626 * to make sure that id's are placed in names and also that it is xhtml compliant. 1627 * 1628 * @param string The id given to the module on execution 1629 * @param string The html name of the radio group 1630 * @param string An array of items to create as radio buttons... they should be $key=>$value pairs 1631 * @param string The default selected index of the radio group. Setting to -1 will result in the first choice being selected 1632 * @param string Any additional text that should be added into the tag when rendered 1633 * @param string A delimiter to throw between each radio button, e.g., a <br /> tag or something for formatting 1634 */ 1635 function CreateInputRadioGroup($id, $name, $items, $selectedvalue='', $addttext='', $delimiter='') 1636 { 1637 $this->LoadFormMethods(); 1638 return cms_module_CreateInputRadioGroup($this, $id, $name, $items, $selectedvalue, $addttext, $delimiter); 1639 } 1640 1641 /** 1642 * Returns the xhtml equivalent of a textarea. Also takes WYSIWYG preference into consideration if it's called from the admin side. 1643 * 1644 * @param bool Should we try to create a WYSIWYG for this textarea? 1645 * @param string The id given to the module on execution 1646 * @param string The text to display in the textarea's content 1647 * @param string The html name of the textarea 1648 * @param string The CSS class to associate this textarea to 1649 * @param string The html id to give to this textarea 1650 * @param string The encoding to use for the content 1651 * @param string The text of the stylesheet associated to this content. Only used for certain WYSIWYGs 1652 * @param string The number of characters wide (columns) the resulting textarea should be 1653 * @param string The number of characters high (rows) the resulting textarea should be 1654 * @param string The wysiwyg-system to be forced even if the user has chosen another one 1655 */ 1656 function CreateTextArea($enablewysiwyg, $id, $text, $name, $classname='', $htmlid='', $encoding='', $stylesheet='', $width='80', $cols='15',$forcewysiwyg="") 1657 { 1658 return create_textarea($enablewysiwyg, $text, $id.$name, $classname, $htmlid, $encoding, $stylesheet, $width, $cols,$forcewysiwyg); 1659 } 1660 1661 /** 1662 * Returns the xhtml equivalent of an href link This is basically a nice little wrapper 1663 * to make sure that id's are placed in names and also that it's xhtml compliant. 1664 * 1665 * @param string The id given to the module on execution 1666 * @param string The id to eventually return to when the module is finished it's task 1667 * @param string The action that this form should do when the link is clicked 1668 * @param string The text that will have to be clicked to follow the link 1669 * @param string An array of params that should be inlucded in the URL of the link. These should be in a $key=>$value format. 1670 * @param string Text to display in a javascript warning box. If they click no, the link is not followed by the browser. 1671 * @param boolean A flag to determine if only the href section should be returned 1672 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend) 1673 * @param string Any additional text that should be added into the tag when rendered 1674 */ 1675 function CreateFrontendLink( $id, $returnid, $action, $contents='', $params=array(), $warn_message='', 1676 $onlyhref=false, $inline=true, $addtext='', $targetcontentonly=false, $prettyurl='' ) 1677 { 1678 return $this->CreateLink( $id, $action, $returnid, $contents, $params, $warn_message, $onlyhref, 1679 $inline, $addtext, $targetcontentonly, $prettyurl ); 1680 } 1681 1682 /** 1683 * Returns the xhtml equivalent of an href link This is basically a nice little wrapper 1684 * to make sure that id's are placed in names and also that it's xhtml compliant. 1685 * 1686 * @param string The id given to the module on execution 1687 * @param string The action that this form should do when the link is clicked 1688 * @param string The id to eventually return to when the module is finished it's task 1689 * @param string The text that will have to be clicked to follow the link 1690 * @param string An array of params that should be inlucded in the URL of the link. These should be in a $key=>$value format. 1691 * @param string Text to display in a javascript warning box. If they click no, the link is not followed by the browser. 1692 * @param boolean A flag to determine if only the href section should be returned 1693 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend) 1694 * @param string Any additional text that should be added into the tag when rendered 1695 */ 1696 function CreateLink($id, $action, $returnid='', $contents='', $params=array(), $warn_message='', $onlyhref=false, $inline=false, $addttext='', $targetcontentonly=false, $prettyurl='') 1697 { 1698 $this->LoadFormMethods(); 1699 return cms_module_CreateLink($this, $id, $action, $returnid, $contents, $params, $warn_message, $onlyhref, $inline, $addttext, $targetcontentonly, $prettyurl); 1700 } 1701 1702 /** 1703 * Returns the xhtml equivalent of an href link for content links. This is basically a nice 1704 * little wrapper to make sure that we go back to where we want and that it's xhtml complient 1705 * 1706 * @param string the page id of the page we want to direct to 1707 */ 1708 function CreateContentLink($pageid, $contents='') 1709 { 1710 $this->LoadFormMethods(); 1711 return cms_module_CreateContentLink($this, $pageid, $contents); 1712 } 1713 1714 1715 /** 1716 * Returns the xhtml equivalent of an href link for Content links. This is basically a nice little wrapper 1717 * to make sure that we go back to where we want to and that it's xhtml compliant. 1718 * 1719 * @param string The id given to the module on execution 1720 * @param string The id to return to when the module is finished it's task 1721 * @param string The text that will have to be clicked to follow the link 1722 * @param string An array of params that should be inlucded in the URL of the link. These should be in a $key=>$value format. 1723 * @param boolean A flag to determine if only the href section should be returned 1724 */ 1725 function CreateReturnLink($id, $returnid, $contents='', $params=array(), $onlyhref=false) 1726 { 1727 $this->LoadFormMethods(); 1728 return cms_module_CreateReturnLink($this, $id, $returnid, $contents, $params, $onlyhref); 1729 } 1730 1731 1732 /** 1733 * Redirects the user to another action of the module. 1734 * This function is optimized for frontend use. 1735 * 1736 * @param string The id given to the module on execution 1737 * @param string The action that this form should do when the form is submitted 1738 * @param string The id to eventually return to when the module is finished it's task 1739 * @param string An array of params that should be inlucded in the URL of the link. These should be in a $key=>$value format. 1740 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend) 1741 */ 1742 function RedirectForFrontEnd($id, $returnid, $action, $params = array(), $inline = true ) 1743 { 1744 return $this->Redirect($id, $action, $returnid, $params, $inline ); 1745 } 1746 1747 /** 1748 * Redirects the user to another action of the module. 1749 * 1750 * @param string The id given to the module on execution 1751 * @param string The action that this form should do when the form is submitted 1752 * @param string The id to eventually return to when the module is finished it's task 1753 * @param string An array of params that should be inlucded in the URL of the link. These should be in a $key=>$value format. 1754 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend) 1755 */ 1756 function Redirect($id, $action, $returnid='', $params=array(), $inline=false) 1757 { 1758 $this->LoadRedirectMethods(); 1759 return cms_module_Redirect($this, $id, $action, $returnid, $params, $inline); 1760 } 1761 1762 /** 1763 * Redirects the user to a content page outside of the module. The passed around returnid is 1764 * frequently used for this so that the user will return back to the page from which they first 1765 * entered the module. 1766 * 1767 * @param string Content id to redirect to. 1768 */ 1769 function RedirectContent($id) 1770 { 1771 redirect_to_alias($id); 1772 } 1773 1774 /** 1775 * ------------------------------------------------------------------ 1776 * Intermodule Functions 1777 * ------------------------------------------------------------------ 1778 */ 1779 1780 function &GetModuleInstance($module) 1781 { 1782 global $gCms; 1783 1784 if (isset($gCms->modules[$module]) && 1785 $gCms->modules[$module]['installed'] == true && 1786 $gCms->modules[$module]['active'] == true) 1787 { 1788 return $gCms->modules[$module]['object']; 1789 } 1790 // Fix only variable references should be returned by reference 1791 $tmp = FALSE; 1792 return $tmp; 1793 } 1794 1795 /** 1796 * ------------------------------------------------------------------ 1797 * Language Functions 1798 * ------------------------------------------------------------------ 1799 */ 1800 1801 /** 1802 * Sets the default language (usually en_US) for the module. There 1803 * should be at least a language file for this language if the Lang() 1804 * function is used at all. 1805 */ 1806 function DefaultLanguage() 1807 { 1808 return 'en_US'; 1809 } 1810 1811 /** 1812 * Returns the corresponding translated string for the id given. 1813 * 1814 * @param string Id of the string to lookup and return 1815 * @param array Corresponding params for string that require replacement. 1816 * These params use the vsprintf command and it's style of replacement. 1817 */ 1818 function Lang() 1819 { 1820 $this->LoadLangMethods(); 1821 1822 //Push $this onto front of array 1823 $args = func_get_args(); 1824 array_unshift($args,''); 1825 $args[0] = $this; 1826 1827 return call_user_func_array('cms_module_Lang', $args); 1828 } 1829 1830 /** 1831 * ------------------------------------------------------------------ 1832 * Template/Smarty Functions 1833 * ------------------------------------------------------------------ 1834 */ 1835 1836 function ListTemplates($modulename = '') 1837 { 1838 $this->LoadTemplateMethods(); 1839 return cms_module_ListTemplates($this, $modulename); 1840 } 1841 1842 /** 1843 * Returns a database saved template. This should be used for admin functions only, as it doesn't 1844 * follow any smarty caching rules. 1845 */ 1846 function GetTemplate($tpl_name, $modulename = '') 1847 { 1848 $this->LoadTemplateMethods(); 1849 return cms_module_GetTemplate($this, $tpl_name, $modulename); 1850 } 1851 1852 /** 1853 * Returns contents of the template that resides in modules/ModuleName/templates/{template_name}.tpl 1854 * Code adapted from the Guestbook module 1855 */ 1856 function GetTemplateFromFile($template_name) 1857 { 1858 $this->LoadTemplateMethods(); 1859 return cms_module_GetTemplateFromFile($this, $template_name); 1860 } 1861 1862 function SetTemplate($tpl_name, $content, $modulename = '') 1863 { 1864 $this->LoadTemplateMethods(); 1865 return cms_module_SetTemplate($this, $tpl_name, $content, $modulename); 1866 } 1867 1868 function DeleteTemplate($tpl_name = '', $modulename = '') 1869 { 1870 $this->LoadTemplateMethods(); 1871 return cms_module_DeleteTemplate($this, $tpl_name, $modulename); 1872 } 1873 1874 function IsFileTemplateCached($tpl_name, $designation = '', $timestamp = '', $cacheid = '') 1875 { 1876 $this->LoadTemplateMethods(); 1877 return cms_module_IsFileTemplateCached($this, $tpl_name, $designation, $timestamp, $cacheid); 1878 } 1879 1880 function ProcessTemplate($tpl_name, $designation = '', $cache = false, $cacheid = '') 1881 { 1882 $this->LoadTemplateMethods(); 1883 return cms_module_ProcessTemplate($this, $tpl_name, $designation, $cache = false, $cacheid); 1884 } 1885 1886 function IsDatabaseTemplateCached($tpl_name, $designation = '', $timestamp = '') 1887 { 1888 $this->LoadTemplateMethods(); 1889 return cms_module_IsDatabaseTemplateCached($this, $tpl_name, $designation, $timestamp); 1890 } 1891 1892 /** 1893 * Given a template in a variable, this method processes it through smarty 1894 * note, there is no caching involved. 1895 */ 1896 function ProcessTemplateFromData( $data ) 1897 { 1898 $this->LoadTemplateMethods(); 1899 return cms_module_ProcessTemplateFromData($this, $data); 1900 } 1901 1902 function ProcessTemplateFromDatabase($tpl_name, $designation = '', $cache = false) 1903 { 1904 $this->LoadTemplateMethods(); 1905 return cms_module_ProcessTemplateFromDatabase($this, $tpl_name, $designation, $cache); 1906 } 1907 1908 function ListUserTags() 1909 { 1910 global $gCms; 1911 $usertagops =& $gCms->GetUserTagOperations(); 1912 return $usertagops->ListUserTags(); 1913 } 1914 1915 function CallUserTag($name, $params = array()) 1916 { 1917 global $gCms; 1918 $usertagops =& $gCms->GetUserTagOperations(); 1919 return $usertagops->CallUserTag($name, $params); 1920 } 1921 1922 /** 1923 * ------------------------------------------------------------------ 1924 * Tab Functions 1925 * ------------------------------------------------------------------ 1926 */ 1927 function StartTabHeaders() 1928 { 1929 return '<div id="page_tabs">'; 1930 } 1931 1932 function SetTabHeader($tabid,$title,$active=false) 1933 { 1934 $a=""; 1935 if (TRUE == $active) 1936 { 1937 $a=" class='active'"; 1938 $this->mActiveTab = $tabid; 1939 } 1940 return '<div id="'.$tabid.'"'.$a.'>'.$title.'</div>'; 1941 } 1942 1943 function EndTabHeaders() 1944 { 1945 return "</div><!-- EndTabHeaders -->"; 1946 } 1947 1948 function StartTabContent() 1949 { 1950 return '<div class="clearb"></div><div id="page_content">'; 1951 } 1952 1953 function EndTabContent() 1954 { 1955 return '</div> <!-- EndTabContent -->'; 1956 } 1957 1958 function StartTab($tabid, $params = array()) 1959 { 1960 if (FALSE == empty($this->mActiveTab) && $tabid == $this->mActiveTab && FALSE == empty($params['tab_message'])) { 1961 $message = $this->ShowMessage($this->Lang($params['tab_message'])); 1962 } else { 1963 $message = ''; 1964 } 1965 return '<div id="' . strtolower(str_replace(' ', '_', $tabid)) . '_c">'.$message; 1966 } 1967 1968 function EndTab() 1969 { 1970 return '</div> <!-- EndTab -->'; 1971 } 1972 1973 /** 1974 * ------------------------------------------------------------------ 1975 * Other Functions 1976 * ------------------------------------------------------------------ 1977 */ 1978 1979 /** 1980 * 1981 * Module can spit out extra CSS for the admin side 1982 * 1983 */ 1984 function AdminStyle() 1985 { 1986 return ''; 1987 } 1988 1989 /** 1990 * Set the content-type header. 1991 * 1992 * @param string Value to set the content-type header too 1993 */ 1994 function SetContentType($contenttype) 1995 { 1996 $variables = &$this->cms->variables; 1997 $variables['content-type'] = $contenttype; 1998 } 1999 2000 /** 2001 * Put an event into the audit (admin) log. This should be 2002 * done on most admin events for consistency. 2003 */ 2004 function Audit($itemid, $itemname, $action) 2005 { 2006 #$userid = get_userid(); 2007 #$username = $_SESSION["cms_admin_username"]; 2008 audit($itemid,$itemname,$action); 2009 } 2010 2011 /** 2012 * Create's a new permission for use by the module. 2013 * 2014 * @param string Name of the permission to create 2015 * @param string Description of the permission 2016 */ 2017 function CreatePermission($permission_name, $permission_text) 2018 { 2019 global $gCms; 2020 $db =& $gCms->GetDB(); 2021 2022 $query = "SELECT permission_id FROM ".cms_db_prefix()."permissions WHERE permission_name = ?"; 2023 $count = $db->GetOne($query, array($permission_name)); 2024 2025 if (intval($count) == 0) 2026 { 2027 $new_id = $db->GenID(cms_db_prefix()."permissions_seq"); 2028 $time = $db->DBTimeStamp(time()); 2029 $query = "INSERT INTO ".cms_db_prefix()."permissions (permission_id, permission_name, permission_text, create_date, modified_date) VALUES (?,?,?,".$time.",".$time.")"; 2030 $db->Execute($query, array($new_id, $permission_name, $permission_text)); 2031 } 2032 } 2033 2034 /** 2035 * Checks a permission against the currently logged in user. 2036 * 2037 * @param string The name of the permission to check against the current user 2038 */ 2039 function CheckPermission($permission_name) 2040 { 2041 $userid = get_userid(); 2042 return check_permission($userid, $permission_name); 2043 } 2044 2045 /** 2046 * Removes a permission from the system. If recreated, the 2047 * permission would have to be set to all groups again. 2048 * 2049 * @param string The name of the permission to remove 2050 */ 2051 function RemovePermission($permission_name) 2052 { 2053 global $gCms; 2054 $db =& $gCms->GetDB(); 2055 2056 $query = "SELECT permission_id FROM ".cms_db_prefix()."permissions WHERE permission_name = ?"; 2057 $row = &$db->GetRow($query, array($permission_name)); 2058 2059 if ($row) 2060 { 2061 $id = $row["permission_id"]; 2062 2063 $query = "DELETE FROM ".cms_db_prefix()."group_perms WHERE permission_id = ?"; 2064 $db->Execute($query, array($id)); 2065 2066 $query = "DELETE FROM ".cms_db_prefix()."permissions WHERE permission_id = ?"; 2067 $db->Execute($query, array($id)); 2068 } 2069 } 2070 2071 /** 2072 * Returns a module preference if it exists. 2073 * 2074 * @param string The name of the preference to check 2075 * @param string The default value, just in case it doesn't exist 2076 */ 2077 function GetPreference($preference_name, $defaultvalue='') 2078 { 2079 return get_site_preference($this->GetName() . "_mapi_pref_" . $preference_name, $defaultvalue); 2080 } 2081 2082 /** 2083 * Sets a module preference. 2084 * 2085 * @param string The name of the preference to set 2086 * @param string The value to set it to 2087 */ 2088 function SetPreference($preference_name, $value) 2089 { 2090 return set_site_preference($this->GetName() . "_mapi_pref_" . $preference_name, $value); 2091 } 2092 2093 /** 2094 * Removes a module preference. If no preference name 2095 * is specified, removes all module preferences. 2096 * 2097 * @param string The name of the preference to remove 2098 */ 2099 function RemovePreference($preference_name='') 2100 { 2101 if( $preference_name == '' ) 2102 { 2103 return remove_site_preference("^".$this->GetName()."_mapi_pref_",true); 2104 } 2105 return remove_site_preference($this->GetName() . "_mapi_pref_" . $preference_name); 2106 } 2107 2108 /** 2109 * Creates a string containing links to all the pages. 2110 * @param string The id given to the module on execution 2111 * @param string The action that this form should do when the form is submitted 2112 * @param string The id to eventually return to when the module is finished it's task 2113 * @param string the current page to display 2114 * @param string the amount of items being listed 2115 * @param string the amount of items to list per page 2116 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend) 2117 */ 2118 function CreatePagination($id, $action, $returnid, $page, $totalrows, $limit, $inline=false) 2119 { 2120 $this->LoadMiscMethods(); 2121 return cms_module_CreatePagination($this, $id, $action, $returnid, $page, $totalrows, $limit, $inline); 2122 } 2123 2124 /** 2125 * ShowMessage 2126 * Returns a formatted page status message 2127 * 2128 * @param message - Message to be shown 2129 */ 2130 function ShowMessage($message) 2131 { 2132 global $gCms; 2133 if (isset($gCms->variables['admintheme'])) 2134 { 2135 $admintheme =& $gCms->variables['admintheme']; //php4 friendly 2136 return $admintheme->ShowMessage($message); 2137 } 2138 return ''; 2139 } 2140 2141 /** 2142 * ShowErrors 2143 * Outputs errors in a nice error box with a troubleshooting link to the wiki 2144 * 2145 * @param errors - array or string of errors to be shown 2146 */ 2147 function ShowErrors($errors) 2148 { 2149 global $gCms; 2150 if (isset($gCms->variables['admintheme'])) 2151 { 2152 $admintheme =& $gCms->variables['admintheme']; //php4 friendly 2153 return $admintheme->ShowErrors($errors); 2154 } 2155 return ''; 2156 } 2157 2158 /** 2159 * ------------------------------------------------------------------ 2160 * Event Handler Related functions 2161 * ------------------------------------------------------------------ 2162 */ 2163 2164 2165 /** 2166 * Add an event handler for a module event 2167 * 2168 * @param string $modulename The name of the module sending the event 2169 * @param string $eventname The name of the event 2170 * @param boolean $removable Can this event be removed from the list? 2171 * 2172 * @returns mixed If successful, true. If it fails, false. 2173 */ 2174 function AddEventHandler( $modulename, $eventname, $removable = true ) 2175 { 2176 Events::AddEventHandler( $modulename, $eventname, false, $this->GetName(), $removable ); 2177 } 2178 2179 2180 /** 2181 * Inform the system about a new event that can be generated 2182 * 2183 * @param string The name of the event 2184 * 2185 * @returns nothing 2186 */ 2187 function CreateEvent( $eventname ) 2188 { 2189 Events::CreateEvent($this->GetName(), $eventname); 2190 } 2191 2192 2193 /** 2194 * Handle an event triggered by another module 2195 * This method must be over-ridden if this module is capable of handling events. 2196 * of any type. 2197 * 2198 * @param string The name of the originating module 2199 * @param string The name of the event 2200 * @param array Array of parameters provided with the event. 2201 * 2202 * @returns boolean 2203 */ 2204 function DoEvent( $originator, $eventname, &$params ) 2205 { 2206 if ($originator != '' && $eventname != '') 2207 { 2208 $filename = dirname(dirname(dirname(__FILE__))) . '/modules/'.$this->GetName().'/event.' 2209 . $originator . "." . $eventname . '.php'; 2210 2211 if (@is_file($filename)) 2212 { 2213 { 2214 global $gCms; 2215 $db =& $gCms->GetDb(); 2216 $config =& $gCms->GetConfig(); 2217 $smarty =& $gCms->GetSmarty(); 2218 2219 include($filename); 2220 2221 } 2222 } 2223 } 2224 } 2225 2226 2227 /** 2228 * Get a (langified) description for an event this module created. 2229 * This method must be over-ridden if this module created any events. 2230 * 2231 * @param string The name of the event 2232 * 2233 * @returns text string 2234 */ 2235 function GetEventDescription( $eventname ) 2236 { 2237 return ""; 2238 } 2239 2240 2241 /** 2242 * Get a (langified) descriptionof the details about when an event is 2243 * created, and the parameters that are attached with it. 2244 * This method must be over-ridden if this module created any events. 2245 * 2246 * @param string The name of the event 2247 */ 2248 function GetEventHelp( $eventname ) 2249 { 2250 return ""; 2251 } 2252 2253 2254 /** 2255 * A callback indicating if this module has a DoEvent method to 2256 * handle incoming events. 2257 */ 2258 function HandlesEvents() 2259 { 2260 return false; 2261 } 2262 2263 /** 2264 * Remove an event from the CMS system 2265 * This function removes all handlers to the event, and completely removes 2266 * all references to this event from the database 2267 * 2268 * Note, only events created by this module can be removed. 2269 * 2270 * @param string The name of the event 2271 * 2272 * @returns nothing 2273 */ 2274 function RemoveEvent( $eventname ) 2275 { 2276 Events::RemoveEvent($this->GetName(), $eventname); 2277 } 2278 2279 /** 2280 * Remove an event from the CMS system 2281 * This function removes all handlers to the event, and completely removes 2282 * all references to this event from the database 2283 * 2284 * Note, only events created by this module can be removed. 2285 * 2286 * @param string The name of the event 2287 * 2288 * @returns nothing 2289 */ 2290 function RemoveEventHandler( $modulename, $eventname ) 2291 { 2292 Events::RemoveEventHandler($modulename, $eventname, false, $this->GetName()); 2293 } 2294 2295 2296 /** 2297 * Trigger an event. 2298 * This function will call all registered event handlers for the event 2299 * 2300 * @param string The name of the event 2301 * @param array The parameters associated with this event. 2302 * 2303 * @returns nothing 2304 */ 2305 function SendEvent( $eventname, $params ) 2306 { 2307 Events::SendEvent($this->GetName(), $eventname, $params); 2308 } 2309 } 2310 2311 # vim:ts=4 sw=4 noet 2312 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |