Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     zbase()->setConsoleCommand($this);
     $phpCommand = env('ZBASE_PHP_COMMAND', 'php');
     $packages = zbase()->packages();
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\TestCommandInterface) {
                 $this->info($this->signature . '.pre - ' . $packageName);
                 $zbase->testCommand($phpCommand, ['test.pre' => true, 'command' => $this]);
             }
         }
     }
     $commands = [];
     if (!empty($commands)) {
         foreach ($commands as $command) {
             if ($command instanceof \Closure) {
                 $command();
             }
         }
     }
     zbase_package('zbase')->testCommand($phpCommand, ['test.post' => true, 'command' => $this]);
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\TestCommandInterface) {
                 $this->info($this->signature . '.post - ' . $packageName);
                 $zbase->testCommand($phpCommand, ['test.post' => true, 'command' => $this]);
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Added module can be added dynamically to route
  * and can be accessed
  * @group Modules
  */
 function testModuleRoute()
 {
     $modules = zbase()->modules();
     foreach ($modules as $module) {
         $this->assertTrue(zbase()->module($module->id()) instanceof \Zbase\Module\ModuleInterface);
     }
 }
 public function register()
 {
     $this->app->singleton(zivsluck_tag(), function () {
         return new Zivsluck();
     });
     zbase()->addPackage(zivsluck_tag());
 }
Esempio n. 4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     zbase()->setConsoleCommand($this);
     $phpCommand = env('ZBASE_PHP_COMMAND', 'php');
     $packages = zbase()->packages();
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\AssetsCommandInterface) {
                 $this->info($this->signature . '.pre - ' . $packageName);
                 $zbase->assetsCommand($phpCommand, ['assets.pre' => true, 'command' => $this]);
             }
         }
     }
     echo shell_exec($phpCommand . ' artisan vendor:publish --tag=public --force');
     $commands = [];
     if (!empty($commands)) {
         foreach ($commands as $command) {
             if ($command instanceof \Closure) {
                 $command();
             } else {
                 echo shell_exec($phpCommand . ' artisan ' . $command);
             }
         }
     }
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\AssetsCommandInterface) {
                 $this->info($this->signature . '.post - ' . $packageName);
                 $zbase->assetsCommand($phpCommand, ['assets.post' => true, 'command' => $this]);
             }
         }
     }
 }
 public function register()
 {
     $this->app->singleton(packagename_tag(), function () {
         return new Packagename();
     });
     zbase()->addPackage(packagename_tag());
 }
Esempio n. 6
0
 /**
  * Used only for testing
  * @return view
  */
 public function form()
 {
     if ($this->isPost()) {
         $validatorMessages = ['email.required' => _zt('Email Address is required.'), 'email.email' => _zt('Invalid email address.')];
         $valid = $this->validateInputs(zbase()->request()->inputs(), ['email' => 'required|email'], $validatorMessages);
         if (!empty($valid)) {
             $this->message('success', _zt('Successfull!'));
         }
     }
     return $this->view('form');
 }
Esempio n. 7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     zbase_maintenance_set();
     zbase()->setConsoleCommand($this);
     $phpCommand = env('ZBASE_PHP_COMMAND', 'php');
     $packages = zbase()->packages();
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\MigrateCommandInterface) {
                 $this->info($this->signature . '.pre - ' . $packageName);
                 $zbase->migrateCommand($phpCommand, ['migrate.pre' => true, 'command' => $this]);
             }
         }
     }
     \File::cleanDirectory(database_path() . '/migrations');
     \File::cleanDirectory(database_path() . '/seeds');
     \File::cleanDirectory(database_path() . '/factories');
     \File::cleanDirectory(storage_path() . '/zbase');
     \File::cleanDirectory(storage_path() . '/framework/cache');
     \File::cleanDirectory(storage_path() . '/framework/views');
     \File::cleanDirectory(storage_path() . '/logs');
     echo shell_exec($phpCommand . ' artisan vendor:publish --tag=migrations --force');
     echo shell_exec($phpCommand . ' artisan optimize');
     echo shell_exec($phpCommand . ' artisan migrate:refresh --seed --force');
     $commands = [];
     // zbase()->commands('migrate');
     if (!empty($commands)) {
         foreach ($commands as $command) {
             if ($command instanceof \Closure) {
                 $command();
             } else {
                 echo shell_exec($phpCommand . ' artisan ' . $command);
             }
         }
     }
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\MigrateCommandInterface) {
                 $this->info($this->signature . '.post - ' . $packageName);
                 $zbase->migrateCommand($phpCommand, ['migrate.post' => true, 'command' => $this]);
             }
         }
     }
     zbase_maintenance_unset();
 }
Esempio n. 8
0
/**
 * Return contents for a certain module and widget
 *
 * @param string $module The module that is asking for content
 * @param string $widget The widget that is asking for content
 * @param string $section The current section [default: front] front|back
 * @param boolean $adminView IF for admin [default: false]
 * @param string $key key to search
 * @param array $contents Some contents
 * @return array
 */
function zbase_module_widget_contents($module, $widget, $section = 'front', $adminView = false, $key = null, $contents = [])
{
    $modules = zbase()->modules();
    foreach ($modules as $mod) {
        $widgetContent = $mod->widgetContents($widget, $module, $section, $adminView, $key);
        if (!empty($widgetContent)) {
            foreach ($widgetContent as $index => $content) {
                $contents[] = $content;
            }
        }
    }
    if (!empty($contents)) {
        return zbase_collection($contents)->sortByDesc(function ($itm) {
            return !empty($itm['position']) ? $itm['position'] : 0;
        })->toArray();
    }
}
Esempio n. 9
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     zbase()->setConsoleCommand($this);
     $phpCommand = env('ZBASE_PHP_COMMAND', 'php');
     $packages = zbase()->packages();
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\ClearCommandInterface) {
                 $this->info($this->signature . '.pre - ' . $packageName);
                 $zbase->clearCommand($phpCommand, ['clear.pre' => true, 'command' => $this]);
             }
         }
     }
     echo shell_exec($phpCommand . ' artisan clear-compiled');
     echo shell_exec($phpCommand . ' artisan cache:clear');
     echo shell_exec($phpCommand . ' artisan view:clear');
     echo shell_exec($phpCommand . ' artisan config:clear');
     echo shell_exec($phpCommand . ' artisan route:clear');
     \File::cleanDirectory(zbase_storage_path('tmp/images'));
     \File::cleanDirectory(zbase_storage_path(zbase_tag() . '_tmp/images'));
     $commands = [];
     // zbase()->commands('clear');
     if (!empty($commands)) {
         foreach ($commands as $command) {
             if ($command instanceof \Closure) {
                 $command();
             } else {
                 echo shell_exec($phpCommand . ' artisan ' . $command);
             }
         }
     }
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\ClearCommandInterface) {
                 $this->info($this->signature . '.post - ' . $packageName);
                 $zbase->clearCommand($phpCommand, ['clear.post' => true, 'command' => $this]);
             }
         }
     }
 }
Esempio n. 10
0
 /**
  * Event after Action
  * @param string $action
  * @param string $url The Default URL to redirect
  */
 protected function _postEvent($action)
 {
     if ($this->isPublic() && $this->isNode() && $this->isCreating()) {
         return zbase_redirect()->to($this->entity()->alphaUrl());
     }
     $isAjax = zbase_request_is_ajax();
     $requestMethod = strtolower(zbase_request_method());
     if ($isAjax) {
         if ($requestMethod == 'post') {
             $e = $this->_v('event.' . zbase_section() . '.' . $action . '.post-json.post', $this->_v('event.' . $action . '.post-json'));
         } else {
             $e = $this->_v('event.' . zbase_section() . '.' . $action . '.post-json', $this->_v('event.' . zbase_section() . '.' . $action . '.post'));
         }
     } else {
         if ($requestMethod == 'post') {
             $e = $this->_v('event.' . zbase_section() . '.' . $action . '.post.post', $this->_v('event.' . $action . '.post.post', null));
         } else {
             $e = $this->_v('event.' . zbase_section() . '.' . $action . '.post', $this->_v('event.' . $action . '.post', null));
         }
     }
     if (is_null($e)) {
         if (zbase_is_back()) {
             if ($this->isCreating()) {
                 $action = 'update';
             }
             $byAlphaId = $this->_v('entity.repo.byAlphaId.route', false);
             if ($this->entityIsPostInterface($this->entity())) {
                 if (!empty($byAlphaId)) {
                     $params = ['action' => $action, 'id' => $this->entity()->postAlphaId()];
                 } else {
                     $params = ['action' => $action, 'id' => $this->entity()->postId()];
                 }
             } else {
                 if (!empty($byAlphaId)) {
                     $params = ['action' => $action, 'id' => $this->entity()->alphaId()];
                 } else {
                     $params = ['action' => $action, 'id' => $this->entity()->id()];
                 }
             }
         } else {
             $params = ['action' => $action, 'id' => $this->entity()->alphaId()];
         }
         if ($action == 'delete') {
             $params = [];
         }
         $url = $this->getModule()->url(zbase_section(), $params);
         if ($action == 'restore' || $action == 'ddelete') {
             $url = zbase_url_previous();
         }
     }
     if (!empty($e)) {
         if (!empty($e['data'])) {
             if ($isAjax) {
                 zbase()->json()->addVariables($e['data']);
             }
         }
         if (!empty($e['route'])) {
             $params = zbase_route_inputs();
             if (!empty($e['route']['params'])) {
                 $params = array_merge($params, $e['route']['params']);
             }
             if (zbase_is_back()) {
                 $byAlphaId = $this->_v('entity.repo.byAlphaId.route', false);
                 if (!empty($byAlphaId)) {
                     $params['id'] = $this->entity()->alphaId();
                 } else {
                     $params['id'] = $this->entity()->id();
                 }
             }
             if ($action == 'ddelete') {
                 if (isset($params['id']) && isset($params['action'])) {
                     unset($params['id']);
                     unset($params['action']);
                 }
             }
             $e['route']['params'] = $params;
             $url = zbase_url_from_config($e);
         }
         $toUrl = zbase_value_get($e, 'url', false);
         if (!empty($toUrl)) {
             $url = $toUrl;
         }
     }
     $enableRedirect = $this->_v('event.' . zbase_section() . '.' . $action . '.post.redirect.enable', $this->_v('event.' . $action . '.post.redirect.enable', true));
     if (!empty($url) && !empty($enableRedirect)) {
         return zbase_redirect()->to($url);
     }
     return true;
 }
 * Dx
 *
 * @link http://dennesabing.com
 * @author Dennes B Abing <*****@*****.**>
 * @license proprietary
 * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx
 * @version 0.0.0.1
 * @since Aug 22, 2016 8:29:03 PM
 * @file maintenance-notice.blade.php
 * @project Zbase
 * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php.
 */
if (zbase()->system()->hasScheduledDowntime() && !zbase()->system()->inMaintenance()) {
    ?>
	<?php 
    $details = zbase()->system()->scheduledDowntimeDetails();
    ?>
	<div class="alert alert-warning">
		<h3>Temporary Downtime Notice.</h3>
		<p>
			<?php 
    $message = null;
    if (!empty($details['maintenance-message'])) {
        $message = $details['maintenance-message'];
    }
    if (!empty($details['start-datetime'])) {
        $startTime = zbase_date_from_format('Y-m-d H:i:s', $details['start-datetime']);
        $endTime = zbase_date_from_format('Y-m-d H:i:s', $details['end-datetime']);
        echo str_replace(array('{START_TIME}', '{END_TIME}'), array('<strong>' . $startTime->format('F d, Y h:i A') . '</strong>', '<strong>' . $endTime->format('F d, Y h:i A') . '</strong>'), nl2br($message));
    }
    ?>
Esempio n. 12
0
 /**
  * User By Email
  * @param string $email
  * @return object|array
  */
 public static function findUserByEmail($email, $object = false)
 {
     if (is_array($email) && !empty($email['email'])) {
         $email = $email['email'];
     }
     if (!empty($email)) {
         $entity = zbase()->entity('user', [], true);
         return ['user' => self::userApi($entity->repo()->by('email', $email)->first())];
     }
 }
Esempio n. 13
0
<!DOCTYPE html>
<html>
	<head>
		<title>@yield('title')<?php 
echo zbase()->view()->pageTitle();
?>
</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" >
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<style type="text/css">
			body {
				background-color: #eee;
			}

			body, h1, p {
				font-family: "Helvetica Neue", "Segoe UI", Segoe, Helvetica, Arial, "Lucida Grande", sans-serif;
				font-weight: normal;
				margin: 0;
				padding: 0;
				text-align: center;
			}

			.container {
				margin-left:  auto;
				margin-right:  auto;
				margin-top: 177px;
				max-width: 1170px;
				padding-right: 15px;
				padding-left: 15px;
			}
Esempio n. 14
0
 /**
  * Element Factory
  * @param array $configuration
  * @return \Zbase\Ui\Form\Element
  */
 public static function factory($configuration)
 {
     /**
      * Load a widget
      */
     if (!empty($configuration['widget'])) {
         if (!empty($configuration['validations'])) {
             $widget = zbase()->widget($configuration['widget'], [], true)->setAttribute('validations', $configuration['validations']);
         } else {
             $widget = zbase()->widget($configuration['widget'], [], true);
         }
         return $widget;
     }
     if (!empty($configuration['ui'])) {
         $ui = \Zbase\Ui\Ui::factory($configuration['ui']);
         if ($ui->enabled()) {
             return $ui;
         }
         return null;
     }
     $type = !empty($configuration['type']) ? $configuration['type'] : 'text';
     $id = !empty($configuration['id']) ? $configuration['id'] : null;
     if (is_null($id)) {
         throw new Exceptions\ConfigNotFoundException('Index:id is not set on Form Element Factory');
     }
     if (!empty($type)) {
         $className = zbase_model_name(null, 'class.ui.form.type.' . strtolower($type), '\\Zbase\\Ui\\Form\\Type\\' . ucfirst($type));
         $element = new $className($configuration);
         if ($element->enabled()) {
             $element->prepare();
             return $element;
         }
     }
     return null;
 }
<?php

/**
 * Dx
 *
 * @link http://dennesabing.com
 * @author Dennes B Abing <*****@*****.**>
 * @license proprietary
 * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx
 * @version 0.0.0.1
 * @since Mar 8, 2016 10:37:59 AM
 * @file widget.php
 * @project Expression project.name is undefined on line 13, column 15 in Templates/Scripting/EmptyPHP.php.
 * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php.
 *
 */
return ['type' => 'form', 'enable' => true, 'config' => ['access' => 'only::sudo', 'values' => ['default' => ['enable' => true, 'array' => function () {
    return zbase()->telegram()->settings();
}]], 'entity' => null, 'elements' => ['status' => ['type' => 'select', 'id' => 'status', 'label' => 'Status', 'multiOptions' => 'enableDisable', 'help' => ['text' => 'Disable telegram messaging.']], 'botusername' => ['type' => 'text', 'id' => 'botusername', 'label' => 'Bot Name', 'html' => ['attributes' => ['input' => ['placeholder' => 'Bot Username']]]], 'bottoken' => ['type' => 'text', 'id' => 'bottoken', 'label' => 'Bot Token', 'html' => ['attributes' => ['input' => ['placeholder' => 'Bot Token']]]], 'webhook' => ['type' => 'text', 'id' => 'webhook', 'label' => 'WebHook (Optional)', 'html' => ['attributes' => ['input' => ['value' => function () {
    $token = zbase()->telegram()->token();
    if (!empty($token)) {
        return zbase_url_from_route('telegramhook', ['token' => $token]);
    }
}, 'placeholder' => 'Webhook']]]], 'testmessage' => ['type' => 'select', 'id' => 'testmessage', 'label' => 'Send Test Message', 'multiOptions' => 'yesNo', 'help' => ['text' => 'Will send test message to Dennes.']]]]];
Esempio n. 16
0
/**
 * Retur the response format
 * @return string
 */
function zbase_response_format()
{
    return zbase()->getResponseFormat();
}
Esempio n. 17
0
 public function api()
 {
     $validation = $this->validateApi();
     if (!$validation) {
         $this->returns['message'] = 'Validation error. Kindly check error messages.';
         $this->returns['errors'] = $this->apiErrors;
     } else {
         $objectClass = $this->apiConfiguration['class'];
         $objectClassMethod = $this->apiConfiguration['method'];
         $objectResult = $objectClass::$objectClassMethod($this->params);
         /**
          * Entity
          */
         if ($objectResult instanceof \Zbase\Interfaces\EntityInterface) {
             $this->returns['result'] = $objectResult->toArray();
         }
         /**
          * Array
          */
         if (is_array($objectResult)) {
             $this->returns['result'] = $objectResult;
         }
     }
     $this->returns['parameters'] = $this->params;
     zbase()->json()->setVariable('api', $this->returns);
 }
Esempio n. 18
0
 /**
  * Delete/Remove File
  * @param object|array $file
  *
  * return boolean
  */
 public function postFileDelete($file)
 {
     if (method_exists($this, 'fileDelete')) {
         return $this->fileDelete($file);
     }
     try {
         $file = (object) $file;
         if (file_exists($this->postFileUploadFolder() . $file->filename)) {
             zbase_db_transaction_start();
             $files = $this->postFiles();
             $i = 0;
             foreach ($files as $f) {
                 if ($f['filename'] == $file->filename) {
                     unset($files[$i]);
                     unlink($this->postFileUploadFolder() . $file->filename);
                     break;
                 }
                 $i++;
             }
             $this->postSetOption('_files', $files);
             $this->save();
             zbase()->json()->addVariable('post_file_deleted', 1);
             zbase_db_transaction_commit();
             return true;
         }
     } catch (\Zbase\Exceptions\RuntimeException $e) {
         zbase_db_transaction_rollback();
         zbase_exception_throw($e);
         return false;
     }
 }
<?php

/**
 * Dx
 *
 * @link http://dennesabing.com
 * @author Dennes B Abing <*****@*****.**>
 * @license proprietary
 * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx
 * @version 0.0.0.1
 * @since Aug 23, 2016 6:00:01 PM
 * @file notifications.blade.php
 * @project Zbase
 * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php.
 */
if (zbase()->telegram()->isEnabled() && zbase_config_get('modules.account.widgets.account.tab.telegram', true)) {
    ?>
	<?php 
    echo zbase_view_render(zbase_view_file_module('account.views.telegram-user', 'account', 'zbase'), ['user' => zbase_auth_user()]);
}
Esempio n. 20
0
/**
 * Render HTML before </body>
 *
 * @return string
 */
function zbase_view_render_body()
{
    $str = '';
    zbase()->view()->prepare();
    $onloadScripts = zbase_view_placeholder_render('body_scripts_onload');
    $str .= zbase_view_placeholder_render('body_javascripts');
    $str .= zbase_view_placeholder_render('body_footer_html');
    $str .= EOF . '<script type="text/javascript">';
    $str .= EOF . zbase_view_compile(zbase_view_placeholder_render('body_scripts'));
    if (!empty(zbase_auth_is_duplex())) {
        $onloadScripts .= 'jQuery(\'body\').append(\'<div style="margin:0px auto;z-index:999999;background:yellow;width: auto;position:absolute;top:0px;padding:5px;margin-top:2px;margin-left:2px;">You are loggedin as: ' . zbase_auth_user()->displayFullDetails() . ' <a class="btn btn-danger btn-sm" href="' . zbase_url_from_route('admin.duplex', ['action' => 'unduplex']) . '">SignOut</a></div>\');';
    }
    if (!empty($onloadScripts)) {
        $str .= EOF . 'jQuery(document).ready(function(){' . EOF . $onloadScripts . EOF . '});';
    }
    $str .= EOF . '</script>';
    return $str;
}
<?php

if (zbase()->system()->inMaintenance()) {
    ?>
	<div class="alert alert-danger text-center">
		<a href="<?php 
    echo zbase_url_from_route('admin.system', ['action' => 'maintenance-mode-off']);
    ?>
" class="btn btn-danger">Stop Maintenance Mode</a>
		<br />
		<br />
		Website is currently in <strong>maintenance mode</strong>.
	</div>
<?php 
} else {
    ?>
	<div class="alert alert-info text-center">
		<a href="<?php 
    echo zbase_url_from_route('admin.system', ['action' => 'maintenance-mode-on']);
    ?>
" class="btn btn-info">Set to Maintenance Mode</a>
		<br />
		<br />
		When <strong>maintenance mode</strong> is enabled,<br />
		a maintenance message will be displayed when someone accesses the site.
		Your current IP Address of <strong><?php 
    echo zbase_ip();
    ?>
</strong> will be excluded.
	</div>
<?php 
Esempio n. 22
0
 public function controllerIndex()
 {
     if (!$this->getModule()->hasAccess()) {
         if (zbase_auth_has()) {
             return $this->unathorized(_zt('You don\'t have enough access to the resource.'));
         } else {
             return redirect()->to(zbase_url_from_route('login'));
         }
     }
     /**
      * Check for widgets
      */
     $widgetsAction = $action = str_replace('.', '-', $this->getRouteParameter('action', 'index'));
     $requestMethod = zbase_request_method();
     if (!empty($this->nodeName)) {
         $widgetsAction = $requestMethod . '-node-' . $this->nodeName . '-' . $action;
         $htmls = [];
     }
     $isAjax = zbase_request_is_ajax();
     if ($isAjax) {
         $widgetsAction = (!empty($this->nodeName) ? $requestMethod . '-node-' . $this->nodeName . '-' : '') . 'json-' . $action;
         $htmls = [];
     }
     if ($this->getModule()->hasAction($requestMethod . '-' . $action)) {
         $widgetsAction = $requestMethod . '-' . $action;
         $action = $widgetsAction;
         $htmls = [];
     }
     $widgets = $this->getModule()->pageProperties($action)->widgetsByControllerAction($widgetsAction);
     if (count($widgets) == 1) {
         $firstWidget = collect($widgets)->first();
         if ($firstWidget instanceof \Zbase\Widgets\WidgetInterface) {
             $firstWidget->pageProperties($widgetsAction);
         }
     }
     if (!is_array($widgets) && $widgets instanceof \Illuminate\Http\RedirectResponse) {
         return $widgets;
     }
     zbase()->json()->addVariable('_widget', $this->getModule()->id() . '_' . str_replace('-', '', $action));
     if (zbase_is_dev()) {
         zbase()->json()->addVariable(__METHOD__, $widgetsAction);
         if (zbase_request_is_post()) {
             zbase()->json()->addVariable('_POST_PARAMETERS', zbase_request_inputs());
         }
         zbase()->json()->addVariable('_ROUTE_PARAMETERS', zbase_route_inputs());
         zbase()->json()->addVariable('_GET_PARAMETERS', zbase_request_query_inputs());
     }
     // dd($this->getModule(), $widgetsAction, $widgets);
     if (empty($widgets)) {
         return zbase_abort(404);
     }
     foreach ($widgets as $widget) {
         if (!empty($this->nodeName)) {
             zbase()->json()->addVariable('node', ['prefix' => $this->getModule()->nodeNamespace(), 'name' => $this->nodeName, 'support' => 1]);
             $widget->setNodename($this->nodeName)->setNodeSupport(true);
         }
         if ($widget instanceof \Zbase\Widgets\ControllerInterface) {
             $v = $widget->validateWidget($action);
             if ($v instanceof \Illuminate\Contracts\Validation\Validator) {
                 if ($isAjax) {
                     zbase()->json()->addVariable('errors', $v->errors()->getMessages());
                     return new \Illuminate\Http\JsonResponse($v->errors()->getMessages(), 422);
                 } else {
                     return redirect()->to($this->getRedirectUrl())->withInput(zbase_request_inputs())->withErrors($v->errors()->getMessages());
                 }
             }
             $ret = $widget->controller($this->getRouteParameter('action', 'index'));
             if ($ret instanceof \Zbase\Exceptions\NotFoundHttpException) {
                 return $this->notFound();
             }
             if ($ret instanceof \Zbase\Exceptions\UnauthorizedException) {
                 return $this->unathorized();
             }
             if ($ret instanceof \Zbase\Exceptions\Exception) {
                 return $this->error();
             }
             if ($ret instanceof \Illuminate\Http\RedirectResponse) {
                 if ($isAjax) {
                     zbase()->json()->addVariable('redirect', $ret->getTargetUrl());
                 } else {
                     return $ret;
                 }
             }
             if (zbase_is_json()) {
                 zbase_response_format_set('json');
                 $jsonIndexName = $widget->getWidgetPrefix();
                 if (zbase_is_angular()) {
                     if ($widget instanceof \Zbase\Widgets\Type\Datatable) {
                         $angularTemplate = zbase_angular_widget_datatable($this->getModule(), $widget);
                         $jsonIndexName = $angularTemplate['serviceName'];
                     }
                 }
                 if (zbase_is_dev()) {
                     zbase()->json()->addVariable('$jsonIndexName', $jsonIndexName);
                 }
                 if (!$widget->isExporting()) {
                     zbase()->json()->addVariable($jsonIndexName, $widget->toArray());
                 }
             } else {
                 if ($isAjax) {
                     $htmls[str_replace('-', '_', $widget->id())] = $widget->render();
                 }
             }
             $widget->pageProperties($widgetsAction);
         }
     }
     if (!empty($isAjax)) {
         zbase()->json()->addVariable('_widgets', 1);
         zbase()->json()->addVariable('html', $htmls);
     } else {
         return $this->view(zbase_view_file('module.index'), array('module' => $this->getModule(), 'widgets' => $widgets));
     }
 }
Esempio n. 23
0
 /**
  * Send a reset link to the given user.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postEmail(Request $request)
 {
     // $this->validate($request, ['email' => 'required|email|exists:' . zbase_config_get('entity.user.table.name') . ',email']);
     $entity = zbase()->entity('user', [], true);
     $user = $entity->repo()->by('email', zbase_request_input('email'))->first();
     if (!empty($user)) {
         $broker = $this->getBroker();
         $response = \Password::broker($broker)->sendResetLink($this->getSendResetLinkEmailCredentials($request), $this->resetEmailBuilder());
         $user->lostPassword();
     }
     zbase()->json()->setVariable('password_success', 1);
     zbase()->json()->setVariable('_redirect', zbase_url_previous());
     if (!zbase_is_json()) {
         return redirect()->back()->with('status', trans(\Password::RESET_LINK_SENT));
     }
 }
Esempio n. 24
0
<?php

/**
 * Dx
 *
 * @link http://dennesabing.com
 * @author Dennes B Abing <*****@*****.**>
 * @license proprietary
 * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx
 * @version 0.0.0.1
 * @since Mar 5, 2016 11:51:42 PM
 * @file dsstore/module.php
 *
 */
return ['id' => 'system', 'enable' => true, 'access' => 'only::sudo', 'class' => null, 'backend' => true, 'frontend' => false, 'url' => ['backend' => 'system/{action?}/{id?}/{task?}'], 'navigation' => ['back' => ['enable' => true, 'nav' => ['order' => 9998, 'route' => ['name' => 'admin.dsorders'], 'icon' => 'fa fa-gears', 'label' => 'System', 'title' => 'System', 'children' => [['route' => ['name' => 'admin.system', 'params' => ['action' => 'maintenance']], 'icon' => 'fa fa-flash', 'label' => 'Maintenance', 'title' => 'Maintenance'], ['route' => ['name' => 'admin.system', 'params' => ['action' => 'telegram']], 'icon' => 'fa fa-flash', 'label' => 'Telegram', 'title' => 'Telegram']]]]], 'controller' => ['back' => ['action' => ['telegram' => ['page' => ['title' => 'Telegram Integration', 'headTitle' => 'Telegram Integration', 'subTitle' => '', 'breadcrumbs' => [['label' => 'Telegram Integration']]]], 'maintenance' => ['page' => ['title' => 'System Maintenance', 'headTitle' => 'System Maintenance', 'subTitle' => '', 'breadcrumbs' => [['label' => 'System Maintenance']]]], 'maintenance-mode-on' => ['page' => ['title' => 'System Maintenance - WEBSITE IN MAINTENANCE MODE!', 'headTitle' => 'System Maintenance', 'subTitle' => '', 'breadcrumbs' => [['label' => 'System Maintenance']]]], 'maintenance-mode-off' => ['page' => ['title' => 'System Maintenance', 'headTitle' => 'System Maintenance', 'subTitle' => '', 'breadcrumbs' => [['label' => 'System Maintenance']]]]]]], 'routes' => [], 'widgets' => ['back' => ['controller' => ['action' => ['maintenance' => ['system-maintenance-form' => null], 'telegram' => ['telegram-settings-form' => null], 'telegram-disable' => function () {
    zbase()->telegram()->disableUserTelegram(zbase_auth_user());
    return redirect()->to(zbase_url_previous());
}, 'post-telegram' => function () {
    zbase()->telegram()->saveSettings(zbase_request_inputs());
    return ['telegram-settings-form' => null];
}, 'post-maintenance' => function () {
    zbase()->system()->scheduleDowntime(zbase_request_inputs());
    return ['system-maintenance-form' => null];
}, 'maintenance-mode-on' => function () {
    zbase()->system()->startMaintenance();
    return redirect()->to(zbase_url_previous());
}, 'maintenance-mode-off' => function () {
    zbase()->system()->stopMaintenance();
    return redirect()->to(zbase_url_previous());
}]]]]];
<!-- BEGIN NOTIFICATION DROPDOWN -->
<?php 
$modules = zbase()->modules();
$notifications = [];
foreach ($modules as $module) {
    $notifications = array_merge($notifications, $module->getNotifications());
}
if (!empty($notifications)) {
    $notifications = zbase_collection($notifications)->sortByDesc(function ($itm) {
        return $itm->getOrder();
    })->toArray();
    foreach ($notifications as $notification) {
        echo $notification;
    }
}
?>
<!-- END NOTIFICATION DROPDOWN -->
Esempio n. 26
0
 /**
  * Return widgets by Index and IndexName
  * @param string $index
  * @param string $indexName
  */
 public function getWidgets($index, $indexName)
 {
     $section = zbase_section();
     $hasSection = $this->_v('widgets.' . $section, false);
     if (!empty($hasSection)) {
         $byAction = $this->_v('widgets.' . $section . '.controller.' . $index, []);
         if (!empty($byAction)) {
             $widgets = $this->_v('widgets.' . $section . '.controller.' . $index . '.' . $indexName, []);
         } else {
             $widgets = $this->_v('widgets.' . $section . '.controller.' . $indexName, []);
         }
         /**
          * If widgets are for this action,
          * then let;s look at if there is a "default" action to do.
          *
          * On the front/public pages, we have links like: node/action/nodeId
          *  but if there are no widgets on the given action,
          *  probably, the given action is the slug-name of an entity
          *  like:
          * 		node/node-slug-id
          * 		nodes/category-slug-id
          *  so if the module has a "default" index, then we will load that default widget
          */
         if (empty($widgets)) {
             $widgets = $this->_v('widgets.' . $section . '.controller.' . $index . '.default', $this->_v('widgets.' . $section . '.controller.default', []));
         }
     } else {
         $widgets = $this->_v('widgets.controller.' . $indexName, []);
     }
     if (is_array($widgets)) {
         foreach ($widgets as $name => $path) {
             if ($path instanceof \Closure) {
                 $path();
                 continue;
             }
             if (is_string($path) && zbase_file_exists($path)) {
                 $config = (require $path);
             }
             if (!empty($config) && is_array($config)) {
                 if (empty($config['id'])) {
                     $config['id'] = $name;
                 }
                 $widget = zbase_widget(['id' => $name, 'config' => $config]);
             }
             if (is_null($path)) {
                 $widget = zbase()->widget($name, [], true);
             }
             if ($widget instanceof \Zbase\Widgets\WidgetInterface) {
                 $widget->setModule($this);
                 $widgets[$name] = $widget;
             }
         }
         return $widgets;
     }
     return $widgets;
 }
Esempio n. 27
0
 /**
  * HTML the ui
  * @return string
  */
 public function __toString()
 {
     $this->prepare();
     try {
         if (!is_null($this->_viewFile) && empty($this->_rendered)) {
             if (!zbase_request_is_ajax()) {
                 zbase()->view()->multiAdd($this->_v('view.library', false));
             }
             $this->_viewParams['ui'] = $this;
             $str = $this->preTag();
             $str .= $this->htmlPreContent();
             if (!empty($this->_viewFileContent)) {
                 $str .= zbase_view_render(zbase_view_file_contents($this->_viewFile), $this->getViewParams());
             } else {
                 $str .= zbase_view_render($this->_viewFile, $this->getViewParams());
             }
             $str .= $this->htmlPostContent();
             $str .= $this->postTag();
             $this->_rendered = true;
             return $str;
         }
         return '';
     } catch (\Exception $e) {
         if (zbase_is_dev()) {
             dd($e);
         }
         zbase_abort(500);
     }
 }
Esempio n. 28
0
 /**
  * Telegram Hook
  * http://Agse-local.biz/telegram/237861793:AAFW6v2ZRg5oPHiQWuedtXuqs2GAguCSZU8
  */
 public function telegramHook()
 {
     zbase()->telegram()->receiveMessage();
 }
Esempio n. 29
0
/**
 * Write To Console
 */
function _zdd($msg)
{
    if (zbase_is_console()) {
        zbase()->consoleCommand()->info($msg);
    }
}
Esempio n. 30
0
 /**
  * User By Email
  * @param string $email
  * @return object|array
  */
 public static function findUserByEmail($email)
 {
     if (is_array($email) && !empty($email['email'])) {
         $email = $email['email'];
     }
     if (!empty($email)) {
         $entity = zbase()->entity('user', [], true);
         $user = $entity->repo()->by('email', $email)->first();
         return ['user' => $user, 'user_profile' => $user->profile()];
     }
 }