Project

General

Profile

« Previous | Next » 

Revision 2113

Added by darkviper almost 10 years ago

+ framework/UpgradeHelper added new method convInfoIni2InfoPhp()

View differences:

UpgradeHelper.php
341 341
	}
342 342

  
343 343

  
344
    static public function convInfoIni2InfoPhp($sIniDir)
345
    {
346
        $aVarTypePrefixes = array(
347
            'template' => 'template',
348
            'theme'    => 'template',
349
            'tool'     => 'module',
350
            'page'     => 'module',
351
            'snippet'  => 'module'
352
        );
353
        $aNeededVars = array_flip(
354
            array('directory','name','function','version','platform','author','license','license_terms','description')
355
        );
356
        $aRetval = array();
357
        $sIniDir = rtrim(str_replace('\\', '/', $sIniDir), '/').'/';
358
        if (is_readable($sIniDir.'info.ini')) {
359
            if (($ini = parse_ini_file($sIniDir.'info.ini', true))) {
360
                if (!array_key_exists($ini['info']['type'], $aVarTypePrefixes)) {
361
                    return null;
362
                }
363
                $aRetval['prefix'] = $aVarTypePrefixes[$ini['info']['type']];
364
                $aRetval['function'] = $ini['info']['type'];
365
                unset($aNeededVars['function']);
366
                foreach ($ini['info'] as $sVar => $sValue) {
367
                    $aRetval[$sVar] = $sValue;
368
                    unset($aNeededVars[$sVar]);
369
                }
370
                if (isset($ini['platform']['versions'])) {
371
                    $aRetval['platform'] = $ini['platform']['versions'];
372
                    unset($aNeededVars['platform']);
373
                }
374
                if  (sizeof($aNeededVars) > 0) {
375
                    return null;
376
                }
377
            } else {
378
                return null;
379
            }
380
        } else {
381
            return null;
382
        }
383
        return $aRetval;
384
    } // end of function Ini2PhpInfo
385

  
344 386
} // end of class UpgradeHelper
345 387

  

Also available in: Unified diff