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


PHP Pluf类代码示例

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


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

示例1: __construct

 /**
  * Construct the constructor with a default condition.
  */
 function __construct($base = '', $args = array())
 {
     $this->db = Pluf::db();
     if (strlen($base) > 0) {
         $this->Q($base, $args);
     }
 }
开发者ID:burbuja,项目名称:pluf,代码行数:10,代码来源:SQL.php

示例2: getItem

 /**
  * Get an item to process.
  *
  * @return mixed False if no item to proceed.
  */
 public static function getItem()
 {
     $item = false;
     $db = Pluf::db();
     $db->begin();
     // In a transaction to not process the same item at
     // the same time from to processes.
     $gqueue = new Pluf_Queue();
     $items = $gqueue->getList(array('filter' => $db->qn('lock') . '=0', 'order' => 'creation_dtime ASC'));
     if ($items->count() > 0) {
         $item = $items[0];
         $item->lock = 1;
         $item->update();
     }
     $db->commit();
     if ($item === false) {
         return false;
     }
     // try to get the corresponding object
     $obj = Pluf::factory($item->model_class, $item->model_id);
     if ($obj->id != $item->model_id) {
         $obj = null;
     }
     return array('queue' => $item, 'item' => $obj);
 }
开发者ID:burbuja,项目名称:pluf,代码行数:30,代码来源:Processor.php

示例3: __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

示例4: 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

示例5: 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

示例6: __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

示例7: __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

示例8: 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

示例9: formField

 /**
  * Get the form field for this field.
  *
  * We put this method at the field level as it allows us to easily
  * create a new DB field and a new Form field and use them without
  * the need to modify another place where the mapping would be
  * performed.
  *
  * @param array Definition of the field.
  * @param string Form field class.
  */
 function formField($def, $form_field = 'Pluf_Form_Field_Varchar')
 {
     Pluf::loadClass('Pluf_Form_BoundField');
     // To get mb_ucfirst
     $defaults = array('required' => !$def['blank'], 'label' => mb_ucfirst($def['verbose']), 'help_text' => $def['help_text']);
     unset($def['blank'], $def['verbose'], $def['help_text']);
     if (isset($def['default'])) {
         $defaults['initial'] = $def['default'];
         unset($def['default']);
     }
     if (isset($def['choices'])) {
         $defaults['widget'] = 'Pluf_Form_Widget_SelectInput';
         if (isset($def['widget_attrs'])) {
             $def['widget_attrs']['choices'] = $def['choices'];
         } else {
             $def['widget_attrs'] = array('choices' => $def['choices']);
         }
     }
     foreach (array_keys($def) as $key) {
         if (!in_array($key, array('widget', 'label', 'required', 'multiple', 'initial', 'choices', 'widget_attrs'))) {
             unset($def[$key]);
         }
     }
     $params = array_merge($defaults, $def);
     return new $form_field($params);
 }
开发者ID:burbuja,项目名称:pluf,代码行数:37,代码来源:Field.php

示例10: 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

示例11: __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

示例12: testFullRender

 public function testFullRender()
 {
     $renderer = Pluf::factory('Pluf_Text_Wiki_Renderer');
     $string = file_get_contents(dirname(__FILE__) . '/wikisample.txt');
     $render = file_get_contents(dirname(__FILE__) . '/wikisample.render.txt');
     $this->assertEquals($render, $renderer->render($string));
 }
开发者ID:burbuja,项目名称:pluf,代码行数:7,代码来源:PlufTextWikiTest.php

示例13: 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

示例14: 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

示例15: current

 /**
  * Get the current item.
  */
 public function current()
 {
     $i = current($this->results);
     $doc = Pluf::factory($i['model_class'], $i['model_id']);
     $doc->_searchScore = $i['score'];
     return $doc;
 }
开发者ID:burbuja,项目名称:pluf,代码行数:10,代码来源:ResultSet.php


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