/**
  * Constructor
  * 
  * @param string $module your module-name
  * @param array $subs the sub-module names that are possible
  * @param string $default the default sub-module
  */
 public function __construct($module, $subs = array(), $default = 'default')
 {
     $input = FWS_Props::get()->input();
     if (count($subs) == 0) {
         FWS_Helper::error('Please provide the possible submodules of this module!');
     }
     $sub = $input->correct_var('sub', 'get', FWS_Input::STRING, $subs, $default);
     // include the sub-module and create it
     include_once FWS_Path::server_app() . 'module/' . $module . '/sub_' . $sub . '.php';
     $classname = 'PC_SubModule_' . $module . '_' . $sub;
     $this->sub = new $classname();
 }
Exemplo n.º 2
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $ap = $this->get_action_performer();
     $ap->set_prefix('PC_Action_');
     $ap->set_mod_folder('module/');
     $tpl = FWS_Props::get()->tpl();
     $tpl->set_path('templates/');
     $tpl->set_cache_folder(FWS_Path::server_app() . 'cache/');
     // add the home-breadcrumb
     $url = new FWS_URL();
     $url->set('action', 'home');
     $this->add_breadcrumb('PHP-Check', $url->to_url());
 }
Exemplo n.º 3
0
/**
 * The autoloader for the todolist src-files
 * 
 * @param string $item the item to load
 * @return boolean wether the file has been loaded
 */
function TDL_autoloader($item)
{
    if (FWS_String::starts_with($item, 'TDL_')) {
        $item = FWS_String::substr($item, 4);
        $item = str_replace('_', '/', $item);
        $item = FWS_String::strtolower($item);
        $item .= '.php';
        $path = FWS_Path::server_app() . 'src/' . $item;
        if (is_file($path)) {
            include $path;
            return true;
        }
    }
    return false;
}
Exemplo n.º 4
0
 /**
  * @return FWS_DB_Connection the property
  */
 protected function db()
 {
     include_once FWS_Path::server_app() . 'config/mysql.php';
     $c = new FWS_DB_MySQLi_Connection();
     $c->connect(PC_MYSQL_HOST, PC_MYSQL_LOGIN, PC_MYSQL_PASSWORD);
     $c->select_database(PC_MYSQL_DATABASE);
     $c->set_save_queries(false);
     $c->set_escape_values(true);
     $version = $c->get_server_version();
     if ($version >= '4.1') {
         $c->execute('SET CHARACTER SET utf8;');
         // we don't want to have any sql-modes
         $c->execute('SET SESSION sql_mode="";');
     }
     return $c;
 }
Exemplo n.º 5
0
/**
 * The autoloader for the phpcheck src-files
 * 
 * @param string $item the item to load
 * @return boolean whether the file has been loaded
 */
function PC_autoloader($item)
{
    if (FWS_String::starts_with($item, 'PC_')) {
        $nitem = substr($item, 3);
        $parts = explode('_', $nitem);
        if (!FWS_String::starts_with($item, 'PC_Module_')) {
            array_unshift($parts, 'src');
        }
        $nitem = implode('/', $parts);
        $nitem = str_replace('_', '/', $nitem);
        $nitem = strtolower($nitem);
        $nitem .= '.php';
        $path = FWS_Path::server_app() . $nitem;
        if (is_file($path)) {
            include $path;
            return true;
        }
    }
    return false;
}
Exemplo n.º 6
0
 /**
  * @see FWS_Document_Renderer_HTML_Default::before_render()
  */
 protected final function before_render()
 {
     $tpl = FWS_Props::get()->tpl();
     $msgs = FWS_Props::get()->msgs();
     $locale = FWS_Props::get()->locale();
     $doc = FWS_Props::get()->doc();
     $user = FWS_Props::get()->user();
     // add redirect information
     $redirect = $doc->get_redirect();
     if ($redirect) {
         $tpl->add_variable_ref('redirect', $redirect, 'inc_header.htm');
     }
     // notify the template if an error has occurred
     $tpl->add_global('module_error', !$this->has_access() || $doc->get_module()->error_occurred());
     if (!$this->has_access()) {
         $msgs->add_error($locale->_('You don\'t have access to this module!'));
     }
     // add global variables
     $action_result = $this->get_action_result();
     $tpl->add_global('action_result', $action_result);
     $tpl->add_global('path', FWS_Path::client_app());
     $tpl->add_global('fwspath', FWS_Path::client_fw());
     // add objects
     $js = FWS_Javascript::get_instance();
     $js->set_cache_folder('cache/');
     $js->set_shrink(false);
     $tpl->add_global_ref('js', $js);
     $url = new TDL_URL();
     $tpl->add_global_ref('url', $url);
     $tpl->add_global_ref('locale', $locale);
     $tpl->add_global_ref('user', $user);
     // set callable methods
     $tpl->add_allowed_method('url', 'simple_url');
     $tpl->add_allowed_method('js', 'get_file');
     $tpl->add_allowed_method('locale', '*');
     $tpl->add_allowed_method('user', 'get_theme_item_path');
     // add messages
     if ($msgs->contains_msg()) {
         $this->_handle_msgs($msgs);
     }
 }
Exemplo n.º 7
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
include_once 'config/userdef.php';
include_once 'config/mysql.php';
// define fwspath for init.php
define('FWS_PATH', TDL_FWS_PATH);
// init the framework
include_once TDL_FWS_PATH . 'init.php';
// the db is latin1
FWS_String::set_use_mb_functions(true, 'ISO-8859-1');
include_once FWS_Path::server_app() . 'src/props.php';
// init the autoloader
include_once FWS_Path::server_app() . 'src/autoloader.php';
FWS_AutoLoader::register_loader('TDL_autoloader');
// set the accessor and loader for the todolist
$accessor = new TDL_PropAccessor();
$accessor->set_loader(new TDL_PropLoader());
FWS_Props::set_accessor($accessor);
// init user
$user = FWS_Props::get()->user();
$user->init();
// ok, now show the page
$doc = FWS_Props::get()->doc();
echo $doc->render();