Beispiel #1
0
/**
 * Walks through the boxes or forms folders and recursively builds a $list of found actions.
 *
 * @param string
 * @param string
 * @param string
 * @param array
 * @return boolean
 *
 */
function help_walker($appname, $type = 'boxes', $directory, &$list)
{
    $dir = new Dir($directory);
    if (!$dir->handle) {
        return false;
    }
    foreach ($dir->read_all() as $file) {
        if (strpos($file, '.') === 0 || $file == 'CVS') {
            continue;
        } elseif (@is_dir($directory . '/' . $file)) {
            $name = str_replace(getcwd() . '/inc/app/' . $appname . '/' . $type . '/', '', $directory . '/' . $file);
            $box = array('name' => $name, 'alt' => ucfirst(basename($name)), $type => array(), 'is_dir' => false);
            if (!@file_exists($directory . '/' . $file . '/index.php')) {
                $box['is_dir'] = true;
            } else {
                if ($type == 'boxes' && @file_exists($directory . '/' . $file . '/settings.php')) {
                    $settings = ini_parse($directory . '/' . $file . '/settings.php');
                    $box['alt'] = $settings['Meta']['name'];
                }
            }
            $list[$name] = $box;
            help_walker($appname, $type, $directory . '/' . $file, $list[$name][$type]);
        }
    }
    return true;
}
Beispiel #2
0
 function getChildFolders($id, $limit)
 {
     if (!empty($id)) {
         $root = 'inc/data/';
     } else {
         $root = 'inc/data';
     }
     $d = new Dir($root . $id);
     $list = $d->read_all();
     $folders = array();
     foreach ($list as $file) {
         if (strpos($file, '.') === 0 || !@is_dir($root . $id . '/' . $file) || $file == 'CVS') {
             continue;
         }
         if (!empty($id)) {
             $pref = $id . '/';
         } else {
             $pref = '';
         }
         $folders[] = (object) array('id' => $pref . $file, 'name' => $file);
     }
     return $folders;
     /*
     if (session_admin ()) {
     	$function = 'session_allowed_sql';
     } else {
     	$function = 'session_approved_sql';
     }
     if (! $id) {
     	$id = '';
     }
     return db_fetch_array ('select id, name from webpages_folder where parent_id = ? and ' . $function (), $id);
     */
 }
Beispiel #3
0
 function getTemplates($path = false)
 {
     if (!$path) {
         $path = 'inc/html/' . conf('Server', 'default_template_set');
     }
     $templates = array('' => 'Inherit', 'default' => 'Default');
     loader_import('saf.File.Directory');
     $dir = new Dir();
     if (!$dir->open($path)) {
         return $templates;
     }
     foreach ($dir->read_all() as $file) {
         if (strpos($file, '.') === 0 || @is_dir($path . '/' . $file)) {
             continue;
         }
         if (preg_match('/^html.([^\\.]+)\\.tpl$/', $file, $regs)) {
             if ($regs[1] == 'default') {
                 continue;
             }
             $templates[$regs[1]] = ucfirst($regs[1]);
         }
     }
     asort($templates);
     return $templates;
 }
Beispiel #4
0
 function getThemes($path = false)
 {
     if (!$path) {
         $path = site_docroot() . '/inc/app/sitepresenter/themes';
     }
     $themes = array();
     //'' => 'Default');
     loader_import('saf.File.Directory');
     $dir = new Dir();
     if (!$dir->open($path)) {
         return $themes;
     }
     foreach ($dir->read_all() as $file) {
         if (strpos($file, '.') === 0 || !@is_dir($path . '/' . $file)) {
             continue;
         }
         //if (preg_match ('/^html.([^\.]+)\.tpl$/', $file, $regs)) {
         //if ($regs[1] == 'default') {
         //	continue;
         //}
         $themes[$file] = ucfirst($file);
         //}
     }
     return $themes;
 }
Beispiel #5
0
 function build($path = false)
 {
     if ($path === false) {
         $path = $this->root;
     }
     $dir = new Dir($path);
     if (!$dir->handle) {
         $this->error = 'Failed to read directory: ' . $path;
         return false;
     }
     echo '<ul>';
     foreach ($dir->read_all() as $file) {
         if (strpos($file, '.') === 0 || in_array($file, array('CVS', 'PEAR', 'Ext', 'pix', 'install', 'data', 'lang', 'modes.php', 'images.php', 'access.php')) || preg_match('/\\.(jpg|gif|png|css|js)$/i', $file)) {
             continue;
         }
         if (in_array($path . '/' . $file, $this->except) || in_array($file, $this->except)) {
             continue;
         }
         echo '<li>' . $path . '/' . $file . '</li>';
         if (@is_dir($path . '/' . $file)) {
             if (!$this->build($path . '/' . $file)) {
                 $dir->close();
                 return false;
             }
         } elseif (@is_file($path . '/' . $file) && preg_match('/\\.(' . join('|', array_keys($this->extensions)) . ')$/i', $file, $regs)) {
             if ($file == 'settings.php' && strstr($path, 'forms')) {
                 $regs[1] = 'settings';
             } elseif ($file == 'translate.ini.php') {
                 $regs[1] = 'db';
             } elseif (strstr($path, 'conf/collections')) {
                 $regs[1] = 'collection';
             } elseif ($file == 'config.ini.php') {
                 $regs[1] = 'config';
             } elseif ($file == 'settings.ini.php') {
                 $regs[1] = 'settings';
             }
             if (!$this->{$this->extensions[$regs[1]]}($path . '/' . $file, $this->getContents($path . '/' . $file))) {
                 $dir->close();
                 return false;
             }
         }
         // else it's not a type of file we know how to parse
     }
     echo '</ul>';
     $dir->close();
     return true;
 }
Beispiel #6
0
 /**
  * Returns an array of all installed modules as Module objects.
  * 
  * @access	public
  * @return	array
  * 
  */
 function listAll()
 {
     global $loader;
     $loader->import('saf.File.Directory');
     $d = new Dir('mod');
     $dirs = $d->read_all();
     $mods = array();
     foreach ($dirs as $dir) {
         if ($dir == '_backup' || $dir == '.' || $dir == '..') {
             continue;
         }
         if (@file_exists('mod/' . $dir . '/settings.php')) {
             $tmp = new Module($dir);
             if (!$tmp->error) {
                 array_push($mods, $tmp);
             }
         }
     }
     return $mods;
 }
Beispiel #7
0
<?php

if (!session_admin()) {
    return;
}
$applications = parse_ini_file('inc/conf/auth/applications/index.php');
loader_import('saf.File.Directory');
$d = new Dir('inc/app');
$apps = array();
foreach ($d->read_all() as $file) {
    if (strpos($file, '.') === 0 || !@is_dir('inc/app/' . $file) || !@file_exists('inc/app/' . $file . '/conf/config.ini.php') || in_array($file, array('cms', 'usradm'))) {
        continue;
    }
    if (session_is_resource('app_' . $file) && !session_allowed('app_' . $file, 'rw', 'resource')) {
        continue;
    }
    if (isset($applications[$file]) && !$applications[$file]) {
        continue;
    }
    $c = @parse_ini_file('inc/app/' . $file . '/conf/config.ini.php');
    if (!isset($c['admin_handler']) || !isset($c['admin_handler_type']) || isset($c['admin']) && !$c['admin']) {
        continue;
    }
    if (!isset($c['app_name'])) {
        $c['app_name'] = $file;
    }
    if ($c['admin_handler_type'] == 'box') {
        $type = 'action';
    } else {
        $type = $c['admin_handler_type'];
    }
Beispiel #8
0
    /**
     * Returns the display HTML for this widget.  The optional
     * parameter determines whether or not to automatically display the widget
     * nicely, or whether to simply return the widget (for use in a template).
     * 
     * @access	public
     * @param	boolean	$generate_html
     * @return	string
     * 
     */
    function display($generate_html = 0)
    {
        $_dl = new MF_Widget_select('MF_' . $this->name . '_DIRLIST');
        $_dl->extra = $this->extra;
        $dir = new Dir($this->directory);
        if ($this->recursive == 0) {
            $list = $dir->read_all();
            $goodlist = array();
            $dir->close();
            foreach ($list as $file) {
                if (!eregi('^\\.ht', $file) && (eregi('\\.(' . join('|', $this->extensions) . ')$', $file) || count($this->extensions) == 0) && $file != '.' && $file != '..') {
                    $goodlist[$file] = $file;
                }
            }
        } else {
            $goodlist = array();
            // recurse
            $list = $dir->find('*', $this->directory, 1);
            for ($i = 0; $i < count($list); $i++) {
                if (!@is_dir($list[$i]) && !eregi('^\\.ht', $list[$i]) && (eregi('\\.(' . join('|', $this->extensions) . ')$', $list[$i]) || count($this->extensions) == 0) && $list[$i] != '.' && $list[$i] != '..') {
                    $list[$i] = preg_replace('/^' . preg_quote($this->directory . '/', '/') . '/', '', $list[$i]);
                    $goodlist[$list[$i]] = $list[$i];
                }
            }
        }
        $_dl->setValues($goodlist);
        $_dl->data_value = $this->data_value_DIRLIST;
        $_dirlist = new MF_Widget_hidden($this->name);
        $data = '';
        if ($this->show_viewbutton) {
            global $intl;
            $data .= '<script language="JavaScript">
<!--

function ' . $this->name . '_preview (name, params, formname) {
	// get src from form widget
	path = "' . $this->web_path . '/' . '" + document.forms[formname].elements[name].options[document.forms[formname].elements[name].selectedIndex].value;

	pop = window.open (\'\', name, params);
	pop.document.open ();
	pop.document.write (\'<link rel="stylesheet" type="text/css" href="css/site.css" />\');
	pop.document.write (\'<div align="center">\');
	pop.document.write (\'<img src="\' + path + \'" alt="\' + name + \'" border="0" />\');
	pop.document.write (\'<br /><br /><a href="#" onclick="window.close ()">' . $intl->get('Close Window') . '</a></div>\');
}

// -->
</script>';
            $showbutton = '&nbsp;<a href="#" onclick="' . $this->name . '_preview (\'MF_' . $this->name . '_DIRLIST\', \'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,dependent=no,fullscreen=no,width=300,height=300,top=50,left=160\', \'' . $this->formname . '\')">' . $intl->get('Preview') . '</a>';
        } else {
            $showbutton = '';
        }
        if ($generate_html) {
            $data .= $_dirlist->display(0) . "\n";
            $data .= "\t<tr>\n\t\t<td>" . '<label for="' . $this->name . '"' . $this->invalid() . '>' . $this->display_value . "</label></td>\n\t\t<td>" . $_dl->display(0) . $showbutton . "</td>\n\t</tr>\n";
        } else {
            $data .= $_dirlist->display(0);
            $data .= $_dl->display(0);
            $data .= $showbutton;
        }
        return $data;
    }
Beispiel #9
0
    return;
}
page_title(intl_get('AppDoc'));
echo '<p>';
//echo '<a href="' . site_prefix () . '/index/appdoc-translation-action?appname=GLOBAL">' . intl_get ('Global Translation') . '</a>';
//echo ' &nbsp; &nbsp; ';
echo '<a href="' . site_prefix() . '/index/help-app?appname=appdoc">' . intl_get('Help') . '</a>';
echo '</p>';
echo '<p>' . intl_get('Choose an app') . ':</p>';
loader_import('saf.File.Directory');
$dir = new Dir(getcwd() . '/inc/app');
if (!$dir->handle) {
    die($dir->error);
}
$apps = array();
$files = $dir->read_all();
echo '<ul>' . NEWLINE;
foreach ($files as $file) {
    if (strpos($file, '.') === 0 || $file == 'CVS') {
        continue;
    } elseif (@is_dir(getcwd() . '/inc/app/' . $file)) {
        // get name
        $info = ini_parse(getcwd() . '/inc/app/' . $file . '/conf/config.ini.php', false);
        if (isset($info['app_name'])) {
            $name = $info['app_name'];
        } else {
            $name = ucfirst($file);
        }
        echo '<li><a href="' . site_prefix() . '/index/appdoc-appinfo-action?appname=' . $file . '">' . $name . '</a></li>' . NEWLINE;
    }
}
Beispiel #10
0
 /**
  * Fills the $tables property with a list of Sitellite modules.
  * 
  * @access	public
  * 
  */
 function getMods()
 {
     global $loader;
     $loader->import('saf.App.Module');
     $loader->import('saf.File.Directory');
     $dir = new Dir(getcwd() . '/mod');
     $files = $dir->read_all();
     foreach ($files as $file) {
         if (ereg("^\\.+\$", $file)) {
             continue;
         }
         $module = new Module($file);
         if (!empty($module->name)) {
             $this->tables[$file] = $module->name;
         }
     }
 }
Beispiel #11
0
 /**
  * Searches a directory or directories (recursively) for a file
  * that contains a given string or pattern.  Note: this method requires
  * the saf.File class.
  * 
  * @access	public
  * @param	string	$string
  * @param	string	$basedir
  * @param	boolean	$recursive
  * @param	boolean	$regex
  * @return	array
  * 
  */
 function findInFiles($string, $basedir, $recursive = 0, $regex = 0)
 {
     $dir = new Dir($basedir);
     $res = array();
     $files = $dir->read_all();
     //echo "evaluating $basedir...\n";
     foreach ($files as $file) {
         if ($file == '.' || $file == '..') {
             continue;
         }
         //echo "trying file $file...\n";
         if (is_file($basedir . '/' . $file) && File::contains($string, $regex, $basedir . '/' . $file)) {
             array_push($res, $basedir . '/' . $file);
         }
         //exit;
         if ($recursive && is_dir($basedir . '/' . $file)) {
             $new_res = Dir::find_in_files($string, $basedir . '/' . $file, $recursive, $regex);
             // add $new_res to $res
             foreach ($new_res as $n) {
                 array_push($res, $n);
             }
         }
     }
     $dir->close();
     return $res;
 }