How to create an info file to the module?

There is $inc object that allows you to store information about modules. Module information system can move as follows.

Code in fw_modules/mymodule/info_mymodule.php

<?php
//-------your module group name------------//
$modname='mymodule';
//-------group information-----------------//
$inc->lib['group_'.$modname]['name']=$modname;
$inc->lib['group_'.$modname]['version']=1.3;
$inc->lib['group_'.$modname]['author']='Bc. Peter Horváth';
$inc->lib['group_'.$modname]['email']='info[at]opensencillo[dot]com';
$inc->lib['group_'.$modname]['license']='GNU/GPL';
$inc->lib['group_'.$modname]['homepage']='www.mymodule.com';
$inc->lib['group_'.$modname]['integrity']='966x1$b9u7qga4401hu7';
$inc->lib['group_'.$modname]['your_own_key']='my own info';
//-------your module group function--------//
$inc->lib['function'][]='test function';
$inc->lib['function'][]='smile function';
$inc->lib['function'][]='good function';
?>

This saves the information about the module to RAM during execution of the script.
Information will be publicly available throughout the system.

Facebooktwitterredditpinterestlinkedinmail

Creating basic module

PHP code needs to be divided into multiple parts? Use OpenSencillo modules. You can then create logical units separate from the source code yourcode.php.

Obrazovka z 2015-01-28 19:41:35

  1. Open folder fw_modules.
  2. Create folders that will have the name of your module (for example: mymodule). At least one file in the folder must contain the name.
  3. Open folder mymodule and create info_mymodule.php, install_mymodule.php and main_mymodule.php. If you not use prefix, lib_identificator.php bootup module as basic code without installer.
  4. Add to info_mymodule.php simple information about module.
  5. Enter code to install_mymodule.php to install the module database tables, and other code needed for installation.
  6. Use main_mymodule.php to insert any code that need to be separated. Code shall be made for the introduction OpenSencillo.

Question: When OpenSencillo connect the module?
Ask: Before loading yourcode.php.

Question: Can I move code from yourcode.php into modules?
Ask: Yes, of course.

Facebooktwitterredditpinterestlinkedinmail

MySQL in OpenSencillo – Connecting and create new table

We have four classes for SQL in three layers:

MySQL classes diagram

  • mysql – Main SQL class with minimal servicing database (manual SQL query and testing only)
  • mysqlEdit – Extension for class mysql (useful for generating simple SQL queries)
  • logMan – Extension for class mysqlEdit (useful for login and user management)
  • mysqlInterface – Extension for class mysqlEdit (best way for create and management custom tables)

mysqlInterface PHP OpenSencillo example:

<?php
//yourcode.php
//call class mysqlInterface
$mysql = new mysqlInterface($DBHost,$DBName,$DBUser,$DBPass);
//prepare table structure
$newTable = array('hostCtr'=>array(
    'id'=>array('type'=>'int','auto_increment'=>true,'primary_key'=>true),
    'ip'=>array('type'=>'varchar(15)','unique_key'=>true),
    'datetime'=>array('type'=>'datetime'))
);

//create shadow configuration and open connection to OpenSencillo database
$mysql->config();
$mysql->connect();
//add new table
$mysql->dbCreateTable($newTable);
//collected all queries from the last execute and send queries to SQL server
$mysql->execute();
echo "SQL changes saved!";
?>

Output to SQL:
New table: hostCtr
Structure of new table:

  • id – int, auto_increment, primary_key
  • ip – varchar(15), unique_key
  • datetime – datetime

Now you can save your own data. Continue like this:

<?php
//continue yourcode.php
//assign data structure
$newInsert = array('hostCtr'=>array(
    'id'=>"''",
    'ip'=>"'".$_SERVER['REMOTE_ADDR']."'",
    'datetime'=>"'".date('Y-m-d H:i:s')."'")
);
//add structure and data to SQL generator
$mysql->insert($newInsert);
//execute generated queries
$mysql->execute();
?>

Now you save new id, new unique ip with date and time.

Facebooktwitterredditpinterestlinkedinmail

OpenSencillo file system

File system after OpenSencillo installation.

OpenSencillo 2015.003 file system

System folders:

  • fw_cache – folder for OpenSencillo Cache or QuickCache subsystem
  • fw_core – OpenSencillo and LightWeight Sencillo main core
  • fw_doxygen – doxygen configuration for create docs
  • fw_headers – config and core modules layer (if you want find core modules and system configuration)
  • fw_libraries – system libraries for standard OpenSencillo PHP classes
  • fw_modules – destination for custom modules. If you write new module, save it here.
  • fw_templates – destination for all templates

System files:

  • .htaccess – special file for configuration your hosting
  • firststart.json – information about first start your OpenSencillo installation
  • ajax.slot.php – file for obtaining and sending AJAX request
  • basicstrap.php – basic requires for bootup OpenSencillo before your PHP code
  • cache.php – usable if cache is Allowed
  • index.php – introducing OpenSencillo basicstrap
  • yourcode.php – if you write main code for your webpage, save it here. It is most important file for all your projects.
Facebooktwitterredditpinterestlinkedinmail

OpenSencillo simple debug

You can add pretty debug. This tool not work correct if your server using PHP xdebug module.

  1. Open yourcode.php to edit your new webpage.
  2. Add code:
    <?php
      $seo=new headerSeo;
      $seo->encode();
      $seo->robots();
      echo $seo->save();
    ?>
    <body>
    <?php
      $var=array('my first debug','my second debug',null,123); //debuging variable
      log::vd($var); //Print pretty var_dump equivalent
    ?>
    </body>
    </html>
    
  3. Save yourcode.php and open your example.com first page where is installed OpenSencillo.
  4. Check example.com with your first pretty debug.
Facebooktwitterredditpinterestlinkedinmail

OpenSencillo add subpages

You can add your first subpage with custom URL.

  1. Find file yourcode.php.
  2. Open yourcode.php to edit your new webpage.
  3. Add code:
    <?php
      $seo=new headerSeo; //add minimal seo and create opening HTML tag
      $seo->encode(); //add page encoding to UTF-8
      $seo->robots(); //add support for bots control
      echo $seo->save(); //generate meta tags
    ?>
    <body>
    <?php
      switch(PAGE)
      {
        //create new subpage by case
        case 'my-first-subpage':
        case '/my-first-subpage':
          echo 'HELLO SUBPAGE';
        break;
        //create homepage / landing page
        case '':
        case '/':
          echo 'HELLO WORLD';
        break;
        //create custom 404 page
        default:
          echo 'MY 404 PAGE';
      }
    ?>
    </body>
    </html>
    
  4. Save yourcode.php and open your example.com first page where is installed OpenSencillo.
  5. Check example.com/my-first-subpage new subpage with pretty URL.
Facebooktwitterredditpinterestlinkedinmail

OpenSencillo hello world webpage

After installation you can write your first webpage.

  1. Find file yourcode.php.
  2. Open yourcode.php to edit your new webpage.
  3. Add code:
    <?php
      $seo=new headerSeo; //add minimal seo and add opening HTML tag
      $seo->encode(); //add page encoding to UTF-8
      $seo->robots(); //add support for bots control
      echo $seo->save(); //generate meta tags
    ?>
    
    <body>
      HELLO WORLD
    </body>
    </html>
    
  4. Save yourcode.php and open your example.com first page where is installed OpenSencillo.
Facebooktwitterredditpinterestlinkedinmail

Installation 2015.001, 2015.002

  1. Download Sencillo.
  2. Upload sencillo to the root directory on your server.
  3. Go to www.example.com/fw_core/core_installer.php and show you install guide as in the picture:
    img-step1
  4. Fill in all fields and set Cache value to Disallow for programming without cache.img-step2
  5. Now click on the Install
Facebooktwitterredditpinterestlinkedinmail