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

Source for file thelang.php

Documentation is available at thelang.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  * @copyright (c) 2001, Zikula Development Team
  5.  * @link http://www.zikula.org
  6.  * @version $Id: thelang.php 24342 2008-06-06 12:03:14Z markwest $
  7.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  8.  * @package Zikula_System_Modules
  9.  * @subpackage Blocks
  10.  */
  11.  
  12. /**
  13.  * initialise block
  14.  *
  15.  * @author       The Zikula Development Team
  16.  */
  17. {
  18.     // Security
  19.     pnSecAddSchema('Languageblock::''Block title::');
  20. }
  21.  
  22. /**
  23.  * get information on block
  24.  *
  25.  * @author       The Zikula Development Team
  26.  * @return       array       The block information
  27.  */
  28. {
  29.     return array('text_type'       => 'Language',
  30.                  'module'          => 'Blocks',
  31.                  'text_type_long'  => 'Languages',
  32.                  'allow_multiple'  => false,
  33.                  'form_content'    => false,
  34.                  'form_refresh'    => false,
  35.                  'show_preview'    => true,
  36.                  'admin_tableless' => true);
  37. }
  38.  
  39. /**
  40.  * Display the block
  41.  *
  42.  * @param        row           blockinfo array
  43.  */
  44. function Blocks_thelangblock_display($blockinfo)
  45. {
  46.     // security check
  47.     if (!SecurityUtil::checkPermission('Languageblock::'"$blockinfo[title]::"ACCESS_OVERVIEW)) {
  48.         return;
  49.     }
  50.  
  51.     // if the site's not an ML site don't display the block
  52.     if (!pnConfigGetVar('multilingual')) {
  53.         return;
  54.     }
  55.  
  56.     // Get current content
  57.     $vars pnBlockVarsFromContent($blockinfo['content']);
  58.  
  59.     // Defaults
  60.     if (empty($vars['format'])) {
  61.         $vars['format'2;
  62.     }
  63.  
  64.     // quick fix for [#5166] Languages block displays an empty list
  65.     // this needs some rework for .9
  66.     if (!isset($vars['languages']|| empty($vars['languages']|| !is_array($vars['languages'])) {
  67.         $vars['languages'Blocks_thelangblock_getAvailableLanguages();
  68.     }
  69.  
  70.     // Create output object - this object will store all of our output so that
  71.     // we can return it easily when required
  72.     $pnRender pnRender::getInstance('Blocks');
  73.  
  74.     // assign the block vars
  75.     $pnRender->assign($vars);
  76.  
  77.     // what's the current language
  78.     $pnRender->assign('currentlanguage'pnUserGetLang());
  79.  
  80.     // set a block title
  81.     if (empty($blockinfo['title'])) {
  82.         $blockinfo['title'DataUtil::formatForDisplay(_SELECTLANGUAGE);
  83.     }
  84.  
  85.     // get the block content from the template then end the templating
  86.     $blockinfo['content'$pnRender->fetch('blocks_block_thelang.htm');
  87.  
  88.     // return the block to the theme
  89.     return pnBlockThemeBlock($blockinfo);
  90. }
  91.  
  92.  
  93. /**
  94.  * modify block settings
  95.  *
  96.  * @author       The Zikula Development Team
  97.  * @param        array       $blockinfo     a blockinfo structure
  98.  * @return       output      the bock form
  99.  */
  100. function blocks_thelangblock_modify($blockinfo)
  101. {
  102.     // Get current content
  103.     $vars pnBlockVarsFromContent($blockinfo['content']);
  104.  
  105.     // Defaults
  106.     if (empty($vars['format'])) {
  107.         $vars['format'2;
  108.     }
  109.  
  110.     // Create output object
  111.     // As Admin output changes often, we do not want caching.
  112.     $pnRender pnRender::getInstance('Blocks'false);
  113.  
  114.     // assign the approriate values
  115.     $pnRender->assign($vars);
  116.  
  117.     // clear the block cache
  118.     $pnRender pnRender::getInstance('Blocks');
  119.     $pnRender->clear_cache('blocks_block_thelang.htm');
  120.  
  121.     // Return the output that has been generated by this function
  122.     return $pnRender->fetch('blocks_block_thelang_modify.htm');
  123. }
  124.  
  125.  
  126. /**
  127.  * update block settings
  128.  *
  129.  * @author       The Zikula Development Team
  130.  * @param        array       $blockinfo     a blockinfo structure
  131.  * @return       $blockinfo  the modified blockinfo structure
  132.  */
  133. function Blocks_thelangblock_update($blockinfo)
  134. {
  135.     // Get current content
  136.     $vars pnBlockVarsFromContent($blockinfo['content']);
  137.  
  138.     // Read inputs
  139.     $vars['format'FormUtil::getPassedValue('format');
  140.  
  141.     // Scan for languages and save cached version
  142.     $vars['languages'Blocks_thelangblock_getAvailableLanguages();
  143.  
  144.     // write back the new contents
  145.     $blockinfo['content'pnBlockVarsToContent($vars);
  146.  
  147.     // clear the block cache
  148.     $pnRender pnRender::getInstance('Blocks');
  149.     $pnRender->clear_cache('blocks_block_thelang.htm');
  150.  
  151.     return $blockinfo;
  152. }
  153.  
  154.  
  155. {
  156.     $langlist LanguageUtil::getInstalledLanguages();
  157.     $flags array();
  158.     $lang array();
  159.  
  160.     foreach ($langlist as $k => $v{
  161.         // if we don't have an image or the language directory doesn't exist
  162.         // then don't pass this language to the template
  163.         if (is_dir("language/$k")) {
  164.             $imgsize @getimagesize("images/flags/flag-$k.png");
  165.             $lang[array('code' => $k,
  166.                             'name' => $v);
  167.             if ($imgsize{
  168.                 $flags[array('code' => $k,
  169.                                  'title' => $v,
  170.                                  'image' => "images/flags/flag-$k.png");
  171.             }
  172.         }
  173.     }
  174.     //asort($lang);
  175.  
  176.     return array('lang' => $lang'flags' => $flags);
  177. }

Documentation generated on Fri, 18 Jul 2008 21:58:26 +0200 by phpDocumentor 1.4.1