예제 #1
0
 public function indexAction()
 {
     if (($response = parent::indexAction()) instanceof Response) {
         return $response;
     }
     $form = new Form(module_path('Brands', '/Resources/forms/admin/expired-filters.php'));
     $form->populate($this->view->filters);
     $this->view->assign('form', $form);
 }
예제 #2
0
파일: Crud.php 프로젝트: control-corp/micro
 /**
  * @param EntityInterface $entity
  * @return RedirectResponse|View
  */
 public function addAction(EntityInterface $entity = \null)
 {
     $module = $this->request->getParam('module');
     $controller = $this->request->getParam('controller');
     $model = $this->getModel();
     if ($entity === \null) {
         $entity = $model->createEntity();
     }
     $form = new Form(module_path(ucfirst(Utils::camelize($module)), '/Resources/forms/' . ($this->scope ? $this->scope . '/' : '') . $controller . '-add.php'));
     $form->populate($entity->toArray());
     // hook
     $this->prepareForm($form, $entity);
     if ($this->request->isPost()) {
         $post = $this->request->getPost();
         if (isset($post['btnBack'])) {
             return new RedirectResponse(route(\null, ['action' => 'index', 'id' => \null]));
         }
         $post = Utils::arrayMapRecursive('trim', $post);
         // hook
         $this->modifyPost($form, $entity, $post);
         // hook
         $this->preValidate($form, $entity, $post);
         $form->isValid($post);
         // hook
         $this->postValidate($form, $entity, $post);
         if (!$form->hasErrors()) {
             if (!isset($post['languageId']) && $this->container->has('language') && ($language = $this->container->get('language')) instanceof LanguageInterface) {
                 $post['languageId'] = $language->getId();
             }
             try {
                 $post = Utils::arrayMapRecursive('trim', $post, true);
                 // hook
                 $this->modifyData($post);
                 $entity->setFromArray($post);
                 // hook
                 $this->modifyEntity($entity);
                 $model->save($entity);
                 if (isset($post['btnApply'])) {
                     $redirectResponse = new RedirectResponse(route(\null, ['action' => 'edit', 'id' => $entity[$model->getIdentifier()]]));
                 } else {
                     $redirectResponse = new RedirectResponse(route(\null, ['action' => 'index', 'id' => \null]));
                 }
                 return $redirectResponse->withFlash('Информацията е записана');
             } catch (\Exception $e) {
                 if ($entity[$model->getIdentifier()]) {
                     $redirectResponse = new RedirectResponse(route(\null, ['action' => 'edit', 'id' => $entity[$model->getIdentifier()]]));
                 } else {
                     $redirectResponse = new RedirectResponse(route(\null, ['action' => 'add', 'id' => \null]));
                 }
                 return $redirectResponse->withFlash(env('development') ? $e->getMessage() : 'Възникна грешка. Опитайте по-късно', 'danger');
             }
         }
     }
     $this->view->setTemplate(($this->scope ? $this->scope . '/' : '') . $controller . '/add');
     return $this->view->assign(['form' => $form, 'item' => $entity]);
 }
예제 #3
0
 /**
  * Autoload custom module files.
  *
  * @param array $module
  *
  * @return void
  */
 private function autoloadFiles($module)
 {
     if (isset($module['autoload'])) {
         foreach ($module['autoload'] as $file) {
             $path = module_path($module['slug'], $file);
             if (file_exists($path)) {
                 include $path;
             }
         }
     }
 }
예제 #4
0
 public function migrate_module()
 {
     $module = $this->uri->segment(5);
     $file = $this->input->post('version');
     $version = $file !== 'uninstall' ? (int) substr($file, 0, 3) : 0;
     $path = module_path($module, 'migrations');
     // Reset the migrations path for this run only.
     $this->migrations->set_path($path);
     // Do the migration
     $this->migrate_to($version, $module . '_');
 }
예제 #5
0
 /**
  * Get the destination class path.
  *
  * @param string $name
  *
  * @return string
  */
 protected function getPath($name)
 {
     $slug = $this->argument('slug');
     // take everything after the module name in the given path (ignoring case)
     $key = array_search(strtolower($slug), explode('\\', strtolower($name)));
     if ($key === false) {
         $newPath = str_replace('\\', '/', $name);
     } else {
         $newPath = implode('/', array_slice(explode('\\', $name), $key + 1));
     }
     return module_path($slug, "{$newPath}.php");
 }
예제 #6
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $arguments = $this->argument();
     $option = $this->option();
     $options = [];
     array_walk($option, function (&$value, $key) use(&$options) {
         $options['--' . $key] = $value;
     });
     unset($arguments['slug']);
     $options['--path'] = str_replace(realpath(base_path()), '', module_path($this->argument('slug'), 'Database/Migrations'));
     $options['--path'] = ltrim($options['--path'], '/');
     return $this->call('make:migration', array_merge($arguments, $options));
 }
예제 #7
0
 public function loginAction()
 {
     $form = new Form(module_path('UserManagement', 'Resources/forms/admin/login.php'));
     if ($this->request->isPost()) {
         $data = $this->request->getPost();
         if ($form->isValid($data)) {
             $usersModel = new Users();
             if ($usersModel->login($data['username'], $data['password'])) {
                 if (($backTo = $this->request->getParam('backTo')) !== \null) {
                     return new RedirectResponse(urldecode($backTo));
                 } else {
                     return new RedirectResponse(route('admin', [], \true));
                 }
             } else {
                 $form->password->addError('Невалидни данни');
             }
         }
     }
     return ['form' => $form];
 }
예제 #8
0
function get_file_substitution_values($handle, $type, $author, $override)
{
    $subs = array();
    $subs['dir'] = handle_to_path($handle, $type);
    if (0 == strcmp("controller", $type)) {
        $subs['class'] = handle_to_controller($handle);
    } else {
        $subs['class'] = handle_to_class($handle, $type);
    }
    list($plugin, $class) = explode("/", $handle);
    list($codepool, $company, $plugin_dir) = explode("/", module_path($plugin));
    $subs['filename'] = handle_to_file($handle, $type);
    $subs['output_file'] = "{$subs['dir']}/{$subs['filename']}";
    $subs['package'] = $company;
    $subs['description'] = cmd_switch("description");
    if (!$subs['description']) {
        $subs['description'] = user_text("Enter a description for the file");
    }
    $subs['plugin'] = $plugin_dir;
    $subs['author'] = cmd_switch("author");
    if (!$subs['author']) {
        $subs['author'] = user_text("Who is the author of the plugin", $author);
    }
    $subs['copyright'] = date("Y") . " " . $subs['author'];
    if (file_exists($subs['output_file'])) {
        throw new Exception("Class already exists, so I can't create it again, amirite?");
    }
    // FIXME
    $subs['extends'] = "";
    if ($override) {
        $subs['extends'] = " extends {$override}";
    }
    return $subs;
}
예제 #9
0
 /**
  * Define the "api" routes for the module.
  *
  * These routes are typically stateless.
  *
  * @return void
  */
 protected function mapApiRoutes()
 {
     Route::group(['middleware' => 'api', 'namespace' => $this->namespace, 'prefix' => 'api'], function ($router) {
         require module_path('DummySlug', 'Routes/api.php');
     });
 }
예제 #10
0
 /**
  * @param mixed $module
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param bool $subRequest
  * @throws CoreException
  * @return ResponseInterface
  */
 public function resolve($module, ServerRequestInterface $request, ResponseInterface $response, $subRequest = \false)
 {
     if ($module instanceof ResponseInterface) {
         return $module;
     }
     if (($matches = $this->matchResolve($module)) === \null) {
         // write string to the response
         if (\is_string($module) || \is_object($module) && \method_exists($module, '__toString')) {
             $response->getBody()->write((string) $module);
             return $response;
         }
         throw new CoreException(\sprintf('Handler [%s] must be in [Handler@action] format', \is_object($module) ? \get_class($module) : $module));
     }
     $module = $matches[0];
     $action = $matches[1];
     if ($this->container->has($module)) {
         $moduleInstance = $this->container->get($module);
         if (!\is_object($moduleInstance) || $moduleInstance instanceof \Closure) {
             throw new CoreException('Handler "' . $module . '" is container service but it is not object', 500);
         }
         $module = \get_class($moduleInstance);
     } else {
         if (!\class_exists($module, \true)) {
             throw new CoreException('Handler class "' . $module . '" not found', 404);
         }
         $moduleInstance = new $module($request, $response, $this->container);
         if ($moduleInstance instanceof ContainerAwareInterface) {
             $moduleInstance->setContainer($this->container);
         }
     }
     $parts = explode('\\', $module);
     $moduleParam = Utils::decamelize($parts[0]);
     $controllerParam = Utils::decamelize($parts[count($parts) - 1]);
     $actionParam = Utils::decamelize($action);
     $request->withAttribute('module', $moduleParam);
     $request->withAttribute('controller', $controllerParam);
     $request->withAttribute('action', $actionParam);
     if ($moduleInstance instanceof Controller) {
         $action = $action . 'Action';
     }
     if (!\method_exists($moduleInstance, $action) && !\method_exists($moduleInstance, '__call')) {
         throw new CoreException('Method "' . $action . '" not found in "' . $module . '"', 404);
     }
     if ($moduleInstance instanceof Controller) {
         $moduleInstance->init();
     }
     $scope = '';
     if (\method_exists($moduleInstance, 'getScope')) {
         $scope = $moduleInstance->getScope();
     }
     if (($moduleResponse = $moduleInstance->{$action}()) instanceof ResponseInterface) {
         return $moduleResponse;
     }
     if (\is_object($moduleResponse) && !$moduleResponse instanceof View) {
         throw new CoreException('Handler response is object and must be instance of View', 500);
     }
     // resolve View object
     if ($moduleResponse === \null || is_array($moduleResponse)) {
         if ($moduleInstance instanceof Controller) {
             $view = $moduleInstance->getView();
         } else {
             $view = new View();
         }
         if (is_array($moduleResponse)) {
             $view->assign($moduleResponse);
         }
         $moduleResponse = $view;
     }
     if ($moduleResponse instanceof View) {
         if ($moduleResponse->getTemplate() === \null) {
             $moduleResponse->setTemplate(($scope ? $scope . '/' : '') . $controllerParam . '/' . $actionParam);
         }
         try {
             $moduleResponse->addPath(module_path($parts[0], '/Resources/views'), $moduleParam);
             $moduleResponse->addPath(config('view.paths', []));
         } catch (\Exception $e) {
         }
         if ($this->useEvent === \true && ($eventResponse = $this->container->get('event')->trigger('render.start', ['view' => $moduleResponse])) instanceof ResponseInterface) {
             return $eventResponse;
         }
         if ($subRequest) {
             $moduleResponse->setRenderParent(\false);
         }
         $response->getBody()->write((string) $moduleResponse->render());
     } else {
         $response->getBody()->write((string) $moduleResponse);
     }
     return $response;
 }
예제 #11
0
 /**
  * Does the actual work of reading in and parsing the help file.
  *
  * @param  array  $segments The uri_segments array.
  */
 private function read_page($segments = array())
 {
     $defaultType = $this->docsTypeApp;
     // Strip the 'controller name
     if ($segments[1] == $this->router->fetch_class()) {
         array_shift($segments);
     }
     // Is this core, app, or module?
     $type = array_shift($segments);
     if (empty($type)) {
         $type = $defaultType;
     }
     // Is it a module?
     if ($type != $this->docsTypeApp && $type != $this->docsTypeBf) {
         $modules = module_list();
         if (in_array($type, $modules)) {
             $module = $type;
             $type = $this->docsTypeMod;
         } else {
             $type = $defaultType;
         }
     }
     // for now, assume we are using Markdown files as the only
     // allowed format. With an extension of '.md'
     if (count($segments)) {
         $file = implode('/', $segments) . $this->docsExt;
     } else {
         $file = 'index' . $this->docsExt;
         if ($type != $this->docsTypeMod && !is_file(APPPATH . $this->docsDir . '/' . $file)) {
             $type = $this->docsTypeBf;
         }
     }
     switch ($type) {
         case $this->docsTypeBf:
             $content = is_file(BFPATH . $this->docsDir . '/' . $file) ? file_get_contents(BFPATH . $this->docsDir . '/' . $file) : '';
             break;
         case $this->docsTypeApp:
             $content = is_file(APPPATH . $this->docsDir . '/' . $file) ? file_get_contents(APPPATH . $this->docsDir . '/' . $file) : '';
             break;
         case $this->docsTypeMod:
             // Assume it's a module
             $mod_path = module_path($module, $this->docsDir);
             $content = is_file($mod_path . '/' . $file) ? file_get_contents($mod_path . '/' . $file) : '';
             break;
     }
     // Parse the file
     $this->load->helper('markdown_extended');
     $content = MarkdownExtended($content);
     return trim($content);
 }
 /**
  * Get migrations path.
  *
  * @return string
  */
 protected function getMigrationPath($slug)
 {
     return module_path($slug, 'Database/Migrations');
 }
예제 #13
0
 public function brandsAction()
 {
     $filters = parent::handleFilters();
     if ($filters instanceof Response) {
         return $filters;
     }
     $form = new Form(module_path('Brands', '/Resources/forms/admin/reports-brands-filters.php'));
     $form->populate($filters);
     $brands = array();
     $brandImages = array();
     if (isset($filters['brandId'])) {
         $brandsModel = new Brands();
         $brandsModel->addWhere('name', $filters['brandId']);
         if (isset($filters['date']) && $filters['date']) {
             try {
                 $date = new \DateTime($filters['date']);
                 $statusDate = $date->format('Y-m-d');
                 //$brandsModel->addWhere(new Expr('statusDate <= "' . $brandsModel->getAdapter()->quote($statusDate) . '"'));
             } catch (\Exception $e) {
             }
         }
         $brandsRows = $brandsModel->getItems();
         foreach ($brandsRows as $brandRow) {
             if (!isset($brands[$brandRow['countryId']])) {
                 $brands[$brandRow['countryId']] = array();
             }
             $brands[$brandRow['countryId']][$brandRow['typeId']] = $brandRow;
             if (!isset($brandImages[$brandRow['typeId']])) {
                 if ($brandRow->getThumb()) {
                     $brandImages[$brandRow['typeId']] = array('path' => $brandRow->getThumb(), 'image' => 'uploads/brands/thumbs/' . $brandRow->getId() . '.' . pathinfo($brandRow->getImage(), PATHINFO_EXTENSION));
                 }
             }
         }
     }
     if (empty($brands)) {
         return ['form' => $form, 'brands' => $brands];
     }
     $nomContinents = new Continents();
     $continents = $nomContinents->fetchCachedPairs(array('active' => 1), null, array('id' => 'ASC'));
     $nomTypes = new Types();
     $types = $nomTypes->fetchCachedPairs(['active' => 1]);
     $nomCountries = new Countries();
     $nomCountries->addWhere('active', '1');
     $nomCountries->addOrder('name', 'ASC');
     $countriesRows = $nomCountries->getItems();
     $countries = array();
     $populations = array();
     foreach ($countriesRows as $countryRow) {
         /**
          * Създаване на списъци от държави за континент
          */
         if (!isset($countries[$countryRow['continentId']])) {
             $countries[$countryRow['continentId']] = array();
         }
         $countries[$countryRow['continentId']][$countryRow['id']] = $countryRow;
         /**
          * Изчисляване на популацията за континент
          */
         if (!isset($populations[$countryRow['continentId']])) {
             $populations[$countryRow['continentId']] = 0;
         }
         $populations[$countryRow['continentId']] += $countryRow['population'];
     }
     $nomStatus = new Statuses();
     $statuses = $nomStatus->fetchCachedPairs();
     $nomStatus->resetSelect(true);
     $statusesColors = $nomStatus->fetchCachedPairs(null, array('id', 'color'));
     return ['form' => $form, 'continents' => $continents, 'populations' => $populations, 'types' => $types, 'countries' => $countries, 'brands' => $brands, 'brandImages' => $brandImages, 'statuses' => $statuses, 'statusesColors' => $statusesColors];
 }
예제 #14
0
 public function addItemAction()
 {
     $menuId = $this->request->getParam('menuId');
     $id = $this->request->getParam('id');
     $menu = $this->getModel()->find((int) $menuId);
     if ($menu === null) {
         return new RedirectResponse(route(\null, array('action' => 'index', 'menuId' => \null)));
     }
     $model = new Model\Items();
     if ($id) {
         $item = $model->find((int) $id);
         if ($item === null) {
             return new RedirectResponse(route(\null, array('action' => 'items', 'id' => \null)));
         }
     } else {
         $item = $model->createEntity();
     }
     if ($item instanceof Model\Entity\Item) {
     }
     $form = new Form(module_path('Navigation', '/Resources/forms/admin/index-add-item.php'));
     $tree = new Helper\Tree($menu->getAlias());
     $form->parentId->setMultiOptions($tree->flat($tree->getTree(null), '---', array((int) $id)));
     $form->populate($item->toArray());
     if ($this->request->isPost()) {
         $post = $this->request->getPost();
         if (isset($post['btnBack'])) {
             return new RedirectResponse(route(\null, array('action' => 'items', 'id' => \null)));
         }
         $form->isValid($post);
         if (isset($post['alias']) && $post['alias']) {
             $m = new Model\Table\Items();
             $where = array('alias = ?' => $post['alias']);
             if ($item->getId()) {
                 $where['id <> ?'] = $item->getId();
             }
             if ($m->fetchRow($where)) {
                 $form->alias->addError('Псевдонимът се използва');
                 $form->markAsError();
             }
         }
         if (!$form->hasErrors()) {
             if (isset($post['routeData'])) {
                 $routeData = $post['routeData'];
             } else {
                 $routeData = array();
             }
             foreach ($routeData as $k => $v) {
                 if (empty($v)) {
                     unset($routeData[$k]);
                 }
             }
             $post = Utils::arrayMapRecursive('trim', $post, true);
             $item->setFromArray($post);
             $item->setMenuId($menuId);
             if ($item->getRoute() === \null) {
                 if ($item->getUrl() === \null) {
                     $item->setUrl('#');
                 }
             } else {
                 $item->setUrl(\null);
             }
             if ($item->getRoute()) {
                 if (($navigationHelper = $this->getNavigationHelper($item->getRoute())) !== \null) {
                     if (\method_exists($navigationHelper, 'decode')) {
                         $navigationHelper->decode($routeData, $item);
                     }
                 }
             }
             $item->setRouteData(empty($routeData) ? \null : json_encode($routeData));
             if ($item->getOrder() === \null) {
                 if ($item->getParentId()) {
                     $and = ' AND parentId = ' . (int) $item->getParentId();
                 } else {
                     $and = ' AND parentId IS NULL';
                 }
                 $item->setOrder($model->getTable()->getAdapter()->fetchOne('SELECT IFNULL(MAX(`order`), 0) + 1 FROM MenuItems WHERE menuId = ' . (int) $menuId . $and));
             }
             try {
                 $model->save($item);
                 if (isset($post['btnApply'])) {
                     $redirectResponse = new RedirectResponse(route(\null, ['action' => 'add-item', 'id' => $item->getId()]));
                 } else {
                     $redirectResponse = new RedirectResponse(route(\null, ['action' => 'items', 'id' => \null]));
                 }
                 return $redirectResponse->withFlash('Информацията е записана');
             } catch (\Exception $e) {
                 if ($item->getId()) {
                     $redirectResponse = new RedirectResponse(route(\null, ['action' => 'add-item', 'id' => $item->getId()]));
                 } else {
                     $redirectResponse = new RedirectResponse(route(\null, ['action' => 'items', 'id' => \null]));
                 }
                 return $redirectResponse->withFlash(env('development') ? $e->getMessage() : 'Възникна грешка. Опитайте по-късно', 'danger');
             }
         }
     }
     $this->view->assign('menu', $menu);
     $this->view->assign('item', $item);
     $this->view->assign('form', $form);
 }
예제 #15
0
/**
 * Function draw
 *
 * This method processes all data to render the display. It is executed by
 * each tool. Is in charge of generating the interface and parse it to the user's browser.
 *
 * @param mixed $toolContent html code
 * @param int $menuTypeID
 * @param string $tool_css (optional) catalog name where a "tool.css" file exists
 * @param string $head_content (optional) code to be added to the HEAD of the UI
 * @param string $body_action (optional) code to be added to the BODY tag
 */
function draw($toolContent, $menuTypeID, $tool_css = null, $head_content = null, $body_action = null, $hideLeftNav = null, $perso_tool_content = null)
{
    global $course_code, $course_id, $helpTopic, $is_editor, $langActivate, $langAdmin, $langAdvancedSearch, $langAnonUser, $langChangeLang, $langChooseLang, $langCopyrightFooter, $langDeactivate, $langEclass, $langExtrasLeft, $langExtrasRight, $langHelp, $langHomePage, $langLogin, $langLogout, $langMyPersoAgenda, $langMyAgenda, $langMyPersoAnnouncements, $langMyPersoDeadlines, $langMyPersoDocs, $langMyPersoForum, $langMyPersoLessons, $langPersonalisedBriefcase, $langSearch, $langUser, $langUserBriefcase, $langUserHeader, $language, $navigation, $pageName, $toolName, $sectionName, $currentCourseName, $require_current_course, $require_help, $siteName, $siteName, $status, $switchLangURL, $theme, $themeimg, $toolContent_ErrorExists, $urlAppend, $urlSecure, $urlServer, $theme_settings, $language, $saved_is_editor, $langStudentViewEnable, $langStudentViewDisable;
    //get blocks content from $toolContent array
    if ($perso_tool_content) {
        $lesson_content = $perso_tool_content['lessons_content'];
        $assigns_content = $perso_tool_content['assigns_content'];
        $docs_content = $perso_tool_content['docs_content'];
        $agenda_content = $perso_tool_content['agenda_content'];
        $forum_content = $perso_tool_content['forum_content'];
        $personal_calendar_content = $perso_tool_content['personal_calendar_content'];
    }
    function get_theme_class($class)
    {
        global $theme_settings;
        if (isset($theme_settings['classes'][$class])) {
            return $theme_settings['classes'][$class];
        } else {
            return $class;
        }
    }
    if (!$toolName and $pageName) {
        $toolName = $pageName;
    } elseif (!$pageName and $toolName) {
        $pageName = $toolName;
    }
    $pageTitle = '';
    $is_mobile = isset($_SESSION['mobile']) && $_SESSION['mobile'] == true;
    $is_embedonce = isset($_SESSION['embedonce']) && $_SESSION['embedonce'] == true;
    unset($_SESSION['embedonce']);
    //get the left side menu from tools.php
    $toolArr = $is_mobile ? array() : getSideMenu($menuTypeID);
    $numOfToolGroups = count($toolArr);
    $GLOBALS['head_content'] = '';
    $head_content .= $GLOBALS['head_content'];
    $t = new Template('template/' . $theme);
    if ($is_embedonce) {
        $template_file = 'embed.html';
    } else {
        $template_file = 'theme.html';
    }
    $t->set_file('fh', $template_file);
    $t->set_block('fh', 'mainBlock', 'main');
    // template_callback() can be defined in theme settings.php
    if (function_exists('template_callback')) {
        template_callback($t, $menuTypeID, $is_embedonce);
    }
    $t->set_var('LANG', $language);
    if (!$is_embedonce) {
        //Remove search if not enabled
        if (!get_config('enable_search')) {
            $t->set_block('mainBlock', 'searchBlock', 'delete');
        }
        $t->set_var('leftNavClass', 'no-embed');
    }
    //	BEGIN constructing of left navigation
    //	----------------------------------------------------------------------
    $t->set_block('mainBlock', 'leftNavBlock', 'leftNav');
    $t->set_block('leftNavBlock', 'leftNavCategoryBlock', 'leftNavCategory');
    $t->set_block('leftNavCategoryBlock', 'leftNavCategoryTitleBlock', 'leftNavCategoryTitle');
    $t->set_block('leftNavCategoryBlock', 'leftNavLinkBlock', 'leftNavLink');
    $t->set_var('template_base', $urlAppend . 'template/' . $theme);
    $t->set_var('img_base', $themeimg);
    $current_module_dir = module_path($_SERVER['REQUEST_URI']);
    if (!$is_mobile and !$hideLeftNav) {
        if (is_array($toolArr)) {
            $group_opened = false;
            for ($i = 0; $i < $numOfToolGroups; $i++) {
                if (!$is_embedonce) {
                    $t->set_var('NAV_BLOCK_CLASS', $toolArr[$i][0]['class']);
                    $t->set_var('TOOL_GROUP_ID', $i);
                    if ($toolArr[$i][0]['type'] == 'none') {
                        $t->set_var('ACTIVE_TOOLS', '&nbsp;');
                        $t->set_var('NAV_CSS_CAT_CLASS', 'spacer');
                    } elseif ($toolArr[$i][0]['type'] == 'split') {
                        $t->set_var('ACTIVE_TOOLS', '&nbsp;');
                        $t->set_var('NAV_CSS_CAT_CLASS', 'split');
                    } elseif ($toolArr[$i][0]['type'] == 'text') {
                        $t->set_var('ACTIVE_TOOLS', $toolArr[$i][0]['text']);
                        $t->set_var('NAV_CSS_CAT_CLASS', 'category');
                    }
                    $t->parse('leftNavCategoryTitle', 'leftNavCategoryTitleBlock', false);
                }
                $t->set_var('GROUP_CLASS', '');
                $numOfTools = count($toolArr[$i][1]);
                for ($j = 0; $j < $numOfTools; $j++) {
                    $t->set_var('TOOL_LINK', $toolArr[$i][2][$j]);
                    $t->set_var('TOOL_TEXT', $toolArr[$i][1][$j]);
                    if (in_array($toolArr[$i][2][$j], array(get_config('phpMyAdminURL'), get_config('phpSysInfoURL'))) or strpos($toolArr[$i][3][$j], 'external_link') === 0) {
                        $t->set_var('TOOL_ATTR', ' target="_blank"');
                    } else {
                        $t->set_var('TOOL_ATTR', '');
                    }
                    $t->set_var('IMG_FILE', $toolArr[$i][3][$j]);
                    $img_class = basename($toolArr[$i][3][$j], ".png");
                    $img_class = preg_replace('/_(on|off)$/', '', $img_class);
                    if (isset($theme_settings['icon_map'][$img_class])) {
                        $img_class = $theme_settings['icon_map'][$img_class];
                    }
                    $t->set_var('IMG_CLASS', $img_class);
                    $module_dir = module_path($toolArr[$i][2][$j]);
                    if ($module_dir == $current_module_dir) {
                        $t->set_var('TOOL_CLASS', get_theme_class('tool_active'));
                        $t->set_var('GROUP_CLASS', get_theme_class('group_active'));
                        $group_opened = true;
                    } else {
                        $t->set_var('TOOL_CLASS', '');
                    }
                    $t->parse('leftNavLink', 'leftNavLinkBlock', true);
                }
                if (!$group_opened and ($current_module_dir == '/' or $current_module_dir == 'course_home' or $current_module_dir == 'main/portfolio.php')) {
                    $t->set_var('GROUP_CLASS', get_theme_class('group_active'));
                    $group_opened = true;
                }
                $t->parse('leftNavCategory', 'leftNavCategoryBlock', true);
                $t->clear_var('leftNavLink');
                //clear inner block
            }
            $t->parse('leftNav', 'leftNavBlock', true);
        }
    }
    $t->set_var('URL_PATH', $urlAppend);
    $t->set_var('SITE_NAME', $siteName);
    //If there is a message to display, show it (ex. Session timeout)
    if ($messages = Session::getMessages()) {
        $t->set_var('EXTRA_MSG', "<div class='row'><div class='col-xs-12'>" . $messages . "</div></div>");
    }
    $t->set_var('TOOL_CONTENT', $toolContent);
    if (isset($GLOBALS['leftNavExtras'])) {
        $t->set_var('ECLASS_LEFTNAV_EXTRAS', $GLOBALS['leftNavExtras']);
    }
    //if user is logged in display the logout option
    if (isset($_SESSION['uid'])) {
        $t->set_var('LANG_USER', $langUserHeader);
        $t->set_var('USER_NAME', q($_SESSION['givenname']));
        $t->set_var('USER_SURNAME', q($_SESSION['surname']));
        $t->set_var('USER_ICON', user_icon($_SESSION['uid']));
        $t->set_var('USERNAME', q($_SESSION['uname']));
        $t->set_var('LANG_PROFILE', $GLOBALS['langMyProfile']);
        $t->set_var('PROFILE_LINK', $urlServer . "main/profile/display_profile.php");
        $t->set_var('LANG_MESSAGES', $GLOBALS['langMyDropBox']);
        $t->set_var('MESSAGES_LINK', $urlServer . "modules/dropbox/index.php");
        $t->set_var('LANG_AGENDA', $langMyAgenda);
        $t->set_var('AGENDA_LINK', $urlServer . "main/personal_calendar/index.php");
        $t->set_var('LANG_NOTES', $GLOBALS['langNotes']);
        $t->set_var('NOTES_LINK', $urlServer . 'main/notes/index.php');
        $t->set_var('LANG_STATS', $GLOBALS['langMyStats']);
        $t->set_var('STATS_LINK', $urlServer . "main/profile/personal_stats.php");
        $t->set_var('LANG_LOGOUT', $langLogout);
        $t->set_var('LOGOUT_LINK', $urlServer . 'index.php?logout=yes');
        $t->set_var('MY_COURSES', $GLOBALS['langMyCoursesSide']);
        $t->set_var('MY_MESSAGES', $GLOBALS['langMyMessagesSide']);
        $t->set_var('QUICK_NOTES', $GLOBALS['langQuickNotesSide']);
        $t->set_var('LOGGED_IN', 'true');
    } else {
        if (!get_config('dont_display_login_form')) {
            $t->set_var('LANG_LOGOUT', $langLogin);
            $t->set_var('LOGOUT_LINK', $urlSecure . 'main/login_form.php');
        } else {
            $t->set_var('LOGOUT_LINK', '#');
        }
        $t->set_var('LOGGED_IN', 'false');
    }
    if (isset($require_current_course) and !isset($sectionName)) {
        $sectionName = $currentCourseName;
    }
    // set the text and icon on the third bar (header)
    if ($menuTypeID == 2) {
        if (!$pageName) {
            $t->set_var('SECTION_TITLE', q($currentCourseName));
        } else {
            $t->set_var('SECTION_TITLE', "<a href='{$urlServer}courses/{$course_code}/'>" . q($currentCourseName) . '</a>');
        }
    } elseif ($menuTypeID == 3) {
        $t->set_var('SECTION_TITLE', $langAdmin);
        $sectionName = $langAdmin;
    } elseif ($menuTypeID > 0 and $menuTypeID < 3) {
        $t->set_var('SECTION_TITLE', $langUserBriefcase);
        $sectionName = $langUserBriefcase;
    } else {
        $t->set_var('SECTION_TITLE', $langEclass);
        $sectionName = $langEclass;
    }
    //set the appropriate search action for the searchBox form
    if ($menuTypeID == 2) {
        $searchAction = "search_incourse.php?all=true";
        $searchAdvancedURL = $searchAction;
    } elseif ($menuTypeID == 1 || $menuTypeID == 3) {
        $searchAction = "search.php";
        $searchAdvancedURL = $searchAction;
    } else {
        //$menuType == 0
        $searchAction = "search.php";
        $searchAdvancedURL = $searchAction;
    }
    $mod_activation = '';
    if ($is_editor and isset($course_code)) {
        // link for activating / deactivating module
        $module_id = current_module_id();
        if (display_activation_link($module_id)) {
            if (visible_module($module_id)) {
                $message = $langDeactivate;
                $mod_activation = "\n\n                <a class='deactivate_module' href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;eclass_module_id={$module_id}&amp;hide=0'>\n                    <i class='fa fa-minus-square tiny-icon tiny-icon-red' rel='tooltip' data-toggle='tooltip' data-placement='top' title='{$langDeactivate}'></i>\n                    </a>";
            } else {
                $message = $langActivate;
                $mod_activation = "\n\n                <a class='activate_module' href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;eclass_module_id={$module_id}&amp;hide=1'>\n                    <i class='fa fa-check-square tiny-icon tiny-icon-green' rel='tooltip' data-toggle='tooltip' data-placement='top' title='{$langActivate}'></i>\n                    </a>";
            }
        }
    }
    $t->set_var('SEARCH_ACTION', $searchAction);
    $t->set_var('SEARCH_ADVANCED_URL', $searchAdvancedURL);
    $t->set_var('SEARCH_TITLE', $langSearch);
    $t->set_var('SEARCH_ADVANCED', $langAdvancedSearch);
    $t->set_var('TOOL_NAME', $toolName);
    if ($is_editor) {
        $t->set_var('ACTIVATE_MODULE', $mod_activation);
    }
    if (!$t->get_var('LANG_SELECT')) {
        if ($menuTypeID != 2) {
            $t->set_var('LANG_SELECT', lang_selections());
            $t->set_var('LANG_SELECT_TITLE', "title='{$langChooseLang}'");
        } else {
            $t->set_var('LANG_SELECT', '');
        }
    }
    // breadcrumb and page title
    if (!$is_embedonce and !$is_mobile and $current_module_dir != '/') {
        $t->set_block('mainBlock', 'breadCrumbLinkBlock', 'breadCrumbLink');
        $t->set_block('mainBlock', 'breadCrumbEntryBlock', 'breadCrumbEntry');
        // Breadcrumb first entry (home / portfolio)
        if ($status != USER_GUEST) {
            if (isset($_SESSION['uid'])) {
                $t->set_var('BREAD_TEXT', $langPersonalisedBriefcase);
                $t->set_var('BREAD_HREF', $urlAppend . 'main/portfolio.php');
            } else {
                $t->set_var('BREAD_TEXT', $langHomePage);
                $t->set_var('BREAD_HREF', $urlAppend);
            }
            if (isset($require_current_course) or $pageName) {
                $t->parse('breadCrumbEntry', 'breadCrumbLinkBlock', true);
            } else {
                $t->parse('breadCrumbEntry', 'breadCrumbEntryBlock', true);
            }
        }
        $pageTitle = $siteName;
        // Breadcrumb course home entry
        if (isset($course_code)) {
            $t->set_var('BREAD_TEXT', q(ellipsize($currentCourseName, 48)));
            if ($pageName) {
                $t->set_var('BREAD_HREF', $urlAppend . 'courses/' . $course_code . '/');
                $t->parse('breadCrumbEntry', 'breadCrumbLinkBlock', true);
            } else {
                $t->parse('breadCrumbEntry', 'breadCrumbEntryBlock', true);
            }
            $pageTitle .= " | " . ellipsize($currentCourseName, 32);
        }
        foreach ($navigation as $step) {
            $t->set_var('BREAD_TEXT', q($step['name']));
            if (isset($step['url'])) {
                $t->set_var('BREAD_HREF', $step['url']);
                $t->parse('breadCrumbEntry', 'breadCrumbLinkBlock', true);
            } else {
                $t->parse('breadCrumbEntry', 'breadCrumbEntryBlock', true);
            }
        }
        if ($pageName) {
            $t->set_var('BREAD_TEXT', q($pageName));
            $t->parse('breadCrumbEntry', 'breadCrumbEntryBlock', true);
        }
        if ($pageName) {
            $pageTitle .= " | " . $pageName;
        }
    } else {
        if (!$is_embedonce) {
            $t->set_block('mainBlock', 'breadCrumbs', 'delete');
        }
    }
    //END breadcrumb --------------------------------
    $t->set_var('PAGE_TITLE', q($pageTitle));
    if (isset($course_code)) {
        $t->set_var('COURSE_CODE', $course_code);
        $t->set_var('COURSE_ID', $course_id);
    }
    if (!$is_embedonce) {
        if ($is_mobile) {
            $t->set_block('mainBlock', 'normalViewOpenDiv', 'delete');
        } else {
            $t->set_block('mainBlock', 'mobileViewOpenDiv', 'delete');
        }
    }
    // Add Theme Options styles
    $t->set_var('logo_img', 'eclass-new-logo.png');
    $t->set_var('logo_img_small', 'logo_eclass_small.png');
    if (get_config('theme_options_id')) {
        $theme_options = Database::get()->querySingle("SELECT * FROM theme_options WHERE id = ?d", get_config('theme_options_id'));
        $theme_options_styles = unserialize($theme_options->styles);
        $styles_str = '';
        if (!empty($theme_options_styles['bgColor']) || !empty($theme_options_styles['bgImage'])) {
            $background_type = $theme_options_styles['bgType'] == 'stretch' ? "background-size: 100% 100%;" : "";
            $bg_image = isset($theme_options_styles['bgImage']) ? " url('{$themeimg}/{$theme_options_styles['bgImage']}')" : "";
            $styles_str .= "body{background: {$theme_options_styles['bgColor']}{$bg_image};{$background_type}}";
        }
        if (!empty($theme_options_styles['loginJumbotronBgColor']) && !empty($theme_options_styles['loginJumbotronRadialBgColor'])) {
            $styles_str .= ".jumbotron.jumbotron-login { background: -webkit-radial-gradient(30% 60%, closest-corner, {$theme_options_styles['loginJumbotronRadialBgColor']}, {$theme_options_styles['loginJumbotronBgColor']});}";
        }
        if (isset($theme_options_styles['loginImg'])) {
            $styles_str .= ".jumbotron.jumbotron-login .graphic{ background-image: url('{$themeimg}/{$theme_options_styles['loginImg']}'); }";
        }
        if (!empty($theme_options_styles['leftNavBgColor'])) {
            $rgba_no_alpha = explode(',', $theme_options_styles['leftNavBgColor']);
            $rgba_no_alpha[3] = "1)";
            $rgba_no_alpha = implode(',', $rgba_no_alpha);
            $styles_str .= "#background-cheat-leftnav, #bgr-cheat-header, #bgr-cheat-footer{background:{$theme_options_styles['leftNavBgColor']};} @media(max-width: 992px){#leftnav{background:{$rgba_no_alpha};}}";
        }
        if (!empty($theme_options_styles['leftSubMenuFontColor'])) {
            $styles_str .= "#leftnav .panel a {color: {$theme_options_styles['leftSubMenuFontColor']};}";
        }
        if (!empty($theme_options_styles['leftSubMenuHoverBgColor'])) {
            $styles_str .= "#leftnav .panel a.list-group-item:hover{background: {$theme_options_styles['leftSubMenuHoverBgColor']};}";
        }
        if (!empty($theme_options_styles['leftSubMenuHoverFontColor'])) {
            $styles_str .= "#leftnav .panel a.list-group-item:hover{color: {$theme_options_styles['leftSubMenuHoverFontColor']};}";
        }
        if (!empty($theme_options_styles['leftMenuFontColor'])) {
            $styles_str .= "#leftnav .panel a.parent-menu{color: {$theme_options_styles['leftMenuFontColor']};}";
        }
        if (!empty($theme_options_styles['leftMenuBgColor'])) {
            $styles_str .= "#leftnav .panel a.parent-menu{background: {$theme_options_styles['leftMenuBgColor']};}";
        }
        if (!empty($theme_options_styles['leftMenuHoverFontColor'])) {
            $styles_str .= "#leftnav .panel .panel-heading:hover {color: {$theme_options_styles['leftMenuHoverFontColor']};}";
        }
        if (!empty($theme_options_styles['leftMenuSelectedFontColor'])) {
            $styles_str .= "#leftnav .panel a.parent-menu:not(.collapsed){color: {$theme_options_styles['leftMenuSelectedFontColor']};}";
        }
        if (isset($theme_options_styles['custom_logo'])) {
            $t->set_var('logo_img', $theme_options_styles['custom_logo']);
        }
        if (isset($theme_options_styles['custom_logo_small'])) {
            $t->set_var('logo_img_small', $theme_options_styles['custom_logo_small']);
        }
        $t->set_var('EXTRA_CSS', "<style>{$styles_str}</style>");
    }
    $t->set_var('TOOL_PATH', $urlAppend);
    if (isset($body_action)) {
        $t->set_var('BODY_ACTION', $body_action);
    }
    $t->set_var('LANG_SEARCH', $langSearch);
    // display role switch button if needed
    if (isset($require_current_course) and ($is_editor or isset($saved_is_editor) and $saved_is_editor)) {
        if ($is_editor) {
            $t->set_var('STUDENT_VIEW_TITLE', $langStudentViewEnable);
        } else {
            $t->set_var('STUDENT_VIEW_TITLE', $langStudentViewDisable);
            $t->set_var('STUDENT_VIEW_CLASS', 'btn-toggle-on');
        }
        $t->set_var('STUDENT_VIEW_URL', $urlAppend . 'main/student_view.php?course=' . $course_code);
    } else {
        if (!$is_embedonce) {
            $t->set_block('mainBlock', 'statusSwitchBlock', 'delete');
        }
    }
    // if $require_help is true (set by each tool) display the help link
    if ($require_help == true) {
        if (isset($require_current_course) and !$is_editor) {
            $helpTopic .= '_student';
        }
        $head_content .= "\n        <script>\n        \$(function() {\n            \$('#help-btn').click(function(e) {\n                e.preventDefault();\n                \$.get(\$(this).attr(\"href\"), function(data) {bootbox.alert(data);});\n            });\n        });\n        </script>\n        ";
        $help_link_icon = "\n\n        <a id='help-btn' href=\"" . $urlAppend . "modules/help/help.php?topic={$helpTopic}&amp;language={$language}\">\n            <i class='fa fa-question-circle tiny-icon' rel='tooltip' data-toggle='tooltip' data-placement='top' title='{$langHelp}'></i>\n        </a>";
        $t->set_var('HELP_LINK_ICON', $help_link_icon);
        $t->set_var('LANG_HELP', $langHelp);
    } else {
        $t->set_var('HELP_LINK_ICON', '');
        $t->set_var('LANG_HELP', '');
    }
    if (isset($head_content)) {
        global $webDir;
        // required by indexer
        require_once 'modules/search/indexer.class.php';
        if (isset($_SESSION[Indexer::SESSION_PROCESS_AT_NEXT_DRAW]) && $_SESSION[Indexer::SESSION_PROCESS_AT_NEXT_DRAW] === true) {
            $head_content .= Indexer::queueAsyncJSCode();
            $_SESSION[Indexer::SESSION_PROCESS_AT_NEXT_DRAW] = false;
        }
        $t->set_var('HEAD_EXTRAS', $head_content);
    }
    if (defined('RSS')) {
        $t->set_var('RSS_LINK_ICON', "\n\n            <a href='{$urlAppend}" . RSS . "'>\n                <i class='fa fa-rss-square tiny-icon tiny-icon-rss' rel='tooltip' data-toggle='tooltip' data-placement='top' title='RSS Feed'></i>\n            </a>\n\n\n        ");
    }
    if ($perso_tool_content) {
        $t->set_var('LANG_MY_PERSO_LESSONS', $langMyPersoLessons);
        $t->set_var('LANG_MY_PERSO_DEADLINES', $langMyPersoDeadlines);
        $t->set_var('LANG_MY_PERSO_ANNOUNCEMENTS', $langMyPersoAnnouncements);
        $t->set_var('LANG_MY_PERSO_DOCS', $langMyPersoDocs);
        $t->set_var('LANG_MY_PERSO_AGENDA', $langMyPersoAgenda);
        $t->set_var('LANG_PERSO_FORUM', $langMyPersoForum);
        $t->set_var('LANG_MY_PERSONAL_CALENDAR', $langMyAgenda);
        $t->set_var('LESSON_CONTENT', $lesson_content);
        $t->set_var('ASSIGN_CONTENT', $assigns_content);
        $t->set_var('DOCS_CONTENT', $docs_content);
        $t->set_var('AGENDA_CONTENT', $agenda_content);
        $t->set_var('FORUM_CONTENT', $forum_content);
        $t->set_var('URL_PATH', $urlAppend);
        $t->set_var('TOOL_PATH', $urlAppend);
        $t->set_var('PERSONAL_CALENDAR_CONTENT', $personal_calendar_content);
    }
    $t->set_var('LANG_COPYRIGHT_NOTICE', $langCopyrightFooter);
    // Remove tool title block from selected pages
    if (defined('HIDE_TOOL_TITLE')) {
        $t->set_block('mainBlock', 'toolTitleBlock', 'toolTitleBlockVar');
        $t->set_var('toolTitleBlockVar', '');
    }
    //	At this point all variables are set and we are ready to send the final output
    //	back to the browser
    $t->parse('main', 'mainBlock', false);
    $t->pparse('Output', 'fh');
}
예제 #16
0
function handle_to_path($handle, $type = "model")
{
    if (false === strpos($handle, "/")) {
        throw new Exception("{$handle} isn't a valid class handle");
    }
    list($plugin, $model) = explode("/", $handle);
    $plugin_path = module_path($plugin);
    $magento = magento_path();
    $type = 0 == strcmp("controller", $type) ? "{$type}s" : ucfirst($type);
    $full_path = "{$magento}/app/code/{$plugin_path}/{$type}";
    $dir = "";
    if (false !== strpos($model, "_")) {
        $dir = "/" . str_replace(" ", "/", ucwords(str_replace("_", " ", substr($model, 0, strrpos($model, "_")))));
    }
    return "{$full_path}{$dir}";
}
예제 #17
0
	/**
	 * Listet alle Module mit dem absoluten Pfad auf
	 *
	 * @return array
	 */
	private function modules()
	{
		return $this->files->directories(module_path());
	}
예제 #18
0
 /**
  * Save a language file
  *
  * @param string $filename The name of the file to locate. The file will be found by looking in all modules.
  * @param string $language The language to retrieve.
  * @param array  $settings An array of the language settings
  * @param bool   $return   TRUE to return the contents or FALSE to write to file
  *
  * @return mixed A string when the $return setting is TRUE
  */
 function save_lang_file($filename = NULL, $language = 'english', $settings = NULL, $return = FALSE)
 {
     if (empty($filename) || !is_array($settings)) {
         return FALSE;
     }
     // Is it the application_lang file?
     if ($filename == 'application_lang.php' || $filename == 'datatable_lang.php') {
         $path = APPPATH . 'language/' . $language . '/' . $filename;
     } else {
         $module = str_replace('_lang.php', '', $filename);
         $path = module_file_path($module, 'language', $language . '/' . $filename);
         // If it's empty still, just grab the module path
         if (empty($path)) {
             $path = module_path($module, 'language');
         }
     }
     // Load the file so we can loop through the lines
     if (is_file($path)) {
         $contents = file_get_contents($path);
         $empty = FALSE;
     } else {
         // Create the folder...
         $folder = basename($path) == 'language' ? $path . '/' . $language : dirname($path);
         if (!is_dir($folder)) {
             mkdir($folder);
             $path = basename($path) == 'language' ? $folder . '/' . $module . '_lang.php' : $path;
         }
         $contents = '';
         $empty = TRUE;
     }
     // Save the file.
     foreach ($settings as $name => $val) {
         // Is the config setting in the file?
         $start = strpos($contents, '$lang[\'' . $name . '\']');
         $end = strpos($contents, ';', $start);
         $search = substr($contents, $start, $end - $start + 1);
         //var_dump($search); die();
         if (is_array($val)) {
             $tval = 'array(\'';
             $tval .= implode("','", $val);
             $tval .= '\')';
             $val = $tval;
             unset($tval);
         } else {
             if (is_numeric($val)) {
                 $val = $val;
             } else {
                 $val = '\'' . str_replace("'", "\\'", $val) . '\'';
             }
         }
         if (!$empty) {
             $contents = str_replace($search, '$lang[\'' . $name . '\'] = ' . $val . ';', $contents);
         } else {
             $contents .= '$lang[\'' . $name . '\'] = ' . $val . ";\n";
         }
     }
     //end foreach
     // is the code we are producing OK?
     if (!is_null(eval(str_replace('<?php', '', $contents)))) {
         return FALSE;
     }
     // Make sure the file still has the php opening header in it...
     if (strpos($contents, '<?php') === FALSE) {
         $contents = '<?php if ( ! defined(\'BASEPATH\')) exit(\'No direct script access allowed\');' . "\n\n" . $contents;
     }
     // Write the changes out...
     if (!function_exists('write_file')) {
         $CI = get_instance();
         $CI->load->helper('file');
     }
     if ($return == FALSE) {
         $result = write_file($path, $contents);
     } else {
         return $contents;
     }
     if ($result === FALSE) {
         return FALSE;
     } else {
         return TRUE;
     }
 }
예제 #19
0
 /**
  * Deletes a module and all of its files.
  *
  * @access public
  *
  * @return void
  */
 public function delete()
 {
     $module_name = $this->input->post('module');
     if (!empty($module_name)) {
         $this->auth->restrict('Bonfire.Modules.Delete');
         $prefix = $this->db->dbprefix;
         $this->db->trans_begin();
         // check if there is a model to drop (non-table modules will have no model)
         $model_name = $module_name . "_model";
         if (module_file_path($module_name, 'models', $model_name . '.php')) {
             // drop the table
             $this->load->model($module_name . '/' . $model_name, 'mt');
             $this->dbforge->drop_table($this->mt->get_table());
         }
         // get any permission ids
         $query = $this->db->query('SELECT permission_id FROM ' . $prefix . 'permissions WHERE name LIKE "' . $module_name . '.%.%"');
         if ($query->num_rows() > 0) {
             foreach ($query->result_array() as $row) {
                 // undo any permissions that exist
                 $this->db->where('permission_id', $row['permission_id']);
                 $this->db->delete('permissions');
                 // and fron the roles as well.
                 $this->db->where('permission_id', $row['permission_id']);
                 $this->db->delete('role_permissions');
             }
         }
         // drop the schema - old Migration schema method
         $module_name_lower = preg_replace("/[ -]/", "_", strtolower($module_name));
         if ($this->db->field_exists($module_name_lower . '_version', 'schema_version')) {
             $this->dbforge->drop_column('schema_version', $module_name_lower . '_version');
         }
         // drop the Migration record - new Migration schema method
         $module_name_lower = preg_replace("/[ -]/", "_", strtolower($module_name));
         if ($this->db->field_exists('version', 'schema_version')) {
             $this->db->delete('schema_version', array('type' => $module_name_lower . '_'));
         }
         if ($this->db->trans_status() === FALSE) {
             $this->db->trans_rollback();
             Template::set_message('We could not delete this module.', $this->db->error, 'error');
         } else {
             $this->db->trans_commit();
             // database was successful in deleting everything. Now try to get rid of the files.
             if (delete_files(module_path($module_name), true)) {
                 @rmdir(module_path($module_name . '/'));
                 // Log the activity
                 $this->activity_model->log_activity((int) $this->current_user->id, lang('mb_act_delete') . ': ' . $module_name . ' : ' . $this->input->ip_address(), 'builder');
                 Template::set_message('The module and associated database entries were successfully deleted.', 'success');
             } else {
                 Template::set_message('The module and associated database entries were successfully deleted, HOWEVER, the module folder and files were not removed. They must be removed manually.', 'info');
             }
         }
         //end if
     }
     //end if
     Template::redirect(SITE_AREA . '/developer/builder');
 }
예제 #20
0
 /**
  * Deletes a module and all of its files.
  *
  * @access public
  *
  * @return void
  */
 public function delete()
 {
     $module_name = $this->input->post('module');
     if (!empty($module_name)) {
         $this->auth->restrict('Bonfire.Modules.Delete');
         $this->db->trans_begin();
         // check if there is a model to drop (non-table modules will have no model)
         $model_name = $module_name . '_model';
         if (module_file_path($module_name, 'models', $model_name . '.php')) {
             // drop the table
             $this->load->model($module_name . '/' . $model_name, 'mt');
             $this->load->dbforge();
             $this->dbforge->drop_table($this->mt->get_table());
         }
         // get any permission ids
         $query = $this->db->select('permission_id')->like('name', $module_name . '.', 'after')->get('permissions');
         if ($query->num_rows() > 0) {
             foreach ($query->result_array() as $row) {
                 // undo any permissions that exist
                 $this->db->where('permission_id', $row['permission_id'])->delete('permissions');
                 // and from the roles as well.
                 $this->db->where('permission_id', $row['permission_id'])->delete('role_permissions');
             }
         }
         // drop the schema - old Migration schema method
         $module_name_lower = preg_replace("/[ -]/", "_", strtolower($module_name));
         if ($this->db->field_exists($module_name_lower . '_version', 'schema_version')) {
             $this->dbforge->drop_column('schema_version', $module_name_lower . '_version');
         }
         // drop the Migration record - new Migration schema method
         if ($this->db->field_exists('version', 'schema_version')) {
             $this->db->delete('schema_version', array('type' => $module_name_lower . '_'));
         }
         if ($this->db->trans_status() === FALSE) {
             $this->db->trans_rollback();
             Template::set_message(lang('mb_delete_trans_false'), $this->db->error, 'error');
         } else {
             $this->db->trans_commit();
             // database was successful in deleting everything. Now try to get rid of the files.
             if (delete_files(module_path($module_name), true)) {
                 @rmdir(module_path($module_name . '/'));
                 // Log the activity
                 log_activity((int) $this->current_user->id, lang('mb_act_delete') . ': ' . $module_name . ' : ' . $this->input->ip_address(), 'builder');
                 Template::set_message(lang('mb_delete_success'), 'success');
             } else {
                 Template::set_message(lang('mb_delete_success') . lang('mb_delete_success_db_only'), 'info');
             }
         }
         //end if
     }
     //end if
     redirect(SITE_AREA . '/developer/builder');
 }
예제 #21
0
/**
 * Function draw
 *
 * This method processes all data to render the display. It is executed by
 * each tool. Is in charge of generating the interface and parse it to the user's browser.
 *
 * @param mixed $toolContent html code
 * @param int $menuTypeID
 * @param string $tool_css (optional) catalog name where a "tool.css" file exists
 * @param string $head_content (optional) code to be added to the HEAD of the UI
 * @param string $body_action (optional) code to be added to the BODY tag
 */
function draw($toolContent, $menuTypeID, $tool_css = null, $head_content = null, $body_action = null, $hideLeftNav = null, $perso_tool_content = null)
{
    global $session, $course_code, $course_id, $helpTopic, $is_editor, $langActivate, $langNote, $langAdmin, $langAdvancedSearch, $langAnonUser, $langChangeLang, $langChooseLang, $langDeactivate, $langProfileMenu, $langEclass, $langHelp, $langUsageTerms, $langHomePage, $langLogin, $langLogout, $langMyPersoAgenda, $langMyAgenda, $langMyPersoAnnouncements, $langMyPersoDeadlines, $langMyPersoDocs, $langMyPersoForum, $langMyCourses, $langPortfolio, $langSearch, $langUser, $langUserPortfolio, $langUserHeader, $language, $navigation, $pageName, $toolName, $sectionName, $currentCourseName, $require_current_course, $require_course_admin, $require_help, $siteName, $siteName, $switchLangURL, $theme, $themeimg, $toolContent_ErrorExists, $urlAppend, $urlServer, $theme_settings, $language, $saved_is_editor, $langProfileImage, $langStudentViewEnable, $langStudentViewDisable, $langNoteTitle, $langEnterNote, $langFieldsRequ;
    // negative course_id might be set in common documents
    if ($course_id < 1) {
        unset($course_id);
        unset($course_code);
    }
    // get blocks content from $toolContent array
    if ($perso_tool_content) {
        $lesson_content = $perso_tool_content['lessons_content'];
        $personal_calendar_content = $perso_tool_content['personal_calendar_content'];
    }
    function get_theme_class($class)
    {
        global $theme_settings;
        if (isset($theme_settings['classes'][$class])) {
            return $theme_settings['classes'][$class];
        } else {
            return $class;
        }
    }
    if (!$toolName and $pageName) {
        $toolName = $pageName;
    } elseif (!$pageName and $toolName) {
        $pageName = $toolName;
    }
    $pageTitle = $siteName;
    $is_mobile = isset($_SESSION['mobile']) && $_SESSION['mobile'] == true;
    $is_embedonce = isset($_SESSION['embedonce']) && $_SESSION['embedonce'] == true;
    unset($_SESSION['embedonce']);
    //get the left side menu from tools.php
    $toolArr = $is_mobile ? array() : getSideMenu($menuTypeID);
    $numOfToolGroups = count($toolArr);
    $GLOBALS['head_content'] = '';
    $head_content .= $GLOBALS['head_content'];
    $t = new Template('template/' . $theme);
    if ($is_embedonce) {
        $template_file = 'embed.html';
    } else {
        $template_file = 'theme.html';
    }
    $t->set_file('fh', $template_file);
    $t->set_block('fh', 'mainBlock', 'main');
    // template_callback() can be defined in theme settings.php
    if (function_exists('template_callback')) {
        template_callback($t, $menuTypeID, $is_embedonce);
    }
    $t->set_var('LANG', $language);
    $t->set_var('ECLASS_VERSION', ECLASS_VERSION);
    if (!$is_embedonce) {
        // Remove search if not enabled
        if (!get_config('enable_search')) {
            $t->set_block('mainBlock', 'searchBlock', 'delete');
        }
        $t->set_var('leftNavClass', 'no-embed');
    }
    //	BEGIN constructing of left navigation
    //	----------------------------------------------------------------------
    $t->set_block('mainBlock', 'leftNavBlock', 'leftNav');
    $t->set_block('leftNavBlock', 'leftNavCategoryBlock', 'leftNavCategory');
    $t->set_block('leftNavCategoryBlock', 'leftNavCategoryTitleBlock', 'leftNavCategoryTitle');
    $t->set_block('leftNavCategoryBlock', 'leftNavLinkBlock', 'leftNavLink');
    $t->set_var('template_base', $urlAppend . 'template/' . $theme);
    $t->set_var('img_base', $themeimg);
    $current_module_dir = module_path($_SERVER['REQUEST_URI']);
    if (!$is_mobile and !$hideLeftNav) {
        if (is_array($toolArr)) {
            $group_opened = false;
            for ($i = 0; $i < $numOfToolGroups; $i++) {
                if (!$is_embedonce) {
                    $t->set_var('NAV_BLOCK_CLASS', $toolArr[$i][0]['class']);
                    $t->set_var('TOOL_GROUP_ID', $i);
                    if ($toolArr[$i][0]['type'] == 'none') {
                        $t->set_var('ACTIVE_TOOLS', '&nbsp;');
                        $t->set_var('NAV_CSS_CAT_CLASS', 'spacer');
                    } elseif ($toolArr[$i][0]['type'] == 'split') {
                        $t->set_var('ACTIVE_TOOLS', '&nbsp;');
                        $t->set_var('NAV_CSS_CAT_CLASS', 'split');
                    } elseif ($toolArr[$i][0]['type'] == 'text') {
                        $t->set_var('ACTIVE_TOOLS', $toolArr[$i][0]['text']);
                        $t->set_var('NAV_CSS_CAT_CLASS', 'category');
                    }
                    $t->parse('leftNavCategoryTitle', 'leftNavCategoryTitleBlock', false);
                }
                $t->set_var('GROUP_CLASS', '');
                $numOfTools = count($toolArr[$i][1]);
                for ($j = 0; $j < $numOfTools; $j++) {
                    $t->set_var('TOOL_LINK', $toolArr[$i][2][$j]);
                    $t->set_var('TOOL_TEXT', $toolArr[$i][1][$j]);
                    if (is_external_link($toolArr[$i][2][$j]) or $toolArr[$i][3][$j] == 'fa-external-link') {
                        $t->set_var('TOOL_EXTRA', ' target="_blank"');
                    } else {
                        $t->set_var('TOOL_EXTRA', '');
                    }
                    $t->set_var('IMG_FILE', $toolArr[$i][3][$j]);
                    $img_class = basename($toolArr[$i][3][$j], ".png");
                    $img_class = preg_replace('/_(on|off)$/', '', $img_class);
                    if (isset($theme_settings['icon_map'][$img_class])) {
                        $img_class = $theme_settings['icon_map'][$img_class];
                    }
                    $t->set_var('IMG_CLASS', $img_class);
                    $module_dir = module_path($toolArr[$i][2][$j]);
                    if ($module_dir == $current_module_dir) {
                        $t->set_var('TOOL_CLASS', get_theme_class('tool_active'));
                        $t->set_var('GROUP_CLASS', get_theme_class('group_active'));
                        $group_opened = true;
                    } else {
                        $t->set_var('TOOL_CLASS', '');
                    }
                    $t->parse('leftNavLink', 'leftNavLinkBlock', true);
                }
                if (!$group_opened and ($current_module_dir == '/' or $current_module_dir == 'course_home' or $current_module_dir == 'units' or $current_module_dir == 'weeks' or $current_module_dir == 'main/portfolio.php')) {
                    $t->set_var('GROUP_CLASS', get_theme_class('group_active'));
                    $group_opened = true;
                }
                $t->parse('leftNavCategory', 'leftNavCategoryBlock', true);
                $t->clear_var('leftNavLink');
                //clear inner block
            }
            $t->parse('leftNav', 'leftNavBlock', true);
        }
    }
    $t->set_var('URL_PATH', $urlAppend);
    $t->set_var('SITE_NAME', $siteName);
    $t->set_var('FAVICON_PATH', $urlAppend . 'template/favicon/favicon.ico');
    $t->set_var('ICON_PATH', $urlAppend . 'template/favicon/openeclass_128x128.png');
    //If there is a message to display, show it (ex. Session timeout)
    if ($messages = Session::getMessages()) {
        $t->set_var('EXTRA_MSG', "<div class='row'><div class='col-xs-12'>" . $messages . "</div></div>");
    }
    $t->set_var('TOOL_CONTENT', $toolContent);
    if (isset($GLOBALS['leftNavExtras'])) {
        $t->set_var('ECLASS_LEFTNAV_EXTRAS', $GLOBALS['leftNavExtras']);
    }
    // if user is logged in display the logout option
    if (isset($_SESSION['uid'])) {
        $t->set_var('LANG_USER', q($langUserHeader));
        $t->set_var('USER_NAME', q($_SESSION['givenname']));
        $t->set_var('USER_SURNAME', q($_SESSION['surname']));
        $t->set_var('LANG_USER_ICON', $langProfileMenu);
        $t->set_var('USER_ICON', user_icon($_SESSION['uid']));
        $t->set_var('USERNAME', q($_SESSION['uname']));
        $t->set_var('LANG_PROFILE', q($GLOBALS['langMyProfile']));
        $t->set_var('PROFILE_LINK', $urlAppend . 'main/profile/display_profile.php');
        $t->set_var('LANG_MESSAGES', q($GLOBALS['langMyDropBox']));
        $t->set_var('MESSAGES_LINK', $urlAppend . 'modules/dropbox/index.php');
        $t->set_var('LANG_COURSES', q($GLOBALS['langMyCourses']));
        $t->set_var('COURSES_LINK', $urlAppend . 'main/my_courses.php');
        $t->set_var('LANG_AGENDA', q($langMyAgenda));
        $t->set_var('AGENDA_LINK', $urlAppend . 'main/personal_calendar/index.php');
        $t->set_var('LANG_NOTES', q($GLOBALS['langNotes']));
        $t->set_var('NOTES_LINK', $urlAppend . 'main/notes/index.php');
        $t->set_var('LANG_STATS', q($GLOBALS['langMyStats']));
        $t->set_var('STATS_LINK', $urlAppend . 'main/profile/personal_stats.php');
        $t->set_var('LANG_LOGOUT', q($langLogout));
        $t->set_var('LOGOUT_LINK', $urlAppend . 'index.php?logout=yes');
        $t->set_var('MY_COURSES', q($GLOBALS['langMyCoursesSide']));
        $t->set_var('MY_MESSAGES', q($GLOBALS['langNewMyMessagesSide']));
        $t->set_var('LANG_ANNOUNCEMENTS', q($GLOBALS['langMyAnnouncements']));
        $t->set_var('ANNOUNCEMENTS_LINK', $urlAppend . 'modules/announcements/myannouncements.php');
        if (!$is_embedonce) {
            if (get_config('personal_blog')) {
                $t->set_var('LANG_MYBLOG', q($GLOBALS['langMyBlog']));
                $t->set_var('MYBLOG_LINK', $urlAppend . 'modules/blog/index.php');
            } elseif ($menuTypeID > 0) {
                $t->set_block('mainBlock', 'PersoBlogBlock', 'delete');
            }
            if ($session->status == USER_TEACHER and get_config('mydocs_teacher_enable') or $session->status == USER_STUDENT and get_config('mydocs_student_enable')) {
                $t->set_var('LANG_MYDOCS', q($GLOBALS['langMyDocs']));
                $t->set_var('MYDOCS_LINK', $urlAppend . 'main/mydocs/index.php');
            } elseif ($menuTypeID > 0) {
                $t->set_block('mainBlock', 'MyDocsBlock', 'delete');
            }
        }
        $t->set_var('QUICK_NOTES', q($GLOBALS['langQuickNotesSide']));
        $t->set_var('langSave', q($GLOBALS['langSave']));
        $t->set_var('langAllNotes', q($GLOBALS['langAllNotes']));
        $t->set_var('langAllMessages', q($GLOBALS['langAllMessages']));
        $t->set_var('langNoteTitle', q($langNoteTitle));
        $t->set_var('langEnterNoteLabel', $langNote);
        $t->set_var('langEnterNote', q($langEnterNote));
        $t->set_var('langFieldsRequ', q($langFieldsRequ));
        $t->set_var('LOGGED_IN', 'true');
    } else {
        if (get_config('hide_login_link')) {
            $t->set_block('mainBlock', 'LoginIconBlock', 'delete');
        } else {
            $next = str_replace($urlAppend, '/', $_SERVER['REQUEST_URI']);
            if (preg_match('@(?:^/(?:modules|courses)|listfaculte|opencourses|openfaculties)@', $next)) {
                $nextParam = '?next=' . urlencode($next);
            } else {
                $nextParam = '';
            }
            $t->set_var('LANG_LOGOUT', $langLogin);
            $t->set_var('LOGOUT_LINK', $urlServer . 'main/login_form.php' . $nextParam);
        }
        $t->set_var('LOGGED_IN', 'false');
    }
    if (isset($require_current_course) and !isset($sectionName)) {
        $sectionName = $currentCourseName;
    }
    // set the text and icon on the third bar (header)
    if ($menuTypeID == 2) {
        if (!$pageName) {
            $t->set_var('SECTION_TITLE', q($currentCourseName));
        } else {
            $t->set_var('SECTION_TITLE', "<a href='{$urlServer}courses/{$course_code}/'>" . q($currentCourseName) . '</a>');
        }
    } elseif ($menuTypeID == 3) {
        $t->set_var('SECTION_TITLE', $langAdmin);
        $sectionName = $langAdmin;
    } elseif ($menuTypeID > 0 and $menuTypeID < 3) {
        $t->set_var('SECTION_TITLE', $langUserPortfolio);
        $sectionName = $langUserPortfolio;
    } else {
        $t->set_var('SECTION_TITLE', $langEclass);
        $sectionName = $langEclass;
    }
    //set the appropriate search action for the searchBox form
    if ($menuTypeID == 2) {
        $searchAction = "search_incourse.php?all=true";
        $searchAdvancedURL = $searchAction;
    } elseif ($menuTypeID == 1 || $menuTypeID == 3) {
        $searchAction = "search.php";
        $searchAdvancedURL = $searchAction;
    } else {
        //$menuType == 0
        $searchAction = "search.php";
        $searchAdvancedURL = $searchAction;
    }
    $mod_activation = '';
    if ($is_editor and isset($course_code)) {
        // link for activating / deactivating module
        $module_id = current_module_id();
        if (display_activation_link($module_id)) {
            if (visible_module($module_id)) {
                $modIconClass = 'fa-minus-square tiny-icon-red';
                $modIconTitle = q($langDeactivate);
                $modState = 0;
            } else {
                $modIconClass = 'fa-check-square tiny-icon-green';
                $modIconTitle = q($langActivate);
                $modState = 1;
            }
            $mod_activation = "<a href='{$urlAppend}main/module_toggle.php?course={$course_code}&amp;module_id={$module_id}' id='module_toggle' data-state='{$modState}' data-toggle='tooltip' data-placement='top' title='{$modIconTitle}'><span class='fa tiny-icon {$modIconClass}'></span></a>";
        }
    }
    $t->set_var('SEARCH_ACTION', $searchAction);
    $t->set_var('SEARCH_ADVANCED_URL', $searchAdvancedURL);
    $t->set_var('SEARCH_TITLE', $langSearch);
    $t->set_var('SEARCH_ADVANCED', $langAdvancedSearch);
    $t->set_var('LANG_PORTFOLIO', $langPortfolio);
    $t->set_var('TOOL_NAME', $toolName);
    if ($is_editor) {
        $t->set_var('ACTIVATE_MODULE', $mod_activation);
    }
    if (!$t->get_var('LANG_SELECT')) {
        if ($menuTypeID != 2) {
            $t->set_var('LANG_SELECT', lang_selections());
            $t->set_var('LANG_SELECT_TITLE', "title='{$langChooseLang}'");
        } else {
            $t->set_var('LANG_SELECT', '');
        }
    }
    // breadcrumb and page title
    if (!$is_embedonce and !$is_mobile and $current_module_dir != '/') {
        $t->set_block('mainBlock', 'breadCrumbLinkBlock', 'breadCrumbLink');
        $t->set_block('mainBlock', 'breadCrumbEntryBlock', 'breadCrumbEntry');
        // Breadcrumb first entry (home / portfolio)
        if ($session->status != USER_GUEST) {
            if (isset($_SESSION['uid'])) {
                $t->set_var('BREAD_TEXT', '<span class="fa fa-home"></span> ' . $langPortfolio);
                $t->set_var('BREAD_HREF', $urlAppend . 'main/portfolio.php');
            } else {
                $t->set_var('BREAD_TEXT', $langHomePage);
                $t->set_var('BREAD_HREF', $urlAppend);
            }
            if (isset($require_current_course) or $pageName) {
                $t->parse('breadCrumbEntry', 'breadCrumbLinkBlock', true);
            } else {
                $t->parse('breadCrumbEntry', 'breadCrumbEntryBlock', true);
            }
        }
        // Breadcrumb course home entry
        if (isset($course_code)) {
            $t->set_var('BREAD_TEXT', q(ellipsize($currentCourseName, 48)));
            if ($pageName) {
                $t->set_var('BREAD_HREF', $urlAppend . 'courses/' . $course_code . '/');
                $t->parse('breadCrumbEntry', 'breadCrumbLinkBlock', true);
            } else {
                $t->parse('breadCrumbEntry', 'breadCrumbEntryBlock', true);
            }
            $pageTitle .= " | " . ellipsize($currentCourseName, 32);
        }
        foreach ($navigation as $step) {
            $t->set_var('BREAD_TEXT', q($step['name']));
            if (isset($step['url'])) {
                $t->set_var('BREAD_HREF', $step['url']);
                $t->parse('breadCrumbEntry', 'breadCrumbLinkBlock', true);
            } else {
                $t->parse('breadCrumbEntry', 'breadCrumbEntryBlock', true);
            }
        }
        if ($pageName) {
            $t->set_var('BREAD_TEXT', q($pageName));
            $t->parse('breadCrumbEntry', 'breadCrumbEntryBlock', true);
        }
        if ($pageName) {
            $pageTitle .= " | " . $pageName;
        }
    } else {
        if (!$is_embedonce) {
            $t->set_block('mainBlock', 'breadCrumbs', 'delete');
        }
    }
    //END breadcrumb --------------------------------
    $t->set_var('PAGE_TITLE', q($pageTitle));
    if (isset($course_code)) {
        $t->set_var('COURSE_CODE', $course_code);
        $t->set_var('COURSE_ID', $course_id);
    }
    if (!$is_embedonce) {
        if ($is_mobile) {
            $t->set_block('mainBlock', 'normalViewOpenDiv', 'delete');
            $t->set_block('mainBlock', 'headerBlock', 'delete');
        } else {
            $t->set_block('mainBlock', 'mobileViewOpenDiv', 'delete');
        }
    }
    // Add Theme Options styles
    $t->set_var('logo_img', $themeimg . '/eclass-new-logo.png');
    $t->set_var('logo_img_small', $themeimg . '/logo_eclass_small.png');
    $t->set_var('container', 'container');
    $theme_id = isset($_SESSION['theme_options_id']) ? $_SESSION['theme_options_id'] : get_config('theme_options_id');
    if ($theme_id) {
        $theme_options = Database::get()->querySingle("SELECT * FROM theme_options WHERE id = ?d", $theme_id);
        $theme_options_styles = unserialize($theme_options->styles);
        $urlThemeData = $urlAppend . 'courses/theme_data/' . $theme_id;
        $styles_str = '';
        if (!empty($theme_options_styles['bgColor']) || !empty($theme_options_styles['bgImage'])) {
            $background_type = "";
            if (isset($theme_options_styles['bgType']) && $theme_options_styles['bgType'] == 'stretch') {
                $background_type .= "background-size: 100% 100%;";
            } elseif (isset($theme_options_styles['bgType']) && $theme_options_styles['bgType'] == 'fix') {
                $background_type .= "background-size: 100% 100%;background-attachment: fixed;";
            }
            $bg_image = isset($theme_options_styles['bgImage']) ? " url('{$urlThemeData}/{$theme_options_styles['bgImage']}')" : "";
            $bg_color = isset($theme_options_styles['bgColor']) ? $theme_options_styles['bgColor'] : "";
            $styles_str .= "body{background: {$bg_color}{$bg_image};{$background_type}}";
        }
        $gradient_str = 'radial-gradient(closest-corner at 30% 60%, #009BCF, #025694)';
        if (!empty($theme_options_styles['loginJumbotronBgColor']) && !empty($theme_options_styles['loginJumbotronRadialBgColor'])) {
            $gradient_str = "radial-gradient(closest-corner at 30% 60%, {$theme_options_styles['loginJumbotronRadialBgColor']}, {$theme_options_styles['loginJumbotronBgColor']})";
        }
        if (isset($theme_options_styles['loginImg'])) {
            $styles_str .= ".jumbotron.jumbotron-login { background-image: url('{$urlThemeData}/{$theme_options_styles['loginImg']}'), {$gradient_str} }";
        }
        if (isset($theme_options_styles['loginImgPlacement']) && $theme_options_styles['loginImgPlacement'] == 'full-width') {
            $styles_str .= ".jumbotron.jumbotron-login {  background-size: cover, cover; background-position: 0% 0%;}";
        }
        //$styles_str .= ".jumbotron.jumbotron-login {  background-size: 353px, cover; background-position: 10% 60%;}";
        if (isset($theme_options_styles['fluidContainerWidth'])) {
            $t->set_var('container', 'container-fluid');
            $styles_str .= ".container-fluid {max-width:{$theme_options_styles['fluidContainerWidth']}px}";
        }
        if (isset($theme_options_styles['openeclassBanner'])) {
            $styles_str .= "#openeclass-banner {display: none;}";
        }
        if (!empty($theme_options_styles['leftNavBgColor'])) {
            $rgba_no_alpha = explode(',', $theme_options_styles['leftNavBgColor']);
            $rgba_no_alpha[3] = "1)";
            $rgba_no_alpha = implode(',', $rgba_no_alpha);
            $styles_str .= "#background-cheat-leftnav, #bgr-cheat-header, #bgr-cheat-footer{background:{$theme_options_styles['leftNavBgColor']};} @media(max-width: 992px){#leftnav{background:{$rgba_no_alpha};}}";
        }
        if (!empty($theme_options_styles['linkColor'])) {
            $styles_str .= "a {color: {$theme_options_styles['linkColor']};}";
        }
        if (!empty($theme_options_styles['linkHoverColor'])) {
            $styles_str .= "a:hover, a:focus {color: {$theme_options_styles['linkHoverColor']};}";
        }
        if (!empty($theme_options_styles['leftSubMenuFontColor'])) {
            $styles_str .= "#leftnav .panel a {color: {$theme_options_styles['leftSubMenuFontColor']};}";
        }
        if (!empty($theme_options_styles['leftSubMenuHoverBgColor'])) {
            $styles_str .= "#leftnav .panel a.list-group-item:hover{background: {$theme_options_styles['leftSubMenuHoverBgColor']};}";
        }
        if (!empty($theme_options_styles['leftSubMenuHoverFontColor'])) {
            $styles_str .= "#leftnav .panel a.list-group-item:hover{color: {$theme_options_styles['leftSubMenuHoverFontColor']};}";
        }
        if (!empty($theme_options_styles['leftMenuFontColor'])) {
            $styles_str .= "#leftnav .panel a.parent-menu{color: {$theme_options_styles['leftMenuFontColor']};}";
        }
        if (!empty($theme_options_styles['leftMenuBgColor'])) {
            $styles_str .= "#leftnav .panel a.parent-menu{background: {$theme_options_styles['leftMenuBgColor']};}";
        }
        if (!empty($theme_options_styles['leftMenuHoverFontColor'])) {
            $styles_str .= "#leftnav .panel .panel-heading:hover {color: {$theme_options_styles['leftMenuHoverFontColor']};}";
        }
        if (!empty($theme_options_styles['leftMenuSelectedFontColor'])) {
            $styles_str .= "#leftnav .panel a.parent-menu:not(.collapsed){color: {$theme_options_styles['leftMenuSelectedFontColor']};}";
        }
        if (isset($theme_options_styles['imageUpload'])) {
            $t->set_var('logo_img', "{$urlThemeData}/{$theme_options_styles['imageUpload']}");
        }
        if (isset($theme_options_styles['imageUploadSmall'])) {
            $t->set_var('logo_img_small', "{$urlThemeData}/{$theme_options_styles['imageUploadSmall']}");
        }
        $t->set_var('EXTRA_CSS', "<style>{$styles_str}</style>");
    }
    $t->set_var('TOOL_PATH', $urlAppend);
    if (isset($body_action)) {
        $t->set_var('BODY_ACTION', $body_action);
    }
    $t->set_var('LANG_SEARCH', $langSearch);
    // display role switch button if needed
    if (isset($require_current_course) and ($is_editor or isset($saved_is_editor) and $saved_is_editor) and !(isset($require_course_admin) and $require_course_admin) and !(isset($require_editor) and $require_editor)) {
        if ($is_editor) {
            $t->set_var('STUDENT_VIEW_TITLE', $langStudentViewEnable);
        } else {
            $t->set_var('STUDENT_VIEW_TITLE', $langStudentViewDisable);
            $t->set_var('STUDENT_VIEW_CLASS', 'btn-toggle-on');
        }
        $t->set_var('STUDENT_VIEW_URL', $urlAppend . 'main/student_view.php?course=' . $course_code);
    } else {
        if (!$is_embedonce) {
            $t->set_block('mainBlock', 'statusSwitchBlock', 'delete');
        }
    }
    // if $require_help is true (set by each tool) display the help link
    if ($require_help == true) {
        if (isset($require_current_course) and !$is_editor) {
            $helpTopic .= '_student';
        }
        $head_content .= "\n        <script>\n        \$(function() {\n            \$('#help-btn').click(function(e) {\n                e.preventDefault();\n                \$.get(\$(this).attr(\"href\"), function(data) {bootbox.alert(data);});\n            });\n        });\n        </script>\n        ";
        $help_link_icon = "\n\n        <a id='help-btn' href=\"" . $urlAppend . "modules/help/help.php?topic={$helpTopic}&amp;language={$language}\">\n            <i class='fa fa-question-circle tiny-icon' data-toggle='tooltip' data-placement='top' title='{$langHelp}'></i>\n        </a>";
        $t->set_var('HELP_LINK_ICON', $help_link_icon);
        $t->set_var('LANG_HELP', $langHelp);
    } else {
        $t->set_var('HELP_LINK_ICON', '');
        $t->set_var('LANG_HELP', '');
    }
    if (isset($head_content)) {
        global $webDir;
        // required by indexer
        require_once 'modules/search/indexer.class.php';
        if (isset($_SESSION[Indexer::SESSION_PROCESS_AT_NEXT_DRAW]) && $_SESSION[Indexer::SESSION_PROCESS_AT_NEXT_DRAW] === true) {
            $head_content .= Indexer::queueAsyncJSCode();
            $_SESSION[Indexer::SESSION_PROCESS_AT_NEXT_DRAW] = false;
        }
        $t->set_var('HEAD_EXTRAS', $head_content);
    }
    if (defined('RSS')) {
        $t->set_var('RSS_LINK_ICON', "\n\n            <a href='{$urlAppend}" . RSS . "'>\n                <i class='fa fa-rss-square tiny-icon tiny-icon-rss' data-toggle='tooltip' data-placement='top' title='RSS Feed'></i>\n            </a>\n\n\n        ");
    }
    if ($perso_tool_content) {
        $t->set_var('LANG_MY_PERSO_LESSONS', $langMyCourses);
        $t->set_var('LANG_MY_PERSO_ANNOUNCEMENTS', $langMyPersoAnnouncements);
        $t->set_var('LANG_MY_PERSONAL_CALENDAR', $langMyAgenda);
        $t->set_var('LESSON_CONTENT', $lesson_content);
        $t->set_var('URL_PATH', $urlAppend);
        $t->set_var('TOOL_PATH', $urlAppend);
        $t->set_var('PERSONAL_CALENDAR_CONTENT', $personal_calendar_content);
    }
    $t->set_var('COPYRIGHT', 'Open eClass © 2003-' . date('Y'));
    $t->set_var('TERMS_URL', $urlAppend . 'info/terms.php');
    $t->set_var('LANG_TERMS', $langUsageTerms);
    // Remove tool title block from selected pages
    if (defined('HIDE_TOOL_TITLE')) {
        $t->set_block('mainBlock', 'toolTitleBlock', 'toolTitleBlockVar');
        $t->set_var('toolTitleBlockVar', '');
    }
    $t->set_var('EXTRA_FOOTER_CONTENT', get_config('extra_footer_content'));
    // Hack to leave HTML body unclosed
    if (defined('TEMPLATE_REMOVE_CLOSING_TAGS')) {
        $t->set_block('mainBlock', 'closingTagsBlock', 'delete');
    }
    //	At this point all variables are set and we are ready to send the final output
    //	back to the browser
    $t->parse('main', 'mainBlock', false);
    $t->pparse('Output', 'fh');
}
 /**
  * Get all of the migration paths.
  *
  * @return array
  */
 protected function getMigrationPaths()
 {
     $slug = $this->argument('slug');
     $paths = [];
     if ($slug) {
         $paths[] = module_path($slug, 'Database/Migrations');
     } else {
         foreach ($this->module->all() as $module) {
             $paths[] = module_path($module['slug'], 'Database/Migrations');
         }
     }
     return $paths;
 }
예제 #23
0
 /**
  * Generate defined module folders.
  */
 protected function generateModule()
 {
     if (!$this->files->isDirectory(module_path())) {
         $this->files->makeDirectory(module_path());
     }
     $pathMap = config('modules.pathMap');
     $directory = module_path(null, $this->container['basename']);
     $source = __DIR__ . '/../../../resources/stubs/module';
     $this->files->makeDirectory($directory);
     $sourceFiles = $this->files->allFiles($source, true);
     if (!empty($pathMap)) {
         $search = array_keys($pathMap);
         $replace = array_values($pathMap);
     }
     foreach ($sourceFiles as $file) {
         $contents = $this->replacePlaceholders($file->getContents());
         $subPath = $file->getRelativePathname();
         if (!empty($pathMap)) {
             $subPath = str_replace($search, $replace, $subPath);
         }
         $filePath = $directory . '/' . $subPath;
         $dir = dirname($filePath);
         if (!$this->files->isDirectory($dir)) {
             $this->files->makeDirectory($dir, 0755, true);
         }
         $this->files->put($filePath, $contents);
     }
 }
예제 #24
0
 /**
  * Save a language file
  *
  * @param string $filename The name of the file to locate. The file will be found by looking in all modules.
  * @param string $language The language to retrieve.
  * @param array  $settings An array of the language settings
  * @param bool   $return   TRUE to return the contents or FALSE to write to file
  *
  * @return mixed A string when the $return setting is TRUE
  */
 function save_lang_file($filename = NULL, $language = 'english', $settings = NULL, $return = FALSE)
 {
     if (empty($filename) || !is_array($settings)) {
         return FALSE;
     }
     // Is it the application_lang file?
     if ($filename == 'application_lang.php' || $filename == 'datatable_lang.php') {
         $orig_path = APPPATH . 'language/english/' . $filename;
         $path = APPPATH . 'language/' . $language . '/' . $filename;
     } else {
         $module = str_replace('_lang.php', '', $filename);
         $orig_path = module_file_path($module, 'language', 'english/' . $filename);
         $path = module_file_path($module, 'language', $language . '/' . $filename);
         // If it's empty still, just grab the module path
         if (empty($path)) {
             $path = module_path($module, 'language');
         }
     }
     // Load the file so we can loop through the lines
     if (!is_file($orig_path)) {
         return FALSE;
     }
     $contents = file_get_contents($orig_path);
     $contents = trim($contents) . "\n";
     if (!is_file($path)) {
         // Create the folder...
         $folder = basename($path) == 'language' ? $path . '/' . $language : dirname($path);
         if (!is_dir($folder)) {
             mkdir($folder);
             $path = basename($path) == 'language' ? $folder . '/' . $module . '_lang.php' : $path;
         }
     }
     // Save the file.
     foreach ($settings as $name => $val) {
         // Use strrpos() instead of strpos() so we don't lose data
         // when people have put duplicate keys in the english files
         $start = strrpos($contents, '$lang[\'' . $name . '\']');
         if ($start === FALSE) {
             // tried to add non-existent value?
             return FALSE;
         }
         $end = strpos($contents, "\n", $start) + strlen("\n");
         if ($val !== '') {
             $val = '\'' . addcslashes($val, '\'\\') . '\'';
             $replace = '$lang[\'' . $name . '\'] = ' . $val . ";\n";
         } else {
             $replace = '// ' . substr($contents, $start, $end - $start);
         }
         $contents = substr($contents, 0, $start) . $replace . substr($contents, $end);
     }
     //end foreach
     // is the code we are producing OK?
     if (!is_null(eval(str_replace('<?php', '', $contents)))) {
         return FALSE;
     }
     // Make sure the file still has the php opening header in it...
     if (strpos($contents, '<?php') === FALSE) {
         $contents = '<?php if ( ! defined(\'BASEPATH\')) exit(\'No direct script access allowed\');' . "\n\n" . $contents;
     }
     // Write the changes out...
     if (!function_exists('write_file')) {
         $CI = get_instance();
         $CI->load->helper('file');
     }
     if ($return == FALSE) {
         $result = write_file($path, $contents);
     } else {
         return $contents;
     }
     if ($result === FALSE) {
         return FALSE;
     } else {
         return TRUE;
     }
 }
예제 #25
0
 public function get_available_versions($type = '')
 {
     switch ($type) {
         case '':
             $migrations_path = $this->migrations_path . 'core/';
             break;
         case 'app_':
             $migrations_path = $this->migrations_path;
             break;
         default:
             $migrations_path = module_path(substr($type, 0, -1), 'migrations') . '/';
             break;
     }
     $files = glob($migrations_path . '*_*' . EXT);
     for ($i = 0; $i < count($files); $i++) {
         $files[$i] = str_ireplace($migrations_path, '', $files[$i]);
     }
     return $files;
 }
예제 #26
0
 /**
  * Get the destination class path.
  *
  * @param string $name
  *
  * @return string
  */
 protected function getPath($name)
 {
     return module_path($this->argument('slug'), 'Database/Seeds/' . $name . '.php');
 }
예제 #27
0
 public function migrate_module()
 {
     $module = $this->uri->segment(5);
     $file = $this->input->post('version');
     $version = $file !== 'uninstall' ? (int) substr($file, 0, 3) : 0;
     $path = module_path($module, 'migrations');
     // Reset the migrations path for this run only.
     $this->migrations->set_path($path);
     // Do the migration
     $this->migrate_to($version, $module . '_');
     // Log the activity
     $this->activity_model->log_activity($this->auth->user_id(), 'Migrate module: ' . $module . ' Version: ' . $version . ' from: ' . $this->input->ip_address(), 'migrations');
 }
예제 #28
0
 /**
  * Search the migrations folder and return a list of available migration files.
  *
  * @access public
  *
  * @param string $type A string that represents the name of the module, or 'app_' for application migrations. If empty, it returns core migrations.
  *
  * @return array An array of migration files
  */
 public function get_available_versions($type = '')
 {
     switch ($type) {
         case '':
             $migrations_path = $this->migrations_path;
             break;
         case 'app_':
             $migrations_path = APPPATH . 'db/migrations/';
             break;
         default:
             $migrations_path = module_path(substr($type, 0, -1), 'migrations') . '/';
             break;
     }
     // List all *_*.php files in the migrations path
     $files = glob($migrations_path . '*_*' . EXT);
     for ($i = 0; $i < count($files); $i++) {
         // Remove path and extension
         $files[$i] = basename($files[$i], EXT);
         // Mark wrongly formatted files as FALSE for later filtering
         if (!preg_match('/^\\d{3}_(\\w+)$/', $files[$i])) {
             $files[$i] = FALSE;
         }
     }
     $migrations = array_filter($files);
     sort($migrations);
     return $migrations;
 }