本文整理汇总了PHP中ContentHelper::resetHits方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentHelper::resetHits方法的具体用法?PHP ContentHelper::resetHits怎么用?PHP ContentHelper::resetHits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentHelper
的用法示例。
在下文中一共展示了ContentHelper::resetHits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveContent
//.........这里部分代码省略.........
// Build parameter INI string
if (is_array($params)) {
$txt = array();
foreach ($params as $k => $v) {
$txt[] = "{$k}={$v}";
}
$row->attribs = implode("\n", $txt);
}
// Get metadata string
$metadata = JRequest::getVar('meta', null, 'post', 'array');
if (is_array($metadata)) {
$txt = array();
foreach ($metadata as $k => $v) {
if ($k == 'description') {
$row->metadesc = $v;
} elseif ($k == 'keywords') {
$row->metakey = $v;
} else {
$txt[] = "{$k}={$v}";
}
}
$row->metadata = implode("\n", $txt);
}
// Prepare the content for saving to the database
ContentHelper::saveContentPrep($row);
// Make sure the data is valid
if (!$row->check()) {
JError::raiseError(500, $db->stderr());
return false;
}
// Increment the content version number
$row->version++;
$result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $isNew));
if (in_array(false, $result, true)) {
JError::raiseError(500, $row->getError());
return false;
}
// Store the content to the database
if (!$row->store()) {
JError::raiseError(500, $db->stderr());
return false;
}
// Check the article and update item order
$row->checkin();
$row->reorder('catid = ' . (int) $row->catid . ' AND state >= 0');
/*
* We need to update frontpage status for the article.
*
* First we include the frontpage table and instantiate an instance of it.
*/
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_frontpage' . DS . 'tables' . DS . 'frontpage.php';
$fp = new TableFrontPage($db);
// Is the article viewable on the frontpage?
if (JRequest::getVar('frontpage', 0, '', 'int')) {
// Is the item already viewable on the frontpage?
if (!$fp->load($row->id)) {
// Insert the new entry
$query = 'INSERT INTO #__content_frontpage' . ' VALUES ( ' . (int) $row->id . ', 1 )';
$db->setQuery($query);
if (!$db->query()) {
JError::raiseError(500, $db->stderr());
return false;
}
$fp->ordering = 1;
}
} else {
// Delete the item from frontpage if it exists
if (!$fp->delete($row->id)) {
$msg .= $fp->stderr();
}
$fp->ordering = 0;
}
$fp->reorder();
$cache =& JFactory::getCache('com_content');
$cache->clean();
$dispatcher->trigger('onAfterContentSave', array(&$row, $isNew));
switch ($task) {
case 'go2menu':
$mainframe->redirect('index.php?option=com_menus&menutype=' . $menu);
break;
case 'go2menuitem':
$mainframe->redirect('index.php?option=com_menus&menutype=' . $menu . '&task=edit&id=' . $menuid);
break;
case 'menulink':
ContentHelper::menuLink($redirect, $row->id);
break;
case 'resethits':
ContentHelper::resetHits($redirect, $row->id);
break;
case 'apply':
$msg = JText::sprintf('SUCCESSFULLY SAVED CHANGES TO ARTICLE', $row->title);
$mainframe->redirect('index.php?option=com_content§ionid=' . $redirect . '&task=edit&cid[]=' . $row->id, $msg);
break;
case 'save':
default:
$msg = JText::sprintf('Successfully Saved Article', $row->title);
$mainframe->redirect('index.php?option=com_content§ionid=' . $redirect, $msg);
break;
}
}