本文整理汇总了PHP中MenusHelper::cleanCache方法的典型用法代码示例。如果您正苦于以下问题:PHP MenusHelper::cleanCache方法的具体用法?PHP MenusHelper::cleanCache怎么用?PHP MenusHelper::cleanCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenusHelper
的用法示例。
在下文中一共展示了MenusHelper::cleanCache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMenuJ15
//.........这里部分代码省略.........
$params = new JParameter('');
$params->bind($menu['params']);
$query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `ordering`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES
($parentid, 'kunenamenu', {$this->db->quote($menu['name'])}, {$this->db->quote($menu['alias'])}, {$this->db->quote($menu['link'])}, 'component', 1, 0, $component_id, 0, 1, 0, '0000-00-00 00:00:00', 0, 0, {$menu['access']}, 0, {$this->db->quote($params->toString('INI'))}, 0, 0, 0);";
$this->db->setQuery ( $query );
$this->db->query ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
$parentid = ( int ) $this->_db->insertId ();
}
// Submenu (shown in Kunena)
$defaultmenu = 0;
$ordering = 0;
foreach ($submenu as $menuitem) {
$ordering++;
// $query = "SELECT id FROM `#__menu` WHERE `link`={$this->db->quote($menuitem['link'])} AND `menutype`='kunenamenu';";
// $this->db->setQuery ( $query );
// $id = ( int ) $this->db->loadResult ();
// if ($this->db->getErrorNum ())
// throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
$id = 0;
if (! $id) {
$params = new JParameter('');
$params->bind($menuitem['params']);
$query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `ordering`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES
($id, 'kunenamenu', {$this->db->quote($menuitem['name'])}, {$this->db->quote($menuitem['alias'])}, {$this->db->quote($menuitem['link'])},'component', 1, $parentid, $component_id, 1, $ordering, 0, '0000-00-00 00:00:00', 0, 0, {$menuitem['access']}, 0, {$this->db->quote($params->toString('INI'))}, 0, 0, 0);";
$this->db->setQuery ( $query );
$this->db->query ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
$id = ( int ) $this->_db->insertId ();
if (!$defaultmenu || (isset($menuitem['default']) && $config->fbdefaultpage == $menuitem['default'])) {
$defaultmenu = $id;
}
}
}
if ($defaultmenu) {
$query = "UPDATE `#__menu` SET `link`={$this->db->quote($menu['link']."&defaultmenu=$defaultmenu")} WHERE id={$parentid}";
$this->db->setQuery ( $query );
$this->db->query ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
}
$query = "SELECT id FROM `#__modules` WHERE `position`='kunena_menu';";
$this->db->setQuery ( $query );
$moduleid = ( int ) $this->db->loadResult ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
// Check if it exists, if not create it
if (! $moduleid) {
// Create a module for the Kunena menu
$query = "REPLACE INTO `#__modules` (`id`, `title`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `published`, `module`, `numnews`, `access`, `showtitle`, `params`, `iscore`, `client_id`, `control`) VALUES
($moduleid, {$this->db->quote(JText::_ ( 'COM_KUNENA_MENU_TITLE' ))}, '', 0, 'kunena_menu', 0, '0000-00-00 00:00:00', 1, 'mod_mainmenu', 0, 0, 0, 'menutype=kunenamenu\nmenu_style=list\nstartLevel=1\nendLevel=2\nshowAllChildren=1\nwindow_open=\nshow_whitespace=0\ncache=1\ntag_id=\nclass_sfx=\nmoduleclass_sfx=\nmaxdepth=10\nmenu_images=0\nmenu_images_align=0\nmenu_images_link=0\nexpand_menu=0\nactivate_parent=0\nfull_active_id=0\nindent_image=0\nindent_image1=\nindent_image2=\nindent_image3=\nindent_image4=\nindent_image5=\nindent_image6=\nspacer=\nend_spacer=\n\n', 0, 0, '');";
$this->db->setQuery ( $query );
$this->db->query ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
// Now get the module id again, we need it, in order to publish the menu module
$query = "SELECT id FROM `#__modules` WHERE `position`='kunena_menu';";
$this->db->setQuery ( $query );
$moduleid = ( int ) $this->db->loadResult ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
// Now publish the module
$query = "REPLACE INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES ($moduleid, 0);";
$this->db->setQuery ( $query );
$this->db->query ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
}
// Finally add forum menu link to default menu
$jmenu = JMenu::getInstance('site');
$dmenu = $jmenu->getDefault();
$query = "SELECT id, name, type, link, published FROM `#__menu` WHERE `alias` IN ('forum', 'kunenaforum', {$this->db->quote(JText::_ ( 'COM_KUNENA_MENU_FORUM_ALIAS' ))}) AND `menutype`={$this->db->quote($dmenu->menutype)}";
$this->db->setQuery ( $query, 0, 1 );
$menualias = $this->db->loadObject ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
// We do not want to replace users own menu items (just alias or deprecated link to Kunena)
if (!$menualias || $menualias->type == 'menulink' || $menualias->link == 'index.php?option=com_kunena') {
$id = $menualias ? intval($menualias->id) : 0;
// Keep state (default=unpublished) and name (default=Forum)
$published = $menualias ? intval($menualias->published) : 0;
$name = $menualias ? $menualias->name : $menu['name'];
$query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES
($id, {$this->db->quote($dmenu->menutype)}, {$this->db->quote($name)}, 'kunenaforum', 'index.php?Itemid={$parentid}', 'menulink', {$published}, 0, 0, 0, 0, '0000-00-00 00:00:00', 0, 0, {$menu['access']}, 0, 'menu_item=$parentid{$menu['params']}\r\n\r\n', 0, 0, 0);";
$this->db->setQuery ( $query );
$this->db->query ();
if ($this->db->getErrorNum ())
throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
}
require_once (JPATH_ADMINISTRATOR . '/components/com_menus/helpers/helper.php');
MenusHelper::cleanCache ();
}
示例2: deleteByType
/**
* Delete menu items by type
*/
function deleteByType($type = '')
{
if (!$type) {
return false;
}
$db =& $this->getDBO();
$query = 'DELETE FROM #__menu' . ' WHERE menutype = ' . $db->Quote($type);
$db->setQuery($query);
if (!$db->query()) {
$this->setError($menuTable->getErrorMsg());
return false;
}
// clean cache
MenusHelper::cleanCache();
return true;
}
示例3: delete
/**
* Delete one or more menu items
* @param mixed int or array of id values
*/
function delete($ids)
{
JArrayHelper::toInteger($ids);
$db =& $this->getDBO();
if (count($ids)) {
// Delete associated module and template mappings
$where = 'WHERE menuid = ' . implode(' OR menuid = ', $ids);
$query = 'DELETE FROM #__modules_menu ' . $where;
$db->setQuery($query);
if (!$db->query()) {
$this->setError($menuTable->getErrorMsg());
return false;
}
// Set any alias menu types to not point to missing menu items
$query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = ' . implode(' OR id = ', $ids) . ')';
$db->setQuery($query);
if (!$db->query()) {
$this->setError($db->getErrorMsg());
return false;
}
// Delete the menu items
$where = 'WHERE id = ' . implode(' OR id = ', $ids);
$query = 'DELETE FROM #__menu ' . $where;
$db->setQuery($query);
if (!$db->query()) {
$this->setError($db->getErrorMsg());
return false;
}
}
// clean cache
MenusHelper::cleanCache();
return true;
}