Added : Smarty v3 Support

Added : ClipBUcket v2.7 Templating
This commit is contained in:
Arslan Hassan 2013-11-09 14:20:22 +00:00
parent 10500acfd3
commit adaf341eb4
14 changed files with 94 additions and 36 deletions

View file

@ -5,14 +5,15 @@
<img src="{$imageurl}/dot.gif" class="menu_toggle" alt="Toggle Menu" title="Toggle Menu" onClick="toggle_menu()"/>
{assign var='menu' value = $Cbucket->AdminMenu}
{foreach from=$menu key=name item=menu}
{$menus=$Cbucket->AdminMenu}
{foreach $menus as $name => $menu}
<!-- *********************************Start {$name} Menu****************************** -->
<div class="mainDiv" >
<div class="topItem" >{$name}</div>
<div class="dropMenu" >
<div class="subMenu">
{foreach from=$menu key=sub_menu item=sub_link}
{foreach $menu as $sub_menu => $sub_link}
<div class="subItem"><a href="{$sub_link}">{$sub_menu}</a></div>
{/foreach}
</div>

View file

@ -451,7 +451,9 @@ class ClipBucket
$myquery->set_template($template);
}
//
//$this->smarty_version
$template_details = $cbtpl->get_template_details($template);
$cbtpl->smarty_version = $template_details['smarty_version'];
return $this->template = $template;
}

View file

@ -5,28 +5,48 @@ class CBTemplate {
/**
* Function used to set Smarty Functions
*/
function CBTemplate() {
function init() {
global $Smarty;
if (!isset($Smarty)) {
$Smarty = new Smarty;
$this->load_smarty();
}
}
static function create() {
function load_smarty()
{
global $Smarty;
$Smarty = new Smarty();
if($this->smarty_version < 3)
$Smarty = new Smarty;
else
$Smarty = new SmartyBC;
$Smarty->compile_check = true;
$Smarty->debugging = false;
$Smarty->template_dir = BASEDIR."/styles";
$Smarty->compile_dir = BASEDIR."/cache";
}
function create() {
global $Smarty;
if (!isset($Smarty)) {
$this->load_smarty();
}
return true;
}
function setCompileDir($dir_name) {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
$Smarty->compile_dir = $dir_name;
}
@ -34,15 +54,15 @@ class CBTemplate {
function setType($type) {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
$Smarty->type = $type;
}
static function assign($var, $value) {
function assign($var, $value) {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
$Smarty->assign($var, $value);
}
@ -50,7 +70,7 @@ class CBTemplate {
function setTplDir($dir_name = null) {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
if (!$dir_name) {
$Smarty->template_dir = BASEDIR."/styles/clipbucketblue";
@ -62,7 +82,7 @@ class CBTemplate {
function setModule($module) {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
$Smarty->theme = $module;
$Smarty->type = "module";
@ -71,7 +91,7 @@ class CBTemplate {
function setTheme($theme) {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
$Smarty->template_dir = BASEDIR."/styles/" . $theme;
$Smarty->compile_dir = BASEDIR."/styles/" . $theme;
@ -82,23 +102,23 @@ class CBTemplate {
function getTplDir() {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
return $Smarty->template_dir;
}
static function display($filename) {
function display($filename) {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
$Smarty->display($filename);
}
static function fetch($filename) {
function fetch($filename) {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
return $Smarty->fetch($filename);
}
@ -106,7 +126,7 @@ class CBTemplate {
function getVars() {
global $Smarty;
if (!isset($Smarty)) {
CBTemplate::create();
$this->create();
}
return $Smarty->get_template_vars();
}
@ -155,8 +175,8 @@ class CBTemplate {
preg_match('/<website title="(.*)">(.*)<\/website>/',$content,$website_arr);
/* For 2.7 and Smarty v3 Support */
preg_match('/<min_version>(.*)<\/min_version>/',$content,$version);
preg_match('/<version>(.*)<\/version>/',$content,$version);
preg_match('/<min_version>(.*)<\/min_version>/',$content,$min_version);
preg_match('/<smarty_version>(.*)<\/smarty_version>/',$content,$smarty_version);
$name = $name[1];
@ -164,6 +184,8 @@ class CBTemplate {
$version = $version[1];
$released = $released[1];
$description = $description[1];
$min_version = $min_version[1];
$smarty_version = $smarty_version[1];
$website = array('title'=>$website_arr[1],'link'=>$website_arr[2]);
@ -176,6 +198,8 @@ class CBTemplate {
'description'=>$description,
'website'=>$website,
'dir'=>$temp,
'min_version'=>$min_version,
'smarty_version'=>$smarty_version,
'path'=>TEMPLATEFOLDER.'/'.$temp
);

View file

@ -409,20 +409,21 @@ if(!@$in_bg_cron)
//Checking Website Template
$Cbucket->set_the_template();
include 'plugin.functions.php';
include 'plugins_functions.php';
require BASEDIR.'/includes/templatelib/Template.class.php';
require BASEDIR.'/includes/classes/template.class.php';
require BASEDIR.'/includes/classes/objects.class.php';
require BASEDIR.'/includes/active.php';
$cbtpl = new CBTemplate();
$cbobjects = new CBObjects();
$swfobj = new SWFObject();
//Initializng Userquery class
@ -434,6 +435,21 @@ if(!@$in_bg_cron)
//Setting Up Group Class
$cbgroup->gp_thumb_width = config('grp_thumb_width');
$cbgroup->gp_thumb_height = config('grp_thumb_height');
$Cbucket->set_the_template();
if($cbtpl->smarty_version < 3 )
require BASEDIR.'/includes/templatelib/Template.class.php';
else
{
//require BASEDIR.'/includes/smartyv3/Smarty.class.php';
require BASEDIR.'/includes/smartyv3/SmartyBC.class.php';
}
$cbtpl->init();
require BASEDIR.'/includes/active.php';
Assign('THIS_URL', $thisurl);
@ -612,7 +628,7 @@ $Smarty->register_modifier('SetTime','SetTime');
$Smarty->register_modifier('getname','getname');
$Smarty->register_modifier('getext','getext');
$Smarty->register_modifier('form_val','form_val');
$Smarty->register_modifier('get_from_val','get_from_val');
//$Smarty->register_modifier('get_from_val','get_from_val');
$Smarty->register_modifier('post_form_val','post_form_val');
$Smarty->register_modifier('request_form_val','request_form_val');
$Smarty->register_modifier('get_thumb_num','get_thumb_num');
@ -623,13 +639,13 @@ $Smarty->register_modifier('get_age','get_age');
$Smarty->register_modifier('outgoing_link','outgoing_link');
$Smarty->register_modifier('nicetime','nicetime');
$Smarty->register_modifier('country','get_country');
$Smarty->register_modifier('cbsearch',new cbsearch());
//$Smarty->register_modifier('cbsearch',new cbsearch());
$Smarty->register_modifier('flag_type','flag_type');
$Smarty->register_modifier('get_username','get_username');
$Smarty->register_modifier('formatfilesize','formatfilesize');
$Smarty->register_modifier('getWidth','getWidth');
$Smarty->register_modifier('getHeight','getHeight');
$Smarty->register_modifier('get_collection_name','get_collection_name');
//$Smarty->register_modifier('get_collection_name','get_collection_name');
$Smarty->register_modifier('json_decode','jd');
$Smarty->register_modifier('getGroupPrivacy','getGroupPrivacy');

View file

@ -30,21 +30,22 @@ function Fetch($name,$inside=FALSE)
//Simple Template Displaying Function
function Template($template,$layout=true){
global $admin_area;
global $admin_area,$cbtpl;
if($layout)
CBTemplate::display(LAYOUT.'/'.$template);
$cbtpl->display(LAYOUT.'/'.$template);
else
CBTemplate::display($template);
$cbtpl->display($template);
if($template == 'footer.html' && $admin_area !=TRUE){
CBTemplate::display(BASEDIR.'/includes/templatelib/'.$template);
$cbtpl->display(BASEDIR.'/includes/templatelib/'.$template);
}
if($template == 'header.html'){
CBTemplate::display(BASEDIR.'/includes/templatelib/'.$template);
$cbtpl->display(BASEDIR.'/includes/templatelib/'.$template);
}
}
function Assign($name,$value)
{
CBTemplate::assign($name,$value);
global $cbtpl;
$cbtpl->assign($name,$value);
}

View file

@ -105,6 +105,7 @@ class SmartyBC extends Smarty
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
}
/**
* Unregisters custom function
*

View file

View file

View file

View file

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<template>
<name>ClipBucket 2013 Fall</name>
<author>Fawaz Tahir, Arslan Hassan</author>
<min_version>2.7</min_version>
<smarty_version>3</smarty_version>
<version>1</version>
<released>Fri, 8 November 2013 06:00:00 +0000</released>
<description>ClipBucket v2.7 Theme</description>
<website title="ClipBucket">http://clip-bucket.com</website>
<license>Attribute Assurance License</license>
</template>

View file

@ -6,4 +6,5 @@
<released>Fri, 15 January 2010 06:00:00 +0000</released>
<description>ClipBucket version 2.0 Theme by Fawaz Tahir, Arslan Hassan</description>
<website title="ClipBucket">http://clip-bucket.com</website>
</template>