Lang('friendlyname'); } function GetVersion() { return '1.5.3'; } function GetHelp() { $helptxt = $this->Lang('help') . '

Copyright and License

Copyright © 2009, Jos <josvd@live.nl>. All Rights Are Reserved.

This module has been released under the GNU Public License v3. However, as a special exception to the GPL, this software is distributed as an addon module to CMS Made Simple. You may only use this software when there is a clear and obvious indication in the admin section that the site was built with CMS Made Simple.

'; return $helptxt; } function GetAuthor() { return 'Jos'; } function GetAuthorEmail() { return 'josvd@live.nl'; } function GetChangeLog() { return file_get_contents(dirname(__FILE__).'/changelog.inc'); } function IsPluginModule() { return true; } function HasAdmin() { return true; } function GetAdminSection() { return 'content'; } function GetAdminDescription() { return $this->Lang('moddescription'); } function VisibleToAdminUser() { return $this->CheckPermission('Use Gallery'); } function GetDependencies() { return array(); } function MinimumCMSVersion() { return "1.10"; } function InitializeFrontend() { $this->RegisterModulePlugin(); $this->RestrictUnknownParams(); // Pretty url route for viewing a gallery in all its variations $urlprefix = $this->GetPreference('urlprefix', '[gG]allery'); $this->RegisterRoute('/'.$urlprefix.'\/(?P.+)\/(?P[0-9]+)-(?P[0-9]+)-(?P[a-zA-Z]+)-(?P[0-9]+)$/', array('action'=>'default')); $this->RegisterRoute('/'.$urlprefix.'\/(?P.+)\/(?P[0-9]+)-(?P[0-9]+)-(?P[0-9]+)$/', array('action'=>'default')); $this->RegisterRoute('/'.$urlprefix.'\/(?P.+)\/(?P[0-9]+)$/', array('action'=>'default')); $this->RegisterRoute('/'.$urlprefix.'\/(?P[0-9]+)-(?P[0-9]+)-(?P[a-zA-Z]+)-(?P[0-9]+)$/', array('action'=>'default')); $this->RegisterRoute('/'.$urlprefix.'\/(?P[0-9]+)-(?P[0-9]+)-(?P[0-9]+)$/', array('action'=>'default')); $this->RegisterRoute('/'.$urlprefix.'\/(?P[0-9]+)$/', array('action'=>'default')); $this->SetParameterType('dir',CLEAN_STRING); $this->SetParameterType('template',CLEAN_STRING); $this->SetParameterType('targetpage',CLEAN_STRING); $this->SetParameterType('number',CLEAN_INT); $this->SetParameterType('start',CLEAN_INT); $this->SetParameterType('show',CLEAN_STRING); $this->SetParameterType('action',CLEAN_STRING); $this->SetParameterType('img',CLEAN_INT); $this->SetParameterType('id',CLEAN_INT); $this->SetParameterType('fid',CLEAN_INT); $this->SetParameterType('gid',CLEAN_INT); $this->SetParameterType('mode',CLEAN_STRING); } function SetParameters() { // syntax for creating a parameter is parameter name, default value, description $this->CreateParameter('dir', 'sub1/sub2', $this->Lang('help_dir')); $this->CreateParameter('template', '', $this->Lang('help_template')); $this->CreateParameter('targetpage', '', $this->Lang('help_targetpage')); $this->CreateParameter('number', '100', $this->Lang('help_number')); $this->CreateParameter('start', '1', $this->Lang('help_start')); $this->CreateParameter('show', 'all', $this->Lang('help_show')); $this->CreateParameter('action', 'default', $this->Lang('help_action')); $this->CreateParameter('img', 10, $this->Lang('help_img')); } function InitializeAdmin() { $this->SetParameters(); } function LazyLoadFrontend() { return FALSE; } function GetEventDescription ( $eventname ) { return; // $this->Lang('event_info_'.$eventname ); } function GetEventHelp ( $eventname ) { return; // $this->Lang('event_help_'.$eventname ); } function InstallPostMessage() { return $this->Lang('postinstall'); } /** * DoEvent methods */ function DoEvent( $originator, $eventname, &$params ) { if ($originator == 'Core' && $eventname == 'ContentPostRender') { $pos = stripos($params["content"],"GalleryMetadata) ) { $params["content"] = substr($params["content"], 0, $pos) . $this->GalleryMetadata . substr($params["content"], $pos); } } } /** * Search methods */ function SearchResult($returnid, $gid, $attr = '') { $result = array(); if ($attr == 'gallery') { $galleryinfo = Gallery_utils::Getgalleryinfobyid($gid); if ( $galleryinfo && $galleryinfo['active'] ) { //0 position is the prefix displayed in the list results. $result[0] = $this->GetFriendlyName(); //1 position is the title $result[1] = empty($galleryinfo['title']) ? trim($galleryinfo['filename'],"/") : $galleryinfo['title']; //2 position is the URL to the title. $gdir = $gid == 1 ? '' : str_replace('%2F','/',rawurlencode((empty($galleryinfo['filepath']) ? '' : $galleryinfo['filepath'] . '/') . $galleryinfo['filename'])); $prettyurl = $this->GetPreference('urlprefix','gallery') . '/' . $gdir . $returnid; $result[2] = $this->CreateLink('cntnt01', 'default', $returnid, '', array('dir' => trim($gdir,'/')) ,'', true, false, '', true, $prettyurl); } } return $result; } function SearchReindex(&$module) { $galleries = Gallery_utils::GetGalleries(); foreach ($galleries as $gid=>$gallery) { $galleryinfo = Gallery_utils::Getgalleryinfobyid($gid); if ( $galleryinfo['active'] ) { $searchwords = $gallery['title'] . ' ' . $gallery['comment']; $db = $this->GetDB(); $query = "SELECT title, comment FROM " . cms_db_prefix() . "module_gallery g1 WHERE galleryid=?"; $result = $db->Execute($query, array($gid)); if ( $result && $result->RecordCount() > 0 ) { while ( $row=$result->FetchRow() ) { $searchwords .= ' ' . $row['title'] . ' ' . $row['comment']; } } $module->AddWords($this->GetName(), $gid, 'gallery',$searchwords); } } } /** * Register TinyMCE plugin */ function RegisterTinyMCEPlugin() { $gCms = cmsms(); $db = $this->GetDB(); $config = $this->GetConfig(); $plugin1 = " tinymce.create('tinymce.plugins.picker', { createControl: function(n, cm) { switch (n) { case 'picker': var c = cm.createMenuButton('picker', { title : '".$this->Lang('tinymce_button_picker')."', image : '".$config["root_url"]."/modules/Gallery/images/icon_TinyMCE.gif', icons : false }); c.onRenderMenu.add(function(c, m) { "; $query = "SELECT * FROM " . cms_db_prefix() . "module_gallery WHERE active = 1 AND (fileid = 1 OR filename LIKE '%/') ORDER BY " . $db->Concat('filepath', 'filename') . " ASC"; $result = $db->Execute($query); if ( $result && $result->RecordCount() > 0 ) { while ( $gallery=$result->FetchRow() ) { $plugin1 .= " m.add({title : '".$gallery['filename']."', onclick : function() { tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{Gallery" . ($gallery['fileid'] == 1 ? "}" : " dir=\'" . substr($gallery['filepath'] . $gallery['filename'], 0, -1) . "\'}")."'); }}); m.addSeparator(); "; } } $plugin1 .= " }); // Return the new menu button instance return c; } return null; } }); "; return array(array('picker',$plugin1,$this->Lang('tinymce_description_picker'))); } function GetHeaderHTML() { $tmpl = << {literal} {/literal} EOT; return $this->ProcessTemplateFromData($tmpl); } } ?>