Smarty
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file resource.userdb.php

Documentation is available at resource.userdb.php

  1. <?php 
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8. /** 
  9. * Smarty plugin
  10. * -------------------------------------------------------------
  11. * Type:     resource
  12. * Name:     userdb
  13. * Purpose:  read user maintained source as a template
  14. *           $tpl_name is parsed as a uri type of string where
  15. *          the path to the template field is encoded as:
  16. * table/source_field?field=condtional&field=conditional...
  17. * results in:
  18. *    SELECT source_field FROM table WHERE conditions...
  19. * -------------------------------------------------------------
  20. */ 
  21. function smarty_resource_userdb_fetch($tpl_name&$tpl_source&$smarty$default=false
  22.     $_url parse_url($tpl_name)
  23.     
  24.     // (required) expected syntax: table/source_field 
  25.     $_path_items explode('/'$_url['path'])
  26.     $table $_path_items[0]
  27.     $source $_path_items[1]
  28.  
  29.     // Theme Configuration
  30.     $skinid pnModAPIFunc('Xanthia','user','getSkinID',
  31.                                 array('skin' => $table));
  32.  
  33.     $dbconn =pnDBGetConn(true);
  34.     $pntable =pnDBGetTables();
  35.  
  36.     $table $pntable['theme_tplsource'];
  37.     $column &$pntable['theme_tplsource_column'];
  38.     $query "SELECT $column[tpl_source]
  39.                     FROM $table
  40.                     WHERE $column[tpl_file_name]='$source'
  41.                     AND $column[tpl_skin_id]= '$skinid' LIMIT 1";
  42.     $result =$dbconn->Execute($query);        
  43.  
  44.     if ($result->EOF{
  45.     else {
  46.         list($tpl_source$result->fields;
  47.     }
  48.     $result->MoveNext();
  49.     $result->Close();
  50.     if ($tpl_source
  51.         return true
  52.     else 
  53.         return $default
  54.     
  55.  
  56. function smarty_resource_userdb_source($tpl_name&$tpl_source&$smarty
  57.     if (smarty_resource_userdb_fetch($tpl_name$tpl_source$smarty)) 
  58.         $tpl_source stripslashes($tpl_source)
  59.         return true
  60.     }  
  61.     return false
  62. }  
  63.  
  64. /** 
  65. * -------------------------------------------------------------
  66. * pass current time back to smarty.
  67. * no need to make sql query since template will be updated in the database
  68. * and local compiled template will be deleted automatically
  69. * forcing smarty to reload template again form database
  70. * -------------------------------------------------------------
  71. */ 
  72. function smarty_resource_userdb_timestamp($tpl_name&$tpl_timestamp&$smarty
  73. /*
  74.     $_url = parse_url($tpl_name); 
  75.     
  76.     // (required) expected syntax: table/source_field 
  77.     $_path_items = explode('/', $_url['path']); 
  78.     $table = $_path_items[0]; 
  79.     $source = $_path_items[1]; 
  80.  
  81.     // Theme Configuration
  82.     $skinid = pnModAPIFunc('Xanthia','user','getSkinID',
  83.                                 array('skin' => $table));
  84.  
  85.     $dbconn =& pnDBGetConn(true);
  86.     $pntable =& pnDBGetTables();
  87.     $table = $pntable['theme_tplsource'];
  88.     $column = &$pntable['theme_tplsource_column'];
  89.  
  90.     $query = "SELECT $column[tpl_timestamp]
  91.                     FROM $table
  92.                     WHERE $column[tpl_file_name]='$source'
  93.                     AND $column[tpl_skin_id]= '$skinid' LIMIT 1";
  94.     $result =& $dbconn->Execute($query);        
  95.     if ($result->EOF) {
  96.     } else {
  97.         list($tpl_timestamp) = $result->fields;
  98.     }
  99.     $result->MoveNext();
  100.     $result->Close();
  101.  
  102.     if ($tpl_timestamp) {
  103.         return true; 
  104.     } else {
  105.         return false;
  106.     } 
  107. }
  108. */
  109.  
  110.     $default=microtime()
  111.     return $default;
  112. }
  113.  
  114. function smarty_resource_userdb_secure($tpl_name&$smarty
  115.     return true
  116. }  
  117. function smarty_resource_userdb_trusted($tpl_name&$smarty
  118.     return true
  119. }  
  120.  
  121. ?>

Documentation generated on Fri, 18 Jul 2008 21:56:37 +0200 by phpDocumentor 1.4.1