Skip to content

Commit

Permalink
README.md resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshekher committed Apr 4, 2018
2 parents 834ece3 + 293ad43 commit 0cbd726
Show file tree
Hide file tree
Showing 15 changed files with 997 additions and 469 deletions.
131 changes: 24 additions & 107 deletions Mentions.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php

e107::lan('mentions', 'front', true);
if ( ! defined('e107_INIT')) {
exit;
}

class Mentions
{

protected $prefs;
protected $parse;

protected $dataVars = [];

/**
* Mentions constructor.
*/
Expand All @@ -19,106 +18,14 @@ public function __construct()
$this->parse = e107::getParser();
}


/**
* Magic set
* @param $name
* @param $value
*/
protected function __set($name, $value)
{
$this->set($name, $value);
}


/**
* Magic get
* @param $name
*
* @return mixed|null
*/
protected function __get($name)
{
return $this->get($name);
}


/**
* Magic isset
*
* @param $name
*
* @return bool
*/
protected function __isset($name)
{
if (property_exists($this, $name)) {
return isset($this->$name);
}

if (array_key_exists($name, $this->dataVars)) {
return isset($this->dataVars[$name]);
}
}


/**
* Magic unset
* @param $name
*/
protected function __unset($name)
{
if (property_exists($this, $name)) {
unset($this->$name);
} elseif (array_key_exists($name, $this->dataVars)) {
unset($this->dataVars[$name]);
}
}

/**
* Gets property
* @param $name
*
* @return mixed|null
*/
protected function get($name)
{
if (property_exists($this, $name)) {
return $this->$name;
}

if (array_key_exists($name, $this->dataVars)) {
return $this->dataVars[$name];
}

return null;
}


/**
* Sets property
* @param $name
* @param $value
*/
protected function set($name, $value)
{
if (property_exists($this, $name)) {
$this->$name = $value;
}

$this->dataVars[$name] = $value;

}




/**
* Converts mention to user profile link if user matched exists in database
* Converts valid user mention to user profile-link
*
* @param $mention
* @param string $mention
* User mention string
*
* @return string
* User mention profile-link or string prepended with '@'
*/
protected function createUserLinkFrom($mention)
{
Expand All @@ -137,11 +44,13 @@ protected function createUserLinkFrom($mention)


/**
* Get user data drom database
* Get user data from database
*
* @param $mention
* @param string $mention
* String prepended with '@' which the parsing logic captured.
*
* @return array
* User details from 'user' table - user_id, user_name, user_email
*/
protected function getUserData($mention)
{
Expand All @@ -154,11 +63,12 @@ protected function getUserData($mention)


/**
* Strips '@' sign from mention
*
* @param $mention
* Strips '@' sign from mention string
*
* @param string $mention
* String prepended with '@'.
* @return string
* String striped clean of '@'
*/
protected function stripAtFrom($mention)
{
Expand All @@ -167,14 +77,21 @@ protected function stripAtFrom($mention)


/**
* Does Debug logging
* Does Debug logging by writing a log file to the plugin directory
*
* @param string $content
* @param string|array $content
* The data to be logged - can be passed as string or array.
* @param string $logname
* The name of log that need to be written to file-system.
*/
protected function log($content, $logname = 'mentions')
{
$path = e_PLUGIN . 'mentions/' . $logname . '.txt';

if (is_array($content)) {
$content = var_export($content, true);
}

file_put_contents($path, $content . "\n", FILE_APPEND);
unset($path, $content);
}
Expand Down
Loading

0 comments on commit 0cbd726

Please sign in to comment.