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


PHP Pluf::f方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * If the folder name is not provided, it will default to
  * Pluf::f('template_folders')
  * If the cache folder name is not provided, it will default to
  * Pluf::f('tmp_folder')
  *
  * @param string Template name.
  * @param string Template folder paths (null)
  * @param string Cache folder name (null)
  */
 function __construct($template, $folders = null, $cache = null)
 {
     $this->tpl = $template;
     if (null == $folders) {
         $this->folders = Pluf::f('template_folders');
     } else {
         $this->folders = $folders;
     }
     if (null == $cache) {
         $this->cache = Pluf::f('tmp_folder');
     } else {
         $this->cache = $cache;
     }
     if (defined('IN_UNIT_TESTS')) {
         if (!isset($GLOBALS['_PX_tests_templates'])) {
             $GLOBALS['_PX_tests_templates'] = array();
         }
     }
     $this->compiled_template = $this->getCompiledTemplateName();
     $b = $this->compiled_template[1];
     $this->class = 'Pluf_Template_' . $b;
     $this->compiled_template = $this->compiled_template[0];
     if (!class_exists($this->class, false)) {
         if (!file_exists($this->compiled_template) or Pluf::f('debug')) {
             $compiler = new Pluf_Template_Compiler($this->tpl, $this->folders);
             $this->template_content = $compiler->getCompiledTemplate();
             $this->write($b);
         }
         include $this->compiled_template;
     }
 }
开发者ID:burbuja,项目名称:pluf,代码行数:43,代码来源:Template.php

示例2: __construct

 function __construct($exception, $mimetype = null)
 {
     $content = '';
     $admins = Pluf::f('admins', array());
     if (count($admins) > 0) {
         // Get a nice stack trace and send it by emails.
         $stack = Pluf_HTTP_Response_ServerError_Pretty($exception);
         $subject = $exception->getMessage();
         $subject = substr(strip_tags(nl2br($subject)), 0, 50) . '...';
         foreach ($admins as $admin) {
             $email = new Pluf_Mail($admin[1], $admin[1], $subject);
             $email->addTextMessage($stack);
             $email->sendMail();
         }
     }
     try {
         $context = new Pluf_Template_Context(array('message' => $exception->getMessage()));
         $tmpl = new Pluf_Template('500.html');
         $content = $tmpl->render($context);
         $mimetype = null;
     } catch (Exception $e) {
         $mimetype = 'text/plain';
         $content = 'The server encountered an unexpected condition which prevented it from fulfilling your request.' . "\n\n" . 'An email has been sent to the administrators, we will correct this error as soon as possible. Thank you for your comprehension.' . "\n\n" . '500 - Internal Server Error';
     }
     parent::__construct($content, $mimetype);
     $this->status_code = 500;
 }
开发者ID:burbuja,项目名称:pluf,代码行数:27,代码来源:ServerError.php

示例3: save

 /**
  * Save the model in the database.
  *
  * @param bool Commit in the database or not. If not, the object
  *             is returned but not saved in the database.
  * @return Object Model with data set from the form.
  */
 function save($commit = true)
 {
     if (!$this->isValid()) {
         throw new Exception(__('Cannot save the model from an invalid form.'));
     }
     return Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_User::changeEmailDo', array($this->cleaned_data['key']));
 }
开发者ID:burbuja,项目名称:indefero,代码行数:14,代码来源:UserChangeEmail.php

示例4: Pluf_DB_Field_File_Path

/**
 * Returns the path to access the file.
 */
function Pluf_DB_Field_File_Path($field, $method, $model, $args = null)
{
    if (strlen($model->{$field}) != 0) {
        return Pluf::f('upload_path') . '/' . $model->{$field};
    }
    return '';
}
开发者ID:burbuja,项目名称:pluf,代码行数:10,代码来源:File.php

示例5: __construct

 /**
  * @param mixed Values, will be encoded using json_encode
  */
 function __construct($data, $mimetype = null)
 {
     if (null == $mimetype) {
         $mimetype = Pluf::f('mimetype_json', 'application/json') . '; charset=utf-8';
     }
     parent::__construct(json_encode($data), $mimetype);
 }
开发者ID:burbuja,项目名称:pluf,代码行数:10,代码来源:Json.php

示例6: process_request

 /**
  * Process the request.
  *
  * @param Pluf_HTTP_Request The request
  * @return bool false
  */
 function process_request(&$request)
 {
     // Find which language to use. By priority:
     // A session value with 'pluf_language'
     // A cookie with 'pluf_language'
     // The browser information.
     $lang = false;
     if (!empty($request->session)) {
         $lang = $request->session->getData('pluf_language', false);
         if ($lang and !in_array($lang, Pluf::f('languages', array('en')))) {
             $lang = false;
         }
     }
     if ($lang === false and !empty($request->COOKIE[Pluf::f('lang_cookie', 'pluf_language')])) {
         $lang = $request->COOKIE[Pluf::f('lang_cookie', 'pluf_language')];
         if ($lang and !in_array($lang, Pluf::f('languages', array('en')))) {
             $lang = false;
         }
     }
     if ($lang === false) {
         // will default to 'en'
         $lang = Pluf_Translation::getAcceptedLanguage(Pluf::f('languages', array('en')));
     }
     Pluf_Translation::loadSetLocale($lang);
     $request->language_code = $lang;
     return false;
 }
开发者ID:burbuja,项目名称:pluf,代码行数:33,代码来源:Translation.php

示例7: process_response

    /**
     * Process the response of a view.
     *
     * If the status code and content type are allowed, add the
     * tracking code.
     *
     * @param Pluf_HTTP_Request The request
     * @param Pluf_HTTP_Response The response
     * @return Pluf_HTTP_Response The response
     */
    function process_response($request, $response)
    {
        if (!Pluf::f('google_analytics_id', false)) {
            return $response;
        }
        if (!in_array($response->status_code, array(200, 201, 202, 203, 204, 205, 206, 404, 501))) {
            return $response;
        }
        $ok = false;
        $cts = array('text/html', 'text/html', 'application/xhtml+xml');
        foreach ($cts as $ct) {
            if (false !== strripos($response->headers['Content-Type'], $ct)) {
                $ok = true;
                break;
            }
        }
        if ($ok == false) {
            return $response;
        }
        $js = '<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));
</script>
<script type="text/javascript"> try {
var pageTracker = _gat._getTracker("' . Pluf::f('google_analytics_id') . '");
pageTracker._trackPageview(); } catch(err) {}
</script>';
        $response->content = str_replace('</body>', $js . '</body>', $response->content);
        return $response;
    }
开发者ID:burbuja,项目名称:pluf,代码行数:40,代码来源:GoogleAnalytics.php

示例8: testAddPrefixedViews

 public function testAddPrefixedViews()
 {
     $res = Pluf_Dispatcher::addPrefixToViewFile('/alternate', Pluf::f('app_views'));
     $this->assertEquals('#^/alternate/$#', $res[0]['regex']);
     $this->assertEquals('Todo_Views', $res[0]['model']);
     $this->assertEquals('#^/alternate/install/$#', $res[1]['regex']);
 }
开发者ID:burbuja,项目名称:pluf,代码行数:7,代码来源:PlufDispatcherTest.php

示例9: __construct

 function __construct($request, $vars = array())
 {
     $vars = array_merge(array('request' => $request), $vars);
     foreach (Pluf::f('template_context_processors', array()) as $proc) {
         Pluf::loadFunction($proc);
         $vars = array_merge($proc($request), $vars);
     }
     $params = array('request' => $request, 'context' => $vars);
     /**
      * [signal]
      *
      * Pluf_Template_Context_Request::construct
      *
      * [sender]
      *
      * Pluf_Template_Context_Request
      *
      * [description]
      *
      * This signal allows an application to dynamically modify the
      * context array.
      *
      * [parameters]
      *
      * array('request' => $request,
      *       'context' => array());
      *
      */
     Pluf_Signal::send('Pluf_Template_Context_Request::construct', 'Pluf_Template_Context_Request', $params);
     $this->_vars = new Pluf_Template_ContextVars($params['context']);
 }
开发者ID:burbuja,项目名称:pluf,代码行数:31,代码来源:Request.php

示例10: url

 public static function url($file = '')
 {
     if ($file !== '' && Pluf::f('last_update_file', false) && false !== ($last_update = Pluf::fileExists(Pluf::f('last_update_file')))) {
         $file = $file . '?' . substr(md5(filemtime($last_update)), 0, 5);
     }
     return Pluf::f('url_media', Pluf::f('app_base') . '/media') . $file;
 }
开发者ID:burbuja,项目名称:pluf,代码行数:7,代码来源:MediaUrl.php

示例11: setUp

 function setUp()
 {
     $GLOBALS['_PX_config']['log_delayed'] = false;
     Pluf_Log::$level = Pluf_Log::ALL;
     Pluf_Log::$stack = array();
     $this->logfile = Pluf::f('pluf_log_file', Pluf::f('tmp_folder', '/tmp') . '/pluf.log');
     @unlink($this->logfile);
 }
开发者ID:burbuja,项目名称:pluf,代码行数:8,代码来源:TestLog.php

示例12: setUp

 protected function setUp()
 {
     Pluf::start(dirname(__FILE__) . '/../conf/pluf.config.php');
     Pluf::loadFunction('Pluf_HTTP_URL_buildReverseUrl');
     Pluf::loadFunction('Pluf_HTTP_URL_reverse');
     $d = new Pluf_Dispatcher();
     $d->loadControllers(Pluf::f('app_views'));
 }
开发者ID:burbuja,项目名称:pluf,代码行数:8,代码来源:PlufHTTPURLTest.php

示例13: Pluf_DB_getConnection

/**
 * Get the default DB connection.
 *
 * The default database connection is defined in the configuration file
 * through the following configuration variables:
 * - db_login : Login to connect to the database
 * - db_password : Password to the database
 * - db_server : Name of the server
 * - db_database : Name of the database
 * - db_table_prefix : Prefix for the table names
 * - db_version : Version of the database engine
 * - db_engine : Engine for exampe 'MySQL', 'SQLite'
 *
 * Once the first connection is created the following calls to Pluf::db()
 * are getting the same connection.
 *
 */
function Pluf_DB_getConnection($extra = null)
{
    if (isset($GLOBALS['_PX_db']) && (is_resource($GLOBALS['_PX_db']->con_id) or is_object($GLOBALS['_PX_db']->con_id))) {
        return $GLOBALS['_PX_db'];
    }
    $GLOBALS['_PX_db'] = Pluf_DB::get(Pluf::f('db_engine'), Pluf::f('db_server'), Pluf::f('db_database'), Pluf::f('db_login'), Pluf::f('db_password'), Pluf::f('db_table_prefix'), Pluf::f('debug'), Pluf::f('db_version'));
    return $GLOBALS['_PX_db'];
}
开发者ID:burbuja,项目名称:pluf,代码行数:25,代码来源:DB.php

示例14: preDelete

 /**
  * Predelete to drop the row level permissions.
  */
 function preDelete()
 {
     if (Pluf::f('pluf_use_rowpermission', false)) {
         $_rpt = Pluf::factory('Pluf_RowPermission')->getSqlTable();
         $sql = new Pluf_SQL('owner_class=%s AND owner_id=%s', array($this->_a['model'], $this->_data['id']));
         $this->_con->execute('DELETE FROM ' . $_rpt . ' WHERE ' . $sql->gen());
     }
 }
开发者ID:burbuja,项目名称:pluf,代码行数:11,代码来源:Group.php

示例15: slugify

 /**
  * Return a "URL friendly" version in lowercase.
  * 
  * Define the words separator with the configuration 
  * option <code>slug-separator</code>. Default to <code>-</code>.
  *
  * @param $value string Value to convert
  * @return string The slugify version.
  */
 public static function slugify($value)
 {
     $separator = Pluf::f('slug-separator', '-');
     $value = Pluf_Text_UTF8::romanize(Pluf_Text_UTF8::deaccent($value));
     $value = preg_replace('#[^' . $separator . '\\w]#u', $separator, mb_strtolower($value, Pluf::f('encoding', 'UTF-8')));
     // remove redundant
     $value = preg_replace('#' . $separator . '{2,}#u', $separator, trim($value, $separator));
     return $value;
 }
开发者ID:burbuja,项目名称:pluf,代码行数:18,代码来源:Slug.php


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