forked from techjoomla/com_tjvendors
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task techjoomla#53 feat: Create a bootsrap file
- Loading branch information
Amol Thite
committed
Nov 6, 2019
1 parent
44e6c5f
commit 3efe935
Showing
5 changed files
with
330 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
<?php | ||
/** | ||
* @package TJVendors | ||
* @subpackage com_tjvendors | ||
* | ||
* @author Techjoomla <[email protected]> | ||
* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. | ||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL | ||
*/ | ||
|
||
// No direct access | ||
defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Component\ComponentHelper; | ||
use Joomla\CMS\HTML\HTMLHelper; | ||
use Joomla\CMS\MVC\Model\BaseDatabaseModel; | ||
use Joomla\CMS\Table\Table; | ||
use Joomla\String\StringHelper; | ||
|
||
/** | ||
* TJVendors factory class. | ||
* | ||
* This class perform the helpful operation required to TJVendors package | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class TJV | ||
{ | ||
/** | ||
* Holds the record of the loaded TJVendors classes | ||
* | ||
* @var array | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
private static $loadedClass = array(); | ||
|
||
/** | ||
* Holds the record of the component config | ||
* | ||
* @var Joomla\Registry\Registry | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
private static $config = null; | ||
|
||
/** | ||
* Retrieves a table from the table folder | ||
* | ||
* @param string $name The table file name | ||
* @param array $config Configuration array for model. Optional. | ||
* | ||
* @return Table|boolean object or false on failure | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
**/ | ||
public static function table($name, $config = array()) | ||
{ | ||
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjvendors/tables'); | ||
$table = Table::getInstance($name, 'TjvendorsTable', $config); | ||
|
||
return $table; | ||
} | ||
|
||
/** | ||
* Retrieves a model from the model folder | ||
* | ||
* @param string $name The model name | ||
* @param array $config Configuration array for model. Optional. | ||
* | ||
* @return BaseDatabaseModel|boolean object or false on failure | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
**/ | ||
public static function model($name, $config = array()) | ||
{ | ||
BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_tjvendors/models', 'TJVendorsModel'); | ||
$model = BaseDatabaseModel::getInstance($name, 'TJVendorsModel', $config); | ||
|
||
return $model; | ||
} | ||
|
||
/** | ||
* Magic method to create instance of Tjvendors library | ||
* | ||
* @param string $name The name of the class | ||
* @param mixed $arguments Arguments of class | ||
* | ||
* @return mixed return the Object of the respective class if exist OW return false | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
**/ | ||
public static function __callStatic($name, $arguments) | ||
{ | ||
self::loadClass($name); | ||
|
||
$className = 'Tjvendors' . StringHelper::ucfirst($name); | ||
|
||
if (class_exists($className)) | ||
{ | ||
if (method_exists($className, 'getInstance')) | ||
{ | ||
return call_user_func_array(array($className, 'getInstance'), $arguments); | ||
} | ||
|
||
return new $className; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Load the class library if not loaded | ||
* | ||
* @param string $className The name of the class which required to load | ||
* | ||
* @return boolean True on success | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
**/ | ||
public static function loadClass($className) | ||
{ | ||
if (! isset(self::$loadedClass[$className])) | ||
{ | ||
$className = (string) StringHelper::strtolower($className); | ||
|
||
$path = JPATH_SITE . '/components/com_tjvendors/includes/' . $className . '.php'; | ||
|
||
include_once $path; | ||
|
||
self::$loadedClass[$className] = true; | ||
} | ||
|
||
return self::$loadedClass[$className]; | ||
} | ||
|
||
/** | ||
* Load the component configuration | ||
* | ||
* @return Joomla\Registry\Registry A Registry object. | ||
*/ | ||
public static function config() | ||
{ | ||
if (empty(self::$config)) | ||
{ | ||
self::$config = ComponentHelper::getParams('com_tjvendors'); | ||
} | ||
|
||
return self::$config; | ||
} | ||
|
||
/** | ||
* Initializes the css, js and necessary dependencies | ||
* | ||
* @param string $location The location where the assets needs to load | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public static function init($location = 'site') | ||
{ | ||
static $loaded = null; | ||
$docType = Factory::getDocument()->getType(); | ||
$versionClass = self::version(); | ||
|
||
if ($loaded[$location] && ($docType != 'html')) | ||
{ | ||
return; | ||
} | ||
|
||
if (file_exists(JPATH_ROOT . '/media/techjoomla_strapper/tjstrapper.php')) | ||
{ | ||
require_once JPATH_ROOT . '/media/techjoomla_strapper/tjstrapper.php'; | ||
TjStrapper::loadTjAssets('com_tjvendors'); | ||
} | ||
|
||
$version = $versionClass->getMediaVersion(); | ||
$options = array("version" => $version); | ||
|
||
HTMLHelper::script('media/com_tjvendor/js/tjvendors.js', $options); | ||
HTMLHelper::stylesheet('media/com_tjvendor/css/tjvendors.css', $options); | ||
HTMLHelper::stylesheet('media/techjoomla_strapper/vendors/no-more-tables.css', $options); | ||
|
||
// Load Boostrap | ||
if (self::config()->get('load_bootstrap') == '1') | ||
{ | ||
define('COM_TJVENDORS_WRAPPAER_CLASS', "tjBs3"); | ||
HTMLHelper::_('stylesheet', 'media/techjoomla_strapper/bs3/css/bootstrap.min.css'); | ||
HTMLHelper::_('stylesheet', 'media/techjoomla_strapper/vendors/font-awesome/css/font-awesome.min.css'); | ||
} | ||
else | ||
{ | ||
define('COM_TJVENDORS_WRAPPAER_CLASS', ''); | ||
} | ||
|
||
$loaded[$location] = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
/** | ||
* @package TJVendors | ||
* @subpackage com_tjvendors | ||
* | ||
* @author Techjoomla <[email protected]> | ||
* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. | ||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL | ||
*/ | ||
|
||
use Joomla\CMS\Factory; | ||
|
||
defined('_JEXEC') or die(); | ||
|
||
/** | ||
* Version information class for the TJVendors. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class TjvendorsVersion | ||
{ | ||
/** | ||
* Product name. | ||
* | ||
* @var string | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
const PRODUCT = 'TJVendors'; | ||
|
||
/** | ||
* Major release version. | ||
* | ||
* @var integer | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
const MAJOR_VERSION = 1; | ||
|
||
/** | ||
* Minor release version. | ||
* | ||
* @var integer | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
const MINOR_VERSION = 4; | ||
|
||
/** | ||
* Patch release version. | ||
* | ||
* @var integer | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
const PATCH_VERSION = 0; | ||
|
||
/** | ||
* Release date. | ||
* | ||
* @var string | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
const RELDATE = '20-August-2019'; | ||
|
||
/** | ||
* Gets a "PHP standardized" version string for the current TJVendors. | ||
* | ||
* @return string Version string. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function getShortVersion() | ||
{ | ||
return self::MAJOR_VERSION . '.' . self::MINOR_VERSION . '.' . self::PATCH_VERSION; | ||
} | ||
|
||
/** | ||
* Gets a version string for the current TJVendors with all release information. | ||
* | ||
* @return string Complete version string. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function getLongVersion() | ||
{ | ||
return self::PRODUCT . ' ' . $this->getShortVersion() . ' ' . self::RELDATE; | ||
} | ||
|
||
/** | ||
* Generate a media version string for assets | ||
* Public to allow third party developers to use it | ||
* | ||
* @return string | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function generateMediaVersion() | ||
{ | ||
return md5($this->getLongVersion() . Factory::getConfig()->get('secret')); | ||
} | ||
|
||
/** | ||
* Gets a media version which is used to append to TJVendors core media files. | ||
* | ||
* This media version is used to append to TJVendors core media in order to trick browsers into | ||
* reloading the CSS and JavaScript, because they think the files are renewed. | ||
* The media version is renewed after TJVendors core update, install, discover_install and uninstallation. | ||
* | ||
* @return string The media version. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function getMediaVersion() | ||
{ | ||
return $this->generateMediaVersion(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.