<?php
//@*--


class Theme_Designer_Model_ThemeList extends Varien_Object
{
    public function getThemeList()
    {
        $appDir = MAGENTO_ROOT . Mage::getSingleton('designer/config')->get('paths/app_base');
        $themes = new Varien_Data_Collection();
        $dir = opendir($appDir);
        // todo: use DirectoryIterator
        while (($item = readdir($dir)) !== false) {
            if ($item === '.' || $item === '..' || preg_match('/_preview$/i', $item) || !file_exists($appDir . DS . $item . '/designer/project.json')) continue;
            $theme = Mage::getModel('designer/theme');
            $theme->setData('name', $item);
            $theme->setData('editable', true);
            $themes->addItem($theme);
        }
        return $themes;
    }
}

//--*@