示例#1
0
 function getStaticUrl()
 {
     if ($module = Modules::get($this->stylesheet)) {
         return $module->getName();
     }
     return $this->stylesheet;
 }
示例#2
0
 function showPermission($id)
 {
     if ($userData = Sentry::findUserById($id)) {
         if ($userData->isSuperUser()) {
             return Redirect::to($this->moduleURL . 'show-list');
         }
     } else {
         return Redirect::to($this->moduleURL . 'show-list');
     }
     $this->data['status'] = Session::has("status") ? Session::get("status") : FALSE;
     $this->data['message'] = Session::has("message") ? Session::get("message") : "";
     $this->data['id'] = $id;
     // GET ALL PERMISSION
     $permissions = Permission::get()->toArray();
     $permissionMap = array();
     // GET ALL MODULE
     $moduleData = Modules::get()->toArray();
     if (!empty($permissions)) {
         foreach ($permissions as $permission) {
             $permissionMap[$permission['module_id']][] = $permission;
         }
     }
     if (!empty($moduleData)) {
         $moduleData = array_column($moduleData, 'name', 'id');
     }
     // GET USER PERMISSION
     $userPermissions = Sentry::findUserById($id)->getPermissions();
     $this->data['permissionMap'] = $permissionMap;
     $this->data['moduleData'] = $moduleData;
     $this->data['userPermissions'] = $userPermissions;
     if (Request::isMethod('post')) {
         $this->postPermission($id, $userData, $this->data);
         if ($this->data['status'] === TRUE) {
             return Redirect::to($this->moduleURL . 'permission/' . $this->data['id']);
         }
     }
     $this->layout->content = View::make('showPermission', $this->data);
 }
示例#3
0
文件: theme.php 项目: ycms/wordpress
/**
 * Retrieve theme directory URI.
 *
 * @since 1.5.0
 *
 * @return string Template directory URI.
 */
function get_template_directory_uri()
{
    $template = str_replace('%2F', '/', rawurlencode(get_template()));
    $theme_root_uri = get_theme_root_uri($template);
    if (class_exists('Modules') and $module = Modules::get($template)) {
        $template = $module->getName();
    }
    $template_dir_uri = "{$theme_root_uri}/{$template}";
    /**
     * Filter the current theme directory URI.
     *
     * @since 1.5.0
     *
     * @param string $template_dir_uri The URI of the current theme directory.
     * @param string $template         Directory name of the current theme.
     * @param string $theme_root_uri   The themes root URI.
     */
    return apply_filters('template_directory_uri', $template_dir_uri, $template, $theme_root_uri);
}
示例#4
0
文件: Generator.php 项目: xiphe/html
 /**
  * Catch all Method that allows to use the tag name as method name and append options to it
  *
  * @param string $method the tag name with optional options i.e. s_div or h1
  * @param array  $args   the arguments passed to the method call
  * 
  * @return mixed  null or Tag instance or string
  */
 public static function call($method, $args = array(), $addedOptions = array())
 {
     /*
      * Return if not enabled.
      */
     if (Config::get('disable')) {
         return;
     }
     /*
      * Sanitize Method name. (Just to be sure XD)
      */
     $method = preg_replace('/[^a-z0-9_]+/', '', strtolower($method));
     /*
      * Split the method name into options and tag.
      */
     $e = explode('_', $method);
     if (count($e) == 1 && !empty($e[0])) {
         $tag = $e[0];
         $options = false;
     } elseif (count($e) == 2 && !empty($e[1])) {
         $tag = $e[1];
         $options = $e[0];
     } else {
         /*
          * Invalid format
          */
         self::debug(sprintf('Invalid format in HTML Call "%s"', $method), 3, 2);
         return null;
     }
     /*
      * Verify the options
      */
     $tmp = array();
     foreach (str_split($options) as $key) {
         if (isset(self::$tagOptionKeys[$key])) {
             $tmp[] = self::$tagOptionKeys[$key];
         }
     }
     $options = $tmp;
     unset($tmp);
     /*
      * Verify options passed indirectly to the generator (by a module for example).
      */
     foreach ($addedOptions as $key => $option) {
         if (!in_array($option, self::$tagOptionKeys)) {
             unset($addedOptions[$key]);
         }
     }
     /*
      * Merge all options.
      */
     $options = array_merge($options, $addedOptions);
     unset($addedOptions);
     $called = $tag;
     Modules::appendAlias($tag);
     $Module = '';
     /**
      * Loads the Module and asks if is should be used for this case.
      *
      * @var function
      */
     $useModule = function () use(&$Module, $tag, &$args, &$options, &$called) {
         $Module = Modules::get($tag, $args, $options, $called);
         return $Module->sure();
     };
     /*
      * Check if the Tag is forced to be generated or no module exists and generate it.
      * Otherwise prefer the module.
      */
     if (in_array('generate', $options) || !Modules::exist($tag) || !$useModule()) {
         $tag = $called;
         /*
          * Create new Tag
          */
         $Tag = new Tag($tag, $args, $options);
         /*
          * Do things that should be done before tag will be created
          */
         $r = self::_applyPreGenerationFilters($Tag);
         /*
          * Check if the pre-generation filters have returned anything and return it in this case.
          */
         if ($r !== null) {
             return $r;
         }
         $Tag->open();
         if (!$Tag->hasOption('start')) {
             $Tag->content();
             $Tag->close();
         }
         /*
          * Do things that should be done after tag generation.
          */
         return self::_applyPostGenerationFilters($Tag);
     } else {
         if (empty($Module)) {
             $Module = Modules::get($tag, $args, $options, $called);
         }
         /*
          * Do things that should be done before tag will be created
          */
         $r = self::_applyPreGenerationFilters($Module);
         /*
          * Check if the pre-generation filters have returned anything and return it in this case.
          */
         if ($r !== null) {
             return $r;
         }
         $Module->execute();
         /*
          * Do things that should be done after tag generation.
          */
         return self::_applyPostGenerationFilters($Module);
     }
 }
 function render()
 {
     $listModuleFile = array();
     $listIgnores = array('.', '..', '.DS_Store', '.svn');
     $primaryArray = array('Create', 'Read', 'Edit', 'Delete');
     $listFiles = array_diff(scandir($this->modulePath), $listIgnores);
     // GET LIST FILE IN FOLDER
     if (!empty($listFiles)) {
         foreach ($listFiles as $file) {
             $fileName = ucwords(str_replace("_", " ", $file));
             $fileSlug = str_replace("_", "-", $file);
             $listModuleFile[$fileSlug] = $fileName;
         }
     }
     // GET LIST FILE IN DATABASE
     $listModuleStore = Modules::get()->toArray();
     $listModuleStore = array_column($listModuleStore, 'name', 'slug');
     // NEW MODULE
     $diffInsert = array_diff($listModuleFile, $listModuleStore);
     $insertData = array();
     if (!empty($diffInsert)) {
         foreach ($diffInsert as $k => $v) {
             $mA = explode("-", $k);
             $suffix = last($mA);
             if ($suffix == 'manager') {
                 $count = count($mA);
                 $preSuffix = $mA[$count - 2];
                 $suffix = $preSuffix . "_" . $suffix;
             }
             $groupString = "group_" . $suffix . "_id";
             $group = 0;
             if (Config::has("backend.{$groupString}")) {
                 $group = Config::get("backend.{$groupString}");
             }
             $insertData = array('slug' => $k, 'name' => $v, 'group_id' => $group, 'status' => 1);
             if ($item = Modules::create($insertData)) {
                 if ($item->save()) {
                     // // Insert Menu
                     // $menuInsert = array(
                     // 	'status'		=>	0,
                     // 	'name'			=>	$item->name,
                     // 	'module_id'		=>	$item->id,
                     // 	'slug'			=>	$item->slug.'/show-list',
                     // );
                     // Menus::create($menuInsert);
                     // Create Primary Permission
                     foreach ($primaryArray as $p) {
                         $primaryInsert = array('name' => $item->name . " " . $p, 'slug' => $item->slug . "-" . strtolower($p), 'module_id' => $item->id, 'group_id' => $group, 'action' => strtolower($p));
                         Permission::create($primaryInsert);
                     }
                 }
             }
         }
     }
     // REMOVE MODULE
     $diffRemove = array_diff($listModuleStore, $listModuleFile);
     if (!empty($diffRemove)) {
         foreach ($diffRemove as $k => $v) {
             $item = Modules::where(array('slug' => $k, 'name' => $v))->first();
             $deleteID = $item->id;
             if ($item->delete()) {
                 // Menus::where('module_id', $deleteID)->delete();
                 Permission::where('module_id', $deleteID)->delete();
             }
         }
     }
 }
示例#6
0
<div class="row">
	<?php 
global $Options;
$modules = Modules::get();
foreach (force_array($modules) as $_module) {
    if (isset($_module['application']['details']['namespace'])) {
        $module_namespace = $_module['application']['details']['namespace'];
        ?>
	<div class="col-lg-3">
   	<div class="box" id="#module-">
      	<div class="box-header">
         	<h3 class="box-title"><?php 
        echo isset($_module['application']['details']['name']) ? $_module['application']['details']['name'] : __('Tendoo Extension');
        ?>
</h3>
         </div>
         <div class="box-body" style="height:100px;"><?php 
        echo isset($_module['application']['details']['description']) ? $_module['application']['details']['description'] : '';
        ?>
 </div>
         <div class="box-footer">
           	<?php 
        echo 'v' . (isset($_module['application']['details']['version']) ? $_module['application']['details']['version'] : 0.1);
        ?>
             <div class="box-tools pull-right">
            <?php 
        if (isset($_module['application']['details']['main'])) {
            // if the module has a main file, it can be activated
            if (!Modules::is_active($module_namespace)) {
                ?>
					  <a href="<?php 
示例#7
0
 /**
  * Modules Update Features
  **/
 function check_modules()
 {
     $modules = json_decode(file_get_content('https://raw.githubusercontent.com/Blair2004/tendoo-cms/3.0/modules.json'));
     $modules_status = force_array($this->options->get('modules_status'));
     foreach (Modules::get() as $namespace => $module) {
         // if current module is genuine
         if (in_array($namespace, array_keys($modules))) {
             // If a new version is available
             if (intval($module['version']) < $modules[$namespace]['version']) {
                 $modules_status[$namespace] = array('version' => $modules[$namespace]['version'], 'zip_url' => $modules[$namespace]['zip_url']);
             } else {
                 unset($modules_status[$namespace]);
                 // make sure already updated module is removed from "updatable modules"
             }
         }
     }
     $this->options->set('modules_status', $modules_status);
 }
示例#8
0
 function render()
 {
     $listModuleFile = array();
     $listIgnores = array('dashboard', 'home', 'chat', 'search', '.', '..', '.DS_Store', '.svn');
     $primaryArray = array('Create', 'Read', 'Edit', 'Delete');
     $listFiles = array_diff(scandir($this->modulePath), $listIgnores);
     // GET LIST FILE IN FOLDER
     if (!empty($listFiles)) {
         foreach ($listFiles as $file) {
             $file = str_replace("_backend", "", $file);
             $fileName = ucwords(str_replace("_", " ", $file));
             $fileSlug = str_replace("_", "-", $file);
             $listModuleFile[$fileSlug] = $fileName;
         }
     }
     // GET LIST FILE IN DATABASE
     $listModuleStore = Modules::get()->toArray();
     $listModuleStore = array_column($listModuleStore, 'name', 'slug');
     // NEW MODULE
     $diffInsert = array_diff($listModuleFile, $listModuleStore);
     $insertData = array();
     if (!empty($diffInsert)) {
         foreach ($diffInsert as $k => $v) {
             $insertData = array('slug' => $k, 'name' => $v, 'status' => 1);
             if ($item = Modules::create($insertData)) {
                 if ($item->save()) {
                     // Insert Menu
                     $menuInsert = array('status' => 0, 'name' => $item->name, 'module_id' => $item->id, 'slug' => $item->slug . '/show-list');
                     Menus::create($menuInsert);
                     // Create Primary Permission
                     foreach ($primaryArray as $p) {
                         $primaryInsert = array('name' => $item->name . " " . $p, 'slug' => $item->slug . "-" . strtolower($p), 'module_id' => $item->id, 'action' => strtolower($p));
                         Permission::create($primaryInsert);
                     }
                 }
             }
         }
     }
     // REMOVE MODULE
     $diffRemove = array_diff($listModuleStore, $listModuleFile);
     if (!empty($diffRemove)) {
         foreach ($diffRemove as $k => $v) {
             $item = Modules::where(array('slug' => $k, 'name' => $v))->first();
             $deleteID = $item->id;
             if ($item->delete()) {
                 Menus::where('module_id', $deleteID)->delete();
                 Permission::where('module_id', $deleteID)->delete();
             }
         }
     }
 }