Example #1
0
    public static function createDb()
    {
        $sql = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . bqSQL(self::$definition['table']) . '` (
				`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
				`path` varchar(256) NOT NULL,
				`desc` varchar(50) NOT NULL,
				`recursive` TINYINT(1) NOT NULL DEFAULT \'0\',
				`user` TINYINT(1) NOT NULL DEFAULT \'1\',
				`enabled` TINYINT(1) NOT NULL DEFAULT \'0\',
				PRIMARY KEY (`id`)
			) ENGINE=' . _MYSQL_ENGINE_ . ' default CHARSET=utf8';
        if (!Db::getInstance()->execute($sql)) {
            return false;
        }
        $directories = array(array('path' => _PS_PROD_IMG_DIR_, 'desc' => 'Products images', 'recursive' => true), array('path' => _PS_CAT_IMG_DIR_, 'desc' => 'Categories images', 'recursive' => true), array('path' => _PS_MANU_IMG_DIR_, 'desc' => 'Manufacturers  images', 'recursive' => true), array('path' => _PS_SHIP_IMG_DIR_, 'desc' => 'Carriers (shipping) images', 'recursive' => true), array('path' => _PS_SUPP_IMG_DIR_, 'desc' => 'Suppliers  images', 'recursive' => true), array('path' => _PS_SCENE_IMG_DIR_, 'desc' => 'Scenes  images', 'recursive' => true), array('path' => _PS_STORE_IMG_DIR_, 'desc' => 'Stores  images', 'recursive' => true), array('path' => _PS_COL_IMG_DIR_, 'desc' => 'Colors  images', 'recursive' => true), array('path' => _PS_LANG_IMG_DIR_, 'desc' => 'Languages  images', 'recursive' => true), array('path' => _PS_EMPLOYEE_IMG_DIR_, 'desc' => 'Employees  images', 'recursive' => true), array('path' => _PS_MODULE_DIR_, 'desc' => 'Modules  images', 'recursive' => true), array('path' => _PS_ALL_THEMES_DIR_ . _THEME_NAME_ . '/img/', 'desc' => 'Theme specifics images', 'recursive' => true), array('path' => _PS_ALL_THEMES_DIR_ . _THEME_NAME_ . '/mobile/img/', 'desc' => 'Theme mobile images', 'recursive' => true), array('path' => _PS_ALL_THEMES_DIR_ . _THEME_NAME_ . '/modules/', 'desc' => 'Theme modules images', 'recursive' => true), array('path' => _PS_CORE_IMG_DIR_, 'desc' => 'Prestashop core images', 'recursive' => false));
        foreach ($directories as $systemdir) {
            $dir = new self();
            if (!$dir->getByPath($systemdir['path']) && !$dir->fromDef($systemdir, true)->save()) {
                return false;
            }
        }
        return true;
    }
Example #2
0
 /**
  * Static interface for instanciating and extracting
  * in a single operation. Delegates to getByPath.
  *
  * @param mixed $subject
  * @param string $propertyPath
  * @param array $accessors
  * @return mixed
  */
 public static function extract($subject, $propertyPath, array $accessors = array())
 {
     $extractor = new self();
     return $extractor->getByPath($subject, $propertyPath, $accessors);
 }