Пример #1
0
 public function get($id)
 {
     $app = [];
     if (substr($id, 0, 9) == '__module_') {
         $id = substr_replace($id, '', 0, 9);
         $db = new \Core\Db();
         $module = $db->select('m.*, p.*')->from(':module', 'm')->join(':product', 'p', 'p.product_id = m.product_id')->where(['m.module_id' => $id])->get();
         if ($module['product_id'] == 'phpfox') {
             $module['version'] = \Phpfox::getVersion();
         }
         $app = ['id' => '__module_' . $id, 'name' => \Phpfox_Locale::instance()->translate($id, 'module'), 'path' => null, 'is_module' => true, 'version' => $module['version']];
     } else {
         if (!isset($this->_apps[$id])) {
             throw new \Exception('App not found "' . $id . '".');
         }
         $app = $this->_apps[$id];
     }
     return new App\Object($app);
 }
Пример #2
0
 public function rebuild()
 {
     $flavorId = $this->flavor_folder;
     if (!$flavorId) {
         throw new \Exception('Cannot merge a theme without a flavor.');
     }
     $db = new \Core\Db();
     $moduleList = $db->select('module_id')->singleData('module_id')->from(':module')->where('is_active=1')->all();
     $css = new CSS($this);
     try {
         $data = $css->get();
         $moduleData = $css->getModule($moduleList);
         $css->reBuildModule($moduleList);
         $appData = $css->getApp();
         $css->set($data, null, $moduleData . $appData, $this->name);
     } catch (\Exception $e) {
         return false;
     }
 }
Пример #3
0
 public function merge()
 {
     $flavorId = $this->flavor_folder;
     if (!$flavorId) {
         throw new \Exception('Cannot merge a theme without a flavor.');
     }
     $id = $this->theme_id;
     //get folder name
     $Db = new \Core\Db();
     $folderName = (string) $Db->select('folder')->from(':theme')->where('theme_id=' . (int) $id)->count();
     if (empty($folderName)) {
         $folderName = $id;
     }
     $path = PHPFOX_DIR_SITE . 'themes/' . $folderName . '/';
     $File = \Phpfox_File::instance();
     $copy = [];
     $dirs = [];
     $themeFile = strtolower($folderName) == 'bootstrap' ? 'bootstrap' : 'default';
     $files = $File->getAllFiles(PHPFOX_DIR . 'theme/' . $themeFile . '/');
     foreach ($files as $file) {
         if (!in_array($File->extension($file), ['html', 'js', 'css', 'less'])) {
             continue;
         }
         $parts = pathinfo($file);
         $dirs[] = str_replace(PHPFOX_DIR . 'theme/default/', '', $parts['dirname']);
         $copy[] = $file;
     }
     foreach ($copy as $file) {
         $newFile = $path . str_replace(PHPFOX_DIR . 'theme/' . $themeFile . '/', '', $file);
         if (in_array($File->extension($file), ['less', 'css'])) {
             $newFile = str_replace('default.' . $File->extension($file), $flavorId . '.' . $File->extension($file), $newFile);
         }
         copy($file, $newFile);
         // p($file . ' -> ' . $newFile);
         if ($File->extension($file) == 'less') {
             $content = file_get_contents($newFile);
             $content = str_replace('../../../', '../../../../PF.Base/', $content);
             file_put_contents($newFile, $content);
         }
     }
     $Cache = new \Core\Cache();
     $Db->update(':setting', array('value_actual' => (int) \Phpfox::getParam('core.css_edit_id') + 1), 'var_name = \'css_edit_id\'');
     $Cache->del('setting');
     // exit;
     return true;
 }
Пример #4
0
 * For this app we return a callable function, which passes the current $App object
 */
return function (Core\App\Object $App, Twig_Environment $View) {
    // Check if user is logged in, if not don't load the event below
    $auth = new Core\Auth\User();
    if (!$auth->isLoggedIn()) {
        return false;
    }
    /**
     * Attach an event to the loading of all blocks
     */
    new Core\Event('lib_module_get_blocks', function (Phpfox_Module $object) use($View) {
        $db = new Core\Db();
        // $cache = new Core\Cache();
        $limit = (int) setting('pfu_total_to_feature', 6);
        $cond = [];
        $featured = $db->select('*')->from(':user_featured')->limit($limit)->order('ordering DESC')->all();
        if ($featured) {
            $users = '';
            foreach ($featured as $user) {
                $users[] = (int) $user['user_id'];
            }
            $cond = ['user_id' => ['in' => implode(',', $users)]];
        }
        $users = new Api\User();
        $users->limit(setting('pfu_total_to_feature', 6));
        $users->where($cond);
        // $users->order('RAND()');
        $object->block('core.index-member', 1, $View->render('@PHPfox_FeaturedUsers/block.html', ['users' => $users->get()]));
    });
};