Changes between Version 18 and Version 19 of DolphinTutorialMyFirstModule


Ignore:
Timestamp:
Nov 4, 2010, 12:53:57 AM (13 years ago)
Author:
AlexT
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DolphinTutorialMyFirstModule

    v18 v19  
    305305The '''pageCodeAdmin''' function is similar to the  '''pageCode''' function, but it displays the admin page instead of the user page. Also, this function accepts only one parameter - page title. 
    306306 
    307 Also the difference in the code is that we check if admin only can access this page. The '''$GLOBALS!['logged']!['admin']''' variable is set to true if admin is logged in. Additionally, you can check if regular members are logged in by using the '''$GLOBALS['logged']['member']''' variable. If none of these values are true, then a guest is accessing your page. The '''displayAccessDenied''' function displays a page with an "access denied" message - in this case, we don't need to care much about that, and we can just return from the function or even exit. The '''$GLOBALS['logged']''' does not always exist, and is initialized in the '''check_logged''' function. In our case this function is called in the '''bloggie/request.php''' file. 
    308  
    309 Another new function here is '''DesignBoxAdmin'''. It wraps our content in a nice box. The box title is the first parameter and box content is the second one. There is an optional 3rd parameter where you can define the box menu. Also, there is an analog of this function in the user side called '''DesignBoxContent'''. You can examine existing Dolphin code for a lot of examples. 
     307Also the difference in the code is that we check if admin only can access this page. The '''$GLOBALS!['logged']!['admin']''' variable is set to true if admin is logged in. Additionally, you can check if regular members are logged in by using the '''$GLOBALS!['logged']!['member']''' variable. If none of these values are true, then a guest is accessing your page. The '''displayAccessDenied''' function displays a page with an "access denied" message - in this case, we don't need to care much about that, and we can just return from the function or even exit. The '''$GLOBALS!['logged']''' does not always exist, and is initialized in the '''check_logged''' function. In our case this function is called in the '''bloggie/request.php''' file. 
     308 
     309Another new function here is '''!DesignBoxAdmin'''. It wraps our content in a nice box. The box title is the first parameter and box content is the second one. There is an optional 3rd parameter where you can define the box menu. Also, there is an analog of this function in the user side called '''!DesignBoxContent'''. You can examine existing Dolphin code for a lot of examples. 
    310310 
    311311To test the page, you need to login to the admin panel and open the '''http://www.your-site.com/your-path/m/bloggie/administration''' URL. 
     
    467467Clarification: 
    468468 
    469     * the '''getSettingsCategory''' method is placed into '''MeBlggDb''' since all database queries must be in this file. 
     469    * the '''getSettingsCategory''' method is placed into '''!MeBlggDb''' since all database queries must be in this file. 
    470470    * the '''getOne''' method returns the value of '''ID''' field in the '''SELECT''' SQL query. There are other handy functions to get the data from database. Refer to '''inc/classes/BxDolDb.php''' for complete list. 
    471     * '''_oDb''' is automatically defined in the '''MeBlggDb''' class 
    472     * the '''MsgBox''' function wraps text in a nice message box 
    473     * the '''bx_import''' function automatically imports a class by its name, and it can load classes with '''BxDol''', '''BxBase''', '''BxTempl''' prefixes if they are correctly named and located. Also, it can load module classes if the module config is passed as the second parameter. 
    474     * the '''BxDolAdminSettings''' class is used to display and save settings. Just use it as shown above. Make a note that the '''saveSettings''' function returns a result message which we append at the beginning of the result string. 
     471    * '''_oDb''' is automatically defined in the '''!MeBlggDb''' class 
     472    * the '''!MsgBox''' function wraps text in a nice message box 
     473    * the '''bx_import''' function automatically imports a class by its name, and it can load classes with '''!BxDol''', '''!BxBase''', '''!BxTempl''' prefixes if they are correctly named and located. Also, it can load module classes if the module config is passed as the second parameter. 
     474    * the '''!BxDolAdminSettings''' class is used to display and save settings. Just use it as shown above. Make a note that the '''saveSettings''' function returns a result message which we append at the beginning of the result string. 
    475475 
    476476 
     
    599599== 4.2. Creating the add post page. == 
    600600 
    601 Add the following method to the '''MeBlggModule''' class: 
     601Add the following method to the '''!MeBlggModule''' class: 
    602602 
    603603{{{ 
     
    643643}}} 
    644644 
    645 then modify the '''MeBlggModule''' class constructor the following way: 
     645then modify the '''!MeBlggModule''' class constructor the following way: 
    646646 
    647647{{{ 
     
    734734              * '''error''' is the message to display near the field if checking failed. 
    735735       * db describes the database field to save input data to. The most important is the following parameter: 
    736               * '''pass''' is the function to pass data through, it validates data properly - to not allow an inappropriate value in a particular field. The value of this field may be '''Xss''', '''XssHtml''', '''Int''', '''Float''', '''Date''', etc. 
     736              * '''pass''' is the function to pass data through, it validates data properly - to not allow an inappropriate value in a particular field. The value of this field may be '''Xss''', '''!XssHtml''', '''Int''', '''Float''', '''Date''', etc. 
    737737 
    738738This doesn't describe all the possible values of this array. For a complete list please refer to the '''inc/classes/BxDolForm.php''' file. 
    739739 
    740 Let's come back to the '''actionAdd''' function. First, we check that only members and admins can add blog posts. We have already described the '''$GLOBALS['logged']''' array. Then '''pageStart''' tells us that output will be below. Then, we import the '''BxTemplFormView''' class and create a class instance by passing the form description array to the class constructor. '''initChecker''' initializes the checker function. It is needed if the form was submitted with wrong values. Then, if the form was not submitted or it has invalid data the the form will be displayed ('''getCode''' function is called). Otherwise we will save the submitted data by calling the '''insert''' form function. Before saving, we added additional database fields, and after successful saving we are redirected to the post view page (which we will create in the next step). This page displays when we call the '''pageCode''' function. 
     740Let's come back to the '''actionAdd''' function. First, we check that only members and admins can add blog posts. We have already described the '''$GLOBALS!['logged']''' array. Then '''pageStart''' tells us that output will be below. Then, we import the '''!BxTemplFormView''' class and create a class instance by passing the form description array to the class constructor. '''initChecker''' initializes the checker function. It is needed if the form was submitted with wrong values. Then, if the form was not submitted or it has invalid data the the form will be displayed ('''getCode''' function is called). Otherwise we will save the submitted data by calling the '''insert''' form function. Before saving, we added additional database fields, and after successful saving we are redirected to the post view page (which we will create in the next step). This page displays when we call the '''pageCode''' function. 
    741741 
    742742You can already try the form functionality, and see in the database if the data was saved. Let's proceed to the blog view page, to be able to view submitted data in a user friendly manner. 
     
    745745== 4.3. View Bloggie post page. == 
    746746 
    747 Add the following function to the '''MeBlggModule''' class: 
     747Add the following function to the '''!MeBlggModule''' class: 
    748748 
    749749 
     
    779779    * '''getEntryById''' is the database function which is created below. 
    780780 
    781 Add the following method to the '''MeBlggDb''' class: 
     781Add the following method to the '''!MeBlggDb''' class: 
    782782 
    783783{{{ 
     
    859859== 4.5. Edit the post page. == 
    860860 
    861 Add the following method to the '''MeBlggModule''' class: 
     861Add the following method to the '''!MeBlggModule''' class: 
    862862 
    863863{{{ 
     
    977977    * [http://www.boonex.com/trac/dolphin/roadmap BoonEx Tickets System] - check the current Dolphin development stage or get latest source code. 
    978978    * [http://www.boonex.com/trac/dolphin/wiki/Dolphin7Docs BoonEx Wiki] - Dolphin documentation. 
    979     * [http://www.boonex.com/agents/ BoonEx Agents] - get support from your personal BoonEx agent 
     979    * [http://www.boonex.com/agents/ BoonEx Agents] - get support from your personal !BoonEx agent 
    980980 
    981981 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
Fork me on GitHub