-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b1f4f7e
Showing
20 changed files
with
521 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*~ | ||
*.bak |
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,64 @@ | ||
<?php | ||
|
||
namespace themroc\humhub\modules\iframe; | ||
|
||
use Yii; | ||
|
||
class Events | ||
{ | ||
/** | ||
* Defines what to do when the top menu is initialized. | ||
* | ||
* @param $event | ||
*/ | ||
public static function onTopMenuInit($event) | ||
{ | ||
$mod= Yii::$app->getModule('iframe'); | ||
|
||
foreach ($mod->getFrames() as $f) { | ||
$prefix= $f.'/'; | ||
$label= $mod->getSetting('label', $f); | ||
$event->sender->addItem([ | ||
'icon'=> '<i class="fa '.$mod->getSetting($prefix.'icon').'"></i>', | ||
'label'=> $label, | ||
'url'=> $mod->getUrl('index', ['frame'=> $label]), | ||
'sortOrder'=> $mod->getSetting('sort', $f), | ||
'isActive'=> self::checkActive('index', $f), | ||
]); | ||
} | ||
} | ||
|
||
/** | ||
* Defines what to do if admin menu is initialized. | ||
* | ||
* @param $event | ||
*/ | ||
public static function onAdminMenuInit($event) | ||
{ | ||
$mod= Yii::$app->getModule('iframe'); | ||
if (! Yii::$app->controller->module || ! Yii::$app->controller->module->id == 'iframe') | ||
return; | ||
|
||
$event->sender->addItem([ | ||
'icon'=> '<i class="fa fa-desktop"></i>', | ||
'label'=> 'Iframe', | ||
'url'=> $mod->getUrl('admin'), | ||
'group'=> 'manage', | ||
'sortOrder'=> 99999, | ||
'isActive'=> self::checkActive('admin'), | ||
]); | ||
} | ||
|
||
/** | ||
* Defines what to do when the top menu is initialized. | ||
* | ||
* @param $event | ||
*/ | ||
public static function checkActive($page, $frame= null) | ||
{ | ||
if ((! Yii::$app->controller->module) || Yii::$app->controller->module->id != 'iframe' || Yii::$app->controller->id != $page) | ||
return 0; | ||
|
||
return $frame==null ? 1 : (Yii::$app->request->get('frame') == $frame); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
namespace themroc\humhub\modules\iframe; | ||
|
||
use Yii; | ||
use yii\helpers\Url; | ||
use yii\widgets\ActiveForm; | ||
use humhub\components\UrlManager; | ||
use humhub\modules\content\components\ContentContainerActiveRecord; | ||
use humhub\modules\space\models\Space; | ||
use humhub\modules\user\models\User; | ||
|
||
use themroc\humhub\modules\iframe\Assets; | ||
|
||
class Module extends \humhub\modules\content\components\ContentContainerModule | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getConfigUrl() | ||
{ | ||
return Url::to(['/iframe/admin']); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function disable() | ||
{ | ||
// Cleanup all module data, don't remove the parent::disable()!!! | ||
parent::disable(); | ||
} | ||
|
||
public function getSetting($key, $frame=null) | ||
{ | ||
return $this->settings->get(($frame==null ? '' : $frame.'/') . $key); | ||
} | ||
|
||
public function getUrl($page, $params=null) | ||
{ | ||
$url= [ '/iframe/'.$page ]; | ||
if (is_array($params)) | ||
foreach ($params as $k => $v) | ||
$url[$k]= strtolower($v); | ||
|
||
return Url::to($url); | ||
} | ||
|
||
public function getFrames() | ||
{ | ||
$frames= $this->settings->get('/frames'); | ||
if ($frames == null) | ||
return []; | ||
|
||
return preg_split('!\s*/\s*!', $frames); | ||
} | ||
} |
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,18 @@ | ||
### Description | ||
Add (nearly) fullscreen iframes to topbar. | ||
|
||
__Module website:__ <https://github.com/Themroc/humhub_iframe> | ||
|
||
__Author:__ Themroc <7hemroc@gmail.com> | ||
|
||
### Changelog | ||
|
||
<https://github.com/Themroc/humhub_iframe/commits/master> | ||
|
||
### Bugtracker | ||
|
||
<https://github.com/Themroc/humhub_iframe/issues> | ||
|
||
### ToDos | ||
|
||
- |
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,31 @@ | ||
<?php | ||
|
||
namespace themroc\humhub\modules\iframe\assets; | ||
|
||
use yii\web\AssetBundle; | ||
|
||
class Assets extends AssetBundle | ||
{ | ||
/** | ||
* @var string defines the path of your module assets | ||
*/ | ||
public $sourcePath= '@iframe/resources'; | ||
|
||
/** | ||
* @var array defines where the js files are included into the page, note your custom js files should be included after the core files (which are included in head) | ||
*/ | ||
public $jsOptions= [ | ||
'position'=> \yii\web\View::POS_END | ||
]; | ||
|
||
/** | ||
* @var array change forceCopy to true when testing your js in order to rebuild this assets on every request (otherwise they will be cached) | ||
*/ | ||
public $publishOptions= [ | ||
'forceCopy'=> false | ||
]; | ||
|
||
public $js= [ | ||
'humhub.iframe.js' | ||
]; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
<?php | ||
|
||
use humhub\widgets\TopMenu; | ||
use humhub\modules\admin\widgets\AdminMenu; | ||
use themroc\humhub\modules\iframe\Events; | ||
|
||
return [ | ||
'id' => 'iframe', | ||
'class' => 'themroc\humhub\modules\iframe\Module', | ||
'namespace' => 'themroc\humhub\modules\iframe', | ||
'events' => [ | ||
[ TopMenu::class, TopMenu::EVENT_INIT, [Events::class, 'onTopMenuInit'] ], | ||
[ AdminMenu::class, AdminMenu::EVENT_INIT, [Events::class, 'onAdminMenuInit'] ], | ||
], | ||
]; |
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,62 @@ | ||
<?php | ||
|
||
namespace themroc\humhub\modules\iframe\controllers; | ||
|
||
use Yii; | ||
use humhub\modules\admin\components\Controller; | ||
use themroc\humhub\modules\iframe\models\AdminForm; | ||
|
||
class AdminController extends Controller | ||
{ | ||
public $adminOnly= true; | ||
public $subLayout= '@iframe/views/layouts/admin'; | ||
|
||
public function init() | ||
{ | ||
if (Yii::$app->getModule('mod-helper')===null) | ||
$this->subLayout= null; | ||
|
||
return parent::init(); | ||
} | ||
|
||
/** | ||
* Render admin only page | ||
* | ||
* @return string | ||
*/ | ||
public function actionIndex() | ||
{ | ||
if ($this->subLayout===null) | ||
return $this->render('error', [ | ||
'msg'=> 'Please install and activate the <a href="https://github.com/Themroc/humhub_mod-helper" target="_blank">Mod-Helper plugin</a>.', | ||
]); | ||
|
||
$mod= Yii::$app->getModule('iframe'); | ||
$frame= Yii::$app->request->get('frame'); | ||
|
||
if (Yii::$app->request->get('delete') == 1) { | ||
$model= new AdminForm(); | ||
foreach (array_keys($model->getVars()) as $v) | ||
$mod->settings->delete($frame.'/'.$v); | ||
$frames= $mod->getFrames(); | ||
if (false !== $k= array_search($frame, $frames)) { | ||
unset($frames[$k]); | ||
$mod->settings->set('/frames', join('/', $frames)); | ||
} | ||
|
||
return $this->redirect($mod->getUrl('admin')); | ||
} | ||
|
||
$model= new AdminForm(isset($frame) ? $frame.'/' : ''); | ||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
$this->view->saved(); | ||
|
||
return $this->redirect($mod->getUrl('admin')); | ||
} | ||
|
||
return $this->render('@mod-helper/views/form', [ | ||
'model'=> $model, | ||
'standAlone'=> 0, | ||
]); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace themroc\humhub\modules\iframe\controllers; | ||
|
||
use Yii; | ||
use humhub\components\Controller; | ||
|
||
class IndexController extends Controller | ||
{ | ||
public $subLayout = "@iframe/views/layouts/default"; | ||
|
||
public function actionIndex() | ||
{ | ||
return $this->render('index', [ | ||
]); | ||
} | ||
} |
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,88 @@ | ||
<?php | ||
|
||
namespace themroc\humhub\modules\iframe\models; | ||
|
||
use Yii; | ||
use yii\helpers\Url; | ||
use humhub\libs\Html; | ||
use humhub\modules\ui\form\widgets\IconPicker; | ||
|
||
/** | ||
* AdminForm defines the configurable fields. | ||
*/ | ||
class AdminForm extends \themroc\humhub\modules\modhelper\models\AdminForm | ||
{ | ||
public $icon; | ||
public $label; | ||
public $sort; | ||
public $size; | ||
public $url; | ||
|
||
protected $vars= [ | ||
'label'=> [ | ||
'hints'=> 'This will show up under the icon', | ||
], | ||
'icon'=> [ | ||
'form'=> [ | ||
'type'=> 'widget', | ||
'class'=> IconPicker::class, | ||
], | ||
], | ||
'sort'=> [ | ||
'label'=> 'Sort order', | ||
'hints'=> 'Determines topbar menu position', | ||
], | ||
'size'=> [ | ||
'rules'=> ['in', 'range'=> [0, 1]], | ||
'form'=> ['type'=> 'radio', 'params'=> [self::class, 'sizeModes']], | ||
], | ||
'url'=> [ | ||
'label'=> 'Page URL', | ||
'hints'=> 'The webpage to be shown', | ||
], | ||
]; | ||
|
||
protected $mod= [ | ||
'form'=> ['btn_post'=> [self::class, 'deleteButton']], | ||
]; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function save() | ||
{ | ||
$frame= strtolower($this->label); | ||
$this->mod['prefix']= $frame.'/'; | ||
$frames= $this->mod['_']->getFrames(); | ||
$fs= []; | ||
foreach ($frames as $f) | ||
$fs[$f]= $this->mod['settings']->get($f.'/sort'); | ||
$fs[$frame]= $this->sort; | ||
asort($fs); | ||
if (join('/', $frames) != ($frames_str= join('/', array_keys($fs)))) | ||
$this->mod['settings']->set('/frames', $frames_str); | ||
|
||
foreach ($this->vars as $name => $v) | ||
$this->mod['settings']->set($this->mod['prefix'].$name, trim($this->{$name})); | ||
|
||
return $this->loadSettings(); | ||
} | ||
|
||
public function deleteButton($model) | ||
{ | ||
return strlen($model->label) | ||
? "\t\t\t".Html::a( | ||
Yii::t('IframeModule.base', 'Delete'), | ||
$model->getMod('_')->getUrl('admin', ['frame'=> $model->label, 'delete'=> '1']), | ||
['class' => 'btn btn-default pull-right', 'style'=>'margin-right:10px'])."\n" | ||
: ""; | ||
} | ||
|
||
public function sizeModes() | ||
{ | ||
return [ | ||
0=> Yii::t('IframeModule.base', 'Box'), | ||
1=> Yii::t('IframeModule.base', 'Fullscreen'), | ||
]; | ||
} | ||
} |
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,12 @@ | ||
{ | ||
"id": "iframe", | ||
"name": "Iframe", | ||
"description": "(Nearly) fullscreen iframes", | ||
"keywords": [ | ||
], | ||
"version": "0.1", | ||
"humhub": { | ||
"minVersion": "1.2" | ||
}, | ||
"screenshots": ["assets/screen1.jpg", "assets/screen2.jpg", "assets/screen3.jpg"] | ||
} |
Oops, something went wrong.