Example #1
0
 function onSubmit($vals)
 {
     $vals['name'] = strtolower($vals['name']);
     //make sure that file doesnt exit
     if (file_exists('inc/html/' . $vals['set_name'] . '/' . $vals['name'] . '.css')) {
         echo '<p>' . intl_get('A file with that name already exists. Choose a different file name.') . '</p>';
         echo '<p>' . intl_get('Go <a href=javascript:history.back()>back</a> to choose a different file name.') . '</p>';
     }
     if (preg_match('/\\.css$/i', $vals['name'])) {
         $ext = '';
     } else {
         $ext = '.css';
     }
     if (!file_overwrite('inc/html/' . $vals['set_name'] . '/' . $vals['name'] . $ext, $vals['body'])) {
         page_title(intl_get('An Error Occurred'));
         echo '<p>' . intl_get('The file was unable to be saved.  Please verify your server settings before trying again.') . '</p>';
         return;
     }
     umask(00);
     chmod('inc/html/' . $vals['set_name'] . '/' . $vals['name'] . $ext, 0777);
     list($set, $tpl) = explode('/', $vals['path']);
     echo $set . ' ' . $tpl;
     page_title('File Saved');
     echo '<p><a href="' . site_prefix() . '/index/sitetemplate-templateselect-action?set_name=' . $vals['set_name'] . '">' . intl_get('Return to template set') . '</a></p>';
 }
Example #2
0
 function onSubmit($vals)
 {
     unset($vals['submit_button']);
     loader_import('saf.File');
     file_overwrite('inc/app/sitewiki/conf/settings.php', ini_write($vals));
     echo '<p>Settings saved.  <a href="' . site_prefix() . '/index/sitewiki-app">Continue</a></p>';
 }
Example #3
0
 function onSubmit($vals)
 {
     loader_import('saf.File');
     if (!preg_match('/\\.html$/', $vals['filename'])) {
         $vals['filename'] .= '.html';
     }
     if (!preg_match('/\\.html$/', $vals['helpfile'])) {
         $vals['helpfile'] .= '.html';
     }
     $vals['body'] = '<h1>' . $vals['title'] . '</h1>' . NEWLINEx2 . $vals['body'];
     if (!file_overwrite(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang'] . '/' . $vals['filename'], $vals['body'])) {
         echo '<p>Error: Unable to write to the file.  Please verify your file and folder permissions.</p>';
         return;
     }
     if ($vals['helpfile'] != $vals['filename']) {
         // erase old file, this is a rename
         $res = @unlink(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang'] . '/' . $vals['helpfile']);
         if (!$res) {
             echo '<p>Error: Unable to remove the old file.  Please verify your file and folder permissions.</p>';
             return;
         }
     }
     header('Location: ' . site_prefix() . '/index/appdoc-helpdoc-action?appname=' . $vals['appname'] . '&lang=' . $vals['lang']);
     exit;
 }
Example #4
0
 function onSubmit($vals)
 {
     loader_import('saf.File');
     loader_import('saf.File.Directory');
     loader_import('saf.Misc.Ini');
     $info = help_get_langs($vals['appname']);
     $info[$vals['lang_code']] = $vals['lang_name'];
     if (!@mkdir(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang_code'], 0777)) {
         echo '<p>Error: Unable to create language folder.  Please verify your folder permissions.</p>';
         return;
     }
     if (!file_overwrite(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/languages.php', ini_write($info))) {
         echo '<p>Error: Unable to write to the file.  Please verify your folder permissions.</p>';
         return;
     }
     if (!empty($vals['copy_from'])) {
         // copy help files from specified lang to new dir
         $pages = help_get_pages($vals['appname'], $vals['lang']);
         foreach ($pages as $page) {
             $id = help_get_id($page);
             $res = copy(site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang'] . '/' . $id . '.html', site_docroot() . '/inc/app/' . $vals['appname'] . '/docs/' . $vals['lang_code'] . '/' . $id . '.html');
             if (!$res) {
                 echo '<p>Error: Unable to duplicate help files.  Please verify your folder permissions.</p>';
                 return;
             }
         }
     }
     // go to new language
     header('Location: ' . site_prefix() . '/index/appdoc-helpdoc-action?appname=' . $vals['appname'] . '&lang=' . $vals['lang_code']);
     exit;
 }
Example #5
0
 function onSubmit($vals)
 {
     if (!file_overwrite('inc/html/' . $vals['path'], $vals['body'])) {
         page_title(intl_get('An Error Occurred'));
         echo '<p>' . intl_get('The file was unable to be saved.  Please verify your server settings before trying again.') . '</p>';
         return;
     }
     list($set, $tpl) = explode('/', $vals['path']);
     page_title('Template Saved');
     echo '<p><a href="' . site_prefix() . '/index/sitetemplate-templateselect-action?set_name=' . $set . '">' . intl_get('Return to template set') . '</a></p>';
 }
Example #6
0
 function onSubmit($vals)
 {
     $set = $vals['set'];
     unset($vals['set']);
     file_overwrite('inc/html/' . $set . '/modes.php', $vals['modes']);
     unset($vals['submit_button']);
     unset($vals['modes']);
     $r = ini_write($vals);
     file_overwrite('inc/html/' . $set . '/config.ini.php', $r);
     header('Location: ' . site_prefix() . '/index/sitetemplate-templateselect-action?set_name=' . $set);
     exit;
 }
Example #7
0
 function onSubmit($vals)
 {
     // overwrite file
     $cache = array('Cache' => array(), 'Cacheable' => array());
     $cacheable = $vals['cacheable'];
     unset($vals['cacheable']);
     unset($vals['submit_button']);
     foreach ($vals as $k => $v) {
         $cache['Cache'][$k] = $v;
     }
     $cacheable = ini_parse($cacheable, false);
     foreach ($this->ignore as $i) {
         $cacheable[$i] = false;
     }
     $cache['Cacheable'] = $cacheable;
     loader_import('saf.File');
     if (!file_overwrite('inc/conf/cache.php', ini_write($cache))) {
         die('Error writing to file: inc/conf/cache.php');
     }
     echo '<p>' . intl_get('Cache settings saved.') . '  <a href="' . site_prefix() . '/index/cms-cpanel-action">' . intl_get('Continue') . '</a></p>';
 }
Example #8
0
 function onSubmit($vals)
 {
     unset($vals['Database']);
     unset($vals['Site']);
     unset($vals['Server']);
     unset($vals['I18n']);
     unset($vals['Messaging']);
     unset($vals['submit_button']);
     $config = array();
     foreach ($vals as $k => $v) {
         list($cname, $key) = explode('_', $k, 2);
         if (!isset($config[$cname])) {
             $config[$cname] = array($key => $v);
         } else {
             $config[$cname][$key] = $v;
         }
     }
     loader_import('saf.File');
     if (!file_overwrite('inc/conf/config.ini.php', ini_write($config))) {
         die('Error writing to file: inc/conf/config.ini.php');
     }
     echo '<p>' . intl_get('Site settings saved.') . '  <a href="' . site_prefix() . '/index/cms-cpanel-action">' . intl_get('Continue') . '</a></p>';
 }
Example #9
0
<?php

$info = parse_ini_file('inc/conf/auth/applications/index.php');
if (!empty($parameters['appname']) && isset($info[$parameters['appname']]) && $info[$parameters['appname']] != 'core') {
    $info[$parameters['appname']] = true;
    loader_import('saf.File');
    loader_import('saf.Misc.Ini');
    file_overwrite('inc/conf/auth/applications/index.php', ini_write($info));
}
header('Location: ' . site_prefix() . '/index/usradm-applications-action');
exit;
Example #10
0
<?php

if (!isset($parameters['orig'])) {
    list($filename, $remote) = explode('?snipshot_output=', $parameters['file']);
    list($tmp, $parameters['orig']) = explode('/pix/', $filename);
    $parameters['orig'] = 'pix/' . $parameters['orig'];
    $parameters['remote'] = 'cache/_' . str_replace('/', '_', $parameters['orig']);
    loader_import('saf.File');
    $filedata = @join('', @file($remote));
    file_overwrite($parameters['remote'], $filedata);
    page_title(intl_get('Saving File') . ': ' . $filename);
    $max_width = 350;
    $max_height = 400;
    list($w, $h) = getimagesize($parameters['orig']);
    if ($max_height < $h || $max_width < $w) {
        if ($h > $w) {
            $w = $w * ($max_height / $h);
            $h = $max_height;
        } else {
            $h = $h * ($max_width / $w);
            $w = $max_width;
        }
    }
    $parameters['orig_w'] = $w;
    $parameters['orig_h'] = $h;
    $parameters['dir'] = dirname($parameters['orig']);
    list($w, $h) = getimagesize($parameters['remote']);
    if ($max_height < $h || $max_width < $w) {
        if ($h > $w) {
            $w = $w * ($max_height / $h);
            $h = $max_height;
Example #11
0
 /**
  * Deletes an item from $data and rewrites the INI file.
  *
  * @param string
  * @return boolean
  */
 function delete($name)
 {
     unset($this->data[$name]);
     $r = file_overwrite($this->file, ini_write($this->data));
     if (!$r) {
         $this->error = 'Failed to write INI file!';
     }
     return $r;
 }
Example #12
0
        $val = false;
    }
    $w =& $form->createWidget($k, $v);
    if ($val) {
        $w->setValue($val);
    }
}
$sub =& $form->addWidget('msubmit', 'submit_button');
$b1 =& $sub->getButton();
$b1->setValues(intl_get('Save'));
$b2 =& $sub->addbutton('submit_button', intl_get('Cancel'));
$b2->extra = 'onclick="window.location.href = \'' . site_prefix() . '/index/usradm-applications-action\'; return false"';
if ($form->invalid($cgi)) {
    $form->setValues($cgi);
    echo $form->show();
} else {
    $vals = $form->getValues();
    foreach ($vals as $k => $v) {
        if ($k == 'appname' || $k == 'submit_button') {
            continue;
        }
        if (isset($v)) {
            $settings[$k]['value'] = $v;
        }
    }
    loader_import('saf.File');
    if (!file_overwrite(getcwd() . '/inc/app/' . $parameters['appname'] . '/conf/settings.ini.php', ini_write($settings))) {
        die('Error writing to file: inc/app/' . $parameters['appname'] . '/conf/settings.ini.php');
    }
    echo '<p>' . intl_get('Application settings saved.') . ' <a href="' . site_prefix() . '/index/usradm-applications-action">' . intl_get('Continue') . '</a></p>';
}
Example #13
0
             $data['body'] = '<p class="notice">SQL Error: ' . mysql_error() . '</p>';
             break;
         }
     }
     if (!$data['error']) {
         // save info to config.ini.php
         $conf = @join('', @file('../inc/conf/config.ini.php'));
         if ($cgi->dbhost != 'localhost' || $cgi->dbport != 3306) {
             $conf = preg_replace('/hostname[ \\t]*= localhost/', "hostname\t\t= \"" . $cgi->dbhost . ':' . $cgi->dbport . '"', $conf);
         }
         $conf = preg_replace('/database[ \\t]*= DBNAME/', "database\t\t= \"" . $cgi->database . '"', $conf);
         $conf = preg_replace('/username[ \\t]*= USER/', "username\t\t= \"" . $cgi->dbuser . '"', $conf);
         $conf = preg_replace('/password[ \\t]*= PASS/', "password\t\t= \"" . $cgi->dbpass . '"', $conf);
         $conf = preg_replace('/domain[ \\t]*= DOMAIN/', "domain\t\t\t= \"" . $_SERVER['HTTP_HOST'] . '"', $conf);
         loader_import('saf.File');
         if (!file_overwrite('../inc/conf/config.ini.php', $conf)) {
             $data['error'] = true;
             $data['body'] = '<p class="notice">Error: Unable to save configuration settings</p>';
         }
     }
     $data['step'] = 5;
     $data['next_step'] = 6;
     $data['title'] = 'Password';
     $data['next'] = 'Finish Up';
     if (empty($data['body'])) {
         $data['onclick'] = 'return validate (this.form)';
         $data['body'] = template_simple('password.spt', $data);
     }
     break;
 case 6:
     $conn = @mysql_connect($cgi->dbhost . ':' . $cgi->dbport, $cgi->dbuser, $cgi->dbpass);
Example #14
0
    $apps[$apps[$k]] = Workflow::getServices($k);
    unset($apps[$k]);
}
if (empty($cgi->submit_button)) {
    echo template_simple('workflow.spt', $apps);
} else {
    $services = array();
    foreach ($apps as $app) {
        foreach ($app as $service) {
            if ($parameters[$service['name']]) {
                foreach ($service['actions'] as $action) {
                    if (!is_array($services[$action])) {
                        $services[$action] = array();
                    }
                    $services[$action]['service:' . $service['name']] = array('name' => $service['title'], 'handler' => $service['handler']);
                }
            }
        }
    }
    loader_import('saf.File');
    loader_import('saf.File.Directory');
    foreach ($services as $action => $servs) {
        file_overwrite('inc/app/cms/conf/services/' . $action . '.php', ini_write($servs));
    }
    foreach (Dir::find('*.php', 'inc/app/cms/conf/services') as $file) {
        if (!isset($services[str_replace('.php', '', basename($file))])) {
            file_overwrite($file, ini_write(array()));
        }
    }
    echo '<p>' . intl_get('Workflow settings saved.') . '  <a href="' . site_prefix() . '/index/cms-cpanel-action">' . intl_get('Continue') . '</a></p>';
}
Example #15
0
    /**
     * Loads a series of objects that are dynamically generated from an INI file.
     * The INI file lives in the 'lib' folder of an app, and is named $pkg.ini.php.
     * If the 'lib' folder is writeable, a static copy of the generated code will
     * be saved to lib/_$pkg.php and be loaded next time.  The static copy is
     * automatically regenerated upon any change to the INI file or to this file
     * (Generic.php).
     *
     * The INI file defines which objects to make available, and the relations
     * between them.  For example, for a shopping cart you might define objects for
     * Product, Category, Option, and Order.  The relations might be that a Product
     * belongs to one or more Categories and Orders, and one or more Options belong
     * to a Product.
     *
     * The benefit of using this technique is that it provides convenience methods
     * for controlling the relationships between objects.  Specifically, for each
     * relation, the following three methods are defined (in both directions):
     *
     * - set{Object} (&$Object)
     * - unset{Object} (&$object)
     * - get{Object}s ()
     *
     * Where {Object} is the name of the related object.  So for a Product, you
     * would have setCategory, unsetCategory, getCategories, and so on.  For a
     * Category you would have setProduct, unsetProduct, and getProducts.  However,
     * for Options, since they belong to only one Product, the getProducts method
     * is actually named getProduct and returns just the one Product.
     *
     * Loading packages in this way is also seamlessly integrated into the Loader
     * class as well, simply call:
     *
     * loader_import ('myapp.Objects');
     *
     * And you will have generated and imported the objects defined in
     * inc/app/myapp/lib/Objects.ini.php just like that.
     *
     * The INI format is as follows:
     *
     * <code>
     * ; <?php /*
     *
     * [Product]
     *
     * table = myapp_product
     * pkey = id
     * ;permissions = on ; uncomment this if your table has the sitellte_* fields
     *
     * [Category]
     *
     * table = myapp_category
     * pkey = id
     *
     * [Option]
     *
     * table = myapp_option
     * pkey = id
     *
     * [rel:Product:Category]
     *
     * type = xx ; many-to-many
     * join_table = myapp_product_category
     * Product field = product_id
     * Category field = category_id
     *
     * [rel:Product:Option]
     *
     * type = 1x ; one-to-many
     * Option field = product_id
     * cascade = on ; delete options when product is deleted
     *
     * ; * / ? >
     * </code>
     *
     * Additional relationship types '11' (one-to-one) and 'tree' (via self-
     * referencing columns) are planned to be added in a future release.
     *
     * @access public
     * @param string
     * @param string
     * @return boolean
     */
    function load($app, $pkg)
    {
        $inifile = 'inc/app/' . $app . '/lib/' . $pkg . '.ini.php';
        $codefile = 'inc/app/' . $app . '/lib/_' . $pkg . '.php';
        if (@file_exists($codefile) && filemtime($codefile) >= filemtime($inifile) && filemtime($codefile) >= filemtime(__FILE__)) {
            include_once $codefile;
            return true;
        }
        $spt_header = '{filter none}{import}{end filter}class {class_name} extends {extends} {
	function {class_name} ($id = false) {
		parent::{extends} (\'{table}\', \'{pkey}\');
		{if obj[permissions]}$this->usePermissions = true;{end if}
		{if obj[multilingual]}$this->multilingual = true;{end if}

		if (is_array ($id)) {
			$newkey = $this->add ($id);
			if (is_numeric ($newkey)) {
				$this->setCurrent ($this->get ($newkey));
			} else {
				$this->setCurrent ($this->get ($id[\'{pkey}\']));
			}
		} elseif (is_object ($id)) {
			$this->setCurrent ($id);
		} elseif ($id) {
			$this->setCurrent ($this->get ($id));
		}

		// {class_name} cascade
	}
';
        $spt_xx = '

	function &set{class_two} (&$o) {
		if (is_subclass_of ($o, \'Generic\')) {
			$k = $o->pkey ();
		} else {
			$k = $o->{pkey_two};
		}
		if (! db_execute (
			\'insert into {join_table} ({field_one}, {field_two}) values (?, ?)\',
			$this->pkey (),
			$k
		)) {
			$this->error = db_error ();
			return false;
		}
		return $o;
	}

	function unset{class_two} (&$o) {
		if (is_subclass_of ($o, \'Generic\')) {
			$k = $o->pkey ();
		} else {
			$k = $o->{pkey_two};
		}
		if (! db_execute (
			\'delete from {join_table} where {field_one} = ? and {field_two} = ?\',
			$this->val (\'{pkey}\'),
			$k
		)) {
			$this->error = db_error ();
			return false;
		}
		return true;
	}

	function get{class_two_pleural} ($id = false) {
		if (! $id) {
			$id = $this->val (\'{pkey}\');
		} elseif (is_object ($id)) {
			$id = $id->{pkey};
		}

		return db_fetch_array (
			\'select b.*, j.* from {table} a, {join_table} j, {table_two} b
			where a.{pkey} = ? and a.{pkey} = j.{field_one} and b.{pkey_two} = j.{field_two}\',
			$id
		);
	}
';
        $spt_1x = '

	function &set{class_two} (&$o) {
		if (is_subclass_of ($o, \'Generic\')) {
			$k = $o->pkey ();
			$o->_current->{join_field} = $this->pkey ();
		} else {
			$k = $o->{pkey_two};
		}
		if (! db_execute (
			\'update {table_two} set {join_field} = ? where {pkey_two} = ?\',
			$this->pkey (),
			$k
		)) {
			$this->error = db_error ();
			return false;
		}
		return $o;
	}

	function unset{class_two} (&$o) {
		if (is_subclass_of ($o, \'Generic\')) {
			$k = $o->pkey ();
			$o->_current->{join_field} = 0;
		} else {
			$k = $o->{pkey_two};
		}
		if (! db_execute (
			\'update {table_two} set {join_field} = ? where {pkey_two} = ?\',
			0,
			$k
		)) {
			$this->error = db_error ();
			return false;
		}
		return true;
	}

	function get{class_two_pleural} ($id = false) {
		if (! $id) {
			$id = $this->val (\'{pkey}\');
		} elseif (is_object ($id)) {
			$id = $id->{pkey};
		}

		return db_fetch_array (
			\'select * from {table_two}
			where {join_field} = ?\',
			$id
		);
	}
';
        $spt_x1 = '

	function &set{class_two} (&$o) {
		if (is_subclass_of ($o, \'Generic\')) {
			$k = $o->pkey ();
		} else {
			$k = $o->{pkey_two};
		}
		if (! db_execute (
			\'update {table} set {join_field} = ? where {pkey} = ?\',
			$k,
			$this->pkey ()
		)) {
			$this->error = db_error ();
			return false;
		}
		$this->_current->{join_field} = $k;
		return $o;
	}

	function unset{class_two} (&$o) {
		if (is_subclass_of ($o, \'Generic\')) {
			$k = $o->pkey ();
		} else {
			$k = $o->{pkey_two};
		}
		if (! db_execute (
			\'update {table} set {join_field} = ? where {pkey} = ?\',
			0,
			$this->pkey ()
		)) {
			$this->error = db_error ();
			return false;
		}
		$this->_current->{join_field} = 0;
		return true;
	}

	function get{class_two} () {
		return db_single (
			\'select * from {table_two}
			where {pkey_two} = ?\',
			$this->val (\'{join_field}\')
		);
	}
';
        $spt_11 = '

	function &set{class_two} (&$o) {
	}

	function unset{class_two} (&$o) {
	}

	function get{class_two} ($id = false) {
	}
';
        // parse ini file, generate code file, save code file, load code file
        $block = ini_parse($inifile);
        if (!is_array($block)) {
            return false;
        }
        $rels = array();
        $objs = array();
        $code = OPEN_TAG . NEWLINEx2;
        foreach ($block as $name => $info) {
            if (strpos($name, 'rel:') === 0) {
                $rels[$name] = $info;
            } else {
                $objs[$name] = $info;
            }
        }
        foreach ($objs as $name => $info) {
            $info['class_name'] = $name;
            if (!isset($info['extends'])) {
                $info['extends'] = 'Generic';
            }
            if (isset($info['import'])) {
                $info['import'] = 'loader_import (\'' . $info['import'] . "');\n\n";
            } else {
                $info['import'] = '';
            }
            $info['cascade'] = '';
            $code .= template_simple($spt_header, $info);
            foreach ($rels as $k => $v) {
                list($tmp, $class_one, $class_two) = explode(':', $k);
                if ($name == $class_one) {
                    // add relationships to the current object declaration
                    if ($v['cascade']) {
                        $info['cascade'] .= '
		$this->_cascade[\'' . $class_two . '\'] = \'' . $v[$class_two . ' field'] . '\';';
                    } elseif ($v['type'] == 'xx') {
                        $info['cascade'] .= '
		$this->_cascade[] = array (\'' . $v['join_table'] . '\', \'' . $v[$class_one . ' field'] . '\');';
                    }
                    $v['class_one'] = $class_one;
                    $v['class_two'] = $class_two;
                    switch ($v['type']) {
                        case 'xx':
                            $v['class_one_pleural'] = str_replace('ys', 'ies', $class_one . 's');
                            $v['class_two_pleural'] = str_replace('ys', 'ies', $class_two . 's');
                            $v['class_one_pleural'] = preg_replace('/ss$/', 's', $v['class_one_pleural']);
                            $v['class_two_pleural'] = preg_replace('/ss$/', 's', $v['class_two_pleural']);
                            $v['class_one_pleural'] = preg_replace('/xs$/', 'xes', $v['class_one_pleural']);
                            $v['class_two_pleural'] = preg_replace('/xs$/', 'xes', $v['class_two_pleural']);
                            $v['table'] = $objs[$class_one]['table'];
                            $v['pkey'] = $objs[$class_one]['pkey'];
                            $v['table_two'] = $objs[$class_two]['table'];
                            $v['pkey_two'] = $objs[$class_two]['pkey'];
                            $v['field_one'] = $v[$class_one . ' field'];
                            $v['field_two'] = $v[$class_two . ' field'];
                            $code .= template_simple($spt_xx, $v);
                            break;
                        case '1x':
                            $v['class_two_pleural'] = str_replace('ys', 'ies', $class_two . 's');
                            $v['class_two_pleural'] = preg_replace('/ss$/', 's', $v['class_two_pleural']);
                            $v['class_two_pleural'] = preg_replace('/xs$/', 'xes', $v['class_two_pleural']);
                            $v['table'] = $objs[$class_one]['table'];
                            $v['pkey'] = $objs[$class_one]['pkey'];
                            $v['table_two'] = $objs[$class_two]['table'];
                            $v['pkey_two'] = $objs[$class_two]['pkey'];
                            $v['join_field'] = $v[$class_two . ' field'];
                            $code .= template_simple($spt_1x, $v);
                            break;
                        case '11':
                            /*$v['table'] = $objs[$class_one]['table'];
                            		$v['pkey'] = $objs[$class_one]['pkey'];
                            		$v['table_two'] = $objs[$class_two]['table'];
                            		$v['pkey_two'] = $objs[$class_two]['pkey'];
                            		$v['join_field'] = $v[$class_two . ' field'];
                            		$code .= template_simple ($spt_11, $v);*/
                            break;
                        case 'tree':
                            break;
                        default:
                            die('Invalid relationship type in ' . $inifile);
                    }
                } elseif ($name == $class_two) {
                    // add relationships to the current object declaration
                    $tmp = $class_one;
                    $class_one = $class_two;
                    $class_two = $tmp;
                    $v['class_one'] = $class_one;
                    $v['class_two'] = $class_two;
                    switch ($v['type']) {
                        case 'xx':
                            $v['class_one_pleural'] = str_replace('ys', 'ies', $class_one . 's');
                            $v['class_two_pleural'] = str_replace('ys', 'ies', $class_two . 's');
                            $v['class_one_pleural'] = preg_replace('/ss$/', 's', $v['class_one_pleural']);
                            $v['class_two_pleural'] = preg_replace('/ss$/', 's', $v['class_two_pleural']);
                            $v['class_one_pleural'] = preg_replace('/xs$/', 'xes', $v['class_one_pleural']);
                            $v['class_two_pleural'] = preg_replace('/xs$/', 'xes', $v['class_two_pleural']);
                            $v['table'] = $objs[$class_one]['table'];
                            $v['pkey'] = $objs[$class_one]['pkey'];
                            $v['table_two'] = $objs[$class_two]['table'];
                            $v['pkey_two'] = $objs[$class_two]['pkey'];
                            $v['field_one'] = $v[$class_one . ' field'];
                            $v['field_two'] = $v[$class_two . ' field'];
                            $code .= template_simple($spt_xx, $v);
                            break;
                        case '1x':
                            $v['table'] = $objs[$class_one]['table'];
                            $v['pkey'] = $objs[$class_one]['pkey'];
                            $v['table_two'] = $objs[$class_two]['table'];
                            $v['pkey_two'] = $objs[$class_two]['pkey'];
                            $v['join_field'] = $v[$class_one . ' field'];
                            $code .= template_simple($spt_x1, $v);
                            break;
                        case '11':
                            /*$v['table'] = $objs[$class_one]['table'];
                            		$v['pkey'] = $objs[$class_one]['pkey'];
                            		$v['table_two'] = $objs[$class_two]['table'];
                            		$v['pkey_two'] = $objs[$class_two]['pkey'];
                            		$v['join_field'] = $v[$class_two . ' field'];
                            		$code .= template_simple ($spt_11, $v);*/
                            break;
                        case 'tree':
                            break;
                        default:
                            die('Invalid relationship type in ' . $inifile);
                    }
                }
            }
            if (!empty($info['cascade'])) {
                $code = str_replace("\t\t// " . $info['class_name'] . ' cascade', $info['cascade'], $code);
            }
            $code .= '}' . NEWLINEx2;
        }
        $code .= CLOSE_TAG;
        if (!@file_exists($codefile) && is_writeable(dirname($codefile)) || @is_writeable($codefile)) {
            loader_import('saf.File');
            file_overwrite($codefile, $code);
            umask(00);
            @chmod($codefile, 0777);
            include_once $codefile;
            return true;
        } else {
            eval(CLOSE_TAG . $code);
            return true;
        }
    }
Example #16
0
}
if (!@is_dir($read)) {
    die('No app folder found.');
}
if (!@is_dir($langs)) {
    $r = mkdir($langs, 0777);
    if (!$r) {
        die('No lang folder found.  Attempt to create failed.');
    }
}
if (!@is_writeable($langs)) {
    die('Cannot write to langs folder.  Please change your filesystem permissions.');
}
if (!@file_exists($list)) {
    loader_import('saf.File');
    $r = file_overwrite($list, ini_write(array()));
    if (!$r) {
        die('No lang/languages.php file found.  Attempt to create failed.');
    }
}
if (!@file_exists($write)) {
    $info = pathinfo($write);
    if (!@is_writeable($info['dirname'])) {
        die('Cannot write to lang folder.  Please change your filesystem permissions.');
    }
} else {
    if (!@is_writeable($write)) {
        die('Cannot write to lang/en.php file.  Please change your filesystem permissions.');
    }
}
$fullname = $info['app_name'];
Example #17
0
function make_set($set_name)
{
    if (!@is_writable('inc/html')) {
        $data['err'] = 'The template folder is not writable, please contact the site admin.';
    } else {
        umask(00);
        mkdir('inc/html/' . $set_name, 0777);
        mkdir('inc/html/' . $set_name . '/pix', 0777);
        //variables for all files written to
        $html_default_tpl;
        $site_css;
        $config_ini_php;
        $modes_php;
        //populate the variables
        $html_default_tpl = <<<END
<xt:tpl version="1.0"><xt:doctype
\troot="html"
\taccess="public"
\tname="-//W3C//DTD XHTML 1.0 Transitional//EN"
\turi="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
\t<title xt:content="string: Site Name - \${head_title}">Site Name</title>

\t<!-- note the space-slash (' /') at the end of the following tag.  this
\t     tells the XML parser that this tag doesn't have a matching closing
\t     tag.  this syntax is required to make your templates XHTML and XT
\t     compatible -->
\t<link rel="stylesheet" type="text/css" href="\${site/prefix}/inc/html/{$set_name}/site.css" />

</head>
<body><a name="top"> </a>

<!-- wrapper -->
<div id="wrapper">

<!-- header -->
<div id="header">

\t<h1>Site Name</h1>

</div>

<!-- the default navigation boxes are in the inc/app/sitellite/boxes/nav folder -->
<div id="breadcrumb">
\t<xt:box name="sitellite/nav/breadcrumb">
\t\t<p><a href="#">Home</a> / <a href="#">About Us</a> / Fake Page</p>
\t</xt:box>
</div>

<table id="columns">
<tr>

<!-- left column -->
<td id="left">

\t<!-- the sidebar box places a column of sidebars at this location.
\t     note that you can put sample data between the xt:box tags to
\t     make your templates previewable directly in the web browser,
\t     or even in editors like Dreamweaver and Golive -->
\t<xt:box name="sitellite/sidebar" position="left">
\t\t<h1>Fake Menu</h1>
\t\t<ul>
\t\t\t<li><a href="#">About Us</a></li>
\t\t\t<li><a href="#">Services</a></li>
\t\t\t<li><a href="#">Support</a></li>
\t\t\t<li><a href="#">Contact Us</a></li>
\t\t</ul>
\t</xt:box>

</td>

<!-- centre column -->
<td id="centre">

\t<!-- this box inclusion embeds the page editing buttons into your pages -->
\t<xt:box name="cms/buttons" />

\t<!-- display the page title, if there is one -->
\t<h1
\t\txt:content="title"
\t\txt:condition="php: not empty (object.title)">Fake Page</h1>

\t<!-- replace this span tag with the page body contents -->
\t<span xt:replace="body">
\t\t<p></p>
\t</span>

\t<!-- the xt:intl tag marks its contents as translateable text -->
\t<p align="right">
\t\t<a href="#top"><xt:intl>Return to Top</xt:intl></a>
\t</p>

</td>

<!-- right column -->
<td id="right">

\t<xt:box name="sitellite/sidebar" position="right">
\t\t<h1>Right Column</h1>
\t\t<p>
\t\t\tThis is a sample sidebar element.  It will be replaced with
\t\t\tactual content when the template is rendered by Sitellite.
\t\t</p>
\t</xt:box>

</td>

</tr>
</table>

<!-- footer -->
<div id="footer">

\t<p>
\t\t<xt:intl>Copyright</xt:intl>

\t\t<!-- the ch: tags replace HTML entities such as 'nbsp' and 'copy',
\t\t     since XT templates are XML documents which don't know about
\t\t     HTML's special entities -->
\t\t<ch:copy />

\t\t<!-- you can include basic PHP statements in your templates via the
\t\t     following syntax -->
\t\t<span xt:replace="php: date ('Y')">2004</span>

\t\tSite Name.<br />
\t\t<xt:intl>All rights reserved.</xt:intl><br />
\t\t<a href="http://www.sitellite.org/" target="_blank"><xt:intl>Powered by Sitellite CMS</xt:intl></a>
\t</p>

</div>

</div>

</body>
</html>
</xt:tpl>
END;
        $site_css = <<<END
xt\\:comment, xt\\:note {
\tdisplay: none;
}

ch\\:nbsp {
\tpadding: .5em;
}

body {
\tbackground-color: #fff;
\tcolor: #444;
\tfont: 12px Verdana, Helvetica, Arial, sans-serif;
\tmargin: 0px;
\tpadding: 0px;
}

td {
\tcolor: #444;
\tfont: 12px Verdana, Helvetica, Arial, sans-serif;
}

#wrapper {
\tmargin: 10px;
\tpadding: 10px;
\twidth: 800px;
}

#header {
\theight: 47px;
\tpadding: 10px;
\tpadding-bottom: 0px;
\tmargin: 0px;
\tbackground-color: #a00;
}

#header h1 {
\tfont-variant: small-caps;
\tfont-size: 28px;
\tcolor: #fff;
}

#breadcrumb {
\theight: 20px;
}

#columns {
\tborder: 0px none;
}

#left {
\twidth: 160px;
\tpadding-right: 5px;
\tvertical-align: top;
}

#centre {
\tpadding-left: 5px;
\tpadding-right: 5px;
\tborder-left: 1px solid #aaa;
\tborder-right: 1px solid #aaa;
\tvertical-align: top;
}

#right {
\twidth: 170px;
\tpadding-left: 5px;
\tvertical-align: top;
}

#footer {
\tclear: both;
\tmargin-top: 5px;
\tborder-top: 1px solid #aaa;
}

a {
\tcolor: #a00;
\ttext-decoration: none;
}

a:hover {
\ttext-decoration: underline;
}

h1 {
\tfont-size: 18px;
}

h2 {
\tfont-size: 14px;
}

h3 {
\tfont-weight: normal;
}

span.highlighted {
\tbackground-color: #ff0;
\tpadding: 2px;
\tpadding-bottom: 0px;
}
END;
        $config_ini_php = <<<END
; <?php /* DO NOT ALTER THIS LINE, IT IS HERE FOR SECURITY REASONS

; This is your template set config file.  Most fields are optional, and those
; that are not so self explanatory have a comment above them.

; Only set_name among all these is actually required, but all are recommended.
set_name\t\t= {$set_name}
description\t\t= About {$set_name} ...
author\t\t\t= Me
copyright\t\t= "Copyright (C) 2004, Me Inc."
license\t\t\t= "http://www.opensource.org/licenses/index.php#PICK ONE!!!"
version\t\t\t= "0.1 alpha"

; DO NOT ALTER THIS LINE, IT IS HERE FOR SECURITY REASONS */ ?>
END;
        $modes_php = <<<END
; <?php /*

[html]

content_type\t= text/html
filter 1\t\t= "body: saf.Misc.Search"
;filter 2\t\t= "body: siteglossary.Terms"

; */ ?>
END;
        //write the files
        file_overwrite('inc/html/' . $set_name . '/html.default.tpl', $html_default_tpl);
        file_overwrite('inc/html/' . $set_name . '/site.css', $site_css);
        file_overwrite('inc/html/' . $set_name . '/config.ini.php', $config_ini_php);
        file_overwrite('inc/html/' . $set_name . '/modes.php', $modes_php);
    }
}
Example #18
0
 function onSubmit($vals)
 {
     loader_import('saf.File');
     foreach ($vals['taxes'] as $k => $v) {
         $vals['taxes'][$k] = $v / 100;
     }
     $vals['currencies'] = preg_split('/, ?/', $vals['currencies']);
     file_overwrite('inc/app/siteinvoice/conf/properties.old.php', join('', file('inc/app/siteinvoice/conf/properties.php')));
     file_overwrite('inc/app/siteinvoice/conf/properties.php', template_simple($this->_template, $vals));
     umask(00);
     @chmod('inc/app/siteinvoice/conf/properties.old.php', 0777);
     @chmod('inc/app/siteinvoice/conf/properties.php', 0777);
     page_title('SiteInvoice - Settings Saved');
     echo '<p><a href="' . site_prefix() . '/index/siteinvoice-app">Continue</a></p>';
 }