本文整理汇总了PHP中JLog类的典型用法代码示例。如果您正苦于以下问题:PHP JLog类的具体用法?PHP JLog怎么用?PHP JLog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JLog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete()
{
// Check for request forgeries
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
// Get items to remove from the request.
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
if (!is_array($cid) || count($cid) < 1) {
JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
} else {
// Get the model.
$model = $this->getModel();
// Make sure the item ids are integers
jimport('joomla.utilities.arrayhelper');
JArrayHelper::toInteger($cid);
// Remove the items.
if ($model->delete($cid)) {
$this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
} else {
$this->setMessage($model->getError());
}
}
$version = new JVersion();
if ($version->isCompatible('3.0')) {
// Invoke the postDelete method to allow for the child class to access the model.
$this->postDeleteHook($model, $cid);
}
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
}
示例2: log
/**
* Logs with an arbitrary level.
*
* @param mixed $level The log level.
* @param string $message The log message.
* @param array $context Additional message context.
*
* @return null
*
* @since 4.0
* @throws InvalidArgumentException
*/
public function log($level, $message, array $context = array())
{
// Make sure the log level is valid
if (!array_key_exists($level, $this->priorityMap)) {
throw new InvalidArgumentException('An invalid log level has been given.');
}
// Map the level to Joomla's priority
$priority = $this->priorityMap[$level];
$category = null;
$date = null;
// If a message category is given, map it
if (!empty($context['category'])) {
$category = $context['category'];
}
// If a message timestamp is given, map it
if (!empty($context['date'])) {
$date = $context['date'];
}
// Joomla's logging API will only process a string or a JLogEntry object, if $message is an object without __toString() we can't use it
if (!is_string($message) && !$message instanceof \JLogEntry) {
if (!is_object($message) || !method_exists($message, '__toString')) {
throw new InvalidArgumentException('The message must be a string, a JLogEntry object, or an object implementing the __toString() method.');
}
$message = (string) $message;
}
$this->logger->add($message, $priority, $category, $date, $context);
}
示例3: log
/**
* Logs an entry
*
* @param array|string $entry
* @see JLog::addEntry options
* @return mixed
*/
public function log($entry, $level = LOG_LEVEL_INFO)
{
if (!is_array($entry)) {
$entry = array('comment' => $entry, 'level' => $level);
}
$this->_log->addEntry($entry);
return $this;
}
示例4: fetchElement
/**
* Fetch a filelist element
*
* @param string $name Element name
* @param string $value Element value
* @param JXMLElement &$node JXMLElement node object containing the settings for the element
* @param string $control_name Control name
*
* @return string
*
* @deprecated 12.1 Use JFormFieldFileList::getOptions instead
* @since 11.1
*/
public function fetchElement($name, $value, &$node, $control_name)
{
// Deprecation warning.
JLog::add('JElementFileList::fetchElement() is deprecated.', JLog::WARNING, 'deprecated');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
// path to images directory
$path = JPATH_ROOT . '/' . $node->attributes('directory');
$filter = $node->attributes('filter');
$exclude = $node->attributes('exclude');
$stripExt = $node->attributes('stripext');
$files = JFolder::files($path, $filter);
$options = array();
if (!$node->attributes('hide_none')) {
$options[] = JHtml::_('select.option', '-1', JText::_('JOPTION_DO_NOT_USE'));
}
if (!$node->attributes('hide_default')) {
$options[] = JHtml::_('select.option', '', JText::_('JOPTION_USE_DEFAULT'));
}
if (is_array($files)) {
foreach ($files as $file) {
if ($exclude) {
if (preg_match(chr(1) . $exclude . chr(1), $file)) {
continue;
}
}
if ($stripExt) {
$file = JFile::stripExt($file);
}
$options[] = JHtml::_('select.option', $file, $file);
}
}
return JHtml::_('select.genericlist', $options, $control_name . '[' . $name . ']', array('id' => 'param' . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value));
}
示例5: publish
public function publish()
{
// Check for request forgeries
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
// Get items to publish from the request.
$id = JFactory::getApplication()->input->getInt('id', 0);
$data = array('publish' => 1, 'unpublish' => 0);
$task = $this->getTask();
$value = JArrayHelper::getValue($data, $task, 0, 'int');
if (!$id) {
JLog::add(JText::_('COM_DJCATALOG2_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
} else {
// Get the model.
$model = $this->getModel();
// Make sure the item ids are integers
$cid = array($id);
JArrayHelper::toInteger($cid);
// Publish the items.
if (!$model->publish($cid, $value)) {
JLog::add($model->getError(), JLog::WARNING, 'jerror');
} else {
if ($value == 1) {
$ntext = 'COM_DJCATALOG2_ITEM_PUBLISHED';
} else {
$ntext = 'COM_DJCATALOG2_ITEM_UNPUBLISHED';
}
$this->setMessage(JText::_($ntext));
}
}
$this->setRedirect(JRoute::_(DJCatalogHelperRoute::getMyItemsRoute(), false));
}
示例6: __construct
/**
* Constructor
*
* @param mixed $response The Response data.
* @param string $message The main response message.
* @param boolean $error True, if the success flag shall be set to false, defaults to false.
*
* @since 2.5
* @deprecated 4.0 Use JResponseJson instead.
*/
public function __construct($response = null, $message = null, $error = false)
{
JLog::add('Class JJsonResponse is deprecated. Use class JResponseJson instead.', JLog::WARNING, 'deprecated');
$this->message = $message;
// Get the message queue.
$messages = JFactory::getApplication()->getMessageQueue();
// Build the sorted messages list.
if (is_array($messages) && count($messages)) {
foreach ($messages as $message) {
if (isset($message['type']) && isset($message['message'])) {
$lists[$message['type']][] = $message['message'];
}
}
}
// If messages exist add them to the output.
if (isset($lists) && is_array($lists)) {
$this->messages = $lists;
}
// Check if we are dealing with an error.
if ($response instanceof Exception) {
// Prepare the error response.
$this->success = false;
$this->error = true;
$this->message = $response->getMessage();
} else {
// Prepare the response data.
$this->success = !$error;
$this->error = $error;
$this->data = $response;
}
}
示例7: getInput
/**
* Method to get the user group field input markup.
*
* @return string The field input markup.
*
* @since 11.1
*/
protected function getInput()
{
JLog::add('JFormFieldUsergroup is deprecated. Use JFormFieldUserGroupList instead.', JLog::WARNING, 'deprecated');
$options = array();
$attr = '';
// Initialize some field attributes.
$attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
$attr .= $this->disabled ? ' disabled' : '';
$attr .= $this->size ? ' size="' . $this->size . '"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required aria-required="true"' : '';
$attr .= $this->autofocus ? ' autofocus' : '';
// Initialize JavaScript field attributes.
$attr .= !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
$attr .= !empty($this->onclick) ? ' onclick="' . $this->onclick . '"' : '';
// Iterate through the children and build an array of options.
foreach ($this->element->children() as $option) {
// Only add <option /> elements.
if ($option->getName() != 'option') {
continue;
}
$disabled = (string) $option['disabled'];
$disabled = $disabled == 'true' || $disabled == 'disabled' || $disabled == '1';
// Create a new option object based on the <option /> element.
$tmp = JHtml::_('select.option', (string) $option['value'], trim((string) $option), 'value', 'text', $disabled);
// Set some option attributes.
$tmp->class = (string) $option['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string) $option['onclick'];
// Add the option object to the result set.
$options[] = $tmp;
}
return JHtml::_('access.usergroup', $this->name, $this->value, $attr, $options, $this->id);
}
示例8: __construct
/**
* Constructor
*
* @param JDatabaseDriver $db Database driver object.
*
* @since 11.1
* @deprecated 13.3 Use SQL queries to interact with the session table.
*/
public function __construct(JDatabaseDriver $db)
{
JLog::add('JTableSession is deprecated. Use SQL queries directly to interact with the session table.', JLog::WARNING, 'deprecated');
parent::__construct('#__session', 'session_id', $db);
$this->guest = 1;
$this->username = '';
}
示例9: getFeedParser
/**
* Get a parsed XML Feed Source
*
* @param string $url Url for feed source.
* @param integer $cache_time Time to cache feed for (using internal cache mechanism).
*
* @return mixed SimplePie parsed object on success, false on failure.
*
* @since 12.2
* @deprecated 4.0 Use JFeedFactory($url) instead.
*
* @note In 3.2 will be proxied to JFeedFactory()
*/
public static function getFeedParser($url, $cache_time = 0)
{
JLog::add(__METHOD__ . ' is deprecated. Use JFeedFactory() or supply Simple Pie instead.', JLog::WARNING, 'deprecated');
$cache = JFactory::getCache('feed_parser', 'callback');
if ($cache_time > 0)
{
$cache->setLifeTime($cache_time);
}
$simplepie = new SimplePie(null, null, 0);
$simplepie->enable_cache(false);
$simplepie->set_feed_url($url);
$simplepie->force_feed(true);
$contents = $cache->get(array($simplepie, 'init'), null, false, false);
if ($contents)
{
return $simplepie;
}
JLog::add(JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA'), JLog::WARNING, 'jerror');
return false;
}
示例10: delete
public function delete()
{
// Check for request forgeries
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
// Get items to remove from the request.
$id = JFactory::getApplication()->input->getInt('id', 0);
if (!$id) {
JLog::add(JText::_('COM_DJREVIEWS_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
return false;
} else {
// Get the model.
$model = $this->getModel();
// Make sure the item ids are integers
jimport('joomla.utilities.arrayhelper');
$cid = array($id);
JArrayHelper::toInteger($cid);
// Remove the items.
if ($model->delete($cid)) {
$this->setMessage(JText::_('COM_DJREVIEWS_ITEM_DELETED'));
} else {
$this->setMessage($model->getError());
}
}
require_once JPath::clean(JPATH_ROOT . '/components/com_djreviews/lib/api.php');
DJReviewsAPI::recalculate();
return true;
}
示例11: onUserLoginFailure
function onUserLoginFailure($response)
{
jimport('joomla.error.log');
$log = JLog::getInstance();
$errorlog = array();
switch ($response['status']) {
case JAUTHENTICATE_STATUS_CANCEL:
$errorlog['status'] = $response['type'] . " CANCELED: ";
$errorlog['comment'] = $response['error_message'];
$log->addEntry($errorlog);
break;
case JAUTHENTICATE_STATUS_FAILURE:
$errorlog['status'] = $response['type'] . " FAILURE: ";
if ($this->params->get('log_username', 0)) {
$errorlog['comment'] = $response['error_message'] . ' ("' . $response['username'] . '")';
} else {
$errorlog['comment'] = $response['error_message'];
}
$log->addEntry($errorlog);
break;
default:
$errorlog['status'] = $response['type'] . " UNKNOWN ERROR: ";
$errorlog['comment'] = $response['error_message'];
$log->addEntry($errorlog);
break;
}
}
示例12: read
public function read()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get items to publish from the request.
$cid = $this->input->get('cid', array(), 'array');
$data = array('read' => 1, 'notread' => 0);
$task = $this->getTask();
$value = ArrayHelper::getValue($data, $task, 0, 'int');
$redirectOptions = array("view" => "notifications");
// Make sure the item ids are integers
ArrayHelper::toInteger($cid);
if (empty($cid)) {
$this->displayNotice(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), $redirectOptions);
return;
}
try {
$model = $this->getModel();
$model->read($cid, $value);
} catch (RuntimeException $e) {
$this->displayWarning($e->getMessage(), $redirectOptions);
return;
} catch (Exception $e) {
JLog::add($e->getMessage());
throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM'));
}
if ($value == 1) {
$msg = $this->text_prefix . '_N_ITEMS_READ';
} else {
$msg = $this->text_prefix . '_N_ITEMS_NOT_READ';
}
$this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions);
}
示例13: preflight
public function preflight($type, $parent)
{
if (!JFile::exists(JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php')) {
JLog::add('MijoShop component (com_mijoshop) is not installed. Please, install it first.', JLog::ERROR, 'jerror');
return false;
}
}
示例14: save
public function save($key = null, $urlVar = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$data = $this->input->post->get('jform', array(), 'array');
$itemId = ArrayHelper::getValue($data, "id");
$redirectData = array("task" => $this->getTask(), "id" => $itemId);
$model = $this->getModel();
/** @var $model GamificationModelRank */
$form = $model->getForm($data, false);
/** @var $form JForm */
if (!$form) {
throw new Exception(JText::_("COM_GAMIFICATION_ERROR_FORM_CANNOT_BE_LOADED"), 500);
}
// Validate the form
$validData = $model->validate($form, $data);
// Check for errors
if ($validData === false) {
$this->displayNotice($form->getErrors(), $redirectData);
return;
}
try {
$itemId = $model->save($validData);
$redirectData["id"] = $itemId;
} catch (Exception $e) {
JLog::add($e->getMessage());
throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM'));
}
$this->displayMessage(JText::_('COM_GAMIFICATION_LEVEL_SAVED'), $redirectData);
}
示例15: delete
/**
* Remove an item.
*
* @throws Exception
* @return void
*
* @since 12.2
*/
public function delete()
{
// Check for request forgeries
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
/* @var $app JApplicationAdministrator */
// Gets the data from the form
$cid = $this->input->post->get('cid', array(), 'array');
$cid = Joomla\Utilities\ArrayHelper::toInteger($cid);
$urlId = $app->getUserState("url.id");
$redirectData = array("view" => "url", "layout" => "edit", "id" => $urlId);
if (!$cid) {
$this->displayWarning(JText::_("COM_ITPMETA_ERROR_INVALID_ITEMS"), $redirectData);
return;
}
try {
$model = $this->getModel();
$model->delete($cid);
} catch (Exception $e) {
JLog::add($e->getMessage());
throw new Exception(JText::_('COM_ITPMETA_ERROR_SYSTEM'));
}
$msg = JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid));
$this->displayMessage($msg, $redirectData);
}