Esempio n. 1
0
 public function getAll()
 {
     parent::getAll();
     $path = $this->_root;
     mimport('framework.filesystem.folder');
     $folders = MFolder::folders($path);
     $data = array();
     foreach ($folders as $folder) {
         $files = MFolder::files($path . '/' . $folder);
         $item = new MCacheStorageHelper($folder);
         foreach ($files as $file) {
             $item->updateSize(filesize($path . '/' . $folder . '/' . $file) / 1024);
         }
         $data[$folder] = $item;
     }
     return $data;
 }
Esempio n. 2
0
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Initialize some field attributes.
     $filter = (string) $this->element['filter'];
     $exclude = (string) $this->element['exclude'];
     $hideNone = (string) $this->element['hide_none'];
     $hideDefault = (string) $this->element['hide_default'];
     // Get the path in which to search for file options.
     $path = (string) $this->element['directory'];
     if (!is_dir($path)) {
         $path = MPATH_ROOT . '/' . $path;
     }
     // Prepend some default options based on field attributes.
     if (!$hideNone) {
         $options[] = MHtml::_('select.option', '-1', MText::alt('MOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     if (!$hideDefault) {
         $options[] = MHtml::_('select.option', '', MText::alt('MOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
     }
     // Get a list of folders in the search path with the given filter.
     $folders = MFolder::folders($path, $filter);
     // Build the options list from the list of folders.
     if (is_array($folders)) {
         foreach ($folders as $folder) {
             // Check to see if the file is in the exclude mask.
             if ($exclude) {
                 if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
                     continue;
                 }
             }
             $options[] = MHtml::_('select.option', $folder, $folder);
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Esempio n. 3
0
 protected static function _load($option)
 {
     if (isset(self::$components[$option]) and self::$components[$option] !== null) {
         return true;
     }
     mimport('framework.filesystem.folder');
     $folders = MFolder::folders(MPATH_WP_PLG);
     if (empty($folders)) {
         self::$components[$option] = new stdClass();
         return false;
     }
     self::$components = array();
     $n = count($folders);
     for ($i = 0; $i < $n; $i++) {
         $folder = @$folders[$i];
         if (empty($folder)) {
             continue;
         }
         if (substr($folder, 0, 4) != 'miwo') {
             continue;
         }
         $com = new stdClass();
         $com->id = $i;
         $com->option = 'com_' . $folder;
         $com->params = MFactory::getWOption($folder);
         $com->enabled = 1;
         // Convert the params to an object.
         if (is_string($com->params)) {
             $temp = new MRegistry();
             $temp->loadString($com->params);
             $com->params = $temp;
         }
         self::$components[$com->option] = $com;
     }
     return true;
 }
Esempio n. 4
0
 public function deletePlugins()
 {
     $plugins_dir = MPATH_WP_CNT . '/miwi/plugins';
     if (!MFolder::exists($plugins_dir)) {
         return;
     }
     $folders = MFolder::folders($plugins_dir);
     foreach ($folders as $folder) {
         if (strpos($folder, $this->context) !== false) {
             MFolder::delete($plugins_dir . '/' . $folder);
         }
     }
 }
Esempio n. 5
0
 protected static function _load()
 {
     if (self::$plugins !== null) {
         return self::$plugins;
     }
     mimport('framework.filesystem.folder');
     if (!MFolder::exists(MPATH_PLUGINS)) {
         self::$plugins = array();
         return self::$plugins;
     }
     $folders = MFolder::folders(MPATH_PLUGINS);
     if (empty($folders)) {
         self::$plugins = array();
         return self::$plugins;
     }
     self::$plugins = array();
     foreach ($folders as $folder) {
         $folder = str_replace('plg_', '', $folder);
         list($type, $name) = explode('_', $folder);
         $plg = new stdClass();
         $plg->type = $type;
         $plg->name = $name;
         $plg->params = null;
         $xml_file = MPATH_MIWI . '/plugins/plg_' . $type . '_' . $name . '/' . $name . '.xml';
         if (file_exists($xml_file)) {
             $form = MForm::getInstance($folder . '_form', $xml_file, array(), false, 'config');
             $field_sets = $form->getFieldsets();
             if (!empty($field_sets)) {
                 $params = array();
                 foreach ($field_sets as $name => $field_set) {
                     foreach ($form->getFieldset($name) as $field) {
                         $field_name = $field->get('fieldname');
                         $field_value = $field->get('value');
                         $params[$field_name] = $field_value;
                     }
                 }
                 $plg->params = json_encode($params);
             }
         }
         self::$plugins[] = $plg;
     }
     return self::$plugins;
 }
Esempio n. 6
0
 protected static function &_load($module_id = null)
 {
     /*if (self::$modules !== null) {
     			return self::$modules;
     		}*/
     mimport('framework.filesystem.folder');
     if (!MFolder::exists(MPATH_MODULES)) {
         self::$modules = 0;
         return self::$modules;
     }
     $folders = MFolder::folders(MPATH_MODULES);
     if (empty($folders)) {
         self::$modules = 0;
         return self::$modules;
     }
     self::$modules = array();
     foreach ($folders as $folder) {
         if (strpos($folder, 'quickicons')) {
             continue;
         }
         $mod = new stdClass();
         $mod->id = $folder;
         $mod->title = $folder;
         $mod->module = $folder;
         $mod->name = $folder;
         $mod->menuid = 0;
         $mod->position = $folder;
         $mod->user = 0;
         $mod->params = null;
         $mod->style = null;
         $mod->content = '';
         $mod->showtitle = 0;
         $mod->control = '';
         $params = MFactory::getWOption('widget_' . $folder . '_widget', false, $module_id);
         if ($params != null) {
             $mod->params = json_encode($params);
         }
         self::$modules[] = $mod;
     }
     return self::$modules;
 }
Esempio n. 7
0
 protected function getLayoutsFromViews($plugin, $view)
 {
     $options = array();
     $layouts = array();
     $layoutNames = array();
     $app = MFactory::getApplication();
     $path = '';
     // Get the views for this component.
     if (is_dir(MPATH_WP_PLG . '/' . $plugin . '/site')) {
         $folders = MFolder::folders(MPATH_WP_PLG . '/' . $plugin . '/site', '^view[s]?$', false, true);
     }
     if (!empty($folders[0])) {
         $path = $folders[0] . '/' . $view . '/tmpl';
     }
     if (is_dir($path)) {
         $layouts = array_merge($layouts, MFolder::files($path, '.xml$', false, true));
     } else {
         return $options;
     }
     // Build list of standard layout names
     foreach ($layouts as $layout) {
         // Ignore private layouts.
         if (strpos(basename($layout), '_') === false) {
             // Get the layout name.
             $layoutNames[] = basename($layout, '.xml');
         }
     }
     // Get the template layouts
     $tmpl = $app->getTemplate();
     // Array to hold association between template file names and templates
     $templateName = array();
     //@TODO : Do not forget that delete "com_" string
     if (is_dir(MPATH_THEMES . '/' . $tmpl . '/html/com_' . $plugin . '/' . $view)) {
         $templateLayouts = MFolder::files(MPATH_THEMES . '/' . $tmpl . '/html/com_' . $plugin . '/' . $view, '.xml$', false, true);
         foreach ($templateLayouts as $templateLayout) {
             // Get the layout name.
             $templateLayoutName = basename($templateLayout, '.xml');
             // add to the list only if it is not a standard layout
             if (array_search($templateLayoutName, $layoutNames) === false) {
                 $layouts[] = $templateLayout;
                 // Set template name array so we can get the right template for the layout
                 $templateName[$templateLayout] = $tmpl;
             }
         }
     }
     // Process the found layouts.
     foreach ($layouts as $layout) {
         $file = $layout;
         $array = array();
         // Ignore private layouts.
         if (strpos(basename($layout), '_') === false) {
             $form = new MForm(basename($layout));
             $form->loadFile($layout, true, '/metadata');
             if (is_file($file)) {
                 // Attempt to load the xml file.
                 if ($xml = simplexml_load_file($file)) {
                     // Look for the first view node off of the root node.
                     if ($menu = $xml->xpath('layout[1]')) {
                         $menu = $menu[0];
                         // If the view is hidden from the menu, discard it and move on to the next view.
                         if (!empty($menu['hidden']) && $menu['hidden'] == 'true') {
                             unset($xml);
                             unset($o);
                             continue;
                         }
                         // Populate the title and description if they exist.
                         if (!empty($menu['title'])) {
                             $array['title'] = trim((string) $menu['title']);
                         }
                     }
                 }
             }
             // Add the layout to the options array.
             $array['form'] = $form;
             $options[$view . '_' . basename($layout, '.xml')] = $array;
         }
     }
     return $options;
 }
Esempio n. 8
0
 public static function parseLanguageFiles($dir = null)
 {
     mimport('framework.filesystem.folder');
     $languages = array();
     $subdirs = MFolder::folders($dir);
     foreach ($subdirs as $path) {
         $langs = self::parseXMLLanguageFiles("{$dir}/{$path}");
         $languages = array_merge($languages, $langs);
     }
     return $languages;
 }