public function parse(ttheme $theme) { $filename = litepublisher::$paths->themes . $theme->name . DIRECTORY_SEPARATOR . 'index.tml'; if (!file_exists($filename)) { return false; } if ($theme->name == 'default') { $this->error('Default theme must be in new format'); } $parser = tthemeparser::i(); $about = $parser->getabout($theme->name); if (empty($about['parent'])) { $this->default = ttheme::getinstance('default'); } else { $this->default = ttheme::getinstance($about['parent']); $theme->parent = $about['parent']; } $s = $parser->getfile($filename, $about); $this->theme = $theme; $theme->templates = $this->default->templates; $theme->title = $this->parsetitle($s); $this->parsemenu($s); $this->parsecontent($s); $theme->templates['sidebars'] = $this->parsesidebars($s); $s = $this->fixhead($s); $s = $this->deletespaces($s); $theme->templates['index'] = $s != '' ? $s : $this->default->templates['index']; return true; }
function installClasses() { litepublisher::$urlmap = turlmap::i(); litepublisher::$urlmap->lock(); $posts = tposts::i(); $posts->lock(); $xmlrpc = TXMLRPC::i(); $xmlrpc->lock(); ttheme::$defaultargs = array(); $theme = ttheme::getinstance('default'); // $html = tadminhtml::i(); // $html->loadinstall(); foreach (litepublisher::$classes->items as $class => $item) { //echo "$class<br>\n"; if (preg_match('/^(titem|titem_storage|titemspostsowner|tcomment|IXR_Client|IXR_Server|tautoform|tchildpost|tchildposts|tlitememcache)$/', $class)) { continue; } $obj = getinstance($class); if (method_exists($obj, 'install')) { $obj->install(); } } $xmlrpc->unlock(); $posts->unlock(); litepublisher::$urlmap->unlock(); }
function auto_convert_themes() { $dir = litepublisher::$paths->home . 'themes4' . DIRECTORY_SEPARATOR; @mkdir($dir, 0777); @chmod($dir, 0777); $list = tfiler::getdir(litepublisher::$paths->themes); sort($list); echo "<pre>\n"; foreach ($list as $name) { echo "{$name} theme:\n"; if ($name == 'default') { continue; } $newdir = $dir . $name; @mkdir($newdir, 0777); @chmod($newdir, 0777); $theme = ttheme::getinstance($name); tthemeparser::compress($theme, $newdir . DIRECTORY_SEPARATOR); } }
public function files_getpost(array $args) { $idpost = (int) $args['idpost']; if (!$this->auth($idpost)) { return $this->forbidden(); } $result = array(); $where = litepublisher::$options->ingroup('editor') ? '' : ' and author = ' . litepublisher::$options->user; $files = tfiles::i(); $result['count'] = (int) ceil($files->db->getcount(" parent = 0 {$where}") / 20); $result['files'] = array(); if ($idpost) { $list = $files->itemsposts->getitems($idpost); if (count($list)) { $items = implode(',', $list); $result['files'] = $files->db->res2items($files->db->query("select * from {$files->thistable} where id in ({$items}) or parent in ({$items})")); } } if (litepublisher::$options->show_file_perm) { $theme = ttheme::getinstance('default'); $result['fileperm'] = tadminperms::getcombo(0, 'idperm_upload'); } return $result; }
public function request($arg) { $this->cache = false; $id = self::getget('id'); $sidebar = self::getget('sidebar'); $this->idurlcontext = self::getget('idurl'); if ($id === false || $sidebar === false || !$this->itemexists($id)) { return $this->error_request('Invalid params'); } $themename = isset($_GET['themename']) ? trim($_GET['themename']) : tview::i(1)->themename; if (!preg_match('/^\\w[\\w\\.\\-_]*+$/', $themename) || !ttheme::exists($themename)) { $themename = tviews::i(1)->themename; } $theme = ttheme::getinstance($themename); try { $result = $this->getwidgetcontent($id, $sidebar); return turlmap::htmlheader(false) . $result; } catch (Exception $e) { return $this->error_request('Cant get widget content'); } }
protected function get_theme_instance($name) { return ttheme::getinstance($name); }
public static function compress(ttheme $theme, $dir = '') { if ($theme->name == 'default') { return false; } $result = ''; if ($dir == '') { $dir = litepublisher::$paths->themes . $theme->name . DIRECTORY_SEPARATOR; } $parent = ttheme::getinstance($theme->parent == '' ? 'default' : $theme->parent); if ($theme->templates['index'] != $parent->templates['index']) { if (file_put_contents($dir . 'index.tml', $theme->templates['index']) === false) { return false; } $result .= '$template = {@import(index.tml)}'; $result .= "\n\n"; } foreach ($theme->templates as $name => $value) { if ($name == 'index') { continue; } if (is_array($value)) { continue; } $value = trim($value); if ($value == trim($parent->templates[$name])) { continue; } if (strend($name, '.date')) { if ($value == '' || $value == litepublisher::$options->dateformat || $value == tlocal::get('datetime', 'dateformat')) { continue; } } $result .= "\$template.{$name} = [{$value}]\n\n"; } for ($i = 0; $i < count($theme->templates['sidebars']); $i++) { $sidebar =& $theme->templates['sidebars'][$i]; $parentsidebar =& $parent->templates['sidebars'][$i]; foreach ($sidebar as $name => $value) { if (is_string($value)) { $value = trim($value); if ($value == trim($parentsidebar[$name])) { continue; } } else { if (count(array_diff_assoc($value, $parentsidebar[$name])) == 0) { continue; } $a = array_map(create_function('$k, $v', 'return "$k=$v";'), array_keys($value), array_values($value)); $value = implode(',', $a); } $result .= $i == 0 ? 'sidebar.' : "sidebar{$i}."; $result .= "{$name} = [{$value}]\n\n"; } } return file_put_contents($dir . 'theme.txt', $result); }
public function congratulation($password) { global $lang; $tml = file_get_contents(litepublisher::$paths->lib . 'install' . DIRECTORY_SEPARATOR . 'install.congratulation.tml'); $theme = ttheme::getinstance('default'); $html = tadminhtml::i(); $html->section = 'installation'; $lang = tlocal::i('installation'); $args = targs::i(); $args->title = litepublisher::$site->name; $args->url = litepublisher::$site->url . '/'; $args->password = $password; $args->likeurl = litepublisher::$options->language == 'ru' ? 'litepublisher.ru' : 'litepublisher.com'; $content = $html->parsearg($tml, $args); $this->echohtml($content); }