示例#1
0
 function generateOptions(&$xml)
 {
     $this->values = array();
     $html = '';
     foreach ($xml->option as $option) {
         $v = N2XmlHelper::getAttribute($option, 'value');
         $image = N2Uri::pathToUri($v);
         $selected = $this->isSelected($v);
         if ($v != -1) {
             $value = $this->parseValue($image);
             $this->values[] = $value;
             $html .= N2Html::openTag("div", array("class" => "n2-radio-option n2-imagelist-option" . ($selected ? ' n2-active' : '')));
             $ext = pathinfo($image, PATHINFO_EXTENSION);
             if ($ext == 'svg') {
                 $image = 'data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2Filesystem::getBasePath() . $v));
             }
             $html .= N2Html::image($image, (string) $option, array('data-image' => $value));
             $html .= N2Html::closeTag("div");
         } else {
             $this->values[] = -1;
             $html .= N2Html::tag("div", array("class" => "n2-radio-option" . ($selected ? ' n2-active' : '')), (string) $option);
         }
     }
     return $html;
 }
示例#2
0
文件: uri.php 项目: vicpril/rep_bidqa
 static function pathToUri($path)
 {
     $i = N2Uri::getInstance();
     return $i->_baseuri . str_replace(array(N2Filesystem::getBasePath(), DIRECTORY_SEPARATOR), array('', '/'), str_replace('/', DIRECTORY_SEPARATOR, $path));
 }
示例#3
0
                    controlsClass: "n2-modal-controls-side",
                    controls: [\'<a href="#" class="n2-button n2-button-big n2-button-green n2-uc n2-h4">' . n2_('Select') . '</a>\'],
                    content: \'\',
                    fn: {
                        show: function () {
                            this.content.append(nextend.browse.getNode("folder"));
                            this.controls.find(".n2-button-green")
                                .on("click", $.proxy(function (e) {
                                    e.preventDefault();
                                    this.hide(e);
                                    callback(nextend.browse.getCurrentFolder());
                                }, this));
                        }
                    }
                }
            }, true);
        }';
    }
    public static function SVGToBase64($image)
    {
        $ext = pathinfo($image, PATHINFO_EXTENSION);
        if (substr($image, 0, 1) == '$' && $ext == 'svg') {
            return 'data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2ImageHelper::fixed($image, true)));
        }
        return N2ImageHelper::fixed($image);
    }
}
N2Loader::import('libraries.image.helper', 'platform');
N2ImageHelper::$protocolRelative = N2Settings::get('protocol-relative', '1');
N2ImageHelper::addKeyword('$', N2Filesystem::getBasePath(), N2Uri::getBaseUri());