Esempio n. 1
0
 protected function _extractModules()
 {
     $activeModules = $this->getTable('modules')->innerJoin($this->getTable('modules_type'), 'type_id')->get($this->getTable('modules')->alias() . '.*, ' . $this->getTable('modules_type')->alias() . '.label as type_name');
     if ($activeModules) {
         foreach ($activeModules as $m) {
             $code = $m['code'];
             $moduleLocationDir = BUP_MODULES_DIR;
             if (!empty($m['ex_plug_dir'])) {
                 $moduleLocationDir = utilsBup::getExtModDir($m['ex_plug_dir']);
             }
             if (is_dir($moduleLocationDir . $code)) {
                 $this->_allModules[$m['code']] = 1;
                 if ((bool) $m['active']) {
                     importClassBup($code . strFirstUp(BUP_CODE), $moduleLocationDir . $code . DS . 'mod.php');
                     $moduleClass = toeGetClassNameBup($code);
                     if (class_exists($moduleClass)) {
                         $this->_modules[$code] = new $moduleClass($m);
                         $this->_modules[$code]->setParams((array) json_decode($m['params']));
                         if (is_dir($moduleLocationDir . $code . DS . 'tables')) {
                             $this->_extractTables($moduleLocationDir . $code . DS . 'tables' . DS);
                         }
                     }
                 }
             }
         }
     }
     //$operationTime = microtime(true) - $startTime;
 }
Esempio n. 2
0
 public static function getInstance($table = '')
 {
     static $instances = array();
     if (!isset($instances[$table])) {
         $class = 'table' . strFirstUp($table) . strFirstUp(BUP_CODE);
         if (class_exists($class)) {
             $instances[$table] = new $class();
         } else {
             $instances[$table] = NULL;
         }
         /*throw error must be here*/
     }
     return $instances[$table];
 }
Esempio n. 3
0
 public static function getInstance($table = '')
 {
     static $instances = array();
     if (!$table) {
         throw new Exception('Unknown table [' . $table . ']');
     }
     if (!isset($instances[$table])) {
         $class = 'table' . strFirstUp($table) . strFirstUp(GMP_CODE);
         if (class_exists($class)) {
             $instances[$table] = new $class();
         } else {
             $instances[$table] = NULL;
         }
         /*throw error must be here*/
     }
     return $instances[$table];
 }
Esempio n. 4
0
 protected static function _runModuleInstall($module, $action = 'install')
 {
     $moduleLocationDir = GMP_MODULES_DIR;
     if (!empty($module['ex_plug_dir'])) {
         $moduleLocationDir = utilsGmp::getPluginDir($module['ex_plug_dir']);
     }
     if (is_dir($moduleLocationDir . $module['code'])) {
         if (!class_exists($module['code'] . strFirstUp(GMP_CODE))) {
             importClassGmp($module['code'], $moduleLocationDir . $module['code'] . DS . 'mod.php');
         }
         $moduleClass = toeGetClassNameGmp($module['code']);
         $moduleObj = new $moduleClass($module);
         if ($moduleObj) {
             $moduleObj->{$action}();
         }
     }
 }
Esempio n. 5
0
 function toeGetClassNameGmp($class)
 {
     $className = '';
     if (class_exists($class . strFirstUp(GMP_CODE))) {
         $className = $class . strFirstUp(GMP_CODE);
     } else {
         if (class_exists(GMP_CLASS_PREFIX . $class)) {
             $className = GMP_CLASS_PREFIX . $class;
         } else {
             $className = $class;
         }
     }
     return $className;
 }
Esempio n. 6
0
    public static function galleryBtn($name, $params = array())
    {
        $galleryType = isset($params['galleryType']) ? $params['galleryType'] : 'all';
        $buttonId = self::nameToClassId($name, $params);
        $params['value'] = isset($params['value']) ? $params['value'] : '';
        $params['attrs'] = isset($params['attrs']) ? $params['attrs'] : '';
        if (strpos($params['attrs'], 'id="') === false) {
            $buttonId .= '_' . mt_rand(1, 99999);
            $params['attrs'] .= ' id="' . $buttonId . '"';
        }
        $inputId = $buttonId . '_input';
        $out = self::hidden($name, array('value' => $params['value'], 'attrs' => 'id="' . $inputId . '"'));
        $onChange = isset($params['onChange']) ? $params['onChange'] : '';
        $buttonParams = $params;
        $buttonParams['value'] = isset($params['btnVal']) ? $params['btnVal'] : sprintf(__('Select %s', GMP_LANG_CODE), strFirstUp($galleryType));
        $out .= self::button($buttonParams);
        $out .= '<script type="text/javascript">
		// <!--
			jQuery(function(){
				// Run onChange to make pre-set of required data
				' . ($onChange ? $onChange . '("' . $params['value'] . '", null, "' . $buttonId . '");' : '') . '
				jQuery("#' . $buttonId . '").click(function(){
					var button = jQuery(this);
					_custom_media = true;
					wp.media.editor.send.attachment = function(props, attachment){
						if ( _custom_media ) {
							jQuery("#' . $inputId . '").val( attachment.url ).trigger("change");
							' . ($onChange ? $onChange . '(attachment.url, attachment, "' . $buttonId . '");' : '') . '
						} else {
							return _orig_send_attachment.apply( this, [props, attachment] );
						};
					};
					wp.media.editor.open(button);
					jQuery(".attachment-filters").val("' . $galleryType . '").trigger("change");
					return false;
				});
			});
		// -->
		</script>';
        return $out;
    }