예제 #1
0
파일: CronTodo.php 프로젝트: minutephp/cron
 public function getTodoList(ImportEvent $event)
 {
     $time = time() - $this->config->get(CronJobs::cronKey . '/lastRun', 0);
     $running = $time < 3600;
     $todos[] = ['name' => 'Check cron job are running', 'description' => $running ? "" : "Cron daemon is not running properly (ignore during development)", 'status' => $running ? 'complete' : 'incomplete', 'link' => '/admin/cron-jobs'];
     $event->addContent(['Cron' => $todos]);
 }
예제 #2
0
 public function getTypes(ImportEvent $event)
 {
     $types = array_map(function ($f) {
         return $f['TYPE'];
     }, MConfig::select('TYPE')->get()->toArray());
     $event->setContent(['types' => $types]);
 }
예제 #3
0
 public function getCached(ImportEvent $event)
 {
     $data = $this->cache->get('admin-panels-cached', function () use($event) {
         $fresh = new ImportEvent($event->getViewEvent());
         $this->dispatcher->fire(AdminEvent::IMPORT_ADMIN_DASHBOARD_PANELS, $fresh);
         return $fresh->getContent();
     }, 300);
     $event->setContent($data);
 }
예제 #4
0
 public function adminDashboardPanel(ImportEvent $event)
 {
     $dir = realpath(sprintf('%s/../../../', __DIR__));
     $dirs = glob("{$dir}/*");
     $count = count($dirs) - 1;
     //ignore framework
     $panels = [['type' => 'site', 'title' => 'Plugins', 'stats' => "{$count} installed", 'icon' => 'fa-plug', 'priority' => 99, 'href' => '/admin/plugins', 'cta' => 'Get more..', 'bg' => 'bg-aqua']];
     $event->addContent($panels);
 }
예제 #5
0
 public function getSubsCount(ImportEvent $event)
 {
     $lists = MArList::all();
     foreach ($lists as $list) {
         $list_id = $list->ar_list_id;
         $subs = $this->getTargetUserIds($list_id);
         $results[$list_id] = count($subs);
     }
     $event->setContent($results ?? []);
 }
예제 #6
0
 public function getTodoList(ImportEvent $event)
 {
     $titles = $this->config->get('seo/titles', []);
     $groups = $this->config->get('groups/groups', []);
     $todos[] = ['name' => 'Create a "signature" key in public keys', 'description' => 'To use {signature} tag in emails', 'status' => $this->config->get('public/signature') ? 'complete' : 'incomplete', 'link' => '/admin/config'];
     $todos[] = ['name' => 'Create a "logo_url_dark" key in public keys', 'description' => 'Logo image for white background', 'status' => $this->config->get('public/logo_url_dark') ? 'complete' : 'incomplete', 'link' => '/admin/config'];
     $todos[] = ['name' => 'Create a "logo_url_light" key in public keys', 'description' => 'Logo image for black background', 'status' => $this->config->get('public/logo_url_light') ? 'complete' : 'incomplete', 'link' => '/admin/config'];
     $todos[] = ['name' => 'Enable "Minify" plugin to compress js and css', 'description' => 'For faster website loading', 'status' => is_callable(['Minute\\Minify\\Minify', 'minify']) ? 'complete' : 'incomplete', 'link' => '/admin/plugins'];
     $todos[] = ['name' => 'Install web analytics', 'description' => 'For measuring traffic and advertising ROI', 'status' => !empty($this->config->get('trackers/trackers')) ? 'complete' : 'incomplete', 'link' => '/admin/analytics'];
     $todos[] = ['name' => 'Setup page titles and descriptions', 'description' => 'Helps improve website SEO', 'status' => !empty($titles['/login']) ? 'complete' : 'incomplete', 'link' => '/admin/page-titles'];
     $todos[] = ['name' => 'Setup user groups for site', 'description' => 'To control website access', 'status' => is_array($groups) && count($groups) > 1 ? 'complete' : 'incomplete', 'link' => '/admin/user-groups'];
     $event->addContent(['Admin' => $todos]);
 }
예제 #7
0
 public function getPages(ImportEvent $event)
 {
     $urls = [];
     $routes = $this->router->getRouteCollection();
     /** @var RouteEx $route */
     foreach ($routes as $route) {
         $method = $route->getMethods()[0];
         $hasView = $route->getDefault('_noView') !== true;
         if ($method === 'GET' && $hasView) {
             $compiled = $route->compile();
             $urls[] = $compiled->getStaticPrefix();
             //$urls[$url] = !preg_match('~^/(admin|\_|first\-run|auth)~', $url);
         }
     }
     $event->setContent($urls);
 }
예제 #8
0
 public function compile(ImportEvent $importEvent)
 {
     $results = ['constants' => [], 'handlers' => []];
     $wildcards = [];
     foreach (['constants', 'handlers'] as $type) {
         $e = $type === 'constants';
         foreach (['App', 'Minute'] as $dir) {
             $prefix = $e ? "{$dir}\\Event\\" : "{$dir}\\EventHandler\\";
             $dirs = $this->resolver->find($prefix);
             if (!empty($dirs)) {
                 $finder = new Finder();
                 $fix = function ($path, $replacement) use($prefix) {
                     return preg_replace('/\\.php$/', '', preg_replace(sprintf('/^.*%s/i', preg_quote($prefix)), $replacement, $path));
                 };
                 $files = $finder->depth('< 3')->files()->in($dirs)->name('*.php')->contains($e ? 'const ' : 'function ');
                 foreach ($files as $file) {
                     $classPath = $this->utils->dosPath((string) $file);
                     $classPath = $fix($classPath, $prefix);
                     $basename = $fix($classPath, '');
                     if ($reflector = new ReflectionClass($classPath)) {
                         if ($e) {
                             foreach ($reflector->getConstants() as $value => $constant) {
                                 $parts = explode('.', $constant);
                                 for ($i = 0, $j = count($parts) - 1; $i < $j; $i++) {
                                     $wildcard = join('.', array_slice($parts, 0, $i + 1)) . '.*';
                                     $wildcards[$wildcard] = ['name' => sprintf('%s', strtr($wildcard, '.', '_')), 'value' => $wildcard, 'group' => 'Wildcard events'];
                                 }
                                 $results['constants'][] = ['name' => sprintf('%s in %s', $this->utils->filename($value), $basename), 'value' => $constant, 'group' => $parts[0]];
                             }
                         } else {
                             foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
                                 if (!preg_match('/^\\_/', $method->name)) {
                                     $value = sprintf("%s@%s", $method->class, $method->name);
                                     $parts = explode('\\', $classPath);
                                     $results['handlers'][] = ['name' => sprintf('%s@%s', $basename, $method->name), 'value' => $value, 'group' => $parts[2] ?? 'App'];
                                 }
                             }
                         }
                     }
                 }
             }
         }
         usort($results[$type], function ($a, $b) {
             return $a['group'] === $b['group'] ? $a['value'] <=> $b['value'] : $a['group'] <=> $b['group'];
         });
     }
     usort($wildcards, function ($a, $b) {
         return $a['value'] <=> $b['value'];
     });
     foreach ($wildcards as $wildcard => $event) {
         $results['constants'][] = $event;
     }
     $importEvent->addContent($results);
 }
예제 #9
0
 public function compile(ImportEvent $event)
 {
     $plugins = [];
     $basedir = realpath(sprintf('%s/../../../..', __DIR__));
     $results = $this->cache->get('plugin-list', function () {
         return $this->client->getPackages();
     }, 300);
     foreach ($results ?? [] as $package) {
         $plugin = $package['name'];
         if ($plugin !== 'minutephp/minutephp' && $plugin !== 'minutephp/framework') {
             $name = join(' ', array_slice(preg_split('/\\W+/', $plugin), 1));
             $vendor = dirname($plugin);
             $official = $vendor === 'minutephp';
             $type = $official ? 'official' : 'thirdparty';
             $required = ['admin', 'framework'];
             $plugins[$type][] = ['plugin' => $plugin, 'name' => $name, 'description' => $package['description'], 'installed' => is_dir("{$basedir}/{$plugin}"), 'required' => $official && in_array($name, $required), 'src' => $package['src']];
         }
     }
     $event->setContent($plugins);
 }
예제 #10
0
파일: AuthTodo.php 프로젝트: minutephp/auth
 public function getTodoList(ImportEvent $event)
 {
     $logins = ['Twitter', 'Google', 'Facebook'];
     $providers = $this->config->get('private/auth/providers');
     foreach ($logins as $login) {
         $enabled = false;
         foreach ($providers as $provider) {
             if ($provider['name'] === $login) {
                 $enabled = $provider['enabled'] == 'true';
                 break;
             }
         }
         $todos[] = ['name' => "Enable {$login} login provider", 'status' => $enabled ? 'complete' : 'incomplete', 'link' => '/admin/logins'];
         if ($enabled) {
             $todos[] = $this->todoMaker->createManualItem("check-{$login}-login", "Check {$login} login", "Check {$login} login app is working properly", '/login');
         }
     }
     $todos[] = $this->todoMaker->createManualItem("check-forgot-password-email", "Check forgot password email", 'Check email is being delivered and working properly', '/forgot-password');
     $event->addContent(['Authentication' => $todos ?? []]);
 }
예제 #11
0
 public function adminLinks(ImportEvent $event)
 {
     $links = ['debug' => ['title' => 'Debug tools', 'icon' => 'fa-code', 'priority' => 98, 'parent' => 'expert', 'href' => '/admin/debug']];
     $event->addContent($links);
 }
예제 #12
0
 public function getTodoList(ImportEvent $event)
 {
     $todos[] = $this->todoMaker->createManualItem("check-opcache-is-working", "Check PHP's OPcache is working", 'Can be ignored during development', '/admin/debug');
     $event->addContent(['Debug' => $todos]);
 }
예제 #13
0
파일: AuthMenu.php 프로젝트: minutephp/auth
 public function adminLinks(ImportEvent $event)
 {
     $links = ['logins' => ['title' => 'Social logins', 'icon' => 'fa-sign-in', 'priority' => 1, 'parent' => 'expert', 'href' => '/admin/logins']];
     $event->addContent($links);
 }
예제 #14
0
파일: CronMenu.php 프로젝트: minutephp/cron
 public function adminLinks(ImportEvent $event)
 {
     $links = ['cron' => ['title' => 'Cron jobs', 'icon' => 'fa-clock-o', 'priority' => 5, 'parent' => 'expert', 'href' => '/admin/cron-jobs']];
     $event->addContent($links);
 }
예제 #15
0
 public function getTodoList(ImportEvent $event)
 {
     $todos[] = ['name' => "Create autoresponder campaign", 'description' => 'An autoresponder campaign and at least 3 follow-up messages', 'status' => MArMessage::count() > 2 ? 'complete' : 'incomplete', 'link' => '/admin/autoresponder/campaigns'];
     $todos[] = ['name' => "Create mailing lists", 'description' => 'At least two different mailing list targets', 'status' => MArList::count() >= 2 ? 'complete' : 'incomplete', 'link' => '/admin/autoresponder/lists'];
     $event->addContent(['Autoresponder' => $todos]);
 }
예제 #16
0
 public function memberLinks(ImportEvent $event)
 {
     $links = ['member-support' => ['title' => "Help & Support", 'icon' => 'fa-life-buoy', 'priority' => 80], 'member-support-desk' => ['title' => "Support desk", 'icon' => 'fa-question-circle', 'priority' => 1, 'parent' => 'member-support', 'href' => '/members/support']];
     $event->addContent($links);
 }
예제 #17
0
 public function adminLinks(ImportEvent $event)
 {
     $links = ['autoresponder' => ['title' => 'Auto responders', 'icon' => 'fa-retweet', 'priority' => 2, 'parent' => 'mails', 'href' => '/admin/autoresponder/campaigns'], 'broadcast' => ['title' => 'Broadcasts', 'icon' => 'fa-bullhorn', 'priority' => 3, 'parent' => 'mails', 'href' => '/admin/autoresponder/broadcast'], 'mailingList' => ['title' => 'Mailing Lists', 'icon' => 'fa-list', 'priority' => 4, 'parent' => 'mails', 'href' => '/admin/autoresponder/lists']];
     $event->addContent($links);
 }
예제 #18
0
파일: TodoMenu.php 프로젝트: minutephp/todo
 public function adminLinks(ImportEvent $event)
 {
     $links = ['todos' => ['title' => 'Todo list', 'icon' => 'fa-list-alt', 'priority' => 3, 'href' => '/admin/todos']];
     $event->addContent($links);
 }
예제 #19
0
 public function adminLinks(ImportEvent $event)
 {
     $links = ['minify' => ['title' => 'Minify', 'icon' => 'fa-compress', 'priority' => 70, 'parent' => 'expert', 'href' => '/admin/minify']];
     $event->addContent($links);
 }
예제 #20
0
 public function getTodoList(ImportEvent $event)
 {
     $todos[] = ['name' => 'Enable minifier for CSS', 'description' => '', 'status' => $this->config->get('minify/css/files') ? 'complete' : 'incomplete', 'link' => '/admin/minify'];
     $todos[] = ['name' => 'Enable minifier for Javascript', 'description' => '', 'status' => $this->config->get('minify/js/files') ? 'complete' : 'incomplete', 'link' => '/admin/minify'];
     $event->addContent(['Minifier' => $todos]);
 }
예제 #21
0
 public function getHttpdConf(ImportEvent $event)
 {
     $httpd = file_get_contents(__DIR__ . '/data/apache.conf.txt');
     $conf = $this->engine->render($httpd, array_merge($this->config->getPublicVars(), ['path' => realpath($this->bootLoader->getBaseDir() . '/public')]));
     $event->setContent(['conf' => $conf]);
 }
예제 #22
0
 public function getTodoList(ImportEvent $event)
 {
     $todos[] = ['name' => 'Setup Gmail integration for support desk', 'description' => 'Allows members to update support tickets via email', 'status' => $this->config->get('google/gmail/auth/token/access_token') ? 'complete' : 'incomplete', 'link' => '/admin/gmail/setup'];
     $todos[] = ['name' => 'Create "support" pages', 'description' => 'Create pages with page type as "support"', 'status' => MPage::where('type', '=', 'support')->where('enabled', '=', 'true')->count() ? 'complete' : 'incomplete', 'link' => '/admin/pages'];
     $event->addContent(['Support' => $todos]);
 }
예제 #23
0
 public function adminLinks(ImportEvent $event)
 {
     $links = ['dashboard' => ['title' => 'Dashboard', 'href' => '/admin', 'icon' => 'fa-dashboard', 'priority' => 1], 'user-groups' => ['title' => 'User groups', 'icon' => 'fa-users', 'priority' => 2, 'parent' => 'expert', 'href' => '/admin/user-groups'], 'plugins' => ['title' => 'Plugins', 'icon' => 'fa-plug', 'priority' => 999, 'href' => '/admin/plugins'], 'expert' => ['title' => 'Expert users', 'icon' => 'fa-th', 'priority' => 98], 'config' => ['title' => 'Site config', 'icon' => 'fa-cog', 'priority' => 3, 'parent' => 'expert', 'href' => '/admin/config'], 'seo' => ['title' => 'Page titles / SEO', 'icon' => 'fa-search', 'priority' => 4, 'parent' => 'expert', 'href' => '/admin/page-titles'], 'analytics' => ['title' => 'Web analytics', 'icon' => 'fa-area-chart', 'priority' => 9, 'parent' => 'expert', 'href' => '/admin/analytics'], 'event-manager' => ['title' => 'Events manager', 'icon' => 'fa-magnet', 'priority' => 99, 'parent' => 'expert', 'href' => '/admin/events']];
     $event->addContent($links);
 }
예제 #24
0
 public function adminDashboardPanel(ImportEvent $event)
 {
     $count = MSupportTicket::where('state', '=', 'open')->count();
     $panels = [['type' => 'site', 'title' => 'Support', 'stats' => "{$count} open", 'icon' => 'fa-life-bouy', 'priority' => 3, 'href' => '/admin/support/tickets/open', 'cta' => 'View tickets..']];
     $event->addContent($panels);
 }