Skip to content

Commit adc2154

Browse files
committed
Init Commit
0 parents  commit adc2154

File tree

40 files changed

+1928
-0
lines changed

40 files changed

+1928
-0
lines changed

Block/Adminhtml/System/Feed.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/**
4+
*
5+
* @category: Magepow
6+
* @Copyright (c) 2014 Magepow (<https://magepow.net/>)
7+
* @authors: Magepow (<[email protected]>)
8+
* @license: <https://magepow.net/license-agreement>
9+
* @github: <https://github.com/magepownet>
10+
*/
11+
12+
namespace Magepow\Core\Block\Adminhtml\System;
13+
14+
class Feed extends \Magento\Config\Block\System\Config\Form\Field
15+
{
16+
17+
18+
/**
19+
* @return string
20+
*/
21+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
22+
{
23+
try {
24+
25+
26+
$html = "
27+
<div class='magepow_feed'></div>
28+
<script type='text/javascript'>
29+
require(['jquery', 'magepow/slick', 'magepow/feed']);
30+
</script>
31+
";
32+
33+
return $html;
34+
35+
} catch (Exception $e) {
36+
37+
return $e->getMessage();
38+
}
39+
}
40+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/**
4+
*
5+
* @category: Magepow
6+
* @Copyright (c) 2014 Magepow (<https://magepow.net/>)
7+
* @authors: Magepow (<[email protected]>)
8+
* @license: <https://magepow.net/license-agreement>
9+
* @github: <https://github.com/magepownet>
10+
*/
11+
12+
13+
namespace Magepow\Core\Block\System\Config\Form\Field;
14+
15+
class ColorPicker extends \Magento\Config\Block\System\Config\Form\Field
16+
{
17+
/**
18+
* @param \Magento\Backend\Block\Template\Context $context
19+
* @param array $data
20+
*/
21+
public function __construct(
22+
\Magento\Backend\Block\Template\Context $context,
23+
array $data = []
24+
)
25+
{
26+
parent::__construct($context, $data);
27+
}
28+
29+
/**
30+
* add color picker in admin configuration fields
31+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
32+
* @return string script
33+
*/
34+
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
35+
{
36+
$html = $element->getElementHtml();
37+
$value = $element->getData('value');
38+
39+
$html .= '<script type="text/javascript">
40+
require(["jquery", "jquery/colorpicker/js/colorpicker"], function ($) {
41+
$(document).ready(function (e) {
42+
var $el = $("#' . $element->getHtmlId() . '");
43+
$el.css("backgroundColor", "'. $value .'");
44+
45+
// Attach the color picker
46+
$el.ColorPicker({
47+
color: "'. $value .'",
48+
onChange: function (hsb, hex, rgb) {
49+
$el.css("backgroundColor", "#" + hex).val("#" + hex);
50+
}
51+
});
52+
});
53+
});
54+
</script>';
55+
56+
return $html;
57+
}
58+
}

Console/Command/CleanUp.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/**
3+
*
4+
* @category: Magepow
5+
* @Copyright (c) 2014 Magepow (<https://magepow.net/>)
6+
* @authors: Magepow (<[email protected]>)
7+
* @license: <https://magepow.net/license-agreement>
8+
* @github: <https://github.com/magepownet>
9+
*/
10+
11+
namespace Magepow\Core\Console\Command;
12+
13+
use Symfony\Component\Console\Command\Command; // for parent class
14+
use Symfony\Component\Console\Input\InputInterface; // for InputInterface used in execute method
15+
use Symfony\Component\Console\Output\OutputInterface; // for OutputInterface used in execute method
16+
use Symfony\Component\Filesystem\Filesystem;
17+
use Magento\Framework\App\ResourceConnection;
18+
19+
class CleanUp extends Command
20+
{
21+
22+
private $dirs = [
23+
// 'generated',
24+
'var/log',
25+
'var/report',
26+
'var/session'
27+
];
28+
29+
private $tables = [
30+
'adminnotification_inbox',
31+
'admin_passwords',
32+
'admin_user_session',
33+
'captcha_log',
34+
'customer_visitor',
35+
'customer_log',
36+
'cron_schedule',
37+
'report_event',
38+
'report_viewed_product_index',
39+
];
40+
41+
/**
42+
*
43+
* @var Filesystem
44+
*/
45+
private $filesystem;
46+
47+
/**
48+
*
49+
* @var ResourceConnection
50+
*/
51+
private $resource;
52+
53+
/**
54+
* @param Filesystem $filesystem
55+
* @param ResourceConnection $resource
56+
* @param string $name
57+
*/
58+
public function __construct(
59+
Filesystem $filesystem = null,
60+
ResourceConnection $resource = null,
61+
string $name = null
62+
) {
63+
$this->filesystem = $filesystem ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Filesystem::class);
64+
$this->resource = $resource ?: \Magento\Framework\App\ObjectManager::getInstance()->get(ResourceConnection::class);
65+
66+
parent::__construct($name);
67+
}
68+
69+
protected function configure()
70+
{
71+
// command: bin/magento cleanUp
72+
$this->setName('cleanUp')
73+
->setDescription('Clear TMP Tables & Logs');
74+
75+
parent::configure();
76+
}
77+
78+
protected function execute(InputInterface $input, OutputInterface $output)
79+
{
80+
$connection = $this->resource->getConnection();
81+
$fs = $this->filesystem;
82+
try {
83+
foreach ($this->tables as $table) {
84+
$connection->truncateTable($table);
85+
$output->writeln("TRUNCATE $table");
86+
}
87+
foreach ($this->dirs as $dir) {
88+
if($fs->exists($dir)){
89+
$fs->remove(array($dir));
90+
$output->writeln("Cleared $dir");
91+
}else {
92+
$output->writeln("Can\'t find directy $dir");
93+
}
94+
}
95+
} catch (IOExceptionInterface $e) {
96+
echo "An error occurred while deleting your directory at " . $e->getPath();
97+
}
98+
}
99+
}

Helper/Data.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
*
4+
* @category: Magepow
5+
* @Copyright (c) 2014 Magepow (<https://magepow.net/>)
6+
* @authors: Magepow (<[email protected]>)
7+
* @license: <https://magepow.net/license-agreement>
8+
* @github: <https://github.com/magepownet>
9+
*/
10+
11+
namespace Magepow\Core\Helper;
12+
13+
class Data extends \Magento\Framework\App\Helper\AbstractHelper
14+
{
15+
/**
16+
* @var array
17+
*/
18+
protected $configModule;
19+
20+
/**
21+
* @var \Magento\Framework\Module\Manager
22+
*/
23+
protected $moduleManager;
24+
25+
public function __construct(
26+
\Magento\Framework\App\Helper\Context $context,
27+
\Magento\Framework\Module\Manager $moduleManager
28+
)
29+
{
30+
parent::__construct($context);
31+
$this->moduleManager = $moduleManager;
32+
$this->configModule = $this->getConfig(strtolower($this->_getModuleName()));
33+
}
34+
35+
public function getConfig($cfg='')
36+
{
37+
if($cfg) return $this->scopeConfig->getValue( $cfg, \Magento\Store\Model\ScopeInterface::SCOPE_STORE );
38+
return $this->scopeConfig;
39+
}
40+
41+
public function getConfigModule($cfg='', $value=null)
42+
{
43+
$values = $this->configModule;
44+
if( !$cfg ) return $values;
45+
$config = explode('/', (string) $cfg);
46+
$end = count($config) - 1;
47+
foreach ($config as $key => $vl) {
48+
if( isset($values[$vl]) ){
49+
if( $key == $end ) {
50+
$value = $values[$vl];
51+
}else {
52+
$values = $values[$vl];
53+
}
54+
}
55+
56+
}
57+
return $value;
58+
}
59+
60+
public function isEnabledModule($moduleName)
61+
{
62+
return $this->moduleManager->isEnabled($moduleName);
63+
}
64+
65+
public function getModuleName()
66+
{
67+
return $this->_getModuleName();
68+
}
69+
70+
}

Model/Config/Source/Col.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/**
4+
*
5+
* @category: Magepow
6+
* @Copyright (c) 2014 Magepow (<https://magepow.net/>)
7+
* @authors: Magepow (<[email protected]>)
8+
* @license: <https://magepow.net/license-agreement>
9+
* @github: <https://github.com/magepownet>
10+
*/
11+
12+
namespace Magepow\Core\Model\Config\Source;
13+
14+
class Col implements \Magento\Framework\Option\ArrayInterface
15+
{
16+
/**
17+
* base on 12 col bootstrap.
18+
*
19+
* @return []
20+
*/
21+
22+
public function toOptionArray()
23+
{
24+
return array(
25+
array('value' => 1, 'label'=>__('1 item(s) /row')),
26+
array('value' => 2, 'label'=>__('2 item(s) /row')),
27+
array('value' => 3, 'label'=>__('3 item(s) /row')),
28+
array('value' => 4, 'label'=>__('4 item(s) /row')),
29+
array('value' => 5, 'label'=>__('5 item(s) /row')),
30+
array('value' => 6, 'label'=>__('6 item(s) /row')),
31+
array('value' => 7, 'label'=>__('7 item(s) /row')),
32+
array('value' => 8, 'label'=>__('8 item(s) /row')),
33+
array('value' => 9, 'label'=>__('9 item(s) /row')),
34+
array('value' => 10, 'label'=>__('10 item(s) /row')),
35+
array('value' => 11, 'label'=>__('11 item(s) /row')),
36+
array('value' => 12, 'label'=>__('12 item(s) /row')),
37+
);
38+
}
39+
}

Model/Config/Source/Module.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
*
5+
* @category: Magepow
6+
* @Copyright (c) 2014 Magepow (<https://magepow.net/>)
7+
* @authors: Magepow (<[email protected]>)
8+
* @license: <https://magepow.net/license-agreement>
9+
* @github: <https://github.com/magepownet>
10+
*/
11+
12+
namespace Magepow\Core\Model\Config\Source;
13+
14+
class Module implements \Magento\Framework\Option\ArrayInterface
15+
{
16+
/**
17+
* @var ModuleList
18+
*/
19+
private $moduleList;
20+
21+
/**
22+
* ConfigOption constructor.
23+
* @param ModuleList $moduleList
24+
*/
25+
public function __construct(
26+
\Magento\Framework\Module\ModuleList $moduleList
27+
)
28+
{
29+
$this->moduleList = $moduleList;
30+
}
31+
32+
public function toOptionArray()
33+
{
34+
$modules = $this->getAllModules();
35+
$options = [];
36+
foreach($modules as $module){
37+
$options[] = ['value' => $module, 'label' => $module];
38+
}
39+
return $options;
40+
}
41+
42+
public function getAllModules()
43+
{
44+
return $this->moduleList->getNames();
45+
}
46+
}

0 commit comments

Comments
 (0)