##########################################################################
168504
static public function array_as_option_list(array $data, $checkedValue=NULL, $type="select", $useTemplateString=NULL, array $repArr=NULL) {
		$typeArr = array (
			"select"	=> "selected",
			"radio"		=> "checked",
			"checkbox"	=> "checked"
		);
		
		$myType = $typeArr[$type];
		if(is_null($useTemplateString)) {
			//
			$useTemplateString = "\t\t<option value='%%value%%'%%selectedString%%>%%display%%</option>";
		}
		
		$retval = "";
		foreach($data as $value=>$display) {
			//see if it's the value that's been selected.
			$selectedString = "";
			if($value == $checkedValue || $display == $checkedValue) {
				//yep, it's selected.
				$selectedString = " ". $myType;
			}
			
			//create the string.
			$myRepArr = array(
				'value'				=> $value,
				'display'			=> $display,
				'selectedString'	=> $selectedString
			);
			if(is_array($repArr) && is_array($repArr[$value])) {
				//merge the arrays.
				$myRepArr = array_merge($repArr[$value], $myRepArr);
			}
			$addThis = ToolBox::mini_parser($useTemplateString, $myRepArr, "%%", "%%");
			$retval = ToolBox::create_list($retval, $addThis, "\n");
		}
		
		return($retval);
	}
1258531
public function header()
    {
        $head = '';
        if ($this->options['rownum']) {
            $rownumTh = Html::el('th', ['style' => 'width:1px']);
            if (isset($this->options['rownum']['header']['rowspan'])) {
                $rownumTh->rowspan($this->options['rownum']['header']['rowspan']);
            }
            if (isset($this->options['rownum']['header']['before'])) {
                $head .= $this->options['rownum']['header']['before'];
            }
            $head .= $rownumTh;
            if (isset($this->options['rownum']['header']['after'])) {
                $head .= $this->options['rownum']['header']['after'];
            }

        }
        foreach ($this->columns as $colId => &$col)
        {
            $this->_prepareCol($colId);
            if (isset($col['header']['before'])) $head .= $col['header']['before'];
            if (!isset($col['header']['visible']) || $col['header']['visible']) {
                $head .= $col['th'];
            }
            if (isset($col['header']['after'])) $head .= $col['header']['after'];
        }
        unset($col);
        if ($this->options['edit'] || $this->options['delete'] || $this->options['actions']) {
            $head .= '<th style="width:1px; white-space:nowrap;"></th>';
        }

        if (!empty($this->_filters)) {
            $head .= '</tr><tr class="filters">';


            if ($this->options['rownum']) {
                $head .= '<th style="width:1px"></th>';
            }
            foreach ($this->columns as $colId => &$col)
            {
                if (isset($this->_filters[$colId]) &&
                    $this->_filters[$colId]->isActive()) {
                    $head .= '<th class="filter-active">';
                } else {
                    $head .= '<th>';
                }
                if (isset($this->_filters[$colId])) {
                    $head .= $this->_filters[$colId]->renderFilter();
                }
                $head .= '</th>';
            }
            unset($col);

            if (!$this->options['edit'] && !$this->options['delete'] && !$this->options['actions']) {
                if (substr($head, strlen($head)-9, 9) == '<th></th>') {
                    $head = substr($head,0, strlen($head)-9);
                }
            }
            //if ($this->options['edit'] || $this->options['delete']) {
                $head .= '<th style="width:1px; white-space:nowrap; vertical-align: middle">'.
                    '<button class="btn btn-info btn-xs" type="submit" onclick="return $.S4Y.grid.filter(this)"><i class="glyphicon glyphicon-filter"></i></button> '.
                    '<button class="btn btn-link btn-xs" type="reset" onclick="return $.S4Y.grid.clearFilters(this);"><i class="glyphicon glyphicon-remove"></i></button>'.
                    '</th>';
            //}

        }

        return '<tr>'.$head.'</tr>';
    }
229749
public function run()
    {
        if ($this->hasModel()) {
            $input = Html::activeTextInput($this->model, $this->attribute, $this->options);
            $this->mobileField = Html::getInputId($this->model,$this->mobileField);
        } else {
            $input = Html::textInput($this->name, $this->value, $this->options);
            $this->mobileField = $this->name;
        }
        $button = Html::button(Yii::t('yuncms', 'Get Verify Code'), $this->buttonOptions);

        $this->registerClientScript();
        echo strtr($this->template, [
            '{input}' => $input,
            '{button}' => $button,
        ]);
    }
735847
protected function _init() {
		parent::_init();
		$this->request = $this->_config['request'];

		if (!is_object($this->request) || !$this->request->params) {
			return;
		}
		$default = ['command' => null, 'action' => null, 'args' => null];
		$params = array_diff_key((array) $this->request->params, $default);

		foreach ($params as $key => $param) {
			$this->{$key} = $param;
		}
		$this->response = $this->_config['response'];

		if (!is_object($this->response)) {
			$this->response = $this->_instance('response', $this->response + [
				'plain' => $this->plain
			]);
		}
	}
1353361
public function run()
    {
        $stime = microtime(true);
        $this->header('Content-Type: text/html; charset=utf-8');
        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <title>Server status.</title>
        </head>
        <body>
        <br/>Uptime: <b><?php echo DateTime::diffAsText(Daemon::$startTime, time());
            ?></b>
        <br/><br/><b>State of workers:</b><?php $stat = Daemon::getStateOfWorkers();
        ?>
        <br/>Idle: <?php echo $stat['idle'];
        ?>
        <br/>Busy: <?php echo $stat['busy'];
        ?>
        <br/>Total alive: <?php echo $stat['alive'];
        ?>
        <br/>Shutdown: <?php echo $stat['shutdown'];
        ?>
        <br/>Pre-init: <?php echo $stat['preinit'];
        ?>
        <br/>Wait-init: <?php echo $stat['waitinit'];
        ?>
        <br/>Init: <?php echo $stat['init'];
        ?>
        <br/>
        <br/>Request took: <?php printf('%f', round(microtime(true) - $stime, 6));
        ?>
        </body>
        </html>
        <?php
    }
280745
function html()
	{
		$version = get_option('acf_version','1.0.5');
		$next = false;

		// list of starting points
		if( $version < '3.0.0' )
		{
			$next = '3.0.0';
		}
		elseif( $version < '3.1.8' )
		{
			$next = '3.1.8';
		}
		elseif( $version < '3.2.5' )
		{
			$next = '3.2.5';
		}
		elseif( $version < '3.3.3' )
		{
			$next = '3.3.3';
		}
		elseif( $version < '3.4.1' )
		{
			$next = '3.4.1';
		}

		?>
		<script type="text/javascript">
		(function($){

			function add_message(messaage)
			{
				$('#wpbody-content').append('<p>' + messaage + '</p>');
			}

			function run_upgrade(version)
			{
				$.ajax({
					url: ajaxurl,
					data: {
						action : 'acf_upgrade',
						version : version
					},
					type: 'post',
					dataType: 'json',
					success: function(json){

						if(json)
						{
							if(json.status)
							{
								add_message(json.message);

								// next update?
								if(json.next)
								{
									run_upgrade(json.next);
								}
								else
								{
									// all done
									add_message('Upgrade Complete! <a href="<?php echo admin_url(); ?>edit.php?post_type=acf">Continue to ACF &raquo;</a>');
								}
							}
							else
							{
								// error!
								add_message('Error: ' + json.message);
							}
						}
						else
						{
							// major error!
							add_message('Sorry. Something went wrong during the upgrade process. Please report this on the support forum');
						}
					}
				});
			}

			<?php if($next){ echo 'run_upgrade("' . $next . '");'; } ?>

		})(jQuery);
		</script>
		<style type="text/css">
			#message {
				display: none;
			}
		</style>
		<?php

		if(!$next)
		{
			echo '<p>No Upgrade Required</p>';
		}
	}
1233206
public function init()
    {
        /* @var $options MailOptions */
        $options = $this->getServiceLocator()
            ->getServiceLocator()
            ->get(MailOptions::class);

        $emailAddresses = $options->getAddressList();

        $addressList = [];

        foreach ($emailAddresses as $transport => $address) {

            $addressList[] = [
                'label' => $address['name'] . ' <' . $address['address'] . '>',
                'value' => $transport,
            ];
        }

        $this->setValueOptions($addressList);
    }
1228080
public function init()
	{
		if(!isset($this->htmlOptions['id']))
			$this->htmlOptions['id']=$this->id;
		else
			$this->id=$this->htmlOptions['id'];

		if($this->stateful)
			echo CHtml::statefulForm($this->action, $this->method, $this->htmlOptions);
		else
			echo CHtml::beginForm($this->action, $this->method, $this->htmlOptions);

		if($this->errorMessageCssClass===null)
			$this->errorMessageCssClass=CHtml::$errorMessageCss;
	}
1130162
public function index()
    {
        if (!userHasPermission('admin:blog:settings:\d+:update')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Load models
        $this->load->model('blog/blog_model');
        $oSkinModel = Factory::model('Skin', 'nails/module-blog');

        // --------------------------------------------------------------------------

        $this->data['blogs'] = $this->blog_model->getAllFlat();

        if (empty($this->data['blogs'])) {

            if (userHasPermission('admin:blog:blog:create')) {

                $status   = 'message';
                $message  = '<strong>You don\'t have a blog!</strong> Create a new blog ';
                $message .= 'in order to configure blog settings.';
                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setFlashData($status, $message);
                redirect('admin/blog/blog/create');

            } else {

                show404();
            }
        }

        if (count($this->data['blogs']) == 1) {

            reset($this->data['blogs']);
            $this->data['selectedBlogId'] = key($this->data['blogs']);

        } elseif ($this->input->get('blog_id')) {

            if (!empty($this->data['blogs'][$this->input->get('blog_id')])) {

                $this->data['selectedBlogId'] = $this->input->get('blog_id');
            }

            if (empty($this->data['selectedBlogId'])) {

                $this->data['error'] = 'There is no blog by that ID.';
            }
        }

        //  Check user has permission
        if (!empty($this->data['selectedBlogId'])) {

            if (!userHasPermission('admin:blog:settings:' . $this->data['selectedBlogId'] . ':update')) {

                unauthorised();
            }
        }

        //  Set up the skin model for this blog
        //  @todo; work out a cleaner way of handling this
        $oSkinModel->init($this->data['selectedBlogId']);

        // --------------------------------------------------------------------------

        //  Process POST
        if ($this->input->post()) {

            //  Prepare update
            $settings                       = array();
            $settings['name']               = $this->input->post('name');
            $settings['url']                = $this->input->post('url');
            $settings['postName']           = strtolower($this->input->post('postName'));
            $settings['postNamePlural']     = strtolower($this->input->post('postNamePlural'));
            $settings['use_excerpts']       = (bool) $this->input->post('use_excerpts');
            $settings['gallery_enabled']    = (bool) $this->input->post('gallery_enabled');
            $settings['categories_enabled'] = (bool) $this->input->post('categories_enabled');
            $settings['tags_enabled']       = (bool) $this->input->post('tags_enabled');
            $settings['rss_enabled']        = (bool) $this->input->post('rss_enabled');

            //  Skin settings
            $settings['skin'] = $this->input->post('skin');

            //  Commenting settings
            $settings['comments_enabled']          = $this->input->post('comments_enabled');
            $settings['comments_engine']           = $this->input->post('comments_engine');
            $settings['comments_disqus_shortname'] = $this->input->post('comments_disqus_shortname');

            //  Social settings
            $settings['social_facebook_enabled']   = (bool) $this->input->post('social_facebook_enabled');
            $settings['social_twitter_enabled']    = (bool) $this->input->post('social_twitter_enabled');
            $settings['social_twitter_via']        = $this->input->post('social_twitter_via');
            $settings['social_googleplus_enabled'] = (bool) $this->input->post('social_googleplus_enabled');
            $settings['social_pinterest_enabled']  = (bool) $this->input->post('social_pinterest_enabled');
            $settings['social_skin']               = $this->input->post('social_skin');
            $settings['social_layout']             = $this->input->post('social_layout');
            $settings['social_layout_single_text'] = $this->input->post('social_layout_single_text');
            $settings['social_counters']           = (bool) $this->input->post('social_counters');

            //  If any of the above are enabled, then social is enabled.
            $settings['social_enabled'] = $settings['social_facebook_enabled'] || $settings['social_twitter_enabled'] || $settings['social_googleplus_enabled'] || $settings['social_pinterest_enabled'];

            //  Sidebar
            $settings['sidebar_latest_posts']  = (bool) $this->input->post('sidebar_latest_posts');
            $settings['sidebar_categories']    = (bool) $this->input->post('sidebar_categories');
            $settings['sidebar_tags']          = (bool) $this->input->post('sidebar_tags');
            $settings['sidebar_popular_posts'] = (bool) $this->input->post('sidebar_popular_posts');

            //  @todo: Associations

            // --------------------------------------------------------------------------

            //  Sanitize blog url
            $settings['url'] .= substr($settings['url'], -1) != '/' ? '/' : '';

            // --------------------------------------------------------------------------

            //  Save
            $oAppSettingService = Factory::service('AppSetting');

            if ($oAppSettingService->set($settings, 'blog-' . $this->input->get('blog_id'))) {

                $this->data['success'] = 'Blog settings have been saved.';

                $oRoutesService = Factory::service('Routes');

                if (!$oRoutesService->update()) {

                    $this->data['warning']  = '<strong>Warning:</strong> while the blog settings were updated, the ';
                    $this->data['warning'] .= 'routes file could not be updated. The blog may not behave as expected,';
                }

            } else {

                $this->data['error'] = 'There was a problem saving settings.';
            }
        }

        // --------------------------------------------------------------------------

        //  Get data
        $this->data['skins']        = $oSkinModel->getAll();
        $this->data['skinSelected'] = $oSkinModel->getEnabled();

        if (!empty($this->data['selectedBlogId'])) {

            $this->data['settings'] = appSetting(null, 'blog-' . $this->data['selectedBlogId'], true);
        }

        // --------------------------------------------------------------------------

        //  Load assets
        $oAsset = Factory::service('Asset');
        $oAsset->load('admin.settings.min.js', 'nails/module-blog');

        // --------------------------------------------------------------------------

        //  Set page title
        $this->data['page']->title = 'Settings &rsaquo; Blog';

        if (!empty($this->data['blogs'][$this->input->get('blog_id')])) {

            $this->data['page']->title .= ' &rsaquo; ' . $this->data['blogs'][$this->input->get('blog_id')];
        }

        // --------------------------------------------------------------------------

        //  Add a header button
        if (userHasPermission('admin:blog:blog:manage')) {
            Helper::addHeaderButton(
                'admin/blog/blog/index',
                'Manage Blogs'
            );
        }

        // --------------------------------------------------------------------------

        Helper::loadView('index');
    }
504711
public function handle()
    {
        $p = $this->option('p');
        $f = $this->option('f');
        $t = $this->option('t');
        $path    = realpath(base_path());
        $appPath    = realpath(app_path());
        if($p !== null && $p !=='all') {
            if($f == 'app') {
                $hooks = $this->files->glob($appPath.'/'.$p.'/Hook/config.php');
            } else {
                $hooks = $this->files->glob($path.'/'.$p.'/Hook/config.php');
            }
            if($hooks) {
                $hookLists = $this->files->getRequire($hooks[0])['hookList'];
                $hookInjects = $this->files->getRequire($hooks[0])['hookInject'];
                $this->initHook($hookLists, $t);
                $this->initHookInject($hookInjects, $t);
            }
        } else if($p !== null && $p === 'all') {
            // $defaultHookList = config('hook.default.hookList');
            // $defaulHookInject = config('hook.default.hookInject');
            // $this->initHook($defaultHookList);
            // $this->initHookInject($defaulHookInject);
            $hooks = $this->files->glob($appPath.'/Hook/config.php');
            if($hooks) {
                $hookLists = $this->files->getRequire($hooks[0])['hookList'];
                $hookInjects = $this->files->getRequire($hooks[0])['hookInject'];
                $this->initHook($hookLists);
                $this->initHookInject($hookInjects);
            }
            $mhooks = $this->files->glob($appPath.'/Modules/*/Hook/config.php');
            if($mhooks) {
                foreach ($mhooks as $hook) {
                    $hookLists = $this->files->getRequire($hook)['hookList'];
                    $hookInjects = $this->files->getRequire($hook)['hookInject'];
                    $this->initHook($hookLists);
                    $this->initHookInject($hookInjects);
                }
            }
            $vhooks = $this->files->glob($path.'/vendor/huasituo/*/src/Hook/config.php');
            if($vhooks) {
                foreach ($vhooks as $hook) {
                    $hookLists = $this->files->getRequire($hook)['hookList'];
                    $hookInjects = $this->files->getRequire($hook)['hookInject'];
                    $this->initHook($hookLists);
                    $this->initHookInject($hookInjects);
                }
            }
        }
        $data = HookModel::setCache();
        $injectAll = HookInjectModel::setAllCache();
        $inject = HookInjectModel::setCache();
        $this->info('hook cache ok!');
    }
970680
public function init()
    {
        if ($this->countRows < 1) {
            $this->totalPages = 0;
            $this->currentPage = 0;

            return;
        }

        if ($this->limit < 10) {
            $this->limit = 10;
        }

        $this->totalPages = (int)($this->countRows / $this->limit);

        if ($this->countRows % $this->limit) {
            $this->totalPages++;
        }

        if ($this->totalPages === 0) {
            $this->totalPages = 1;
        }

        if ($this->currentPage < 0) {
            $this->currentPage = 0;
        }

        if ($this->currentPage > $this->totalPages) {
            $this->currentPage = $this->totalPages;
        }
    }
491783
public function index()
    {
        $this->requireAdmin();

        $this->layout->title = Lang::get('settings');

        $this->view->settings = $this->settings;

        $basicSettings = array();
        if (isset($this->settings['phpci']['basic'])) {
            $basicSettings = $this->settings['phpci']['basic'];
        }

        $buildSettings = array();
        if (isset($this->settings['phpci']['build'])) {
            $buildSettings = $this->settings['phpci']['build'];
        }

        $latestBuildsSettings = array();
        if (isset($this->settings['phpci']['latest_builds'])) {
            $latestBuildsSettings = $this->settings['phpci']['latest_builds'];
        }

        $emailSettings = array();
        if (isset($this->settings['phpci']['email_settings'])) {
            $emailSettings = $this->settings['phpci']['email_settings'];
        }

        $authSettings = array();
        if (isset($this->settings['phpci']['authentication_settings'])) {
            $authSettings = $this->settings['phpci']['authentication_settings'];
        }

        $this->view->configFile = PHPCI_CONFIG_FILE;
        $this->view->basicSettings = $this->getBasicForm($basicSettings);
        $this->view->latestBuildsSettings = $this->getLatestBuildsForm($latestBuildsSettings);
        $this->view->buildSettings = $this->getBuildForm($buildSettings);
        $this->view->github = $this->getGithubForm();
        $this->view->emailSettings = $this->getEmailForm($emailSettings);
        $this->view->authenticationSettings = $this->getAuthenticationForm($authSettings);
        $this->view->isWriteable = $this->canWriteConfig();

        if (!empty($this->settings['phpci']['github']['token'])) {
            $this->view->githubUser = $this->getGithubUser($this->settings['phpci']['github']['token']);
        }

        return $this->view->render();
    }
1355465
public function run()
    {
        /* @var $user CWebUser */
        $user = Yii::app()->getUser();
        if (count($user->getFlashes(false)) == 0) {
            return;
        }
        echo TbHtml::openTag('div', $this->htmlOptions);
        foreach ($this->alerts as $color => $alert) {
            if (isset($alert['visible']) && !$alert['visible']) {
                continue;
            }

            if ($user->hasFlash($color)) {
                $htmlOptions = TbArray::popValue('htmlOptions', $alert, array());
                TbArray::defaultValue('closeText', $this->closeText, $htmlOptions);
                TbArray::defaultValue('block', $this->block, $htmlOptions);
                TbArray::defaultValue('fade', $this->fade, $htmlOptions);
                echo TbHtml::alert($color, $user->getFlash($color), $htmlOptions);
            }
        }
        echo '</div>';
        $this->registerEvents("#{$this->htmlOptions['id']} > .alert", $this->events);
    }
350634
public function run() {
		
		echo CHtml::openTag('div', $this->htmlOptions);
		if (empty($this->stacked)) {
			echo '<div class="'.implode(' ', $this->progressBarClasses).'" style="width: ' . $this->percent . '%;">' . $this->content . '</div>';
		} elseif (is_array($this->stacked)) {
			foreach ($this->stacked as $bar) {
				$options = isset($bar['htmlOptions']) ? $bar['htmlOptions'] : array();
				if (empty($options['style'])) {
					$options['style'] = '';
				} else {
					$options['style'] .= ' ';
				}
				$options['style'] .= 'width: ' . $bar['percent'] . '%';

				if (empty($options['class'])) {
					$options['class'] = '';
				} else {
					$options['style'] .= ' ';
				}
				$options['class'] .= 'progress-bar progress-bar-' . $bar['context'];

				echo '<div ' . CHtml::renderAttributes($options) . '>' . @$bar['content'] . '</div>';
			}
		}
		echo CHtml::closeTag('div');
	}
753938
public function run()
	{
		$id=$this->getId();
		if(isset($this->htmlOptions['id']))
			$id=$this->htmlOptions['id'];
		else
			$this->htmlOptions['id']=$id;

		$options=CJavaScript::encode($this->options);
		Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').sortable({$options});");

		echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
		foreach($this->items as $id=>$content)
			echo strtr($this->itemTemplate,array('{id}'=>$id,'{content}'=>$content))."\n";
		echo CHtml::closeTag($this->tagName);
	}
465635
public function init()
    {
        $this->data['host']     = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
        $this->data['script']   = (isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '');
        $this->data['uri']      = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '');
        $this->data['query']    = (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');
        $this->data['name']     = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '');
        $this->data['referer']  = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
        $this->data['protocol'] = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
        $this->data['scheme']   = (isset($_SERVER['HTTPS']) ? 'https://' : 'Http://');
        $this->data['is_post']  = (isset($_SERVER['REQUEST_METHOD']) ? 'POST' == $_SERVER['REQUEST_METHOD'] : false);
        $this->data['is_get']   = (isset($_SERVER['REQUEST_METHOD']) ? 'GET' == $_SERVER['REQUEST_METHOD'] : false);
        $this->data['is_ajax']  = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) ? true : false);

        if (isset($_SERVER['REMOTE_ADDR'])) {
            $this->data['ip'] = $_SERVER['REMOTE_ADDR'];
        } else {
            $this->data['ip'] = 'localhost';
        }
    }
1231042
public function init() {
		
		if (!isset($this->htmlOptions['id'])) {
			$this->htmlOptions['id'] = $this->getId();
		}

		if (isset($this->parent) && !isset($this->options['parent'])) {
			$this->options['parent'] = $this->parent;
		}

		if (isset($this->toggle) && !isset($this->options['toggle'])) {
			$this->options['toggle'] = $this->toggle;
		}

		// NOTE: we depend on the htmlOptions being initialized to empty array already.
		if (empty($this->htmlOptions['class'])) {
			$this->htmlOptions['class'] = 'collapse';
		} else {
			$this->htmlOptions['class'] .= ' collapse';
		}
		echo CHtml::openTag($this->tagName, $this->htmlOptions);
	}