public static function initInstance($engineType = null) { if (self::$engine != null) { return self::$engine; } $parser = ModuleOperations::get_instance()->get_module_instance('Parser'); if ($engineType == null) { $engineType = $parser->GetPreference('default_engine', Engine::$PARSDOWN); } self::$process_smarty_security = $parser->GetPreference('process_smarty_security', true); self::$process_security = $parser->GetPreference('process_security', true); self::$process_quote = $parser->GetPreference('process_quote', true); self::$process_img = $parser->GetPreference('process_img', true); self::$process_codepre = $parser->GetPreference('process_codepre', true); if (Engine::$MICHELF == $engineType) { include_once dirname(__FILE__) . '/Engines/class.MichelfEngine.php'; self::$engine = new MichelfEngine(); } else { if (Engine::$MICHELF_EXTRA == $engineType) { include_once dirname(__FILE__) . '/Engines/class.MichelfExtraEngine.php'; self::$engine = new MichelfExtraEngine(); } else { if (Engine::$PARSDOWN == $engineType) { include_once dirname(__FILE__) . '/Engines/class.ParsedownEngine.php'; self::$engine = new ParsedownEngine(); } } } return self::$engine; }
public static function get_modules_with_method($methodname) { $gCms = cmsms(); $res = array(); if (version_compare(CMS_VERSION, '1.10-beta0') < 0) { foreach ($gCms->modules as $modulename => $onemodule) { if (!isset($onemodule['object'])) { continue; } $mod =& $onemodule['object']; if (!method_exists($mod, $methodname)) { continue; } $res[$mod->GetName()] = $mod->GetFriendlyName(); } } else { $modules = ModuleOperations::get_instance()->GetInstalledModules(); foreach ($modules as $onemodule) { $mod = ModuleOperations::get_instance()->get_module_instance($onemodule); if (!$mod) { continue; } if (!method_exists($mod, $methodname)) { continue; } $res[$mod->GetName()] = $mod->GetFriendlyName(); } } if (empty($res)) { return FALSE; } return $res; }
/** * Get the only permitted instance of this object. It will be created if necessary * * @return object */ public static function &get_instance() { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c(); } return self::$_instance; }
function cms_autoloader($classname) { $config = cmsms()->GetConfig(); // standard classes $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$classname}.php"); if (file_exists($fn)) { __cms_load($fn); return; } $lowercase = strtolower($classname); $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$lowercase}.inc.php"); if (file_exists($fn) && $classname != 'Content') { __cms_load($fn); return; } // standard interfaces $fn = cms_join_path($config['root_path'], 'lib', 'classes', "interface.{$classname}.php"); if (file_exists($fn)) { __cms_load($fn); return; } // standard content types $fn = cms_join_path($config['root_path'], 'lib', 'classes', 'contenttypes', "{$classname}.inc.php"); if (file_exists($fn)) { __cms_load($fn); return; } // module loaded content types $contentops = cmsms()->GetContentOperations(); $types = $contentops->ListContentTypes(); if (in_array(strtolower($classname), array_keys($types))) { $contentops->LoadContentType(strtolower($classname)); return; } $fn = $config['root_path'] . "/modules/{$classname}/{$classname}.module.php"; if (file_exists($fn)) { __cms_load($fn); return; } $list = ModuleOperations::get_instance()->GetLoadedModules(); if (is_array($list) && count($list)) { foreach (array_keys($list) as $modname) { $fn = $config['root_path'] . "/modules/{$modname}/lib/class.{$classname}.php"; if (file_exists($fn)) { __cms_load($fn); return; } } } // module classes }
public function execute($time = '') { if (!$time) { $time = time(); } // do the task. if (!get_site_preference('enablenotifications', 1)) { return TRUE; } $allmodules = ModuleOperations::get_instance()->GetInstalledModules(); $loadedmods = ModuleOperations::get_instance()->GetLoadedModules(); foreach ($allmodules as $modulename) { $did_load = FALSE; $module = ''; if (isset($loadedmods[$modulename])) { $module = $loadedmods[$modulename]; } else { $module = ModuleOperations::get_instance()->get_module_instance($modulename); $did_load = TRUE; } if (!is_object($module)) { continue; } // now see if this module has notifications $data = $module->GetNotificationOutput(3); if (empty($data)) { continue; } if (is_object($data)) { $data = array($data); } for ($i = 0; $i < count($data); $i++) { if (!isset($data[$i]->name)) { $data[$i]->name = $modulename; } if (!isset($data[$i]->friendlyname)) { $data[$i]->friendlyname = $module->GetFriendlyName(); } } if (!is_array($this->_notifications)) { $this->_notifications = array(); } $this->_notifications = array_merge($this->_notifications, $data); } return TRUE; }
function assignVariables() { // do module upgrades and installs. ModuleOperations::get_instance()->LoadModules(TRUE); $allmodules = ModuleOperations::get_instance()->GetAllModuleNames(); foreach ($allmodules as $name) { // we force all system modules to be loaded... if (ModuleOperations::get_instance()->IsSystemModule($name)) { $module = ModuleOperations::get_instance()->get_module_instance($name, '', TRUE); } } // display a message. $test = new StdClass(); $test->error = false; $test->messages = array(); $test->messages[] = ilang('noneed_upgrade_modules'); $this->smarty->assign('test', $test); $this->smarty->assign('errors', $this->errors); }
function smarty_core_get_module_plugin($_name, &$smarty) { static $data; $fn = TMP_CACHE_LOCATION . '/modulefunctions.cache.dat'; if (!count($data)) { if (!file_exists($fn)) { // build the cache list $loaded = array(); $orig = array_keys($smarty->_plugins['function']); $installed = ModuleOperations::get_instance()->GetInstalledModules(); $preloaded = ModuleOperations::get_instance()->GetLoadedModules(); foreach ($installed as $module) { if (is_array($preloaded) || !count($preloaded) || !in_array($module, $preloaded)) { $loaded[] = $module; } $obj = cms_utils::get_module($module); $tmp = array_keys($smarty->_plugins['function']); $tmp2 = array_diff($tmp, $orig); foreach ($tmp2 as $one) { $data[$one] = $module; } $orig = $tmp; } foreach ($loaded as $module) { ModuleOperations::get_instance()->unload_module($module); } if (count($data)) { file_put_contents($fn, serialize($data)); } } else { $data = unserialize(file_get_contents($fn)); } } if (isset($data[$_name])) { // we know which module this plugin is associated with. // so make sure it's loaded. cms_utils::get_module($data[$_name]); return TRUE; } return FALSE; }
// and now get the list of handlers for this event $handlers = Events::ListEventHandlers($module, $event); // and the list of all available handlers $allhandlers = array(); // we get the list of user tags, and add them to the list $usertags = $usertagops->ListUserTags(); foreach ($usertags as $key => $value) { $allhandlers[$value] = $value; } // and the list of modules, and add them $allmodules = ModuleOperations::get_instance()->GetInstalledModules(); foreach ($allmodules as $key) { if ($key == $modulename) { continue; } $modobj = ModuleOperations::get_instance()->get_module_instance($key); if ($modobj && $modobj->HandlesEvents()) { $allhandlers[$key] = 'm:' . $key; } } echo "<div class=\"pageoverflow\">\n"; echo "<p class=\"pagetext\">" . lang("module_name") . ":</p>\n"; echo "<p class=\"pageinput\">" . $modulename . "</p>\n"; echo "</div>\n"; echo "<div class=\"pageoverflow\">\n"; echo "<p class=\"pagetext\">" . lang("event_name") . ":</p>\n"; echo "<p class=\"pageinput\">" . $event . "</p>\n"; echo "</div>\n"; echo "<div class=\"pageoverflow\">\n"; echo "<p class=\"pagetext\">" . lang("event_description") . ":</p>\n"; echo "<p class=\"pageinput\">" . $description . "</p>\n";
# as an addon module to CMS Made Simple. You may not use this software # in any Non GPL version of CMS Made simple, or in any version of CMS # Made simple that does not indicate clearly and obviously in its admin # section that the site was built with CMS Made simple. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Or read it online: http://www.gnu.org/licenses/licenses.html#GPL # #------------------------------------------------------------------------- #END_LICENSE if (!isset($gCms)) { exit; } $results = ModuleOperations::get_instance()->GetQueueResults(); if (!is_array($results) || count($results) == 0) { echo $this->ShowErrors($this->Lang('error_noresults')); return; } $smarty->assign('mod', $this); $smarty->assign('queue_results', $results); $smarty->assign('return_link', $this->CreateLink($id, 'defaultadmin', $returnid, $this->Lang('back_to_module_manager'))); echo $this->ProcessTemplate('display_install_results.tpl'); # # EOF #
} #Pull the stuff out of the buffer... $htmlresult = ''; if (!(isset($USE_OUTPUT_BUFFERING) && $USE_OUTPUT_BUFFERING == false)) { $htmlresult = @ob_get_contents(); @ob_end_clean(); } #Do any header replacements (this is for WYSIWYG stuff) $headertext = ''; $formtext = ''; $formsubmittext = ''; $bodytext = ''; $userid = get_userid(); //$wysiwyg = get_preference($userid, 'wysiwyg'); // get the active wysiwyg $loaded = ModuleOperations::get_instance()->GetLoadedModules(); if (is_array($loaded) && count($loaded)) { foreach ($loaded as $name => &$object) { if (!is_object($object)) { continue; } if ($object->IsWYSIWYG() && $object->WYSIWYGActive()) { $bodytext .= $object->WYSIWYGGenerateBody(); $headertext .= $object->WYSIWYGGenerateHeader($htmlresult); $formtext .= $object->WYSIWYGPageForm(); $formsubmittext .= $object->WYSIWYGPageFormSubmit(); //break; } else { if ($object->IsSyntaxHighlighter() && $object->SyntaxActive()) { $bodytext .= $object->SyntaxGenerateBody(); $headertext .= $object->SyntaxGenerateHeader($htmlresult);
$error .= "<li>" . lang('errorretrievingcss') . "</li>"; } } } # end of getting css } # end of has access if (strlen($css_name) > 0) { $CMS_ADMIN_SUBTITLE = $css_name; } if (isset($_POST["apply"])) { $CMS_EXCLUDE_FROM_RECENT = 1; } $addlScriptSubmit = ''; $syntaxmodule = get_preference(get_userid(FALSE), 'syntaxhighlighter'); if ($syntaxmodule && ($module = ModuleOperations::get_instance()->get_module_instance($syntaxmodule))) { if ($module->IsSyntaxHighlighter() && $module->SyntaxActive()) { $addlScriptSubmit .= $module->SyntaxPageFormSubmit(); } } $closestr = cms_html_entity_decode(lang('close')); $headtext = <<<EOSCRIPT <script type="text/javascript"> // <![CDATA[ jQuery(document).ready(function(){ jQuery('[name=apply]').live('click',function(){ var data = jQuery('#Edit_CSS').find('input:not([type=submit]), select, textarea').serializeArray(); data.push({ 'name': 'ajax', 'value': 1}); data.push({ 'name': 'apply', 'value': 1 }); \$.post('{$_SERVER['REQUEST_URI']}',data,function(resultdata,text){ var event = jQuery.Event('cms_ajax_apply');
/** * Return a list of all of the modules that have the specified method. * * @deprecated * @param string $methodname * @return string[] */ public static function get_modules_with_method($methodname) { $res = array(); $modules = ModuleOperations::get_instance()->GetInstalledModules(); foreach ($modules as $onemodule) { $mod = ModuleOperations::get_instance()->get_module_instance($onemodule); if (!$mod) { continue; } if (!method_exists($mod, $methodname)) { continue; } $res[$mod->GetName()] = $mod->GetFriendlyName(); } if (empty($res)) { return FALSE; } return $res; }
function search_Reindex(&$module) { @set_time_limit(999); $module->DeleteAllWords(); $gCms = cmsms(); $templateops =& $gCms->GetTemplateOperations(); $alltemplates = $templateops->LoadTemplates(); reset($alltemplates); while (list($key) = each($alltemplates)) { $onetemplate =& $alltemplates[$key]; //$module->EditTemplatePost($onetemplate); $params = array('template' => &$onetemplate, 'forceindexcontent' => 1); $module->DoEvent('Core', 'EditTemplatePost', $params); } $gcbops =& $gCms->GetGlobalContentOperations(); $allblobs = $gcbops->LoadHtmlBlobs(); reset($allblobs); while (list($key) = each($allblobs)) { $oneblob =& $allblobs[$key]; //$module->EditHtmlBlobPost($oneblob); $params = array('global_content' => &$oneblob); $module->DoEvent('Core', 'EditGlobalContentPost', $params); } $modules = ModuleOperations::get_instance()->GetInstalledModules(); foreach ($modules as $name) { if (!$name || $name == 'Search') { continue; } $object = ModuleOperations::get_instance()->get_module_instance($name); if (!is_object($object)) { continue; } if (method_exists($object, 'SearchReindex')) { $object->SearchReindex($module); } } }
/** * Load existing routes from modules */ public static function load_routes() { // force modules to register their routes. $gCms = cmsms(); global $CMS_ADMIN_PAGE; $flag = false; if (isset($CMS_ADMIN_PAGE)) { // hack to force modules to register their routes. $flag = $CMS_ADMIN_PAGE; unset($CMS_ADMIN_PAGE); } // todo: $modules = ModuleOperations::get_instance()->GetLoadedModules(); foreach ($modules as $name => &$module) { $module->SetParameters(); } if ($flag) { $CMS_ADMIN_PAGE = $flag; } // force content to register routes. $contentops = $gCms->GetContentOperations(); $contentops->register_routes(); }
/** * PopulateAdminNavigation * This method populates a big array containing the Navigation Taxonomy * for the admin section. This array is then used to create menus and * section main pages. It uses aggregate permissions to hide sections for which * the user doesn't have permissions, and highlights the current section so * menus can show the user where they are. * * @param subtitle any info to add to the page title * @access private * @ignore */ private function _populate_admin_navigation($subtitle = '') { if (count($this->_menuItems) > 0) { // we have already created the list return; } $config = cmsms()->GetConfig(); debug_buffer('before populate admin navigation'); $this->subtitle = $subtitle; debug_buffer('before menu items'); $this->_menuItems = array('main' => array('url' => 'index.php', 'parent' => -1, 'title' => 'CMS', 'description' => '', 'show_in_menu' => true), 'home' => array('url' => 'index.php', 'parent' => 'main', 'title' => $this->_FixSpaces(lang('home')), 'description' => '', 'show_in_menu' => true), 'viewsite' => array('url' => $config['root_url'] . '/index.php', 'parent' => 'main', 'title' => $this->_FixSpaces(lang('viewsite')), 'type' => 'external', 'description' => '', 'show_in_menu' => true, 'target' => '_blank'), 'logout' => array('url' => 'logout.php', 'parent' => 'main', 'title' => $this->_FixSpaces(lang('logout')), 'description' => '', 'show_in_menu' => true), 'content' => array('url' => 'index.php?section=content', 'parent' => -1, 'title' => $this->_FixSpaces(lang('content')), 'description' => lang('contentdescription'), 'show_in_menu' => $this->HasPerm('contentPerms')), 'pages' => array('url' => 'listcontent.php', 'parent' => 'content', 'title' => $this->_FixSpaces(lang('pages')), 'description' => lang('pagesdescription'), 'show_in_menu' => $this->HasPerm('pagePerms')), 'addcontent' => array('url' => 'addcontent.php', 'parent' => 'pages', 'title' => $this->_FixSpaces(lang('addcontent')), 'description' => lang('addcontent'), 'show_in_menu' => false), 'editpage' => array('url' => 'editcontent.php', 'parent' => 'pages', 'title' => $this->_FixSpaces(lang('editpage')), 'description' => lang('editpage'), 'show_in_menu' => false), 'images' => array('url' => 'imagefiles.php', 'parent' => 'content', 'title' => $this->_FixSpaces(lang('imagemanager')), 'description' => lang('imagemanagerdescription'), 'show_in_menu' => $this->HasPerm('filePerms')), 'blobs' => array('url' => 'listhtmlblobs.php', 'parent' => 'content', 'title' => $this->_FixSpaces(lang('htmlblobs')), 'description' => lang('htmlblobdescription'), 'show_in_menu' => $this->HasPerm('htmlPerms')), 'addhtmlblob' => array('url' => 'addhtmlblob.php', 'parent' => 'blobs', 'title' => $this->_FixSpaces(lang('addhtmlblob')), 'description' => lang('addhtmlblob'), 'show_in_menu' => false), 'edithtmlblob' => array('url' => 'edithtmlblob.php', 'parent' => 'blobs', 'title' => $this->_FixSpaces(lang('edithtmlblob')), 'description' => lang('edithtmlblob'), 'show_in_menu' => false), 'layout' => array('url' => 'index.php?section=layout', 'parent' => -1, 'title' => $this->_FixSpaces(lang('layout')), 'description' => lang('layoutdescription'), 'show_in_menu' => $this->HasPerm('layoutPerms')), 'template' => array('url' => 'listtemplates.php', 'parent' => 'layout', 'title' => $this->_FixSpaces(lang('templates')), 'description' => lang('templatesdescription'), 'show_in_menu' => $this->HasPerm('templatePerms')), 'addtemplate' => array('url' => 'addtemplate.php', 'parent' => 'template', 'title' => $this->_FixSpaces(lang('addtemplate')), 'description' => lang('addtemplate'), 'show_in_menu' => false), 'edittemplate' => array('url' => 'edittemplate.php', 'parent' => 'template', 'title' => $this->_FixSpaces(lang('edittemplate')), 'description' => lang('edittemplate'), 'show_in_menu' => false), 'currentassociations' => array('url' => 'listcssassoc.php', 'parent' => 'template', 'title' => $this->_FixSpaces(lang('currentassociations')), 'description' => lang('currentassociations'), 'show_in_menu' => false), 'copytemplate' => array('url' => 'copyemplate.php', 'parent' => 'template', 'title' => $this->_FixSpaces(lang('copytemplate')), 'description' => lang('copytemplate'), 'show_in_menu' => false), 'stylesheets' => array('url' => 'listcss.php', 'parent' => 'layout', 'title' => $this->_FixSpaces(lang('stylesheets')), 'description' => lang('stylesheetsdescription'), 'show_in_menu' => $this->HasPerm('cssPerms') || $this->HasPerm('cssAssocPerms')), 'addcss' => array('url' => 'addcss.php', 'parent' => 'stylesheets', 'title' => $this->_FixSpaces(lang('addstylesheet')), 'description' => lang('addstylesheet'), 'show_in_menu' => false), 'editcss' => array('url' => 'editcss.php', 'parent' => 'stylesheets', 'title' => $this->_FixSpaces(lang('editcss')), 'description' => lang('editcss'), 'show_in_menu' => false), 'templatecss' => array('url' => 'templatecss.php', 'parent' => 'stylesheets', 'title' => $this->_FixSpaces(lang('templatecss')), 'description' => lang('templatecss'), 'show_in_menu' => false), 'usersgroups' => array('url' => 'index.php?section=usersgroups', 'parent' => -1, 'title' => $this->_FixSpaces(lang('usersgroups')), 'description' => lang('usersgroupsdescription'), 'show_in_menu' => $this->HasPerm('usersGroupsPerms')), 'users' => array('url' => 'listusers.php', 'parent' => 'usersgroups', 'title' => $this->_FixSpaces(lang('users')), 'description' => lang('usersdescription'), 'show_in_menu' => $this->HasPerm('userPerms')), 'adduser' => array('url' => 'adduser.php', 'parent' => 'users', 'title' => $this->_FixSpaces(lang('adduser')), 'description' => lang('adduser'), 'show_in_menu' => false), 'edituser' => array('url' => 'edituser.php', 'parent' => 'users', 'title' => $this->_FixSpaces(lang('edituser')), 'description' => lang('edituser'), 'show_in_menu' => false), 'groups' => array('url' => 'listgroups.php', 'parent' => 'usersgroups', 'title' => $this->_FixSpaces(lang('groups')), 'description' => lang('groupsdescription'), 'show_in_menu' => $this->HasPerm('groupPerms')), 'addgroup' => array('url' => 'addgroup.php', 'parent' => 'groups', 'title' => $this->_FixSpaces(lang('addgroup')), 'description' => lang('addgroup'), 'show_in_menu' => false), 'editgroup' => array('url' => 'editgroup.php', 'parent' => 'groups', 'title' => $this->_FixSpaces(lang('editgroup')), 'description' => lang('editgroup'), 'show_in_menu' => false), 'groupmembers' => array('url' => 'changegroupassign.php', 'parent' => 'usersgroups', 'title' => $this->_FixSpaces(lang('groupassignments')), 'description' => lang('groupassignmentdescription'), 'show_in_menu' => $this->HasPerm('groupMemberPerms')), 'groupperms' => array('url' => 'changegroupperm.php', 'parent' => 'usersgroups', 'title' => $this->_FixSpaces(lang('groupperms')), 'description' => lang('grouppermsdescription'), 'show_in_menu' => $this->HasPerm('groupPermPerms')), 'extensions' => array('url' => 'index.php?section=extensions', 'parent' => -1, 'title' => $this->_FixSpaces(lang('extensions')), 'description' => lang('extensionsdescription'), 'show_in_menu' => $this->HasPerm('extensionsPerms')), 'modules' => array('url' => 'listmodules.php', 'parent' => 'extensions', 'title' => $this->_FixSpaces(lang('modules')), 'description' => lang('moduledescription'), 'show_in_menu' => $this->HasPerm('modulePerms')), 'tags' => array('url' => 'listtags.php', 'parent' => 'extensions', 'title' => $this->_FixSpaces(lang('tags')), 'description' => lang('tagdescription'), 'show_in_menu' => $this->HasPerm('taghelpPerms')), 'usertags' => array('url' => 'listusertags.php', 'parent' => 'extensions', 'title' => $this->_FixSpaces(lang('usertags')), 'description' => lang('usertagdescription'), 'show_in_menu' => $this->HasPerm('codeBlockPerms')), 'eventhandlers' => array('url' => 'eventhandlers.php', 'parent' => 'extensions', 'title' => $this->_FixSpaces(lang('eventhandlers')), 'description' => lang('eventhandlerdescription'), 'show_in_menu' => $this->HasPerm('eventPerms')), 'editeventhandler' => array('url' => 'editevent.php', 'parent' => 'eventhandlers', 'title' => $this->_FixSpaces(lang('editeventhandler')), 'description' => lang('editeventshandler'), 'show_in_menu' => false), 'addusertag' => array('url' => 'adduserplugin.php', 'parent' => 'usertags', 'title' => $this->_FixSpaces(lang('addusertag')), 'description' => lang('addusertag'), 'show_in_menu' => false), 'editusertag' => array('url' => 'edituserplugin.php', 'parent' => 'usertags', 'title' => $this->_FixSpaces(lang('editusertag')), 'description' => lang('editusertag'), 'show_in_menu' => false), 'siteadmin' => array('url' => 'index.php?section=siteadmin', 'parent' => -1, 'title' => $this->_FixSpaces(lang('admin')), 'description' => lang('admindescription'), 'show_in_menu' => $this->HasPerm('siteAdminPerms')), 'siteprefs' => array('url' => 'siteprefs.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('globalconfig')), 'description' => lang('preferencesdescription'), 'show_in_menu' => $this->HasPerm('sitePrefPerms')), 'pagedefaults' => array('url' => 'pagedefaults.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('pagedefaults')), 'description' => lang('pagedefaultsdescription'), 'show_in_menu' => $this->HasPerm('sitePrefPerms')), 'systeminfo' => array('url' => 'systeminfo.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('systeminfo')), 'description' => lang('systeminfodescription'), 'show_in_menu' => $this->HasPerm('adminPerms')), 'systemmaintenance' => array('url' => 'systemmaintenance.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('systemmaintenance')), 'description' => lang('systemmaintenancedescription'), 'show_in_menu' => $this->HasPerm('adminPerms')), 'checksum' => array('url' => 'checksum.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('system_verification')), 'description' => lang('checksumdescription'), 'show_in_menu' => $this->HasPerm('adminPerms')), 'adminlog' => array('url' => 'adminlog.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('adminlog')), 'description' => lang('adminlogdescription'), 'show_in_menu' => $this->HasPerm('adminPerms')), 'myprefs' => array('url' => 'index.php?section=myprefs', 'parent' => -1, 'title' => $this->_FixSpaces(lang('myprefs')), 'description' => lang('myprefsdescription'), 'show_in_menu' => true), 'myaccount' => array('url' => 'myaccount.php', 'parent' => 'myprefs', 'title' => $this->_FixSpaces(lang('myaccount')), 'description' => lang('myaccountdescription'), 'show_in_menu' => true), 'managebookmarks' => array('url' => 'listbookmarks.php', 'parent' => 'myprefs', 'title' => $this->_FixSpaces(lang('managebookmarks')), 'description' => lang('managebookmarksdescription'), 'show_in_menu' => true), 'addbookmark' => array('url' => 'addbookmark.php', 'parent' => 'myprefs', 'title' => $this->_FixSpaces(lang('addbookmark')), 'description' => lang('addbookmark'), 'show_in_menu' => false), 'editbookmark' => array('url' => 'editbookmark.php', 'parent' => 'myprefs', 'title' => $this->_FixSpaces(lang('editbookmark')), 'description' => lang('editbookmark'), 'show_in_menu' => false)); debug_buffer('after menu items'); // slightly cleaner syntax $this->_menuItems['ecommerce'] = array('url' => 'index.php?section=ecommerce', 'parent' => -1, 'title' => $this->_FixSpaces(lang('ecommerce')), 'description' => lang('ecommerce_desc'), 'show_in_menu' => true); // adjust all the urls to include the session key // and set an icon if we can. foreach ($this->_menuItems as $sectionKey => $sectionArray) { if (isset($sectionArray['url']) && (!isset($sectionArray['type']) || $sectionArray['type'] != 'external')) { $url = $this->_menuItems[$sectionKey]['url']; if (strpos($url, '?') !== FALSE) { $url .= '&'; } else { $url .= '?'; } $url .= CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY]; $this->_menuItems[$sectionKey]['url'] = $url; } } debug_buffer('before syste modules'); // add in all of the 'system' modules too $gCms = cmsms(); foreach ($this->_menuItems as $sectionKey => $sectionArray) { $tmpArray = $this->_MenuListSectionModules($sectionKey); $first = true; foreach ($tmpArray as $thisKey => $thisVal) { $thisModuleKey = $thisKey; $counter = 0; // don't clobber existing keys if (array_key_exists($thisModuleKey, $this->_menuItems)) { while (array_key_exists($thisModuleKey, $this->_menuItems)) { $thisModuleKey = $thisKey . $counter; $counter++; } } // if it's a system module... if (ModuleOperations::get_instance()->IsSystemModule($thisModuleKey)) { $this->_menuItems[$thisModuleKey] = array('url' => $thisVal['url'], 'parent' => $sectionKey, 'title' => $this->_FixSpaces($thisVal['name']), 'description' => $thisVal['description'], 'show_in_menu' => true); } } } debug_buffer('before module menu items'); // add in all of the modules foreach ($this->_menuItems as $sectionKey => $sectionArray) { $tmpArray = $this->_MenuListSectionModules($sectionKey); $first = true; foreach ($tmpArray as $thisKey => $thisVal) { $thisModuleKey = $thisKey; $counter = 0; // don't clobber existing keys if (array_key_exists($thisModuleKey, $this->_menuItems)) { while (array_key_exists($thisModuleKey, $this->_menuItems)) { $thisModuleKey = $thisKey . $counter; $counter++; } if ($counter > 0) { continue; } } $this->_menuItems[$thisModuleKey] = array('url' => $thisVal['url'], 'parent' => $sectionKey, 'title' => $this->_FixSpaces($thisVal['name']), 'description' => $thisVal['description'], 'show_in_menu' => true); if ($first) { $this->_menuItems[$thisModuleKey]['firstmodule'] = 1; $first = false; } else { $this->_menuItems[$thisModuleKey]['module'] = 1; } } } debug_buffer('after module menu items'); // remove any top level items that don't have children $parents = array(); foreach ($this->_menuItems as $sectionKey => $sectionArray) { if ($this->_menuItems[$sectionKey]['parent'] == -1) { $parents[] = $sectionKey; } } foreach ($parents as $oneparent) { $found = 0; foreach ($this->_menuItems as $sectionKey => $sectionArray) { if ($sectionArray['parent'] == $oneparent) { $found = 1; break; } } if (!$found) { unset($this->_menuItems[$oneparent]); } } // resolve the tree to be doubly-linked, // and make sure the selections are selected foreach ($this->_menuItems as $sectionKey => $sectionArray) { // link the children to the parents; a little clumsy since we can't // assume php5-style references in a foreach. $this->_menuItems[$sectionKey]['children'] = array(); foreach ($this->_menuItems as $subsectionKey => $subsectionArray) { if ($subsectionArray['parent'] == $sectionKey) { $this->_menuItems[$sectionKey]['children'][] = $subsectionKey; } } // set selected if ($this->_script == 'moduleinterface.php') { $a = preg_match('/(module|mact)=([^&,]+)/', $this->_query, $matches); if ($a > 0 && $matches[2] == $sectionKey) { $this->_menuItems[$sectionKey]['selected'] = true; $this->title .= $sectionArray['title']; if ($sectionArray['parent'] != -1) { $parent = $sectionArray['parent']; while ($parent != -1) { $this->_menuItems[$parent]['selected'] = true; $parent = $this->_menuItems[$parent]['parent']; } } } else { $this->_menuItems[$sectionKey]['selected'] = false; } } else { if (strstr($_SERVER['REQUEST_URI'], $sectionArray['url']) !== FALSE && (!isset($sectionArray['type']) || $sectionArray['type'] != 'external')) { $this->_menuItems[$sectionKey]['selected'] = true; $this->title .= $sectionArray['title']; if ($sectionArray['parent'] != -1) { $parent = $sectionArray['parent']; while ($parent != -1) { $this->_menuItems[$parent]['selected'] = true; $parent = $this->_menuItems[$parent]['parent']; } } } else { $this->_menuItems[$sectionKey]['selected'] = false; } } } // fix subtitle, if any if ($subtitle != '') { $this->title .= ': ' . $subtitle; } // generate breadcrumb array $count = 0; foreach ($this->_menuItems as $key => $menuItem) { if ($menuItem['selected']) { $this->_breadcrumbs[] = array('title' => $menuItem['title'], 'url' => $menuItem['url']); $this->title = $menuItem['title']; $count++; } } if ($count > 0) { // and fix up the last breadcrumb... if ($this->_query != '' && strpos($this->_breadcrumbs[$count - 1]['url'], '&') === false) { $this->_query = preg_replace('/\\&/', '&', $this->_query); $pos = strpos($this->_breadcrumbs[$count - 1]['url'], '?'); $tmp = substr($this->_breadcrumbs[$count - 1]['url'], 0, $pos) . '?' . $this->_query; $this->_breadcrumbs[$count - 1]['url'] = $tmp; } unset($this->_breadcrumbs[$count - 1]['url']); if ($this->subtitle != '') { $this->_breadcrumbs[$count - 1]['title'] .= ': ' . $this->subtitle; } } debug_buffer('after populate admin navigation'); }
/** * Return a list of modules that have the supplied method. * * This method will query all available modules, check if the method name exists for that module, and if so, call the method and trap the * return value. * * @param string method name * @param mixed optional return value. * @return array of matching module names */ public function module_list_by_method($method, $returnvalue = TRUE) { if (empty($method)) { return; } $this->_load_cache(); if (!isset($this->_data['methods']) || !isset($this->_data['methods'][$method])) { debug_buffer('start building module method cache'); if (!isset($this->_data['methods'])) { $this->_data['methods'] = array(); } $installed_modules = ModuleOperations::get_instance()->GetInstalledModules(); $loaded_modules = ModuleOperations::get_instance()->GetLoadedModules(); $this->_data['methods'][$method] = array(); foreach ($installed_modules as $onemodule) { $loaded_it = FALSE; $object = null; if (isset($loaded_modules[$onemodule])) { $object = $loaded_modules[$onemodule]; } else { $object = ModuleOperations::get_instance()->get_module_instance($onemodule); $loaded_it = TRUE; } if (!$object) { continue; } if (!method_exists($object, $method)) { continue; } // now do the test $res = $object->{$method}(); $this->_data['methods'][$method][$onemodule] = $res; // if( $loaded_it ) // { // debug_display('unload '.$onemodule); // ModuleOperations::get_instance()->unload_module($onemodule); // } } // store it. debug_buffer('done building module method cache'); $this->_save_cache(); } $res = null; if (is_array($this->_data['methods'][$method]) && count($this->_data['methods'][$method])) { $res = array(); foreach ($this->_data['methods'][$method] as $key => $value) { if ($value == $returnvalue) { $res[] = $key; } } } return $res; }
function DisplaySectionPages($section) { $gCms = cmsms(); if (count($this->menuItems) < 1) { // menu should be initialized before this gets called. // TODO: try to do initialization. // Problem: current page selection, url, etc? return -1; } $firstmodule = true; foreach ($this->menuItems[$section]['children'] as $thisChild) { $thisItem = $this->menuItems[$thisChild]; if (!$thisItem['show_in_menu'] || strlen($thisItem['url']) < 1) { continue; } // separate system modules from the rest. if (preg_match('/module=([^&]+)/', $thisItem['url'], $tmp)) { if (!ModuleOperations::get_instance()->IsSystemModule($tmp[1]) && $firstmodule == true) { echo "<hr width=\"90%\"/>"; $firstmodule = false; } } echo "<div class=\"itemmenucontainer\">\n"; echo '<div class="itemoverflow">'; echo "<a class=\"title-itemlink\" href=\"" . $thisItem['url'] . "\""; if (array_key_exists('target', $thisItem)) { echo ' rel="external"'; } echo ">" . $thisItem['title'] . "</a><br />\n"; echo '<p class="itemicon">'; $moduleIcon = false; $iconSpec = $thisChild; // handle module icons if (preg_match('/module=([^&]+)/', $thisItem['url'], $tmp)) { if ($tmp[1] == 'News') { $iconSpec = 'newsmodule'; } else { if ($tmp[1] == 'TinyMCE' || $tmp[1] == 'HTMLArea') { $iconSpec = 'wysiwyg'; } else { $imageSpec = dirname($this->cms->config['root_path'] . '/modules/' . $tmp[1] . '/images/icon.gif') . '/icon.gif'; if (file_exists($imageSpec)) { echo '<a href="' . $thisItem['url'] . '"><img class="itemicon" src="' . $this->cms->config['root_url'] . '/modules/' . $tmp[1] . '/images/' . '/icon.gif" alt="' . $thisItem['title'] . '" /></a>'; $moduleIcon = true; } else { $iconSpec = $this->TopParent($thisChild); } } } } if (!$moduleIcon) { if ($thisItem['url'] == $this->_viewsite_url) { $iconSpec = 'viewsite'; } echo '<a href="' . $thisItem['url'] . '">'; echo $this->DisplayImage('icons/topfiles/' . $iconSpec . '.gif', '' . $thisItem['title'] . '', '', '', 'itemicon'); echo '</a>'; } echo '</p>'; echo '<p class="itemtext">'; echo "<a class=\"itemlink\" href=\"" . $thisItem['url'] . "\""; if (array_key_exists('target', $thisItem)) { echo ' rel="external"'; } echo ">" . $thisItem['title'] . "</a><br />\n"; if (isset($thisItem['description']) && strlen($thisItem['description']) > 0) { echo $thisItem['description'] . "<br />"; } echo '</p>'; echo "</div>"; echo '</div>'; } }
/** * Get a handle to the CMS ModuleOperations object. If it does not yet * exist, this method will instantiate it. * * @final * @see ModuleOperations * @return ModuleOperations handle to the ModuleOperations object */ public function &GetModuleOperations() { return ModuleOperations::get_instance(); }
/** * Returns an array of modulenames with the specified capability * and which are installed and enabled, of course * * @final * @param an id specifying which capability to check for, could be "wysiwyg" etc. * @param associative array further params to get more detailed info about the capabilities. Should be syncronized with other modules of same type * @return array */ public final function GetModulesWithCapability($capability, $params = array()) { $result = array(); $tmp = ModuleOperations::get_modules_with_capability($capability, $params); if (is_array($tmp) && count($tmp)) { for ($i = 0; $i < count($tmp); $i++) { if (is_object($tmp[$i])) { $result[] = get_class($tmp[$i]); } else { $result[] = $tmp[$i]; } } } return $result; }
redirect($thisurl); } } // if access if ($action == "showmoduleabout") { $modinstance = ModuleOperations::get_instance()->get_module_instance($module, '', TRUE); if (is_object($modinstance)) { echo '<div class="pagecontainer">'; echo '<p class="pageheader">' . lang('moduleabout', array($module)) . '</p>'; echo $modinstance->GetAbout(); echo "</div>"; } echo '<p class="pageback"><a class="pageback" href="' . $thisurl . '">« ' . lang('back') . '</a></p>'; } else { if ($action == "showmodulehelp") { $modinstance = ModuleOperations::get_instance()->get_module_instance($module, '', TRUE); if (is_object($modinstance)) { $orig_lang = CmsNlsOperations::get_current_language(); $modulehelp_yourlang = lang('modulehelp_yourlang'); if (isset($_GET['lang']) && $orig_lang != 'en_US') { CmsNlsOperations::set_language(trim($_GET['lang'])); } echo '<div class="pagecontainer">'; // Commented out because of bug #914 and had to use code extra below // echo $themeObject->ShowHeader(lang('modulehelp', array($module)), '', lang('wikihelp', $module), 'wiki'); $header = '<div class="pageheader">'; $header .= lang('modulehelp', array($module)); $module_name = $modinstance->GetName(); // Turn ModuleName into _Module_Name $moduleName = preg_replace('/([A-Z])/', "_\$1", $module_name); $moduleName = preg_replace('/_([A-Z])_/', "\$1", $moduleName);
/** * @since 1.11 * @author calguy1000 * @internal * @ignore */ public static function smarty_internal_fetch_contentblock($params, $template) { $smarty = $template->smarty; $gCms = cmsms(); $contentobj = $gCms->variables['content_obj']; $page_id = cmsms()->get_variable('page_id'); if (is_object($contentobj)) { if (!$contentobj->IsPermitted()) { throw new CmsError403Exception(); } $id = ''; $modulename = ''; $action = ''; $inline = false; if (isset($_REQUEST['module'])) { $modulename = $_REQUEST['module']; } if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($_REQUEST['mact'])) { $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4); $modulename = isset($ary[0]) ? $ary[0] : ''; $id = isset($ary[1]) ? $ary[1] : ''; $action = isset($ary[2]) ? $ary[2] : ''; $inline = isset($ary[3]) && $ary[3] == 1 ? true : false; } if (isset($_REQUEST[$id . 'action'])) { $action = $_REQUEST[$id . 'action']; } else { if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } } //Only consider doing module processing if //a. There is no block parameter //b. then // 1. $id is cntnt01 or _preview_ // 2. or inline is false if (!isset($params['block']) && ($id == 'cntnt01' || $id == '_preview_' || $id != '' && $inline == false)) { // todo, would be neat here if we could get a list of only frontend modules. $installedmodules = ModuleOperations::get_instance()->GetInstalledModules(); if (count($installedmodules)) { // case insensitive module match. foreach ($installedmodules as $key) { if (strtolower($modulename) == strtolower($key)) { $modulename = $key; } } if (!isset($modulename) || empty($modulename)) { // no module specified. @trigger_error('Attempt to call a module action, without specifying a valid module name'); return self::content_return('', $params, $smarty); } $modobj = ModuleOperations::get_instance()->get_module_instance($modulename); if (!$modobj) { // module not found... couldn't even autoload it. @trigger_error('Attempt to access module ' . $modulename . ' which could not be found (is it properly installed and configured?'); return self::content_return('', $params, $smarty); } if ($modobj->IsPluginModule()) { @ob_start(); unset($params['block']); unset($params['label']); unset($params['wysiwyg']); unset($params['oneline']); unset($params['default']); unset($params['size']); unset($params['tab']); $params = array_merge($params, GetModuleParameters($id)); $returnid = ''; if (isset($params['returnid'])) { $returnid = $params['returnid']; } else { $returnid = $contentobj->Id(); } $oldcache = $smarty->caching; $smarty->caching = false; $result = $modobj->DoActionBase($action, $id, $params, $returnid); $smarty->caching = $oldcache; if ($result !== FALSE) { echo $result; } $modresult = @ob_get_contents(); @ob_end_clean(); return self::content_return($modresult, $params, $smarty); } else { @trigger_error('Attempt to access module ' . $key . ' which could not be found (is it properly installed and configured?'); return self::content_return("<!-- Not a tag module -->\n", $params, $smarty); } } } else { $block = isset($params['block']) ? $params['block'] : 'content_en'; $result = ''; $oldvalue = $smarty->caching; $smarty->caching = false; if ($id == '_preview_' || $page_id == '__CMS_PREVIEW_PAGE__') { // note: content precompile/postcompile events will not be triggererd in preview. $val = $contentobj->Show($block); $result = $smarty->fetch('string:' . $val); } else { $result = $smarty->fetch(str_replace(' ', '_', 'content:' . $block), '|' . $block, $contentobj->Id() . $block); } $smarty->caching = $oldvalue; return self::content_return($result, $params, $smarty); } } return _smarty_cms_function_content_return('', $params, $smarty); }
if (FALSE == is_writable(TMP_CACHE_LOCATION) || FALSE == is_writable(TMP_TEMPLATES_C_LOCATION)) { echo $themeObject->ShowErrors(lang('cachenotwritable')); } // warning: uber hack. $tmp = ModuleOperations::get_instance()->GetInstalledModules(); for ($i = 0; $i < count($tmp); $i++) { if (!ModuleOperations::get_instance()->IsSystemModule($tmp[$i])) { continue; } $mod = cms_utils::get_module($tmp[$i]); if (is_object($mod)) { break; } } $smarty->assign('mod', $mod); $modules = ModuleOperations::get_instance()->get_modules_with_capability('search'); if (is_array($modules) && count($modules)) { $tmp = array(); $tmp['-1'] = lang('none'); for ($i = 0; $i < count($modules); $i++) { $tmp[$modules[$i]] = $modules[$i]; } $smarty->assign('search_modules', $tmp); } $smarty->assign('languages', get_language_list()); $smarty->assign('templates', $templates); $tmp = module_meta::get_instance()->module_list_by_method('IsWYSIWYG'); $tmp2 = array(-1 => lang('none')); for ($i = 0; $i < count($tmp); $i++) { $tmp2[$tmp[$i]] = $tmp[$i]; }
/** * Reset the static route table. * * @since 1.11 * @author Robert Campbell * @internal */ public static function rebuild_static_routes() { // clear the route table. $db = cmsms()->GetDb(); $query = 'TRUNCATE TABLE ' . cms_db_prefix() . 'routes'; $db->Execute($query); // get content routes $query = 'SELECT content_id,page_url FROM ' . cms_db_prefix() . "content \n WHERE active=1 AND COALESCE(page_url,'') != ''"; $tmp = $db->GetArray($query); if (is_array($tmp) && count($tmp)) { for ($i = 0; $i < count($tmp); $i++) { $route = CmsRoute::new_builder($tmp[$i]['page_url'], '__CONTENT__', $tmp[$i]['content_id'], '', TRUE); cms_route_manager::add_static($route); } } // get the module routes $installed = ModuleOperations::get_instance()->GetInstalledModules(); foreach ($installed as $module_name) { $modobj = cms_utils::get_module($module_name); if (!$modobj) { continue; } $routes = $modobj->CreateStaticRoutes(); } }
if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($_REQUEST['mact'])) { $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4); $module = isset($ary[0]) ? $ary[0] : ''; $id = isset($ary[1]) ? $ary[1] : 'm1_'; $action = isset($ary[2]) ? $ary[2] : ''; } if (!$module) { trigger_error('Module action specified, but could not determine the module.'); redirect("index.php" . $urlext); } $modinst = ModuleOperations::get_instance()->get_module_instance($module); if (!$modinst) { trigger_error('Module ' . $module . ' not found in memory. This could indicate that the module is in need of upgrade or that there are other problems'); redirect("index.php" . $urlext); } if (get_preference($userid, 'use_wysiwyg') == '1' && $modinst->IsWYSIWYG()) { $htmlarea_flag = "true"; $htmlarea_replaceall = true; } $USE_THEME = true; if (isset($_REQUEST[$id . 'disable_buffer']) || isset($_REQUEST['disable_buffer'])) { $USE_THEME = false; } else { if (isset($_REQUEST[$id . 'disable_theme']) || isset($_REQUEST['disable_theme'])) { $USE_THEME = false; }
$tmp2 = array(-1 => lang('none')); for ($i = 0; $i < count($tmp); $i++) { $tmp2[$tmp[$i]] = $tmp[$i]; } $smarty->assign('wysiwyg_opts', $tmp2); # Syntaxhighlighter editor $tmp = module_meta::get_instance()->module_list_by_method('IsSyntaxHighlighter'); $tmp2 = array(-1 => lang('none')); for ($i = 0; $i < count($tmp); $i++) { $tmp2[$tmp[$i]] = $tmp[$i]; } $smarty->assign('syntax_opts', $tmp2); # Admin themes $smarty->assign('themes_opts', CmsAdminThemeBase::GetAvailableThemes()); # Modules $allmodules = ModuleOperations::get_instance()->GetInstalledModules(); $modules = array(); foreach ((array) $allmodules as $onemodule) { $modules[$onemodule] = $onemodule; } #Tabs $smarty->assign('tab_start', $themeObject->StartTabHeaders() . $themeObject->SetTabHeader('maintab', lang('useraccount'), 'maintab' == $tab ? true : false) . $themeObject->SetTabHeader('advancedtab', lang('userprefs'), 'advtab' == $tab ? true : false) . $themeObject->EndTabHeaders() . $themeObject->StartTabContent()); $smarty->assign('tabs_end', $themeObject->EndTabContent()); $smarty->assign('maintab_start', $themeObject->StartTab("maintab")); $smarty->assign('advancedtab_start', $themeObject->StartTab("advancedtab")); $smarty->assign('tab_end', $themeObject->EndTab()); # Prefs $smarty->assign('module_opts', $modules); $smarty->assign('gcb_wysiwyg', $gcb_wysiwyg); $smarty->assign('wysiwyg', $wysiwyg); $smarty->assign('syntaxhighlighter', $syntaxhighlighter);
/** * A convenience method to get the currently selected search module. * * @since 1.10 * @author calguy1000 * @return object or null */ public static function &get_search_module() { return ModuleOperations::get_instance()->GetSearchModule(); }
function cms_autoloader($classname) { //if( $classname != 'Smarty_CMS' && $classname != 'Smarty_Parser' && startswith($classname,'Smarty') ) return; $config = cmsms()->GetConfig(); // standard classes $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$classname}.php"); if (file_exists($fn)) { __cms_load($fn); return; } $lowercase = strtolower($classname); $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$lowercase}.inc.php"); if (file_exists($fn) && $classname != 'Content') { __cms_load($fn); return; } // standard interfaces $fn = cms_join_path($config['root_path'], 'lib', 'classes', "interface.{$classname}.php"); if (file_exists($fn)) { __cms_load($fn); return; } global $CMS_LAZYLOAD_MODULES; global $CMS_INSTALL_PAGE; if (!isset($CMS_LAZYLOAD_MODULES) || isset($CMS_INSTALL_PAGE)) { return; } // standard content types $fn = cms_join_path($config['root_path'], 'lib', 'classes', 'contenttypes', "{$classname}.inc.php"); if (file_exists($fn)) { __cms_load($fn); return; } // module loaded content types $contentops = ContentOperations::get_instance(); if ($contentops) { // why would this ever NOT be true.. dunno, but hey. $types = $contentops->ListContentTypes(); if (in_array(strtolower($classname), array_keys($types))) { $contentops->LoadContentType(strtolower($classname)); return; } } $fn = $config['root_path'] . "/modules/{$classname}/{$classname}.module.php"; if (file_exists($fn)) { __cms_load($fn); return; } $list = ModuleOperations::get_instance()->GetLoadedModules(); if (is_array($list) && count($list)) { foreach (array_keys($list) as $modname) { $fn = $config['root_path'] . "/modules/{$modname}/lib/class.{$classname}.php"; if (file_exists($fn)) { __cms_load($fn); return; } } } // module classes }
public static function install_module($module_meta, $is_upgrade = FALSE) { // get the module xml to a temporary location $mod = cms_utils::get_module('ModuleManager'); $xml_filename = modulerep_client::get_repository_xml($module_meta['filename'], $module_meta['size']); if (!$xml_filename) { return array(FALSE, $mod->Lang('error_downloadxml', $module_meta['filename'])); } // get the md5sum of the data from the server. $server_md5 = modulerep_client::get_module_md5($module_meta['filename']); // verify the md5 $dl_md5 = md5_file($xml_filename); if ($server_md5 != $dl_md5) { @unlink($xml_filename); return array(FALSE, $mod->Lang('error_checksum', array($server_md5, $dl_md5))); } // expand the xml $ops = cmsms()->GetModuleOperations(); if (!$ops->ExpandXMLPackage($xml_filename, 1)) { debug_display('error:'); die($ops->GetLastError()); return array(FALSE, $ops->GetLastError()); } @unlink($xml_filename); // update the database. ModuleOperations::get_instance()->QueueForInstall($module_meta['name']); return array(true, ''); }
public static function check_cge_modules() { $module_names = ModuleOperations::get_instance()->GetInstalledModules(); if (!count($module_names)) { throw new \LogicException('Could not get a list of installed modules'); } $out = array(); foreach ($module_names as $module_name) { if (ModuleOperations::get_instance()->IsSystemModule($module_name)) { continue; } // ignore system modules. $mod = \cms_utils::get_module($module_name); if (!$mod) { throw new \cg_notfoundException($module_name . ' could not be loaded'); } if (!$mod instanceof CGExtensions) { continue; } $out[] = self::check_module($module_name); } return $out; }
function search_Reindex(&$module) { audit('', $module->GetName(), 'Reindex Operation Started'); @set_time_limit(999); $module->DeleteAllWords(); // this could run out of memory... cmsms()->GetContentOperations()->LoadAllContent(TRUE, FALSE, TRUE); $full_list = cmsms()->GetHierarchyManager()->getFlatList(); foreach ($full_list as $node) { $cid = $node->get_tag('id'); $content = cmsms()->GetContentOperations()->LoadContentFromId($cid); if (!is_object($content)) { continue; } $parms = array('content' => $content); search_DoEvent($module, 'Core', 'ContentEditPost', $parms, TRUE); } // this could run out of memory very quickly. $modules = ModuleOperations::get_instance()->GetInstalledModules(); foreach ($modules as $name) { if (!$name || $name == 'Search') { continue; } $object = ModuleOperations::get_instance()->get_module_instance($name); if (!is_object($object)) { continue; } if (method_exists($object, 'SearchReindex')) { $object->SearchReindex($module); } } audit('', $module->GetName(), 'Reindex Operation Completed'); }