Spade

Mini Shell

Directory:~$ /home/lmsyaran/www/pusher/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/www/pusher/helpers.tar

html/utility.php000064400000005212151167606750007742 0ustar00<?php
/**
 * This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
 *
 * @package     Joomla.Site
 * @subpackage  com_jea
 * @copyright   Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * Jea Utility helper
 *
 * @package     Joomla.Site
 * @subpackage  com_jea
 *
 * @since       2.0
 */
abstract class JHtmlUtility
{
	/**
	 * @var Joomla\Registry\Registry
	 */
	protected static $params = null;

	/**
	 * Format price following the component configuration.
	 * If price is empty, return a default string value.
	 *
	 * @param   float|int  $price    The price as number
	 * @param   string     $default  Default value if price equals 0
	 *
	 * @return  string
	 */
	public static function formatPrice($price = 0, $default = '')
	{
		$params = self::getParams();

		if (! empty($price))
		{
			$currency_symbol = $params->get('currency_symbol',
'&euro;');
			$price = self::formaNumber($price);

			// Is currency symbol before or after price ?
			if ($params->get('symbol_position', 1))
			{
				$price = $price . ' ' . $currency_symbol;
			}
			else
			{
				$price = $currency_symbol . ' ' . $price;
			}

			return $price;
		}
		else
		{
			return $default;
		}
	}

	/**
	 * Format surface following the component configuration.
	 * If surface is empty, return a default string value.
	 *
	 * @param   float|int  $surface  The surface as number
	 * @param   string     $default  Default value if surface equals 0
	 *
	 * @return  string
	 */
	public static function formatSurface($surface = 0, $default =
'')
	{
		$params = self::getParams();

		if (!empty($surface))
		{
			$surfaceMeasure = $params->get('surface_measure',
'm&sup2;');
			$surface = self::formaNumber($surface);

			return $surface . ' ' . $surfaceMeasure;
		}

		return $default;
	}

	/**
	 * Format number following the component configuration.
	 *
	 * @param   float|int  $number  The number to format
	 *
	 * @return  string
	 */
	public static function formaNumber($number = O)
	{
		$params = self::getParams();
		$number = (float) $number;
		$decimal_separator = $params->get('decimals_separator',
',');
		$thousands_separator = $params->get('thousands_separator',
' ');
		$decimals = (int) $params->get('decimals_number',
'0');

		return number_format($number, $decimals, $decimal_separator,
$thousands_separator);
	}

	/**
	 * Get JEA params
	 *
	 * @return Joomla\Registry\Registry
	 */
	protected static function getParams()
	{
		if (self::$params == null)
		{
			self::$params = JComponentHelper::getParams('com_jea');
		}

		return self::$params;
	}
}
html/amenities.php000064400000005776151167606750010234 0ustar00<?php
/**
 * This file is part of Joomla Estate Agency - Joomla! extension for real
estate agency
 *
 * @package     Joomla.Site
 * @subpackage  com_jea
 * @copyright   Copyright (C) 2008 - 2020 PHILIP Sylvain. All rights
reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\Utilities\ArrayHelper;

/**
 * Jea Amenities HTML helper
 *
 * @package     Joomla.Site
 * @subpackage  com_jea
 *
 * @since       2.0
 */
abstract class JHtmlAmenities
{
	/**
	 * @var stdClass[]
	 */
	protected static $amenities = null;

	/**
	 * Method to get an HTML list of amenities
	 *
	 * @param   mixed   $value   string or array of amenities ids
	 * @param   string  $format  The wanted format (ol, li, raw (default))
	 *
	 * @return string HTML for the list.
	 */
	static public function bindList($value = 0, $format = 'raw')
	{
		if (is_string($value) && !empty($value))
		{
			$ids = explode('-', $value);
		}
		elseif (empty($value))
		{
			$ids = array();
		}
		else
		{
			$ids = ArrayHelper::toInteger($value);
		}

		$html = '';
		$amenities = self::getAmenities();
		$items = array();

		foreach ($amenities as $row)
		{
			if (in_array($row->id, $ids))
			{
				if ($format == 'ul')
				{
					$items[] = "<li>{$row->value}</li>\n";
				}
				else
				{
					$items[] = $row->value;
				}
			}
		}

		if ($format == 'ul')
		{
			$html = "<ul>\n" . implode("\n", $items) .
"</ul>\n";
		}
		else
		{
			$html = implode(', ', $items);
		}

		return $html;
	}

	/**
	 * Return HTML list of amenities as checkboxes
	 *
	 * @param   array   $values    The checkboxes values
	 * @param   string  $name      The attribute name for the checkboxes
	 * @param   string  $idSuffix  An optional ID suffix for the checkboxes
	 *
	 * @return string Html list
	 */
	static public function checkboxes($values = array(), $name =
'amenities', $idSuffix = '')
	{
		$amenities = self::getAmenities();
		$values = (array) $values;
		$html = '';

		if (!empty($amenities))
		{
			$html .= "<ul>\n";

			foreach ($amenities as $row)
			{
				$checked = '';
				$id = 'amenity' . $row->id . $idSuffix;

				if (in_array($row->id, $values))
				{
					$checked = 'checked="checked"';
				}

				$html .= '<li><input name="' . $name .
'[]" id="' . $id . '"
type="checkbox" value="' . $row->id . '"
' . $checked . ' /> '
						. '<label for="' . $id . '">' .
$row->value . '</label></li>' . "\n";
			}

			$html .= "</ul>";
		}

		return $html;
	}

	/**
	 * Get Jea amenities from database
	 *
	 * @return array An array of amenity row objects
	 */
	static public function getAmenities()
	{
		if (self::$amenities === null)
		{
			$db = JFactory::getDbo();
			$query = $db->getQuery(true);
			$query->select('a.id , a.value');
			$query->from('#__jea_amenities AS a');
			$query->where('a.language in (' .
$db->quote(JFactory::getLanguage()->getTag()) . ',' .
$db->quote('*') . ')');
			$query->order('a.ordering');
			$db->setQuery($query);

			self::$amenities = $db->loadObjectList();
		}

		return self::$amenities;
	}
}
color.php000064400000035546151171350140006406 0ustar00<?php
/**
 * mod_vertical_menu - Vertical Menu
 *
 * @author    Balint Polgarfi
 * @copyright 2014-2019 Offlajn.com
 * @license   https://gnu.org/licenses/gpl-2.0.html
 * @link      https://offlajn.com
 */
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');

if(!class_exists('OfflajnColorHelper')){

  class OfflajnColorHelper
  {
      /**
       *
       * Converts hexadecimal colors to RGB.
       *
       * @param string $hex Hexadecimal value. Accepts values with 3 or 6
numbers,
       * with or without #, e.g., CCC, #CCC, CCCCCC or #CCCCCC.
       *
       * @return array RGB values: 0 => R, 1 => G, 2 => B
       *
       */
      public function hex2rgb($hex)
      {
          // Remove #.
          if (strpos($hex, '#') === 0) {
              $hex = substr($hex, 1);
          }
  
          if (strlen($hex) == 3) {
              $hex .= $hex;
          }
  
          if (strlen($hex) != 6) {
              return false;
          }
  
          // Convert each tuple to decimal.
          $r = hexdec(substr($hex, 0, 2));
          $g = hexdec(substr($hex, 2, 2));
          $b = hexdec(substr($hex, 4, 2));
  
          return array($r, $g, $b);
      }
      
      public function hex2rgba($hex)
      {
          // Remove #.
          if (strpos($hex, '#') === 0) {
              $hex = substr($hex, 1);
          }
  
          if (strlen($hex) == 6) {
              $hex.='ff';
          }
  
          if (strlen($hex) != 8) {
              return false;
          }
  
          // Convert each tuple to decimal.
          $r = hexdec(substr($hex, 0, 2));
          $g = hexdec(substr($hex, 2, 2));
          $b = hexdec(substr($hex, 4, 2));
          $a = intval(hexdec(substr($hex, 6, 2))/2);
  
          return array($r, $g, $b, $a);
      }
      
      public function hex82hex($hex)
      {
          // Remove #.
          if (strpos($hex, '#') === 0) {
              $hex = substr($hex, 1);
          }
  
          if (strlen($hex) == 6) {
              $hex.='ff';
          }
  
          if (strlen($hex) != 8) {
              return false;
          }
          return array(substr($hex, 0, 6), substr($hex, 6, 2));
      }
  
      /**
       *
       * Converts hexadecimal colors to HSV.
       *
       * @param string $hex Hexadecimal value. Accepts values with 3 or 6
numbers,
       * with or without #, e.g., CCC, #CCC, CCCCCC or #CCCCCC.
       *
       * @return array HSV values: 0 => H, 1 => S, 2 => V
       *
       */
      public function hex2hsv($hex)
      {
          return $this->rgb2hsv($this->hex2rgb($hex));
      }
  
      /**
       *
       * Converts hexadecimal colors to HSL.
       *
       * @param string $hex Hexadecimal value. Accepts values with 3 or 6
numbers,
       * with or without #, e.g., CCC, #CCC, CCCCCC or #CCCCCC.
       *
       * @return array HSL values: 0 => H, 1 => S, 2 => L
       *
       */
      public function hex2hsl($hex)
      {
          return $this->rgb2hsl($this->hex2rgb($hex));
      }
  
      /**
       *
       * Converts RGB colors to hexadecimal.
       *
       * @param array $rgb RGB values: 0 => R, 1 => G, 2 => B
       *
       * @return string Hexadecimal value with six digits, e.g., CCCCCC.
       *
       */
      public function rgb2hex($rgb)
      {
          if(count($rgb) < 3) {
              return false;
          }
  
          list($r, $g, $b) = $rgb;
  
          // From php.net.
          $r = 0x10000 * max(0, min(255, $r));
          $g = 0x100 * max(0, min(255, $g));
          $b = max(0, min(255, $b));
  
          return strtoupper(str_pad(dechex($r + $g + $b), 6, 0,
STR_PAD_LEFT));
      }
  
      /**
       *
       * Converts RGB to HSV.
       *
       * @param array $rgb RGB values: 0 => R, 1 => G, 2 => B
       *
       * @return array HSV values: 0 => H, 1 => S, 2 => V
       *
       */
      public function rgb2hsv($rgb)
      {
          // RGB values = 0 ?ˇ 255
          $var_R = ($rgb[0] / 255);
          $var_G = ($rgb[1] / 255);
          $var_B = ($rgb[2] / 255);
  
          // Min. value of RGB
          $var_Min = min($var_R, $var_G, $var_B);
  
          // Max. value of RGB
          $var_Max = max($var_R, $var_G, $var_B);
  
          // Delta RGB value
          $del_Max = $var_Max - $var_Min;
  
          $V = $var_Max;
  
          // This is a gray, no chroma...
          if ( $del_Max == 0 ) {
             // HSV results = 0 ?ˇ 1
             $H = 0;
             $S = 0;
          } else {
             // Chromatic data...
             $S = $del_Max / $var_Max;
  
             $del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) /
$del_Max;
             $del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) /
$del_Max;
             $del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) /
$del_Max;
  
             if ($var_R == $var_Max) {
                 $H = $del_B - $del_G;
             } else if ($var_G == $var_Max) {
                 $H = (1 / 3) + $del_R - $del_B;
             } else if ($var_B == $var_Max) {
                 $H = (2 / 3) + $del_G - $del_R;
             }
  
             if ($H < 0) {
                 $H += 1;
             }
             if ($H > 1) {
                 $H -= 1;
             }
          }
  
          // Returns agnostic values.
          // Range will depend on the application: e.g. $H*360, $S*100,
$V*100.
          return array($H, $S, $V);
      }
  
      /**
       *
       * Converts RGB to HSL.
       *
       * @param array $rgb RGB values: 0 => R, 1 => G, 2 => B
       *
       * @return array HSL values: 0 => H, 1 => S, 2 => L
       *
       */
      public function rgb2hsl($rgb)
      {
          // Where RGB values = 0 ?ˇ 255.
          $var_R = $rgb[0] / 255;
          $var_G = $rgb[1] / 255;
          $var_B = $rgb[2] / 255;
  
          // Min. value of RGB
          $var_Min = min($var_R, $var_G, $var_B);
          // Max. value of RGB
          $var_Max = max($var_R, $var_G, $var_B);
          // Delta RGB value
          $del_Max = $var_Max - $var_Min;
  
          $L = ($var_Max + $var_Min) / 2;
  
          if ( $del_Max == 0 ) {
              // This is a gray, no chroma...
              // HSL results = 0 ?ˇ 1
              $H = 0;
              $S = 0;
          } else {
              // Chromatic data...
              if ($L < 0.5) {
                  $S = $del_Max / ($var_Max + $var_Min);
              } else {
                  $S = $del_Max / ( 2 - $var_Max - $var_Min );
              }
  
              $del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) /
$del_Max;
              $del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) /
$del_Max;
              $del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) /
$del_Max;
  
              if ($var_R == $var_Max) {
                  $H = $del_B - $del_G;
              } else if ($var_G == $var_Max) {
                  $H = ( 1 / 3 ) + $del_R - $del_B;
              } else if ($var_B == $var_Max) {
                  $H = ( 2 / 3 ) + $del_G - $del_R;
              }
  
              if ($H < 0) {
                  $H += 1;
              }
              if ($H > 1) {
                  $H -= 1;
              }
          }
  
          return array($H, $S, $L);
      }
  
      /**
       *
       * Converts HSV colors to hexadecimal.
       *
       * @param array $hsv HSV values: 0 => H, 1 => S, 2 => V
       *
       * @return string Hexadecimal value with six digits, e.g., CCCCCC.
       *
       */
      public function hsv2hex($hsv)
      {
          return $this->rgb2hex($this->hsv2rgb($hsv));
      }
  
      /**
       *
       * Converts HSV to RGB.
       *
       * @param array $hsv HSV values: 0 => H, 1 => S, 2 => V
       *
       * @return array RGB values: 0 => R, 1 => G, 2 => B
       *
       */
      public function hsv2rgb($hsv)
      {
          $H = $hsv[0];
          $S = $hsv[1];
          $V = $hsv[2];
  
          // HSV values = 0 ?ˇ 1
          if ($S == 0) {
              $R = $V * 255;
              $G = $V * 255;
              $B = $V * 255;
          } else {
              $var_h = $H * 6;
              // H must be < 1
              if ( $var_h == 6 ) {
                  $var_h = 0;
              }
              // Or ... $var_i = floor( $var_h )
              $var_i = floor( $var_h );
              $var_1 = $V * ( 1 - $S );
              $var_2 = $V * ( 1 - $S * ( $var_h - $var_i ) );
              $var_3 = $V * ( 1 - $S * ( 1 - ( $var_h - $var_i ) ) );
  
              switch($var_i) {
                  case 0:
                      $var_r = $V;
                      $var_g = $var_3;
                      $var_b = $var_1;
                      break;
                  case 1:
                      $var_r = $var_2;
                      $var_g = $V;
                      $var_b = $var_1;
                      break;
                  case 2:
                      $var_r = $var_1;
                      $var_g = $V;
                      $var_b = $var_3;
                      break;
                  case 3:
                      $var_r = $var_1;
                      $var_g = $var_2;
                      $var_b = $V;
                      break;
                  case 4:
                      $var_r = $var_3;
                      $var_g = $var_1;
                      $var_b = $V;
                      break;
                  default:
                      $var_r = $V;
                      $var_g = $var_1;
                      $var_b = $var_2;
              }
  
              //RGB results = 0 ?ˇ 255
              $R = $var_r * 255;
              $G = $var_g * 255;
              $B = $var_b * 255;
          }
  
          return array($R, $G, $B);
      }
  
      /**
       *
       * Converts HSV colors to HSL.
       *
       * @param array $hsv HSV values: 0 => H, 1 => S, 2 => V
       *
       * @return array HSL values: 0 => H, 1 => S, 2 => L
       *
       */
      public function hsv2hsl($hsv)
      {
          return $this->rgb2hsl($this->hsv2rgb($hsv));
      }
  
      /**
       *
       * Converts hexadecimal colors to HSL.
       *
       * @param array $hsl HSL values: 0 => H, 1 => S, 2 => L
       *
       * @return string Hexadecimal value. Accepts values with 3 or 6
numbers,
       * with or without #, e.g., CCC, #CCC, CCCCCC or #CCCCCC.
       *
       */
      public function hsl2hex($hsl)
      {
          return $this->rgb2hex($this->hsl2rgb($hsl));
      }
  
      /**
       *
       * Converts HSL to RGB.
       *
       * @param array $hsv HSL values: 0 => H, 1 => S, 2 => L
       *
       * @return array RGB values: 0 => R, 1 => G, 2 => B
       *
       */
      public function hsl2rgb($hsl)
      {
          list($H, $S, $L) = $hsl;
  
          if ($S == 0) {
              // HSL values = 0 ?ˇ 1
              // RGB results = 0 ?ˇ 255
              $R = $L * 255;
              $G = $L * 255;
              $B = $L * 255;
          } else {
              if ($L < 0.5) {
                  $var_2 = $L * (1 + $S);
              } else {
                  $var_2 = ($L + $S) - ($S * $L);
              }
  
              $var_1 = 2 * $L - $var_2;
  
              $R = 255 * $this->_hue2rgb($var_1, $var_2, $H + (1 / 3));
              $G = 255 * $this->_hue2rgb($var_1, $var_2, $H);
              $B = 255 * $this->_hue2rgb($var_1, $var_2, $H - (1 / 3));
          }
  
          return array($R, $G, $B);
      }
  
      /**
       *
       * Support method for hsl2rgb(): converts hue ro RGB.
       *
       * @param
       *
       * @param
       *
       * @param
       *
       * @return int
       *
       */
      protected function _hue2rgb($v1, $v2, $vH)
      {
          if ($vH < 0) {
              $vH += 1;
          }
  
          if ($vH > 1) {
              $vH -= 1;
          }
  
          if ((6 * $vH) < 1) {
              return ($v1 + ($v2 - $v1) * 6 * $vH);
          }
  
          if ((2 * $vH) < 1) {
              return $v2;
          }
  
          if ((3 * $vH) < 2) {
              return ($v1 + ($v2 - $v1) * (( 2 / 3) - $vH) * 6);
          }
  
          return $v1;
      }
  
      /**
       *
       * Converts hexadecimal colors to HSL.
       *
       * @param array $hsl HSL values: 0 => H, 1 => S, 2 => L
       *
       * @return array HSV values: 0 => H, 1 => S, 2 => V
       *
       */
      public function hsl2hsv($hsl)
      {
          return $this->rgb2hsv($this->hsl2rgb($hsl));
      }
  
      /**
       *
       * Updates HSV values.
       *
       * @param array $hsv HSV values: 0 => H, 1 => S, 2 => V
       *
       * @param array $values Values to update: 0 => value to add to H
(0 to 360),
       * 1 and 2 => values to multiply S and V (0 to 100). Example:
       *
       * {{{code:php
       *     // Update saturation to 80% in the provided HSV.
       *     $hsv = array(120, 0.75, 0.75);
       *     $new_hsv = $color->updateHsv($hsv, array(null, 80, null));
       * }}}
       *
       */
      public function updateHsv($hsv, $values)
      {
          if (isset($values[0])) {
              $hsv[0] = max(0, min(360, ($hsv[0] + $values[0])));
          }
  
          if (isset($values[1])) {
              $hsv[1] = max(0, min(1, ($hsv[1] * ($values[1] / 100))));
          }
  
          if (isset($values[2])) {
              $hsv[2] = max(0, min(1, ($hsv[2] * ($values[2] / 100))));
          }
  
          return $hsv;
      }
  
      /**
       *
       * Updates HSL values.
       *
       * @param array $hsl HSL values: 0 => H, 1 => S, 2 => L
       *
       * @param array $values Values to update: 0 => value to add to H
(0 to 360),
       * 1 and 2 => values to multiply S and V (0 to 100). Example:
       *
       * {{{code:php
       *     // Update saturation to 80% in the provided HSL.
       *     $hsl = array(120, 0.75, 0.75);
       *     $new_hsl = $color->updateHsl($hsl, array(null, 80, null));
       * }}}
       *
       */
      public function updateHsl($hsl, $values)
      {
          if (isset($values[0])) {
              $hsl[0] = max(0, min(1, ($hsl[0] + $values[0]/360)));
          }
  
          if (isset($values[1])) {
              $hsl[1] = max(0, min(1, ($hsl[1] * ($values[1] / 100))));
          }
  
          if (isset($values[2])) {
              $hsl[2] = max(0, min(1, ($hsl[2] * ($values[2] / 100))));
          }
  
          return $hsl;
      }
      
      function rgb2array($rgb) {
        return array(
          base_convert(substr($rgb, 0, 2), 16, 10),
          base_convert(substr($rgb, 2, 2), 16, 10),
          base_convert(substr($rgb, 4, 2), 16, 10),
      );
    }
    
  }
}
?>functions.php000064400000001713151171350140007265 0ustar00<?php
/**
 * mod_vertical_menu - Vertical Menu
 *
 * @author    Balint Polgarfi
 * @copyright 2014-2019 Offlajn.com
 * @license   https://gnu.org/licenses/gpl-2.0.html
 * @link      https://offlajn.com
 */
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.filesystem.folder');
$path = dirname(__FILE__);

foreach(JFolder::files($path, '.php', false, false) AS $f){
  require_once($path.'/'.$f);
}

if(!function_exists('o_flat_array')){

  /* Multidimensional to flat array */
  function o_flat_array($array){
    if(!is_array($array)) return array();
   $out=array();
   foreach($array as $k=>$v){
    if(is_array($array[$k]) && o_isAssoc($array[$k])){
     $out+=o_flat_array($array[$k]);
    }else{
     $out[$k]=$v;
    }
   }
   return $out;
  }
}

if(!function_exists('o_isAssoc')){
  function o_isAssoc($arr){
    return array_keys($arr) !== range(0, count($arr) - 1);
  }
}


?>index.html000064400000000047151171350140006540
0ustar00<html><head></head><body></body></html>minifont.php000064400000024073151171350140007104
0ustar00<?php
/**
 * mod_vertical_menu - Vertical Menu
 *
 * @author    Balint Polgarfi
 * @copyright 2014-2019 Offlajn.com
 * @license   https://gnu.org/licenses/gpl-2.0.html
 * @link      https://offlajn.com
 */
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');

if (!class_exists('OfflajnMiniFontHelper')) {

  class OfflajnMiniFontHelper
  {
    public function __construct($params)
    {
      $this->_params = &$params;
      $this->_parser = new OfflajnParser();
    }

    public function parseFonts()
    {
      $fonts = array();
      foreach ($this->_params->toArray() as $k => $f) {
        if (strpos($k, 'font') !== false && isset($f[0])
&& $f[0] == '{') {
          $f = json_decode($f, true);
          $tabs = array_keys($f);
          $default_tab = $tabs[0];
          $f['default_tab'] = $default_tab;

          if (version_compare(JVERSION, '3.0', 'ge'))
{
            $this->_params->set($k, $f);
          } else {
            $this->_params->setValue($k, $f);
          }
          // if(!isset($f[$default_tab]['bold']))
$f[$default_tab]['bold'] = 400;
          // $weight = $f[$default_tab]['bold'] ? 700 : 400;

          // $weight =
(strtoupper($t['textdecor'])=='LIGHTER') ? 300 :
((strtoupper($t['textdecor'])=='NORMAL') ? 400 : 700);
          $weight = @$f[$default_tab]['textdecor'];

          if (!isset($f[$default_tab]['italic'])) {
            $f[$default_tab]['italic'] = '';
          }

          $italic = $f[$default_tab]['italic'] ?
'italic' : '';
          $subset =
$this->_getSubset(isset($f[$default_tab]['subset']) ?
$f[$default_tab]['subset'] : 'latin');

          foreach ($f as $k => $t) {
            if ($k == 'default_tab') {
              continue;
            }
            if (isset($t['type']) && $t['type']
== '0' || !isset($t['type']) &&
$f[$default_tab]['type'] == '0') {
              continue;
            }

            $_family = isset($t['family']) ?
$t['family'] : $f[$default_tab]['family'];
            $_subset = (isset($t['subset']) ?
$this->_getSubset($t['subset']) : $subset);
            // $_weight = (isset($t['bold']) ?
($t['bold'] ? 700 : 400) : $weight);

            // $_weight = (isset($t['textdecor']) ?
((strtoupper($t['textdecor'])=='LIGHTER') ? 300 :
((strtoupper($t['textdecor'])=='NORMAL') ? 400 : 700))
: $weight);
            $_weight = @$t['textdecor'];
            $_italic = (isset($t['italic']) ?
($t['italic'] ? 'italic' : '') : $italic);
            if (!isset($fonts[$_family])) {
              $fonts[$_family] = array('subset' => array());
            }

            $fonts[$_family]['subset'][] = $_subset;
            $fonts[$_family]['options'][] = $_weight . $_italic;
          }
        }
      }
      $query = '';
      foreach ($fonts as $k => $font) {
        if ($k == '') continue;
        if ($query != '') $query .= '|';
        $query .= $k . ':' . implode(',',
array_unique(array_filter($font['options'])));
      }
      if ($query == '') return '';
      $url = 'https://fonts.googleapis.com/css?family=' .
$query;
      return "@import url('" . $url .
"');\n";
    }

    /*
    Ha $loadDefaultTab true, akkor az aktuális tab hiányzó értékeibe
beletölti a default tabból az értékeket.
    Ha a $justValue true, akkor csak az adott css tulajdonság értékét
jeleníti meg.
    */

    public function _printFont($name, $tab, $excl = null, $incl = null,
$loadDefaultTab = false, $justValue = false)
    {
      global $ratio;
      if (!$ratio) {
        $ratio = 1;
      }

      $f = $this->_params->get($name);
      if (!$tab) {
        $tab = $f['default_tab'];
      }

      $t = $f[$tab];
      if ($loadDefaultTab && $tab != $f['default_tab'])
{
        foreach ($f[$f['default_tab']] as $k => $v) {
          if (!isset($t[$k])) {
            $t[$k] = $v;
          }
        }
      }
      $family = '';
      if (isset($t['type']) && $t['type'] !=
'0' && isset($t['family'])) {
        $family = "'" . $t['family'] .
"'";
      }

      if (isset($t['afont']) && $t['afont'] !=
'') {
        $afont = OfflajnParser::parse($t['afont']);
        if ($afont[1]) {
          if ($family != '') {
            $family .= ',';
          }

          $family .= $afont[0];
        }
      }
      if ((!$excl || !in_array('font-family', $excl)) &&
(!$incl || in_array('font-family', $incl))) {
        if ($family != '') {
          if (!$justValue) {
            echo 'font-family: ' . $family . ";\n";
          } else {
            echo $family;
          }
        }
      }

      if ((!$excl || !in_array('font-size', $excl)) &&
(!$incl || in_array('font-size', $incl))) {
        if (isset($t['size']) && $t['size'] !=
'') {
          if (!$justValue) {
            $s = OfflajnParser::parse($t['size']);
            $s[0] = intval($s[0] * $ratio);
            echo 'font-size: ' . implode('', $s) .
";\n";
          } else {
            $s = OfflajnParser::parse($t['size']);
            $s[0] = intval($s[0] * $ratio);
            echo implode('', $s);
          }
        }
      }

      if ((!$excl || !in_array('color', $excl)) &&
(!$incl || in_array('color', $incl))) {
        if (isset($t['color']) && $t['color']
!= '') {
          echo "color: " . $t['color'] .
";\n";
        }
      }

      if ((!$excl || !in_array('font-weight', $excl)) &&
(!$incl || in_array('font-weight', $incl))) {
        if (isset($t['bold'])) {
          if (!$justValue) {
            echo 'font-weight: ' . ($t['bold'] ==
'1' ? 'bold' : 'normal') . ";\n";
          } else {
            echo ($t['bold'] == '1' ? 'bold'
: 'normal');
          }
        }
      }

      if ((!$excl || !in_array('font-weight', $excl)) &&
(!$incl || in_array('font-weight', $incl))) {
        if (isset($t['textdecor'])) {
          if (!$justValue) {
            echo 'font-weight: ' . $t['textdecor'] .
";\n";
          } else {
            echo $t['textdecor'];
          }
        }
      }

      if ((!$excl || !in_array('font-style', $excl)) &&
(!$incl || in_array('font-style', $incl))) {
        if (isset($t['italic'])) {
          if (!$justValue) {
            echo 'font-style: ' . ($t['italic'] ==
'1' ? 'italic' : 'normal') .
";\n";
          } else {
            echo ($t['italic'] == '1' ?
'italic' : 'normal');
          }
        }
      }

      if ((!$excl || !in_array('text-decoration', $excl))
&& (!$incl || in_array('text-decoration', $incl))) {
        if (isset($t['underline'])) {
          if (!$justValue) {
            echo 'text-decoration: ' . ($t['underline']
== '1' ? 'underline' : 'none') .
";\n";
          } else {
            echo ($t['underline'] == '1' ?
'underline' : 'none');
          }
        }

        if (isset($t['linethrough'])) {
          if (!$justValue) {
            echo 'text-decoration: ' .
($t['linethrough'] == '1' ? 'linethrough' :
'none') . ";\n";
          } else {
            echo ($t['linethrough'] == '1' ?
'linethrough' : 'none');
          }
        }

      }

      if ((!$excl || !in_array('text-transform', $excl))
&& (!$incl || in_array('text-transform', $incl))) {
        if (isset($t['uppercase'])) {
          if (!$justValue) {
            echo 'text-transform: ' . ($t['uppercase']
== '1' ? 'uppercase' : 'none') .
";\n";
          } else {
            echo ($t['uppercase'] == '1' ?
'uppercase' : 'none');
          }
        }
      }

      if ((!$excl || !in_array('text-align', $excl)) &&
(!$incl || in_array('text-align', $incl))) {
        if (isset($t['align'])) {
          if (!$justValue) {
            echo 'text-align: ' . $t['align'] .
";\n";
          } else {
            echo $t['align'];
          }
        }
      }

      if ((!$excl || !in_array('text-shadow', $excl)) &&
(!$incl || in_array('text-shadow', $incl))) {
        echo isset($t['tshadow']) ?
$this->getTextShadow($t['tshadow']) : '';
      }

      if ((!$excl || !in_array('line-height', $excl)) &&
(!$incl || in_array('line-height', $incl))) {
        if (isset($t['lineheight'])) {
          if (!$justValue) {
            if ($ratio == 1) {
              echo 'line-height: ' . $t['lineheight'] .
";\n";
            } else {
              $lht = $t['lineheight'];
              $lh = intval($t['lineheight']);
              if ($lh > 0) {
                $lhu = str_replace($lh, '',
$t['lineheight']);
                $lh = intval($lh * $ratio);
                echo 'line-height: ' . $lh . $lhu .
";\n";
              } else {
                echo 'line-height: ' . $t['lineheight']
. ";\n";
              }
            }
          } else {
            echo $t['lineheight'];
          }
        }
      }

    }

    public function printFont($name, $tab, $loadDefaultTab = false)
    {
      $this->_printFont($name, $tab, null, null, $loadDefaultTab);
    }

    public function printFontExcl($name, $tab, $excl, $loadDefaultTab =
false)
    {
      $this->_printFont($name, $tab, $excl, null, $loadDefaultTab);
    }

    public function printFontIncl($name, $tab, $incl, $loadDefaultTab =
false)
    {
      $this->_printFont($name, $tab, null, $incl, $loadDefaultTab);
    }

    public function getTextShadow($s)
    {
      $ts = OfflajnParser::parse($s);
      if (!$ts[4]) {
        return "text-shadow: none;\n";
      }
      while (count($ts) > 4) {
        array_pop($ts);
      }
      foreach ($ts as &$v) {
        if (!is_string($v)) {
          $v = implode('', $v);
        }
      }
      return 'text-shadow: ' . implode(' ', $ts) .
";\n";
    }

    public function _getSubset($subset)
    {
      if ($subset == 'LatinExtended') {
        $subset = 'latin,latin-ext';
      } elseif ($subset == 'CyrillicExtended') {
        $subset = 'cyrillic,cyrillic-ext';
      } elseif ($subset == 'GreekExtended') {
        $subset = 'greek,greek-ext';
      }
      return $subset;
    }

    public function printPropertyValue($name, $tab, $prop, $loadDefaultTab
= false)
    {
      $this->_printFont($name, $tab, null, array($prop),
$loadDefaultTab, true);
    }
  }

}
miniimage.php000064400000013712151171350140007216 0ustar00<?php
/**
 * mod_vertical_menu - Vertical Menu
 *
 * @author    Balint Polgarfi
 * @copyright 2014-2019 Offlajn.com
 * @license   https://gnu.org/licenses/gpl-2.0.html
 * @link      https://offlajn.com
 */
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');

if(!class_exists('OfflajnMiniImageHelper')){
    require_once(dirname(__FILE__).'/color.php');

    class OfflajnMiniImageHelper{
        var $cache;

        var $cacheUrl;

        var $step = 1;

        var $c;

        function __construct($cacheDir, $cacheUrl){
          $this->cache = $cacheDir;
          $this->cacheUrl = $cacheUrl;
          $this->c = new OfflajnColorHelper();
        }

        function colorizeImage($img, $targetColor, $baseColor){
					preg_match('/(\d+),\s*(\d+),\s*(\d+),\s*(\d\.?\d*)/',
$targetColor, $m);
					$targetColor = count($m) ? dechex($m[1]).dechex($m[2]).dechex($m[3]) :
substr($targetColor, 1);
					$alpha = count($m) ? (float)$m[4] : 1;
          $c1 = $this->c->hex2hsl($baseColor);
          $c2 = $this->c->hex2hsl($targetColor);
          $im = imagecreatefrompng($img);
          $height = imagesy($im);
          $width = imagesx($im);
          $imnew = imagecreatetruecolor($width, $height);
          imagesavealpha($imnew, true);
          imagealphablending($imnew, false);
          $transparent = imagecolorallocatealpha($imnew, 255, 255, 255,
127);
          imagefilledrectangle($imnew, 0, 0, $width, $height,
$transparent);
          $rgb = $this->c->rgb2array($targetColor);
          for($x=0; $x<$width; $x++){
              for($y=0; $y<$height; $y++){
                  $rgba = ImageColorAt($im, $x, $y);
                  $rgb = array(($rgba >> 16) & 0xFF, ($rgba
>> 8) & 0xFF, $rgba & 0xFF);
                  $hsl = $this->c->rgb2hsl($rgb);
                  $a[0] = $hsl[0] + ($c2[0] - $c1[0]);
                  $a[1] = $hsl[1] * ($c2[1] / $c1[1]);
                  if($a[1] > 1) $a[1] = 1;
                  $a[2] = exp(log($hsl[2]) * log($c2[2]) / log($c1[2]) );
                  if($a[2] > 1) $a[2] = 1;
                  $rgb = $this->c->hsl2rgb($a);
                  $A = 0xFF-(($rgba >> 24)*2) & 0xFF;
                  $A = (int)($A * $alpha);
                  if($A > 0xFF) $A = 0xFF;
                  $A = (int)((0xFF-$A)/2);
                  imagesetpixel($imnew, $x, $y,
imagecolorallocatealpha($imnew, $rgb[0], $rgb[1], $rgb[2], $A));
              }
          }
          $hash = md5($img.$targetColor.$alpha).'.png';
          imagepng($imnew, $this->cache.'/'.$hash);
          imagedestroy($imnew);
          imagedestroy($im);
          return $this->cacheUrl.$hash;
        }

        function colorizeImages($img, $color1, $color2, $baseColor){
					//if ($color1 == color2) return $this->colorizeImage($img, $color1,
$baseColor);
					preg_match('/(\d+),\s*(\d+),\s*(\d+),\s*(\d\.?\d*)/',
$color1, $m);
					$color1 = count($m) ? dechex($m[1]).dechex($m[2]).dechex($m[3]) :
substr($color1, 1);
					$alpha1 = count($m) ? (float)$m[4] : 1;
					preg_match('/(\d+),\s*(\d+),\s*(\d+),\s*(\d\.?\d*)/',
$color2, $m);
					$color2 = count($m) ? dechex($m[1]).dechex($m[2]).dechex($m[3]) :
substr($color2, 1);
					$alpha2 = count($m) ? (float)$m[4] : 1;
          $c = $this->c->hex2hsl($baseColor);
          $c1 = $this->c->hex2hsl($color1);
					$c2 = $this->c->hex2hsl($color2);
          $im = imagecreatefrompng($img);
          $height = imagesy($im);
          $width = imagesx($im);
          $imnew = imagecreatetruecolor(2 * $width, $height);
          imagesavealpha($imnew, true);
          imagealphablending($imnew, false);
          $transparent = imagecolorallocatealpha($imnew, 255, 255, 255,
127);
          imagefilledrectangle($imnew, 0, 0, 2 * $width, $height,
$transparent);
          $rgb = $this->c->rgb2array($color1);
          for($x=0; $x<$width; $x++){
              for($y=0; $y<$height; $y++){
                  $rgba = ImageColorAt($im, $x, $y);
                  $rgb = array(($rgba >> 16) & 0xFF, ($rgba
>> 8) & 0xFF, $rgba & 0xFF);
                  $hsl = $this->c->rgb2hsl($rgb);
                  $a[0] = $hsl[0] + ($c1[0] - $c[0]);
                  $a[1] = $hsl[1] * ($c1[1] / $c[1]);
                  if($a[1] > 1) $a[1] = 1;
                  $a[2] = exp(log($hsl[2]) * log($c1[2]) / log($c[2]) );
                  if($a[2] > 1) $a[2] = 1;
                  $rgb = $this->c->hsl2rgb($a);
                  $A = 0xFF-(($rgba >> 24)*2) & 0xFF;
                  $A = (int)($A * $alpha1);
                  if($A > 0xFF) $A = 0xFF;
                  $A = (int)((0xFF-$A)/2);
                  imagesetpixel($imnew, $x, $y,
imagecolorallocatealpha($imnew, $rgb[0], $rgb[1], $rgb[2], $A));
              }
          }
          $rgb = $this->c->rgb2array($color2);
          for($x=$width; $x<2*$width; $x++){
              for($y=0; $y<$height; $y++){
                  $rgba = ImageColorAt($im, $x - $width, $y);
                  $rgb = array(($rgba >> 16) & 0xFF, ($rgba
>> 8) & 0xFF, $rgba & 0xFF);
                  $hsl = $this->c->rgb2hsl($rgb);
                  $a[0] = $hsl[0] + ($c2[0] - $c[0]);
                  $a[1] = $hsl[1] * ($c2[1] / $c[1]);
                  if($a[1] > 1) $a[1] = 1;
                  $a[2] = exp(log($hsl[2]) * log($c2[2]) / log($c[2]) );
                  if($a[2] > 1) $a[2] = 1;
                  $rgb = $this->c->hsl2rgb($a);
                  $A = 0xFF-(($rgba >> 24)*2) & 0xFF;
                  $A = (int)($A * $alpha2);
                  if($A > 0xFF) $A = 0xFF;
                  $A = (int)((0xFF-$A)/2);
                  imagesetpixel($imnew, $x, $y,
imagecolorallocatealpha($imnew, $rgb[0], $rgb[1], $rgb[2], $A));
              }
          }
          $hash =
md5($img.$color1.$alpha1.$color2.$alpha2).'.png';
          imagepng($imnew, $this->cache.'/'.$hash);
          imagedestroy($imnew);
          imagedestroy($im);
          return $this->cacheUrl.$hash;
        }
    }
}
?>miniparser.php000064400000004206151171350140007426 0ustar00<?php
/**
 * mod_vertical_menu - Vertical Menu
 *
 * @author    Balint Polgarfi
 * @copyright 2014-2019 Offlajn.com
 * @license   https://gnu.org/licenses/gpl-2.0.html
 * @link      https://offlajn.com
 */
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');

if (!class_exists('OfflajnParser')) {

  class OfflajnParser
  {
    public static function parse($s, $def = null)
    {
      $v = explode("|*|", is_string($s) ? $s : $def);
      if ($v[count($v) - 1] == '') {
        unset($v[count($v) - 1]);
      }

      if (is_string($s) && is_string($def)) {
        $d = explode("|*|", $def);
        if (!is_string($v) && !is_string($d)) {
          for ($i = count($v); $i--;) {
            array_shift($d);
          }
          $v = array_merge($v, $d);
        }
      }
      for ($i = 0; $i < count($v); $i++) {
        if (strpos($v[$i], "||") !== false) {
          $v[$i] = explode("||", $v[$i]);
        }
      }

      // if ($def=='#eeeeee|*|rgba(0, 0, 0,
0.53)|*|50||px|*|0||px|*|0||px'){
      //   echo'<pre>';print_r(count($v) == 1 ? $v[0] :
$v);exit;
      // }

      return count($v) == 1 ? $v[0] : $v;
    }

    public static function parseUnit($v, $concat = '')
    {
      if (!is_array($v)) {
        $v = self::parse($v);
      }

      $unit = @$v[count($v) - 1];
      unset($v[count($v) - 1]);
      $r = '';
      foreach ($v as $m) {
        $r .= $m . $unit . $concat;
      }
      return $r;
    }

    public static function parseBorder($s)
    {
      $v = self::parse($s);
      return array(self::parseUnit(array_splice($v, 0, 5), ' '),
$v[0], $v[1]);
    }

    public static function parseColorizedImage($s)
    {
      global $MiniImageHelper;
      $v = self::parse($s);
      $img = '';
      $v[0] = JPATH_SITE . preg_replace('#^.*?(/modules/)#',
'$1', $v[0]);
      if (file_exists($v[0])) {
        if ($v[2] == '#000000') $v[2] = '#000001';
        if ($v[3] == '#000000') $v[3] = '#000001';
        $img = $MiniImageHelper->colorizeImages($v[0], $v[2], $v[3],
'548722');
      }
      return array($img, $v[1]);
    }
  }

}
events.php000064400000002504151171643460006572 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_notifly
 *
 * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * Notifly component helper.
 *
 * @since  1.6
 */
class NotiflyEventsHelper
{

	public static function getList($random = false)
	{
		$events = NotiflyEventsHelper::getEvents($random);
		$results = [];
		foreach ($events as $key => $event) {
			$item = [];
			$item['message'] =
NotiflyMessageHelper::parseMessage($event->message, $event);
			$item['image'] = $event->image_url;
			$item['url'] = $event->url;
			$results[] = $item;
		}
		// print_r($results);die;

		return $results;
	}

	public static function getEvents($random = false)
	{
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);
		$query->select("a.*, m.message")
			  ->from('#__notifly_events as a')			  
			  ->join('LEFT', '#__notifly_templates AS m ON m.id =
a.template_id')
			  ->where($db->quoteName('a.published') . ' =
1');
		if($random){
			$query->order('rand() DESC');
		}else{
			$query->order($db->quoteName('a.id') . '
DESC');
		}

		// get the setLimit form config
		$query->setLimit('20');
		$db->setQuery($query);
		$result = $db->loadObjectList();
		return $result;
	}

}
message.php000064400000011654151171643460006720 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_notifly
 *
 * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * Notifly component helper.
 *
 * @since  1.6
 */
class NotiflyMessageHelper
{
	/**
	 * Returns valid contexts
 	 * @param   time of action
	 *
	 * @return  array

	 *
	 * @since   1.0.0
	 */
	public static function parseMessage($msg, $event)
	{
		$title = isset($event->title) && !empty($event->title) ?
$event->title : JText::_('COM_NOTIFLY_MESSAGE_TITLE');
		$url = isset($event->url) && !empty($event->url) ?
JRoute::_($event->url) : Juri::root();

		$m = new Mustache_Engine;
		$data = array(
			'name' => isset($event->name) &&
!empty($event->name) ? $event->name :
JText::_('COM_NOTIFLY_MESSAGE_SOMEONE'),
			'city' => isset($event->city) &&
!empty($event->city) ? $event->city :
JText::_('COM_NOTIFLY_MESSAGE_CITY_UNKNOWN'),
			'province' => isset($event->province) &&
!empty($event->province) ? $event->province :
JText::_('COM_NOTIFLY_MESSAGE_PROVINCE_UNKNOWN'),
			'country' => isset($event->country) &&
!empty($event->country) ? $event->country :
JText::_('COM_NOTIFLY_MESSAGE_COUNTRY_UNKNOWN'),
			'title' => $title,
			'url' => $url,
			'title_with_link' =>
'['.$title.']('.$url.')', //'<a
href="'.$url.'">'.$title.'</a>',
			'time_ago' => isset($event->created) &&
!empty($event->created) ?
NotiflyMessageHelper::getFormatedTime($event->created) :
JText::_('COM_NOTIFLY_MESSAGE_CREATED')
		);	

		return $m->render($msg, $data);
	}

	/**
	 * Returns valid contexts
 	 * @param   ip
	 *
	 * @return  array

	 *
	 * @since   1.0.0
	 */
	public static function getLocation($ip)
	{
		//
http://api.db-ip.com/v2/e9a901d2b1df53e77ab70dc79a74d11558d3bdb9/61.6.1.39
		// http://freegeoip.net/json/?q=119.148.0.0
		
		try {
			// Set up custom headers for a single request.
			$headers = array('Accept' => 'application/json');
			$http = JHttpFactory::getHttp();
			
			// In this case, the Accept header in $headers will override the options
header.
			$response = $http->get('http://freegeoip.net/json/' . $ip,
$headers);
			if($response->code == '200'){
				$data = json_decode($response->body, true);
				return $data;
			}
		} catch (Exception $e) {
			// Add a message to the message queue
			JFactory::getApplication()->enqueueMessage(JText::_('COM_NOTIFLY_ERROR_LOCATION'),
'error');
		}
	}


	/**
	 * Get either a Gravatar URL or complete image tag for a specified email
address.
	 *
	 * @param string $email The email address
	 * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
	 * @param string $d Default imageset to use [ 404 | mm | identicon |
monsterid | wavatar ]
	 * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
	 * @param boole $img True to return a complete IMG tag False for just the
URL
	 * @param array $atts Optional, additional key/value attributes to include
in the IMG tag
	 * @return String containing either just a URL or a complete image tag
	 * @source https://gravatar.com/site/implement/images/php/
	 */
	public static function getGravater( $email, $s = 80, $d = 'mm',
$r = 'g', $img = false, $atts = array() ) {
	    $url = 'https://www.gravatar.com/avatar/';
	    $url .= md5( strtolower( trim( $email ) ) );
	    $url .= "?s=$s&d=$d&r=$r";
	    if ( $img ) {
	        $url = '<img src="' . $url . '"';
	        foreach ( $atts as $key => $val )
	            $url .= ' ' . $key . '="' . $val .
'"';
	        $url .= ' />';
	    }
	    return $url;
	}

	public static function getRealIpAddr()
	{
	    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from
share internet
	    {
	      $ip=$_SERVER['HTTP_CLIENT_IP'];
	    }
	    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to
check ip is pass from proxy
	    {
	      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
	    }
	    else
	    {
	      $ip=$_SERVER['REMOTE_ADDR'];
	    }
	    return $ip;
	}
	
	//https://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago
	public static function getFormatedTime($datetime, $full = false) 
	{
		$zone = JFactory::getConfig()->get('offset');
		$now = JFactory::getDate( 'now' , $zone );
	    $ago = JFactory::getDate( $datetime , $zone );
	    $diff = $now->diff($ago);

	    $diff->w = floor($diff->d / 7);
	    $diff->d -= $diff->w * 7;

	    $string = array(
	        'y' => 'year',
	        'm' => 'month',
	        'w' => 'week',
	        'd' => 'day',
	        'h' => 'hour',
	        'i' => 'minute',
	        's' => 'second',
	    );
	    foreach ($string as $k => &$v) {
	        if ($diff->$k) {
	            $v = $diff->$k . ' ' . $v . ($diff->$k > 1
? 's' : '');
	        } else {
	            unset($string[$k]);
	        }
	    }

	    if (!$full) $string = array_slice($string, 0, 1);
	    return $string ? implode(', ', $string) . ' '.
JText::_('COM_NOTIFLY_MESSAGE_AGO') :
JText::_('COM_NOTIFLY_MESSAGE_NOW');
	}



}
notifly.php000064400000011026151171643460006751 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_notifly
 *
 * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * Notifly component helper.
 *
 * @since  1.6
 */
class NotiflyHelper extends JHelperContent
{
	public static $extension = 'com_notifly';

	/**
	 * Configure the Linkbar.
	 *
	 * @param   string  $vName  The name of the active view.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	public static function addSubmenu($vName)
	{
		JHtmlSidebar::addEntry(
			JText::_('COM_NOTIFLY_SUBMENU_DASHBOARD'),
			'index.php?option=com_notifly&view=dashboard',
			$vName == 'dashboard'
		);
		JHtmlSidebar::addEntry(
			JText::_('COM_NOTIFLY_SUBMENU_TEMPLATES'),
			'index.php?option=com_notifly&view=templates',
			$vName == 'templates'
		);

		JHtmlSidebar::addEntry(
			JText::_('COM_NOTIFLY_SUBMENU_INTEGRATIONS'),
			'index.php?option=com_notifly&view=integrations',
			$vName == 'integrations'
		);

		JHtmlSidebar::addEntry(
			JText::_('COM_NOTIFLY_SUBMENU_EVENTS'),
			'index.php?option=com_notifly&view=events',
			$vName == 'events'
		);

		JHtmlSidebar::addEntry(
			JText::_('COM_NOTIFLY_SUBMENU_DESIGN'),
			'index.php?option=com_notifly&view=design',
			$vName == 'design'
		);
	}

	/**
	 * Applies the content tag filters to arbitrary text as per settings for
current user group
	 *
	 * @param   text  $text  The string to filter
	 *
	 * @return  string  The filtered string
	 *
	 * @deprecated  4.0  Use JComponentHelper::filterText() instead.
	 */
	public static function filterText($text)
	{
		try
		{
			JLog::add(
				sprintf('%s() is deprecated. Use JComponentHelper::filterText()
instead', __METHOD__),
				JLog::WARNING,
				'deprecated'
			);
		}
		catch (RuntimeException $exception)
		{
			// Informational log only
		}

		return JComponentHelper::filterText($text);
	}

	/**
	 * Returns valid contexts
	 *
	 * @return  array
	 *
	 * @since   3.7.0
	 */
	public static function getContexts()
	{
		JFactory::getLanguage()->load('com_notifly',
JPATH_ADMINISTRATOR);

		$contexts = array(
			'com_notifly.template'    =>
JText::_('COM_NOTIFLY_SUBMENU_TEMPLATES'),
			'com_notifly.integration' =>
JText::_('COM_NOTIFLY_SUBMENU_INTEGRATIONS')
		);

		return $contexts;
	}

	/**
	 * Returns all notifly group plugins list
	 *
	 * @return  object
	 *
	 * @since   1.0.0
	 */
	public static function getGroupPlugins()
	{
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);
		$query->select("*")
			  ->from('#__extensions')
			  ->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
			  ->where($db->quoteName('folder') . ' = ' .
$db->quote('notifly'))
			  ->setLimit('20');
		$db->setQuery($query);
		$result = $db->loadObjectList();

		return $result;
	}

	/*
	* to get update info
	* use layout to get alert structure
	*/

	public static function getUpdateStatus(){

		$update = self::checkUpdate();
		
		// if(isset($update->update_id) && $update->update_id)
		// {
		// 	$credentials = self::hasCredentials();
		// 	// Instantiate a new JLayoutFile instance and render the layout
		// 	$layout = new JLayoutFile('toolbar.update');
		// 	return $layout->render(array('info' => $update,
'credentials' => $credentials));		
		// }

		return $update;
	}

	/*
	* to get update info
	* use layout to get alert structure
	*/

	public static function checkUpdate(){
		// Get a database object.
		$return = [];
		$db = JFactory::getDbo();

		// get extensionid
		$query = $db->getQuery(true)
					->select('*')
					->from('#__extensions')
					->where($db->quoteName('type') . ' = ' .
$db->quote('package'))
					->where($db->quoteName('element') . ' = ' .
$db->quote('pkg_notifly'));

		$db->setQuery($query);
		
		$result1 = $db->loadObject();
		$extensionid = $result1->extension_id;

		$manifest_cache 	= json_decode($result1->manifest_cache);
		$return['old'] 		= $manifest_cache->version;

		// get update_site_id
		$query = $db->getQuery(true)
					->select('*')
					->from('#__updates')
					->where($db->quoteName('extension_id') . ' =
' . $db->quote($extensionid))
					->where($db->quoteName('element') . ' = ' .
$db->quote('pkg_notifly'))
					->where($db->quoteName('type') . ' = ' .
$db->quote('package'));
		$db->setQuery($query);
		
		$return2 = $db->loadObject();
		$return['new'] 	= (isset($return2->version) ?
$return2->version : $manifest_cache->version);

		return $return;
		
	}

	public static function showWarning()
	{
		$layout = new JLayoutFile('notifly.warning');
		return $layout->render();
	}
}