示例#1
0
	public static function getInstance() {      

        if (!isset(self::$_instance)) {

            // init vars
            $path = dirname(__FILE__);
            self::$_instance = new Warp();

            // add default helper
            self::$_instance->addHelper(new PathWarpHelper());

            // set default paths
            self::$_instance['path']->register($path, 'warp');
            self::$_instance['path']->register($path.'/classes', 'classes');
            self::$_instance['path']->register($path.'/helpers', 'helpers');
            self::$_instance['path']->register($path.'/libraries', 'lib');
            self::$_instance['path']->register($path.'/css', 'css');
            self::$_instance['path']->register($path.'/js', 'js');
            self::$_instance['path']->register($path.'/layouts', 'layouts');
            self::$_instance['path']->register($path.'/menus', 'menu');
            self::$_instance['path']->register(dirname($path), 'template');
        }

        return self::$_instance;
    }
示例#2
0
	public function __construct() {

		// set default name
		$this->warp = Warp::getInstance();
		$this->name = strtolower(basename(get_class($this), 'WarpHelper'));

	}
示例#3
0
文件: warp.php 项目: smart-one/3kita
 function &getInstance()
 {
     static $instance;
     if (!isset($instance)) {
         $instance = new Warp();
         $path = dirname(__FILE__);
         // add default helper
         $instance->addHelper(new WarpHelperPath());
         // set default paths
         $instance->path->register($path, 'warp');
         $instance->path->register($path . '/helpers', 'helpers');
         $instance->path->register($path . '/libraries', 'lib');
         $instance->path->register($path . '/css', 'css');
         $instance->path->register($path . '/js', 'js');
         $instance->path->register($path . '/layouts', 'layouts');
         $instance->path->register($path . '/menus', 'menu');
         $instance->path->register(dirname($path), 'template');
         $instance->loadHelper(array('legacy', 'template', 'menu'));
     }
     return $instance;
 }
示例#4
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        // load config
        require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/config.php';
        // get warp and helpers
        $warp =& Warp::getInstance();
        $path =& $warp->getHelper('path');
        $check =& $warp->getHelper('checksum');
        // verify theme files
        $content = array();
        if (($checksums = $path->path('template:checksums')) && filesize($checksums)) {
            $check->verify($path->path('template:'), $log);
            if (count($log)) {
                $content[] = 'Some template files have been modified. <a href="#" class="verify-link">Click to show files.</a>';
                $content[] = '<ul class="verify">';
                foreach (array('modified', 'missing') as $type) {
                    if (isset($log[$type])) {
                        foreach ($log[$type] as $file) {
                            $content[] = '<li class="' . $type . '">' . $file . ($type == 'missing' ? ' (missing)' : null) . '</li>';
                        }
                    }
                }
                $content[] = '</ul>';
            } else {
                $content[] = 'Verification successful, no file modifications detected.';
            }
        } else {
            $content[] = 'Checksum file is missing! Your template is maybe compromised.';
        }
        ob_start();
        ?>
			
		<script type="text/javascript">
		
			window.addEvent('domready', function(){
				var ul = document.getElement("ul.verify");

				if (ul) {
					ul.setStyle('display', 'none');
				   	document.getElement("a.verify-link").addEvent("click", function(event){
						var event = new Event(event).stop();
						ul.setStyle('display', ul.getStyle('display') == 'none' ? 'block' : 'none');
					});
				}
			});
      
		</script>
		
		<?php 
        return implode("\n", $content) . ob_get_clean();
    }
示例#5
0
 function widget($args, $instance)
 {
     global $wp_query;
     extract($args);
     $title = $instance['title'];
     $warp = Warp::getInstance();
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $output = $warp['template']->get('sidebar.output', "");
     echo $output;
     echo $after_widget;
 }
 protected function getInput()
 {
     // copy callback
     $this->copyAjaxCallback();
     // load config
     require_once dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/config.php';
     // get warp
     $warp = Warp::getInstance();
     $warp['system']->document->addScript($warp['path']->url('config:js/config.js'));
     $warp['system']->document->addScript($warp['path']->url('config:js/admin.js'));
     $warp['system']->document->addStyleSheet($warp['path']->url('config:css/config.css'));
     $warp['system']->document->addStyleSheet($warp['path']->url('config:css/admin.css'));
     // render config
     return $warp['template']->render('config:layouts/config');
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     // copy callback
     $this->copyAjaxCallback();
     // load config
     require_once dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/config.php';
     // get warp
     $warp = Warp::getInstance();
     $warp['system']->document->addScript($warp['path']->url('lib:jquery/jquery.js'));
     $warp['system']->document->addScript($warp['path']->url('config:js/config.js'));
     $warp['system']->document->addScript($warp['path']->url('config:js/admin.js'));
     $warp['system']->document->addStyleSheet($warp['path']->url('config:css/config.css'));
     $warp['system']->document->addStyleSheet($warp['path']->url('config:css/admin.css'));
     // render config
     return $warp['template']->render('config:layouts/config');
 }
<?php

/**
* @package   yoo_shelf Template
* @file      error.php
* @version   1.0.0 August 2011
* @author    YOOtheme http://www.yootheme.com
* @copyright Copyright (C) 2007 - 2011 YOOtheme GmbH
* @license   YOOtheme Proprietary Use License (http://www.yootheme.com/license)
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// include config
include_once dirname(__FILE__) . '/config.php';
// get warp
$warp = Warp::getInstance();
// set messages
$title = $this->title;
$error = $this->error->code;
$message = $this->error->message;
// set 404 messages
if ($error == '404') {
    $title = JText::_('404 PAGE TITLE');
    $message = JText::sprintf('404 PAGE MESSAGE', $warp['system']->url, $warp['config']->get('site_name'));
}
// render error layout
echo $warp['template']->render('error', compact('title', 'error', 'message'));
示例#9
0
    protected function getInput()
    {
        // load config
        require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/config.php';
        // get warp
        $warp = Warp::getInstance();
        // get presets
        $presets = $warp->config->get('_presets', array());
        ob_start();
        ?>
		
			<select id="selectPreset" style="width:200px;">
				<option value="-1">Please choose a preset...</option>
				<?php 
        foreach ($presets as $key => $preset) {
            ?>
					<option value="<?php 
            echo $key;
            ?>
"><?php 
            echo $preset['name'];
            ?>
</option>
				<?php 
        }
        ?>
			</select>
			
			<script type="text/javascript">
			
				window.addEvent('domready', function(){
				   document.getElement("#selectPreset").addEvent("change", function(){
						
						var warp_presets = <?php 
        echo json_encode($presets);
        ?>
;
						var select 		 = this;
						
						if (select.value == -1) return;

						var preset = warp_presets[select.value];
						var elements = document.getElements(".panel [name^=jform]");
						
						for(var i=0;i<elements.length;i++){
							var node  = elements[i];
							var $name = node.name.replace("jform[params][",'').replace("]",'');

							if(preset.options[$name] || preset.options[$name]===0){
								if(node.type=='radio') {
									if(node.value==preset.options[$name]) node.setProperty('checked',true);
								} else {
									node.value = preset.options[$name];
								}
							}

						}

						//select.selectedIndex = 0;
					});
				});
       
			</script>
		
		<?php 
        return ob_get_clean();
    }
示例#10
0
 public function render($content = ' ', $title = false, array $module = array(), $attribs = array())
 {
     /*
     		KLoader::load('lib.joomla.application.module.helper');
     		$load =& JModuleHelper::_load();
     		$load[] = (object) array(
     			'id' => 50,
     			'title' => $title,
     			     'module' => 'mod_custom',
     			     'position' => 'above',
     			     'content' => $content,
     			     'showtitle' => 1,
     			     'control' => '',
     			     'params' => '
     			moduleclass_sfx=-slide red
     			cache=0
     			
     			',
     			     'user' => 0,
     			     'name' => 'custom',
     			     //'style' => isset($module['style']) ? $module['style'] : 'rounded',
     			     'style' => 'xhtml'
     		);
     		return null;
     		die('<pre>'.print_r($load, true).'</pre>');
     		//*/
     /*
     	 0 => 
     stdClass::__set_state(array(
        'id' => '50',
        'title' => 'Breadcrumb',
        'module' => 'mod_breadcrumbs',
        'position' => 'breadcrumb',
        'content' => '',
        'showtitle' => '0',
        'control' => '',
        'params' => 'showHome=1
     	homeText=Home
     	showLast=1
     	separator=
     	moduleclass_sfx=
     	cache=0
     	
     	',
        'user' => 0,
        'name' => 'breadcrumbs',
        'style' => NULL,
     )),
     */
     $tmp = $module;
     $module = new KObject();
     $module->params = 'moduleclass_sfx=' . @$tmp['moduleclass_sfx'];
     $module->module = 'mod_' . $this->_identifier->package . '_' . $this->_identifier->name;
     $module->id = KFactory::tmp('lib.koowa.filter.int')->sanitize(uniqid());
     $module->title = (string) $title;
     $module->style = isset($tmp['style']) ? $tmp['style'] : 'rounded';
     $module->position = $this->_identifier->package . '-' . $this->_identifier->name;
     $module->showtitle = (bool) $title;
     $module->name = $this->_identifier->package . '_' . $this->_identifier->name;
     $module->user = 0;
     $module->content = $content;
     $module->set($tmp);
     if (!isset($attribs['name'])) {
         $attribs['name'] = $module->position;
     }
     if (!isset($attribs['style'])) {
         $attribs['style'] = $module->style;
     }
     if (!isset($attribs['first'])) {
         $attribs['first'] = null;
     }
     if (!isset($attribs['last'])) {
         $attribs['last'] = null;
     }
     if (($yoofix = JPATH_THEMES . DS . KFactory::get('lib.joomla.application')->getTemplate() . DS . 'lib' . DS . 'php' . DS . 'template.php') && ($isYoo = file_exists($yoofix))) {
         require_once $yoofix;
     }
     if ($isYoo) {
         $attribs['style'] = 'yoo';
     }
     static $chrome;
     $mainframe = JFactory::getApplication();
     $scope = $mainframe->scope;
     //record the scope
     $mainframe->scope = $module->module;
     //set scope to Component name
     // Get module parameters
     $params = new JParameter($module->params);
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = JPATH_BASE . DS . 'modules' . DS . $module->module . DS . $module->module . '.php';
     // Load the module
     if (!$module->user && file_exists($path) && empty($module->content)) {
         $lang =& JFactory::getLanguage();
         $lang->load($module->module);
         $content = '';
         ob_start();
         require $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     KLoader::load('lib.joomla.application.module.helper');
     $load =& JModuleHelper::_load();
     if (!$this->_modules) {
         $this->_modules_backup = $this->_modules = $load;
     }
     $this->_modules[] = $module;
     $load = $this->_modules;
     require_once JPATH_BASE . DS . 'templates' . DS . 'system' . DS . 'html' . DS . 'modules.php';
     $chromePath = JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             require_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     //make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'rounded';
     }
     //dynamically add outline style
     if (JRequest::getBool('tp')) {
         $attribs['style'] .= ' outline';
     }
     $tpl = KFactory::get('lib.joomla.application')->getTemplate();
     $yoofix = false;
     $warpfive = 'templates/' . $tpl . '/layouts/module.php';
     if (JFile::exists(JPATH_ROOT . '/' . $warpfive)) {
         $tpl_dir = JPATH_ROOT . "/templates/{$tpl}";
         //include warp
         require_once $tpl_dir . '/warp/warp.php';
         $warp = Warp::getInstance();
         $warp->getHelper('path')->register($tpl_dir . '/warp/systems/joomla.1.5/helpers', 'helpers');
         $warp->getHelper('path')->register($tpl_dir . '/warp/systems/joomla.1.5/layouts', 'layouts');
         $warp->getHelper('path')->register($tpl_dir . '/layouts', 'layouts');
         $template = KFactory::tmp($this->getTemplate())->addFilters(array('alias'));
         $template->getFilter('alias')->append(array('$this' => '$warp_helper_template'));
         $data = array('warp_helper_template' => $warp->getHelper("template"), '$warp' => $warp);
         $module->menu = false;
         $yoofix = true;
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         //Warp 5.5 fix
         if ($yoofix) {
             $module->parameter = new JParameter($module->params);
             $data['module'] = $module;
             $data['params'] = array();
             //@TODO count this
             $count = 1;
             $index = 0;
             $data['params']['count'] = $count;
             $data['params']['order'] = $index + 1;
             $data['params']['first'] = $data['params']['order'] == 1;
             $data['params']['last'] = $data['params']['order'] == $count;
             $data['params']['suffix'] = $module->parameter->get('moduleclass_sfx', '');
             $data['params']['menu'] = false;
             // get class suffix params
             $parts = preg_split('/[\\s]+/', $data['params']['suffix']);
             foreach ($parts as $part) {
                 if (strpos($part, '-') !== false) {
                     $yoostyles = explode('-', $part, 2);
                     $data['params'][$yoostyles[0]] = $yoostyles[1];
                 }
             }
             $module->content = $template->loadPath($warpfive, $data)->render(true);
         } elseif (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     $mainframe->scope = $scope;
     //revert the scope
     return $module->content;
 }
示例#11
0
 function __construct()
 {
     // set default name
     $this->warp =& Warp::getInstance();
     $this->name = strtolower(substr(get_class($this), strlen(__CLASS__)));
 }
示例#12
0
 public function start_el(&$output, $item, $depth, $args)
 {
     // get warp
     $warp = Warp::getInstance();
     // init vars
     $data = array();
     $classes = empty($item->classes) ? array() : (array) $item->classes;
     $options = $warp['system']->getMenuItemOptions($item->ID);
     // set id
     $data['data-id'] = $item->ID;
     // is current item ?
     if (in_array('current-menu-item', $classes) || in_array('current_page_item', $classes)) {
         $data['data-menu-active'] = 2;
         // home/fronpage item
     } elseif ($item->url == 'index.php' && (is_home() || is_front_page())) {
         $data['data-menu-active'] = 2;
     }
     // has columns ?
     if (!empty($options['columns'])) {
         $data['data-menu-columns'] = (int) $options['columns'];
     }
     // has columnwidth ?
     if (!empty($options['columnwidth'])) {
         $data['data-menu-columnwidth'] = (int) $options['columnwidth'];
     }
     // has image ?
     if (!empty($options['image'])) {
         $upload = wp_upload_dir();
         $data['data-menu-image'] = trailingslashit($upload['baseurl']) . $options['image'];
     }
     // set item attributes
     $attributes = '';
     foreach ($data as $name => $value) {
         $attributes .= sprintf(' %s="%s"', $name, esc_attr($value));
     }
     // create item output
     $id = apply_filters('nav_menu_item_id', '', $item, $args);
     $output .= '<li' . (strlen($id) ? sprintf(' id="%s"', esc_attr($id)) : '') . $attributes . '>';
     // set link attributes
     $attributes = '';
     foreach (array('attr_title' => 'title', 'target' => 'target', 'xfn' => 'rel', 'url' => 'href') as $var => $attr) {
         if (!empty($item->{$var})) {
             $attributes .= sprintf(' %s="%s"', $attr, esc_attr($item->{$var}));
         }
     }
     // escape link title
     $item->title = htmlspecialchars($item->title, ENT_COMPAT, "UTF-8");
     // is separator ?
     if ($item->url == '#') {
         $format = '%s<span%s><span>%s</span></span>%s';
         $attributes = ' class="separator"';
     } else {
         $format = '%s<a%s><span>%s</span></a>%s';
     }
     // create link output
     $item_output = sprintf($format, $args->before, $attributes, $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after, $args->after);
     $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
 }
示例#13
0
        function mytheme_comment($comment, $args, $depth)
        {
            global $user_identity;
            $GLOBALS['comment'] = $comment;
            $warp = Warp::getInstance();
            $_GET['replytocom'] = get_comment_ID();
            ?>
					<li>
						<article id="comment-<?php 
            comment_ID();
            ?>
" class="comment <?php 
            echo $comment->user_id > 0 ? 'comment-byadmin' : '';
            ?>
">
					 
							<header class="comment-head">
							
								<?php 
            echo get_avatar($comment, $size = '50', get_bloginfo('template_url') . '/images/comments_avatar.png');
            ?>
								
								<h4 class="author"><?php 
            echo get_comment_author_link();
            ?>
</h4>
							
								<p class="meta">
									<time datetime="<?php 
            echo get_comment_date('Y-m-d');
            ?>
" pubdate><?php 
            printf(__('%1$s at %2$s', 'warp'), get_comment_date(), get_comment_time());
            ?>
</time>
									| <a class="permalink" href="<?php 
            echo htmlspecialchars(get_comment_link($comment->comment_ID));
            ?>
">#</a>
									<?php 
            edit_comment_link(__('Edit'), '| ', '');
            ?>
								</p>
							
							</header>
							
							<div class="comment-body">
							
								<div class="content"><?php 
            comment_text();
            ?>
</div>
								
								<?php 
            if (comments_open()) {
                ?>
								<p class="reply"><a href="#" rel="<?php 
                comment_ID();
                ?>
"><?php 
                echo __('Reply', 'warp');
                ?>
</a></p>
								<?php 
            }
            ?>
									
								<?php 
            if ($comment->comment_approved == '0') {
                ?>
								<p class="moderation"><?php 
                _e('Your comment is awaiting moderation.', 'warp');
                ?>
</p>
								<?php 
            }
            ?>
								
							</div>
							
						</article>
					<?php 
            unset($_GET['replytocom']);
            // </li> is rendered by system
        }
示例#14
0
文件: cache.php 项目: bizanto/Hooked
 function _buildPath($matches, $base = null, $filepath = null)
 {
     static $_base;
     static $_filepath;
     if (isset($base)) {
         $_base = $base;
     }
     if (isset($filepath)) {
         $_filepath = $filepath;
     }
     // prefix with base and remove '../' segments where possible
     $path = $_base . $matches[1];
     $last = '';
     while ($path != $last) {
         $last = $path;
         $path = preg_replace('`(^|/)(?!\\.\\./)([^/]+)/\\.\\./`', '$1', $path);
     }
     // map image to file path
     if (preg_match('/\\.(gif|png|jpg)$/i', $matches[1])) {
         $warp =& Warp::getInstance();
         $warp->cache->images[sprintf('url(%s)', $path)] = realpath(rtrim($_filepath, '/') . '/' . $matches[1]);
     }
     return sprintf('url(%s)', $path);
 }
示例#15
0
    protected function getInput()
    {
        // load config
        require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/config.php';
        // get warp and helpers
        $warp =& Warp::getInstance();
        $path =& $warp->getHelper('path');
        $check =& $warp->getHelper('checksum');
        // verify theme files
        $content = array('<div style="margin: 5px 0px;float: left;">');
        if (($checksums = $path->path('template:checksums')) && filesize($checksums)) {
            $check->verify($path->path('template:'), $log);
            if (count($log)) {
                $content[] = 'Some template files have been modified. <a href="#" class="verify-link">Click to show files.</a>';
                $content[] = '<ul class="verify">';
                foreach (array('modified', 'missing') as $type) {
                    if (isset($log[$type])) {
                        foreach ($log[$type] as $file) {
                            $content[] = '<li class="' . $type . '">' . $file . ($type == 'missing' ? ' (missing)' : null) . '</li>';
                        }
                    }
                }
                $content[] = '</ul>';
            } else {
                $content[] = 'Verification successful, no file modifications detected.';
            }
        } else {
            $content[] = 'Checksum file is missing! Your template is maybe compromised.';
        }
        $content[] = '</div>';
        ob_start();
        ?>

		<style type="text/css">

			ul.verify {
				margin: 5px 0px 0px 0px;
				padding: 5px;
				background: #EEE;
				-moz-border-radius: 5px;
				-webkit-border-radius: 5px;
				border-radius: 5px;
			}

			ul.verify li {
				margin: 5px;
				padding: 0px;
			}

			ul.verify li.missing {
				color: red;
			}

		</style>
			
		<script type="text/javascript">
		
			window.addEvent('domready', function(){
				var ul = document.getElement("ul.verify");

				if (ul) {
					ul.setStyle('display', 'none');
				   	document.getElement("a.verify-link").addEvent("click", function(event){
						var event = new Event(event).stop();
						ul.setStyle('display', ul.getStyle('display') == 'none' ? 'block' : 'none');
					});
				}
			});
      
		</script>
		
		<?php 
        return implode("\n", $content) . ob_get_clean();
    }