Ejemplo n.º 1
0
 /**
  * Class constructor.
  *
  * @param string $elemName Widget instance unique name.
  * @param array $elemArgs Widget arguments and attributes.
  * @param string $elemTheme Theme name to be applied to the element. Not used anymore.
  * @param array $dispEvents Dispatcher events.
  */
 public function __construct($elemName, $elemArgs = '', $elemTheme = '', $dispEvents = '')
 {
     $this->mName = $elemName;
     $this->mArgs =& $elemArgs;
     $this->mComments = \Innomatic\Wui\Wui::showSourceComments();
     $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $wuiContainer = \Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui');
     if (is_array($dispEvents)) {
         $this->mDispEvents =& $dispEvents;
     }
     $currentWuiTheme = $wuiContainer->getThemeName();
     if (strlen($elemTheme) and $elemTheme != $currentWuiTheme) {
         $this->mTheme = $elemTheme;
         $this->mThemeHandler = new \Innomatic\Wui\WuiTheme($container->getDataAccess(), $this->mTheme);
     } else {
         $this->mTheme = $currentWuiTheme;
         $this->mThemeHandler = $wuiContainer->getTheme();
     }
     if (isset($this->mArgs['usesession']) and ($this->mArgs['usesession'] == 'true' or $this->mArgs['usesession'] == 'false')) {
         $this->mUseSession = $this->mArgs['usesession'];
     } else {
         $this->mUseSession = 'true';
     }
     // Initialise session parameters.
     if (isset($this->mArgs['sessionobjectnouser'])) {
         $this->mSessionObjectNoUser = $this->mArgs['sessionobjectnouser'];
     }
     if (isset($this->mArgs['sessionobjectnopage'])) {
         $this->mSessionObjectNoPage = $this->mArgs['sessionobjectnopage'];
     }
     if (isset($this->mArgs['sessionobjectnotype'])) {
         $this->mSessionObjectNoType = $this->mArgs['sessionobjectnotype'];
     }
     if (isset($this->mArgs['sessionobjectnoname'])) {
         $this->mSessionObjectNoName = $this->mArgs['sessionobjectnoname'];
     }
     if (isset($this->mArgs['sessionobjectusername'])) {
         $this->mSessionObjectUserName = $this->mArgs['sessionobjectusername'];
     }
     $url_path = '';
     if ($this->mSessionObjectNoPage != 'true') {
         $url_path = $_SERVER['REQUEST_URI'];
         if (strpos($url_path, '?')) {
             $url_path = substr($url_path, 0, strpos($url_path, '?'));
         }
         $url_path .= '_';
     }
     $this->mSessionObjectName = ($this->mSessionObjectNoUser == 'true' ? '' : (is_object($container->getCurrentUser()) ? $container->getCurrentUser()->getUserName() : 'root') . '_') . $url_path . ($this->mSessionObjectNoType == 'true' ? '' : get_class($this) . '_') . ($this->mSessionObjectNoName == 'true' ? '' : $this->mName) . (strlen($this->mSessionObjectUserName) ? '_' . $this->mSessionObjectUserName : '');
     // Check if the widget should be prepared once for all instances
     $widgetName = substr(get_class($this), 3);
     if (!isset($wuiContainer->preparedWidgets[$widgetName])) {
         // Register action ajax calls
         $theObject = new \ReflectionObject($this);
         $methods = $theObject->getMethods();
         foreach ($methods as $method) {
             // Ignore private methods
             $theMethod = new \ReflectionMethod($theObject->getName(), $method->getName());
             if (!$theMethod->isPublic()) {
                 continue;
             }
             // Expose only methods beginning with "ajax" prefix
             if (!(substr($method->getName(), 0, 4) == 'ajax')) {
                 continue;
             }
             // Register the ajax call
             $call_name = substr($method->getName(), 4);
             $wuiContainer->registerAjaxCall($call_name);
             $wuiContainer->getXajax()->registerExternalFunction(array($call_name, get_class($this), $method->getName()), 'shared/wui/' . get_class($this) . '.php');
         }
         // Set the widget as prepared
         $wuiContainer->preparedWidgets[$widgetName] = $widgetName;
     }
 }
Ejemplo n.º 2
0
function main_default($eventData)
{
    global $wuiMainFrame, $wuiTitleBar, $innomaticLocale, $actionDispatcher, $wuiMainStatus, $wuiComments, $compressedOb;
    $appCfg = new \Innomatic\Application\ApplicationSettings('innomatic');
    $themesQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT name,catalog FROM wui_themes ');
    while (!$themesQuery->eof) {
        $tmpLocale = new \Innomatic\Locale\LocaleCatalog($themesQuery->getFields('catalog'), \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getLanguage());
        $elements[$themesQuery->getFields('name')] = $tmpLocale->getStr($themesQuery->getFields('name'));
        $themesQuery->moveNext();
    }
    asort($elements);
    $themesXmlDef = '<vertgroup><name>vgroup</name><args><halign>center</halign></args><children>
        <form><name>theme</name><args><action type="encoded">' . urlencode(\Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'default', ''), array('action', 'settheme', '')))) . '</action></args><children>
        <grid><name>themegrid</name><children>
            <label row="0" col="0"><name>themelabel</name><args><label type="encoded">' . urlencode($innomaticLocale->getStr('themes_label')) . '</label><bold>true</bold></args></label>
            <listbox row="1" col="0"><name>theme</name><args><elements type="array">' . WuiXml::encode($elements) . '</elements><default>' . \Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui')->getThemeName() . '</default><disp>action</disp><size>10</size></args></listbox>
        </children></grid>
        <submit><name>submit</name><args><caption type="encoded">' . urlencode($innomaticLocale->getStr('settheme_submit')) . '</caption></args></submit>
      </children></form>
    </children></vertgroup>';
    // Service provider settings
    // Service Provider
    //
    $serviceProviderFrame = new WuiVertframe('serviceproviderframe');
    $serviceProviderVGroup = new WuiVertgroup('serviceprovidervgroup', array('width' => '100%'));
    $serviceProviderVGroup->addChild(new WuiLabel('serviceproviderlabel', array('label' => $innomaticLocale->getStr('serviceproviderframe_label'), 'bold' => 'true')));
    $serviceProviderGrid = new WuiGrid('serviceprovidergrid', array('rows' => '4', 'cols' => '2'));
    // Service Provider name
    //
    $serviceProviderGrid->addChild(new WuiLabel('serviceprovidername_label', array('label' => $innomaticLocale->getStr('serviceprovidername_label'))), 0, 0);
    $serviceProviderGrid->addChild(new WuiString('serviceprovidername', array('disp' => 'action', 'size' => '30', 'value' => $appCfg->getKey('serviceprovider-name'))), 0, 1);
    // Service Provider url
    //
    $serviceProviderGrid->addChild(new WuiLabel('serviceproviderurl_label', array('label' => $innomaticLocale->getStr('serviceproviderurl_label'))), 1, 0);
    $serviceProviderGrid->addChild(new WuiString('serviceproviderurl', array('disp' => 'action', 'size' => '30', 'value' => $appCfg->getKey('serviceprovider-url'))), 1, 1);
    // Service Provider big logo
    //
    $serviceProviderGrid->addChild(new WuiLabel('serviceproviderbiglogo_label', array('label' => $innomaticLocale->getStr('serviceproviderbiglogo_label'))), 2, 0);
    $serviceProviderGrid->addChild(new WuiFile('serviceproviderbiglogo', array('disp' => 'action')), 2, 1);
    // Service Provider link logo
    //
    $serviceProviderGrid->addChild(new WuiLabel('serviceproviderlogo_label', array('label' => $innomaticLocale->getStr('serviceproviderlogo_label'))), 3, 0);
    $serviceProviderGrid->addChild(new WuiFile('serviceproviderlinklogo', array('disp' => 'action')), 3, 1);
    $serviceProviderVGroup->addChild($serviceProviderGrid);
    $serviceProviderVGroup->addChild(new WuiSubmit('serviceprovidersubmit', array('caption' => $innomaticLocale->getStr('serviceprovider_submit'))));
    $formEventsCall = new \Innomatic\Wui\Dispatch\WuiEventsCall();
    $formEventsCall->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('action', 'setserviceprovider', ''));
    $formEventsCall->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('view', 'default', ''));
    $serviceProviderForm = new WuiForm('setserviceproviderform', array('action' => $formEventsCall->getEventsCallString()));
    $serviceProviderForm->addChild($serviceProviderVGroup);
    // Enabled icons
    //
    $enableVGroup = new WuiVertgroup('enablevgroup', array('width' => '100%'));
    $enableVGroup->addChild(new WuiLabel('enablelabel', array('label' => $innomaticLocale->getStr('enabled_icons_label'), 'bold' => 'true')));
    $enableGrid = new WuiGrid('enablegrid', array('rows' => '5', 'cols' => '2'));
    // Innomatic site link
    //
    $enableGrid->addChild(new WuiLabel('innomaticlabel', array('label' => $innomaticLocale->getStr('innomatic_link_enabled_label'))), 0, 1);
    $enableGrid->addChild(new WuiCheckBox('innomaticicon', array('disp' => 'action', 'checked' => $appCfg->getKey('innomatic-link-disabled') ? 'false' : 'true')), 0, 0);
    // Service Provider link
    //
    $enableGrid->addChild(new WuiLabel('serviceprovidericonlabel', array('label' => $innomaticLocale->getStr('serviceprovider_link_enabled_label'))), 1, 1);
    $enableGrid->addChild(new WuiCheckBox('serviceprovidericon', array('disp' => 'action', 'checked' => $appCfg->getKey('serviceprovider-link-disabled') ? 'false' : 'true')), 1, 0);
    // Innomatic big logo
    //
    $enableGrid->addChild(new WuiLabel('innomaticbigiconlabel', array('label' => $innomaticLocale->getStr('innomatic_biglogo_enabled_label'))), 2, 1);
    $enableGrid->addChild(new WuiCheckBox('innomaticbigicon', array('disp' => 'action', 'checked' => $appCfg->getKey('innomatic-biglogo-disabled') ? 'false' : 'true')), 2, 0);
    // Service Provider logo
    //
    $enableGrid->addChild(new WuiLabel('serviceprovidericonlabel', array('label' => $innomaticLocale->getStr('serviceprovider_biglogo_enabled_label'))), 3, 1);
    $enableGrid->addChild(new WuiCheckBox('serviceproviderbigicon', array('disp' => 'action', 'checked' => $appCfg->getKey('serviceprovider-biglogo-disabled') ? 'false' : 'true')), 3, 0);
    $enableVGroup->addChild($enableGrid);
    $enableVGroup->addChild(new WuiSubmit('enablesubmit', array('caption' => $innomaticLocale->getStr('enable_submit'))));
    $formEventsCall = new \Innomatic\Wui\Dispatch\WuiEventsCall();
    $formEventsCall->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('action', 'setenabledicons', ''));
    $formEventsCall->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('view', 'default', ''));
    $enableForm = new WuiForm('setenableform', array('action' => $formEventsCall->getEventsCallString()));
    $enableForm->addChild($enableVGroup);
    // Advanced settings
    //
    $advancedVGroup = new WuiVertgroup('enablevgroup', array('width' => '100%'));
    $advancedVGroup->addChild(new WuiLabel('enablelabel', array('label' => $innomaticLocale->getStr('advancedsettings_label'), 'bold' => 'true')));
    $advancedGrid = new WuiGrid('enablegrid', array('rows' => '2', 'cols' => '2'));
    // Compressed output buffering
    //
    $advancedGrid->addChild(new WuiLabel('compressed-ob-label', array('label' => $innomaticLocale->getStr('compressed-ob_label'))), 0, 1);
    if (!strlen($compressedOb)) {
        if (\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getConfig()->value('CompressedOutputBuffering') == '1') {
            $compressedOb = 'true';
        } else {
            $compressedOb = 'false';
        }
    }
    $advancedGrid->addChild(new WuiCheckBox('compressed-ob', array('disp' => 'action', 'checked' => $compressedOb)), 0, 0);
    // WUI code comments
    //
    $advancedGrid->addChild(new WuiLabel('wui-comments-label', array('label' => $innomaticLocale->getStr('wui-comments_label'))), 1, 1);
    if (!strlen($wuiComments)) {
        if (\Innomatic\Wui\Wui::showSourceComments()) {
            $wuiComments = 'true';
        } else {
            $wuiComments = 'false';
        }
    }
    $advancedGrid->addChild(new WuiCheckBox('wui-comments', array('disp' => 'action', 'checked' => $wuiComments)), 1, 0);
    $advancedVGroup->addChild($advancedGrid);
    $advancedVGroup->addChild(new WuiSubmit('enablesubmit', array('caption' => $innomaticLocale->getStr('advanced_submit'))));
    $formEventsCall = new \Innomatic\Wui\Dispatch\WuiEventsCall();
    $formEventsCall->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('action', 'setadvanced', ''));
    $formEventsCall->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('view', 'default', ''));
    $advancedForm = new WuiForm('setenableform', array('action' => $formEventsCall->getEventsCallString()));
    $advancedForm->addChild($advancedVGroup);
    $tabHeaders[0]['label'] = $innomaticLocale->getStr('themes_title');
    $tabHeaders[1]['label'] = $innomaticLocale->getStr('serviceproviderframe_label');
    $tabHeaders[2]['label'] = $innomaticLocale->getStr('enabled_icons_label');
    $tabHeaders[3]['label'] = $innomaticLocale->getStr('advancedsettings_label');
    $tab = new WuiTab('interface', array('tabactionfunction' => 'interface_tab_action_builder', 'activetab' => isset($eventData['activetab']) ? $eventData['activetab'] : '', 'tabs' => $tabHeaders));
    $tab->addChild(new WuiXml('page', array('definition' => $themesXmlDef)));
    $tab->addChild($serviceProviderForm);
    $tab->addChild($enableForm);
    $tab->addChild($advancedForm);
    $wuiMainFrame->addChild($tab);
    $wuiTitleBar->mTitle .= ' - ' . $innomaticLocale->getStr('default_title');
}