Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/Classes/Repositories/PageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

use App\Model\Page;
use Illuminate\Support\Collection;
use App\Plugins\Pages\Model\PageTypes;
use App\Plugins\Pages\Model\PageOptions;
use App\Modules\Pages\Model\PageTypes;
use App\Modules\Pages\Model\PageOptions;
use Illuminate\Database\Eloquent\Builder;

/**
Expand Down Expand Up @@ -53,9 +53,9 @@ public function allNormalPages()
*
* @return $collection
*/
public function allPluginPages()
public function allModulePages()
{
$bitmask = PageTypes::TYPE_PLUGIN;
$bitmask = PageTypes::TYPE_MODULE;

return $this->model->whereRaw('`type` & '.$bitmask.'='.$bitmask)->get();
}
Expand Down
7 changes: 2 additions & 5 deletions app/Console/Commands/JuneUpdateOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use App\Model\Page;
use Illuminate\Console\Command;
use App\Plugins\Pages\Model\PageTypes;
use App\Plugins\Pages\Model\PageOptions;
use App\Modules\Pages\Model\PageTypes;
use App\Modules\Pages\Model\PageOptions;
use App\Classes\Repositories\PageRepository;

class JuneUpdateOne extends Command
Expand Down Expand Up @@ -59,9 +59,6 @@ public function handle()
if (! $page->editable && ! $page->special) {
$page->type = (PageTypes::TYPE_FRAMEWORK | PageTypes::TYPE_STANDARD);
$page->option = PageOptions::OPTION_PUBLIC | PageOptions::OPTION_SITEMAP;
} elseif ($page->plugin) {
$page->type = PageTypes::TYPE_PLUGIN;
$page->option = PageOptions::OPTION_DEFAULT;
} elseif ($page->identifier == 'newsletter.success') {
$page->type = PageTypes::TYPE_PLUGIN;
$page->option = PageOptions::OPTION_PUBLIC;
Expand Down
8 changes: 8 additions & 0 deletions app/Helpers/Global.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,11 @@ function formSelect($value, $matches)
{
return $value == $matches ? 'selected' : '';
}

/**
* @return \App\Modules\ModuleManager
*/
function modules()
{
return app(\App\Modules\ModuleManager::class);
}
2 changes: 1 addition & 1 deletion app/Model/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function getPageAttribute()
*/
public function path()
{
return url($this->page->path().'/'.$this->category->slug.'/'.$this->slug);
return url(config('modules.articles.route').'/'.$this->category->slug.'/'.$this->slug);
}

/**
Expand Down
37 changes: 32 additions & 5 deletions app/Model/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
use Laravel\Scout\Searchable;
use App\Model\Concerns\Publishers;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use App\Classes\Interfaces\Linkable;
use App\Model\Concerns\ActivityFeed;
use App\Plugins\Pages\Model\PageTypes;
use App\Plugins\Pages\Model\PageOptions;
use App\Modules\Pages\Model\PageTypes;
use App\Modules\Pages\Model\PageOptions;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand All @@ -31,6 +32,7 @@
* @property string $heading
* @property string $description
* @property string $keywords
* @property string $module
* @property int $views
* @property int $type
* @property int $option
Expand Down Expand Up @@ -266,7 +268,7 @@ public function getKeywordsAttribute()
/**
* Return the status if the page has the options specified.
*
* @param PageOptions $options Values of the required options
* @param string $options Values of the required options
*
* @return bool the returned condition
*/
Expand All @@ -278,7 +280,7 @@ public function hasOption($options)
$constant = constant(sprintf('%s::OPTION_%s', PageOptions::class, strtoupper($option)));

if ($this->option & $constant) {
return $constant;
return true;
}
}

Expand All @@ -288,7 +290,7 @@ public function hasOption($options)
/**
* Return if the current page type matches the condition giving.
*
* @param PageTypes $type The type required for the condition
* @param string $type The type required for the condition
*
* @return bool The condition of the function.
*/
Expand All @@ -298,4 +300,29 @@ public function isType(string $type)

return $this->type & $constant;
}

/**
* Toggle the disability of all the module pages.
* (Enable, Disable);.
*
* If one page fails, do not toggle.
*
* @param string $module
*
* @return mixed
*/
public static function toggleModuleDisability(string $module, bool $active)
{
DB::transaction(function () use ($module, $active) {
if ($active == true) {
foreach (self::whereModule($module)->get() as $page) {
$page->update(['option' => $page->option & ~PageOptions::OPTION_DISABLED]);
}
} else {
foreach (self::whereModule($module)->get() as $page) {
$page->update(['option' => $page->option | PageOptions::OPTION_DISABLED]);
}
}
});
}
}
Loading