PHP Class Smarty, shudong-share Code Examples

This page contains top rated real world PHP examples of class Smarty from package shudong-share extracted from open source projects. You can rate examples to help us improve the quality of examples
Inheritance: extends Smarty_Internal_TemplateBase
Example #1
Show file File: function.filegal_uploader.php Project: rjsmelo/tiki
0
/** filegal_uploader: Adds a widget to the page to upload files
 *
 * @param array $params
 *     'galleryId' => int	file gallery to upload into by default
 *
 * @param Smarty $smarty
 * @return string html
 */
function smarty_function_filegal_uploader($params, $smarty)
{
    $headerlib = TikiLib::lib('header');
    //	Image loader and canvas libs
    $headerlib->add_jsfile('vendor/blueimp/javascript-load-image/js/load-image.all.min.js');
    $headerlib->add_jsfile('vendor/blueimp/javascript-canvas-to-blob/js/canvas-to-blob.min.js');
    //	The Iframe Transport is required for browsers without support for XHR file uploads
    $headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js');
    //	The basic File Upload plugin
    $headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js');
    //	The File Upload processing plugin
    $headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-process.js');
    //	The File Upload image preview & resize plugin
    $headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-image.js');
    //	The File Upload audio preview plugin
    $headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-audio.js');
    //	The File Upload video preview plugin
    $headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-video.js');
    //	The File Upload validation plugin
    $headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-validate.js');
    //	The File Upload user interface plugin
    $headerlib->add_jsfile('vendor/blueimp/jquery-file-upload/js/jquery.fileupload-ui.js');
    // CSS
    $headerlib->add_cssfile('vendor/blueimp/jquery-file-upload/css/jquery.fileupload.css');
    $headerlib->add_cssfile('vendor/blueimp/jquery-file-upload/css/jquery.fileupload-ui.css');
    //	Tiki customised application script
    $headerlib->add_jsfile('lib/jquery_tiki/tiki-jquery_upload.js');
    $return = $smarty->fetch('file/jquery_upload.tpl');
    return $return;
}
Example #2
Show file File: smarty_internal_method_clearcache.php Project: yanlyan/si_ibuhamil
0
 /**
  * Empty cache for a specific template
  *
  * @api  Smarty::clearCache()
  * @link http://www.smarty.net/docs/en/api.clear.cache.tpl
  *
  * @param \Smarty  $smarty
  * @param  string  $template_name template name
  * @param  string  $cache_id      cache id
  * @param  string  $compile_id    compile id
  * @param  integer $exp_time      expiration time
  * @param  string  $type          resource type
  *
  * @return integer number of cache files deleted
  */
 public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
 {
     $smarty->_clearTemplateCache();
     // load cache resource and call clear
     $_cache_resource = Smarty_CacheResource::load($smarty, $type);
     return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time);
 }
Example #3
Show file File: block.copixhtmlheader.php Project: JVS-IS/ICONITO-EcoleNumerique
0
/**
 * Permet au concepteur de template d'ajouter des éléments censés apparaitre dans la partie
 * <head> du template HTML.
 *
 * Params:   kind: string (jsLink, cssLink, style, others, jsCode)
 *
 * @param		array	$params		tableau des paramètres passés à la balise
 * @param		string	$content	contenu du block
 * @param		Smarty	$smarty		pointeur sur l'élement smarty
 * @return		string
 *
 * <code>
 * {copixhtmlheader kind=JsCode}
 * var variable = "{$maVariableValue}";
 * {/copixhtmlheader}
 * </code>
 */
function smarty_block_copixhtmlheader($params, $content, &$smarty)
{
    if (is_null($content)) {
        return;
    }
    //Si aucun type n'a été demandé, on utilise others par défaut.
    $kind = isset($params['kind']) ? strtolower($params['kind']) : 'others';
    $key = isset($params['key']) ? $params['key'] : null;
    $funcName = 'add' . $kind;
    switch ($kind) {
        case 'jscode':
        case 'jsdomreadycode':
        case 'others':
            CopixHTMLHeader::$funcName($content, $key);
            break;
        case 'jslink':
        case 'csslink':
            foreach (array_filter(array_map('trim', explode("\n", $content))) as $line) {
                if (strlen(trim($line)) > 0) {
                    CopixHTMLHeader::$funcName($line);
                }
            }
            break;
        case 'style':
        case 'others':
            CopixHTMLHeader::$funcName($content);
            break;
        default:
            $smarty->_trigger_fatal_error("[plugin copixhtmlheader] unknow kind " . $params['kind'] . ", only jsLink, cssLink, style, others, jsCode are available");
    }
    return '';
}
Example #4
Show file File: block.contentPlaceholderTest.php Project: cargomedia/cm
0
 public function setUp()
 {
     $smarty = new Smarty();
     $render = new CM_Frontend_Render();
     $this->_template = $smarty->createTemplate('string:');
     $this->_template->assignGlobal('render', $render);
 }
Example #5
Show file File: shut_down.php Project: awwthentic1234/hey
0
function compile_CFG($prop)
{
    $smarty = new Smarty();
    $smarty->assign($prop);
    $string = $smarty->fetch(dirname(__FILE__) . '/compile.tpl');
    return $string;
}
Example #6
Show file File: md5demo.php Project: sanplit/huishou
0
 /**
  * 显示登录页(默认Action)
  */
 function doDefault()
 {
     $base = dirname(__FILE__);
     // 初始化smarty
     import('smarty.Smarty');
     $smarty = new Smarty();
     $smarty->template_dir = $this->app->cfg['smarty']['template_dir'];
     $smarty->compile_dir = $this->app->cfg['smarty']['compile_dir'];
     $smarty->config_dir = $this->app->cfg['smarty']['config_dir'];
     $smarty->cache_dir = $this->app->cfg['smarty']['cache_dir'];
     $smarty->debugging = $this->app->cfg['smarty']['debugging'];
     $smarty->caching = $this->app->cfg['smarty']['caching'];
     $smarty->cache_lifetime = $this->app->cfg['smarty']['cache_lifetime'];
     $smarty->left_delimiter = '{<';
     $smarty->right_delimiter = '>}';
     $result = null;
     if (isset($_POST['u']) && isset($_POST['p'])) {
         //$password 是从数据库中读取的用户密码,现在暂定hello
         $password = "hello";
         //计算密码和验证码的md5值
         if (md5($password . $_SESSION['VALIDATE_CODE']) == $_POST['p']) {
             $result = "The result is: right";
         } else {
             $result = "The result is: false";
         }
     }
     $smarty->assign("result", $result);
     $smarty->display($base . "\\md5demo.tpl");
 }
Example #7
Show file File: function.mobile_access_paginator.php Project: NaszvadiG/activecollab_loc
0
/**
 * Render pagination block
 * 
 * Parameters:
 * 
 * - page - current_page
 * - total_pages - total pages
 * - route - route for URL assembly
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_mobile_access_paginator($params, &$smarty)
{
    $url_params = '';
    if (is_foreachable($params)) {
        foreach ($params as $k => $v) {
            if (strpos($k, 'url_param_') !== false && $v) {
                $url_params .= '&amp;' . substr($k, 10) . '=' . $v;
            }
            // if
        }
        // foreach
    }
    // if
    $paginator = array_var($params, 'paginator', new Pager());
    $paginator_url = array_var($params, 'url', ROOT_URL);
    $paginator_anchor = array_var($params, 'anchor', '');
    $smarty->assign(array("_mobile_access_paginator_url" => $paginator_url, "_mobile_access_paginator" => $paginator, '_mobile_access_paginator_anchor' => $paginator_anchor, "_mobile_access_paginator_url_params" => $url_params));
    $paginator_url = strpos($paginator_url, '?') === false ? $paginator_url . '?' : $paginator_url . '&';
    if (!$paginator->isFirst()) {
        $smarty->assign('_mobile_access_paginator_prev_url', $paginator_url . 'page=' . ($paginator->getCurrentPage() - 1) . $url_params . $paginator_anchor);
    }
    // if
    if (!$paginator->isLast()) {
        $smarty->assign('_mobile_access_paginator_next_url', $paginator_url . 'page=' . ($paginator->getCurrentPage() + 1) . $url_params . $paginator_anchor);
    }
    // if
    return $smarty->fetch(get_template_path('_paginator', null, MOBILE_ACCESS_MODULE));
}
Example #8
Show file File: joinus.php Project: ECP-Black/ECP
0
function admin_joinus()
{
    global $db, $countries;
    $tpl = new smarty();
    $db->query('SELECT tname, `joinID`, `name`, b.username, b.email, b.icq, b.msn, `age`, b.country, `teamID`, `comment`, `IP`, `datum`, `closed`, `closedby`, a.username as closedby_username FROM ' . DB_PRE . 'ecp_joinus as b LEFT JOIN ' . DB_PRE . 'ecp_teams ON (teamID = tID) LEFT JOIN ' . DB_PRE . 'ecp_user as a ON (ID=closedby) ORDER BY closed ASC, datum ASC');
    $joinus = array();
    while ($row = $db->fetch_assoc()) {
        $row['datum'] = date(SHORT_DATE, $row['datum']);
        if ($row['joinID'] == (int) @$_GET['id']) {
            $spe = $row;
        }
        $joinus[] = $row;
    }
    if (@$spe) {
        ob_start();
        $tpl1 = new Smarty();
        foreach ($spe as $key => $value) {
            $tpl1->assign($key, $value);
        }
        $tpl1->assign('countryname', $countries[$spe['country']]);
        $tpl1->assign('id', $row['joinID']);
        $tpl1->display(DESIGN . '/tpl/admin/joinus_view.html');
        $tpl->assign('details', ob_get_contents());
        ob_end_clean();
    }
    $tpl->assign('joinus', $joinus);
    ob_start();
    $tpl->display(DESIGN . '/tpl/admin/joinus.html');
    $content = ob_get_contents();
    ob_end_clean();
    main_content(JOINUS, $content, '', 1);
}
Example #9
Show file File: SmartyDynamic.php Project: alachaum/timetrex
0
 function _renderForm(&$page)
 {
     $pageName = $page->getAttribute('name');
     $tabPreview = array_slice($page->controller->_tabs, -2, 1);
     // setup a template object
     $tpl = new Smarty();
     $tpl->template_dir = './templates';
     $tpl->compile_dir = './templates_c';
     // on preview tab, add progress bar javascript and stylesheet
     if ($pageName == $tabPreview[0][0]) {
         $bar = $page->controller->createProgressBar();
         $tpl->assign(array('qf_style' => $bar->getStyle(), 'qf_script' => $bar->getScript()));
         $barElement = $page->getElement('progressBar');
         $barElement->setText($bar->toHtml());
     }
     $renderer = new HTML_QuickForm_Renderer_Array(true);
     $page->accept($renderer);
     $tpl->assign('form', $renderer->toArray());
     // capture the array stucture
     // (only for showing in sample template)
     ob_start();
     print_r($renderer->toArray());
     $tpl->assign('dynamic_array', ob_get_contents());
     ob_end_clean();
     $tpl->display('smarty-dynamic.tpl');
 }
Example #10
Show file File: function.get_favorites.php Project: notzen/exponent-cms
0
/**
 * Smarty {get_favorites} function plugin
 *
 * Type:     function<br>
 * Name:     get_favorites<br>
 * Purpose:  get and assign favorites
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_get_favorites($params, &$smarty)
{
    global $user;
    $uid = empty($params['user_id']) ? $user->id : $params['user_id'];
    $id = empty($params['id']) ? null : $params['id'];
    $smarty->assign($params['assign'], favorites::get($params['module'], $id, $uid));
}
Example #11
Show file File: indexController.php Project: Nykus/xnova
0
 private function __construct()
 {
     $mode = isset($_GET['mode']) ? $_GET['mode'] : false;
     require 'core/models/class.Access.php';
     switch ($mode) {
         case 'login':
             $login = new Access();
             $login->Login();
             break;
         case 'reg':
             if (isset($_POST['faccion'])) {
                 $reg = new Access();
                 $reg->Register();
             } else {
                 $lng = new Lang();
                 $template = new Smarty();
                 $template->assign(array('x_user' => $lng->x_user, 'x_pass' => $lng->x_pass, 'x_email' => $lng->x_email, 'x_registrarme' => $lng->x_registrarme));
                 $template->display('public/registro.xnv');
             }
             break;
         default:
             $lng = new Lang();
             $template = new Smarty();
             $template->assign(array('x_user' => $lng->x_user, 'x_pass' => $lng->x_pass, 'x_recordar' => $lng->x_recordar, 'x_submit' => $lng->x_submit));
             $template->display('public/index.xnv');
             break;
     }
     unset($lng, $template);
 }
Example #12
Show file File: function.oxscript.php Project: Alpha-Sys/oxideshop_ce
0
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File: function.oxscript.php
 * Type: string, html
 * Name: oxscript
 * Purpose: Collect given javascript includes/calls, but include/call them at the bottom of the page.
 *
 * Add [{oxscript add="oxid.popup.load();"}] to add script call.
 * Add [{oxscript include="oxid.js"}] to include local javascript file.
 * Add [{oxscript include="oxid.js?20120413"}] to include local javascript file with query string part.
 * Add [{oxscript include="http://www.oxid-esales.com/oxid.js"}] to include external javascript file.
 *
 * IMPORTANT!
 * Do not forget to add plain [{oxscript}] tag before closing body tag, to output all collected script includes and calls.
 * -------------------------------------------------------------
 *
 * @param array  $params Params
 * @param Smarty $smarty Clever simulation of a method
 *
 * @return string
 */
function smarty_function_oxscript($params, &$smarty)
{
    $isDynamic = isset($smarty->_tpl_vars["__oxid_include_dynamic"]) ? (bool) $smarty->_tpl_vars["__oxid_include_dynamic"] : false;
    $priority = !empty($params['priority']) ? $params['priority'] : 3;
    $widget = !empty($params['widget']) ? $params['widget'] : '';
    $isInWidget = !empty($params['inWidget']) ? $params['inWidget'] : false;
    $output = '';
    if (isset($params['add'])) {
        if (empty($params['add'])) {
            $smarty->trigger_error("{oxscript} parameter 'add' can not be empty!");
            return '';
        }
        $register = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRegistrator');
        $register->addSnippet($params['add'], $isDynamic);
    } elseif (isset($params['include'])) {
        if (empty($params['include'])) {
            $smarty->trigger_error("{oxscript} parameter 'include' can not be empty!");
            return '';
        }
        $register = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRegistrator');
        $register->addFile($params['include'], $priority, $isDynamic);
    } else {
        $renderer = oxNew('OxidEsales\\EshopCommunity\\Core\\ViewHelper\\JavaScriptRenderer');
        $output = $renderer->render($widget, $isInWidget, $isDynamic);
    }
    return $output;
}
Example #13
Show file File: function.public_url.php Project: skullyframework/skully
0
/**
 * @param array $params
 * SSL default behaviour:
 * Decided by current page.
 * Set parameter __ssl to true or false to override default ssl behaviour.
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_public_url($params = array(), &$smarty)
{
    $path = '';
    if (!empty($params['path'])) {
        $path = $params['path'];
        unset($params['path']);
    }
    if (!empty($params['__ssl'])) {
        $ssl = $params['__ssl'];
        unset($params['__ssl']);
    } else {
        $ssl = \Skully\App\Helpers\UrlHelper::isSecure();
    }
    $arguments = array();
    foreach ($params as $key => $val) {
        $arguments[$key] = $val;
    }
    /** @var \Skully\ApplicationInterface $app */
    $app = $smarty->getRegisteredObject('app');
    if (strpos($path, "http://") !== 0 && strpos($path, "https://") !== 0) {
        $path = $app->getTheme()->getPublicBaseUrl($ssl) . $path;
    }
    if (!empty($arguments)) {
        $argumentsStr = http_build_query($arguments);
        return $path . '?' . $argumentsStr;
    } else {
        return $path;
    }
}
Example #14
Show file File: function.optiondisplayer.php Project: notzen/exponent-cms
0
/**
 * Smarty {optiondisplayer} function plugin
 *
 * Type:     function<br>
 * Name:     optiondisplayer<br>
 * Purpose:  display option dropdown list
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_optiondisplayer($params, &$smarty)
{
    global $db;
    $groupname = $params['options'];
    $product = $params['product'];
    $display_price_as = isset($params['display_price_as']) ? $params['display_price_as'] : 'diff';
    // get the option group
    $og = new optiongroup();
    //$group = $og->find('bytitle', $groupname);
    $group = $og->find('first', 'product_id=' . $product->id . ' AND title="' . $groupname . '"');
    //grab the options configured for this product
    $options = $product->optionDropdown($group->title, $display_price_as);
    // if there are no  options we can return now
    if (empty($options)) {
        return false;
    }
    // find the default option if there is one.
    $default = $db->selectValue('option', 'id', 'optiongroup_id=' . $group->id . ' AND is_default=1');
    $view = $params['view'];
    //if((isset() || $og->required == false) $includeblank = $params['includeblank'] ;
    //elseif((isset($params['includeblank']) && $params['includeblank'] == false) || $og->required == true) $includeblank = false;
    $includeblank = $og->required == false && !isset($params['includeblank']) ? gt('-- Please Select an Option --') : $params['includeblank'];
    $template = get_common_template($view, $smarty->getTemplateVars('__loc'), 'options');
    $template->assign('product', $product);
    $template->assign('options', $options);
    $template->assign('group', $group);
    $template->assign('params', $params);
    $template->assign('default', $default);
    $template->assign('includeblank', $includeblank);
    $template->assign('required', $params['required']);
    $template->assign('selected', $params['selected']);
    echo $template->render();
}
Example #15
Show file File: page.php Project: glzaboy/fastlib
0
 /**
  * executes & displays the template results
  *
  * 是否压缩传输默认是开启的,最终还是取决于浏览器和服务器
  *
  * @param $template string
  *            模板文件名
  * @param $return bool
  *            是否返回到php变量
  */
 public function render($tplvar = array(), $template = null)
 {
     header('content-type:text/html;charset=utf-8');
     if ($template == null) {
         $template = FL_PAGE_MOD . '/' . FL_PAGE_ACT;
     }
     $template .= '.html';
     $smarty = new \Smarty();
     $smarty->allow_php_templates = true;
     $smarty->left_delimiter = '{';
     $smarty->right_delimiter = '}';
     // $this->addPluginsDir ( __FASTLIB__ . FastLoad::getplatform ( true ) .
     // '/smarty_plug' ); // 加入PLUG目录
     $smarty->setTemplateDir(FL_PAGE_DIR . '/templates');
     $smarty->setCompileDir(FL_TMP . '/templates_c/' . FL_PAGE_DIR . '/compile');
     $smarty->assign($tplvar);
     // $this->registerFilter ( 'pre', create_function ( '$tplString',
     // 'return strtr($tplString,array(\'<!--{\'=>\'{\',\'}-->\'=>\'}\'));' )
     // );
     // $this->registerFilter ( 'pre', create_function ( '$tplString',
     // 'return
     // preg_replace_callback("/\{{$delimiter}[^\{$delimiter}]+{$delimiter}\}/",
     // array(fasttpl,gettextCompiler), $tplString);' ) );
     if (FL_DEBUG) {
         $smarty->compile_check = true;
         $smarty->caching = false;
     } else {
         $smarty->compile_check = false;
         $smarty->caching = false;
         $smarty->merge_compiled_includes = true;
     }
     $smarty->display($template);
 }
Example #16
Show file File: function.object_subscriptions.php Project: NaszvadiG/activecollab_loc
0
/**
 * Render object subscribers
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_subscriptions($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
    }
    // if
    js_assign('max_subscribers_count', MAX_SUBSCRIBERS_COUNT);
    require_once SYSTEM_MODULE_PATH . '/helpers/function.user_link.php';
    $subscribers = $object->getSubscribers();
    if (count($subscribers) > MAX_SUBSCRIBERS_COUNT) {
        $smarty->assign(array('_object_subscriptions_list_subscribers' => false, '_object_subscriptions_object' => $object, '_object_subscriptions_subscribers_count' => count($subscribers), '_object_subscription_brief' => array_var($params, 'brief', false), '_object_subscriptions_popup_url' => assemble_url('object_subscribers_widget', array('object_id' => $object->getId()))));
    } else {
        $links = null;
        if (is_foreachable($subscribers)) {
            $links = array();
            foreach ($subscribers as $subscriber) {
                $links[] = smarty_function_user_link(array('user' => $subscriber), $smarty);
            }
            // foreach
        }
        // if
        $smarty->assign(array('_object_subscriptions_list_subscribers' => true, '_object_subscriptions' => $subscribers, '_object_subscriptions_object' => $object, '_object_subscription_links' => $links, '_object_subscription_brief' => array_var($params, 'brief', false), '_object_subscriptions_popup_url' => assemble_url('object_subscribers_widget', array('object_id' => $object->getId()))));
    }
    // if
    return $smarty->fetch(get_template_path('_object_subscriptions', 'subscriptions', RESOURCES_MODULE));
}
Example #17
Show file File: form.php Project: sd-studio/sh
0
function send($id)
{
    $form = is_array($id) ? $id : get($id);
    $results = results($id);
    if (!$results) {
        return false;
    }
    if (!is_array($form['template']) || !strlen($form['template']['recipient'])) {
        return false;
    }
    $smarty = new \Smarty();
    $smarty->compile_check = true;
    $smarty->debugging = false;
    foreach ($results as $nm => $val) {
        $smarty->assign($nm, $val);
    }
    $mail = new \PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->Subject = $smarty->fetch('string:' . $form['template']['subject']);
    $addresses = explode(',', $form['template']['recipient']);
    foreach ($addresses as $a) {
        $mail->AddAddress(trim($a));
    }
    $mail->MsgHTML($smarty->fetch('string:' . $form['template']['body']));
    return $mail->Send();
}
Example #18
Show file File: Driver.php Project: samuferenc/codegenerator
0
 public function GenOutput()
 {
     $this->tables = array();
     foreach ($this->codeGenerator->getClasses() as $class) {
         $columns = array();
         if ($class->hasChild()) {
             foreach ($class->getChildElements() as $element) {
                 if ($element->getType() == Type::PropertyElement) {
                     $columnText = $element->getAttribute(self::Column);
                     if ($columnText != null) {
                         $column = $this->getColumnParams(substr($columnText, 1, -1));
                         $column['name'] = $element->getName();
                         $columns[] = $column;
                     }
                 }
             }
             if (count($columns) > 0) {
                 $this->tables[$class->getName()] = array("name" => $class->getName(), "columns" => $columns);
             }
         }
     }
     $smarty = new \Smarty();
     // $smarty->caching = false;
     $smarty->assign("tables", $this->tables);
     $smarty->display(__DIR__ . '/database.tpl');
 }
Example #19
Show file File: function.add_form_element.php Project: nicholasryan/CorePlus
0
/**
 * Render and add a form element to both the PHP session and HTML output.
 *
 * @experimental
 * @param array  $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param Smarty $smarty  Parent Smarty template object
 *
 * @return string
 * @throws SmartyException
 */
function smarty_function_add_form_element($params, $smarty){

	if(!isset($params['form'])){
		$form = null;
	}
	elseif($params['form'] instanceof Form){
		$form = $params['form'];
	}
	elseif($params['form'] instanceof \Core\ListingTable\Table){
		$form = $params['form']->getEditForm();
	}
	else{
		throw new SmartyException('Unsupported value provided for "form", please ensure it is either a valid Form object or omitted completely!');
	}

	$type = isset($params['type']) ? $params['type'] : 'text';

	$element = FormElement::Factory($type, $params);

	if($form){
		$form->addElement($element);
	}

	// Assign or render?
	if(isset($params['assign'])){
		$smarty->assign($params['assign'], $element->render());
	}
	else{
		echo $element->render();
	}
}
Example #20
Show file File: function.securelink.php Project: notzen/exponent-cms
0
/**
 * Smarty {securelink} function plugin
 *
 * Type:     function<br>
 * Name:     securelink<br>
 * Purpose:  create a secure link
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_securelink($params, &$smarty)
{
    /*$loc = $smarty->getTemplateVars('__loc');
    	if (!isset($params['module'])) $params['module'] = $loc->mod;
    	if (!isset($params['src'])) $params['src'] = $loc->src;
    	if (!isset($params['int'])) $params['int'] = $loc->int;
    	
    	$params['expid'] = session_id();
    	*/
    $loc = $smarty->getTemplateVars('__loc');
    if (!isset($params['module'])) {
        $params['module'] = empty($params['controller']) ? $loc->mod : $params['controller'];
    }
    if (!isset($params['src'])) {
        if (expModules::controllerExists($params['module'])) {
            $params['src'] = $loc->src;
        } elseif (@call_user_func(array($loc->mod, 'hasSources'))) {
            $params['src'] = $loc->src;
        }
    }
    if (!isset($params['int'])) {
        $params['int'] = $loc->int;
    }
    echo expCore::makeSecureLink($params);
}
Example #21
Show file File: index_i.php Project: uirapuru/virgoapi
0
function ShowSearchForm(VirgoAPI $api, Smarty $smarty, $lng)
{
    $smarty->assign("ShowSearchForm", true);
    $smarty->assign("provinces", $api->GetInvestmentsProvinces($lng));
    $smarty->assign("categories", $api->GetInvestmentsCategories($lng));
    $smarty->assign("post", $_POST);
}
Example #22
Show file File: smarty_cacheresource.php Project: Aaron-zh/ThinkPHPFull
0
 /**
  * Load Cache Resource Handler
  *
  * @param Smarty $smarty Smarty object
  * @param string $type name of the cache resource
  * @return Smarty_CacheResource Cache Resource Handler
  */
 public static function load(Smarty $smarty, $type = null)
 {
     if (!isset($type)) {
         $type = $smarty->caching_type;
     }
     // try smarty's cache
     if (isset($smarty->_cacheresource_handlers[$type])) {
         return $smarty->_cacheresource_handlers[$type];
     }
     // try registered resource
     if (isset($smarty->registered_cache_resources[$type])) {
         // do not cache these instances as they may vary from instance to instance
         return $smarty->_cacheresource_handlers[$type] = $smarty->registered_cache_resources[$type];
     }
     // try sysplugins dir
     if (isset(self::$sysplugins[$type])) {
         if (!isset(self::$resources[$type])) {
             $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
             self::$resources[$type] = new $cache_resource_class();
         }
         return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
     }
     // try plugins dir
     $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
     if ($smarty->loadPlugin($cache_resource_class)) {
         if (!isset(self::$resources[$type])) {
             self::$resources[$type] = new $cache_resource_class();
         }
         return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
     }
     // give up
     throw new SmartyException("Unable to load cache resource '{$type}'");
 }
Example #23
Show file File: function.hidden.php Project: saiber/livecart
0
/**
 * ...
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty.form
 * @author Integry Systems
 */
function smarty_function_hidden($params, $smarty)
{
    if (empty($params['name'])) {
        $params['name'] = $smarty->getTemplateVars('input_name');
    }
    $formParams = $smarty->_tag_stack[0][1];
    $formHandler = $formParams['handle'];
    $fieldName = $params['name'];
    if (!$formHandler instanceof Form) {
        throw new HelperException('Element must be placed in {form} block');
    }
    if (!empty($formParams['model'])) {
        $params['ng-model'] = $formParams['model'] . '.' . $params['name'];
    }
    $fieldName = $params['name'];
    $output = '<input type="hidden"';
    if (!isset($params['value'])) {
        $params['value'] = $formHandler->get($fieldName);
    }
    foreach ($params as $name => $value) {
        $output .= ' ' . $name . '="' . htmlspecialchars($value, ENT_QUOTES) . '"';
    }
    $output .= " />";
    return $output;
}
Example #24
Show file File: function.date.php Project: nicholasryan/CorePlus
0
/**
 * Take a GMT date and return the formatted string.
 *
 * @todo Finish documentation of smarty_function_date
 *
 * #### Smarty Parameters
 *
 * * date (or unnamed variable)
 * * format
 * * assign
 *
 * #### Example Usage
 *
 * <pre>
 * {date 1234567890}
 * </pre>
 *
 * @param array  $params  Associative (and/or indexed) array of smarty parameters passed in from the template
 * @param Smarty $smarty  Parent Smarty template object
 *
 * @throws SmartyException
 *
 * @return string
 */
function smarty_function_date($params, $smarty){

	if(array_key_exists('date', $params)){
		$date = $params['date'];
	}
	elseif(isset($params[0])){
		$date = $params[0];
	}
	else{
		// Use "now" as the time.
		$date = \Core\Date\DateTime::Now(Time::FORMAT_RFC2822);
	}

	if(!$date){
		if(DEVELOPMENT_MODE){
			return 'Parameter [date] was empty, cowardly refusing to format an empty string.';
		}
		else{
			return '';
		}
	}


	$format = isset($params['format']) ? $params['format'] : \Core\Date\DateTime::RELATIVE;
	//$timezone = isset($params['timezone']) ? $params['timezone'] : Time::TIMEZONE_GMT;

	$coredate = new \Core\Date\DateTime($date);

	if(isset($params['assign']) && $params['assign']){
		$smarty->assign($params['assign'], $coredate->format($format));
	}
	else{
		return $coredate->format($format);
	}
}
Example #25
Show file File: smarty_internal_method_clearallcache.php Project: LEXXiY/devschool
0
 /**
  * Empty cache folder
  *
  * @api  Smarty::clearAllCache()
  * @link http://www.smarty.net/docs/en/api.clear.all.cache.tpl
  *
  * @param \Smarty  $smarty
  * @param  integer $exp_time expiration time
  * @param  string  $type     resource type
  *
  * @return integer number of cache files deleted
  */
 public function clearAllCache(Smarty $smarty, $exp_time = null, $type = null)
 {
     $smarty->_clearTemplateCache();
     // load cache resource and call clearAll
     $_cache_resource = Smarty_CacheResource::load($smarty, $type);
     return $_cache_resource->clearAll($smarty, $exp_time);
 }
Example #26
Show file File: Markdown.php Project: orlov-vo/yii2-markdown
0
 /**
  * Converts markdown into HTML
  *
  * @param string $content
  * @param array  $config . Options to configure MarkdownExtra and smarty
  *  - markdown: array for MarkdownExtra configuration parameters
  *  - smarty: array for SmartyPantsTypographer configuration parameters
  *  - custom: array for Custom configuration parameters
  * @param int    $smartyMode the SmartyPantsTypographer processing mode
  *
  * @return string
  * @throws InvalidConfigException if module not set
  */
 public static function convert($content, $config = [], $smartyMode = self::SMARTYPANTS_ATTR_LONG_EM_DASH_SHORT_EN)
 {
     $module = Config::initModule(Module::classname());
     $output = $content;
     if (strlen($output) > 0) {
         $mdConfig = empty($config['markdown']) ? [] : $config['markdown'];
         $output = static::process($content, $mdConfig);
         if ($module->smartyPants) {
             $smConfig = empty($config['smarty']) ? [] : $config['smarty'];
             $smarty = new SmartyPants($smartyMode);
             foreach ($smConfig as $name => $value) {
                 $smarty->{$name} = $value;
             }
             $output = $smarty->transform($output);
             $cuConfig = empty($config['custom']) ? $module->customConversion : $config['custom'];
             $output = static::customProcess($output, $cuConfig);
         }
         if (is_bool($module->smarty) && $module->smarty || (is_string($module->smarty) || is_callable($module->smarty)) && call_user_func($module->smarty, $module)) {
             $smarty = new \Smarty();
             if ($module->smartyYiiApp) {
                 $smarty->assign('app', Yii::$app);
             }
             if ($module->smartyYiiParams) {
                 $smarty->config_vars = Yii::$app->params;
             }
             $output = $smarty->fetch('string:' . $output, null, null, $module->smartyParams);
         }
     }
     return $output;
 }
Example #27
Show file File: Smarty.php Project: pinepain/ape
0
 public function render(\Ape\Responses\View $response)
 {
     $smarty = new \Smarty();
     // NOTE: it may be a good idea to initialize smarty once and for next fetches just clean it up and reuse
     $smarty->assign($response->data()->all());
     return $smarty->fetch($response->getTemplate());
 }
Example #28
Show file File: function.mobile_access_object_comments.php Project: NaszvadiG/activecollab_loc
0
/**
 * Render comments
 * 
 * Parameters:
 * 
 * - comments - comments that needs to be rendered
 * - page - current_page
 * - total_pages - total pages
 * - counter - counter for comment #
 * - url - base URL for link assembly
 * - parent - parent object
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_mobile_access_object_comments($params, &$smarty)
{
    $url_params = '';
    if (is_foreachable($params)) {
        foreach ($params as $k => $v) {
            if (strpos($k, 'url_param_') !== false && $v) {
                $url_params .= '&amp;' . substr($k, 10) . '=' . $v;
            }
            // if
        }
        // foreach
    }
    // if
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
    }
    // if
    $user = array_var($params, 'user');
    if (!instance_of($user, 'User')) {
        return new InvalidParamError('object', $user, '$user is expected to be an instance of User class', true);
    }
    // if
    $page = array_var($params, 'page', 1);
    $page = (int) array_var($_GET, 'page');
    if ($page < 1) {
        $page = 1;
    }
    // if
    $counter = array_var($params, 'counter', 1);
    $counter = ($page - 1) * $object->comments_per_page + $counter;
    list($comments, $pagination) = $object->paginateComments($page, $object->comments_per_page, $user->getVisibility());
    $smarty->assign(array("_mobile_access_comments_comments" => $comments, "_mobile_access_comments_paginator" => $pagination, "_mobile_access_comments_url" => mobile_access_module_get_view_url($object), "_mobile_access_comments_url_params" => $url_params, "_mobile_access_comments_counter" => $counter, "_mobile_access_comments_show_counter" => array_var($params, 'show_counter', true)));
    return $smarty->fetch(get_template_path('_object_comments', null, MOBILE_ACCESS_MODULE));
}
Example #29
Show file File: helper.php Project: soares289/gojira
0
 function request($class, $proc, $param = array(), $lRet = false)
 {
     $globals = $GLOBALS['globals'];
     $objData = Controller::Call($class, $proc, $globals, $param);
     if (isset($objData->view_file)) {
         $file = $objData->view_file . '.tpl';
     } else {
         $file = $class . '/' . $proc . '.tpl';
     }
     if (is_string($objData)) {
         if ($lRet) {
             return $objData;
         }
         echo $objData;
     } else {
         //if( file_exists( $globals->environment->dir_view . $file ) ){
         $smarty = new Smarty();
         $smarty->setTemplateDir($globals->environment->dir_view);
         $smarty->assign('class', $class);
         $smarty->assign('proc', $proc);
         $smarty->assign('param', $param);
         $smarty->assign('objData', $objData);
         $smarty->assign('tools', $globals->tools);
         $smarty->assign('environment', $globals->environment);
         if ($lRet) {
             return $smarty->fetch($file);
         }
         $smarty->display($file);
     }
 }
Example #30
Show file File: function.radio.php Project: saiber/livecart
0
/**
 * Display radio button
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty.form
 * @author Integry Systems <http://integry.com>
 */
function smarty_function_radio($params, $smarty)
{
    if (empty($params['name'])) {
        $params['name'] = $smarty->getTemplateVars('input_name');
    }
    $formParams = $smarty->_tag_stack[0][1];
    $formHandler = $formParams['handle'];
    if (!$formHandler instanceof Form) {
        throw new HelperException('Element must be placed in {form} block');
    }
    $fieldName = $params['name'];
    if (!empty($formParams['model'])) {
        $params['ng-model'] = $formParams['model'] . '.' . $params['name'];
    }
    // Check permissions
    if ($formParams['readonly']) {
        $params['disabled'] = 'disabled';
    }
    // get checked state
    $formValue = $formHandler->get($fieldName);
    if ($formValue == $params['value'] || empty($formValue) && $params['checked']) {
        $params['checked'] = 'checked';
    }
    $output = '<input type="radio"';
    foreach ($params as $name => $value) {
        $output .= ' ' . $name . '="' . $value . '"';
    }
    $output .= "/>";
    return $output;
}
Frequently Used Methods