/** * Execute the console command. * * @return mixed */ public function fire() { //echo $this->argument('example'); //echo $this->option('example'); $app_name = $this->option('app_name'); $app_id = $this->option('app_id'); if ($app_name) { $plugins = \Plugin::whereHas('applications', function ($q) use($app_name) { $q->where('name', $app_name); })->get(); } else { if ($app_id) { $plugins = \Plugin::whereHas('applications', function ($q) use($app_id) { $q->where('id', $app_id); })->get(); } else { $plugins = \Plugin::get(); } } echo "\n"; foreach ($plugins as $plugin) { //Register appliation service providers \App::register($plugin->service_provider); echo "Publishing for " . $plugin->name . "\n"; } //we now need to re asset publish? //TODO: do we really want to force this 100% of the time? \Artisan::call('vendor:publish', ['--force' => 1]); }
/** * Display the main page of the permission settings */ public function index() { $permissionGroups = Permission::getAllGroupByPlugin(); $example = isset($this->roleId) ? array('roleId' => $this->roleId) : array(); $data = RolePermission::getListByExample(new DBExample($example)); $values = array(); foreach ($data as $value) { $values[$value->permissionId][$value->roleId] = $value->value; } $roles = isset($this->roleId) ? array(Role::getById($this->roleId)) : Role::getAll(null, array(), array(), true); $param = array('id' => 'permissions-form', 'fieldsets' => array('form' => array(), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button')))))); foreach ($roles as $role) { foreach ($permissionGroups as $group => $permissions) { if (Plugin::get($group)) { foreach ($permissions as $permission) { if ($role->id == Role::ADMIN_ROLE_ID) { $default = 1; } elseif (isset($values[$permission->id][$role->id])) { $default = $values[$permission->id][$role->id]; } else { $default = 0; } $param['fieldsets']['form'][] = new CheckboxInput(array('name' => "permission-{$permission->id}-{$role->id}", 'disabled' => $role->id == Role::ADMIN_ROLE_ID || $role->id == Role::GUEST_ROLE_ID && !$permission->availableForGuests, 'default' => $default, 'class' => $permission->id == Permission::ALL_PRIVILEGES_ID ? 'select-all' : '', 'nl' => false)); } } } } $form = new Form($param); if (!$form->submitted()) { $page = View::make(Plugin::current()->getView("permissions.tpl"), array('permissions' => $permissionGroups, 'fields' => $form->inputs, 'roles' => $roles)); return NoSidebarTab::make(array('icon' => 'unlock-alt', 'title' => Lang::get('permissions.page-title'), 'page' => $form->wrap($page))); } else { try { foreach ($form->inputs as $name => $field) { if (preg_match('/^permission\\-(\\d+)\\-(\\d+)$/', $name, $match)) { $permissionId = $match[1]; $roleId = $match[2]; $value = App::request()->getBody($name) ? 1 : 0; if ($roleId != Role::ADMIN_ROLE_ID && !($roleId == Role::GUEST_ROLE_ID && !$permission->availableForGuests)) { $permission = new RolePermission(); $permission->set(array('roleId' => $roleId, 'permissionId' => $permissionId, 'value' => $value)); $permission->save(); } } } App::logger()->info('Permissions were succesfully updated'); return $form->response(Form::STATUS_SUCCESS, Lang::get("roles.permissions-update-success")); } catch (Exception $e) { App::logger()->error('An error occured while updating permissions'); return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : Lang::get("roles.permissions-update-error")); } } }
public function index($plugin) { $this->admin_only('plugin config'); $data = $this->init_view_data(); $plugin = Plugin::get($plugin); PluginData::setPluginId($plugin->getPluginId()); OpenVBX::$currentPlugin = $plugin; try { $data['info'] = $plugin->getInfo(); $data['script'] = $plugin->getScript('config'); } catch (PluginException $e) { error_log($e->getMessage()); $data['script'] = null; } $this->respond('', 'page/config', $data); }
public function plus_hook($module, $action, $data = NULL, $return = false) { $action_name = 'hook_' . $module . '_' . $action; $list = $this->model->table('plugin')->where('status=1')->select(); $plugin_list = Plugin::get(); if (!empty($list)) { foreach ($list as $value) { $action_array = $plugin_list[$value['file']]; if (!empty($action_array)) { if (in_array($action_name, $action_array)) { if ($return) { return Plugin::run($value['file'], $action_name, $data, $return); } else { Plugin::run($value['file'], $action_name, $data); } } } } } }
/** * Display and treat application settings */ public function settings() { $languages = array_map(function ($language) { return $language->label; }, Language::getAll('tag')); $roleObjects = Role::getListByExample(new DBExample(array('id' => array('$ne' => 0))), 'id'); $roles = array(); foreach ($roleObjects as $role) { $roles[$role->id] = Lang::get("roles.role-{$role->id}-label"); } $items = MenuItem::getAvailableItems(); $menuItems = array(); foreach ($items as $item) { if ($item->action && !preg_match('/^(javascript\\:|#)/', $item->action) && (!$item->target || $item->target == 'newtab')) { if ($item->label === 'user.username') { $item->label = App::session()->getUser()->username; } $menuItems[$item->action] = $item->label; } else { foreach ($item->visibleItems as $subitem) { if ($item->label === 'user.username') { $item->label = App::session()->getUser()->username; } if (!preg_match('/^(javascript\\:|#)/', $subitem->action) && (!$subitem->target || $subitem->target == 'newtab')) { $menuItems[$subitem->action] = $item->label . " > " . $subitem->label; } } } } $api = new HawkApi(); try { $updates = $api->getCoreAvailableUpdates(); } catch (\Hawk\HawkApiException $e) { $updates = array(); } $param = array('id' => 'settings-form', 'upload' => true, 'fieldsets' => array('main' => array(new TextInput(array('name' => 'main_sitename', 'required' => true, 'default' => Option::get('main.sitename'), 'label' => Lang::get('admin.settings-sitename-label'))), new SelectInput(array('name' => 'main_language', 'required' => true, 'options' => $languages, 'default' => Option::get('main.language'), 'label' => Lang::get('admin.settings-language-label'))), new SelectInput(array('name' => 'main_timezone', 'required' => true, 'options' => array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()), 'default' => Option::get('main.timezone'), 'label' => Lang::get('admin.settings-timezone-label'))), new SelectInput(array('name' => 'main_currency', 'required' => true, 'options' => array('EUR' => 'Euro (€)', 'USD' => 'US Dollar ($)'), 'default' => Option::get('main.currency'), 'label' => Lang::get('admin.settings-currency-label'))), new FileInput(array('name' => 'logo', 'label' => Lang::get('admin.settings-logo-label'), 'after' => Option::get('main.logo') ? '<img src="' . Plugin::get('main')->getUserfilesUrl(Option::get('main.logo')) . '" class="settings-logo-preview" />' : '', 'maxSize' => 200000, 'extensions' => array('gif', 'png', 'jpg', 'jpeg'))), new FileInput(array('name' => 'favicon', 'label' => Lang::get('admin.settings-favicon-label'), 'after' => Option::get('main.favicon') ? '<img src="' . Plugin::get('main')->getUserfilesUrl(Option::get('main.favicon')) . '" class="settings-favicon-preview" />' : '', 'maxSize' => 20000, 'extensions' => array('gif', 'png', 'jpg', 'jpeg', 'ico')))), 'referencing' => call_user_func(function () use($languages) { $inputs = array(); foreach ($languages as $tag => $language) { $inputs[] = new TextInput(array('name' => 'main_page-title-' . $tag, 'default' => Option::get('main.page-title-' . $tag))); $inputs[] = new TextareaInput(array('name' => 'main_page-description-' . $tag, 'default' => Option::get('main.page-description-' . $tag))); $inputs[] = new TextInput(array('name' => 'main_page-keywords-' . $tag, 'default' => Option::get('main.page-keywords-' . $tag))); } return $inputs; }), 'home' => array(new RadioInput(array('name' => 'main_home-page-type', 'options' => array('default' => Lang::get('admin.settings-home-page-type-default'), 'custom' => Lang::get('admin.settings-home-page-type-custom'), 'page' => Lang::get('admin.settings-home-page-type-page')), 'default' => Option::get('main.home-page-type') ? Option::get('main.home-page-type') : 'default', 'label' => Lang::get('admin.settings-home-page-type-label'), 'layout' => 'vertical', 'attributes' => array('e-value' => 'homePage.type'))), new WysiwygInput(array('name' => 'main_home-page-html', 'id' => 'home-page-html', 'label' => Lang::get('admin.settings-home-page-html-label'), 'default' => Option::get('main.home-page-html'))), new SelectInput(array('name' => 'main_home-page-item', 'id' => 'home-page-item', 'label' => Lang::get('admin.settings-home-page-item-label'), 'options' => $menuItems, 'value' => Option::get('main.home-page-item'))), new CheckboxInput(array('name' => 'main_open-last-tabs', 'label' => Lang::get('admin.settings-open-last-tabs'), 'default' => Option::get('main.open-last-tabs'), 'dataType' => 'int'))), 'users' => array(new RadioInput(array('name' => 'main_allow-guest', 'options' => array(0 => Lang::get('main.no-txt'), 1 => Lang::get('main.yes-txt')), 'default' => Option::get('main.allow-guest') ? Option::get('main.allow-guest') : 0, 'label' => Lang::get('admin.settings-allow-guest-label'))), new RadioInput(array('name' => 'main_open-register', 'options' => array(0 => Lang::get('admin.settings-open-register-off'), 1 => Lang::get('admin.settings-open-register-on')), 'layout' => 'vertical', 'label' => Lang::get('admin.settings-open-registers-label'), 'default' => Option::get('main.open-register') ? Option::get('main.open-register') : 0, 'attributes' => array('e-value' => 'register.open'))), new CheckboxInput(array('name' => 'main_confirm-register-email', 'label' => Lang::get('admin.settings-confirm-email-label'), 'default' => Option::get('main.confirm-register-email'), 'dataType' => 'int', 'attributes' => array('e-value' => 'register.checkEmail'))), new WysiwygInput(array('name' => 'main_confirm-email-content', 'id' => 'settings-confirm-email-content-input', 'default' => Option::get('main.confirm-email-content'), 'label' => Lang::get('admin.settings-confirm-email-content-label'), 'labelWidth' => 'auto')), new CheckboxInput(array('name' => 'main_confirm-register-terms', 'label' => Lang::get('admin.settings-confirm-terms-label'), 'default' => Option::get('main.confirm-register-terms'), 'dataType' => 'int', 'labelWidth' => 'auto', 'attributes' => array('e-value' => 'register.checkTerms'))), new WysiwygInput(array('name' => 'main_terms', 'id' => 'settings-terms-input', 'label' => Lang::get('admin.settings-terms-label'), 'labelWidth' => 'auto', 'default' => Option::get('main.terms'))), new SelectInput(array('name' => 'roles_default-role', 'label' => Lang::get('admin.settings-default-role-label'), 'options' => $roles, 'default' => Option::get('roles.default-role')))), 'email' => array(new EmailInput(array('name' => 'main_mailer-from', 'default' => Option::get('main.mailer-from') ? Option::get('main.mailer-from') : App::session()->getUser()->email, 'label' => Lang::get('admin.settings-mailer-from-label'))), new TextInput(array('name' => 'main_mailer-from-name', 'default' => Option::get('main.mailer-from-name') ? Option::get('main.mailer-from-name') : App::session()->getUser()->getDisplayName(), 'label' => Lang::get('admin.settings-mailer-from-name-label'))), new SelectInput(array('name' => 'main_mailer-type', 'default' => Option::get('main.mailer-type'), 'options' => array('mail' => Lang::get('admin.settings-mailer-type-mail-value'), 'smtp' => Lang::get('admin.settings-mailer-type-smtp-value'), 'pop3' => Lang::get('admin.settings-mailer-type-pop3-value')), 'label' => Lang::get('admin.settings-mailer-type-label'), 'attributes' => array('e-value' => 'mail.type'))), new TextInput(array('name' => 'main_mailer-host', 'default' => Option::get('main.mailer-host'), 'label' => Lang::get('admin.settings-mailer-host-label'))), new IntegerInput(array('name' => 'main_mailer-port', 'default' => Option::get('main.mailer-port'), 'label' => Lang::get('admin.settings-mailer-port-label'), 'size' => 4)), new TextInput(array('name' => 'main_mailer-username', 'default' => Option::get('main.mailer-username'), 'label' => Lang::get('admin.settings-mailer-username-label'))), new PasswordInput(array('name' => 'main_mailer-password', 'encrypt' => 'Crypto::aes256Encode', 'decrypt' => 'Crypto::aes256Decode', 'default' => Option::get('main.mailer-password'), 'label' => Lang::get('admin.settings-mailer-password-label'))), new SelectInput(array('name' => 'main_smtp-secured', 'options' => array('' => Lang::get('main.no-txt'), 'ssl' => 'SSL', 'tsl' => 'TSL'), 'label' => Lang::get('admin.settings-smtp-secured-label')))), '_submits' => array(empty($updates) ? new HtmlInput(array('value' => '<span class="btn btn-success">' . Lang::get('admin.hawk-version-up-to-date', array('version' => HAWK_VERSION)) . '</span>')) : new ButtonInput(array('name' => 'update-hawk', 'value' => Lang::get('admin.update-page-update-hawk-btn', array('version' => end($updates)['version'])), 'icon' => 'refresh', 'id' => 'update-hawk-btn', 'attributes' => array('e-click' => 'function(){ updateHawk("' . end($updates)['version'] . '"); }'), 'class' => 'btn-warning')), new SubmitInput(array('name' => 'save', 'value' => Lang::get('main.valid-button'), 'class' => 'pull-right'))))); $form = new Form($param); if (!$form->submitted()) { // Display the form $this->addCss(Plugin::current()->getCssUrl('settings.less')); $page = View::make(Plugin::current()->getView('settings.tpl'), array('form' => $form, 'languages' => $languages)); $this->addKeysToJavaScript('admin.update-page-confirm-update-hawk'); $this->addJavaScript(Plugin::current()->getJsUrl('settings.js')); return NoSidebarTab::make(array('icon' => 'cogs', 'title' => Lang::get('admin.settings-page-name'), 'description' => Lang::get('admin.settings-page-description'), 'page' => $page)); } else { // treat the form try { if ($form->check()) { // register scalar values foreach ($form->inputs as $name => $field) { if (!$field instanceof \Hawk\FileInput && !$field instanceof \Hawk\ButtonInput && !$field instanceof \Hawk\HtmlInput) { $value = $field->dbvalue(); if ($value === null) { $value = '0'; } $optionName = str_replace('_', '.', $name); App::logger()->error("Option name =" . $optionName . 'X'); App::logger()->error("basename=" . $value . 'X'); Option::set($optionName, $value); } elseif ($field instanceof \Hawk\FileInput) { $upload = Upload::getInstance($name); if ($upload) { try { $file = $upload->getFile(); $dir = Plugin::get('main')->getPublicUserfilesDir(); if (!is_dir($dir)) { mkdir($dir, 0755); } if ($name == 'favicon') { $basename = uniqid() . '.ico'; $generator = new \PHPICO($file->tmpFile, array(array(16, 16), array(32, 32), array(48, 48), array(64, 64))); $generator->save_ico($dir . $basename); } else { $basename = uniqid() . '.' . $file->extension; $upload->move($file, $dir, $basename); } // remove the old image @unlink($dir . Option::get("main.{$name}")); App::logger()->error("Option name = " . $name); App::logger()->error("main.{$name}"); App::logger()->error("basename=" . $basename); Option::set("main.{$name}", $basename); } catch (ImageException $e) { $form->error($name, Lang::get('form.image-format')); throw $e; } } } } // Register the favicon App::logger()->info('The options of the application has been updated by ' . App::session()->getUser()->username); return $form->response(Form::STATUS_SUCCESS, Lang::get('admin.settings-save-success')); } } catch (Exception $e) { App::logger()->error('An error occured while updating application options'); return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : Lang::get('admin.settings-save-error')); } } }
$project_wave = $objForm->getPost('project_wave'); if (!empty($project_wave)) { $criteria['project_wave'] = $project_wave; } $team = $objForm->getPost('team'); if (!empty($team)) { $criteria['team_id'] = $team; } $position = $objForm->getPost('position'); if (!empty($position)) { $criteria['position_id'] = $position; } if (!empty($criteria)) { $rows = $objRecruitment->getRecruitmentByCriteria($criteria); //var_dump($rows); echo Plugin::get('recruitment_search', array('rows' => $rows)); exit; } else { echo ''; exit; } } $header = 'Recruitment :: Search'; require_once '_header.php'; ?> <h1><?php echo $header; ?> <a class="h2rightlink" id="clearSearch"><u>Clear search</u></a> </h1> <?php
private function applet_headers($applet, $plugin_dir_name) { $plugin = Plugin::get($plugin_dir_name); $plugin_info = $plugin ? $plugin->getInfo() : false; header("X-OpenVBX-Applet-Version: {$applet->version}"); if ($plugin_info) { header("X-OpenVBX-Plugin: {$plugin_info['name']}"); header("X-OpenVBX-Plugin-Version: {$plugin_info['version']}"); } header("X-OpenVBX-Applet: {$applet->name}"); }
<?php namespace Hawk; try { /*** Initialize the application ***/ define('SCRIPT_START_TIME', microtime(true)); define('ROOT_DIR', __DIR__ . '/'); define('INCLUDES_DIR', ROOT_DIR . 'includes/'); include ROOT_DIR . 'start.php'; App::logger()->debug('script has been Initialized'); (new Event('process-start'))->trigger(); /*** Initialize the plugins ***/ $plugins = App::conf()->has('db') ? Plugin::getActivePlugins() : array(Plugin::get('main'), Plugin::get('install')); foreach ($plugins as $plugin) { if (is_file($plugin->getStartFile())) { include $plugin->getStartFile(); } } /*** Initialize the theme ***/ if (is_file(Theme::getSelected()->getStartFile())) { include Theme::getSelected()->getStartFile(); } (new Event('before-routing'))->trigger(); /*** Execute action just after routing ***/ Event::on('after-routing', function ($event) { $route = $event->getData('route'); if (!App::conf()->has('db') && App::request()->getUri() == App::router()->getUri('index')) { // The application is not installed yet App::logger()->notice('Hawk is not installed yet, redirect to install process page'); App::response()->redirectToAction('install');
<?php $objPage = new Page(); $groups = $objPage->getGroups('', array('order' => 'asc')); require_once '_header.php'; ?> <h1><?php echo $header; ?> </h1> <div class="fl_l"> <h2>Page Groups</h2> <div data-plugin="page_groups" class="reloadSection" data-current="1" > <?php echo Plugin::get('page_groups', array('groups' => $groups)); ?> </div> </div> <div style="margin-left:45%;"> <div data-plugin="pages_in_group" class="reloadSection" style="overflow-y:hidden;"> <h1>Group Details</h1> Click a group to see the pages in it. </div> </div> <div style="height:25px;clear:both;"></div>
} $team = $objForm->getPost('team'); if (!empty($team)) { $criteria['involvements']['team_id'] = $team; } $position = $objForm->getPost('position'); if (!empty($position)) { $criteria['involvements']['position_id'] = $position; } if (!empty($criteria['personal']) || !empty($criteria['involvements'])) { if ($return_null) { $rows = array(); } else { $rows = $objMember->getMemberByCrit($criteria); } echo Plugin::get('member_search', array('profile' => $current_user, 'rows' => $rows, 'objMember' => $objMember)); exit; } else { echo ''; exit; } } $header = 'Member :: Search'; require_once '_header.php'; ?> <h1>Member :: Search <span style="float:right;font-size:12px;cursor:pointer;"> <!-- <a id="clearFields"><u>Clear all fields</u></a> | --> <a id="clearSearch"><u>Clear search</u></a>
public function __construct(Plugin $plugin) { $this->plugin = $plugin; $this->validatorBuilder = $plugin->get('validatorBuilder'); }
<?php $objTeam = new Team(); $teams = $objTeam->getAllTeams(); $teamsProject = $objTeam->getAllTeamsInProject(6); $teamsEXCO = $objTeam->getAllTeamsInProject(5); require_once '_header.php'; ?> <h1><?php echo $header; ?> </h1> <div data-plugin="team_categories" class="reloadSection" style="display:inline-block; float: left;" data-type="/sugarkms/mod/changeTeamType.php" > <?php echo Plugin::get('team_categories', array('teams' => $teams, 'objTeam' => $objTeam)); ?> </div> <div data-plugin="team_order" class="reloadSection" style="display:inline-block;float:right;" > <?php echo Plugin::get('team_order', array('teamsEXCO' => $teamsEXCO, 'teamsProject' => $teamsProject)); ?> </div> <?php require_once '_footer.php';
$positionsProject = $objPosition->getAllPositionsInProject(6); $objTeam = new Team(); $teamsProject = $objTeam->getAllTeamsInProject(6); $teamsEXCO = $objTeam->getAllTeamsInProject(5); require_once '_header.php'; ?> <h1><?php echo $header; ?> </h1> <div data-plugin="position_categories" style="display:inline-block; float: left;" class="reloadSection"> <?php echo Plugin::get('position_categories', array('positions' => $positions, 'objPosition' => $objPosition)); ?> </div> <div data-plugin="position_order" style="display:inline-block;float:right;" class="reloadSection"> <?php echo Plugin::get('position_order', array('positionsEXCO' => $positionsEXCO, 'positionsProject' => $positionsProject)); ?> </div> <div data-plugin="position_team" style="clear:both;display:block;" class="reloadSection"> <?php echo Plugin::get('position_team', array('positionsEXCO' => $positionsEXCO, 'positionsProject' => $positionsProject, 'teamsEXCO' => $teamsEXCO, 'teamsProject' => $teamsProject, 'objPosition' => $objPosition)); ?> </div> <div style="height:25px;clear:both;"></div> <?php require_once '_footer.php';
/** * Prepare the content to send in the email */ private function prepareContent() { if ($this->useDefaultTemplate) { // Create the email content $cssVariables = Theme::getSelected()->getEditableVariables(); $values = Theme::getSelected()->getVariablesCustomValues(); $css = array(); foreach ($cssVariables as $var) { $css[$var['name']] = isset($values[$var['name']]) ? $values[$var['name']] : $var['default']; } // Format the email $emailHtml = View::make(Theme::getSelected()->getView('email.tpl'), array('css' => $css, 'title' => $this->title, 'content' => $this->content, 'logo' => Option::get('main.logo') ? Plugin::get('main')->getUserfilesUrl(Option::get('main.logo')) : Plugin::get('main')->getStaticUrl('img/hawk-logo.png'))); $this->html($emailHtml); } }
/** * Check if plugin exist and if it is active * * @param string $name The plugin name to test * * @return bool True if the plugin exists and is active, else False */ public static function existAndIsActive($name) { $class = self::getNamespaceByName($name) . "\\Installer"; if (class_exists($class)) { $plugin = Plugin::get($name); if ($plugin != null && $plugin->isActive()) { return true; } else { return false; } } else { return false; } }
private function installOrupdateDependencies(Plugin $plugin) { // Check if the plugin has dependencies $dependencies = $plugin->getDefinition('dependencies'); if (!empty($dependencies)) { foreach ($dependencies as $name => $param) { $dependentPlugin = Plugin::get($name); if (!$dependentPlugin) { // The plugin does not exist yet, download it $controller = self::getInstance(array('plugin' => $name)); $controller->download(false); } else { // The plugin already exists. Check if it needs to be updated if (!empty($param['version'])) { $installedVersion = Utils::getSerializedVersion($dependentPlugin->getDefinition('version')); $expectedVersion = Utils::getSerializedVersion($param['version']); if ($installedVersion < $expectedVersion) { // The dependency needs to be updated $controller = $controller = self::getInstance(array('plugin' => $name)); $controller->update(); } } } } } }
<div id="tabs"> <ul> <li><a href="#organizers">Organizers (<?php echo $objProject->_total; ?> )</a></li> <li><a href="#volunteers">Volunteers (<?php echo $objProject->_total_volunteer; ?> )</a></li> </ul> <div id="organizers"> <?php echo Plugin::get('project_view_member_list', array('teams' => $teams, 'can_view' => $can_view)); ?> </div> <div id="volunteers"> <?php echo Plugin::get('project_view_member_list', array('teams' => $volunteers, 'can_view' => $can_view)); ?> </div> </div> <?php } ?> <div style="height:25px;"></div> <?php require_once '_footer.php';
public function ownsPlugin(Plugin $plugin) { return $this->isAuthenticated() && $this->getUserId() == $plugin->get('created_by'); }
<?php $objSchool = new School(); $schools = $objSchool->getAllUni(); require_once '_header.php'; ?> <h1><?php echo $header; ?> </h1> <div data-plugin="universities" class="reloadSection"> <?php echo Plugin::get('universities', array('schools' => $schools, 'objSchool' => $objSchool)); ?> </div> <div style="height:25px;"></div> <?php require_once '_footer.php';
<?php namespace FakerPress; $fields[] = new Field('text', array('id' => 'erase_phrase', 'placeholder' => 'The cold never bothered me anyway!'), array('label' => __('Erase faked data', 'fakerpress'), 'description' => __('To erase all data generated type "<b>Let it Go!</b>".', 'fakerpress'), 'actions' => array('delete' => __('Delete!', 'fakerpress')))); $fields[] = new Field('heading', array('id' => 'heading-500px', 'title' => __('API: <i>500px</i>', 'fakerpress'), 'description' => __('Setting up 500px API connection is fully optional.', 'fakerpress'))); $fields[] = new Field('text', array('id' => '500px-key', 'placeholder' => __('E.g.: fU3TlASxi2uL76TcP5PAd946fYGZTVsfle6v13No', 'fakerpress'), 'value' => Plugin::get(array('500px', 'key'))), array('label' => __('Consumer Key', 'fakerpress'), 'description' => __('Application Consumer Key — <a href="https://500px.com/settings/applications" target="_blank">500px Applications</a>', 'fakerpress'), 'actions' => array('save_500px' => __('Save', 'fakerpress')))); ?> <div class='wrap'> <h2><?php echo esc_attr(Admin::$view->title); ?> </h2> <form method='post'> <?php wp_nonce_field(Plugin::$slug . '.request.' . Admin::$view->slug . (isset(Admin::$view->action) ? '.' . Admin::$view->action : '')); ?> <table class="form-table" style="display: table;"> <tbody> <?php foreach ($fields as $field) { $field->output(true); } ?> </tbody> </table> </form> </div><?php
/** * Display the list * * @return string The HTML result of displaying */ public function display() { try { $pages = 1; $data = array(); $param = array(); $this->recordNumber = 0; if ($this->refresh) { // Get the data to display $this->get(); // Get the total number of pages $pages = ceil($this->recordNumber / $this->lines) > 0 ? ceil($this->recordNumber / $this->lines) : 1; // At least one result to display $data = array(); $param = array(); if (is_array($this->results)) { foreach ($this->results as $id => $line) { $data[$id] = array(); $param[$id] = array('class' => ''); if ($this->lineClass) { $function = $this->lineClass; $param[$id]['class'] .= $function($line); } foreach ($this->fields as $name => $field) { $data[$id][$name] = $field->displayCell($id); } } } } // Get the list views files $this->getViews(); return View::make($this->refresh ? $this->resultTpl : $this->tpl, array('list' => $this, 'data' => $data, 'linesParameters' => $param, 'pages' => $pages)) . View::make(Plugin::get('main')->getView('list.js.tpl'), array('list' => $this, 'pages' => $pages)); } catch (\Exception $e) { App::errorHandler()->exception($e); } }
<h2>Current Recruitment</h2> <table cellpadding="0" cellspacing="0" border="0" style="width:100%;" data-object="recruitment"> <tr> <th>Project</th> <th>Position</th> <th>Team</th> <th>Deadline</th> <th>Status</th> <th colspan="2">Action</th> </tr> <tbody class="recruitmentList reloadSection" data-plugin="recruitment_current"> <?php echo Plugin::get('recruitment_current'); ?> </tbody> </table> <form class="addPositionForm" action="" method="">
<div id="questions"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%;"> <tr> <td style="width:45%;" class="alignTop"> <div class="reloadSection questionListSection" data-plugin="recruitment_question_list"> <?php echo Plugin::get('recruitment_question_list', array('id' => $id)); ?> </div> </td> <td style="width:0%;"></td> <td class="alignTop" style="width:50%;"> <div class="reloadSection editQuestionSection" data-plugin="recruitment_question_edit"> <?php echo Plugin::get('recruitment_question_edit', array('params' => array('recruitment_id' => $id))); ?> </div> </td> </tr> </table> </div> </div>
<?php $header = 'High Schools :: Manage'; $objSchool = new School(); $schools = $objSchool->getAllHighSchools(); require_once '_header.php'; ?> <h1><?php echo $header; ?> </h1> <div data-plugin="high_schools" class="reloadSection"> <?php echo Plugin::get('high_schools', array('schools' => $schools, 'objSchool' => $objSchool)); ?> </div> <div style="height:25px;"></div> <?php require_once '_footer.php';
<?php require_once '../inc/config.php'; if (isset($_POST['plugin'])) { $plugin = $_POST['plugin']; $params = isset($_POST['params']) ? $_POST['params'] : ''; echo Plugin::get($plugin, array('params' => $params)); }
echo $objProject->_total; ?> )</a></li> <li><a href="#volunteers">Volunteers (<?php echo $objProject->_total_volunteer; ?> )</a></li> </ul> <div id="organizers"> <?php echo Plugin::get('project_edit_member', array('teams' => $teams, 'project' => $project)); ?> </div> <div id="volunteers" style="display:none;"> <?php echo Plugin::get('project_edit_member', array('teams' => $volunteers, 'project' => $project)); ?> </div> </div> <?php } ?> </div> --> <?php require_once '_footer.php';
/** * This method is used when you define your own template for displaying the form content. * It will wrap the form content with the <form> tag, and all the parameters defined for this form * * @param string $content The form content to wrap * * @return string The HTML result */ public function wrap($content) { App::logger()->info('display form ' . $this->id); // Filter input data that can be sent to the client $clientVars = array('id', 'type', 'name', 'required', 'emptyValue', 'pattern', 'minimum', 'maximum', 'compare', 'errorAt', 'label', 'invitation'); $clientInputs = array(); foreach ($this->inputs as $field) { $clientInputs[$field->name] = array_filter(get_object_vars($field), function ($key) use($clientVars) { return in_array($key, $clientVars); }, ARRAY_FILTER_USE_KEY); $clientInputs[$field->name]['type'] = $field::TYPE; } // Generate the script to include the form in the application, client side $inputs = json_encode($clientInputs, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_NUMERIC_CHECK); $errors = json_encode($this->errors, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_NUMERIC_CHECK); return View::make(Theme::getSelected()->getView(Form::VIEWS_DIR . 'form.tpl'), array('form' => $this, 'content' => $content)) . View::make(Plugin::get('main')->getView('form.js.tpl'), array('form' => $this, 'inputs' => $inputs, 'errors' => $errors)); }
/** * @brief __get 魔术方法,用于获取注册的钩子 * * @param $name 钩子名 * * @return array */ public function __get($name) { return Plugin::get($name); }
/** * Autoload components * * If there are any components set to be autoloaded, do so now. * This step is the glue that holds everything together. While * some "Plugins" are simply additions that you want autoloaded, * others are ciritcal for the system to function correctly. * These critical components are located in the core/extends * directory, and are built this way to allow any tweaking * desired. */ foreach ($config->getSection('autoload') as $loader => $component) { // Build a "Plugin" array as used by the Plugin/DynamicLoader // component loading system. $component_data = array(); $component_data['name'] = $config->get('plugin.' . $component, 'name'); $component_data['class'] = preg_replace_callback('/\\%([A-Z]+)\\%/', 'replace_with_constant', $config->get('plugin.' . $component, 'class')); $snforge->profiler->log('Loading class ' . $component_data['name'] . ' from ' . $component_data['class']); foreach ($config->getSection('plugin.' . $component) as $key => $value) { // Some components can pre-set variables prior to // constructing the object. if (preg_match('/^var\\.(.*)/', $key, $matches)) { $component_data['var_set'][$matches[1]] = preg_replace_callback('/\\%([A-Z]+)\\%/', 'replace_with_constant', $value); } // Some components require an immediate call - this // acts as the constructor for the component. if (preg_match('/^call\\.(.*)/', $key, $matches)) { $component_data['pre_run'][$matches[1]] = $value; } } // Build the object as a new snForge plugin.
public function removeplugin() { if ($_REQUEST['rmid']) { $Plugin = new Plugin($_REQUEST['rmid']); } if ($Plugin) { if ($this->getClass(ucfirst($Plugin->get('name')) . 'Manager')->uninstall()) { if ($Plugin->destroy()) { $this->FOGCore->setMessage('Plugin Removed'); $this->FOGCore->redirect('?node=' . $_REQUEST['node'] . '&sub=activate'); } } } }