当前位置: 首页>>代码示例>>PHP>>正文


PHP object::assign方法代码示例

本文整理汇总了PHP中object::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP object::assign方法的具体用法?PHP object::assign怎么用?PHP object::assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在object的用法示例。


在下文中一共展示了object::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Binds template files with a Smarty
  *
  * @author Rafal Wesolowski <wesolowski@nexus-netsoft.com>
  * @param string $sFileName template filename
  * @return void
  */
 public function render($sFileName)
 {
     $sTplPath = dirname(__DIR__) . '/views/page/';
     $this->oSmarty->setTemplateDir($sTplPath);
     $this->oSmarty->assign($this->aData);
     $this->oSmarty->display($sTplPath . $sFileName . '.tpl');
 }
开发者ID:mrsank,项目名称:work_sample,代码行数:14,代码来源:Load.class.php

示例2: smarty_function_help

/**
 * Adds inline help
 *
 * @param array  $params the function params
 * @param object $smarty reference to the smarty object
 *
 * @return string the help html to be inserted
 * @access public
 */
function smarty_function_help($params, &$smarty)
{
    if (!isset($params['id']) || !isset($smarty->_tpl_vars['config'])) {
        return;
    }
    if (empty($params['file']) && isset($smarty->_tpl_vars['tplFile'])) {
        $params['file'] = $smarty->_tpl_vars['tplFile'];
    } elseif (empty($params['file'])) {
        return NULL;
    }
    $params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']);
    if (empty($params['title'])) {
        // Avod overwriting existing vars CRM-11900
        $oldID = $smarty->get_template_vars('id');
        $smarty->assign('id', $params['id'] . '-title');
        $name = trim($smarty->fetch($params['file'] . '.hlp'));
        $additionalTPLFile = $params['file'] . '.extra.hlp';
        if ($smarty->template_exists($additionalTPLFile)) {
            $name .= trim($smarty->fetch($additionalTPLFile));
        }
        $smarty->assign('id', $oldID);
    } else {
        $name = trim(strip_tags($params['title']));
    }
    // Escape for html
    $title = htmlspecialchars(ts('%1 Help', array(1 => $name)));
    // Escape for html and js
    $name = htmlspecialchars(json_encode($name), ENT_QUOTES);
    // Format params to survive being passed through json & the url
    unset($params['text'], $params['title']);
    foreach ($params as &$param) {
        $param = is_bool($param) || is_numeric($param) ? (int) $param : (string) $param;
    }
    return '<a class="helpicon" title="' . $title . '" href="#" onclick=\'CRM.help(' . $name . ', ' . json_encode($params) . '); return false;\'>&nbsp;</a>';
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:44,代码来源:function.help.php

示例3: assign

 /**
  * assigns a Smarty variable.
  *
  * @param array|string $block the template variable name(s)
  * @param mixed $value the value to assign
  * @param boolean $nocache if true any output of this variable will be not cached
  */
 protected function assign($block, $content, $nocache = false)
 {
     if ($this->tpl == null) {
         $this->setRenderer($this->renderer);
     }
     $this->tpl->assign($block, $content, $nocache);
 }
开发者ID:nijal,项目名称:Orion,代码行数:14,代码来源:template.php

示例4: smarty_function_math

/**
 * Smarty {math} function plugin
 *
 * Type:     function<br>
 * Name:     math<br>
 * Purpose:  handle math computations in template<br>
 * @link http://smarty.php.net/manual/en/language.function.math.php {math}
 *          (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param array $params parameters
 * @param object $template template object
 * @return string|null
 */
function smarty_function_math($params, $template)
{
    // be sure equation parameter is present
    if (empty($params['equation'])) {
        trigger_error("math: missing equation parameter",E_USER_WARNING);
        return;
    }

    $equation = $params['equation'];

    // make sure parenthesis are balanced
    if (substr_count($equation,"(") != substr_count($equation,")")) {
        trigger_error("math: unbalanced parenthesis",E_USER_WARNING);
        return;
    }

    // match all vars in equation, make sure all are passed
    preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match);
    $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
                           'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
    
    foreach($match[1] as $curr_var) {
        if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
            trigger_error("math: function call $curr_var not allowed",E_USER_WARNING);
            return;
        }
    }

    foreach($params as $key => $val) {
        if ($key != "equation" && $key != "format" && $key != "assign") {
            // make sure value is not empty
            if (strlen($val)==0) {
                trigger_error("math: parameter $key is empty",E_USER_WARNING);
                return;
            }
            if (!is_numeric($val)) {
                trigger_error("math: parameter $key: is not numeric",E_USER_WARNING);
                return;
            }
            $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
        }
    }
    $smarty_math_result = null;
    eval("\$smarty_math_result = ".$equation.";");

    if (empty($params['format'])) {
        if (empty($params['assign'])) {
            return $smarty_math_result;
        } else {
            $template->assign($params['assign'],$smarty_math_result);
        }
    } else {
        if (empty($params['assign'])){
            printf($params['format'],$smarty_math_result);
        } else {
            $template->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
        }
    }
}
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:72,代码来源:function.math.php

示例5: indexAction

/**
 * Формирование главной страницы
 *
 * @param object $smarty шаблонизатор
 */
function indexAction($smarty)
{
    $rsCategories = getAllMainCatsWithChildren();
    $smarty->assign('pageTitle', 'Главная страница сайта');
    $smarty->assign('rsCategories', $rsCategories);
    loadTemplate($smarty, 'header');
    loadTemplate($smarty, 'index');
    loadTemplate($smarty, 'footer');
}
开发者ID:NickMomchev,项目名称:advancedShop,代码行数:14,代码来源:IndexController.php

示例6: setUp

 /**
  * Initialize the fixture.
  *
  * @return null
  */
 protected function setUp()
 {
     parent::setUp();
     $this->_oAction = oxNew('oxActions');
     $this->_oAction->oxactions__oxtitle = new oxField("test", oxField::T_RAW);
     $this->_oAction->save();
     $this->_oPromo = oxNew('oxActions');
     $this->_oPromo->assign(array('oxtitle' => 'title', 'oxlongdesc' => 'longdesc', 'oxtype' => 2, 'oxsort' => 1, 'oxactive' => 1));
     $this->_oPromo->save();
     //   oxTestModules::addFunction('oxStr', 'setH($h)', '{oxStr::$_oHandler = $h;}');
 }
开发者ID:Crease29,项目名称:oxideshop_ce,代码行数:16,代码来源:oxactionsTest.php

示例7: process

 /**
  * Processes / setups the template
  * assigns all things to the template like mod_srings and app_strings
  *
  */
 function process()
 {
     global $current_language, $app_strings, $sugar_version, $sugar_config, $timedate, $theme;
     $module_strings = return_module_language($current_language, $this->module);
     $this->ss->assign('SUGAR_VERSION', $sugar_version);
     $this->ss->assign('JS_CUSTOM_VERSION', $sugar_config['js_custom_version']);
     $this->ss->assign('VERSION_MARK', getVersionedPath(''));
     $this->ss->assign('THEME', $theme);
     $this->ss->assign('APP', $app_strings);
     $this->ss->assign('MOD', $module_strings);
 }
开发者ID:NALSS,项目名称:SuiteCRM,代码行数:16,代码来源:EditView.php

示例8: _comments_at_email

 /**
  * 留言评论有回复,发邮件通知
  *
  * @author      mrmsl <msl-138@163.com>
  * @date        2013-06-07 17:36:25
  *
  * @param array $info 邮件信息,array('email' => $email, 'subject' => $subject, 'content' => $content)
  *
  * @return true|string true发送成功,否则错误信息
  */
 private function _comments_at_email($info)
 {
     $comment_info = $info['email'];
     $info['email'] = $comment_info['email'];
     $info['mail_type'] = MAIL_TYPE_COMMMENTS_AT_EMAIL;
     $info['subject'] = str_replace('{$comment_name}', $comment_name = $comment_info['comment_name'], $info['subject']);
     $info['content'] = $this->_view_template->assign(array('comment_name' => $comment_name, 'content' => $comment_info['parent_id'] ? str_replace('@<a class="link" href="', '@<a class="link" target="_blank" href="' . substr_replace($comment_info['link_url'], '', strpos($comment_info['link_url'], '#')), $comment_info['content']) : $comment_info['content'], 'link_url' => $comment_info['link_url']))->fetch('Mail', 'comments_at_email');
     $result = $this->doMail($info);
     //C('_FACADE_SKIP', 'skip');
     //$this->_model->table(TB_COMMENTS)->where(array('comment_id' => $comment_info['comment_id']))->save(array('at_email' => true === $result ? MAIL_RESULT_SUCCESS : MAIL_RESULT_FAILURE));
     return $result;
 }
开发者ID:yunsite,项目名称:yablog,代码行数:22,代码来源:Mailer.class.php

示例9: buildQuickForm

 /**
  * Function used to build form element for new contact or select contact widget
  *
  * @param object   $form form object
  * @param int      $blocNo by default it is one, except for address block where it is
  * build for each block
  * @param array    $extrProfiles extra profiles that should be included besides reserved
  *
  * @access public
  *
  * @return void
  */
 static function buildQuickForm(&$form, $blockNo = 1, $extraProfiles = NULL, $required = FALSE, $prefix = '')
 {
     // call to build contact autocomplete
     $attributes = array('width' => '200px');
     $form->add('text', "{$prefix}contact[{$blockNo}]", ts('Select Contact'), $attributes, $required);
     $form->addElement('hidden', "{$prefix}contact_select_id[{$blockNo}]");
     if (CRM_Core_Permission::check('edit all contacts') || CRM_Core_Permission::check('add contacts')) {
         // build select for new contact
         $contactProfiles = CRM_Core_BAO_UFGroup::getReservedProfiles('Contact', $extraProfiles);
         $form->add('select', "{$prefix}profiles[{$blockNo}]", ts('Create New Contact'), array('' => ts('- create new contact -')) + $contactProfiles, FALSE, array('onChange' => "if (this.value) {  newContact{$prefix}{$blockNo}( this.value, {$blockNo}, '{$prefix}' );}"));
     }
     $form->assign('blockNo', $blockNo);
     $form->assign('prefix', $prefix);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:26,代码来源:NewContact.php

示例10: smarty_function_footnotes

/**
 * Smarty function to display footnotes caculated by earlier modifier
 *
 * Example
 *   {footnotes}
 *
 * @param       array       $params      All attributes passed to this function from the template
 * @param       object      $smarty     Reference to the Smarty object
 */
function smarty_function_footnotes($params, $smarty)
{
    // globalise the links array
    global $link_arr;
    $text = '';
    if (is_array($link_arr) && !empty($link_arr)) {
        $text .= '<ol>';
        $link_arr = array_unique($link_arr);
        foreach ($link_arr as $key => $link) {
            // check for an e-mail address
            if (preg_match("/^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$/i", $link)) {
                $linktext = $link;
                $link = 'mailto:' . $link;
                // append base URL for local links (not web links)
            } elseif (!preg_match("/^http:\\/\\//i", $link)) {
                $link = System::getBaseUrl() . $link;
                $linktext = $link;
            } else {
                $linktext = $link;
            }
            $linktext = DataUtil::formatForDisplay($linktext);
            $link = DataUtil::formatForDisplay($link);
            // output link
            $text .= '<li><a class="print-normal" href="' . $link . '">' . $linktext . '</a></li>' . "\n";
        }
        $text .= '</ol>';
    }
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $text);
    } else {
        return $text;
    }
}
开发者ID:rmaiwald,项目名称:core,代码行数:42,代码来源:function.footnotes.php

示例11: smarty_function_isValueChange

/**
 * Smarty function for checking change in a property's value, for example
 * when looping through an array.
 *
 *
 * Smarty param:  string $key     unique identifier for this property (REQUIRED)
 * Smarty param:  mixed  $value   the current value of the property
 * Smarty param:  string $assign  name of template variable to which to assign result
 *
 *
 * @param array $params   template call's parameters
 * @param object $smarty  the Smarty object
 *
 * @return NULL
 */
function smarty_function_isValueChange($params, &$smarty)
{
    static $values = array();
    if (empty($params['key'])) {
        $smarty->trigger_error("Missing required parameter, 'key', in isValueChange plugin.");
        return;
    }
    $is_changed = FALSE;
    if (!array_key_exists($params['key'], $values) || $params['value'] != $values[$params['key']]) {
        // if we have a new value
        $is_changed = TRUE;
        $values[$params['key']] = $params['value'];
        // clear values on all properties added below/after this property
        $clear = FALSE;
        foreach ($values as $k => $dontcare) {
            if ($clear) {
                unset($values[$k]);
            } elseif ($params['key'] == $k) {
                $clear = TRUE;
            }
        }
    }
    if ($params['assign']) {
        $smarty->assign($params['assign'], $is_changed);
    }
    return;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:42,代码来源:function.isValueChange.php

示例12: setup

 /**
  * sets up the search forms, populates the preset values
  * 
  */
 function setup()
 {
     global $mod_strings, $app_strings, $image_path, $app_list_strings, $theme, $timedate;
     $this->xtpl = new XTemplate($this->tpl);
     $this->xtpl->assign("MOD", $mod_strings);
     $this->xtpl->assign("APP", $app_strings);
     $this->xtpl->assign("THEME", $theme);
     $this->xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
     $this->xtpl->assign("USER_DATEFORMAT", '(' . $timedate->get_user_date_format() . ')');
     $this->xtpl->assign("IMAGE_PATH", $image_path);
     foreach ($this->searchFields as $name => $params) {
         if (isset($params['template_var'])) {
             $templateVar = $params['template_var'];
         } else {
             $templateVar = strtoupper($name);
         }
         if (isset($params['value'])) {
             // populate w/ preselected values
             if (isset($params['options'])) {
                 $options = $app_list_strings[$params['options']];
                 if (isset($params['options_add_blank']) && $params['options_add_blank']) {
                     array_unshift($options, '');
                 }
                 $this->xtpl->assign($templateVar, get_select_options_with_id($options, $params['value']));
             } else {
                 if (isset($params['input_type'])) {
                     switch ($params['input_type']) {
                         case 'checkbox':
                             // checkbox input
                             if ($params['value'] == 'on' || $params['value']) {
                                 $this->xtpl->assign($templateVar, 'checked');
                             }
                             break;
                     }
                 } else {
                     // regular text input
                     $this->xtpl->assign($templateVar, to_html($params['value']));
                 }
             }
         } else {
             // populate w/o preselected values
             if (isset($params['options'])) {
                 $options = $app_list_strings[$params['options']];
                 if (isset($params['options_add_blank']) && $params['options_add_blank']) {
                     array_unshift($options, '');
                 }
                 $this->xtpl->assign($templateVar, get_select_options_with_id($options, ''));
             }
         }
     }
     if (!empty($_REQUEST['assigned_user_id'])) {
         $this->xtpl->assign("USER_FILTER", get_select_options_with_id(get_user_array(FALSE), $_REQUEST['assigned_user_id']));
     } else {
         $this->xtpl->assign("USER_FILTER", get_select_options_with_id(get_user_array(FALSE), ''));
     }
     // handle my items only
     if (isset($this->searchFields['current_user_only']) && isset($this->searchFields['current_user_only']['value'])) {
         $this->xtpl->assign("CURRENT_USER_ONLY", "checked");
     }
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:64,代码来源:SearchForm.php

示例13: loadModuleAdminMenu

 /**
  * Function: Creates a pretty menu and navigation bar above your module admin page
  *
  * I've nicked the basis of this from functions.php,v 1.2 of the new Profiles module
  * developed by hyperpod for Xoops V1.2, who in turn based this on Hsalazar's work with Soapbox
  *
  * @version 1
  * @author A Kitson
  * @param int $currentoption The menu option to display as being current
  * @param string $breadcrumb the trail back to where we've come from
  */
 function loadModuleAdminMenu($currentoption = 0, $breadcrumb = '')
 {
     /**
      * @global object $xoopsModule {@link XoopsModule} object for the current module
      */
     global $xoopsModule;
     /**
      * @var array $menuoptions - get the adminmenu variables from the template object (assigned during xoops_cp_header() )
      */
     $menuoptions = $this->tplEngine->get_template_vars('adminmenu');
     /**
      * If the current module has menu links there
      */
     if (isset($menuoptions[$xoopsModule->getVar('mid')])) {
         /**
          * Add the breadcrumb to the links
          */
         $menuoptions[$xoopsModule->getVar('mid')]['breadcrumb'] = $breadcrumb;
         /**
          * Add the currently selected option
          */
         $menuoptions[$xoopsModule->getVar('mid')]['current'] = $currentoption;
         /**
          * Assign the links with additional information to the template object
          */
         $this->tplEngine->assign('modulemenu', $menuoptions[$xoopsModule->getVar('mid')]);
     }
 }
开发者ID:BackupTheBerlios,项目名称:xoops4-svn,代码行数:39,代码来源:theme.php

示例14: __set

 /**
  * Setter
  * @access public
  * @return array Mounts
  */
 public function __set($name, $value)
 {
     if ($name == "SmartyBody") {
         if (is_array($value)) {
             $this->Smarty->assign($value[1]);
             $template_name = $value[0];
         } else {
             $template_name = $value[0];
         }
         $body = $this->Smarty->fetch($template_name);
         preg_match_all("/\\[([A-Za-z0-9]+)([^\\]]*)\\]((.*)\\[\\/\\1\\])?/si", $body, $matches);
         foreach ($matches[0] as $index => $variable) {
             switch ($matches[1][$index]) {
                 case "subject":
                     $this->Subject = $matches[4][$index];
                     break;
                 case "settings":
                     $str = str_replace(' ', '&', trim($matches[2][$index]));
                     parse_str($str, $settings);
                     if ($settings['priority']) {
                         $this->Priority = $settings['priority'];
                     }
                     if ($settings['charset']) {
                         $this->CharSet = $settings['charset'];
                     }
                     break;
             }
             $body = str_replace($matches[0][$index], "", $body);
         }
         $this->Body = trim($body);
         if ($settings['type'] == 'html') {
             $this->AltBody = strip_tags(trim($body));
         }
     }
 }
开发者ID:jasherai,项目名称:libwebta,代码行数:40,代码来源:class.PHPSmartyMailer.php

示例15: renderFile

 /**
  * 解析视图文件
  *
  * @param string $file
  */
 public function renderFile($file)
 {
     // 开启smarty模版引擎后, 实例化smarty对象
     switch (Imp::app()->instance('config')->get('template')) {
         case 'smarty':
             Loader::load('vendor/Imp/Core/Template');
             $smartyObject = new Template();
             $this->smarty = $smartyObject->smarty;
             $this->smarty->assign($this->tpl_var);
             $this->smarty->display($file);
             break;
         default:
             echo $this->readFileContent($file);
             break;
     }
 }
开发者ID:Rgss,项目名称:imp,代码行数:21,代码来源:View.php


注:本文中的object::assign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。