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


PHP Pimple::instance方法代码示例

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


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

示例1: instance

 /**
  *
  * @return Pimple
  */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:11,代码来源:Pimple.php

示例2: minify

 public static function minify($filename)
 {
     require_once Pimple::instance()->getRessource('lib/minify/min/lib/Minify/CSS.php');
     require_once Pimple::instance()->getRessource('lib/minify/min/lib/Minify/CSS/Compressor.php');
     $isPimple = String::StartsWith($filename, Pimple::instance()->getBaseDir());
     $base = dirname($isPimple ? substr($filename, strlen(Pimple::instance()->getBaseDir() . 'www/')) : substr($filename, strlen(Pimple::instance()->getSiteDir()))) . '/';
     $base = $isPimple ? Settings::get(Pimple::URL) . $base : Url::basePath() . $base;
     return Minify_CSS::minify(String::normalize(file_get_contents($filename), false), array('prependRelativePath' => $base));
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:9,代码来源:Stylesheet.php

示例3: tagJson

 protected function tagJson($attrs)
 {
     require_once Pimple::instance()->getRessource('lib/Zend/Json.php');
     $value = $attrs->value;
     if ($attrs->striptags) {
         $value = ArrayUtil::stripValues($value);
     }
     $result = Zend_Json::encode($value);
     return $result;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:10,代码来源:JavascriptTagLib.php

示例4: client

 /**
  *
  * @return couchClient
  */
 public static function client()
 {
     if (self::$_client == null) {
         $basepath = Pimple::instance()->getRessource('lib/phponcouch/');
         require_once "{$basepath}/couch.php";
         require_once "{$basepath}/couchAdmin.php";
         require_once "{$basepath}/couchClient.php";
         require_once "{$basepath}/couchDocument.php";
         require_once "{$basepath}/couchReplicator.php";
         self::$_client = new couchClient(Settings::get(self::URL), Settings::get(self::NAME));
     }
     return self::$_client;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:17,代码来源:CouchDb.php

示例5: append

 public static function append(MPdf $pdf, $template, $data, $containerViewFile = null)
 {
     require_once Pimple::instance()->getRessource('lib/mpdf50/mpdf.php');
     if ($containerViewFile) {
         $container = new View($containerViewFile);
     }
     $view = new View($template);
     if (!is_array($data)) {
         $data = ArrayUtil::fromObject($data);
     }
     $cData = $data;
     $cData['body'] = $view->render($data);
     $css = "";
     if ($container) {
         $html = $container->render($cData);
         self::readCss($pdf, $container);
     } else {
         $html = $cData['body'];
     }
     self::readCss($pdf, $view);
     $pdf->WriteHTML($html);
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:22,代码来源:Pdf.php

示例6: tagWizard

 /**
  * Renders a wizard section. Each wizard section must be defined in the controller and a wizard section must 
  * corrospond to a method in the controller
  * @param string id | id of the section
  * @container
  */
 protected function tagWizard($attrs)
 {
     $current = Pimple::instance()->getAction();
     $w = Wizard::get($attrs->id);
     if ($w) {
         $cs = $w->getStep($current);
     }
     if ($cs) {
         $title = '<ul class="horizontal divided">';
         $before = true;
         foreach ($w->getSteps() as $s) {
             if ($s->getId() == $current) {
                 $title .= sprintf('<li class="active">%s</li>', $s->getTitle());
                 $before = false;
             } else {
                 $add = '';
                 if ($before) {
                     $add = ' class="done"';
                 }
                 if ($cs->canJumpTo($s->getId())) {
                     $title .= sprintf('<li%s><a href="%s">%s</a></li>', $add, Url::makeLink(Pimple::instance()->getController(), $s->getId()), $s->getTitle());
                 } else {
                     $title .= sprintf('<li%s>%s</li>', $add, $s->getTitle());
                 }
             }
         }
         $title .= '</ul>';
         return sprintf('<div class="panel wizard %s"><h2>%s<strong>' . T('Step %s of %s', $cs->getStep(), $w->getNumSteps()) . '</strong></h2>%s</div>', $attrs->class, $title, $this->body());
     } else {
         return sprintf('<div class="panel">%s</div>', $this->body());
     }
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:38,代码来源:WidgetTagLib.php

示例7: getInternalCssFiles

 public function getInternalCssFiles()
 {
     $nodes = $this->getNodeTree()->getElementsByTagNameNS('p', 'stylesheet');
     $files = array();
     foreach ($nodes as $node) {
         if ($node->getAttribute('local') == 'false') {
             $base = Pimple::instance()->getBaseDir() . 'www/';
         } else {
             $base = Pimple::instance()->getSiteDir();
         }
         $path = $node->getAttribute('path');
         if (String::StartsWith($path, "http://") || String::StartsWith($path, "https://")) {
             $base = '';
         }
         $files[] = $base . $path;
     }
     return $files;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:18,代码来源:View.php

示例8: rtrim

//Load pimple
if ($_SERVER['PIMPLE_PATH']) {
    require_once rtrim($_SERVER['PIMPLE_PATH'], '/') . '/bootstrap.php';
} elseif ($_ENV['PIMPLE_PATH']) {
    require_once rtrim($_ENV['PIMPLE_PATH'], '/') . '/bootstrap.php';
} else {
    die('PIMPLE_PATH NOT FOUND');
}
//Set url to pimple/www/
Settings::set(Pimple::URL, '/pimple/');
require_once 'CouchDb.php';
require_once 'model/SessionModel.php';
require_once 'model/UserModel.php';
require_once 'service/UserService.php';
require_once 'service/ProjectService.php';
//Check for local config file (db settings etc.)
if (isset($_SERVER['HOME']) && !isset($_ENV['HOME'])) {
    $_ENV['HOME'] = $_SERVER['HOME'];
}
$localconfig = $_ENV['HOME'] . '/.pimple/scrumbanana.php';
if (isset($_ENV['HOME']) && file_exists($localconfig)) {
    require_once $localconfig;
}
Pimple::instance()->setSiteName('ScrumBanana.com');
Settings::set(Mail::FROM_NAME, 'ScrumBanana.com');
//Overrule all mails to send to this address - if debug is enabled
Settings::set(Mail::TEST_MAIL, 'scrumbanana@mailinator.com');
//Default date formats
Settings::set(Date::DATE_FORMAT, 'd.m.Y');
Settings::set(Date::DATETIME_FORMAT, 'd.m.Y H:i:s');
Settings::set(Date::TIME_FORMAT, 'H:i:s');
开发者ID:hofmeister,项目名称:ScrumBanana.com,代码行数:31,代码来源:settings.php

示例9: asCSV

 protected function asCSV($array, $firstRowHeader = true, $seperator = ';')
 {
     $this->setSkipView(true);
     header('Content-type: text/csv');
     if ($firstRowHeader) {
         $cols = array();
         foreach ($array[0] as $colName => $val) {
             $cols[] = $colName;
         }
         echo implode($seperator, $cols) . chr(10);
     }
     for ($i = 0; $i < count($array); $i++) {
         $vals = array();
         foreach ($array[$i] as $val) {
             $vals[] = $val;
         }
         echo implode($seperator, $vals) . chr(10);
     }
     echo $value;
     Pimple::instance()->end();
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:21,代码来源:Controller.php

示例10: refresh

 public static function refresh()
 {
     Pimple::instance()->save();
     header(sprintf('Location: %s', self::current()));
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:5,代码来源:Url.php

示例11: define

require_once 'lib/controller/PimpleController.php';
//Handlers
require_once 'lib/handlers/MessageHandler.php';
require_once 'lib/handlers/SessionHandler.php';
require_once 'lib/handlers/AccessHandler.php';
//Main class
require_once 'lib/Pimple.php';
require_once 'lib/TagLib.php';
require_once 'lib/taglib/CoreTagLib.php';
require_once 'lib/taglib/ValueTagLib.php';
require_once 'lib/taglib/BasicTagLib.php';
require_once 'lib/taglib/FormTagLib.php';
require_once 'lib/taglib/WidgetTagLib.php';
require_once 'lib/taglib/JavascriptTagLib.php';
require_once 'lib/taglib/UserTagLib.php';
require_once 'lib/taglib/JSTemplateTagLib.php';
//Add pimple lib to include path
IncludePath::instance()->addPath(Pimple::instance()->getBaseDir() . '/lib');
//Add pimple ressources lib to include path
IncludePath::instance()->addPath(Pimple::instance()->getRessource('lib/'), 1);
define('CACHEDIR', Dir::normalize(BASEDIR) . 'cache');
Dir::ensure(CACHEDIR);
Pimple::instance()->registerTagLib('c', new CoreTagLib());
Pimple::instance()->registerTagLib('val', new ValueTagLib());
Pimple::instance()->registerTagLib('p', new BasicTagLib());
Pimple::instance()->registerTagLib('user', new UserTagLib());
Pimple::instance()->registerTagLib('f', new FormTagLib());
Pimple::instance()->registerTagLib('w', new WidgetTagLib());
Pimple::instance()->registerTagLib('js', new JavascriptTagLib());
Pimple::instance()->registerTagLib('jst', new JSTemplateTagLib());
开发者ID:hofmeister,项目名称:Pimple,代码行数:30,代码来源:bootstrap.php

示例12: define

<?php

define('BASEURL', dirname($_SERVER['SCRIPT_NAME']) . '/');
require_once 'settings.php';
//Init session
SessionHandler::instance()->setSessionKey('SCRUMSID');
SessionHandler::instance()->setSession(new SessionModel());
SessionHandler::instance()->setExpires(3600 * 24 * 7);
SessionHandler::instance()->init();
//Init pimple
Pimple::instance()->run();
开发者ID:hofmeister,项目名称:ScrumBanana.com,代码行数:11,代码来源:bootstrap.php

示例13: _use

 public static function _use($zendClass)
 {
     require_once Pimple::instance()->getRessource('lib/' . str_replace('_', '/', $zendClass) . '.php');
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:4,代码来源:Zend.php

示例14: formElementContainer

 /**
  * Render form element container
  *
  * @param string id | Id of input element
  * @param string label | the label of the field
  * @param string help  | help text for this field
  * @param string instructions | intructions on how to fill out field
  * @param string description | Description of the field / value
  * @param string name | name of the input element
  * @param string cClass | CSS class to apply to form element container
  * @param string cStyle | CSS styles to apply to form element container
  * @param string eClass | CSS class to apply to div element
  * @param string eStyle | CSS styles to apply to div element
  * @param boolean readonly | make field readonly (defaults to false)
  * @param boolean disabled | make field disabled (defaults to false)
  * @param boolean simple | Makes the field behave more as a std html input field (defaults to false)
  * @param boolean composit | Render the field with label, input and instructions (defaults to true)
  * @param boolean small | render field without label and instructions (defaults to false)
  * @param boolean nolabel | render field without label (defaults to false)
  * @param boolean noinstructions | render field without instructions (defaults to false)
  */
 private function formElementContainer($formElement, $attrs)
 {
     $classes = array();
     $elmClasses = explode(' ', $attrs->eClass);
     $errorMessages = array();
     $errors = array();
     $classes[] = 'line';
     if ($attrs->simple) {
         $attrs->composit = 'false';
         $classes[] = 'simple';
     }
     if ($attrs->small || $attrs->composit == 'false') {
         //Remove small attr...
         $attrs->nolabel = true;
         $attrs->noinstructions = true;
     } else {
         $classes[] = 'composit';
     }
     $label = $attrs->label;
     $help = $attrs->help;
     $validators = Pimple::instance()->getControllerInstance()->getFieldValidation($attrs->name);
     $hasValidators = $attrs->readonly != 'true' && !$attrs->disabled && count($validators) > 0;
     if ($hasValidators) {
         if (String::EndsWith($attrs->name, '[]')) {
             $i = Util::count($attrs->name);
             $fieldName = str_replace('[]', "[{$i}]", $attrs->name);
         } else {
             $fieldName = $attrs->name;
         }
         $errors = Validate::getFieldErrors($fieldName);
         if (!$errors) {
             $errors = array();
         }
         $classes[] = 'v-enabled';
         foreach ($validators as $validator) {
             $errorMessages[] = sprintf('<div style="display:none;" class="error-%s">%s</div>', current(explode('[', $validator)), Validate::getValidator($validator)->getError());
             $classes[] = "v-{$validator}";
         }
         if (in_array('required', $validators)) {
             $info = T('This field is required');
             if (!$attrs->help) {
                 $attrs->help = $info;
             }
             if ($label) {
                 $label .= sprintf('<span class="required" title="%s">*</span>', $info);
             }
         }
     }
     if ($attrs->cClass) {
         $classes[] = $attrs->cClass;
     }
     unset($attrs->cClass);
     $hasInstructions = ($attrs->help || $hasValidators || count($errors) > 0) && !$attrs->noinstructions;
     unset($attrs->noinstructions);
     if (!$hasInstructions && !$attrs->instructions) {
         $classes[] = 'no-instructions';
     }
     if ($attrs->nolabel) {
         $classes[] = 'no-label';
     }
     if (count($errors) > 0) {
         $classes[] = 'error';
     } else {
         if ($attrs->name && Validate::isFieldValid($attrs->name)) {
             $classes[] = 'valid';
         }
     }
     $output = '<div class="form-item ' . implode(' ', $classes) . '"';
     if ($attrs->cStyle) {
         $output .= sprintf(' style="%s" ', $attrs->cStyle);
     }
     $output .= '>';
     $label = trim($label);
     if (!$label && (!$attrs->simple && $attrs->composit != 'false')) {
         $label = '&nbsp;';
     }
     if ($label) {
         if (!$attrs->nolabel || $attrs->small || $attrs->composit == 'false') {
             if ($attrs->id) {
//.........这里部分代码省略.........
开发者ID:hofmeister,项目名称:Pimple,代码行数:101,代码来源:FormTagLib.php

示例15: toPHP

    public function toPHP($filename = null) {
        
        if ($this->getTag() == 'phtml') {
            $result =  $this->getInnerPHP();
            if ($filename)
                file_put_contents($filename,$result);
            return $result;
        }
            

        $str = "<";
        $method = false;
        
        $tagName = '';


        if ($this->getNs()) {
            $method = true;
            $str = '<?=$'.$this->getNs().'->callTag("'.$this->getTag().'",';
        } else {
            $str .= $this->getTag();
        }

        
        if (count($this->getAttrs()) > 0) {
            if ($method)
                $str .= 'array(';
            else
                $str .= ' ';
            foreach($this->getAttrs() as $name=>$val) {
                if ($method)
                    $str .= sprintf('"%s"=>%s,',$name,$this->processAttrValue($val));
                else
                    $str .= sprintf('%s="%s" ',$name,$val);
            }
            if ($method)
                $str = trim($str,',').'),';
            else
                $str = trim($str);
        } else if ($method) {
            $str .= 'array(),';
        }
        if ($this->isContainer()) {

            if (!$method)
                $str .= '>';
            else
                $body = '';
            
            if ($method)
                $body .= $this->getInnerPHP();
            else
                $str .= $this->getInnerPHP();
            
            if ($method) {
                $taglibs = Pimple::instance()->getTagLibs();
                if ($taglibs[$this->getNs()] && $taglibs[$this->getNs()]->isPreprocess()) {
                    $tag = $this->getTag();
                    $str = $taglibs[$this->getNs()]->callTag($tag,$this->getAttrs(),$body);
                } else {
                    if (preg_match('/\%\{/',$body) || (preg_match('/<\?/',$body) && preg_match('/\$[A-Z]+\-\>[A-Z]+\(/is',$body))) {
                        //Body contains tags...
                        if (false && version_compare(PHP_VERSION, '5.3.0', '>=')) {
                            //If in PHP 5.3 or higher - use closures
                            $closure = sprintf('function() use (&$view,&$data) {extract($view->taglibs);ob_start();?>%s<? return ob_get_clean();}',$body);;
                            $str .= sprintf('%s,$view);?>',$closure);
                        } else {
                            $closureName = self::getNextClosure();
                            $str .= sprintf('new %s($view),$view);?>',$closureName);
                            self::$prepend .= chr(10).sprintf('<?
                                            //%1$s closure start
                                            if (!class_exists("%2$s")) {
                                                class %2$s extends PhtmlClosure {
                                                public function closure() {
                                                $view = $this->view;
                                                $data = $this->view->data;
                                                if (is_array($this->view->data)) {
                                                    extract($this->view->data);
                                                }
                                                $libs = $this->view->taglibs;
                                                extract($libs);
                                                ?>%3$s<?
                                                }}
                                            }
                                            //%1$s closure end
                                            ?>'.chr(10),$this->getTag(),$closureName,$body);
                        }
                        
                    } else {
                        $str .= sprintf('ob_get_clean(),$view);?>',$closureName);
                        $str = '<? ob_start();?>'."\n$body\n".$str;
                        
                    }
                }
                
            } else
                $str .= sprintf("</%s>",$this->getTag());
        } else {
            if ($method) {
                if ($taglibs[$this->getNs()] && $taglibs[$this->getNs()]->isPreprocess()) {
//.........这里部分代码省略.........
开发者ID:hofmeister,项目名称:Pimple,代码行数:101,代码来源:Phtml.php


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