Exemplo n.º 1
0
Arquivo: Util.php Projeto: demental/m
 public static function &getSearchForm($do, $module)
 {
     MyQuickForm::registerElementType('advandate', 'HTML/QuickForm/advandate.php', 'HTML_QuickForm_advandate');
     $form = new MyQuickForm('formSearch', 'GET', self::getQueryParams(array(), array('page', '_c_'), false));
     $fields = $_GET;
     unset($fields['_c_']);
     unset($fields['page']);
     unset($fields['module']);
     unset($fields['action']);
     unset($fields['filterField']);
     unset($fields['filterValue']);
     if (count($fields) == 0) {
         Log::info('caching search form');
         $cache = true;
     } else {
         Log::info('NO SEARCH FORM CACHING');
         $cache = false;
     }
     $cacheName = 'searchform_' . $module;
     $options = array('caching' => $cache, 'cacheDir' => APP_ROOT . 'app/' . APP_NAME . '/cache/forms/', 'lifeTime' => 3600, 'fileNameProtection' => false);
     $cache = new Cache_Lite($options);
     if ($_cachedData = $cache->get($cacheName)) {
         Mreg::append('autoloadcallback', array(array('MyQuickForm', 'autoloadElements')));
         $_cachedData = unserialize($_cachedData);
         foreach ($_cachedData as $element) {
             $form->addElement($element);
         }
     } else {
         $do->fb_selectAddEmpty = array();
         if (is_array($do->links())) {
             foreach ($do->links() as $field => $link) {
                 $do->fb_selectAddEmpty[] = $field;
             }
         }
         if (is_array($do->fb_enumFields)) {
             foreach ($do->fb_enumFields as $field) {
                 $do->fb_selectAddEmpty[] = $field;
             }
         }
         $do->fb_formHeaderText = __('Search');
         $do->fb_submitText = '>>';
         $do->fb_linkNewValue = false;
         $formBuilder =& MyFB::create($do);
         $formBuilder->_cacheOptions = array('name' => 'office_searchform', 'cacheDir' => APP_ROOT . 'app/' . APP_NAME . '/cache/forms/');
         $formBuilder->preGenerateFormCallback = array($do, 'prepareSearchForm');
         $do->prepareSearchForm($fb);
         $do->fb_userEditableFields = $do->fb_fieldsToRender;
         $table = $do->table();
         foreach ($do->fb_fieldsToRender as $field) {
             if ($table[$field] & DB_DATAOBJECT_DATE || $table[$field] & DB_DATAOBJECT_TIME) {
                 $label = $do->fb_fieldLabels[$field] ? $do->fb_fieldLabels[$field] : $field;
                 $do->fb_preDefElements[$field] = MyQuickForm::createElement('advandate', $field, $label, array("language" => T::getLang()));
             }
         }
         $formBuilder->postGenerateFormCallback = array($do, 'postPrepareSearchForm');
         $formBuilder->useForm($form);
         $formBuilder->getForm();
         foreach ($form->_elements as $elem) {
             $cached[] = $elem;
         }
         if ($cache) {
             $cache->save(serialize($cached));
         }
     }
     $form->_rules = array();
     $form->_formRules = array();
     $form->_required = array();
     self::addHiddenFields($form, array('search', 'page', '__dontpaginate', '_c_'), true);
     $form->addElement('checkbox', '__dontpaginate', 'Afficher les résultats sur une seule page');
     return $form;
 }
Exemplo n.º 2
0
Arquivo: M.php Projeto: demental/m
 public static function addPaths($role, $paths)
 {
     switch ($role) {
         case 'model':
             $options =& PEAR::getStaticProperty('DB_DataObject', 'options');
             $options['class_location'] .= ':' . implode(',', $paths);
             break;
         case 'lang':
             foreach ($paths as $path) {
                 T::addPath($path);
             }
             break;
         case 'templates':
             $moduloptions =& PEAR::getStaticProperty('Module', 'global');
             if (!is_array($moduloptions['template_dir'])) {
                 $moduloptions['template_dir'] = array();
             }
             $moduloptions['template_dir'] = array_merge($moduloptions['template_dir'], $paths);
             break;
         case 'modules':
             $dispatchopt =& PEAR::getStaticProperty('Dispatcher', 'global');
             if (!is_array($dispatchopt['all']['modulepath'])) {
                 $dispatchopt['all']['modulepath'] = array();
             }
             $dispatchopt['all']['modulepath'] = array_merge($dispatchopt['all']['modulepath'], $paths);
             break;
         default:
             Mreg::append("{$role}_paths", $paths);
             break;
     }
 }
Exemplo n.º 3
0
Arquivo: init.php Projeto: demental/m
<?php

Log::info('Init tag plugin');
Mreg::append('autoload', array('tagtrigger' => dirname(__FILE__) . 'lib/tagTrigger.php'));
M::addPath('module', dirname(__FILE__) . '/modules/');
M::addPath('template', dirname(__FILE__) . '/templates/');
M::addPath('model', dirname(__FILE__) . '/models/');
Exemplo n.º 4
0
Arquivo: init.php Projeto: demental/m
<?php

Mreg::append('autoload', array('wptools' => dirname(__FILE__) . '/lib/wptools.php'));
T::$config['switch_callbacks'][] = 'WPTools::on_switch_lang';
WPTools::on_switch_lang(T::getLang());