SugarCRM CMS
                    CogniTom Academic Design

                     kawamura@cognitom.com




2009   9   30
Why?
                •
                •
                •   DB

                •          (?)


                • WEB →
2009   9   30
• Sugar

                •


2009   9   30
•   •
                •   •
                •
                •   •SugarCRM




2009   9   30
• WebPages :
                • WebNews :
                • WebParts :        (             )

                • WebRegistries :
                • WebProducts :         ...etc.


2009   9   30
EditView
                      • TinyMCE                                 ←                 Sugar
                31.   $viewdefs['WebPages']['EditView'] = array(
                32.   	

 'templateMeta' => array (
                33.   	

 	

   'form' => array (...   ...),
                34.   	

 	

   'maxColumns' => '3',
                35.   	

 	

   'widths' => array (...    ...),
                36.   	

   	

    'javascript' => '
                37.   <script type="text/javascript" src="include/javascript/tiny_mce/tiny_mce.js"></script>
                38.   <script type="text/javascript">
                39.   {literal}
                40.   tinyMCE.init({
                41.   	

   mode: "exact",
                42.   	

   elements: "contents",
                43.   	

   theme: "advanced",
                44.   	

   language: "ja_utf-8",
                45.   	

   relative_urls: false,
                46.   	

   plugins: "table",
                47.   	

   ...       ...
                48.   });
                49.   {/literal}
                50.   </script>
                51.   	

   	

  ',
                52.   	

   ),


2009   9   30
Tin
                   yM
                     CE




2009   9   30
•   httpdocs/	

                             SSL

                  •   .htaccess	

                                 index.php
                  •   index.php	

                                   Sugar

                •   httpsdocs/	

                          SSL
                  •   .htaccess	

                                 index.php
                  •   index.php	

                                   Sugar

                  •   sugar/	

                      •  index.php	

                      Sugar
                      •  include/entryPoint.php	

                      •• modules/	

                           WebPages/	

                           • entry_point_registry.php	

                           • public/sample.php	

                           • tpls/sample.html	


2009   9   30
•   /.htaccess

                •   /index.php

                •   /sugar/include/entryPoint.php

                •   /sugar/modules/WebPages/entry_point_registry.php

                •   /sugar/modules/WebPages/public/home.php

                •   /sugar/modules/WebPages/tpls/public.home.html



2009   9   30
entryPoint
                      • entryPoint
                         /sugar/modules/WebPages/entry_point_registry.php
                         index.php?module=WebNews&entryPoint=list&year=2009



                37.   $entry_point_registry['list']
                      	

 = array('file' => 'modules/WebProducts/public/list.php', 'auth' => false);
                38.   $entry_point_registry['detail']
                      	

 = array('file' => 'modules/WebProducts/public/detail.php', 'auth' => false);




2009   9   30
• .htaccess
                       index.php



                3.   RewriteEngine On
                4.   RewriteCond %{REQUEST_FILENAME} !-f
                5.   RewriteCond %{REQUEST_FILENAME} !-d
                6.   RewriteRule ^(.*)$ index.php [L,QSA]




2009   9   30
• PHP                                 Sugar


                        /httpdocs/ → /httpsdocs/sugar/



                2.   chdir('../httpsdocs/sugar');//Sugar




2009   9   30
• REQUEST_URI
                9.     if (preg_match('/^/news/(?<year>d+)/(?<month>d+)//', $path, $matches))
                       	

 $route = array(
                       	

 	

  'module' => 'WebNews',
                       	

 	

  'entryPoint' => 'list',
                       	

 	

  'year' => $matches['year'],
                       	

 	

  'month' => $matches['month']
                       	

 );
                10.    else { header("HTTP/1.0 404 Not Found"); die("                            "); }
                11.    $_REQUEST = array_merge($_REQUEST, $route);



2009   9   30
31.   //
                32.   define('sugarEntry', true);
                33.   $startTime = microtime(true);
                34.   require_once('include/entryPoint.php');
                35.
                36.   //WEB
                37.   require_once('modules/Users/User.php');
                38.   global $current_user;
                39.   $current_user = new User();
                40.   $current_user->retrieve($current_user->retrieve_user_id('webuser'));
                41.
                42.   //
                43.   ob_start();
                44.   require_once('include/MVC/SugarApplication.php');
                45.   $app = new SugarApplication();
                46.   $app->startSession();
                47.   $app->execute();



2009   9   30
• Smarty
                31.   //Smarty
                32.   $ss = new Sugar_Smarty();
                33.   $ss->assign('MOD', $GLOBALS['mod_strings']);
                34.   $ss->assign('APL', $GLOBALS['app_list_strings']);
                35.   $ss->assign('page', $page);
                36.   $ss->assign('page_siblings', $page_siblings);
                37.   $ss->assign('toppage_message', $toppage_message);
                38.   $ss->assign('news', $news);
                39.   $ss->assign('global_links', $global_links);

                41.   //
                42.   echo $ss->fetch('modules/WebPages/tpls/public.home.html');


                                                                          >> Espresso
2009   9   30
•


                8.   $page = new WebPage();
                9.   $page->retrieve_by_string_fields(array('search_key'=>'home', 'language'=>'ja'));




2009   9   30
•


                31.   $focus = new WebNewsArticle();
                32.   $result = $focus->get_list('date desc', “YEAR(date) = {$year}”, 0, 20);
                33.   $news = $result['list'];




2009   9   30

SugarCRM勉強会#001 SugarCRMをCMSとして活用

  • 1.
    SugarCRM CMS CogniTom Academic Design kawamura@cognitom.com 2009 9 30
  • 2.
    Why? • • • DB • (?) • WEB → 2009 9 30
  • 3.
    • Sugar • 2009 9 30
  • 4.
    • • • • • •SugarCRM 2009 9 30
  • 5.
    • WebPages : • WebNews : • WebParts : ( ) • WebRegistries : • WebProducts : ...etc. 2009 9 30
  • 6.
    EditView • TinyMCE ← Sugar 31. $viewdefs['WebPages']['EditView'] = array( 32. 'templateMeta' => array ( 33. 'form' => array (... ...), 34. 'maxColumns' => '3', 35. 'widths' => array (... ...), 36. 'javascript' => ' 37. <script type="text/javascript" src="include/javascript/tiny_mce/tiny_mce.js"></script> 38. <script type="text/javascript"> 39. {literal} 40. tinyMCE.init({ 41. mode: "exact", 42. elements: "contents", 43. theme: "advanced", 44. language: "ja_utf-8", 45. relative_urls: false, 46. plugins: "table", 47. ... ... 48. }); 49. {/literal} 50. </script> 51. ', 52. ), 2009 9 30
  • 7.
    Tin yM CE 2009 9 30
  • 8.
    httpdocs/ SSL • .htaccess index.php • index.php Sugar • httpsdocs/ SSL • .htaccess index.php • index.php Sugar • sugar/ • index.php Sugar • include/entryPoint.php •• modules/ WebPages/ • entry_point_registry.php • public/sample.php • tpls/sample.html 2009 9 30
  • 9.
    /.htaccess • /index.php • /sugar/include/entryPoint.php • /sugar/modules/WebPages/entry_point_registry.php • /sugar/modules/WebPages/public/home.php • /sugar/modules/WebPages/tpls/public.home.html 2009 9 30
  • 10.
    entryPoint • entryPoint /sugar/modules/WebPages/entry_point_registry.php index.php?module=WebNews&entryPoint=list&year=2009 37. $entry_point_registry['list'] = array('file' => 'modules/WebProducts/public/list.php', 'auth' => false); 38. $entry_point_registry['detail'] = array('file' => 'modules/WebProducts/public/detail.php', 'auth' => false); 2009 9 30
  • 11.
    • .htaccess index.php 3. RewriteEngine On 4. RewriteCond %{REQUEST_FILENAME} !-f 5. RewriteCond %{REQUEST_FILENAME} !-d 6. RewriteRule ^(.*)$ index.php [L,QSA] 2009 9 30
  • 12.
    • PHP Sugar /httpdocs/ → /httpsdocs/sugar/ 2. chdir('../httpsdocs/sugar');//Sugar 2009 9 30
  • 13.
    • REQUEST_URI 9. if (preg_match('/^/news/(?<year>d+)/(?<month>d+)//', $path, $matches)) $route = array( 'module' => 'WebNews', 'entryPoint' => 'list', 'year' => $matches['year'], 'month' => $matches['month'] ); 10. else { header("HTTP/1.0 404 Not Found"); die(" "); } 11. $_REQUEST = array_merge($_REQUEST, $route); 2009 9 30
  • 14.
    31. // 32. define('sugarEntry', true); 33. $startTime = microtime(true); 34. require_once('include/entryPoint.php'); 35. 36. //WEB 37. require_once('modules/Users/User.php'); 38. global $current_user; 39. $current_user = new User(); 40. $current_user->retrieve($current_user->retrieve_user_id('webuser')); 41. 42. // 43. ob_start(); 44. require_once('include/MVC/SugarApplication.php'); 45. $app = new SugarApplication(); 46. $app->startSession(); 47. $app->execute(); 2009 9 30
  • 15.
    • Smarty 31. //Smarty 32. $ss = new Sugar_Smarty(); 33. $ss->assign('MOD', $GLOBALS['mod_strings']); 34. $ss->assign('APL', $GLOBALS['app_list_strings']); 35. $ss->assign('page', $page); 36. $ss->assign('page_siblings', $page_siblings); 37. $ss->assign('toppage_message', $toppage_message); 38. $ss->assign('news', $news); 39. $ss->assign('global_links', $global_links); 41. // 42. echo $ss->fetch('modules/WebPages/tpls/public.home.html'); >> Espresso 2009 9 30
  • 16.
    8. $page = new WebPage(); 9. $page->retrieve_by_string_fields(array('search_key'=>'home', 'language'=>'ja')); 2009 9 30
  • 17.
    31. $focus = new WebNewsArticle(); 32. $result = $focus->get_list('date desc', “YEAR(date) = {$year}”, 0, 20); 33. $news = $result['list']; 2009 9 30